From nobody Sun Jul 26 12:42:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1781800488; cv=none; d=zohomail.com; s=zohoarc; b=P8cKfTxYGQ/LZBDAl0jwFvQrJ7aqoyfY71t7fcIlK6mtO5RPJ/aAEJs4EieLn8YafTp3DYfY5JRyYlu2IWOI0FfiplzMFes0k/FATAy17eHujuxNQUb74xMwdsjQRsxUiJeLMqgHHzxTtEaW2ozwfsOLNA1I//70jJuyPWhvOKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781800488; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4hX01wxKGw3BuQr74QeKdveuBzAtu1koRwZnMOTRaN4=; b=faUYboCpv+hCGnyVA06CVSa5nWXPpCEDFYux9ppXsXQ4ERk2NjHOnxuC3vGFzE3ttVjFKbvb4vWvQ1vMreqvrRPbUsHlZKIrsbreNN83/QHRTuTPrcIlBkQg4wjARCVS1AwMjuAB5OCFeBMPg3dG1F9GT6HP3TuWjr2tlOZdMww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781800488091644.9095036609958; Thu, 18 Jun 2026 09:34:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waFgF-0006hN-CM; Thu, 18 Jun 2026 12:33:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waFg3-0006cw-Sn for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:15 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1waFg1-0006Kz-FK for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:15 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-45ef6565cfdso623361f8f.0 for ; Thu, 18 Jun 2026 09:33:13 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:b52:6a9:569d:e33e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4650bc426e1sm26942f8f.29.2026.06.18.09.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 09:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781800392; x=1782405192; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4hX01wxKGw3BuQr74QeKdveuBzAtu1koRwZnMOTRaN4=; b=an3QwisRzIbc1VaBEx51sXKZ9JLQZF02z04heHTaRzdh93XAvLV08+Rn8WQgc0l863 aHQ9SJXYNOhdDPX9geO9DziO2hyZz2StSwyP8XexQolMT03UZaW+KLNOaFAeXsKybBsH FxhLcl5Ykr0S+cX1c84FUj/b6+SNdEZsCMZ+PS4hcfn6xSzLmH/HQOQ3LMX9dT2ASxnM E0fZE62GUy8ynd//FTzLmikVEan9g2zdzmKdDlG74/p8stGyOJvMiwAjFRk/nSGrVdus 3FKddB6/G2R4jpMocXgl9g5FMBhw5u7FFz4PZvqQhdXoEds8elH8eQI5xpIv/2hZCY6e OJ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781800392; x=1782405192; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=4hX01wxKGw3BuQr74QeKdveuBzAtu1koRwZnMOTRaN4=; b=T2S+swm5R+/te0g/2DDhgdNLw43Ovp3njNjb/w2s/JbxoOEMQq9+WeWqz0q2oK4rVu 1w6J/7/FJImdGWfwm1rDN5KjivAZpKV1W6wchfs3m1qaknVcg9w3jmk1CYHekwqrmgWK QR9Omw1zomXkfh2UQdDoRupHf2xwAMgvqxM9L07rnanuJRkz734AHB72rjEjOA7XUlZR 3P5uslL03b//Du+yJ8mB9R66+l8Dn8nd9zcy64rmhEKBTm4zPUWptfnvboGDnoP+fd2+ 7pI4ZDnmLFERilUoeow4yiYffIVhtR++GcGtt5lFkFrcas44xSpmJKTiJgsuMVOpKHuI BqIQ== X-Gm-Message-State: AOJu0YwmERbKbPHEFBnMfUTiQKeVgklJf6BqzkgiCnpBphKIRzD+r/t6 GiEkBEvmtlqjy3fprp0zb1XCi3S60iYQjO5lctPCbggphgG8JpV5WB9V0wbblxSs2VU= X-Gm-Gg: AfdE7cn2fzWhSaprkWzgRYH4XF8EnNtm3bFXh/LGX+AKPKoDcs7hyj+73nfelwIxmLS RNwuZlFn3SZw0Wwgsdljy8bTFKTBr5R+S2fjlJybT/wdHHryhMBQw+f9x8JyCHL/fIXKMhJwKCX 3aKEZ4mFmLSxUz2BhNzMf0fljT6UT+CNj00vgM3TOcge15r4WKHdGzfnrAtTZflTiqVDdgPpG3h S4Sg2ieT2BA6kxgVHqetboLQ7JwgOBcDC91hqHaBwHaMkODSSgT9SF2ZPDsJuX2qoDnZEWdluPg TkPXcnUzkzU1tlcLPBN0YEjr4jp71/0RlMMoX+u7crBJ4a1swp7gKZWY1ZEQVr+yrbOf35u0fQ9 iwgCmexzDJZAG//47ZTMewXHVa77YWI4tVxRhtLONKpeayHuJLt1jeFydHafpLRLinYzoGNFg/0 Fh4qu7ptPASUJADg== X-Received: by 2002:a05:6000:1865:b0:461:9fc7:7d01 with SMTP id ffacd0b85a97d-46501685f0emr358890f8f.23.1781800391974; Thu, 18 Jun 2026 09:33:11 -0700 (PDT) From: Jim MacArthur Date: Thu, 18 Jun 2026 17:33:04 +0100 Subject: [PATCH v3 1/6] target/arm/tcg/cpu64.c: Extra test for GPC3. MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260618-jmac-gpc3b-v3-1-353e546067e7@linaro.org> References: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> In-Reply-To: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-arm@nongnu.org, Jim MacArthur , Richard Henderson X-Mailer: b4 0.13.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=jim.macarthur@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1781800489712158500 Reviewed-by: Richard Henderson Signed-off-by: Jim MacArthur --- target/arm/cpu-features.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 9e70d30964..26099f4c83 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -1159,6 +1159,11 @@ static inline bool isar_feature_aa64_rme_gpc2(const = ARMISARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64PFR0, RME) >=3D 2; } =20 +static inline bool isar_feature_aa64_rme_gpc3(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64PFR0, RME) >=3D 3; +} + static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64PFR0, DIT) !=3D 0; --=20 2.43.0 From nobody Sun Jul 26 12:42:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1781800445; cv=none; d=zohomail.com; s=zohoarc; b=P1ftMD5AuQVB4vLULtbgmKEVzIaJ9mmo1+Bpv5Hauu326G/rKRy1sMnGM8KuFdl2z5gMZyx8ZMtq81dnvCHrO2GP5WQJwqblHyQRDAInERVHF84fu5Q0JypRTuX1irGqIeGQL4hxivDNlPqR9YoiL+7/1WUl/RdTt9a2r7aqVSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781800445; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kea4dc/isoBx6rpEUTWsbHn6iNysu9QKjGPmvqVX+qw=; b=gdHyKXjpbV9tlrWbVVcCcifvn8wp7kuz3hubyRd/asd4pt/j+KF1V5igJhEEZD9wqGonZ3HJmpiv3/za4WOaBw1loRj8yO7jt+AUXvKZXOW2jlbET3l1Zh/gOQWIntDmGQIGYGkmTswoYCxBTecUFGfmlJMCZ4gL+7B54XyXv3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781800445515243.79171513088102; Thu, 18 Jun 2026 09:34:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waFgL-0006k7-UI; Thu, 18 Jun 2026 12:33:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waFg4-0006dJ-AV for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:16 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1waFg2-0006Lr-G2 for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:16 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-4629d80fa08so1163520f8f.3 for ; Thu, 18 Jun 2026 09:33:14 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:b52:6a9:569d:e33e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4650bc426e1sm26942f8f.29.2026.06.18.09.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 09:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781800393; x=1782405193; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kea4dc/isoBx6rpEUTWsbHn6iNysu9QKjGPmvqVX+qw=; b=yoDeb5v3OUKQfkubIRHaH244Ch5UYQeqgScWNgtQTMdrGlaEXUyfJkJDt97G9Vtpq1 zaxwofOKSOFRNln+L+4imwLaFTwuZaI+lJxRukHR5w3uW6m98KXfMHr9fqi7LuqHT3We foTbMCPGOUXGEOwLukqTH0IGgbvKayWnLrr6vQpdLus5OhjSx1HVJaMlWL2inWbTymsy MrERgHKAGUWopEImBRT3K+xNygmUssCiTfpu04g6OqfpuW029+c6dLtnO3ovspAkzrfF ptUkIYG+Va23pQQonDI9s1hbUhu1c9Pz9IypkA2T8ta3NAXsvjevpU8Xeb73hK1MC9dN OYSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781800393; x=1782405193; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=kea4dc/isoBx6rpEUTWsbHn6iNysu9QKjGPmvqVX+qw=; b=Adf6C5hRvUewjuDHlnVMwc7CZdzCqpSmtwXh8JWRohU9wrCCPcmjXEZ5ctO8sBU49y 942xp7yVjaF+DzY5F0mXXhbP1HJdLSgBNmJcR2k9Z3MlmFIHzC1xQXuBxs9+vCelA9cw LZKl94Z9BfaeSuoyPtZEjGHbGL6CosdByjQhHF0w/W9meHgxjpoAxla5/tnLGowxPlxy CRJFbGW02qs2TYro+/MIrBKkuaY97C/POOQINRzROcHac1UYBwH4ry4RApPJ+urLG0YY 0I39pwK6PsemVX56yTZ3VUgsjVjbeKvmtDIMLFW/ylFd0HilypS2CMaGd2mbtSyB2Kky h6Aw== X-Gm-Message-State: AOJu0YxCelB3CgzZw44Hq4ZQiTeLEdcBigdZ+NX4PfSjsStCS9RT8DG/ DV1UVG5p+dpI5+7rfhPsV6xctep0sSlChZcYAfKDzVcsYGwWjFzvLCBpnhPBzaFcwpY= X-Gm-Gg: AfdE7cnc2zbbMhmAWuKJU2NdvFA3s4pRWw9YlMMaLpamx5l5oOjrKZiqmMEsNbfqful Cq3tRMpgf9dRXu8C/Gpvw7DSg0ABCUV41kxcgknnlIcIiSN7cq1dQsrAgpE3HeITesGEOJxRcKQ kL5zyBmiApWzedj7ecNlB5WGjU0EZC/9TGTGJ14150mFITdbwttNUHMz9zojGP8s7nNKT86EVAP b1LuL+WpDPPks+OAIpEQ6HLayjC5KHCWv8kbclExCodCRD9pJglsRyE0+C+CWU21nR3XamWwt4u 01uJV0Zq5ebmi0huy8jOEfSApqOj478dvPOamk5+zsxcFFOYntHXH4AoCHkYcnaFO473xotWLbB uoGEEGL6GMo2ffwEVHknn7TyRB0s130yyOLzNXSfPKtw/QC/CX7rAVpxurpifbGvpjZm96hWONo 1JxFLoW9zJzq6isg== X-Received: by 2002:a5d:5f82:0:b0:45e:f2bd:2b17 with SMTP id ffacd0b85a97d-4650853517amr133653f8f.21.1781800392723; Thu, 18 Jun 2026 09:33:12 -0700 (PDT) From: Jim MacArthur Date: Thu, 18 Jun 2026 17:33:05 +0100 Subject: [PATCH v3 2/6] target/arm: Setup new registers for GPC3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260618-jmac-gpc3b-v3-2-353e546067e7@linaro.org> References: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> In-Reply-To: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-arm@nongnu.org, Jim MacArthur , Richard Henderson X-Mailer: b4 0.13.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=jim.macarthur@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1781800447351158500 Adds GPCBW_EL3. A custom write function is necessary to flush TLBs when this register is written. Also allows write to the GPCBW bit of GPCCR_EL3. Reviewed-by: Richard Henderson Signed-off-by: Jim MacArthur --- target/arm/cpu.h | 7 +++++++ target/arm/helper.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 31a5567c95..84d33e87dc 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -559,6 +559,7 @@ typedef struct CPUArchState { /* RME registers */ uint64_t gpccr_el3; uint64_t gptbr_el3; + uint64_t gpcbw_el3; uint64_t mfar_el3; =20 /* NV2 register */ @@ -1244,6 +1245,8 @@ void arm_v7m_cpu_do_interrupt(CPUState *cpu); typedef struct ARMGranuleProtectionConfig { /* GPCCR_EL3 */ uint64_t gpccr; + /* GPCBW_EL3 */ + uint64_t gpcbw; /* GPTBR_EL3 */ uint64_t gptbr; /* ID_AA64MMFR0_EL1.PARange */ @@ -2116,6 +2119,10 @@ FIELD(GPCCR, NA6, 27, 1) FIELD(GPCCR, NA7, 28, 1) FIELD(GPCCR, GPCBW, 29, 1) =20 +FIELD(GPCBW, BWSIZE, 37, 2) +FIELD(GPCBW, BWSTRIDE, 32, 5) +FIELD(GPCBW, BWADDR, 0, 25) + FIELD(MFAR, FPA, 12, 40) FIELD(MFAR, NSE, 62, 1) FIELD(MFAR, NS, 63, 1) diff --git a/target/arm/helper.c b/target/arm/helper.c index 22e71a2804..8538a28ce6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5001,6 +5001,10 @@ static void gpccr_write(CPUARMState *env, const ARMC= PRegInfo *ri, R_GPCCR_SPAD_MASK | R_GPCCR_NSPAD_MASK | R_GPCCR_RLPAD_= MASK; } =20 + if (cpu_isar_feature(aa64_rme_gpc3, env_archcpu(env))) { + rw_mask |=3D R_GPCCR_GPCBW_MASK; + } + env->cp15.gpccr_el3 =3D (value & rw_mask) | (env->cp15.gpccr_el3 & ~rw= _mask); } =20 @@ -5010,11 +5014,26 @@ static void gpccr_reset(CPUARMState *env, const ARM= CPRegInfo *ri) env_archcpu(env)->reset_l0gptsz); } =20 +static void gpcbw_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t rw_mask =3D R_GPCBW_BWADDR_MASK | R_GPCBW_BWSTRIDE_MASK | + R_GPCBW_BWSIZE_MASK; + ARMCPU *cpu =3D env_archcpu(env); + + tlb_flush(CPU(cpu)); + env->cp15.gpcbw_el3 =3D (value & rw_mask); +} + static const ARMCPRegInfo rme_reginfo[] =3D { { .name =3D "GPCCR_EL3", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 1, .opc2 =3D 6, .access =3D PL3_RW, .writefn =3D gpccr_write, .resetfn =3D gpccr_res= et, .fieldoffset =3D offsetof(CPUARMState, cp15.gpccr_el3) }, + { .name =3D "GPCBW_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 1, .opc2 =3D 5, + .access =3D PL3_RW, .writefn =3D gpcbw_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.gpcbw_el3) }, { .name =3D "GPTBR_EL3", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 1, .opc2 =3D 4, .access =3D PL3_RW, .fieldoffset =3D offsetof(CPUARMState, cp15.gptb= r_el3) }, --=20 2.43.0 From nobody Sun Jul 26 12:42:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1781800444; cv=none; d=zohomail.com; s=zohoarc; b=RP8AqlbMEdwr7h8+yB7vENzK6E9ZuL2g48Q8KpEaEq8C1Be9djPTlkvXJuHjrOMwopzdVKqccZi6j6X7SD3Lb+gtkQpixX9vlsppIPKyzILvooS/GdI/teBVn+fu7STmlNCuPjGMb+VFf2zqnGK6AfPk1YZP17w2e/D43+I21F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781800444; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DFZBT8LvMlXH9tb/dA5m2Omj2BFyYAOCQ6rYsyJrFYc=; b=UjQ3ZZujqs8nPUVljWZ3EmzlLDaEYaR0Z6sO7DFdY3gElzYwcLPNieZ9qWRoCksQaUc8QHH5y+4/72uUC4kqfCpvdsbqajtBEDOPCFMjTf2AIFgg8vmFxNFeUFu5tcRTN6Zlh/xYGKJ8uJeJVfSNVTnjgVeGDThY9LrgaPIPvso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781800444481261.9860684596151; Thu, 18 Jun 2026 09:34:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waFgL-0006k9-UP; Thu, 18 Jun 2026 12:33:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waFg5-0006eW-8Q for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:17 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1waFg3-0006Mb-1e for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:16 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4903d730b1fso13636915e9.2 for ; Thu, 18 Jun 2026 09:33:14 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:b52:6a9:569d:e33e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4650bc426e1sm26942f8f.29.2026.06.18.09.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 09:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781800393; x=1782405193; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DFZBT8LvMlXH9tb/dA5m2Omj2BFyYAOCQ6rYsyJrFYc=; b=pfnoUw58Gvkh31Ahg7TEu4T1t7ogaLHmD3KEoNxFn9Dggag70QrrJ+M4PXzvfEZ9Zh LWTkdZQLo0p9mfzb1akry75geYJ4Y951abm5tf73/phSPev2s4pNZJkunngoqqQN4AaD /Vh/LS7EdgSLyUiTl9WwMc6e3fyFJo5vKzbdwTpp7zuZJYkVGFdOK105ZE7KaSxDlmxA UryO+MLQqAR8K9axDeNwePpZB/JXDIm3o+uNUhbj3pkXpxdsew5ZXDMuMy3byuCfOaen iYHGTfIv2rd49qX/jl2FZKr4nbl2ZCoHRykwGC2dIg3TYJESF9nfebIZOz4YsNup4F46 3Kfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781800393; x=1782405193; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=DFZBT8LvMlXH9tb/dA5m2Omj2BFyYAOCQ6rYsyJrFYc=; b=a8Efffg88QY8v+WJMIvKuwFUhORGcF7FHSV1xAVchzCa4iExTOW6bDxemGwRsWOS5n lAgA9EZjb6vNPG63qvP9ny+nnreP5gbGlc1OBD6hD1xo8SV04lOZ+bVcaksUZvUTi/Bv /jBPomzFV9N7f7SA/19jDKJF9yXe7nUPlIv9r43HwNYRM11RuGh877JKQaIPQsN6uBTg MRVGwz9+mW/qV7kwnRi9cWPQbXH1mw4C227GauP+lFHow75sCTgACJvR1raQWs6rz0fV baw9cH9g8P8uIx0hCvAp2vcRnt3OVSBqQRY5D54ngHqlsPvWf1OsSN1E02cOx9OS29VC fvyw== X-Gm-Message-State: AOJu0YxXJNON6qORG1O6GZHqL7wBQqcbIXHZiiFwkZ5lLoX6T+kSmSkO mzWfITgfmRy+j4OUgE8qURzBygTVgiR3171a/eonFPatcc/3KpSM1zECnl0wddUz224Lhw4Se/a HXuBnG9g= X-Gm-Gg: AfdE7cnVp75xx7J0kjfmeMySU9pvF5ZB5ZyIsYIfSGp5rr4IB8rhCDXJYgLx/F7xT4Y Icewi8C7olEK1fua6qJHJH+fOcP6GC5X7zob3Q16wDiDCsxCdWzfu3Wb88HY4vAQ6po8UhDsMQ6 cRuFWyMhaAY/pnoE63WRlQFdO9X9ypdYcj/t8j+Ja0XLW4yII1pYureE6qijtk90DIFj4SwMIJf ybNNTeXQq+kXJY/uWfCvGP9vuJF/2ooHf4N4X/Bezo05kagCgPIpd+TyNFqRQFelqaQovyuGChf K1GMikAt3k2Gu8nEu1WPgqca4zKr9TSsrGm8Z1xbojSFlMSa7gqCI+vZAKR/Aysue2noRjUP220 YKouyiKke1A+8sxJ19MhofLqiKmOtLJOe7qKDG0mNzAjjeIgnXsepoK1DRPnCzfRwsLM2earchT O6p7Nt/1X5kAAVzQ== X-Received: by 2002:a05:600c:6386:b0:492:3763:aeb9 with SMTP id 5b1f17b1804b1-4923f6d2ff1mr4258645e9.21.1781800393457; Thu, 18 Jun 2026 09:33:13 -0700 (PDT) From: Jim MacArthur Date: Thu, 18 Jun 2026 17:33:06 +0100 Subject: [PATCH v3 3/6] target/arm/ptw.c: Add Granule Bypass Windows MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260618-jmac-gpc3b-v3-3-353e546067e7@linaro.org> References: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> In-Reply-To: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-arm@nongnu.org, Jim MacArthur X-Mailer: b4 0.13.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=jim.macarthur@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1781800445607158500 Signed-off-by: Jim MacArthur Reviewed-by: Richard Henderson --- target/arm/ptw.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 77 insertions(+) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 8b54018c98..493e198da7 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -341,11 +341,21 @@ bool arm_granule_protection_check(ARMGranuleProtectio= nConfig config, .space =3D ARMSS_Root, }; const uint64_t gpccr =3D config.gpccr; + const uint64_t gpcbw =3D config.gpcbw; unsigned pps, pgs, l0gptsz, level =3D 0; uint64_t tableaddr, pps_mask, align, entry, index; MemTxResult result; int gpi; =20 + const uint64_t BW_ADDR_SHIFT =3D 30; + const uint64_t BW_SIZE_SHIFT =3D 30; + const uint64_t BW_STRIDE_SHIFT =3D 40; + + uint64_t bw_size_field =3D FIELD_EX64(gpcbw, GPCBW, BWSIZE); + uint64_t bw_stride_field =3D FIELD_EX64(gpcbw, GPCBW, BWSTRIDE); + uint64_t bw_addr =3D FIELD_EX64(gpcbw, GPCBW, BWADDR) << BW_ADDR_SHIFT; + uint64_t bw_mask =3D 0; + /* * We assume Granule Protection Check is enabled when * calling this function (GPCCR.GPC =3D=3D 1). @@ -397,6 +407,58 @@ bool arm_granule_protection_check(ARMGranuleProtection= Config config, goto fault_walk; } =20 + /* At this point, GPCCR_EL3 is valid */ + + /* + * GPC Priority 1 (R_GMGRR): + * If GPCCR_EL3.GPCBW is 1 and the configuration GPCBW + * is invalid, the access fails as GPT walk fault at level 0. + */ + if (FIELD_EX64(gpccr, GPCCR, GPCBW)) { + uint64_t bw_size =3D 0; + uint64_t bw_stride =3D 0; + + /* BWSIZE, BWSTRIDE have a limited number of acceptable values. */ + switch (bw_size_field) { + case 0b000: + case 0b001: + case 0b010: + case 0b100: + case 0b110: + bw_size =3D 1ULL << (bw_size_field + BW_SIZE_SHIFT); + break; + default: /* Reserved value */ + goto fault_walk; + } + switch (bw_stride_field) { + case 0b00000: + case 0b00010: + case 0b00100: + case 0b00110: + case 0b00111: + case 0b01000: + case 0b01001: + case 0b01010: + case 0b10000: + bw_stride =3D 1ULL << (bw_stride_field + BW_STRIDE_SHIFT); + break; + default: /* Reserved value */ + goto fault_walk; + } + /* + * GPCBW is invalid if the base address is: + * not aligned to the size programmed in BWSIZE, or + * greater than or equal to the stride value configured by BWSTRID= E. + * We can make bw_mask which marks exactly which bits in bw_addr m= ay + * be set (gpcbwu:gpcbwl). + */ + bw_mask =3D bw_stride - bw_size; + + if (bw_addr & ~bw_mask) { + goto fault_walk; + } + } + /* Note this field is read-only and fixed at reset. */ l0gptsz =3D 30 + FIELD_EX64(gpccr, GPCCR, L0GPTSZ); =20 @@ -431,6 +493,20 @@ bool arm_granule_protection_check(ARMGranuleProtection= Config config, goto fault_fail; } =20 + /* + * Bypass window check. + * I_JJLRM: Granule Protection Table (GPT) lookups can be skipped + * in portions of the memory map by using GPC bypass windows. + * I_XNHTX: The GPC bypass window check (...) is performed + * immediately after priority 3. + * bw_mask from earlier makes this check for us. + */ + if (FIELD_EX64(gpccr, GPCCR, GPCBW)) { + if ((paddress & bw_mask) =3D=3D bw_addr) { + return true; + } + } + /* GPC Priority 4: the base address of GPTBR_EL3 exceeds PPS. */ tableaddr =3D config.gptbr << 12; if (tableaddr & ~pps_mask) { @@ -3861,6 +3937,7 @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Tra= nslate *ptw, }; struct ARMGranuleProtectionConfig config =3D { .gpccr =3D env->cp15.gpccr_el3, + .gpcbw =3D env->cp15.gpcbw_el3, .gptbr =3D env->cp15.gptbr_el3, .parange =3D FIELD_EX64_IDREG(&cpu->isar, ID_AA64MMFR0, PARANG= E), .support_sel2 =3D cpu_isar_feature(aa64_sel2, cpu), --=20 2.43.0 From nobody Sun Jul 26 12:42:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1781800444; cv=none; d=zohomail.com; s=zohoarc; b=EymPDkffFHm9fdSkeH8SxKCz2PbrN2Vcm2fS7aodCOP+Wq3AUgmTA1quOp9/B1Olp7VWlFS0hdDXxctnrgaBTKpHA7SBhFtbrMzyBqRqyjrohWMomiNFtEC/MQOR6rzrDWIlLcIiHIlV8T17eBhIW60kyic65f0EgrVij/5HMI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781800444; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4a+8aPCTN0sYynZsFAHEe+whp+fkeVx0KadfV1ixOEc=; b=BqEw7dVcKZoY6YuTyVyo2MQ4axApuGQdA+70flP5+OXJU5WKzTBAq0AULxUFL/Vg4r/aXNs2gYt2ItujqeHvrGpDwD9eE9tLjDDZYx0bwiYd+Bi/Kb1pqf1jnDAJrWQFOx7d3WdrC6P9o0Zndk2JKHPByKVtrHN9d3EqiS1h92A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781800444638273.1502609029168; Thu, 18 Jun 2026 09:34:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waFgP-0006kb-GE; Thu, 18 Jun 2026 12:33:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waFg5-0006eX-AR for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:17 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1waFg3-0006NE-PS for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:17 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-46066e640easo756046f8f.1 for ; Thu, 18 Jun 2026 09:33:15 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:b52:6a9:569d:e33e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4650bc426e1sm26942f8f.29.2026.06.18.09.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 09:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781800394; x=1782405194; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4a+8aPCTN0sYynZsFAHEe+whp+fkeVx0KadfV1ixOEc=; b=dB5Wynre4ZakszK6d2wAeFMJq8pqetA6WDFgC06mCbgrMsSoOxKF4SeZdAV2/VRg+7 pnMFoQDY+bxkV5T2v7akx5z5D820PNdvEMMkmFFQvrsw7nJQAPW3KSFP1zlZMPY2javC W3bTA2nOFOW+SW850zriKol8G5OTBAts+SS5N6ktXyhakY8KIm6c8ynz6HXrRq0KYdwe LQc8AZym5t4XOcH9miBUEf3ukVar/nOpx9AWafbOBdPRl6LEVtbzOinphtJ9tLscuXQ/ 45VbVK4DEYnrfdIGfZlv86z6+dA2BDeLQ6597GI5Lmh8b2jG9MW+uNIzK2NfGPdoR+io EIZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781800394; x=1782405194; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=4a+8aPCTN0sYynZsFAHEe+whp+fkeVx0KadfV1ixOEc=; b=PjU6AFc6Eny/x0czNnFPmwpC6YHiAuymfcN4k13n9y8OXrwpvqYTPg6BA1pNJLZ8Gs GIhiRnGx2onF1krea8OE0d5Op4Sg+xGi6EH7MrPYFeVM7g4IVrwCyBZ+EQWKHCBsSw6l vs6MCnnT44CvgiPf0HvGi2ytfyW28l+oYzi2mmBRByIBqRqirFyhlu6GBfUgwLEJiso1 2LXen4pqwBNuxjicaAodP0ftWuX/L3gLfPUCYrMfGKrBunf8dL1q2kjCPm1zGTTGnh6r A4zVNov2313aN5zfzvt0kuKrTPgj0620BEzDTsyzJcWWFqZ+L96HjLM4ELPB7zmrIa7k VLmQ== X-Gm-Message-State: AOJu0YwrdfvqNlgAhclU7VN7FVehqpDMyyxDUK7V/XvhrZnLwD87xmzY jQQ414hlx8STKa0RCi8yJJaZdHkHDwVcPCzUdXkyc8OHyOAIPJ6UnahjShorPIy4hdA= X-Gm-Gg: AfdE7cnFkKMl0nkt0Qky4bx6IAlccAGpgyH8e2W8tmvWZIaVKIRxYesiDtCzSz9+Ydp mh6GR4VlxB9/kWt45AZkcWVmqtRdwHMp6qv1WFXKbF7DoNP8LPgK5qvJMby3E1B28KWMUZwNReJ b3jWZ7F4OQwR4QZzTXfrGWyTbIaLELpOGm/yrV7t5+yqbpOMvnfifS1tpoZNLqrcjnU1MsPeX5R AEoGQ9Uu3y0MAbUDw+BGkx7R2n6Ea3+Ta0V8fKxyxrfw1lnb9hjVObf76QcQIHEUGC8UHaIDlOL XZ8Qnve4BOfJS7QZiDzZBfRCun1QflUB0fAN+QtyMA+u0bw/kr4bC764fpAdhPW4hZDxt9n0mMn rYpMpHrA3vZ8NWqxJTfly/fU4cSRwsHAhJIRuCQHmZ/8b2ZeF+Kquw0vxFwQftgh8cHbQ7xP1hL blbDAC1QpBQ+QT+Q== X-Received: by 2002:a05:6000:2209:b0:460:1a36:deac with SMTP id ffacd0b85a97d-4650978665amr100939f8f.24.1781800394188; Thu, 18 Jun 2026 09:33:14 -0700 (PDT) From: Jim MacArthur Date: Thu, 18 Jun 2026 17:33:07 +0100 Subject: [PATCH v3 4/6] target/arm/cpu-features.h: x-rme now means GPC3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260618-jmac-gpc3b-v3-4-353e546067e7@linaro.org> References: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> In-Reply-To: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-arm@nongnu.org, Jim MacArthur , Richard Henderson X-Mailer: b4 0.13.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=jim.macarthur@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1781800445557158500 Reviewed-by: Richard Henderson Signed-off-by: Jim MacArthur --- target/arm/tcg/cpu64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index f7a920a202..75c2027900 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -159,8 +159,8 @@ static void cpu_arm_set_rme(Object *obj, bool value, Er= ror **errp) { ARMCPU *cpu =3D ARM_CPU(obj); =20 - /* Enable FEAT_RME_GPC2 */ - FIELD_DP64_IDREG(&cpu->isar, ID_AA64PFR0, RME, value ? 2 : 0); + /* Enable FEAT_RME_GPC3 */ + FIELD_DP64_IDREG(&cpu->isar, ID_AA64PFR0, RME, value ? 3 : 0); } =20 static void cpu_max_set_l0gptsz(Object *obj, Visitor *v, const char *name, --=20 2.43.0 From nobody Sun Jul 26 12:42:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1781800455; cv=none; d=zohomail.com; s=zohoarc; b=B1j3RiwP+3dZg5cgqKaDYDbSrweS9gri+FREUBgNb3vQa1H/G0ZNZDtXgGLIg7CB3BTDVvp+dqea2OZyOxZlSCo1xgqSBCMAKACwddgEqlZKDohR3KCq74wn4RRwVNtSo2srcQfZGbHdR13axaCkRLTolw5IqMAdcdVhTTSwqvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781800455; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=52umHFSUDthXMcK75iwY6XmJbWZQ0XPbx9W1Vy1cSJY=; b=g4QIiegBe9nyWQ2dPIbjpqBpNjo1cQMJzPtldxiAF9Pgb+T6kp+Ad1CesCxn691B/iZFaqdqtc6tIXtIvqKOmPL5gfzOcwj1PtM1xtlPj0PkuvjG+CZFAaW0JTxWqwZkogvtvMPWGgqgunSqjohOeJy92ZpHRX0JhJh98MO/458= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178180045499211.681572103149051; Thu, 18 Jun 2026 09:34:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waFgJ-0006hi-Gw; Thu, 18 Jun 2026 12:33:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waFg6-0006gR-LS for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:19 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1waFg4-0006NR-GQ for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:18 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-49222b6e871so10173965e9.3 for ; Thu, 18 Jun 2026 09:33:16 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:b52:6a9:569d:e33e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4650bc426e1sm26942f8f.29.2026.06.18.09.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 09:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781800395; x=1782405195; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=52umHFSUDthXMcK75iwY6XmJbWZQ0XPbx9W1Vy1cSJY=; b=BI4kcPGd3K6nwhkYexHKqrfbuXtHKbakqPOqgqcGUZY/a+A67LkcusiqdO/nHNQLtt PPfvm/xQLt19V5znXhbLy8Dmabz6fpNYlcoXYJfJagyD3WbZ/0wVUW1Hq6W0aeeX7FJe VU9xgiIHqY8eqtuPoxfM69VHGvwYQ84v9U830cXKD0SjDRwXlVJZdrKUq5G3zCO8i1ny mxwg1dNa4gPOa8bP5MYlSgSFsIlU+gtlPDkPCoe4+VEdbbb4oUW91HvYuKExtrv1o6x9 pVef885iHHt2SACyq7TKkV5ez26Fj2HRlojQQRNOfwTNwIzQs3+GqnbGl1YNaSNRfO1j JvdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781800395; x=1782405195; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=52umHFSUDthXMcK75iwY6XmJbWZQ0XPbx9W1Vy1cSJY=; b=ZbS0bi+mhzVblLyfhEqmhuW8PF9Q3Q3YIH+k9kZxqrR2ckKkWu4wEaS6z+x3jiIGxG ZhssykMi0zCd4VhV3DQJ4de/aRz6d3vjqcuXPrQ/WPuE3mLakewrg2WJeiW4CNNe4ndb GHcZ+Gmk+2r5gNjWE+BoHKAdcF7AjKNmPPo/TRHCa7R8MceLoeNqC82puNXK8bqwn6gO zbUBGr0tlvjLmGhtDTMvHr+HQDAXDU0v7k7sk0Oxd4XSnjqf0iXG6pN+fDHPf8ey+XMI r+zH2oTlKHQIdFVzQwpxeyOzIKiXgFoTrDqihmydcWOTY5wBOhCG6Ilhd0AIz1KAbkIt 3JbQ== X-Gm-Message-State: AOJu0YyhI1qblHZlV86ElAtg/LQoDPc3FuA/3CqRP6kE7hEU6ksjRQhp f52/JbfupDVsQaw9QZbx0q5b0s9+b1cupUaPfJ0eQ8n6yoXvOhVeJ14Bw1889Xtj6QU= X-Gm-Gg: AfdE7cnkP/PEbgKs+v+lHfvfUjslf/vwOa2QboFrMY+yQhrNjtLuAWpo8k3xG2Gl87g 8SewQF9fNouAtK5AdOKaJn+w9T0GlDay1NQ5Ijsg1Cgfb+bGTeUOl81+VFafRQfdOScQnfUiW9O jOpwQripe/b16MxjJCGusRfNIc6/0IJoZ9FxHUtsSJjyxMxM9/IQk3DeQjwtnuVzuC/Ah8xkB5t sNjX6EI5qZo0YZxsoDGNogPQUVnlmteJkee+o2W6LL6xSbe6q78fOWoZu+tX1wBMW3Awg9ndNvK o7KQzGCtLNctdQzNqHxbVqjZ2pxJAB5IKLzqOg952PN89VruH88AgXfrNyCl6LxfoijB5YIP+Q9 UKBRJ9vSjNbWQC7ha7tGzq2/0KbSDqdUSiURPRDgZRh0+9A0iHQwN6eTIg0LOJGGuXgKKal2SAT QHoOMQvAsobPWprXNC5Bwe8nW2 X-Received: by 2002:a05:600c:4caa:b0:490:bad8:329c with SMTP id 5b1f17b1804b1-4923f33cfa3mr4326475e9.12.1781800394856; Thu, 18 Jun 2026 09:33:14 -0700 (PDT) From: Jim MacArthur Date: Thu, 18 Jun 2026 17:33:08 +0100 Subject: [PATCH v3 5/6] tests/tcg/aarch64/system: Alternative boot object for exception logging MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260618-jmac-gpc3b-v3-5-353e546067e7@linaro.org> References: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> In-Reply-To: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-arm@nongnu.org, Jim MacArthur X-Mailer: b4 0.13.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=jim.macarthur@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1781800457365158500 This allows us to record information about exceptions using a small area of memory, and continue with the test so it can verify exceptions have been taken where expected. LOGGING_VECTOR_TABLE is added to switch this on, and vec_logging_boot.o is built from boot.S with this flag. Since boot.o is created for multiple test targets, we have to build a separate object and selectively link this new vec_logging_boot.o into particular test binaries. Signed-off-by: Jim MacArthur Reviewed-by: Richard Henderson --- tests/tcg/aarch64/Makefile.softmmu-target | 11 ++++-- tests/tcg/aarch64/system/boot.S | 65 +++++++++++++++++++++++++++= ++++ tests/tcg/aarch64/system/boot.h | 14 +++++++ 3 files changed, 86 insertions(+), 4 deletions(-) diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/= Makefile.softmmu-target index f7a7d2b800..c353b7f8d6 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -25,7 +25,7 @@ LDFLAGS=3D-Wl,-T$(LINK_SCRIPT) TESTS+=3D$(AARCH64_TESTS) $(MULTIARCH_TESTS) EXTRA_RUNS+=3D$(MULTIARCH_RUNS) CFLAGS+=3D-nostdlib -ggdb -O0 $(MINILIB_INC) -LDFLAGS+=3D-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc +LDFLAGS+=3D-static -nostdlib $(MINILIB_OBJS) -lgcc =20 config-cc.mak: Makefile $(quiet-@)( \ @@ -36,17 +36,20 @@ config-cc.mak: Makefile # building head blobs .PRECIOUS: $(CRT_OBJS) =20 +vector_log_boot.o: $(CRT_PATH)/boot.S + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DLOGGING_VECTOR_TABLE -x assembler-with-= cpp -Wa,--noexecstack -c $< -o $@ + %.o: $(CRT_PATH)/%.S $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -Wa,--noexecstack -= c $< -o $@ =20 # Build and link the tests %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) boot.o =20 memory: CFLAGS+=3D-DCHECK_UNALIGNED=3D1 =20 memory-sve: memory.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) boot.o =20 memory-sve: CFLAGS+=3D-DCHECK_UNALIGNED=3D1 -march=3Darmv8.1-a+sve -O3 =20 @@ -107,7 +110,7 @@ QEMU_MTE_ENABLED_MACHINE=3D-M virt,mte=3Don -cpu max -d= isplay none QEMU_OPTS_WITH_MTE_ON =3D $(QEMU_MTE_ENABLED_MACHINE) $(QEMU_BASE_ARGS) -k= ernel mte: CFLAGS+=3D-march=3Darmv8.5-a+memtag mte: mte.S $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) boot.o =20 run-mte: QEMU_OPTS=3D$(QEMU_OPTS_WITH_MTE_ON) run-mte: mte diff --git a/tests/tcg/aarch64/system/boot.S b/tests/tcg/aarch64/system/boo= t.S index 8bfa4e4efc..c6e5ad889b 100644 --- a/tests/tcg/aarch64/system/boot.S +++ b/tests/tcg/aarch64/system/boot.S @@ -60,6 +60,40 @@ curr_sp0_irq: curr_sp0_fiq: curr_sp0_serror: curr_spx_sync: +#ifdef LOGGING_VECTOR_TABLE + sub sp, sp, #16 + stp x0, x1, [sp, #0] + mrs x0, ESR_EL3 + lsr x0, x0, #26 + and x0, x0, #0x3f + cmp x0, #37 + beq data_fault + cmp x0, #30 + beq gpc_fault + b generic_exception + +data_fault: + mrs x0, FAR_EL3 + adrp x1, exception_log + str x0, [x1] + ldr x0, =3D0x1001 + str x0, [x1, #8] + b skip_return +gpc_fault: + mrs x0, FAR_EL3 + adrp x1, exception_log + str x0, [x1] + ldr x0, =3D0x1002 + str x0, [x1, #8] + /* Fall through */ +skip_return: + mrs x0, ELR_EL3 + add x0, x0, #4 /* Skip faulting instruction */ + msr ELR_EL3, x0 + ldp x0, x1, [sp, #0] + add sp, sp, #16 + eret +#endif curr_spx_irq: curr_spx_fiq: curr_spx_serror: @@ -71,6 +105,7 @@ lower_a32_sync: lower_a32_irq: lower_a32_fiq: lower_a32_serror: +generic_exception: adr x1, .unexp_excp exit_msg: mov x0, SYS_WRITE0 @@ -404,6 +439,36 @@ ttb_stage2: .space 4096, 0 =20 .align 12 + .global realms_gpt0 + /* GPT stage 0 table */ +realms_gpt0: + .space 4096, 0 + .align 17 + .global realms_gpt1 + /* GPT stage 1 table, initialised to all 0xFF (full access) */ +realms_gpt1: + .space 524288, 0xFF +#ifdef LOGGING_VECTOR_TABLE + .align 12 + .global exception_fault_address + .type exception_fault_address, @object + .size exception_fault_address, 8 + .global exception_type_code + .type exception_type_code, @object + .size exception_type_code, 8 + /* + * These fields record details of the last exception, if + * LOGGING_VECTOR_TABLE is defined. + */ +exception_log: +exception_fault_address: + /* The contents of FAR_EL3 when an exception is taken. */ + .space 8, 0 +exception_type_code: + /* A generic code indicating what type of exception occurred. */ + .space 8, 0 +#endif + .align 12 system_stack: .space 4096, 0 system_stack_end: diff --git a/tests/tcg/aarch64/system/boot.h b/tests/tcg/aarch64/system/boo= t.h new file mode 100644 index 0000000000..cb9ab6c1b9 --- /dev/null +++ b/tests/tcg/aarch64/system/boot.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * + * + * Copyright (c) 2026 Linaro Ltd + * + */ + + +/* Global variables exported in boot.S */ +extern volatile uint64_t exception_fault_address; /* Updated by ISR */ +extern volatile uint64_t exception_type_code; /* Updated by ISR */ +extern uint64_t realms_gpt0[]; +extern uint64_t realms_gpt1[]; --=20 2.43.0 From nobody Sun Jul 26 12:42:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1781800445; cv=none; d=zohomail.com; s=zohoarc; b=WXoDd/At6WwgFjKKYd3zJUgBhMTdn6VOTCDO0SuG8Ud6zdjN+gQ6mv69TN0siJ/T0AILHqdFpHTD1+PRUpJeVd/a3DiMcPZO0brnTKtLNybQdfaEhrKnfWHIiJv1Gnq/93ts9IXaOxCu9Q61SzTtUgdoaozNDy4LfV1Sx1g4Aoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781800445; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CBl3lxo4oSOc7xKmASWjR8LYhrDOZUCfXMkQ+asxLqM=; b=oCegXeJWbLEipLcT5PZJuyd9BGEIiojAJc1VFdMCzexWmKA9E6hxv+OsCC+uitOgT9gBtXoCIGwOXHf3vzxPJWTl+FSY/BgJ0xp3gMeWSanSGllBV2N5pBu/7bl6r2Jw1QxVVxkoPTxZRUrwwkZj+NeK2H0BbSFdNlhwvCbVbX8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781800445214689.5869172787541; Thu, 18 Jun 2026 09:34:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waFgT-0006lD-C6; Thu, 18 Jun 2026 12:33:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waFg8-0006gb-0L for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:23 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1waFg5-0006OG-Vs for qemu-devel@nongnu.org; Thu, 18 Jun 2026 12:33:19 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-46066e640easo756083f8f.1 for ; Thu, 18 Jun 2026 09:33:17 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:b52:6a9:569d:e33e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4650bc426e1sm26942f8f.29.2026.06.18.09.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 09:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781800396; x=1782405196; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CBl3lxo4oSOc7xKmASWjR8LYhrDOZUCfXMkQ+asxLqM=; b=jqHcbr8x83GRI5eezrwmO5CWvLHr+cQBpK+5DC/CFJPGfFNq8o7NgVTBwx3vp5gpeZ HYFYCMoNbWGNeIem/s1902nIRzlBhdJ9lsPr0H7PD069RFplJ/MmLP/SLHFxBuwv1Kq3 j5IdwRvwnyHcwDyHWzXFuvoO3dOtRkAba+ntZVBvohU5+bxUwLMDupTUJHoEBvvOaQD5 5vwo5ZOfRbBw3/aVRznuUZCJPICO9a8cOV3xBm1D23BnLFkxQvgar7+i/mp+eVdJTaDO VvQ7ikb27t/O3qpFcOkTmDn/oLKcxWkr647vd8+rVj9P0AywMyeECfo1v//iTtWelPKi kArw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781800396; x=1782405196; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=CBl3lxo4oSOc7xKmASWjR8LYhrDOZUCfXMkQ+asxLqM=; b=qLyUYI5GYq3KwZYvqGllT2QWOIfyT/cNvpkqp6Cw+MJrPvYXlZ8oz0y0ME9ZqS/g8C Gt2eB4cExCjqS64JJpffDq74J+iL2p+O0ZzPNki9Q+UZ6iKp/bzXICl0qjUdOl+T21uT GMGlv3fEvJpAO+bE9WgiP5kgz/z16L/8D3UofIQ8yIp2f55f3LUhhpmTQAkVR81S4TCA 8X8SSL6HdPDCZU+xYvKQ5Vk7k/y39qSLeFo7jcEw0vTkj6dt0tDuxFx2I9bLV0ZSEgDZ EYwIcAQRgpCv21VNmivB0ddaysoOrAFjCDoxhp8N3jy6VUB/gASDevY6g42uYiBtD8Iw F3QA== X-Gm-Message-State: AOJu0YzDvE9BNQsPru3Qecw+7yKUDZjaee5WoqQ8m9HZb1xLM8zirORe 0+LKYVQ/XrYDkBLt7uqvc+P/ba6n0ZnDOa5tr2+8n0nnbLK1X7105zgAcvQ27dzyhpWPFfHmBw0 Rh8VuowQ= X-Gm-Gg: AfdE7cnRdUhFsUvimuxTsaxHGf9hOozj/Ij8t/O2UYCxY+7EPUeDQuzKnuJVxo4lgIK 4iB/dXWb36pMNu+6bVD11syHonxtvpmyvijckK3FRo7Qh/eIxiZ2xJ7XRUjf2q/7ErjT0yCiNVF w3xXQbQNqhSh/Gax/rlwXHU648mhMWEvrcpp+7nDoyppr58uS2gpwzHfc6tlTCYoBKihUpCjW+M 8XTg51xZmGppsBGEoL+P4uavDqoXmHgHgEec5P7QPGjlYgeX7j70RM7aMfG4lCvM8FacMCMbf7W ZtVWyrLK6aeXCjbgWcEjiviU7ZU38mPEsQwH1DyvEq6iDFMNlcj85moaX/bnaf/NU+o7oQZP0P5 ixpSmFDJ3C/3nay8B9vviaL6xq5MWS5SrGooeD9OHouF/FokuaudyXe2S1/9sqd4OtXEMlTva2L PgiXncLlnz5KaY8Q== X-Received: by 2002:a05:6000:46dc:b0:461:dcce:28c3 with SMTP id ffacd0b85a97d-46507c8e476mr96184f8f.17.1781800395539; Thu, 18 Jun 2026 09:33:15 -0700 (PDT) From: Jim MacArthur Date: Thu, 18 Jun 2026 17:33:09 +0100 Subject: [PATCH v3 6/6] tests/tcg/aarch64/system/gpc-test.c: Basic test for granule protection check MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260618-jmac-gpc3b-v3-6-353e546067e7@linaro.org> References: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> In-Reply-To: <20260618-jmac-gpc3b-v3-0-353e546067e7@linaro.org> To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-arm@nongnu.org, Jim MacArthur , Richard Henderson X-Mailer: b4 0.13.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=jim.macarthur@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1781800447460158500 * Sets up granule protection tables * Enables GPC and bypass windows * Performs memory accesses in the protected region to check for allowed and disallowed reads. Reviewed-by: Richard Henderson Signed-off-by: Jim MacArthur --- tests/tcg/aarch64/Makefile.softmmu-target | 11 +- tests/tcg/aarch64/system/gpc-test.c | 165 ++++++++++++++++++++++++++= ++++ 2 files changed, 175 insertions(+), 1 deletion(-) diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/= Makefile.softmmu-target index c353b7f8d6..3f30be6c5d 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -53,7 +53,10 @@ memory-sve: memory.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILI= B_OBJS) =20 memory-sve: CFLAGS+=3D-DCHECK_UNALIGNED=3D1 -march=3Darmv8.1-a+sve -O3 =20 -TESTS+=3Dmemory-sve +gpc-test: gpc-test.c $(LINK_SCRIPT) vector_log_boot.o $(MINILIB_OBJS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) vector_log_boot.o + +TESTS+=3Dmemory-sve gpc-test =20 # Running QEMU_BASE_MACHINE=3D-M virt -cpu max -display none @@ -74,6 +77,12 @@ QEMU_EL2_MACHINE=3D-machine virt,virtualization=3Don,gic= -version=3D2 -cpu cortex-a57 - QEMU_EL2_BASE_ARGS=3D-semihosting-config enable=3Don,target=3Dnative,chard= ev=3Doutput,arg=3D"2" run-vtimer: QEMU_OPTS=3D$(QEMU_EL2_MACHINE) $(QEMU_EL2_BASE_ARGS) -kernel =20 +# gpc tests need EL3 and RME +QEMU_EL3_MACHINE=3D-machine virt,virtualization=3Don,secure=3Don,gic-versi= on=3D3 -cpu max,x-rme=3Don +QEMU_EL3_BASE_ARGS=3D-semihosting-config enable=3Don,target=3Dnative,chard= ev=3Doutput,arg=3D"3" +run-gpc-test: QEMU_OPTS=3D$(QEMU_EL3_MACHINE) $(QEMU_EL3_BASE_ARGS) -kern= el +run-gpc3-test: QEMU_OPTS=3D$(QEMU_EL3_MACHINE) $(QEMU_EL3_BASE_ARGS) -kern= el + # Simple Record/Replay Test .PHONY: memory-record run-memory-record: memory-record memory diff --git a/tests/tcg/aarch64/system/gpc-test.c b/tests/tcg/aarch64/system= /gpc-test.c new file mode 100644 index 0000000000..f26b23efaf --- /dev/null +++ b/tests/tcg/aarch64/system/gpc-test.c @@ -0,0 +1,165 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * + * + * Copyright (c) 2026 Linaro Ltd + * + */ + +#include +#include +#include +#include "boot.h" + +#define ID_AA64PFR0_EL1 "S3_0_C0_C4_0" + +#define GPTBR_EL3 "S3_6_C2_C1_4" +#define GPCBW_EL3 "S3_6_C2_C1_5" +#define GPCCR_EL3 "S3_6_C2_C1_6" +#define VBAR_EL3 "S3_6_C12_C0_0" + +#define get_sys_reg(register_name, dest) \ + asm("mrs %[reg], " register_name "\n\t" : [reg] "=3Dr" (dest)) +#define set_sys_reg(register_name, value) \ + asm("msr " register_name ", %[reg]\n\r" : : [reg] "r" (value)) + +const uint32_t gpc_granule_size =3D 4096; +const uint32_t gpis_per_64_bits =3D 16; + +int main(uint64_t sp) +{ + uint64_t out; + uint64_t pfr0; + uint64_t gpt_base; + uint64_t rme_status; + uint64_t currentel_raw; + uint64_t currentel; + uint64_t gpcbw; + uint64_t gpt_table0_addr =3D (uint64_t) realms_gpt0; + uint64_t gpt_table1_addr =3D (uint64_t) realms_gpt1; + + /* Mask is FNG1, FNG0, and A2 */ + const uint64_t feature_mask =3D (1ULL << 18 | 1ULL << 17 | 1ULL << 16); + const uint64_t in =3D feature_mask; + + get_sys_reg("CurrentEL", currentel_raw); + currentel =3D (currentel_raw >> 2) & 0x3; + + if (currentel < 3) { + ml_printf("FAIL: Test must be run at EL3 (it is %d)\n", currentel); + return 1; + } + + get_sys_reg(ID_AA64PFR0_EL1, pfr0); + + /* rme_status is 1 for RME, 2 for RME + GPC2, 3 for RME+GPC3 */ + rme_status =3D (pfr0 >> 52) & 0xF; + if (rme_status < 2) { + ml_printf("SKIP: System does not support RME (RME=3D%ld)\n", rme_s= tatus); + return 0; + } + + /* Configure the level 0 table for the first 4GB of memory */ + realms_gpt0[0] =3D gpt_table1_addr | 0x3; /* Covers GB 0; table descri= ptor */ + realms_gpt0[1] =3D 0xf1; /* Covers GB 1; full access */ + realms_gpt0[2] =3D 0xf1; /* Covers GB 2; full access */ + realms_gpt0[3] =3D 0xf1; /* Covers GB 3; full access */ + + /* Pick an artibtrary location to read inside the first 1GB. */ + uint64_t fault_location =3D 0x10202008; + uint32_t gpi_index =3D fault_location / gpc_granule_size; + realms_gpt1[gpi_index / gpis_per_64_bits] =3D 0; + + gpt_base =3D gpt_table0_addr >> 12; + set_sys_reg(GPTBR_EL3, gpt_base); + + /* + * Default values: + * PPS=3D0: GPC table 0 protects 4GB. + * RLPAD=3D0: Realm physical address spaces are normal + * NSPAD=3D0: Non-secure physical address spaces are normal + * SPAD=3D0: Secure physical address spaces are normal + * IRGN=3D0: Inner non-cacheable + * ORGN=3D0: Outer non-cacheable + * PGS=3D0: Physical granule size is 4KB. + * GPCP=3D0: All GPC faults reported + * TBGPCP=3D0: Trace buffer rejects trace + * L0GPTSZ=3D0: Each entry in table 0 protects 1GB. + * APPSAA=3D0: Accesses above 4GB must be to Non-secure PAs + * GPCBW=3D0: Bypass windows disabled. + * NA6, NA7, NSP, SA, NSO are all reserved values for GPI. + */ + uint64_t gpccr =3D 0; + + /* Switch on granule protection check */ + gpccr |=3D 1 << 16; /* GPC enabled. */ + gpccr |=3D 0b10 << 12; /* SH =3D Outer shareable */ + set_sys_reg(GPCCR_EL3, gpccr); + + /* Access some memory outside the GPC forbidden region */ + uint64_t x =3D *(unsigned int *) (fault_location + 4096 * 16); + ml_printf("Fault address: %lx\n", exception_fault_address); + if (exception_fault_address !=3D 0) { + ml_printf("FAIL: Memory access was blocked by GPC, " + "and should not have been\n"); + return 1; + } + + /* Access the GPC forbidden region */ + x =3D *(unsigned int *) fault_location; + + ml_printf("Fault address: %lx\n", exception_fault_address); + if (exception_fault_address !=3D fault_location) { + ml_printf("FAIL: Memory access was not blocked by GPC, " + "and should have been\n"); + return 1; + } + + rme_status =3D (pfr0 >> 52) & 0xF; + if (rme_status < 3) { + ml_printf("SKIP: System does not support GPC3 (RME=3D%ld)\n", rme_= status); + return 0; + } + + /* Clear the exception record */ + exception_fault_address =3D 0; + + /* Enable bypass windows */ + gpccr |=3D 1 << 29; /* GPC Bypass windows enabled */ + set_sys_reg(GPCCR_EL3, gpccr); + + gpcbw =3D 0; /* Base 0GB, Size 1GB, Stride 1TB */ + set_sys_reg(GPCBW_EL3, gpcbw); + ml_printf("GPCBW configured\n"); + + /* Access the GPC forbidden region again */ + x =3D *(unsigned int *) fault_location; + + ml_printf("Fault address: %lx\n", exception_fault_address); + if (exception_fault_address !=3D 0) { + ml_printf("FAIL: Memory access was blocked by GPC, " + "and should have been allowed by bypass window. code=3D%= lx\n", + exception_type_code); + return 1; + } + + /* Clear the exception record */ + exception_fault_address =3D 0; + /* Reconfigure GPCBW to 1GB start */ + gpcbw =3D 1; /* Base 1GB, Size 1GB, Stride 1TB */ + set_sys_reg(GPCBW_EL3, gpcbw); + ml_printf("GPCBW reconfigured for 1GB start\n"); + + /* Access the GPC forbidden region again */ + x =3D *(unsigned int *) fault_location; + + ml_printf("Fault address: %lx\n", exception_fault_address); + if (exception_fault_address !=3D fault_location) { + ml_printf("FAIL: Memory access was allowed by GPC, " + "and should not have been allowed by bypass window. code= =3D%lx\n", + exception_type_code); + return 1; + } + + return 0; +} --=20 2.43.0