From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466160790946.0896011299069; Wed, 9 Feb 2022 20:09:20 -0800 (PST) Received: from localhost ([::1]:48430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0lj-0006to-0v for importer@patchew.org; Wed, 09 Feb 2022 23:09:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hE-0003uD-0V for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:40 -0500 Received: from [2607:f8b0:4864:20::636] (port=38788 helo=mail-pl1-x636.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hB-00045r-02 for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:38 -0500 Received: by mail-pl1-x636.google.com with SMTP id c3so747255pls.5 for ; Wed, 09 Feb 2022 20:04:36 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AwzX6nehTYEJJpMljDUaZpO2r34jA4Ju646jiPXQlwk=; b=fxoubPLNEogn+zHRnWFJWC+02DY723o0fq2mD8X6E2s1xgD8o6Q8a3eI/T8JVd8rtq 9ZT1LBBeJTKrH1XeHWmzn1q/QJX9IjQMkZlmav6rW0XnrofDTCUk/+Ck5IJm94cA6Gsg SDBBWqh9qQ9RgT+ewtFxdOk4c1Grp9f4tLZH9kDGC4660fg89EMBZNgkruKqmyL8rTIe Z1RkqS2X/006oeS+5XAXAivHdihTmQYjNZpGtW9FdDsJjUJDasBgtgXhzbNUUW8L0wxY lo4wUWS2/Pa6s2PHUsTMGCJIDeoQLm/Am+lDVd2VJY6vQs7Vi2VAIe0cMqOQO+yIEPkq uL8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AwzX6nehTYEJJpMljDUaZpO2r34jA4Ju646jiPXQlwk=; b=4BlxNNrOe4T1LXYha8wUgwUwKKDf4z752WxHlvPqODpqRTBJB4gW3ADtyzx/1mJITF Jnb8lvVYS6USqPrYq8YpqToYEke8Rw7lTCTPtEA8WZSiG5FhEtd6sAjDxzubJSXuIlbC 3xoYM3VtXycguHi+FUY9cVQiWXOB6VsWXBJTkQhlwsu10fAEICzNkYveEveIk4YW24a7 bcMLWT0borRRQhWKG/nlvoBvaZ74o5jhNY1Gzm0q296H1YAvw8H0REPLno1VhJuJ9azd e/slruz8SNs1vQWs75E+NyzLVC+rrrkUTLFyehvbmFoPGM/5HgRPfcEsY31H04uwohN3 /9GA== X-Gm-Message-State: AOAM533hwFxq3037Eyz2C2USm9R1mDzhENRjmusJS58XHe2QnZWRqgWQ lBPjGksyNdxRdVnFfEMMbkebSfGVzai8J1oh X-Google-Smtp-Source: ABdhPJz0KVvI1mTb0oODJrEK+YKDaIymbE6d50ZoWXQ2NLmSdivXc3vxFLGoaYYn2FgKTCdxQElB7Q== X-Received: by 2002:a17:90b:2243:: with SMTP id hk3mr750212pjb.244.1644465875665; Wed, 09 Feb 2022 20:04:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 01/15] hw/registerfields: Add FIELD_SEX and FIELD_SDP Date: Thu, 10 Feb 2022 15:04:09 +1100 Message-Id: <20220210040423.95120-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::636 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466163548100001 Content-Type: text/plain; charset="utf-8" Add new macros to manipulate signed fields within the register. Suggested-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/registerfields.h | 48 ++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h index f2a3c9c41f..3a88e135d0 100644 --- a/include/hw/registerfields.h +++ b/include/hw/registerfields.h @@ -59,6 +59,19 @@ extract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH) =20 +#define FIELD_SEX8(storage, reg, field) \ + sextract8((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_SEX16(storage, reg, field) \ + sextract16((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_SEX32(storage, reg, field) \ + sextract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_SEX64(storage, reg, field) \ + sextract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) + /* Extract a field from an array of registers */ #define ARRAY_FIELD_EX32(regs, reg, field) \ FIELD_EX32((regs)[R_ ## reg], reg, field) @@ -95,7 +108,40 @@ _d; }) #define FIELD_DP64(storage, reg, field, val) ({ \ struct { \ - uint64_t v:R_ ## reg ## _ ## field ## _LENGTH; \ + uint64_t v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v =3D { .v =3D val }; = \ + uint64_t _d; \ + _d =3D deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, = \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) + +#define FIELD_SDP8(storage, reg, field, val) ({ \ + struct { \ + signed int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v =3D { .v =3D val }; = \ + uint8_t _d; \ + _d =3D deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, = \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) +#define FIELD_SDP16(storage, reg, field, val) ({ \ + struct { \ + signed int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v =3D { .v =3D val }; = \ + uint16_t _d; \ + _d =3D deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, = \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) +#define FIELD_SDP32(storage, reg, field, val) ({ \ + struct { \ + signed int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } _v =3D { .v =3D val }; = \ + uint32_t _d; \ + _d =3D deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, = \ + R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ + _d; }) +#define FIELD_SDP64(storage, reg, field, val) ({ \ + struct { \ + int64_t v:R_ ## reg ## _ ## field ## _LENGTH; \ } _v =3D { .v =3D val }; = \ uint64_t _d; \ _d =3D deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, = \ --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466162881365.551823648649; Wed, 9 Feb 2022 20:09:22 -0800 (PST) Received: from localhost ([::1]:48610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0ll-00070v-FZ for importer@patchew.org; Wed, 09 Feb 2022 23:09:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hG-0003uh-Dt for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:42 -0500 Received: from [2607:f8b0:4864:20::62b] (port=38778 helo=mail-pl1-x62b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hE-00046X-CK for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:42 -0500 Received: by mail-pl1-x62b.google.com with SMTP id c3so747323pls.5 for ; Wed, 09 Feb 2022 20:04:39 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6GEKuSQX+CG8gt0Gp9cWbbYI/Mw1WHwT/DCHRQdQ0Wo=; b=C0+Zc979DKm0HtHVIYzphg2iahc5MEGH3giJcDjotVxWiX9WGysmtfpqykIAhJDNqL C6By6zaYx2M5lThzs4F9vLKkudL+HbEvbJB1cZ71+xPRacDan+RLcksfYKa3wkk/T2NF bN3wtfc7hgQtYW19Hea2WUF5y3wEYztDsrZnYHD4zxnqq7FUU4OfK0HBCNCZR2sbqnyf xos1qUn2DKUmsjRenneyiOO4CGbbd/cQhmtnv9os6quloGLDsrZ+8xkIvzmHXCOXAtTB tLcYfP/7TB4ItpRyh0FB6Bf7hRJFqR0On5ZLHIq+Fob8y+m/VNlxw7FParuRUi9JpOhF BdKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6GEKuSQX+CG8gt0Gp9cWbbYI/Mw1WHwT/DCHRQdQ0Wo=; b=JKqYW8Bsfb5tV87JtrfRTBBsKCAE4QQoJ6Udns7VGcBrjtNBRNqN1j4C4OwM1Mozkf U/FJxkoZmSbRltY5X3dSwui/lJh3Tt45MWFiNfwbzJs90SfUYQsLvyIzdWlA8XtJQYua vKQk2Ufe2iaTFM6jVT48w6utlL5ZpsmY90NdmRFZNmlOTf5MN7BhqoZdqqVDc7PoDarH epCD1q5T6L8okMn8/yoArlEJgQniaDuvS3A8d/M5LMsP1dtsNl7t3cf8/5VCEnDHWmKY z+X+AmUlUCxhnBAcRM7spyN5AvJiX/5uDtGVFxEEO4/8Rq82NFvMGk330ylnGl0u7gvn 0dlg== X-Gm-Message-State: AOAM533qknUkEKsw6C0A0mGeUvlU7v9Cl1x5TMZ0TUHKzqbkrADVApZS VbsHymgVNAx0bGpE3v8hPCddkfxTpvr4g4QP X-Google-Smtp-Source: ABdhPJzVGqBtuSreWgvu904LP4dfn2quNXp3d0Crw2xoyeoJqgE+Gt5mBZmpNSXHpgtwlv+9+JrciA== X-Received: by 2002:a17:902:ccc2:: with SMTP id z2mr5498369ple.145.1644465878436; Wed, 09 Feb 2022 20:04:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/15] target/arm: Set TCR_EL1.TSZ for user-only Date: Thu, 10 Feb 2022 15:04:10 +1100 Message-Id: <20220210040423.95120-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62b (failed) 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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466164024100003 Content-Type: text/plain; charset="utf-8" Set this as the kernel would, to 48 bits, to keep the computation of the address space correct for PAuth. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 5a9c02a256..92f19f919a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -206,10 +206,11 @@ static void arm_cpu_reset(DeviceState *dev) aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1= ); } /* + * Enable 48-bit address space (TODO: take reserved_va into accoun= t). * Enable TBI0 but not TBI1. * Note that this must match useronly_clean_ptr. */ - env->cp15.tcr_el[1].raw_tcr =3D (1ULL << 37); + env->cp15.tcr_el[1].raw_tcr =3D 5 | (1ULL << 37); =20 /* Enable MTE */ if (cpu_isar_feature(aa64_mte, cpu)) { --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466429075205.26846354706743; Wed, 9 Feb 2022 20:13:49 -0800 (PST) Received: from localhost ([::1]:60714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0q4-0006hv-T6 for importer@patchew.org; Wed, 09 Feb 2022 23:13:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hK-0003vm-5F for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:46 -0500 Received: from [2607:f8b0:4864:20::432] (port=34383 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hI-000471-9q for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:45 -0500 Received: by mail-pf1-x432.google.com with SMTP id n23so8041439pfo.1 for ; Wed, 09 Feb 2022 20:04:43 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M9yoHlP5X1aUjQ5+XqVVCuvodgZ7D3QrARDveNRnzPE=; b=vf+owxysXq1AM8pznsPiJhfGf5bzg13BCYLoIW72rwX1LVmWb6NA8lfNEOVK8S8LfU hBq4Q6BEi+wzv+dYGJ+gAnYw12glXMpkRhrp/W4BqQllWoCzgj29AyU0H/ShS0OKJ9La d+2hqdHAwFq4bIqK6jeKpW5ZYOMsaOzPEVm8oIQpjF1i40DNInxKTxnIr4IJsxjB1von vCNJwPdHfU/AFWfF/ufjNOE1ps18kLYH99FY6YOnTFrHieAxoapVux2nHeehYem5GmG9 FYCChhUaHgRniVdzSp6AN5zuntC91PBvEWDp9UkdhIyyynPmXuLau562rN9thkPi+CGe UUPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M9yoHlP5X1aUjQ5+XqVVCuvodgZ7D3QrARDveNRnzPE=; b=fCX/jig1OpXovcX19jzSaAXb17J7OWZBbjkq67DQlU+fsDvJPiCv3C8JjddrL/A8Yq VXg7g/nl+Cdb8+9I+S4qloJLMMN4PpVXH6NJ92dtL+XX32kjECqH4YfgdPuQeyWTtvBY 6pC2pZfXLeun3pA6H96xFuU/bfjJ1ffEz1v798rr1kWntWalMcLC3pkKEC89zDwTCL9C DCKJVf2btmDgqUzkDU6im0rV/ieISOnODZLr1Do+bDZBP2pJfWUeo+ceoUPUkcl1DE8a JMlyqnwzpj+qLaCjpugEfIvWrcNTqNE8biKf/GT4PVraG/PHhhfu30g1SG34ggA8m34B lyLA== X-Gm-Message-State: AOAM5310bai82Z4c4QkxSBFxpNpUd3q3Mn3uZ/mjxHgfebw5dzgAM1DV KvtiKU69bG6uqJWLzM0OSoUCVe5ER9siqexY X-Google-Smtp-Source: ABdhPJxwuJRTtkamHJ5ua8gbfdP8Ie6ONFkd9QPWjTYg24XnoQwfY1gtqxwHZwRIfQeCeMIEV2ZtFg== X-Received: by 2002:a05:6a00:98e:: with SMTP id u14mr5590601pfg.12.1644465881227; Wed, 09 Feb 2022 20:04:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/15] target/arm: Fault on invalid TCR_ELx.TxSZ Date: Thu, 10 Feb 2022 15:04:11 +1100 Message-Id: <20220210040423.95120-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::432 (failed) 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::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466430554100001 Content-Type: text/plain; charset="utf-8" Without FEAT_LVA, the behaviour of programming an invalid value is IMPLEMENTATION DEFINED. With FEAT_LVA, programming an invalid minimum value requires a Translation fault. It is most self-consistent to choose to generate the fault always. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- v2: Continue to bound in aa64_va_parameters, so that PAuth gets something it can use, but provide a flag for get_phys_addr_lpae to raise a fault. --- target/arm/internals.h | 1 + target/arm/helper.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 3f05748ea4..ef6c25d8cb 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1055,6 +1055,7 @@ typedef struct ARMVAParameters { bool hpd : 1; bool using16k : 1; bool using64k : 1; + bool tsz_oob : 1; /* tsz has been clamped to legal range */ } ARMVAParameters; =20 ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, diff --git a/target/arm/helper.c b/target/arm/helper.c index b5f80988c9..14cc866d8d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11188,8 +11188,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, ARMMMUIdx mmu_idx, bool data) { uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; - bool epd, hpd, using16k, using64k; - int select, tsz, tbi, max_tsz; + bool epd, hpd, using16k, using64k, tsz_oob; + int select, tsz, tbi, max_tsz, min_tsz; =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; @@ -11230,9 +11230,17 @@ ARMVAParameters aa64_va_parameters(CPUARMState *en= v, uint64_t va, } else { max_tsz =3D 39; } + min_tsz =3D 16; /* TODO: ARMv8.2-LVA */ =20 - tsz =3D MIN(tsz, max_tsz); - tsz =3D MAX(tsz, 16); /* TODO: ARMv8.2-LVA */ + if (tsz > max_tsz) { + tsz =3D max_tsz; + tsz_oob =3D true; + } else if (tsz < min_tsz) { + tsz =3D min_tsz; + tsz_oob =3D true; + } else { + tsz_oob =3D false; + } =20 /* Present TBI as a composite with TBID. */ tbi =3D aa64_va_parameter_tbi(tcr, mmu_idx); @@ -11249,6 +11257,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, .hpd =3D hpd, .using16k =3D using16k, .using64k =3D using64k, + .tsz_oob =3D tsz_oob, }; } =20 @@ -11372,6 +11381,21 @@ static bool get_phys_addr_lpae(CPUARMState *env, u= int64_t address, param =3D aa64_va_parameters(env, address, mmu_idx, access_type !=3D MMU_INST_FETCH); level =3D 0; + + /* + * If TxSZ is programmed to a value larger than the maximum, + * or smaller than the effective minimum, it is IMPLEMENTATION + * DEFINED whether we behave as if the field were programmed + * within bounds, or if a level 0 Translation fault is generated. + * + * With FEAT_LVA, fault on less than minimum becomes required, + * so our choice is to always raise the fault. + */ + if (param.tsz_oob) { + fault_type =3D ARMFault_Translation; + goto do_fault; + } + addrsize =3D 64 - 8 * param.tbi; inputsize =3D 64 - param.tsz; } else { --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466379105940.6840898395899; Wed, 9 Feb 2022 20:12:59 -0800 (PST) Received: from localhost ([::1]:58276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0pG-000574-3g for importer@patchew.org; Wed, 09 Feb 2022 23:12:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hL-0003wa-B4 for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:48 -0500 Received: from [2607:f8b0:4864:20::42a] (port=41983 helo=mail-pf1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hJ-00047B-K7 for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:47 -0500 Received: by mail-pf1-x42a.google.com with SMTP id i30so7963318pfk.8 for ; Wed, 09 Feb 2022 20:04:45 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hrRLKIw2UploLh3OYXeRorBfG35Au7O6BtUh3Pw46MI=; b=iBi1wrg4DQGv4B7r5taPRZ3/8W1VV57B/vUAAX7NvlrYXf1bLUL0cbPuJG7r8el9ov vvgcD4IdYSqeUPKWnRfXEsOaK5zNFQ5jgCEzjNyDVRxHs1D2VS01qfIbAeR6C20uNnSH XZNI9jsspQIPNebsQ38OCtGpwCs6oIZ83aybixWk5DlqJQBI5mqMrQILt/vuOgwQbRAM nBZQ8o9oUY/TSHsvldrfKhdlOOQlqjLSaMGgjfcTou8htfMwIl+0ZO5uCDHc8ndmUpu/ 4wacc4u5PUQ9+VekUMCybTZqhnqvbiQ931tM39Bh89U/HZwV8TOOMxAdnquP+nCDe1vL 30Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hrRLKIw2UploLh3OYXeRorBfG35Au7O6BtUh3Pw46MI=; b=rtFchY7SRUHGguh8g56LGLAEHLPIfBUNtneHygZ/22LqpMWODuH72T89baiBdts9lt QUXorjmyS4XwZAGxZoxN2FlABHTgM+qALrwGN936B9kdUI0VgRLniox5WfeaWGngiseh UBG3E4yTJS11xvRMZvG4epvTIFKSE6VEBUgqrwOSVH/NTlmxr53f6VH3AVPAjJvCJUYt kzVu+E5en/BrvPL6vEEsSoKBuhqZr692l5Li2MveyXuCo2x+CigVvGJz08UPe3q6hCq0 kEW35kIQIkliwz+G6L72J4hw6mxnfqq5VZomsijvHuDAVSRPAUYzQJ/oVtLjUS6D9Y0r pYoA== X-Gm-Message-State: AOAM533luGRSxInVQCI64ULeP6LKuldknlHYV7ENNcqsA0pbafA485jz lq65gsMkl0A4qCnFfI++uVGXlcyZ8fnyFmNi X-Google-Smtp-Source: ABdhPJygVkRQssZ6DGrIskSk9b4mojjSxaH827Koe8+9NAh4Jt+RvGE5gCdpeYolXN5EpRTreiL8RQ== X-Received: by 2002:a62:b618:: with SMTP id j24mr5792829pff.42.1644465884304; Wed, 09 Feb 2022 20:04:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 04/15] target/arm: Move arm_pamax out of line Date: Thu, 10 Feb 2022 15:04:12 +1100 Message-Id: <20220210040423.95120-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42a (failed) 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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466380993100001 We will shortly share parts of this function with other portions of address translation. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/internals.h | 19 +------------------ target/arm/helper.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index ef6c25d8cb..fefd1fb8d8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -243,24 +243,7 @@ static inline void update_spsel(CPUARMState *env, uint= 32_t imm) * Returns the implementation defined bit-width of physical addresses. * The ARMv8 reference manuals refer to this as PAMax(). */ -static inline unsigned int arm_pamax(ARMCPU *cpu) -{ - static const unsigned int pamax_map[] =3D { - [0] =3D 32, - [1] =3D 36, - [2] =3D 40, - [3] =3D 42, - [4] =3D 44, - [5] =3D 48, - }; - unsigned int parange =3D - FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); - - /* id_aa64mmfr0 is a read-only register so values outside of the - * supported mappings can be considered an implementation error. */ - assert(parange < ARRAY_SIZE(pamax_map)); - return pamax_map[parange]; -} +unsigned int arm_pamax(ARMCPU *cpu); =20 /* Return true if extended addresses are enabled. * This is always the case if our translation regime is 64 bit, diff --git a/target/arm/helper.c b/target/arm/helper.c index 14cc866d8d..fa0824e12c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11150,6 +11150,28 @@ static uint8_t convert_stage2_attrs(CPUARMState *e= nv, uint8_t s2attrs) } #endif /* !CONFIG_USER_ONLY */ =20 +/* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ +unsigned int arm_pamax(ARMCPU *cpu) +{ + static const unsigned int pamax_map[] =3D { + [0] =3D 32, + [1] =3D 36, + [2] =3D 40, + [3] =3D 42, + [4] =3D 44, + [5] =3D 48, + }; + unsigned int parange =3D + FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); + + /* + * id_aa64mmfr0 is a read-only register so values outside of the + * supported mappings can be considered an implementation error. + */ + assert(parange < ARRAY_SIZE(pamax_map)); + return pamax_map[parange]; +} + static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466414091443.6730348882171; Wed, 9 Feb 2022 20:13:34 -0800 (PST) Received: from localhost ([::1]:59812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0po-000671-SS for importer@patchew.org; Wed, 09 Feb 2022 23:13:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hN-0003x8-Il for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:49 -0500 Received: from [2607:f8b0:4864:20::1032] (port=44565 helo=mail-pj1-x1032.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hM-00047j-3l for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:49 -0500 Received: by mail-pj1-x1032.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so4307810pjh.3 for ; Wed, 09 Feb 2022 20:04:47 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kEVSOi5UkE1IrF02F4h1WkWrzoUBduclFFK91bx08AU=; b=YX6jH+v1OiS9An+7cc4yPISzo8OqdUTatWfsi9E9wwTMXef/fjm6nqNYZMeOKO5u1R nps0he/dQbeJ+DUKL6yHNrsHtfs4BdBHcsvwWB8XPuAjHBA0SVnBbdhOkiB/9Ecgz/RL fHt1NnRd8TgosGqW7I1tDM4xwbqcncO4iB9lXzaib9XIf7YDAjnM9f2G4NDkd1ixRheq YDUAgAu74laFveDoy3Mcsmghw0Rkqg4R6NPBchPocQzcHQHqHONUkG5gsJtIUB1g2tv9 okmKN6c31101m+W7T7WQaRyS1wsp+M8z64Ym4TFdJIzMudGEC9D+kQ7PzJzLmJ1UnkGl 3k5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kEVSOi5UkE1IrF02F4h1WkWrzoUBduclFFK91bx08AU=; b=iyqYGEqyo0aFunqvYUW59z4SqEUzOhym45e8ArAN9xO/fZWw4B/dBF8SFT/sK1v6ff QlRiukVTHM77uy/eMuwavY/KeiTlHDZVRjSwnpiNrJlj+NA/0Xs0qurB4aUqyjSEPzwQ jH7Rg5mLvE/kmaDTrNgedSU0/tfq47qS9Dh9cWj+02e4Obbg4aXfqZFNF6DBL5LVF/4A ucY2w6TUkHnoRlpmounGnS/3Ua12cxf7+hnpVSHRXjG+EFDVyMB+6BYH5YlL9wgbWUhN DhdS5nb7OjkpJ56kxH4++AY2f9G2FbuhA6Okeq9/EIZcqdMsM762BCdrw3BuyrcQ6AY5 qa9A== X-Gm-Message-State: AOAM530n0nJgzLCEQtF80lP9eTyzsG+M3T/mbDxmt2+l06KfT0pBa11o +psTjpSa17c6avn3h6OrrgbEK0QAU/4u4ms3 X-Google-Smtp-Source: ABdhPJz8Jn0JRUw6x62G0VbPLQZI80t/slSfi1HWgl0CHrOexz6N1gsWz3uVpYOUn8yWWJ9Dx3i75A== X-Received: by 2002:a17:902:e74d:: with SMTP id p13mr5566798plf.42.1644465886866; Wed, 09 Feb 2022 20:04:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/15] target/arm: Pass outputsize down to check_s2_mmu_setup Date: Thu, 10 Feb 2022 15:04:13 +1100 Message-Id: <20220210040423.95120-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1032 (failed) 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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466415451100001 Content-Type: text/plain; charset="utf-8" Pass down the width of the output address from translation. For now this is still just PAMax, but a subsequent patch will compute the correct value from TCR_ELx.{I}PS. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index fa0824e12c..cf38ebd816 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11063,7 +11063,7 @@ do_fault: * false otherwise. */ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride) + int inputsize, int stride, int outputsize) { const int grainsize =3D stride + 3; int startsizecheck; @@ -11079,22 +11079,19 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool = is_aa64, int level, } =20 if (is_aa64) { - CPUARMState *env =3D &cpu->env; - unsigned int pamax =3D arm_pamax(cpu); - switch (stride) { case 13: /* 64KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && pamax <=3D 42)) { + if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 42)) { return false; } break; case 11: /* 16KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && pamax <=3D 40)) { + if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 40)) { return false; } break; case 9: /* 4KB Pages. */ - if (level =3D=3D 0 && pamax <=3D 42) { + if (level =3D=3D 0 && outputsize <=3D 42) { return false; } break; @@ -11103,8 +11100,8 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is= _aa64, int level, } =20 /* Inputsize checks. */ - if (inputsize > pamax && - (arm_el_is_aa64(env, 1) || inputsize > 40)) { + if (inputsize > outputsize && + (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. = */ return false; } @@ -11390,7 +11387,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, ui= nt64_t address, target_ulong page_size; uint32_t attrs; int32_t stride; - int addrsize, inputsize; + int addrsize, inputsize, outputsize; TCR *tcr =3D regime_tcr(env, mmu_idx); int ap, ns, xn, pxn; uint32_t el =3D regime_el(env, mmu_idx); @@ -11420,11 +11417,13 @@ static bool get_phys_addr_lpae(CPUARMState *env, = uint64_t address, =20 addrsize =3D 64 - 8 * param.tbi; inputsize =3D 64 - param.tsz; + outputsize =3D arm_pamax(cpu); } else { param =3D aa32_va_parameters(env, address, mmu_idx); level =3D 1; addrsize =3D (mmu_idx =3D=3D ARMMMUIdx_Stage2 ? 40 : 32); inputsize =3D addrsize - param.tsz; + outputsize =3D 40; } =20 /* @@ -11509,7 +11508,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, ui= nt64_t address, =20 /* Check that the starting level is valid. */ ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, - inputsize, stride); + inputsize, stride, outputsize); if (!ok) { fault_type =3D ARMFault_Translation; goto do_fault; --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466758816969.5354607787402; Wed, 9 Feb 2022 20:19:18 -0800 (PST) Received: from localhost ([::1]:47368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0vO-0008Iu-Kj for importer@patchew.org; Wed, 09 Feb 2022 23:19:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0he-0004C2-Lu for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:30 -0500 Received: from [2607:f8b0:4864:20::432] (port=46699 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hP-00048F-IX for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:05 -0500 Received: by mail-pf1-x432.google.com with SMTP id i21so6501427pfd.13 for ; Wed, 09 Feb 2022 20:04:50 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A0BDFAPkSF6UtdIiOcrkoG8O0FSVru9MSa+YtK3MJG4=; b=VfVSvp1XHZhiM2vUDzkt3W1s8VjmnrZSjQVXCAsUprBedlGa1jLQnBI3S10ed6eTkF l5ayso7ftaaj0A36mQE3C0R/k8bFhU6V6PhhHVIKEVZMwVr9ctdk7jesG9KeWkDdI/8V o/knUIJNEyznA6uRWUkKqEXxmkKe/g2era05Xk07g1wgRx8xLobvkFUXI0WvhCNSB4Np wD+b7eczMzEQ/HEU7cBFQmzXSkvjH3uX+JDDJFe7y/wXtiGrkD4zBk2ghs8+A+7Goj1c 8U+Ee0vEysRJ6y6JLQcRRNiwKo9d3RNTKLhJzc/vF5ONgPMB2ykRsLj1YzuG8PI/wU0r RMrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A0BDFAPkSF6UtdIiOcrkoG8O0FSVru9MSa+YtK3MJG4=; b=G5CFOsPvbF3Sngm3jiNIiadJFd//niAQwOlQyS0Hi+r59GC+8++qP+wSiqK1ta6KjV VVLdh8i9Y6anoAh3rGWvPQPN2b2i8iQeOWgb2TO7n4DHdw4Z6bVbWzWtBAgnODNEfXMT p5qnkCg8QRkgi1+dX5n87pOc7zjIwkMB6gu4aGEKOOul+FlSFtlihBsagXGbr2FLHVb1 /SAHdPRFx6vc68qOtDMIxeWRLg9mgEyitFGVDEHKiH6P6C2gn96gQzg/TbbGYbq6vO3e s7gjlVMBKXmDcUzSOVDtT4wiJRxZO3ohpSmMHHn8/7nbkeAO98cPqpwKvhtGTVZoZ8DV Bgcw== X-Gm-Message-State: AOAM53226FRV4s6V6t33o3rF+r3rsD52xbq2QLjQwwZ/U7gmlKS66XJN p8GQRxHZzJHWJ03H+JMBnMbbMRrB12KO8ykC X-Google-Smtp-Source: ABdhPJwuZMsepO9q9/j09tINpIeynsZrU3+PTyL0HJCWT7jZ611no/AYpjpImPucm2E2oBFeJkptXw== X-Received: by 2002:a63:690a:: with SMTP id e10mr4589146pgc.599.1644465889715; Wed, 09 Feb 2022 20:04:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 06/15] target/arm: Use MAKE_64BIT_MASK to compute indexmask Date: Thu, 10 Feb 2022 15:04:14 +1100 Message-Id: <20220210040423.95120-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::432 (failed) 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::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466760383100001 Content-Type: text/plain; charset="utf-8" The macro is a bit more readable than the inlined computation. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index cf38ebd816..94304804cb 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11516,8 +11516,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, ui= nt64_t address, level =3D startlevel; } =20 - indexmask_grainsize =3D (1ULL << (stride + 3)) - 1; - indexmask =3D (1ULL << (inputsize - (stride * (4 - level)))) - 1; + indexmask_grainsize =3D MAKE_64BIT_MASK(0, stride + 3); + indexmask =3D MAKE_64BIT_MASK(0, inputsize - (stride * (4 - level))); =20 /* Now we can extract the actual base address from the TTBR */ descaddr =3D extract64(ttbr, 0, 48); --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466617028553.4555647548608; Wed, 9 Feb 2022 20:16:57 -0800 (PST) Received: from localhost ([::1]:41366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0t6-0004J4-P8 for importer@patchew.org; Wed, 09 Feb 2022 23:16:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hT-000433-Pn for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:56 -0500 Received: from [2607:f8b0:4864:20::432] (port=45661 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hR-00048i-R5 for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:55 -0500 Received: by mail-pf1-x432.google.com with SMTP id 9so5101381pfx.12 for ; Wed, 09 Feb 2022 20:04:53 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9unzvtzWabHumoVo2LIqZ3/KoNmw+Kj3VTUoCLWhgOA=; b=h+JwQgMiCcG0aahhuT+yB0y2quVt3pYL82kcF9qIdsWyERj151UAluYcuY7slyPR8P 8iwdBljIxk6WtBLjUyNb8lR6F6MoOVsrdWqyNq18b0Xw47khaERqTcYJBe5/7tLl1OgM AqekX6lgY3ATMIjohLnuji63vBgZizupHk1lbrmd3hPVD02M55IgENNAsiyvi2iSr0WN HvUILAaa0GwmrJyUk9ceLKja1JuHeXapBNczPqjJL7giGLQtV/Rxelz4RhrXf/a11kGA hyJwBaiXh3JTd8LIbikpfq5HMTmKY0Q1mAbsQkvzIzVJ/RPuSgFdK3MO0JPoqPwOJeaI vt/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9unzvtzWabHumoVo2LIqZ3/KoNmw+Kj3VTUoCLWhgOA=; b=2Ak4g7faoe+yLdfzID6qafFzmWSAjAzli1uMA08Ev0ZIP+VcxGjUyOvCQI635dBH2L vpfUwnvveIBjXQ2MNzHByto5It20FMBhD6rIdepnA+HFn3IxsfQM4h66S74eETjpiU1y 7bozhfyaM41U3iGFsKG1ynywKHvmh+cK0U6RVuojHVzsL5kIPLKlxnxCRXvJNtNaCUbr h482OmZ0ikUZQISgoQ5FFsj5b7wifLESPdwlu1WhYLthDIASbXxbfzaR+NEFtat+SFJM /ay/Bbl9fCVQK7s+rtqBFqo8I9gGMsxtCPjV+gVRHsb9pjrqUD8pdq12AfIwFO0R3hq9 XyAg== X-Gm-Message-State: AOAM531obEdP+9VdczyMTzGUp9PSfuoOYs3x0WBNz+PCdF7PHtvMsEI5 PtyXbnkssv9fbx6rkNg/pdb2pSIOT0WkDalS X-Google-Smtp-Source: ABdhPJyvhB3MYTLOaF6Fv80g/cx/bfQs8bEsnPNLx9GfBXiH0zxnzLhNfS6gCiKJpydPV3aJWyN+aw== X-Received: by 2002:a65:66d5:: with SMTP id c21mr701948pgw.152.1644465892535; Wed, 09 Feb 2022 20:04:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 07/15] target/arm: Honor TCR_ELx.{I}PS Date: Thu, 10 Feb 2022 15:04:15 +1100 Message-Id: <20220210040423.95120-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::432 (failed) 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::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466618816100001 This field controls the output (intermediate) physical address size of the translation process. V8 requires to raise an AddressSize fault if the page tables are programmed incorrectly, such that any intermediate descriptor address, or the final translated address, is out of range. Add a PS field to ARMVAParameters, and properly compute outputsize in get_phys_addr_lpae. Test the descaddr as extracted from TTBR and from page table entries. Restrict descaddrmask so that we won't raise the fault for v7. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/internals.h | 1 + target/arm/helper.c | 72 ++++++++++++++++++++++++++++++++---------- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index fefd1fb8d8..3d3d41ba2b 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1032,6 +1032,7 @@ static inline uint32_t aarch64_pstate_valid_mask(cons= t ARMISARegisters *id) */ typedef struct ARMVAParameters { unsigned tsz : 8; + unsigned ps : 3; unsigned select : 1; bool tbi : 1; bool epd : 1; diff --git a/target/arm/helper.c b/target/arm/helper.c index 94304804cb..015f992f02 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11147,17 +11147,19 @@ static uint8_t convert_stage2_attrs(CPUARMState *= env, uint8_t s2attrs) } #endif /* !CONFIG_USER_ONLY */ =20 +/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. = */ +static const uint8_t pamax_map[] =3D { + [0] =3D 32, + [1] =3D 36, + [2] =3D 40, + [3] =3D 42, + [4] =3D 44, + [5] =3D 48, +}; + /* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ unsigned int arm_pamax(ARMCPU *cpu) { - static const unsigned int pamax_map[] =3D { - [0] =3D 32, - [1] =3D 36, - [2] =3D 40, - [3] =3D 42, - [4] =3D 44, - [5] =3D 48, - }; unsigned int parange =3D FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); =20 @@ -11208,7 +11210,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, { uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; bool epd, hpd, using16k, using64k, tsz_oob; - int select, tsz, tbi, max_tsz, min_tsz; + int select, tsz, tbi, max_tsz, min_tsz, ps; =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; @@ -11222,6 +11224,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, hpd =3D extract32(tcr, 24, 1); } epd =3D false; + ps =3D extract32(tcr, 16, 3); } else { /* * Bit 55 is always between the two regions, and is canonical for @@ -11242,6 +11245,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, epd =3D extract32(tcr, 23, 1); hpd =3D extract64(tcr, 42, 1); } + ps =3D extract64(tcr, 32, 3); } =20 if (cpu_isar_feature(aa64_st, env_archcpu(env))) { @@ -11270,6 +11274,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, =20 return (ARMVAParameters) { .tsz =3D tsz, + .ps =3D ps, .select =3D select, .tbi =3D tbi, .epd =3D epd, @@ -11397,6 +11402,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, ui= nt64_t address, =20 /* TODO: This code does not support shareability levels. */ if (aarch64) { + int ps; + param =3D aa64_va_parameters(env, address, mmu_idx, access_type !=3D MMU_INST_FETCH); level =3D 0; @@ -11417,7 +11424,16 @@ static bool get_phys_addr_lpae(CPUARMState *env, u= int64_t address, =20 addrsize =3D 64 - 8 * param.tbi; inputsize =3D 64 - param.tsz; - outputsize =3D arm_pamax(cpu); + + /* + * Bound PS by PARANGE to find the effective output address size. + * ID_AA64MMFR0 is a read-only register so values outside of the + * supported mappings can be considered an implementation error. + */ + ps =3D FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); + ps =3D MIN(ps, param.ps); + assert(ps < ARRAY_SIZE(pamax_map)); + outputsize =3D pamax_map[ps]; } else { param =3D aa32_va_parameters(env, address, mmu_idx); level =3D 1; @@ -11521,19 +11537,38 @@ static bool get_phys_addr_lpae(CPUARMState *env, = uint64_t address, =20 /* Now we can extract the actual base address from the TTBR */ descaddr =3D extract64(ttbr, 0, 48); + + /* + * If the base address is out of range, raise AddressSizeFault. + * In the pseudocode, this is !IsZero(baseregister<47:outputsize>), + * but we've just cleared the bits above 47, so simplify the test. + */ + if (descaddr >> outputsize) { + level =3D 0; + fault_type =3D ARMFault_AddressSize; + goto do_fault; + } + /* * We rely on this masking to clear the RES0 bits at the bottom of the= TTBR * and also to mask out CnP (bit 0) which could validly be non-zero. */ descaddr &=3D ~indexmask; =20 - /* The address field in the descriptor goes up to bit 39 for ARMv7 - * but up to bit 47 for ARMv8, but we use the descaddrmask - * up to bit 39 for AArch32, because we don't need other bits in that = case - * to construct next descriptor address (anyway they should be all zer= oes). + /* + * For AArch32, the address field in the descriptor goes up to bit 39 + * for both v7 and v8. However, for v8 the SBZ bits [47:40] must be 0 + * or an AddressSize fault is raised. So for v8 we extract those SBZ + * bits as part of the address, which will be checked via outputsize. + * For AArch64, the address field always goes up to bit 47 (with extra + * bits for FEAT_LPA placed elsewhere). AArch64 implies v8. */ - descaddrmask =3D ((1ull << (aarch64 ? 48 : 40)) - 1) & - ~indexmask_grainsize; + if (arm_feature(env, ARM_FEATURE_V8)) { + descaddrmask =3D MAKE_64BIT_MASK(0, 48); + } else { + descaddrmask =3D MAKE_64BIT_MASK(0, 40); + } + descaddrmask &=3D ~indexmask_grainsize; =20 /* Secure accesses start with the page table in secure memory and * can be downgraded to non-secure at any step. Non-secure accesses @@ -11558,7 +11593,12 @@ static bool get_phys_addr_lpae(CPUARMState *env, u= int64_t address, /* Invalid, or the Reserved level 3 encoding */ goto do_fault; } + descaddr =3D descriptor & descaddrmask; + if (descaddr >> outputsize) { + fault_type =3D ARMFault_AddressSize; + goto do_fault; + } =20 if ((descriptor & 2) && (level < 3)) { /* Table entry. The top five bits are attributes which may --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466608824720.7119830764036; Wed, 9 Feb 2022 20:16:48 -0800 (PST) Received: from localhost ([::1]:40990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0sx-000451-Fa for importer@patchew.org; Wed, 09 Feb 2022 23:16:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hW-00045G-PQ for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:59 -0500 Received: from [2607:f8b0:4864:20::430] (port=33663 helo=mail-pf1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hU-000498-GQ for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:04:58 -0500 Received: by mail-pf1-x430.google.com with SMTP id i186so8096783pfe.0 for ; Wed, 09 Feb 2022 20:04:56 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yVExx3SXXr9h6DkfYn7yNhxsG0U7fq7HrQiNwR7HpZk=; b=fsL5LBG8K3oCMUeM+JopWyclUVsDw32EhvAFlE6HRLkdXrVz1Nk5yOcqw6SLxGVs9V eBXZgOUdIE+wK8ttHqJlRwnvm9tmzVwsvayxQZAP/zIm67vNOmcOamGe49MVWIJUESaD /DmWuWCwx1netcN011x6pGw8Jn4huH+5Txx123X0QiVF67SQvAmjLUGZnWyH1Sqj3z8V 2DVUOuwh/j4keI3yyWke6EwfCHrfSc6HBRQGcdkO4AHuoGkzXcZBuFwFxr3lSjDwhFhx 755dlRqwk58lj+b1V2zPAdGX1bZFJi1USPe/OjCDLZqDzdL7hWLxzCO2rgK0TBrCf3Oh kt5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yVExx3SXXr9h6DkfYn7yNhxsG0U7fq7HrQiNwR7HpZk=; b=kCho54plIq8gRYGDxHxPw+A57vKr+2ggeyj6Qe6nS26n3uH+kP3L6APNT0M3OWUBuy uVbjd2FTtMDrvsp3Rq8sY8WUgy29WMIFzXXSTWJSWT/afy1VyaePXsWHeYiswLkpzp9Q v2J2u7EnnuL9lqeELTnuRP9FFlip9mXfQ7Y3CSfWMEY2r/WKgzwl3AGixFUViJMjILQq eMO+bxi5p4a2+YhaJt6VVWA+s+a8Swt3pNBBg3swn3NOFbdW/vKBVbMwHlX4RsGd7/By Mx522TD/mjlB1WxmjVd5yhScIo41/iYwcAERo4IxvO+5+lvPnk8H08IjWH45+h7mA9+G klpw== X-Gm-Message-State: AOAM533j3Kp74zBs8MWt2sjkMPG6SBp8NhS/sMh0qHPJSxgu97Ul+U9O 1Lk8WG117tnyQ77iHVmagaqDy5MdqvDBFpuX X-Google-Smtp-Source: ABdhPJxE6sexassuQZ3i6aFXfBTQ3MnkusE7fg3W1cI/KiQ23+CrL/DagQE7BWRIC42FYOS32hEvjA== X-Received: by 2002:a63:4182:: with SMTP id o124mr4654288pga.479.1644465895232; Wed, 09 Feb 2022 20:04:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/15] target/arm: Prepare DBGBVR and DBGWVR for FEAT_LVA Date: Thu, 10 Feb 2022 15:04:16 +1100 Message-Id: <20220210040423.95120-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::430 (failed) 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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466610614100001 Content-Type: text/plain; charset="utf-8" The original A.a revision of the AArch64 ARM required that we force-extend the addresses in these registers from 49 bits. This language has been loosened via a combination of IMPLEMENTATION DEFINED and CONSTRAINTED UNPREDICTABLE to allow consideration of the entire aligned address. This means that we do not have to consider whether or not FEAT_LVA is enabled, and decide from which bit an address might need to be extended. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 015f992f02..e5050816cf 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6421,11 +6421,18 @@ static void dbgwvr_write(CPUARMState *env, const AR= MCPRegInfo *ri, ARMCPU *cpu =3D env_archcpu(env); int i =3D ri->crm; =20 - /* Bits [63:49] are hardwired to the value of bit [48]; that is, the - * register reads and behaves as if values written are sign extended. + /* * Bits [1:0] are RES0. + * + * It is IMPLEMENTATION DEFINED whether [63:49] ([63:53] with FEAT_LVA) + * are hardwired to the value of bit [48] ([52] with FEAT_LVA), or if + * they contain the value written. It is CONSTRAINED UNPREDICTABLE + * whether the RESS bits are ignored when comparing an address. + * + * Therefore we are allowed to compare the entire register, which lets + * us avoid considering whether or not FEAT_LVA is actually enabled. */ - value =3D sextract64(value, 0, 49) & ~3ULL; + value &=3D ~3ULL; =20 raw_write(env, ri, value); hw_watchpoint_update(cpu, i); @@ -6471,10 +6478,19 @@ void hw_breakpoint_update(ARMCPU *cpu, int n) case 0: /* unlinked address match */ case 1: /* linked address match */ { - /* Bits [63:49] are hardwired to the value of bit [48]; that is, - * we behave as if the register was sign extended. Bits [1:0] are - * RES0. The BAS field is used to allow setting breakpoints on 16 - * bit wide instructions; it is CONSTRAINED UNPREDICTABLE whether + /* + * Bits [1:0] are RES0. + * + * It is IMPLEMENTATION DEFINED whether bits [63:49] + * ([63:53] for FEAT_LVA) are hardwired to a copy of the sign bit + * of the VA field ([48] or [52] for FEAT_LVA), or whether the + * value is read as written. It is CONSTRAINED UNPREDICTABLE + * whether the RESS bits are ignored when comparing an address. + * Therefore we are allowed to compare the entire register, which + * lets us avoid considering whether FEAT_LVA is actually enabled. + * + * The BAS field is used to allow setting breakpoints on 16-bit + * wide instructions; it is CONSTRAINED UNPREDICTABLE whether * a bp will fire if the addresses covered by the bp and the addre= sses * covered by the insn overlap but the insn doesn't start at the * start of the bp address range. We choose to require the insn and @@ -6487,7 +6503,7 @@ void hw_breakpoint_update(ARMCPU *cpu, int n) * See also figure D2-3 in the v8 ARM ARM (DDI0487A.c). */ int bas =3D extract64(bcr, 5, 4); - addr =3D sextract64(bvr, 0, 49) & ~3ULL; + addr =3D bvr & ~3ULL; if (bas =3D=3D 0) { return; } --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466615122484.05668423355155; Wed, 9 Feb 2022 20:16:55 -0800 (PST) Received: from localhost ([::1]:41084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0t3-00048U-D5 for importer@patchew.org; Wed, 09 Feb 2022 23:16:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hZ-00046Q-6B for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:01 -0500 Received: from [2607:f8b0:4864:20::42e] (port=42990 helo=mail-pf1-x42e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hX-00049S-9e for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:00 -0500 Received: by mail-pf1-x42e.google.com with SMTP id i6so6085586pfc.9 for ; Wed, 09 Feb 2022 20:04:58 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:04:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wo37py8XK0LMBdk7Dcs+T7V1N42HxeZfeXF4Go5VbHY=; b=KmilAzqqzzMcK2CxmTEW+WnaO+0sT7KCHt56JNPJ8uY/BNOYDqhCDXj3KYZJx4beUA o3zyanFSUTCbH0ewp18YO7jfkDniWacZzHsQ9U/UxOkDyduLs6WR1H+8zCe2aRxfrFHq uJw0u8he6XRhPf8yhUJz1B41ouu0Kly0YmW4l1Qgc+dKh9jB6DQMKMzMrwWUgWYZXQt1 rYNVxt8GWtHjx2MrTk7jYE5ntXLmwcApE8wntYxphPSx9ivxqSPUqzXaeyjxLdNNDBx6 CiE2N9yHg1mL/yQxZxAAoq8PUqF/5KCr4/m7WjsVvjijDp7Z2sv2IcfbnFXRilm0Gcq4 nUlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wo37py8XK0LMBdk7Dcs+T7V1N42HxeZfeXF4Go5VbHY=; b=bNzldBqQT+Y+T3J+5T6l521uIs9bS41hmJBTeTQYBwz40mU6xE4fQMPnrYwsRFWd1s ti7fCAGR/G1yysigH5K7PVg/euV14ii8wol21yURjq4LQE+hjNx4URvdLU3h6QJRzLDd lnwSVpTRb5osqbIPua9/GmC/m4AjqP+p5sNhQi+QR4myoGxDoxJbK7W8AqgNPGIaKyCs wwzrNW9fArbKJR3EKoMBpZmuZAMPktPRk6m4Ia+9bnjiMxqLWfeXiCY4AQuCG2ebWE9m dJ5aPb3CbQkxtdbwXR8fYExUomuHJi414tluBQn4K3NKRyLWzpVtgcWzXd/bzHzsamlh XoKg== X-Gm-Message-State: AOAM530rJ8p0BheCdgTk9uv0F/6NHVdsCExt1rk/nbNa96iVfCChaJf0 I52DTX4BJyRhveuYsyrjdsBfgbNb3+R4f88z X-Google-Smtp-Source: ABdhPJxE/VuSory3V8kcYrxRf+ed8yEi0ab6dETq4smU4job76+/y0ApQEcoHbfxQZQTMKhZf1VjNw== X-Received: by 2002:a05:6a00:a1e:: with SMTP id p30mr5625210pfh.66.1644465898043; Wed, 09 Feb 2022 20:04:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 09/15] target/arm: Implement FEAT_LVA Date: Thu, 10 Feb 2022 15:04:17 +1100 Message-Id: <20220210040423.95120-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42e (failed) 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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466616759100001 Content-Type: text/plain; charset="utf-8" This feature is relatively small, as it applies only to 64k pages and thus requires no additional changes to the table descriptor walking algorithm, only a change to the minimum TSZ (which is the inverse of the maximum virtual address space size). Note that this feature widens VBAR_ELx, but we already treat the register as being 64 bits wide. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/cpu-param.h | 2 +- target/arm/cpu.h | 5 +++++ target/arm/cpu64.c | 1 + target/arm/helper.c | 9 ++++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index 7f38d33b8e..5f9c288b1a 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -11,7 +11,7 @@ #ifdef TARGET_AARCH64 # define TARGET_LONG_BITS 64 # define TARGET_PHYS_ADDR_SPACE_BITS 48 -# define TARGET_VIRT_ADDR_SPACE_BITS 48 +# define TARGET_VIRT_ADDR_SPACE_BITS 52 #else # define TARGET_LONG_BITS 32 # define TARGET_PHYS_ADDR_SPACE_BITS 40 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c6a4d50e82..c52d56f669 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -4289,6 +4289,11 @@ static inline bool isar_feature_aa64_ccidx(const ARM= ISARegisters *id) return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) !=3D 0; } =20 +static inline bool isar_feature_aa64_lva(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) !=3D 0; +} + static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) !=3D 0; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 8786be7783..d80a7eafac 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -781,6 +781,7 @@ static void aarch64_max_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); t =3D FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */ t =3D FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */ + t =3D FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LPA */ cpu->isar.id_aa64mmfr2 =3D t; =20 t =3D cpu->isar.id_aa64zfr0; diff --git a/target/arm/helper.c b/target/arm/helper.c index e5050816cf..62935b06d0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11269,7 +11269,14 @@ ARMVAParameters aa64_va_parameters(CPUARMState *en= v, uint64_t va, } else { max_tsz =3D 39; } - min_tsz =3D 16; /* TODO: ARMv8.2-LVA */ + + min_tsz =3D 16; + if (using64k) { + if (cpu_isar_feature(aa64_lva, env_archcpu(env))) { + min_tsz =3D 12; + } + } + /* TODO: FEAT_LPA2 */ =20 if (tsz > max_tsz) { tsz =3D max_tsz; --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466760625265.94773748373564; Wed, 9 Feb 2022 20:19:20 -0800 (PST) Received: from localhost ([::1]:47336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0vP-0008Hi-BT for importer@patchew.org; Wed, 09 Feb 2022 23:19:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0hb-000496-VZ for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:04 -0500 Received: from [2607:f8b0:4864:20::102c] (port=32853 helo=mail-pj1-x102c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0ha-00049y-10 for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:03 -0500 Received: by mail-pj1-x102c.google.com with SMTP id k60-20020a17090a4cc200b001b932781f3eso962050pjh.0 for ; Wed, 09 Feb 2022 20:05:01 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kHg4U9LRhzSdYYvCz2waEIRzlEfsFRMNDs65CPCnE5Y=; b=myMuzfW7WSHlmizCJsJixj3xK4uhQduOaVVLpApRtj4cxI+AFGwvDJR/rdVyrW9Xte 2sBaFQi8BAWhXFOIqqy7Kiv0MZOA7XGoUSM/J5AOfq6Os5Y1Jl72QS8dJCOlIm0LOXGD qN7dZt5HkEiLXXi68oC/c6ketEtW9pKpE2TDkNn3uVaa8TLtRaDKmGZEKWqnT7f2qdWD WZ48u/LMYXy7Gi+JpEoFWpX5q8GpJul2EaDXx662PWy4QEVXVeYKmwH8RUwy5RtXvIuz g9PylGgq3n40qjW6TDpqdCsVszhLlx/Q+4CPK4fYy/vOEKoE79YsNII/i/jIXx/UYvxn EuHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kHg4U9LRhzSdYYvCz2waEIRzlEfsFRMNDs65CPCnE5Y=; b=rseqk/KGmF5xN/oUw6bjeA59c5/+cnAMte+y0YPc511xLUeeQ6QZDlyAoEtnZg/OiK abqisIvjEBwoP49zkwVXu4UqKfZ9/TPgtsGdFJTBM6vVPhi4yT7mRM6Dd3aQb3zvN1gv uLZ2113qQ0RKWpL/8iqcb26W5YlrtH95TrrES9m8V8tagcRuLkU+LyHOCklWW1SaB1Wv vzTRlvjVIT8QQNIvEnfOvlGRPrQpZvQmbSf7W5E5ASLy/quAsixehQeCm+1fWtigYgsT MXnmmKmy+enKmqon8E17UJvxHCR48iBJN7RFCa2HbH20hT9jFOkSdMJPQ5dz5ssCPqYK UTwg== X-Gm-Message-State: AOAM533Ia8SiNvUjy6pSib+S3NwiCTcsjO7SKfBNEGnsB2IbA3MnlKCr j+4HFUSIlkEf84bIgrJAz/gZfOtK2SeWonJu X-Google-Smtp-Source: ABdhPJzcTo/TsjDbUlLvDWFORay22S2J2hwd9zT61Fz1FDO42Q6BWq1Tn11iC0n7IZndTuIdIVw4tA== X-Received: by 2002:a17:902:da86:: with SMTP id j6mr5779356plx.95.1644465900677; Wed, 09 Feb 2022 20:05:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/15] target/arm: Implement FEAT_LPA Date: Thu, 10 Feb 2022 15:04:18 +1100 Message-Id: <20220210040423.95120-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102c (failed) 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::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466762549100001 Content-Type: text/plain; charset="utf-8" This feature widens physical addresses (and intermediate physical addresses for 2-stage translation) from 48 to 52 bits, when using 64k pages. The only thing left at this point is to handle the extra bits in the TTBR and in the table descriptors. Note that PAR_EL1 and HPFAR_EL2 are nominally extended, but we don't mask out the high bits when writing to those registers, so no changes are required there. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu-param.h | 2 +- target/arm/cpu64.c | 2 +- target/arm/helper.c | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index 5f9c288b1a..b59d505761 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -10,7 +10,7 @@ =20 #ifdef TARGET_AARCH64 # define TARGET_LONG_BITS 64 -# define TARGET_PHYS_ADDR_SPACE_BITS 48 +# define TARGET_PHYS_ADDR_SPACE_BITS 52 # define TARGET_VIRT_ADDR_SPACE_BITS 52 #else # define TARGET_LONG_BITS 32 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index d80a7eafac..707ae7767f 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -765,7 +765,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_aa64pfr1 =3D t; =20 t =3D cpu->isar.id_aa64mmfr0; - t =3D FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 5); /* PARange: 48 bits= */ + t =3D FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 6); /* FEAT_LPA: 52 bit= s */ cpu->isar.id_aa64mmfr0 =3D t; =20 t =3D cpu->isar.id_aa64mmfr1; diff --git a/target/arm/helper.c b/target/arm/helper.c index 62935b06d0..9b1b1b2611 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11171,6 +11171,7 @@ static const uint8_t pamax_map[] =3D { [3] =3D 42, [4] =3D 44, [5] =3D 48, + [6] =3D 52, }; =20 /* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ @@ -11562,11 +11563,15 @@ static bool get_phys_addr_lpae(CPUARMState *env, = uint64_t address, descaddr =3D extract64(ttbr, 0, 48); =20 /* - * If the base address is out of range, raise AddressSizeFault. + * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [5:2] of T= TBR. + * + * Otherwise, if the base address is out of range, raise AddressSizeFa= ult. * In the pseudocode, this is !IsZero(baseregister<47:outputsize>), * but we've just cleared the bits above 47, so simplify the test. */ - if (descaddr >> outputsize) { + if (outputsize > 48) { + descaddr |=3D extract64(ttbr, 2, 4) << 48; + } else if (descaddr >> outputsize) { level =3D 0; fault_type =3D ARMFault_AddressSize; goto do_fault; @@ -11618,7 +11623,15 @@ static bool get_phys_addr_lpae(CPUARMState *env, u= int64_t address, } =20 descaddr =3D descriptor & descaddrmask; - if (descaddr >> outputsize) { + + /* + * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] + * of descriptor. Otherwise, if descaddr is out of range, raise + * AddressSizeFault. + */ + if (outputsize > 48) { + descaddr |=3D extract64(descriptor, 12, 4) << 48; + } else if (descaddr >> outputsize) { fault_type =3D ARMFault_AddressSize; goto do_fault; } --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466923951748.2367333039806; Wed, 9 Feb 2022 20:22:03 -0800 (PST) Received: from localhost ([::1]:51044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0y0-0002TG-NZ for importer@patchew.org; Wed, 09 Feb 2022 23:22:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0he-0004C3-Lv for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:30 -0500 Received: from [2607:f8b0:4864:20::435] (port=41484 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hc-0004EU-LN for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:05:05 -0500 Received: by mail-pf1-x435.google.com with SMTP id i30so7964424pfk.8 for ; Wed, 09 Feb 2022 20:05:04 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aZMJ4LHirkyrTFUMYXP3OGnbkdQ4YiqE1mw9fVX5Eu8=; b=dFiizMjuyAOlvpLu5BMIdCQJsiTAzJkRTbwCTyy3hUVEIrv4mlOyx434t0mPJEcMwj fFdfhVuEa8L57O6vmsO+0w53JIqIGp9TfXymIm+LXTydF4L3U7+1iHCOjF/Ry8HYwj94 bi10uJLjD7DxPDNRtr1zNDlTPbY08CtnCh6WtcFmj05FoWhcnC4sPoEpwoii3dge5QlL lxWG2QoNKKYnLPvN4WvIkijNXtRH8t6F4riu3QLwnuaYVcnrQD+/FFVIBnQHx5cSxMtE evDS/i3tysK1Wd4spYyEzZw5CIPeBcBrFotJsiLqFSdCRLyoEJ2uhrqZwjkFujtQWS1Z Z9LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aZMJ4LHirkyrTFUMYXP3OGnbkdQ4YiqE1mw9fVX5Eu8=; b=LX5IhGzv3ujQT+wvpT9GILnRsKqQtuR4rIimEhHTqUq6fbd46QL8QqRkDys75n/GXb l8hW70G/Tb3rlTIXAuGZxNfEDhYlHVmqbZBH+02joybJJIiaoTeVFbJXCjXNfOprqLDO Cctul1NhdPr/M5oq1g3dUD+BaQRHWqX3uli9UXXgcKQqk3w/pweNj1A2eHjQyjEL8kCT 8yEWRKuKhpwaNoYGqeUp0EXNOmk/PaD5whNrYvh7/j8XOdR/QhL+cUVNIEyPRBJDGJqd zXlIZP51SWHmq0xEobaI2iTWgZIQrKoCQuBK6k0vcnT1zLRYxvEWl/kybiAU9J/iv/KF Gf4A== X-Gm-Message-State: AOAM530ESSG3WgxYFIYJugBtUaFLzBOQhpn8CyVuMZw5IjSqd6+d/awd 7/A5Q3pJWBUo1uYBF+475dnhkCbi2CHsV/bN X-Google-Smtp-Source: ABdhPJxy0s3Ze8bTt8IOrs4J51aKpB5h/1mWWKMzCc3721UNkxernbxQU6A+2BljfDSDl0pafEhRgg== X-Received: by 2002:a63:5c0e:: with SMTP id q14mr4607661pgb.491.1644465903236; Wed, 09 Feb 2022 20:05:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 11/15] target/arm: Extend arm_fi_to_lfsc to level -1 Date: Thu, 10 Feb 2022 15:04:19 +1100 Message-Id: <20220210040423.95120-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::435 (failed) 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::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466925878100001 Content-Type: text/plain; charset="utf-8" With FEAT_LPA2, rather than introducing translation level 4, we introduce level -1, below the current level 0. Extend arm_fi_to_lfsc to handle these faults. Assert that this new translation level does not leak into faults types for which it is not defined, which allows some masking of fi->level to be removed. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/internals.h | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 3d3d41ba2b..00af41d792 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -462,28 +462,51 @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo= *fi) case ARMFault_None: return 0; case ARMFault_AddressSize: - fsc =3D fi->level & 3; + assert(fi->level >=3D -1 && fi->level <=3D 3); + if (fi->level < 0) { + fsc =3D 0b101001; + } else { + fsc =3D fi->level; + } break; case ARMFault_AccessFlag: - fsc =3D (fi->level & 3) | (0x2 << 2); + assert(fi->level >=3D 0 && fi->level <=3D 3); + fsc =3D 0b001000 | fi->level; break; case ARMFault_Permission: - fsc =3D (fi->level & 3) | (0x3 << 2); + assert(fi->level >=3D 0 && fi->level <=3D 3); + fsc =3D 0b001100 | fi->level; break; case ARMFault_Translation: - fsc =3D (fi->level & 3) | (0x1 << 2); + assert(fi->level >=3D -1 && fi->level <=3D 3); + if (fi->level < 0) { + fsc =3D 0b101011; + } else { + fsc =3D 0b000100 | fi->level; + } break; case ARMFault_SyncExternal: fsc =3D 0x10 | (fi->ea << 12); break; case ARMFault_SyncExternalOnWalk: - fsc =3D (fi->level & 3) | (0x5 << 2) | (fi->ea << 12); + assert(fi->level >=3D -1 && fi->level <=3D 3); + if (fi->level < 0) { + fsc =3D 0b010011; + } else { + fsc =3D 0b010100 | fi->level; + } + fsc |=3D fi->ea << 12; break; case ARMFault_SyncParity: fsc =3D 0x18; break; case ARMFault_SyncParityOnWalk: - fsc =3D (fi->level & 3) | (0x7 << 2); + assert(fi->level >=3D -1 && fi->level <=3D 3); + if (fi->level < 0) { + fsc =3D 0b011011; + } else { + fsc =3D 0b011100 | fi->level; + } break; case ARMFault_AsyncParity: fsc =3D 0x19; --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466318891656.7071427960652; Wed, 9 Feb 2022 20:11:58 -0800 (PST) Received: from localhost ([::1]:54994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0oH-0002wn-M5 for importer@patchew.org; Wed, 09 Feb 2022 23:11:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0jc-0004OH-UJ for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:08 -0500 Received: from [2607:f8b0:4864:20::636] (port=39933 helo=mail-pl1-x636.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0hp-0004Li-Da for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:03 -0500 Received: by mail-pl1-x636.google.com with SMTP id w1so742565plb.6 for ; Wed, 09 Feb 2022 20:05:07 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:05:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GtHWBu/qD/0bUllW5Gw8BHbTDtQN4Yofcww2tVSz2tQ=; b=kCkF8KGNhRNZoC5qieC/U/Lg9Y1J+IRE1/GYMka6glUR0MKjNGrCBltLzLbuc5XyL4 CUnknBGzSBwkiLdjW20WXSf1K+2WSwfeYvTGlQHUGZU96Wb6bo/XfonLWPyCGHpnei1g 3+NBx1RGIgyFI5MNkZI2AE1QdxY91F6ewXtA6Ed/lYtnhC6CNOVsRXl1NW0v8o6kgyJ/ MPRfsnaJWwoRjLluv2iTzVitr7gC1H/sfkCo1zn6L339XGt6vm8kgXHXeiFmmM561gWm gXV/rdd7CNos0pZv5zdS6euyp+Hx4xxUi3pC9/Le2ocGeqIPvw553eOufo2NTfbPQ8or CrRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GtHWBu/qD/0bUllW5Gw8BHbTDtQN4Yofcww2tVSz2tQ=; b=QMDaOEZc4Sm755Fo9rpGW2e/XpKjKrnn5jxNKDl5fTPK8TjuafNCnbN7ZpGSqPba/i TnGzXCFOAC2Eq8eCoDG2pl/Yl/FDejDDQFbRnykfJFBBeo/K+F+jqxC3fVv1VgUbwyoC rngzth2miZTI+jDX2zZDCPk4Hh0DW1frraOUNquvLbsOt+9iZ+JsBIfkf3ai81kLi4jH Sb7PW3TPME8KUyEbmQgWftN1Ps+5L09G1t98x8NZ0Bxwj902MQdPAOXqpelA/e181Qlp HeHzQjL9Nu5ZwOIMaw6SZeQlak2fd27ub4WMQxTuBUEe8uMEGx2d+ttde2K9IWBQOPDL ZDBA== X-Gm-Message-State: AOAM531/d/4Mx+RS6wrCiMlQ+pCZJxR4wGJp3Zdtqai3+DeZyXnJdFEu AnS0XrCkBF2cxJXnSLv03cEKYVXprbUua5tY X-Google-Smtp-Source: ABdhPJxWPEO53thfISXMnMYS/I7k5W7LAcD2DsY5unofEUdwapNVEJb8WpG0ayUycsKl8L0P+QKzXg== X-Received: by 2002:a17:903:2306:: with SMTP id d6mr5018868plh.14.1644465906216; Wed, 09 Feb 2022 20:05:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 12/15] target/arm: Introduce tlbi_aa64_get_range Date: Thu, 10 Feb 2022 15:04:20 +1100 Message-Id: <20220210040423.95120-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::636 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466321072100001 Content-Type: text/plain; charset="utf-8" Merge tlbi_aa64_range_get_length and tlbi_aa64_range_get_base, returning a structure containing both results. Pass in the ARMMMUIdx, rather than the digested two_ranges boolean. This is in preparation for FEAT_LPA2, where the interpretation of 'value' depends on the effective value of DS for the regime. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 58 +++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 9b1b1b2611..8b1899ceef 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4509,70 +4509,60 @@ static void tlbi_aa64_vae3is_write(CPUARMState *env= , const ARMCPRegInfo *ri, } =20 #ifdef TARGET_AARCH64 -static uint64_t tlbi_aa64_range_get_length(CPUARMState *env, - uint64_t value) -{ - unsigned int page_shift; - unsigned int page_size_granule; - uint64_t num; - uint64_t scale; - uint64_t exponent; +typedef struct { + uint64_t base; uint64_t length; +} TLBIRange; + +static TLBIRange tlbi_aa64_get_range(CPUARMState *env, ARMMMUIdx mmuidx, + uint64_t value) +{ + unsigned int page_size_granule, page_shift, num, scale, exponent; + TLBIRange ret =3D { }; =20 - num =3D extract64(value, 39, 5); - scale =3D extract64(value, 44, 2); page_size_granule =3D extract64(value, 46, 2); =20 if (page_size_granule =3D=3D 0) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid page size granule %d\n", page_size_granule); - return 0; + return ret; } =20 page_shift =3D (page_size_granule - 1) * 2 + 12; - + num =3D extract64(value, 39, 5); + scale =3D extract64(value, 44, 2); exponent =3D (5 * scale) + 1; - length =3D (num + 1) << (exponent + page_shift); =20 - return length; -} + ret.length =3D (num + 1) << (exponent + page_shift); =20 -static uint64_t tlbi_aa64_range_get_base(CPUARMState *env, uint64_t value, - bool two_ranges) -{ - /* TODO: ARMv8.7 FEAT_LPA2 */ - uint64_t pageaddr; - - if (two_ranges) { - pageaddr =3D sextract64(value, 0, 37) << TARGET_PAGE_BITS; + if (regime_has_2_ranges(mmuidx)) { + ret.base =3D sextract64(value, 0, 37) << TARGET_PAGE_BITS; } else { - pageaddr =3D extract64(value, 0, 37) << TARGET_PAGE_BITS; + ret.base =3D extract64(value, 0, 37) << TARGET_PAGE_BITS; } =20 - return pageaddr; + return ret; } =20 static void do_rvae_write(CPUARMState *env, uint64_t value, int idxmap, bool synced) { ARMMMUIdx one_idx =3D ARM_MMU_IDX_A | ctz32(idxmap); - bool two_ranges =3D regime_has_2_ranges(one_idx); - uint64_t baseaddr, length; + TLBIRange range; int bits; =20 - baseaddr =3D tlbi_aa64_range_get_base(env, value, two_ranges); - length =3D tlbi_aa64_range_get_length(env, value); - bits =3D tlbbits_for_regime(env, one_idx, baseaddr); + range =3D tlbi_aa64_get_range(env, one_idx, value); + bits =3D tlbbits_for_regime(env, one_idx, range.base); =20 if (synced) { tlb_flush_range_by_mmuidx_all_cpus_synced(env_cpu(env), - baseaddr, - length, + range.base, + range.length, idxmap, bits); } else { - tlb_flush_range_by_mmuidx(env_cpu(env), baseaddr, - length, idxmap, bits); + tlb_flush_range_by_mmuidx(env_cpu(env), range.base, + range.length, idxmap, bits); } } =20 --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644466478948616.508905481696; Wed, 9 Feb 2022 20:14:38 -0800 (PST) Received: from localhost ([::1]:36714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0qr-00017U-HU for importer@patchew.org; Wed, 09 Feb 2022 23:14:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0jc-0004OJ-Vo for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:09 -0500 Received: from [2607:f8b0:4864:20::434] (port=38792 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0jU-0004Lz-Pj for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:04 -0500 Received: by mail-pf1-x434.google.com with SMTP id x15so5567832pfr.5 for ; Wed, 09 Feb 2022 20:05:09 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ySk6DI87bH3eZGMitydYEQW5NydufZmFbEicSz0knRM=; b=dpyNdJ/FKi6Zmei/B8RXxNVHE0F3dnzClNKC/Chn7jfsgSbMp3Z3ZHnZzZhJi6TYeU Y4qToCWUSvQpHzFZVHK/yPcNTMajdFG80e0m8eYIg8Vldv/tZrVXdvjhYGoPpyxSVw3w PBSgLGUdJjLsOfADwOPKNzXFuoNOSbVihRAfWsKGoKTzlIUDl1JQ4BOD3/pi4Eqr62HB tAoFBAcWnn3nG1W32czzvmMVzyTz9OFd41t2Chl6k5tWichkJmpJdiI8BzftUMpzdNW7 qz49lRXNYlCdYFZ6x9CcYFG71NNNp5VuMLaUwB0Dm6ieIYqfwhWuMsht6FvFha4mygMA Qetw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ySk6DI87bH3eZGMitydYEQW5NydufZmFbEicSz0knRM=; b=p/72x6rYe6dzasazGN/jF5jykF6OKd8HBJxnlpLyda0aJ/nATZHM+pFRbQUoWfwKVl ILaZXbDN1dBX2iWzdYWvin6QOZKql+Q8pXpuf/alEYTwGmYO+bee0BwqKojagavF+6ov 05zygPrR1CEMxXaT3FdjwkVygy7K4eFq6u8LShwffMRslPaIz3eyG+lWmR9VBiCILh9a 8oJi2xp+UXcFCIO388wmHyYG+I3h4wK9XhZPfjtss7WLL6Yy36VP5ELEPfOFIGRzMTuJ LzQAt8tLlbOy271AhPMTv/sK8FuOcYnfIRlhQLM9GZExEN4MNtle3zi71OhNfMMry+N+ Cc2A== X-Gm-Message-State: AOAM531cuq7e6PlQI8ckNOj5FztvPZ9umD2bSWNu7k3odQDF9BjQNIkY k130/GmDqBo++1xcIW6MhAu7KnDgqdG60foK X-Google-Smtp-Source: ABdhPJw8KonN67F+wAYkGlmu4ESxVSktkJM3Mp7G2/79M3cEf5Cm9/v1Ugatsx2uNXDd6S8ol8yx3g== X-Received: by 2002:a05:6a02:195:: with SMTP id bj21mr4545558pgb.277.1644465908969; Wed, 09 Feb 2022 20:05:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 13/15] target/arm: Fix TLBIRange.base for 16k and 64k pages Date: Thu, 10 Feb 2022 15:04:21 +1100 Message-Id: <20220210040423.95120-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) 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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644466480601100001 Content-Type: text/plain; charset="utf-8" The shift of the BaseADDR field depends on the translation granule in use. Fixes: 84940ed8255 ("target/arm: Add support for FEAT_TLBIRANGE") Reported-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 8b1899ceef..e2551e693b 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4536,10 +4536,11 @@ static TLBIRange tlbi_aa64_get_range(CPUARMState *e= nv, ARMMMUIdx mmuidx, ret.length =3D (num + 1) << (exponent + page_shift); =20 if (regime_has_2_ranges(mmuidx)) { - ret.base =3D sextract64(value, 0, 37) << TARGET_PAGE_BITS; + ret.base =3D sextract64(value, 0, 37); } else { - ret.base =3D extract64(value, 0, 37) << TARGET_PAGE_BITS; + ret.base =3D extract64(value, 0, 37); } + ret.base <<=3D page_shift; =20 return ret; } --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164446718332324.722371272991154; Wed, 9 Feb 2022 20:26:23 -0800 (PST) Received: from localhost ([::1]:56966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI12D-0006Z5-W4 for importer@patchew.org; Wed, 09 Feb 2022 23:26:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0jd-0004OK-0N for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:09 -0500 Received: from [2607:f8b0:4864:20::1036] (port=43962 helo=mail-pj1-x1036.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0jU-0004ME-PT for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:04 -0500 Received: by mail-pj1-x1036.google.com with SMTP id t14-20020a17090a3e4e00b001b8f6032d96so4321719pjm.2 for ; Wed, 09 Feb 2022 20:05:12 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:05:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/PyGX3z0esgQKjWtAq0OXlyQ3FBYa3KsBIg46iOmGfg=; b=kfqC3NK4ri29kF9NBPjhhpz6IjztxGGBsIcc2ETKQDQVMot/koXli4OmLUFxRRQdf6 4fPCqGpCdyHxBjxgkX5fpmzdI+4n6xHK1Dbfpz2UMBEwq0MIjUInvqnZVzXhAzkcRy0w avttEZx4P4phkTLj6EtCAL4Sb9IFwISptCpcweYvX70tpCJi2Tg2nSnqI16q7Ig+2ILw K7OvAh23uar0xAKByTOcWDbqR1hlRqcPWMzrIliaZleexRI1KDAzUk101vd1q2kyRJTD RaNws58VWuIkaXJVSm0w4cmLlvWAKl1TNmGYgQX8BVp9LqlAyWlADlie3Rni/P5KvDdb 5FAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/PyGX3z0esgQKjWtAq0OXlyQ3FBYa3KsBIg46iOmGfg=; b=pQJxlPHYDwamhiUfBAGz36ull/W+ofW+wdaIscFaqDRMLR4MjKlnVPDWvj8TtkWPBV lyPASX7fvrM3DYHCa4XC+LQVf/DN+5caTucE3jn/PReHRackDqzQz3pASq1LhGv1nrpI y48+oOVsRCel2GMVuhGo3l+oyoVxVtfTyaRb8V2BaNKmyETvyLPUtIkSc9B5yTul143E JjHtB0mvsNC/Pxg33rx/dhpAoGxsRZbQAtz9xsgvcX0vVO3rgI3YRPH9CP3AcSGnZR+A QR+clFi340pe8Tbwf2EZGpOgaKmfUGu06X3QDyhW3dm84eLm2TtswCCLViNpvPywTL0s WY1g== X-Gm-Message-State: AOAM5304i1s0zd5MdZwYjzazP98FCxgcoa2CApIkgZjY+YpDQWoTQfqL KiqwQ9mA+AUgJ6J4089CnH21OLuJOf1YfVQP X-Google-Smtp-Source: ABdhPJxdORFKGt+AH+E+Z1p3QTMgjDJlZZiIFKYSfNOSKjfZPvQgifrV+te5bdK7mhZSV1uAGckLOw== X-Received: by 2002:a17:90a:19c2:: with SMTP id 2mr744294pjj.132.1644465911851; Wed, 09 Feb 2022 20:05:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/15] target/arm: Validate tlbi TG matches translation granule in use Date: Thu, 10 Feb 2022 15:04:22 +1100 Message-Id: <20220210040423.95120-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1036 (failed) 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::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644467185059100001 Content-Type: text/plain; charset="utf-8" For FEAT_LPA2, we will need other ARMVAParameters, which themselves depend on the translation granule in use. We might as well validate that the given TG matches; the architecture "does not require that the instruction invalidates any entries" if this is not true. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index e2551e693b..771de959dd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4518,12 +4518,16 @@ static TLBIRange tlbi_aa64_get_range(CPUARMState *e= nv, ARMMMUIdx mmuidx, uint64_t value) { unsigned int page_size_granule, page_shift, num, scale, exponent; + /* Extract one bit to represent the va selector in use. */ + uint64_t select =3D sextract64(value, 36, 1); + ARMVAParameters param =3D aa64_va_parameters(env, select, mmuidx, true= ); TLBIRange ret =3D { }; =20 page_size_granule =3D extract64(value, 46, 2); =20 - if (page_size_granule =3D=3D 0) { - qemu_log_mask(LOG_GUEST_ERROR, "Invalid page size granule %d\n", + /* The granule encoded in value must match the granule in use. */ + if (page_size_granule !=3D (param.using64k ? 3 : param.using16k ? 2 : = 1)) { + qemu_log_mask(LOG_GUEST_ERROR, "Invalid tlbi page size granule %d\= n", page_size_granule); return ret; } @@ -4535,7 +4539,7 @@ static TLBIRange tlbi_aa64_get_range(CPUARMState *env= , ARMMMUIdx mmuidx, =20 ret.length =3D (num + 1) << (exponent + page_shift); =20 - if (regime_has_2_ranges(mmuidx)) { + if (param.select) { ret.base =3D sextract64(value, 0, 37); } else { ret.base =3D extract64(value, 0, 37); --=20 2.25.1 From nobody Mon Feb 9 22:20:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164446701316638.14874145208137; Wed, 9 Feb 2022 20:23:33 -0800 (PST) Received: from localhost ([::1]:53676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI0zU-0004Gb-1n for importer@patchew.org; Wed, 09 Feb 2022 23:23:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0jc-0004OI-U7 for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:08 -0500 Received: from [2607:f8b0:4864:20::62a] (port=36823 helo=mail-pl1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0jU-0004Mh-PI for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:03 -0500 Received: by mail-pl1-x62a.google.com with SMTP id x3so751750pll.3 for ; Wed, 09 Feb 2022 20:05:15 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rl+deY7CG2LcOyT6/JU0+OryAiRw3UHGvhaIal+CJ9A=; b=bWtrIFoSs5PuGjsscb7b8/eW/WW1cavo3DDOXu2O59fl8H5CKwfJ1Ujbx71wHnqEJi n3F1hGe9Guo4RXvEELIHUYlovCbsovzQeTTp6eb62R5KpbwK2DrR5O+PJNYDKsUBpcb6 d5takqQ54eyNoXYqk3l7nKFZSkCG091eZeXigqL5GGDi6cHbE+sNV+2hSTKyfDVyZVk3 owahHlvplhbmcXzZX/u0qMUhy7HM6Z6tVDA/eNJuCDaeUugPZ9gYsiq7u0X9kzH15aCE ejMbhZRjwTy4VOb3ZLYCCSS/2/JgotI2k4bj3k2Mlsgztv1xOm+mBiXNiFEe1e1oxl7f LdIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rl+deY7CG2LcOyT6/JU0+OryAiRw3UHGvhaIal+CJ9A=; b=0fF8QMxe+G3tg4IM/UvYEU5bSi6NRe9YP+HZUPUHjSIF5Kr1O4px6UhqBvIV+lzf8V 8rG9AZOAJlXCW17YC+oNNuhpAnk8m7zNsbL7f/HaPO8bRMvSgKRkSNv5z1AcBgCaBJBj zWHbqQY4hwxMJakatR0TpEEZ1/KnYOB4LvmVDxxLI1xBWLQCgKNdykXMU2w4QuSCZxzR yZRhpcaWzK2pe3LFUxazPTRB+S1aEv6LQNUhBMe4DcM7g+Je1lP01kcQHwM8HVk6iR4B JplvjRPQeWBsPxTCgo1TxUygbhLz9el44nhJbJf1H/hH4ieEpUJoWp1DSop93QhIu+QR bSFQ== X-Gm-Message-State: AOAM533ABh7Ihmj2/xRTlviZuHYLhbOEnUqI7VfVx6rTwLrEU2jSM8RO 4ukcOa249pvfTLsGzw53U3NymY6PTiY/vxrs X-Google-Smtp-Source: ABdhPJx5nIpDzel28jebnQMYICp5EneOAlnSX+mODHYXP8FQNQJCvPOqdl8Od+a6Oel2kNq0OftKSQ== X-Received: by 2002:a17:90b:4c91:: with SMTP id my17mr722070pjb.221.1644465914575; Wed, 09 Feb 2022 20:05:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/15] target/arm: Implement FEAT_LPA2 Date: Thu, 10 Feb 2022 15:04:23 +1100 Message-Id: <20220210040423.95120-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62a (failed) 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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644467014552100001 Content-Type: text/plain; charset="utf-8" This feature widens physical addresses (and intermediate physical addresses for 2-stage translation) from 48 to 52 bits, when using 4k or 16k pages. This introduces the DS bit to TCR_ELx, which is RES0 unless the page size is enabled and supports LPA2, resulting in the effective value of DS for a given table walk. The DS bit changes the format of the page table descriptor slightly, moving the PS field out to TCR so that all pages have the same sharability and repurposing those bits of the page table descriptor for the highest bits of the output address. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- v2: Check DS in tlbi_aa64_get_range. Check TGRAN4_2 and TGRAN16_2. --- target/arm/cpu.h | 22 +++++++++ target/arm/internals.h | 2 + target/arm/cpu64.c | 4 ++ target/arm/helper.c | 102 +++++++++++++++++++++++++++++++++++------ 4 files changed, 115 insertions(+), 15 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c52d56f669..24d9fff170 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -4284,6 +4284,28 @@ static inline bool isar_feature_aa64_i8mm(const ARMI= SARegisters *id) return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, I8MM) !=3D 0; } =20 +static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) +{ + return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >=3D 1; +} + +static inline bool isar_feature_aa64_tgran4_2_lpa2(const ARMISARegisters *= id) +{ + unsigned t =3D FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); + return t >=3D 3 || (t =3D=3D 0 && isar_feature_aa64_tgran4_lpa2(id)); +} + +static inline bool isar_feature_aa64_tgran16_lpa2(const ARMISARegisters *i= d) +{ + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >=3D 2; +} + +static inline bool isar_feature_aa64_tgran16_2_lpa2(const ARMISARegisters = *id) +{ + unsigned t =3D FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); + return t >=3D 3 || (t =3D=3D 0 && isar_feature_aa64_tgran16_lpa2(id)); +} + static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) !=3D 0; diff --git a/target/arm/internals.h b/target/arm/internals.h index 00af41d792..a34be2e459 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1056,6 +1056,7 @@ static inline uint32_t aarch64_pstate_valid_mask(cons= t ARMISARegisters *id) typedef struct ARMVAParameters { unsigned tsz : 8; unsigned ps : 3; + unsigned sh : 2; unsigned select : 1; bool tbi : 1; bool epd : 1; @@ -1063,6 +1064,7 @@ typedef struct ARMVAParameters { bool using16k : 1; bool using64k : 1; bool tsz_oob : 1; /* tsz has been clamped to legal range */ + bool ds : 1; } ARMVAParameters; =20 ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 707ae7767f..9382c19e54 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -766,6 +766,10 @@ static void aarch64_max_initfn(Object *obj) =20 t =3D cpu->isar.id_aa64mmfr0; t =3D FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 6); /* FEAT_LPA: 52 bit= s */ + t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN16, 2); /* FEAT_LPA2: 52 bi= ts */ + t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN4, 1); /* FEAT_LPA2: 52 bi= ts */ + t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 3); /* FEAT_LPA2: 52 = bits */ + t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 3); /* FEAT_LPA2: 52 = bits */ cpu->isar.id_aa64mmfr0 =3D t; =20 t =3D cpu->isar.id_aa64mmfr1; diff --git a/target/arm/helper.c b/target/arm/helper.c index 771de959dd..bf694d8324 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4544,6 +4544,14 @@ static TLBIRange tlbi_aa64_get_range(CPUARMState *en= v, ARMMMUIdx mmuidx, } else { ret.base =3D extract64(value, 0, 37); } + if (param.ds) { + /* + * With DS=3D1, BaseADDR is always shifted 16 so that it is able + * to address all 52 va bits. The input address is perforce + * aligned on a 64k boundary regardless of translation granule. + */ + page_shift =3D 16; + } ret.base <<=3D page_shift; =20 return ret; @@ -11079,8 +11087,13 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool i= s_aa64, int level, const int grainsize =3D stride + 3; int startsizecheck; =20 - /* Negative levels are never allowed. */ - if (level < 0) { + /* + * Negative levels are usually not allowed... + * Except for FEAT_LPA2, 4k page table, 52-bit address space, which + * begins with level -1. Note that previous feature tests will have + * eliminated this combination if it is not enabled. + */ + if (level < (inputsize =3D=3D 52 && stride =3D=3D 9 ? -1 : 0)) { return false; } =20 @@ -11221,8 +11234,9 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, ARMMMUIdx mmu_idx, bool data) { uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; - bool epd, hpd, using16k, using64k, tsz_oob; - int select, tsz, tbi, max_tsz, min_tsz, ps; + bool epd, hpd, using16k, using64k, tsz_oob, ds; + int select, tsz, tbi, max_tsz, min_tsz, ps, sh; + ARMCPU *cpu =3D env_archcpu(env); =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; @@ -11236,7 +11250,9 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, hpd =3D extract32(tcr, 24, 1); } epd =3D false; + sh =3D extract32(tcr, 12, 2); ps =3D extract32(tcr, 16, 3); + ds =3D extract64(tcr, 32, 1); } else { /* * Bit 55 is always between the two regions, and is canonical for @@ -11246,6 +11262,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, if (!select) { tsz =3D extract32(tcr, 0, 6); epd =3D extract32(tcr, 7, 1); + sh =3D extract32(tcr, 12, 2); using64k =3D extract32(tcr, 14, 1); using16k =3D extract32(tcr, 15, 1); hpd =3D extract64(tcr, 41, 1); @@ -11255,24 +11272,51 @@ ARMVAParameters aa64_va_parameters(CPUARMState *e= nv, uint64_t va, using64k =3D tg =3D=3D 3; tsz =3D extract32(tcr, 16, 6); epd =3D extract32(tcr, 23, 1); + sh =3D extract32(tcr, 28, 2); hpd =3D extract64(tcr, 42, 1); } ps =3D extract64(tcr, 32, 3); + ds =3D extract64(tcr, 59, 1); } =20 - if (cpu_isar_feature(aa64_st, env_archcpu(env))) { + if (cpu_isar_feature(aa64_st, cpu)) { max_tsz =3D 48 - using64k; } else { max_tsz =3D 39; } =20 + /* + * DS is RES0 unless FEAT_LPA2 is supported for the given page size; + * adjust the effective value of DS, as documented. + */ min_tsz =3D 16; if (using64k) { - if (cpu_isar_feature(aa64_lva, env_archcpu(env))) { + if (cpu_isar_feature(aa64_lva, cpu)) { + min_tsz =3D 12; + } + ds =3D false; + } else if (ds) { + switch (mmu_idx) { + case ARMMMUIdx_Stage2: + case ARMMMUIdx_Stage2_S: + if (using16k) { + ds =3D cpu_isar_feature(aa64_tgran16_2_lpa2, cpu); + } else { + ds =3D cpu_isar_feature(aa64_tgran4_2_lpa2, cpu); + } + break; + default: + if (using16k) { + ds =3D cpu_isar_feature(aa64_tgran16_lpa2, cpu); + } else { + ds =3D cpu_isar_feature(aa64_tgran4_lpa2, cpu); + } + break; + } + if (ds) { min_tsz =3D 12; } } - /* TODO: FEAT_LPA2 */ =20 if (tsz > max_tsz) { tsz =3D max_tsz; @@ -11294,6 +11338,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, return (ARMVAParameters) { .tsz =3D tsz, .ps =3D ps, + .sh =3D sh, .select =3D select, .tbi =3D tbi, .epd =3D epd, @@ -11301,6 +11346,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, .using16k =3D using16k, .using64k =3D using64k, .tsz_oob =3D tsz_oob, + .ds =3D ds, }; } =20 @@ -11526,10 +11572,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, = uint64_t address, * VTCR_EL2.SL0 field (whose interpretation depends on the page si= ze) */ uint32_t sl0 =3D extract32(tcr->raw_tcr, 6, 2); + uint32_t sl2 =3D extract64(tcr->raw_tcr, 33, 1); uint32_t startlevel; bool ok; =20 - if (!aarch64 || stride =3D=3D 9) { + /* SL2 is RES0 unless DS=3D1 & 4kb granule. */ + if (param.ds && stride =3D=3D 9 && sl2) { + if (sl0 !=3D 0) { + level =3D 0; + fault_type =3D ARMFault_Translation; + goto do_fault; + } + startlevel =3D -1; + } else if (!aarch64 || stride =3D=3D 9) { /* AArch32 or 4KB pages */ startlevel =3D 2 - sl0; =20 @@ -11583,10 +11638,12 @@ static bool get_phys_addr_lpae(CPUARMState *env, = uint64_t address, * for both v7 and v8. However, for v8 the SBZ bits [47:40] must be 0 * or an AddressSize fault is raised. So for v8 we extract those SBZ * bits as part of the address, which will be checked via outputsize. - * For AArch64, the address field always goes up to bit 47 (with extra - * bits for FEAT_LPA placed elsewhere). AArch64 implies v8. + * For AArch64, the address field goes up to bit 47, or 49 with FEAT_L= PA2; + * the highest bits of a 52-bit output are placed elsewhere. */ - if (arm_feature(env, ARM_FEATURE_V8)) { + if (param.ds) { + descaddrmask =3D MAKE_64BIT_MASK(0, 50); + } else if (arm_feature(env, ARM_FEATURE_V8)) { descaddrmask =3D MAKE_64BIT_MASK(0, 48); } else { descaddrmask =3D MAKE_64BIT_MASK(0, 40); @@ -11621,11 +11678,16 @@ static bool get_phys_addr_lpae(CPUARMState *env, = uint64_t address, =20 /* * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] - * of descriptor. Otherwise, if descaddr is out of range, raise - * AddressSizeFault. + * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of + * descaddr are in [9:8]. Otherwise, if descaddr is out of range, + * raise AddressSizeFault. */ if (outputsize > 48) { - descaddr |=3D extract64(descriptor, 12, 4) << 48; + if (param.ds) { + descaddr |=3D extract64(descriptor, 8, 2) << 50; + } else { + descaddr |=3D extract64(descriptor, 12, 4) << 48; + } } else if (descaddr >> outputsize) { fault_type =3D ARMFault_AddressSize; goto do_fault; @@ -11719,7 +11781,17 @@ static bool get_phys_addr_lpae(CPUARMState *env, u= int64_t address, assert(attrindx <=3D 7); cacheattrs->attrs =3D extract64(mair, attrindx * 8, 8); } - cacheattrs->shareability =3D extract32(attrs, 6, 2); + + /* + * For FEAT_LPA2 and effective DS, the SH field in the attributes + * was re-purposed for output address bits. The SH attribute in + * that case comes from TCR_ELx, which we extracted earlier. + */ + if (param.ds) { + cacheattrs->shareability =3D param.sh; + } else { + cacheattrs->shareability =3D extract32(attrs, 6, 2); + } =20 *phys_ptr =3D descaddr; *page_size_ptr =3D page_size; --=20 2.25.1