From nobody Sat Nov 23 18:00:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1731943576; cv=none; d=zohomail.com; s=zohoarc; b=RUN5nyVsPnYL+Si7nYRdsoSxjoVuU93eFU7Yl55zK1IW/9CbxOsm0QCfiyqvxs8iX1WS68OctcxxXdjTfela6dXPTTz47zDkJT9Y62//O8vth6XvGcLh36q0/5lJ9hr3nNejRFbJPQRaavf7OGnN9+CtvOEwRO/hC0xxhidD7Yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731943576; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=akSdSGiRTfyLnN0cC+NRUPJFGXfzjIlmKD+aKjcrBGM=; b=lJrxgFZMDbopQF4IFXQXIhmq99hsKwXTw0bg+boRXhhcb9vaGU6Ueb5FQy8YnXWTBvjfUy308D4e32IN4L4Mev2jCjOJ2U1MNtpgOloP8yqggVEI8mxWMyBct3fRTYNEQxIfx7GxseKrHCVmflp3RLNsCKTLbCHI4Ubqa0EWLRc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731943576940785.9232848202338; Mon, 18 Nov 2024 07:26:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tD3dC-0002p7-BR; Mon, 18 Nov 2024 10:25:38 -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 1tD3dB-0002oc-7p; Mon, 18 Nov 2024 10:25:37 -0500 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tD3d9-0004b5-Bv; Mon, 18 Nov 2024 10:25:36 -0500 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2fb51e00c05so24456001fa.0; Mon, 18 Nov 2024 07:25:34 -0800 (PST) Received: from fedora.. ([2a00:1370:8180:90b:d00f:257f:ffb:ac70]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ff69ae7fb8sm9498981fa.87.2024.11.18.07.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 07:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731943533; x=1732548333; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=akSdSGiRTfyLnN0cC+NRUPJFGXfzjIlmKD+aKjcrBGM=; b=Wl1Iq80KdRduFpRZvJwfGjVIqkd0SH7cC7QG7x2ExupnUu9meT0LowH0cABu/6vMCh b2ZDfQa+HuF2GAE9F4DS5g9Z50yMYEEtr0FkS4F+miZURX3HqIXL11Qt0W909EE18cvo FTUXsyaUhv5SGV/rj5X9gTcd76MHIJ9bUrMCqvdN7V0Gi143qun00MTM+0JYNwFVx2he UfHEl7wYwQ+zqiwNJRVklmQrLQXcBYIcEFvHHYcCMUpzFEzVXKeQZPXPPjiloN4AtfyQ prwcrK8f48cNkkCJWgMF1V8aCubVeh9wlTVdntNe/Oupq4hhIVO9MFf1yE2ybL8CDPNb mi9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731943533; x=1732548333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=akSdSGiRTfyLnN0cC+NRUPJFGXfzjIlmKD+aKjcrBGM=; b=CZwo6YV+ejiwBmrkW+YjUoQmN8tiRpyLMY8BStMJkRq4wL5U7An2ucucF5gj5D5CwC SvIohUoVCAMxMFy8Ky4LURcy9df/tojmh8Lw6CmGNbTAzBFKTzarj8ckVXz/1wtj1ZgX Kz0Y4RIZV+fguqN1ZyCJl1EvjqOyfXSMpkP32tFKjcqpi3Mbz5y8imYImiokXN5hVorF nmdYue79rGQzYYa5WhC1hCyjQ5MkK8OPSrsNVWRPg2GszluRpnUFYuAzlKz5I2EpbUgQ BLrLTwinRg8ezLWQC6t/11uFT8sWyn/6WEiUWmVAcoIADNJYUiD15NQFcMsU0IqE1j/1 z//w== X-Forwarded-Encrypted: i=1; AJvYcCXF5zz7KjYlUe4TKedhE3//9SR0oACv4R8gTFiZnKmYIfybLc21qYwzbOtiA3WXJPQfWBwnLmZS7wfn@nongnu.org X-Gm-Message-State: AOJu0YysVl46n4caYttncrR7+VdeQjIhreTGxpPjy+QEmMgBUIi0oDUQ uIU4zmkSgSkP/6G7Rx1ZVsiQyJlUnHJQT4e8tTTKGbupmvgRc48ltx+5VySl X-Google-Smtp-Source: AGHT+IGi/TszPQc/izzt/ZJ4WxK/3rYzzaQAoRe2gFLi17Fgn+41/1128bPDjHJWoBSDfYp2xT+68Q== X-Received: by 2002:a05:651c:50d:b0:2fa:de13:5c34 with SMTP id 38308e7fff4ca-2ff60661742mr90143831fa.19.1731943533102; Mon, 18 Nov 2024 07:25:33 -0800 (PST) From: Pavel Skripkin To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, Pavel Skripkin Subject: [PATCH v3 1/2] arm/ptw: make get_S1prot accept decoded AP Date: Mon, 18 Nov 2024 10:25:26 -0500 Message-ID: <20241118152526.45185-1-paskripkin@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241118152507.45046-1-paskripkin@gmail.com> References: <20241118152507.45046-1-paskripkin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=paskripkin@gmail.com; helo=mail-lj1-x229.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1731943578387116600 Content-Type: text/plain; charset="utf-8" AP in armv7 short descriptor mode has 3 bits and also domain, which makes it incompatible with other arm schemas. To make it possible to share get_S1prot between armv8, armv7 long format, armv7 short format and armv6 it's easier to make caller decode AP. Signed-off-by: Pavel Skripkin --- target/arm/ptw.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 9849949508..86d6255713 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1357,25 +1357,24 @@ static int get_S2prot(CPUARMState *env, int s2ap, i= nt xn, bool s1_is_el0) * @env: CPUARMState * @mmu_idx: MMU index indicating required translation regime * @is_aa64: TRUE if AArch64 - * @ap: The 2-bit simple AP (AP[2:1]) + * @user_rw: Translated AP for user access + * @prot_rw: Translated AP for privileged access * @xn: XN (execute-never) bit * @pxn: PXN (privileged execute-never) bit * @in_pa: The original input pa space * @out_pa: The output pa space, modified by NSTable, NS, and NSE */ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, - int ap, int xn, int pxn, + int user_rw, int prot_rw, int xn, int pxn, ARMSecuritySpace in_pa, ARMSecuritySpace out_pa) { ARMCPU *cpu =3D env_archcpu(env); bool is_user =3D regime_is_user(env, mmu_idx); - int prot_rw, user_rw; bool have_wxn; int wxn =3D 0; =20 assert(!regime_is_stage2(mmu_idx)); =20 - user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); if (is_user) { prot_rw =3D user_rw; } else { @@ -1393,8 +1392,6 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu= _idx, bool is_aa64, regime_is_pan(env, mmu_idx) && (regime_sctlr(env, mmu_idx) & SCTLR_EPAN) && !xn) { prot_rw =3D 0; - } else { - prot_rw =3D simple_ap_to_rw_prot_is_user(ap, false); } } =20 @@ -2044,6 +2041,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, int nse, ns =3D extract32(attrs, 5, 1); uint8_t attrindx; uint64_t mair; + int user_rw, prot_rw; =20 switch (out_space) { case ARMSS_Root: @@ -2110,11 +2108,14 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, xn =3D 0; ap &=3D ~1; } + + user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); + prot_rw =3D simple_ap_to_rw_prot_is_user(ap, false); /* * Note that we modified ptw->in_space earlier for NSTable, but * result->f.attrs retains a copy of the original security space. */ - result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, ap, xn, pxn, + result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, user_rw, prot= _rw, xn, pxn, result->f.attrs.space, out_space); =20 /* Index into MAIR registers for cache attributes */ --=20 2.47.0 From nobody Sat Nov 23 18:00:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1731943595; cv=none; d=zohomail.com; s=zohoarc; b=Nx6SpIpeD27ww0XALuEGD6JQUm/LmDE2gv4/4hrlF6PBtFXtC7yyechTtHnM3SA6h3HOHQ7cpM1BbMWgunF+QDjYgqex2zrfa0NggwtNGwPsSexPDSd8lD7m1dIMOz0na0CwFRXiFzzR/t9skQBzWkgByObcuvK4soWq4zxqldc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731943595; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K12m86+3CyNiSslbgGmodn9GxajRPUsJHFARu9nTIbs=; b=CO0NDNxCAKNbocinJ3C0LsQGEfXUQhiFlDEIXbJl+qoF1QSrvLN9GVepuc9hJqonV1LPfcmu1U0RXkXguLnUh87P400UZiOM/4QBY/uyFM2VWL2jzWW1HPD/urrYcie1twCHceByDCaiBL+gcH7obZ7XtHy2vtyql/PmHnewhGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173194359558622.015313883969043; Mon, 18 Nov 2024 07:26:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tD3dh-0003Cw-OZ; Mon, 18 Nov 2024 10:26:10 -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 1tD3dM-0002z5-TG; Mon, 18 Nov 2024 10:25:49 -0500 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tD3dL-0004bl-42; Mon, 18 Nov 2024 10:25:48 -0500 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-539f84907caso4703332e87.3; Mon, 18 Nov 2024 07:25:45 -0800 (PST) Received: from fedora.. ([2a00:1370:8180:90b:d00f:257f:ffb:ac70]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53da64f2108sm1654514e87.17.2024.11.18.07.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 07:25:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731943544; x=1732548344; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K12m86+3CyNiSslbgGmodn9GxajRPUsJHFARu9nTIbs=; b=KKs9ItxnvZdyOZ87T1m1HJ5m/tHkyDjcuEeXNzAzUGap41RNz0vuUeSQUEmOxctjOs cEYCMjIjbpYdn8tWwBz7OhYyp/AD9O1yN+YrcMscV7Uzp9nXVPzYHBLbQzAdpRyjjUl0 dkS2CfU2qQq22kKGJV6qzV/5jImTjBa/sPITyiH7nnJWU4cOVQuEDHDtBPqq0FsiIYBU kg0V0+D5/NPnat55kYyHs4eN5pXTKWKH34FAvqyB1kjL+4Cpq0PflVLZ3SEXAqbb4bYu /Bim2BXoA3W13yj5ZTirDll8mJZIpn89Qlsh+O2H8FBRs3wIc6Iacyotj8oGbuBMhhnZ CruQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731943544; x=1732548344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K12m86+3CyNiSslbgGmodn9GxajRPUsJHFARu9nTIbs=; b=P6KFzkydclzcMy+iNlJf9+jNbdjrwOEMNFO6eHdno2P1NVtxik3Nc2G9lE+SW3u6qx VQlTeO3xkhqCLMVwR9DtRcyfEVZT/iEdotUtd5JXjq69bLE8DxQ9Az7FilEmeWjXLy2C +31Gy0LzjvkllvF/yYDbfrISFi+2xw/i7S/eOYxwYgvfOkUQhFizdVEe8rIsj/CCc5L3 VHyNyhHBI00shi9cFaczyfJYNGagNLt+fEHcI6xzFmpTWG6FXZKNpdCA3fEgmi8bwWIy sBoowPoqD4HvNVmL1gyT3q/hgwHPm0RmZ2Wam1XpoHzYOQv/ryrLdQrqubjAVC5FPAtJ 2kiw== X-Forwarded-Encrypted: i=1; AJvYcCUYPeHdJ3GOd1D882OM1PS7+yOdHkyCoPXkxMNF/H+Ehu3392YDt6XF0/ofvCJ3cChxgLQOEHzjI/a+@nongnu.org X-Gm-Message-State: AOJu0YzPu+UhBD+ArIYm/kHFhoBxyH4OIlqeS2I0oCj0bgKcuC4d3xDT JRHFFTBVg2La+ATWGo1O996EGJUtV+Uh+0isN8RNnyPVFS9yKTBYJ/xnh75b X-Google-Smtp-Source: AGHT+IHPZQzFW4/Pmb0XMu/cvXX4HEwrkzr4C1vjMx7TPy+cS5LhF7VfNrop9chbt4QdzXmnT+Qn9w== X-Received: by 2002:a05:6512:224b:b0:539:e776:71f7 with SMTP id 2adb3069b0e04-53dab3b0843mr4984525e87.37.1731943543709; Mon, 18 Nov 2024 07:25:43 -0800 (PST) From: Pavel Skripkin To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, Pavel Skripkin Subject: [PATCH v3 2/2] arm/ptw: use get_S1prot in get_phys_addr_v6 Date: Mon, 18 Nov 2024 10:25:37 -0500 Message-ID: <20241118152537.45277-1-paskripkin@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241118152507.45046-1-paskripkin@gmail.com> References: <20241118152507.45046-1-paskripkin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=paskripkin@gmail.com; helo=mail-lf1-x136.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1731943596498116600 Content-Type: text/plain; charset="utf-8" To share missing SCTRL.{U}WXN and SCR.SIF in short format walker, use get_S1prot instead of open-coded checks. Signed-off-by: Pavel Skripkin --- target/arm/ptw.c | 54 +++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 86d6255713..8150410eff 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -85,6 +85,10 @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Transl= ate *ptw, GetPhysAddrResult *result, ARMMMUFaultInfo *fi); =20 +static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, + int user_rw, int prot_rw, int xn, int pxn, + ARMSecuritySpace in_pa, ARMSecuritySpace out_pa); + /* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. = */ static const uint8_t pamax_map[] =3D { [0] =3D 32, @@ -1148,7 +1152,7 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Tran= slate *ptw, hwaddr phys_addr; uint32_t dacr; bool ns; - int user_prot; + ARMSecuritySpace out_space; =20 /* Pagetable walk. */ /* Lookup l1 descriptor. */ @@ -1240,16 +1244,18 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Tr= anslate *ptw, g_assert_not_reached(); } } + out_space =3D ptw->in_space; + if (ns) { + /* The NS bit will (as required by the architecture) have no effec= t if + * the CPU doesn't support TZ or this is a non-secure translation + * regime, because the attribute will already be non-secure. + */ + out_space =3D ARMSS_NonSecure; + } if (domain_prot =3D=3D 3) { result->f.prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; } else { - if (pxn && !regime_is_user(env, mmu_idx)) { - xn =3D 1; - } - if (xn && access_type =3D=3D MMU_INST_FETCH) { - fi->type =3D ARMFault_Permission; - goto do_fault; - } + int user_rw, prot_rw; =20 if (arm_feature(env, ARM_FEATURE_V6K) && (regime_sctlr(env, mmu_idx) & SCTLR_AFE)) { @@ -1259,37 +1265,23 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Tr= anslate *ptw, fi->type =3D ARMFault_AccessFlag; goto do_fault; } - result->f.prot =3D simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); - user_prot =3D simple_ap_to_rw_prot_is_user(ap >> 1, 1); + prot_rw =3D simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); + user_rw =3D simple_ap_to_rw_prot_is_user(ap >> 1, 1); } else { - result->f.prot =3D ap_to_rw_prot(env, mmu_idx, ap, domain_prot= ); - user_prot =3D ap_to_rw_prot_is_user(env, mmu_idx, ap, domain_p= rot, 1); - } - if (result->f.prot && !xn) { - result->f.prot |=3D PAGE_EXEC; + prot_rw =3D ap_to_rw_prot(env, mmu_idx, ap, domain_prot); + user_rw =3D ap_to_rw_prot_is_user(env, mmu_idx, ap, domain_pro= t, 1); } + + result->f.prot =3D get_S1prot(env, mmu_idx, false, user_rw, prot_r= w, xn, pxn, + result->f.attrs.space, out_space); if (!(result->f.prot & (1 << access_type))) { /* Access permission fault. */ fi->type =3D ARMFault_Permission; goto do_fault; } - if (regime_is_pan(env, mmu_idx) && - !regime_is_user(env, mmu_idx) && - user_prot && - access_type !=3D MMU_INST_FETCH) { - /* Privileged Access Never fault */ - fi->type =3D ARMFault_Permission; - goto do_fault; - } - } - if (ns) { - /* The NS bit will (as required by the architecture) have no effec= t if - * the CPU doesn't support TZ or this is a non-secure translation - * regime, because the attribute will already be non-secure. - */ - result->f.attrs.secure =3D false; - result->f.attrs.space =3D ARMSS_NonSecure; } + result->f.attrs.space =3D out_space; + result->f.attrs.secure =3D arm_space_is_secure(out_space); result->f.phys_addr =3D phys_addr; return false; do_fault: --=20 2.47.0