From nobody Mon Jun 8 14:38:25 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=1780511284; cv=none; d=zohomail.com; s=zohoarc; b=YHFBH22Zfgxo0OtSVTD9TMzXDUNpBUzL86NiFxyuGjw+SKEcI0aqIh0I2QLBbhjPJWei8uOe19zBREUyHD32oz/waZ53FMEbrg+Z4rBXTR9E78VNFi1yPrsqJGPtJIGCMaJbVPINx28hNUkq0pUm2EkP0cmZTW/zDhgBknsXriQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780511284; 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=XHo+RgjT6TDt8H4pIyhVDsbRZWepv+aHkO1DZ26YbNU=; b=KcPh7NHB0dgNKWjwSaejizvByNXrxFzE+XE2CaqVnt0pHNxOucgFta578WdFYxyoNFK0SdJW+8K+R7e2xR4SyMxT+60FqHJVkebevUsG0N9MP0EVd3IyRifQls1TL8/oN+1JzaxHqZUcxuOzefYJW+lMNRKqCtamIWU6gu+V2Ys= 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 1780511284525373.4880186159346; Wed, 3 Jun 2026 11:28:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wUqIc-0000cl-BZ; Wed, 03 Jun 2026 14:26:42 -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 1wUqIS-0000Y6-1q for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:34 -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 1wUqIP-0003Yq-2V for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:31 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-490b43e2b95so12545565e9.0 for ; Wed, 03 Jun 2026 11:26:27 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:d530:6a6b:58a7:e220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2ed944sm9793127f8f.13.2026.06.03.11.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 11:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780511186; x=1781115986; 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=XHo+RgjT6TDt8H4pIyhVDsbRZWepv+aHkO1DZ26YbNU=; b=hFJpSN7JWmme86u/3pZEW1kqFTf2jsIOwO/oW9YVlDl5m6Bh3iDBh8LwQtDjioz4Du W9RsZc40S3W+KCEDm70h73TTfNHIxNy5iE9M+mMR2U2GRMTaapUT+MOnHAILT3aiQNeN UrWiQLBX7TLfvxa+GF3wWXLo8CpPQUpv6SXzSCV3WdH+I8r2f2mwhm3LJnu/FhXX8Z09 AzZme/dMiGkCQcWIx2rB9lpfaTGe7HCvqT9INKZcyxHxic1cpfUcvNVQkzXpxQB25KT/ F6Ol0vJH4NSvHJ0LZv7d73BiCu2Zxz3uKxpKaTw59e8vCwIDkoHiaai8X/e+80Mr/gUv G1Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780511186; x=1781115986; 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=XHo+RgjT6TDt8H4pIyhVDsbRZWepv+aHkO1DZ26YbNU=; b=WffuTVb+IwAVCmNYsYdobqDCrV5w0hQ/HgGgQGmn3MzjuJFDazMpmWbO+LN0BVhrso RaxN22ngJdZQSP/3MhCKLrbonTT/cpV3yzCcedEk9RYm3mSn2IT+Uz2oAkxBLjKYfxG8 2hSe7NeuuACeilSjcYJxXrtO1LVaKqMXngnHfmSbcunpDvsgF+AeOCv+9zLDM8RBG+jx A1Tb27NxkNwUq4PfUVUoQ3vOVg7+lpYhZ7q9cfJ2sy4HnEQ5cErN0AO5YVGzNcS37+K/ k4wWjAewpOY002Lg3PQlaEJnnaJflwpixkwkj4TvcIwzTnejGO26Kzdea++PPs7tR4zJ 8/aQ== X-Gm-Message-State: AOJu0Yztid46KzHUsVjAuDILkA7/OTsXX5T47XisTuMvlQW4OKa+NMHW ua6K2WwViQq1qHVddB+NEL7672BUhoEhE7DW1qhTIfKWPIYe3miQfVuSHJl2E2XE18I5PLXO7aH tedPHhE4= X-Gm-Gg: Acq92OFYHQPSQd+/4K5Z9zn7mqaUHn1+A4QfkW+kOVf0WI2NBwCclAGdxJbyA/v4WGz QaFPwSsHZ3xsSaDGg6vX9TGG3Tc/cDDlvur/h1aUlqkIb2b8/xydYLFtfApqS7Cdoc3WXt8oU1J QJaWr7c0povmYT1cwjWpG8LFFHlkySOZOCnG2ize33ZRFFLDqngB9ENhohY31qpU5fJmWjDLwhb bx+2nXEwWSIGV5L2b+TFjLk2ktlhqvGD8zDNwsx9H6l8oGrk4rLIEC02YO+5n7fblWqRE9K9aXD s95h7P8eRwW6lbaL83C4m6SML3Mxw7XhubJW0simQnbcJvTdYd7rnfxcTblkaA99NQjiVPeoONn 87gfgpguSPjs57HU1b7h5koiV3zJNr8c7xBBlYFhPaZPqvYaKxsLDNQHF1beKLyc0BFlaZfpIrj fT7zLlqsGOEGW1I4YwMKeIjFk3cwhom5E3KknNZg== X-Received: by 2002:a05:600c:64c5:b0:490:52c0:744c with SMTP id 5b1f17b1804b1-490b5ed43cbmr74362175e9.20.1780511186589; Wed, 03 Jun 2026 11:26:26 -0700 (PDT) From: Jim MacArthur Date: Wed, 03 Jun 2026 19:26:20 +0100 Subject: [PATCH v2 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: <20260603-jmac-gpc3b-v2-1-115c51936962@linaro.org> References: <20260603-jmac-gpc3b-v2-0-115c51936962@linaro.org> In-Reply-To: <20260603-jmac-gpc3b-v2-0-115c51936962@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: 1780511284910158500 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 38a695ded7..ad1b1ddc9b 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -1148,6 +1148,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 Mon Jun 8 14:38:25 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=1780511267; cv=none; d=zohomail.com; s=zohoarc; b=LFnIDIMyiuCmU/ZYY2Msw18g7x1pCJya6LexPKNqnqHtXsL7TkS9LSbJ16GnZNRwTjoH+3VjZdPoi3OVtihZO2cuQ3PJGZ2p+riyUNkmHhS8riwhb0Q1SV29/ZuTECMfmszbxHwRGJCws//62Rv/a9lyw3tuRSp88AGWMRhcQM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780511267; 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=bTFIQnxOTusjqU6d0bx1jsZTWZ7O2YKAwwl7YH9M60w=; b=MvVY+RsH3/0QMTXwJ5an6IuqnoEVh/w9YhdXkgFtGK0H+Htjo0UYzp1QzFFkkkxBnfEWHVc3wz74LYb/gFP8kJjKEspEQvSi8sUzCntnX3Lh5UvNZwpwYVREuA/sM86dSFLueygEGT2HHwXGIA8Yl24ztpvhQafGYV449Kqp7OU= 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 1780511267564320.0286644194489; Wed, 3 Jun 2026 11:27:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wUqId-0000ek-Sr; Wed, 03 Jun 2026 14:26: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 1wUqIT-0000YH-FT for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:35 -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 1wUqIQ-0003a7-3e for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:33 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-49050ff7cbdso122298255e9.2 for ; Wed, 03 Jun 2026 11:26:29 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:d530:6a6b:58a7:e220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2ed944sm9793127f8f.13.2026.06.03.11.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 11:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780511189; x=1781115989; 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=bTFIQnxOTusjqU6d0bx1jsZTWZ7O2YKAwwl7YH9M60w=; b=TV7hm+srmPmHublT4HuXQf41GAg7irVZ9+2JcFzY7BU7+jF8XzPKhVkT0Lz8W8QTu/ keY3z3KowjjDqaeb8UjoDwaSED6HQiLRwJbbb8YZVpPp7rYq0Vw0cnb++r8vV3unSaUa qcgkIB4KuUkpmdEejKvjzXTU68qgPY6HigRwOmHnN+LLbhrz63iUKMGcrqqoRtAzwiL7 cDfnCJgOLyYiBOrT0EpdJSV26aY8XmM5+v9xL4u9P5yx5FmX35WwM9a52a3dQPMFFpVA 9OVJdlbohSshVmmXNeW04+TwdAgWY1O9Z5LQThEgAM5ftFQn/f/iwstOCZe/pzOn2B+u UwLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780511189; x=1781115989; 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=bTFIQnxOTusjqU6d0bx1jsZTWZ7O2YKAwwl7YH9M60w=; b=bR3zmeHJXZGCXIh9AgZSbuw5WAUh1LxL/3rMX/YzBvxLbHAoe7hBTtvur8qgylOso7 aSzPLFlQjxzugiu4Y3MlSkUai/YheHUBruoZgfzoUvkF97kspTvUPWY10VAMkhsYaps/ RZ3PCDB7SVP4ffcqEFmmGgbj/OVnQW8L+Tra7JpNtuem+YiIJzEMFeI9ttd1XE3k8f5/ Rdd2zu7MSwhFgzYHc2JK7QT0D3OD4rMUmHGPB/tWoIf3x/tNlJZtFSCG2tZEtnMLlJ0S 9jz2S4qRJGCs1ymjAOadhLBV47P0NUUXsoOwTpBweFUub9gyVq/j0EdIEE6GBHioeIFJ FOJw== X-Gm-Message-State: AOJu0Yxmf7qu1IlD4dmGntn86QMS4utE7WNmFSmCu6nMH9gRhdQRXoGW +GMUOlFGrktbwI1DjBzKtQlltvvCkDh9rFbKvIeMB9EIOPlmfrT+dqZxWIkfWYxEn0E= X-Gm-Gg: Acq92OGoSQExHFn+BEXkIxkzbWK7akJ571nuTobHj9PYadeg6JL0sh8kTMUgYOMTewS Vm3r9CV1oV+wyrCfomcBaklPRAJiz/PAZrJRhxxs382WCzBu5jIPbEBV2F4bb6tkgSB9gpbXCFA Z1ccp/5eQf9w0iU47QaNwTv4KojMzYmgMNHyHIUAdDS/qXGypCeEPZ6jS+6ywAAmJ+DQknxCtbq neulzcVvagZCtLIJXAgLNiYnNfAqCOpEPxPyJgzp4Z500Ola05GQNKhl1LLNWbhUnQ8CyJyO15v P/eR2bVGVfrUYLELCSK13P4Q4KA/AcKKGCZnwAyChPqApvqALj5u5y0KIwpiEyEnOcW75w5tf81 xpwdMK7pOz0cEivRi8r97LeF5cJOphD3g39Iiq+EFzTnuFElVkzM3oJrv96P80akEAYsdqVLEvL rFPEdCjIw9nhWIYplJBB80e9mC12J+U4B6vZoJ15lWSVZkeS+y X-Received: by 2002:a05:600c:a03:b0:490:4663:691b with SMTP id 5b1f17b1804b1-490b5e64599mr75273745e9.7.1780511187252; Wed, 03 Jun 2026 11:26:27 -0700 (PDT) From: Jim MacArthur Date: Wed, 03 Jun 2026 19:26:21 +0100 Subject: [PATCH v2 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: <20260603-jmac-gpc3b-v2-2-115c51936962@linaro.org> References: <20260603-jmac-gpc3b-v2-0-115c51936962@linaro.org> In-Reply-To: <20260603-jmac-gpc3b-v2-0-115c51936962@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: 1780511268880158500 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. 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 85552b573c..9944dc9727 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -546,6 +546,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 */ @@ -1228,6 +1229,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 */ @@ -2098,6 +2101,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 9dd8fdfa41..05fca2a271 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4993,6 +4993,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 @@ -5002,11 +5006,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 Mon Jun 8 14:38:25 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=1780511254; cv=none; d=zohomail.com; s=zohoarc; b=Jl38O9kI53JuYH/JZWoFhVkTwLKLd02oaR+xpR/6np2Pw25LOcjXOdHiKQL5YPsh8bU1WxMppvlOR2yhJQPWQ4mSdz1XQ3tALKyoYhWs8Zs/P+04vCFo95Av7PyUqrEjwuXWQqxP9R53O/85V+/0DqZ1Aj1XC04BCokoBORPizQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780511254; 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=9RYFdzZI9nhf0uIHPze27sdjwQc/3jiSP/AQ6IK1uAY=; b=mBuvT4oxNwIoAX1boESJpziiY/3Q+SLVO8kKpeA7HUnpCULZnv0xDWYR/7222g4MY24dN4BTn9Vxm+hXe8Jucj8OxJxNlF+NuNFa7gf22gD95Mc/vqtplouVT/Rr9cwNITlbv2WzGoP/he0nFLW5ELwMatxWchyERocWIdOzUPQ= 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 1780511254909379.7618594966649; Wed, 3 Jun 2026 11:27:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wUqIc-0000cq-ME; Wed, 03 Jun 2026 14:26:42 -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 1wUqIS-0000Y8-FJ for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:35 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wUqIP-0003Zw-N7 for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:32 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-45ee5cdbd28so688640f8f.1 for ; Wed, 03 Jun 2026 11:26:29 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:d530:6a6b:58a7:e220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2ed944sm9793127f8f.13.2026.06.03.11.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 11:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780511188; x=1781115988; 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=9RYFdzZI9nhf0uIHPze27sdjwQc/3jiSP/AQ6IK1uAY=; b=AhPdDWGoN6dq433xggT82d2uLceu87ELOD//9AQdsHeH1aWUjyAVWPMY83cFJTfcci u/ivy6rC7XPmIuW33Wh4lNqGLX2ucI/mKm0RXYnmBbpwSp9Da/C3XtmNXvctY7gdfl0s D7lKhuP0+7snlU1Q6pMpRsyiyF0TysgfAdi0UjT9FlVh77iPkUj0F5MtmIIHxk+tA8e5 vmYxUkKaSxwJgXSN3pS+Nd2UsmZHRw0HqqoeRhXybKMivAacwdQCYXd/2yMlI2wrw6Pr b9pHXub1BnTIwGjWILON5l1OyCjUu+/yLt+D8tCPlMu+7Ux71Zp+CbXKApoVjByJEGXJ 4afw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780511188; x=1781115988; 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=9RYFdzZI9nhf0uIHPze27sdjwQc/3jiSP/AQ6IK1uAY=; b=gZMiazuz9ezK+Pgseuz30B4lLzyl85z8W93EzXWLQC/htkKZf9/hm5f3k8DIhhnY6n giBMSgObg6oKQR37B+EoIEKODFumh2vYzFC2QT5HNqmEi0mNMF/Jjvc9R1RdWMQJW+EF EVQot7vIxaiuLWoNj3pgKu3UER8aEX2tmXH2+8kHU5KA3IJfKuiDLpOIgyMVCFQo/xyb J92c91FCDSpHywUqU++6xUnbvHug9NumdlHhGWxJw4JpCz0oDCirJPTvxKUpuj6jJ1dY RdE0Xo8yUosr+6xT28COVjaYv0HRScGxpauEprYAMSccdfSlU4oDhhkCF74MKFhaJYeL EhCg== X-Gm-Message-State: AOJu0YwPPLjoQTOGLKVknztPrC36QZhMcpD/qMFJ9BOy5XHrWfWWaVFX vHmPqBakXFpYNkKlN+OaHePl7pheAfl+C9giZZtmg1tzQozToa6HiUpp6xwPnV1w/49WEyLCMtY f/koxJJc= X-Gm-Gg: Acq92OGJfNw1jehZzXan/1Rs+xs8tM0WdrCzSFzCCmAL8eZ2qDNr0W9wteQqP2Qpi11 ghtuUtYT/SBEItjwgi6RKArLg3TJA2rPxh51lcsDD80vUYm4wX3aT7jzoLFDTaE4UUp6ZKTfdVF Zni0IDPA/koGdlcJqwLgVGsVvmA2OA+FOTs79MVLDWT4CI7dWbgRIrX8eKUmgwJc1/1JrlkBjR2 vLO3KYgKBWkf/GjfLciemcvuGFr+YET6pJ9r/X74BTCGdxgCW0AJ/vnkOceCpjdqxXxGbhLJthh b1IeEaHfx9Hm3syHRm9ob+crFtower/fTMfPtACPycE3DytSQDbfqECkcxp+ioMzeR5OVfgQo9F qhWY2K+NuOVytbUmZ/4lIx/+qmpFlYEE5rcSY0KI3iLHIW0EXNAbbu26QUXnar0XAJiwNkQLB6Z ZY5lCT+Xucf59Y48bS7F84OX0cBUp7+5yVnJrCQlw8X4JhJLwb X-Received: by 2002:a05:6000:2082:b0:460:1c93:6eb6 with SMTP id ffacd0b85a97d-4602743465dmr802286f8f.20.1780511188154; Wed, 03 Jun 2026 11:26:28 -0700 (PDT) From: Jim MacArthur Date: Wed, 03 Jun 2026 19:26:22 +0100 Subject: [PATCH v2 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: <20260603-jmac-gpc3b-v2-3-115c51936962@linaro.org> References: <20260603-jmac-gpc3b-v2-0-115c51936962@linaro.org> In-Reply-To: <20260603-jmac-gpc3b-v2-0-115c51936962@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::433; envelope-from=jim.macarthur@linaro.org; helo=mail-wr1-x433.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: 1780511256910158500 Signed-off-by: Jim MacArthur --- target/arm/ptw.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 81 insertions(+) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0a5201763a..e4cc415ce5 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -341,11 +341,22 @@ 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_size =3D 0; + uint64_t bw_stride =3D 0; + /* * We assume Granule Protection Check is enabled when * calling this function (GPCCR.GPC =3D=3D 1). @@ -397,6 +408,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)) { + /* 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. + */ + uint64_t bw_size_mask =3D MAKE_64BIT_MASK(0, bw_size_field + + BW_SIZE_SHIFT); + + if (bw_addr & bw_size_mask) { + goto fault_walk; + } + + if (bw_addr >=3D bw_stride) { + goto fault_walk; + } + } + /* Note this field is read-only and fixed at reset. */ l0gptsz =3D 30 + FIELD_EX64(gpccr, GPCCR, L0GPTSZ); =20 @@ -431,6 +494,23 @@ 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. + */ + if (FIELD_EX64(gpccr, GPCCR, GPCBW)) { + uint64_t bw_stride_mask =3D MAKE_64BIT_MASK(0, bw_stride); + uint64_t effective_address =3D paddress & bw_stride_mask; + + if (effective_address >=3D bw_addr && + effective_address < bw_addr + bw_size) { + return true; + } + } + /* GPC Priority 4: the base address of GPTBR_EL3 exceeds PPS. */ tableaddr =3D config.gptbr << 12; if (tableaddr & ~pps_mask) { @@ -3817,6 +3897,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 Mon Jun 8 14:38:25 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=1780511278; cv=none; d=zohomail.com; s=zohoarc; b=UKM6Hc2ZcMeA9wjOkLhiwyqFldXBQVZ5Pg+RtHqK2Y17WGcOU04L8q5mzb+EwUh6t/uoDu6BtiE145xaubJeLVEGT3iP6LG9o6d9rVSa9tsXU6Ianh2AcpCy79eOtnp/wFv/1LR36Elnp11rrYffGD6GKsmDA7jJmfOqwVy0V/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780511278; 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=GaugsB0+qDsm5JZJtlzVYavpFIe0k85NXYxUoHgAR7Q=; b=XMVKu89D1dF7pMUbb23eowYVZUuQtn6/NT73Mat1FfuASxHztFvmUPE3NqzPsi9a+BwS/2bl78ps10/fP4+RxUjnEz+/guaOiy1cxdkXBLuxI5FxiwJtTsLvZ/Z5cn15RDoswExIu76S+Juc3rEG0x7AEph0+DjLkuiMrzViV4s= 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 1780511278617642.7891602652163; Wed, 3 Jun 2026 11:27:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wUqId-0000cx-4v; Wed, 03 Jun 2026 14:26: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 1wUqIT-0000YK-JD for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:35 -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 1wUqIQ-0003aA-RA for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:33 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-45eeba68948so5209120f8f.1 for ; Wed, 03 Jun 2026 11:26:30 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:d530:6a6b:58a7:e220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2ed944sm9793127f8f.13.2026.06.03.11.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 11:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780511189; x=1781115989; 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=GaugsB0+qDsm5JZJtlzVYavpFIe0k85NXYxUoHgAR7Q=; b=fOvAWmQEQe7mcdjGVF7tzN69ubX9GBd1IU6DzFoMILhiw8hRYatmniAoGuzf0OTeia lJ2Bm6+9ZKk72rU8l3Fs9WO23/A13NUD9B9mm6+fYSaH3HgnZYTay5U2W6OH2hRnsC5v /ejsCsGxnuEVlkj0DP5t6Oi7mnjiT3DI5R22N84STiElMwjcBmrz5sFw+qrKRmLB0wGD 9gL6i7EmbK/pLM74mRNKj/Kh1OLkIMQ/+IiNdskisD8QaTgyh8vPzN7hJYF6s7Qd+gFv f80Qk0rKiWpS0pztTfl7HWSkZGSNK4xJZbwpf7IDhMO2v8BlYHAIDhKPyBCGEIcJHSqr m5Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780511189; x=1781115989; 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=GaugsB0+qDsm5JZJtlzVYavpFIe0k85NXYxUoHgAR7Q=; b=Mf/W1c7eCJJ5lcqwuzHOSpaEWsPdqqNwSZ21fEAARIVBJryoD8NkcwNUMfvFpBNn7q cgnXBp9JYU0G4ZFd59Uz/5Q0aeOGf2B0AIetH9GvpnHyNPau4J8WxENqocRrj8QO4HBv /fEjwSX+EXn1x12i9bJNL63wIkoNWnKjYTaTxPki5wso6KwmBRbsBn6Wz1+CvzcSTYmY Kt3Ke4BLBJqG0Sj3RKmgeZizCCTefYra8WLL/McbD92swB6nFLij/x+cAk2jQdtFIjh+ VBrUEtUzPDaqklMXr/Zh9QohJXBHFjhEVjGW9Qqvw3aZre9SbxaK7oHvZidb6elh0ZJM ynVQ== X-Gm-Message-State: AOJu0Yy5xbgTcjHMsasQ5BOcsoXN5Muv4tryo6djsJ+kjXMnN0KC3Phe NZaE0Z1i/b8f/f7bfO8pwRtm1DWXxNT7Jx5D7/UO1eCeif/f9P89bfaIlWJIU3LvF8Y= X-Gm-Gg: Acq92OHpvZBz/NLZ50g4Bx2h0SHUrmsPu3Z1enG28X3hbBxhC4XkxK8mSrmDjQLwzKq 9NFd+JWTV79QTz/cSIAdaJKziwmFWN8QoxiUPMk4khDL0l7WYBcdgsfS9IQdTQUdhV1Bw3TWYCo kjc1rJSnZsGnyNB2JM9IihW98j6s+ZCYLTAPSyCe4ajNZ3zJr0et4FmPBg0jXz8riUGO7AgFgnc i0jsjtWlakyQF4EPzwG3o9uPizZJLoidknL/MdPSxigV8WNqlPcqbmLy6jX2RoR0h8881C9yzpa ohep0vlws9hfuY16KEEZ6tNOQ4T4asXpuEKN1EQm72IrQptEyhwg5pHE96QbpXp239yR4FHDUgY 16SE0nAPFPd0L6P0w+d6b+AQ595pFddeQBTzhHR056ZQ4xarI4nsuruXK/lURvWbkCJo6GjI7FF a2z3WbuB6ueIK95iatMsc20anIjD9TrtGkDLwmtQ== X-Received: by 2002:adf:fdcd:0:b0:45e:f2bd:2b17 with SMTP id ffacd0b85a97d-4602182d6e5mr5425566f8f.21.1780511188877; Wed, 03 Jun 2026 11:26:28 -0700 (PDT) From: Jim MacArthur Date: Wed, 03 Jun 2026 19:26:23 +0100 Subject: [PATCH v2 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: <20260603-jmac-gpc3b-v2-4-115c51936962@linaro.org> References: <20260603-jmac-gpc3b-v2-0-115c51936962@linaro.org> In-Reply-To: <20260603-jmac-gpc3b-v2-0-115c51936962@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::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: 1780511280676154100 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 1a4f50486d..2d87cc5668 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 Mon Jun 8 14:38:25 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=1780511239; cv=none; d=zohomail.com; s=zohoarc; b=ByCJAZHngVJr/gSOztxF2GG7X5T3IFj1C2Q/+1opG7dH2YZQKSvWeDM36lNxvdCN9nHPYa8m7+ACc6DP1gAX2m9xyN6KEAWqiXcNhULQMj/8A7e8p9hudGXWUZ05aruBnoEK1YnuHP91d8wSfvqxyVepleD+JyQIkgcq9kAsJqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780511239; 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=JCOFwbtmACj5KLqY5uWhFxRDRINL6yEo/buAYwIBFpo=; b=g+C+ZvYvAV8LsuTpVk3nd+gxzGikq9ky6A4gGECEz/Ifix+fARKvMhjCDJylrmiBOzc+ddjEsXYgMxyEbBYzRm3RJpVGY+T8r6fTcDTW16GzPD7Zu+H5FxlcoG+eAYMMPxz7CamffEIbDwZn9MPoPXd7rib+/qvFH7MPTgfmAcg= 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 1780511239737508.8619540010527; Wed, 3 Jun 2026 11:27:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wUqIb-0000bg-RJ; Wed, 03 Jun 2026 14:26:41 -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 1wUqIV-0000YN-27 for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:36 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wUqIR-0003aM-6E for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:34 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-45ef29c5561so3330836f8f.0 for ; Wed, 03 Jun 2026 11:26:30 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:d530:6a6b:58a7:e220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2ed944sm9793127f8f.13.2026.06.03.11.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 11:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780511189; x=1781115989; 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=JCOFwbtmACj5KLqY5uWhFxRDRINL6yEo/buAYwIBFpo=; b=w4ox6v6MiUUfabuSRGYj/ek7i1gSDSGBlrsv9ZN1ZrMoRawQFA4CCbE0tZST5acIfA sPW6LZ5LEOaxgBUMSefDO/vfQUynTutCzg6UoGEEMcCsAZtGHYSo8vDW4fMlU8Jg1hEj Jd06g6wViW5G7jTkVg7tFBMgmZUV8C9/RRH5XkrJkCJ1Cp69C6/qbkjklhwqRvD8WJAX E21Wm7GhgmT8pKWRn/hYgT7ZnAtGT19qx/38tS1pQmNfKsiqfir1FkjS6t81q2geYlH1 KxEpv3PMu55KsLdUFci6MnfxWphG2lEghmLbMhwoxoQsh95U946uRTjo7ycndrMATMXE DviA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780511189; x=1781115989; 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=JCOFwbtmACj5KLqY5uWhFxRDRINL6yEo/buAYwIBFpo=; b=fH1Dkoh8PJ4nJdL8fh/yCjf/2WmZt8J2n8+Xzo24p3PLcsyIb/UVkg1pvNaT/E5UfZ XV8fsTZzx5UwWNGd74NvlU92DcuY65YwAeiaLmuPyAacjNJZTAj3tiAbtHMuSC3xb9Bn xlnIbwmmxgrbW00/VfT5t4eGNQ61X3pFGDoboO1rsxsT3RhNIsQi5Hf9rSd2Vci6J8HK KoVWtD/D134A6MJcHX8ozjenxdp41vKRAa0ArIY8lKYEQXxXTFmLuzTrOAxWcdHNnuS6 V5x6WC3cJZ5EBpTp8vie42eC4XaoOTjnN/9zj5y2R3yAyQ1n70Rnq6tP4UlSy7dttDBy AX5Q== X-Gm-Message-State: AOJu0Yy41bYF0fV+XjCiJWDGyFfURLBognWBUW9scVzg1iU2Is8b6eTx c3JbjDVCdxy/odDpCiOj4n3OOR5K2l3wGO5SXG8GWLr4coi+4aFc1Dk4vqFn6lLJvZ8= X-Gm-Gg: Acq92OEq0yeaDY4YsHxq19IoCLzYr0nydfgMMPrdufICXpCeVEub4Hj05iU0FTrqG3v XxrRFkxSI+DHwDoL+L+EFY1g59PSL+cFav1U38adbzNBxUkh8TshYjo8I2IBotOy+zaTgqOGdLP gOfmIzROrYzs7m19Uwqmc6IGp3Q63SZ9JDjFR+gKM9gWKjXmJYGQwWmwOVjr5uK3SnljQx4TJgZ LJa+jIO1IubLYvxPZFQ3HxF1dDv+e6/Tr5xYCanfxIt/1eDhfV+T8nHYEgiOe5SrXFnEv4VjQe+ 2TrvJOwBpvvrhsnOplc9hLRMwGPAQFccnw1mqzjZic6yaJgix9U0wDkpyy62N19c0IJDbAXSUiR Iqs1aHYGL55Yx8L+9wXvSCk6la6wVLu208nANy9Miz+3GiKYn/vGWqUTgvLOrt4LLSRGmz40LiH o2M80SKcid0+reLSXX5wYuiqLXiW2Xs9ZfXEly+A== X-Received: by 2002:a05:6000:4b0b:b0:45e:f68d:e791 with SMTP id ffacd0b85a97d-46021615d47mr7464882f8f.0.1780511189508; Wed, 03 Jun 2026 11:26:29 -0700 (PDT) From: Jim MacArthur Date: Wed, 03 Jun 2026 19:26:24 +0100 Subject: [PATCH v2 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: <20260603-jmac-gpc3b-v2-5-115c51936962@linaro.org> References: <20260603-jmac-gpc3b-v2-0-115c51936962@linaro.org> In-Reply-To: <20260603-jmac-gpc3b-v2-0-115c51936962@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::42b; envelope-from=jim.macarthur@linaro.org; helo=mail-wr1-x42b.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: 1780511242967154100 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. ALT_VECTOR_TABLE is added to switch this on, and altboot.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 altboot.o into particular test binaries. Signed-off-by: Jim MacArthur --- tests/tcg/aarch64/Makefile.softmmu-target | 11 ++++-- tests/tcg/aarch64/system/boot.S | 62 +++++++++++++++++++++++++++= ++++ tests/tcg/aarch64/system/boot.h | 14 +++++++ 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/= Makefile.softmmu-target index f7a7d2b800..47b32968fb 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 +altboot.o: $(CRT_PATH)/boot.S + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DALT_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..57bddda976 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 ALT_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,33 @@ 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 ALT_VECTOR_TABLE + .align 12 + .global exception_log + .global exception_fault_address + .global exception_type_code +exception_log: + /* + *These fields record details of the last exception, if ALT_VECTOR_TABLE + * is defined. + */ +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 Mon Jun 8 14:38:25 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=1780511296; cv=none; d=zohomail.com; s=zohoarc; b=PFwT8KuWvrD0jleH9F5PWfIvPu6NTCgIp/H4qa92f+XY8gcaCO8VkIjuBvaXjnv0aphSexuUMJiT0mBy43dG58xSFeWQ/VK3KTc3ctkAnrRJce7ccM7CyzcZ5zL/h98eM7oko6nxeto+lf/u72M4bRomM4G7R6a9fLdTrzd78JY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780511296; 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=5Q0hKICo4kl90EEUv9EvxXccnGV5ZbdN4gD+7JWEWr4=; b=KptPfg/AJIrCerwqpiHIw27er0yXEyvVOlGgUQWB91KT6y11k/qUQ2tGOVp9GFnH86eumzWq3JRx5t7R2M/SrjI3e/xab+ZPH6NftZxApzMS9Xn9Cp8EiI7poUzTMpKPghzqDfBN0uJvcwz7E/i1yLwjO+Fv7IA5JazaZ7xRHzo= 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 1780511296350135.26461438648448; Wed, 3 Jun 2026 11:28:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wUqId-0000eA-Kq; Wed, 03 Jun 2026 14:26: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 1wUqIV-0000Yb-CZ for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:36 -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 1wUqIR-0003am-UU for qemu-devel@nongnu.org; Wed, 03 Jun 2026 14:26:35 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-45ef189aa1cso4954543f8f.0 for ; Wed, 03 Jun 2026 11:26:31 -0700 (PDT) Received: from [127.0.1.1] ([2a10:d582:31e:0:d530:6a6b:58a7:e220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2ed944sm9793127f8f.13.2026.06.03.11.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 11:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780511190; x=1781115990; 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=5Q0hKICo4kl90EEUv9EvxXccnGV5ZbdN4gD+7JWEWr4=; b=aZK4i7xwbKrRbhw/axmjuq8XABHQRU4p1g8DHrSeEk0PCOmJHDdypSXW/MGS+SQuCh BKmwu1wfjMVQfw2Wh8hP+xaiE6HYdjx6RjKOpLySAbJk0f9IB7S6Kudsfdg29KwGeHmm N40TLI5Roh1pwV68lF79/jkro1Ym/QgsdvnRg5ly6agf/eACLsHJp9NS814tEBJ9Npyv Ak6WEZWdMzTZFt59cM0D3/l3Ct2fK5zD092LGHmYJn+o9+qoK8TcP09NOV4fMnVsRtfj BIUwiBKh5o2FGdVToHIOJtmy7qow60/VsF61xewa/zXQl2xCus1mmbeJ2ZpGNI1q/MVA 3F9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780511190; x=1781115990; 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=5Q0hKICo4kl90EEUv9EvxXccnGV5ZbdN4gD+7JWEWr4=; b=YfIJZC6ZhaWtOsuSA8zojLWWs3cwqMhQ0sLFWSjhApzVt1NU8oiYu8yfaHDwz4nmKt EgVbk0lqli84tXXWCDOLUg67LSJsKjoAa7xpmNrLKb+PlXlXGw//EGhwnk4LRa9/ea/8 ViJ7t+HyiPiLNshDUsKSSj2lJ+urfqBnRjTNi6VHSfQITK6FXnQR/rXb+rL32EkC8BmI QEaxjacnnWOsBXQRip4c8G6f7tQyFHz6YPBo+gd1cq9948/I3LJ/kFpG2754o4HIpRZ5 RT0J8QxEvYmMpnzA6B9U8ht4Il2vW1OYTMOK3alZP5leaASj6FyA946bCx8AP7toDTVL ZXYw== X-Gm-Message-State: AOJu0YzNtPi7rIdyZIJegTze/XjQ3GUUGk/7xmUtgAcT/vTCIXqzQFKq pBmX0DvSE73dapDo47iFp+gVxhaoEoH+ekf3cpgyvFgnHEtacFhwbXancoQLTZF4/a4yQpdboEL zlLpEcX4= X-Gm-Gg: Acq92OGUVSXhDdaETPYPFnaYp0LMsHUTGxnJ5UBZKgYRhwwF5FeVMmkfgor/fPjOwwn usa0PPWjWbsiCCSj300yZXC52qDp3322xD45LKE51NxHb1Ktp2rsoJnqNj+4nwg1Pc8FZQPBNDy YDVLMGv/Y1u/4uyFojxaFZ37eTzEJ7bY4OMkosJGXAfdVnRhvKPjGBpu/ESPqM6VtZxdkeyhDm5 pNOusvPUycvlJjng9Od7LiCmxsD0KvZaeJbocI5xRZ7VBzpGJcgm2UiR/4QoyOAj25XuRgrMwBK 0bChsP4MEGHncjSdUfCN6JsYRh8p5nyYn5X8MSzM5OW7R5qSQ3NaWbWRw0sTg5jaRAqrTBurIQm blMAuvv7QE634cp9pw3MLS0rOGbDPNwvTF/sr5nZJDcbCeKa+eNG0+TVxzO/uO+p2wRGIW3aZXY ljDr6DIAru+IpC9olZji0ZUXicMBtjGWza8HYH4A== X-Received: by 2002:a5d:5292:0:b0:45b:d891:56bb with SMTP id ffacd0b85a97d-4602186fc27mr4516109f8f.38.1780511190217; Wed, 03 Jun 2026 11:26:30 -0700 (PDT) From: Jim MacArthur Date: Wed, 03 Jun 2026 19:26:25 +0100 Subject: [PATCH v2 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: <20260603-jmac-gpc3b-v2-6-115c51936962@linaro.org> References: <20260603-jmac-gpc3b-v2-0-115c51936962@linaro.org> In-Reply-To: <20260603-jmac-gpc3b-v2-0-115c51936962@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::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: 1780511299083154100 * Sets up granule protection tables * Enables GPC and bypass windows * Performs memory accesses in the protected region to check for allowed and disallowed reads. 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 47b32968fb..d76ca52e63 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) altboot.o $(MINILIB_OBJS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) altboot.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