From nobody Sat Feb 7 05:37:14 2026 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676935633; cv=none; d=zohomail.com; s=zohoarc; b=EhlrQsHPzIX4eHmrGYfLPgJuStunfUMjvOX8mi3DQ8xe+3NfRFWQQPAinyyYBdP3dJyBaqbeSQXlVJBccP/f0SxTbkfHpPX9xW+jplohT2gmj5An6DnBEYfWAQAEb3TtKNuBR0RK8fPXevXFYvUmOBD9EEoG0qRaqjDteBlqhxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676935633; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9O4rQ+1tSrDA/VIHaikB47RvthTap5eXu1DpMH/jhqs=; b=MJjzndDL8jAvN8PnKV4pKkBP+ogGS8HR/z+EEeWIrHYe4PTNeFybi0N5T1/KhaCE6C/Rca7gUI0gegyhMLRVFsl9GGcU7jA/VuHeFb17o2YA4QixeD8sd/cv1GxWXG7FVuWZqwfsugaMtRYDeqb2jHEaxBS7Qzw1TVzMkq/+T4Y= 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 167693563397040.34221808406619; Mon, 20 Feb 2023 15:27:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUFYc-00048M-5m; Mon, 20 Feb 2023 18:26:54 -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 1pUFYZ-00043a-Os for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:51 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYX-0000Or-NT for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:51 -0500 Received: by mail-pl1-x636.google.com with SMTP id e5so4173347plg.8 for ; Mon, 20 Feb 2023 15:26:49 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=9O4rQ+1tSrDA/VIHaikB47RvthTap5eXu1DpMH/jhqs=; b=A7/KCoOvzdkchqGOJQIfJM9hQTufU2tNpCTEO9VwXDuY3E49vaflRpzqnfGj3L7wj8 PzSsZGiEDQm36f5zCTtlpyrTCSmCzotgP4daU2b1/s+YLmcOTRxBlP/Yoadhl3UcOWta qa4OL9tAHQzVeHvDwQfMnDlC9U3MxtnrHlYF5diehNDjmrABFwEqt6iqEeCwhkJ09cSa lFX1gqWKE+s8LUNTySJATjVjRx7yxUphN8com+DzFHF0HjZ9yr/EzDPN7SUUxj33aafn uDAW+L9IWYfL1jp0xFib/LAb8HJjP2LFBnY7zq55ZfgaL3lwYzUQKBjelkqGVfsdPfYK cHIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=9O4rQ+1tSrDA/VIHaikB47RvthTap5eXu1DpMH/jhqs=; b=tcSRIjR/3NmbcNfgjdyhjH9srE9bfUfXl5s4svtTogr1qeO3CdtryNoXwQmfhr8oMZ dsFEj7dRGiodpCH+EwQBH0tOHmqFMZ0WbtvW9Q38tozHmrve40Y7XUqetnpBG0QMQXZa zJXNvuU3o6zbugJPPPtCBIgYJrvqx7EHOJxjHqqmWsER91D9V5tgpBXLz7x3/ZY8rPrf xE0OMO0ScyoCgO7ism/TmcIk6AchxcifVjA0lRQxLPszsqT3CLuvwAkyTI+Vb+LSi9QD H7XIgSG/ZG5mddObMjKnhNmB4Z9dP8nBX2W5wtrbyWIENHp4zi1/3Cp2AqN8QKr3kLzR 1dhw== X-Gm-Message-State: AO0yUKUEXHudxzTG/ngajw7rMzBxBJEcqsu9WjFiQ8SJ4X8SagsDS8Mr K2/TydJZyNOCz+Qm6Pd35QGS9AkLRFQGU5/z3mw= X-Google-Smtp-Source: AK7set/GIBECsuKnFBoIRdNcqEKDqJQ5Bj0VBLXvkhaebJEu4WM7h4o4mvbBGG59YUaNFieKmuMqsw== X-Received: by 2002:a17:903:2305:b0:19a:a4fc:7f80 with SMTP id d5-20020a170903230500b0019aa4fc7f80mr6249197plh.26.1676935608092; Mon, 20 Feb 2023 15:26:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 11/21] target/arm: NSTable is RES0 for the RME EL3 regime Date: Mon, 20 Feb 2023 13:26:16 -1000 Message-Id: <20230220232626.429947-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 autolearn=unavailable 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 @linaro.org) X-ZM-MESSAGEID: 1676935635667100002 Content-Type: text/plain; charset="utf-8" Test in_space instead of in_secure so that we don't switch out of Root space. Handle the output space change immediately, rather than try and combine the NSTable and NS bits later. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 7745287a46..d612e5f38a 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1240,7 +1240,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, { ARMCPU *cpu =3D env_archcpu(env); ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - bool is_secure =3D ptw->in_secure; int32_t level; ARMVAParameters param; uint64_t ttbr; @@ -1256,7 +1255,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); uint64_t descriptor, new_descriptor; - bool nstable; =20 /* TODO: This code does not support shareability levels. */ if (aarch64) { @@ -1417,20 +1415,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, descaddrmask =3D MAKE_64BIT_MASK(0, 40); } descaddrmask &=3D ~indexmask_grainsize; - - /* - * Secure accesses start with the page table in secure memory and - * can be downgraded to non-secure at any step. Non-secure accesses - * remain non-secure. We implement this by just ORing in the NSTable/NS - * bits at each step. - */ - tableattrs =3D is_secure ? 0 : (1 << 4); + tableattrs =3D 0; =20 next_level: descaddr |=3D (address >> (stride * (4 - level))) & indexmask; descaddr &=3D ~7ULL; - nstable =3D extract32(tableattrs, 4, 1); - if (nstable && ptw->in_secure) { + + /* + * Process the NSTable bit from the previous level. This changes + * the table address space and the output space from Secure to + * NonSecure. With RME, the EL3 translation regime does not change + * from Root to NonSecure. + */ + if (extract32(tableattrs, 4, 1) && ptw->in_space =3D=3D ARMSS_Secure) { /* * Stage2_S -> Stage2 or Phys_S -> Phys_NS * Assert the relative order of the secure/non-secure indexes. @@ -1439,7 +1436,11 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2_S + 1 !=3D ARMMMUIdx_Stage2); ptw->in_ptw_idx +=3D 1; ptw->in_secure =3D false; + ptw->in_space =3D ARMSS_NonSecure; + result->f.attrs.secure =3D false; + result->f.attrs.space =3D ARMSS_NonSecure; } + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { goto do_fault; } @@ -1542,7 +1543,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, */ attrs =3D new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(5= 0, 14)); if (!regime_is_stage2(mmu_idx)) { - attrs |=3D nstable << 5; /* NS */ + attrs |=3D !ptw->in_secure << 5; /* NS */ if (!param.hpd) { attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* --=20 2.34.1