From nobody Wed Nov 27 00:34:39 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1702899286; cv=none; d=zohomail.com; s=zohoarc; b=CxfqMWsxcYwiBzJleOpj1+lqG847CDI7lCwrXHuBAXTsVc6O3FrLZtpzJ2+IUBThGGmbdIgcvDuzCcKYx/ucQfCdu9C7exiNjRSSK23AFT3xKL8eQCFviQgb1Es3RN2hc/NzcFLgyCrRms4tQWcH+oLtqLQY71Kp1RtocwEoy/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702899286; h=Content-Transfer-Encoding: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:Cc; bh=8VnUA3Fueqk12WZS/CbUJV8o9iWN9VQ36taC6t7Xhbo=; b=MHegE3tmZYPBNbw87MtSJcNYm48lXHxJ6GCLvpXGjJ0fEIwOFGEKkljhz1/Rq8tZiuLMG2ew7g5SE50bJ3IudqHwaA81oRI0Re7+WkZ6Cb0tp8DsCCR1WvcJjDLQqOvGJGeQKWPsTaSwvsmoqeTwXpVY02QxFhej7bwH/dpSTTo= 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 1702899286941305.2423251634399; Mon, 18 Dec 2023 03:34:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFBsF-00070U-PB; Mon, 18 Dec 2023 06:33:27 -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 1rFBsD-0006vr-DJ for qemu-devel@nongnu.org; Mon, 18 Dec 2023 06:33:25 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFBs5-0003LS-Mk for qemu-devel@nongnu.org; Mon, 18 Dec 2023 06:33:25 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3363aa1b7d2so2625819f8f.0 for ; Mon, 18 Dec 2023 03:33:17 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id j18-20020adff012000000b003366da509ecsm671193wro.85.2023.12.18.03.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 03:33:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702899196; x=1703503996; 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=8VnUA3Fueqk12WZS/CbUJV8o9iWN9VQ36taC6t7Xhbo=; b=aXB69FuLQIO2bLbh6Oy8u3fVu8q1sTVD1QoiEQDUx62eRR+qOKIhVqAKNhghCJPMHY 8UPpo73UuX4FZ5eYV/f8ZpvH7cR8+U11YowB6S+GdGpBUCarHOGAfZaOO5Vz36O46f4J k5q+P4rMQu49pfdKeE8pszR1cL/yv8p4fi2SCD/uZP9JNOA0Ar17bEGU5TrZB5Z7V/od RmNcVQRSyYGpNap7NSOJtKA7hL5M0VJgXOph9Q8lZXMIQyrbR43iLsem8OsSCOtiUZZQ CT09bgPTAFMT8Un84/8sNkH4MvKJN+FHfQx/wVvnhr3yXLLbDotgOq2A5tL039WaBVQb Y8yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702899196; x=1703503996; 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=8VnUA3Fueqk12WZS/CbUJV8o9iWN9VQ36taC6t7Xhbo=; b=pQhAMedjNr7GE98HSWUKQguJn2Gwz1NE7nMKhXo2MBuv6INsACp6v6iIYKyRp5uEnz akHx+cY9ATI+EmHY3WYPH2zpVKN02YrGfyOZneTronTQGxcRfOXUKYUyzPu8jkoO1rfE s7wa8Oip9FlJ7tVbkXn9YrZMWj/BL++vpyI4pe4wo0anqtAxaiBQ29Zfb6jmmR1XtklN VzGtnu2CUDrGs62rJMQnoiWmsM5BlRUVq0dffcofwmwgMjcviCGWCPSC1S61rMZdDsqy vjF8dxmRrt4esIDRQ7oWbLMSIrPpAyMp40fHZYRFOhh524GT/Q/TuJGq1EbfXVvtvlnR kI+w== X-Gm-Message-State: AOJu0YwDXgVc8Tj9ZD5yA7EkjB1ulcx5V0/2/XC4zONHrToZGZ2sMow8 dEl8njZsnw0OyK4l6ijOSsp6hA== X-Google-Smtp-Source: AGHT+IHz7gxnjcyxQImQFq/Iq28oVh4yXGwJ/JfdM1qHYIGoIoypS4xLu7mC+b+DzzKtT+VK+h1Y7A== X-Received: by 2002:adf:ed09:0:b0:336:60ab:12b8 with SMTP id a9-20020adfed09000000b0033660ab12b8mr1225373wro.56.1702899196248; Mon, 18 Dec 2023 03:33:16 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 20/35] target/arm: Handle FEAT_NV page table attribute changes Date: Mon, 18 Dec 2023 11:32:50 +0000 Message-Id: <20231218113305.2511480-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218113305.2511480-1-peter.maydell@linaro.org> References: <20231218113305.2511480-1-peter.maydell@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=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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=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: 1702899287908100001 Content-Type: text/plain; charset="utf-8" FEAT_NV requires that when HCR_EL2.{NV,NV1} =3D=3D {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 --- target/arm/ptw.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 1762b058aec..cab30f0bf46 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, } } =20 +static bool nv_nv1_enabled(CPUARMState *env, S1Translate *ptw) +{ + uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, ptw->in_space); + return (hcr & (HCR_NV | HCR_NV1)) =3D=3D (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, S1T= ranslate *ptw, xn =3D extract64(attrs, 54, 1); pxn =3D extract64(attrs, 53, 1); =20 + if (el =3D=3D 1 && nv_nv1_enabled(env, ptw)) { + /* + * With FEAT_NV, when HCR_EL2.{NV,NV1} =3D=3D {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 descript= ors + * (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 d= oes + * the right thing. + */ + pxn =3D xn; + xn =3D 0; + ap &=3D ~1; + } /* * Note that we modified ptw->in_space earlier for NSTable, but * result->f.attrs retains a copy of the original security space. --=20 2.34.1