From nobody Sun Dec 14 06:35:31 2025 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=1753603675; cv=none; d=zohomail.com; s=zohoarc; b=HNhKNjnGjqP1V97wcSftOjBCexFGkpuf/oqttWUjrT8wyHwj4wFUGqsilWLZzjZ9J7NjdNjwRn6pJ4eM177kMNfb8K/beIsYX+HHvZfGAdl+5PKBcVHCycjgZtSbTAu3sbdr4ZDT7oWs5cPzNtLtibVFonJ05w5PXU2MTlBjmbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603675; 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=q7LCKs76Nw+Cer/cpAQHFjJNOdRtPOAbp6iYLe+f3EQ=; b=YhWTfhzSJuMIGpS4/5OcX4Pkn4oPMNEajtzyMBLsFYypFeSjXE5W5qdkWj8UBRKQ8anH7zmTtc7JJ4pVLugwJDoqR9Q7gyKQ8/+ND65Gio52rsSK38YErLctEsyldypcDtWoNfQUaP9OApBsry2XCggZKNgmw5aYz11tmnCFdMk= 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 1753603675827196.9081905659441; Sun, 27 Jul 2025 01:07:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMT-0008Kn-Gt; Sun, 27 Jul 2025 04:04:01 -0400 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 1ufwLk-0005Cr-Ly for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:16 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLi-00044q-OM for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:16 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2401248e4aaso1288305ad.0 for ; Sun, 27 Jul 2025 01:03:14 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603393; x=1754208193; 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=q7LCKs76Nw+Cer/cpAQHFjJNOdRtPOAbp6iYLe+f3EQ=; b=O0AutxExnGgBeFsJ8I22bRDZyqo/ZnEaJuqLQVXM1rvfHesTzY0piMzWkGhEQO0CRr PzWV/N2jP43KmApTWtAcWoI7H9LxinsiRfj3eImOiC7LOwXg+LVaWIXBGmjnw/7v8cfI kRi7+zDZtP5u3jWyTvxFpaNIkj20WZZ0c8WohYzUC3JaX5zNulQxaXrjLcleUVxdG/kF CD+p2DbvnB/pa4tc7kzgjetEs3Ewb1TnKgmW73gOdq3yfHTcvPW4j8OE6RJ1Siw9Bc1p G7jz54frOXkYCmI8lhuKcIONsBy3AOs4qbOnQFw1v0WzyuflwzUS4GLNg9Kdnxqh3qO9 1DaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603393; x=1754208193; 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=q7LCKs76Nw+Cer/cpAQHFjJNOdRtPOAbp6iYLe+f3EQ=; b=r678ddcu4guv8334j6K1mqrjO9ZWI/HSod4aOTEqha1Clfs8sEjl25Z95SdmyxmheD RZLt+m0efrZpsNVGcTjdFSjtoLXmRtmKgxO8QhmrWOgkZsr/Bj/UsPeOIYV3jN1g0NlI q9qk4v+AgrLYG8J2kQGB1nlb+1zhmt60ypwYi6NXv5HnGdzOMpONGCnDBP83CTBlydqK ylqffeGZzW+b6mOg163lWrOOnwoULkRjL7x6WVpjwAf/zmDBVG30+uLjupI7zpdh9+LW yIi4ZYn6oKA2c+RGGv5T2hVUKnnRel4CNSLVWD1Jh4Bs81bHsr4aOL0dDJ1FufGLD+7p QP4w== X-Gm-Message-State: AOJu0YxODjHrhpRZw94wRzf9WYDbnsbDjbnQj4FvmC3gbQ630njV6Ugz re1NyzzXVmFU0lg3I7JYuHELw9Uc67Ht00P55IiQxwDKkoljUhQk31vbk1FKpXIm3kuz4GxNLlt /eKtn X-Gm-Gg: ASbGnctZzvTfPcxuAt1NDcUoVFJiDONM25WJ8pHyyYgcFPu8Bd+SahfY3I9j0/vRWEl 01b4hQKMgxxfzIYTWwvXV7/WNaYPwR+WwHPwnr6YOndxKdTPbH3G0+evYdo40mqPEUfcQXwtyUv Lov970J8BAwQ3ssUzKDPktEbenhIVjRKipjReJffVDqWg9GcuMj2Q3wlsTFsNR3/rrGhdu7xS75 BLpTr7V9WBo5Ar8CrtJr08wxM+U/wKzHMGcVx+khXfm4s3fTe0huP2hBfn09D8+Hms6IzHZIZ3u PHKCyopRxtEiPXACj+/G6V8mRV5nALjiy59hyU+0tGg+MTD3JxzBVkpAV7BanWo/K5epSggLCIC NiOBd6ZUcc8gyniZ+WGuTu1u1Zzo+ak9OJDTrv8z5WidblcmVhY23KY51pwpU/vFSK3WuSlW6ir WPVY+2ONY4Ag== X-Google-Smtp-Source: AGHT+IGYLJ2isOG6ZUT0awpKMmjRMNeUMEglbx/RJ2Y/VkBoBpUaZfJnVma0NJIUrgXyC7EvAfxesA== X-Received: by 2002:a17:902:ebcd:b0:240:1f25:d443 with SMTP id d9443c01a7336-2401f25d6e2mr1082595ad.30.1753603393160; Sun, 27 Jul 2025 01:03:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 13/82] target/arm: Force HPD for stage2 translations Date: Sat, 26 Jul 2025 22:01:45 -1000 Message-ID: <20250727080254.83840-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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=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 @linaro.org) X-ZM-MESSAGEID: 1753603678022116600 Content-Type: text/plain; charset="utf-8" Stage2 translations do not have hierarchial permissions. Setting HPD means we can eliminate an extra check against regime_is_stage2. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/helper.c | 7 +++++-- target/arm/ptw.c | 24 +++++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 6353b2dea1..a6130f7dcd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9639,8 +9639,11 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env,= uint64_t va, tsz =3D extract32(tcr, 0, 6); gran =3D tg0_to_gran_size(extract32(tcr, 14, 2)); if (stage2) { - /* VTCR_EL2 */ - hpd =3D false; + /* + * Stage2 does not have hierarchical permissions. + * Thus disabling them makes things easier during ptw. + */ + hpd =3D true; } else { hpd =3D extract32(tcr, 24, 1); } diff --git a/target/arm/ptw.c b/target/arm/ptw.c index efbad7af1f..2eb2041edb 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1472,8 +1472,12 @@ static ARMVAParameters aa32_va_parameters(CPUARMStat= e *env, uint32_t va, } tsz =3D sextract32(tcr, 0, 4) + 8; select =3D 0; - hpd =3D false; epd =3D false; + /* + * Stage2 does not have hierarchical permissions. + * Thus disabling them makes things easier during ptw. + */ + hpd =3D true; } else if (el =3D=3D 2) { /* HTCR */ tsz =3D extract32(tcr, 0, 3); @@ -1979,16 +1983,14 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, * except NSTable (which we have already handled). */ attrs =3D new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(5= 0, 14)); - if (!regime_is_stage2(mmu_idx)) { - if (!param.hpd) { - attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ - /* - * The sense of AP[1] vs APTable[0] is reversed, as APTable[0]= =3D=3D 1 - * means "force PL1 access only", which means forcing AP[1] to= 0. - */ - attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D= > AP[1] */ - attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D>= AP[2] */ - } + if (!param.hpd) { + attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D= =3D 1 + * means "force PL1 access only", which means forcing AP[1] to 0. + */ + attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D> AP= [1] */ + attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D> AP[= 2] */ } =20 ap =3D extract32(attrs, 6, 2); --=20 2.43.0