From patchwork Thu Jan 11 11:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 761801 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2335691wrz; Thu, 11 Jan 2024 03:06:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGg4zIy+OEYeqziuo+/nPt3MHO4Qinwx/Hdd3EroP1Hlcm7la0pOIci5g20FsVjdH+6bmvL X-Received: by 2002:a05:6808:1209:b0:3bd:369d:4bb1 with SMTP id a9-20020a056808120900b003bd369d4bb1mr1116070oil.87.1704971196558; Thu, 11 Jan 2024 03:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704971196; cv=none; d=google.com; s=arc-20160816; b=UFzBYWCDORXPOrh4IDcaTCSODiAfKj8DcORxUEsmSKv/pjb5EjZMIVTk4pEvlosl7H 1tZZ9JW10elwHm50q1tPHjqC9Q9VWNQTPUWdQdKW/0OB2aqleK7+5GaKWO7J9BwYjJTV qjiPatmbtbMJLxZ0S2kNLU6HZygwc1h2SaoEYnXMh2yOqG3YpIrEOwTnMr+p2wJMFen+ IOa4WdRNT4nTh7z8PtnsZ7nMyXibe3Vl1+/tQPxGW4JjKMujbb+fbDSKEomjFhDcem/I quPnRl/uLsEr9EiGYvX0ZepU9nS/WHQZ0zh3qw3LWSIxgCg4ZwLU9z4SKf49gO2Mjutm mA0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eJ2Bh2KqWHFGhwYEJgAtL+OLtHKA2aP7b6zI0XswIFc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=ilxNbsysiyLgPW7xWIqBTTka872XfrW6vnjeDo34vTobbkxMlwzdMWegpbpXqpspGN HiQ48jEV4gUWSFnNLn6aClWbgNEB4RGyzcJt+4o6ouyLGLlVOcvXobglAtZ2CeqT/LRR b/Bb3oGxwIhBB6E5Wx8Db5cTC6uU98TXkkdiMPhx+YIV1lUqlM/dzpmLby0T0gq/CnKX uVYtkC2m30u+QGS7PhL1Np03czgF7a47FMl4ny6mVXOBSr8PBb3Xla+rHuUDjQbla0d4 tAjHbuyNz7E5RF9lxaCwpirAUk9MDUdYFr3GCHxxVuSuF5dLYHKAPMmmTKs3/jOGFnv4 94NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DsriuO8d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d8-20020a0cdb08000000b0067f969bf1d6si567392qvk.272.2024.01.11.03.06.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 03:06:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DsriuO8d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNssf-0001bC-Uj; Thu, 11 Jan 2024 06:05:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNssE-0001OA-3V for qemu-devel@nongnu.org; Thu, 11 Jan 2024 06:05:25 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNssB-0004TD-Pm for qemu-devel@nongnu.org; Thu, 11 Jan 2024 06:05:21 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33761e291c1so3051028f8f.0 for ; Thu, 11 Jan 2024 03:05:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704971118; x=1705575918; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eJ2Bh2KqWHFGhwYEJgAtL+OLtHKA2aP7b6zI0XswIFc=; b=DsriuO8dhxbadttNkhkihV2kjaBlI3gnEnhwUomciI134r7uChbnBLUNNc68RLOS+3 zneqOPRRXVcq3TdLNU909eer9zZGsDKIRdJPtG9cEUsKuhcfVV05z3z4CErJWWMXyCxR 5+st7BqwluPO48wyyei9RoA2VGqfAGMwoUs03H9b2BCkjQ0fa9UYZ79TTQDWpQLSIjcp iDJ1AmU9c8wlMmCFM46vyUQc/p3b3RsKbeeyCAZImdpuO3kpGJcJe1hmNN6HCr8IV/uI t0L0klLWk/PjYSrEV16bQUpOj4opeH1Uz4e/uhoV77mQDa20xuMyjVHb+ks75w1l9B/I gbzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704971118; x=1705575918; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eJ2Bh2KqWHFGhwYEJgAtL+OLtHKA2aP7b6zI0XswIFc=; b=KkB3ZdZ6gVEOoXw2lRIDRvlOOpA7GnsXpEPglpmEWF4in9RcYfJ96XMhg7//No+rk+ TkB3OlOKFqwy566Qiguu2v/0L8FEGB3kKDZKW7fkWWjUWuS8cxBbmVOVyll50/NHxuFI QZ2ClwkGpF94FtxSdKaJ1EfFkQkXnsOGj+daqxd8A0n5/kI98fMVrh7cq/kCIlnHJZqS GRgfTmcJpXHre6R/hI0UPc3DVqzLYxvzFk6BbOPk5fBXlElpCAv/XfLREwIF85tr2F0r eHGaCTyD/QeUwr/0YJ9fbsqRiYktYvFIOvSrnv4YZ9OEWABbVKrRezxCP8zX5x1nb7o/ 7oRw== X-Gm-Message-State: AOJu0Yxe/7/jBPPmg14+e2CYFjknQPEoy7F1svfAsL2tqFFptaGFVdWD zq7sNtD3YpL8maRq/32qdT1Vf4SJ0KbYr4eupLVc4LuEYpQ= X-Received: by 2002:a05:600c:520d:b0:40e:622f:ebf with SMTP id fb13-20020a05600c520d00b0040e622f0ebfmr128544wmb.178.1704971118097; Thu, 11 Jan 2024 03:05:18 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v30-20020adf8b5e000000b0033690139ea5sm951323wra.44.2024.01.11.03.05.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:05:17 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/41] target/arm: Handle FEAT_NV page table attribute changes Date: Thu, 11 Jan 2024 11:04:50 +0000 Message-Id: <20240111110505.1563291-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240111110505.1563291-1-peter.maydell@linaro.org> References: <20240111110505.1563291-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org FEAT_NV requires that when HCR_EL2.{NV,NV1} == {1,1} the handling of some of the page table attribute bits changes for the EL1&0 translation regime: * for block and page descriptors: - bit [54] holds PXN, not UXN - bit [53] is RES0, and the effective value of UXN is 0 - bit [6], AP[1], is treated as 0 * for table descriptors, when hierarchical permissions are enabled: - bit [60] holds PXNTable, not UXNTable - bit [59] is RES0 - bit [61], APTable[0] is treated as 0 Implement these changes to the page table attribute handling. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Miguel Luis --- target/arm/ptw.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0ecd3a36dad..2d4fa8dbcaf 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1581,6 +1581,12 @@ static bool lpae_block_desc_valid(ARMCPU *cpu, bool ds, } } +static bool nv_nv1_enabled(CPUARMState *env, S1Translate *ptw) +{ + uint64_t hcr = arm_hcr_el2_eff_secstate(env, ptw->in_space); + return (hcr & (HCR_NV | HCR_NV1)) == (HCR_NV | HCR_NV1); +} + /** * get_phys_addr_lpae: perform one stage of page table walk, LPAE format * @@ -1989,6 +1995,21 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, xn = extract64(attrs, 54, 1); pxn = extract64(attrs, 53, 1); + if (el == 1 && nv_nv1_enabled(env, ptw)) { + /* + * With FEAT_NV, when HCR_EL2.{NV,NV1} == {1,1}, the block/page + * descriptor bit 54 holds PXN, 53 is RES0, and the effective value + * of UXN is 0. Similarly for bits 59 and 60 in table descriptors + * (which we have already folded into bits 53 and 54 of attrs). + * AP[1] (descriptor bit 6, our ap bit 0) is treated as 0. + * Similarly, APTable[0] from the table descriptor is treated as 0; + * we already folded this into AP[1] and squashing that to 0 does + * the right thing. + */ + pxn = xn; + xn = 0; + ap &= ~1; + } /* * Note that we modified ptw->in_space earlier for NSTable, but * result->f.attrs retains a copy of the original security space.