From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CF63606A322 for ; Fri, 4 Dec 2026 06:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=I5XyJ5jj Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZMT5-00050c-QD; Fri, 04 Dec 2026 01:08:27 -0500 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 1xZMT4-000505-Fk for qemu-arm@nongnu.org; Fri, 04 Dec 2026 01:08:26 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xZMT1-0001t9-EY for qemu-arm@nongnu.org; Fri, 04 Dec 2026 01:08:26 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4a35ac4475dso3292325e9.2 for ; Thu, 03 Dec 2026 22:08:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1796364502; x=1796969302; darn=nongnu.org; h=content-type:content-transfer-encoding:mime-version:message-id :in-reply-to:references:user-agent:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Ua0qMJlMsXuloi0ZdGig/HRG3TEJNlwWy5buYZFd7MU=; b=I5XyJ5jjDJm3TTABGn0B4YVJwRP+KUM2vBNraQ+BxciROsd5Tkczhh55EAIgsPJyp8 f4nkuiyacYle/z3Gl8fg+qNRhRgYLsQHTB/bWR8n0gB0gJVJ9zXj/xmsF4QGfxPEnrdo aT+WuEHz3u80mVJeohZvSWqKsOxRf0Q4a5rx+LxCxOb9W4MAn6OA7Brmx0F+lkm7XhA3 C6IUPWHMqZDwQbYeVnX+DB+UF1PBwNjIFVoCIcKQ1BNNozcXvChbfMJkyFUiWUgqYHrH HxFfoWaL/rrJ/Y0imX52OM33tf2OUVGLBruQz/HJsPrHTKg/8x8OySD3rs4C9l0iyLPs TInQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796364502; x=1796969302; h=content-type:content-transfer-encoding:mime-version:message-id :in-reply-to:references:user-agent:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Ua0qMJlMsXuloi0ZdGig/HRG3TEJNlwWy5buYZFd7MU=; b=z21rX86OIT0qF8/xBIIz/TfZzYexBhyBUK/UPlYXbQE3spWUeHzbKvVQsz8t9kZgpA enF0viArurEtUr6iCE+Nd/eBLkDCj6xhRaI4ajo1qOYb1SiNyjR7Ze28esI84TeB3k6C uG4ZQEOefIfT+mwJC1U954NxNcgpn5LOFeFv4EeQfnFRGZ9LMcmzNRYf/sgwbplKViz+ v1gl8KRNj+EOQaIfGqN4PUzft5x46UJWI3s5R7sxDfr0EZ+dVObVgk3yKgYc/29gydAr j5ZWZLCF8PVakwNqac9XMkOWHgGfRUTWkK4lf56CBYZia6yQLZeXrz6OeomhwxsccbUM 0n9Q== X-Forwarded-Encrypted: i=1; AL+hErH+58xu2rd6uebGoss+/JLWYYEKcWgiKvLsidDmOCKkts7e9S03ywzjnOTBijA2L4OmBnXCvaSblQ==@nongnu.org X-Gm-Message-State: APuU4Z+U+XVOB0kydmTrC+sOZy7zLhqFORn/v6pOwIgqff3F9BxGXrCH f8U7j7bvJSwXDiIGPQxQAIBV4lyozlZUGuLvJB993rGXkpKjBvbmJa4JKWshIC4CSxk= X-Gm-Gg: AZFdTZeEKz1eQ/6ozHxz7AeOwNbXS44j6PE9QGqTO127EZYTe7+pXHcAKF6zFNFK8kM jEL1kxJ3ErJYd5Rx0M5UqxBSmQqwkvBYFUgIHyCganNkhADYdq1uTYiaWtEhebcBNI+tKflAZgq 6IbjCUJXkT5HtjN5s0kPwUOHbbbGkq4o4gYOqH+ANJV3sC3aSZnrpWHqXj/RrTiz/Qu1BTbfSGU x2QKgVUB2RLergxWdWRnWHo3nfALaodYwViqytbit0bcfehVCbo5mamTD5e6qm2bdCv3iVmK4Oo akREebGciMZ5gcFTyesoyF3J0YwqglaxYTSZY09tVm03GYsgwTWxavoKu3rVh93UeIjPa8RhF/y 172oor77/cQajlcU0zUjo4mCd4Gx49p1vI+fCW+j71d7ODkBEtMJEln/kBJTA30dL4N3Txm57LX klqIVonWmTTi/7G7Plnaj8a5caxGeRBEklCH+zyXd1xw7YGHxX41ILDUlPTl1NqKOe3f41XuGHt 4fcHT+xqKFuUfwzihWy2OqPP10FAFpCYyYX+p4krNd1fvNypW3DW8NTS1gWWC+HkzsuIsZS8jsr qb2ecE+B5QLa1fdH+qO+ATI/yQ7CJb1DS6vIvG4LeThEk1XFbPQgT89IyQ85FIzsf0xjLE1nQh+ 5jfRSkNlswFV3nhtkIy+XuamyQrUfHPNajeJMM9iAFS2ncrSuo4gvF7qmlEb6il/lh6VjDuv9Uc 0174fUzZmB7pGf16ghArH5HQvqJjaX+2PdvoZZjr5fdf5AD+C8JJZ7qZfm0nzUcBV+UcYP X-Received: by 2002:a05:600c:5397:b0:4bb:6519:477e with SMTP id 5b1f17b1804b1-4bbeb8cc147mr13303125e9.17.1796364501569; Thu, 03 Dec 2026 22:08:21 -0800 (PST) Received: from meli-email.org (athedsl-4431069.home.otenet.gr. [79.129.140.205]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbeb6ea33bsm15382575e9.4.2026.12.03.22.08.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2026 22:08:21 -0800 (PST) Date: Fri, 04 Dec 2026 08:01:39 +0200 From: Manos Pitsidianakis To: Peter Maydell , qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Philippe Mathieu-Daud=?UTF-8?B?w6k=?= , Manos Pitsidianakis Subject: Re: [PATCH v2 09/77] target/arm: GICv5 cpuif: Implement GIC fine-grained trap registers User-Agent: meli/0.9.0 References: <20261203111118.1380524-1-peter.maydell@linaro.org> <20261203111118.1380524-10-peter.maydell@linaro.org> In-Reply-To: <20261203111118.1380524-10-peter.maydell@linaro.org> Message-ID: X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8"; format=flowed Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wm1-x32d.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-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, 03 Dec 2026 13:10, Peter Maydell wrote: >The GICv5 cpu interface includes a set of fine-grained trap registers >which allow a hypervisor to trap guest accesses to the various GIC >cpu interface registers and instructions. We implement this using >the existing fine-grained-trap mechanism. > >This commit provides the definitions of the FGT register bits and the >registers themselves; we will mark up the cpreg definitions with the >fgt trap information in the following commit. > >Note that because FGWTE3 has only write-traps and the indexes into >fgt_read[] and fgt_write[] have to line up, we leave a gap in the >fgt_read[] array for the unused slot. We could have moved FGTWE3 to >the end of the array, since the array location isn't encoded in the >migration stream, but that only saves us 8 bytes in the CPU struct >size and leaves the possibility that we forget about the need to >align the read/write indexes next time we add an FGT feature. > >Signed-off-by: Peter Maydell >--- Reviewed-by: Manos Pitsidianakis > target/arm/cpregs.h | 85 +++++++++++++++++++++++++++++++++++- > target/arm/cpu.h | 10 +++-- > target/arm/tcg/gicv5-cpuif.c | 22 ++++++++++ > 3 files changed, 111 insertions(+), 6 deletions(-) > >diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h >index ce651a4faa6..e46c8c979e1 100644 >--- a/target/arm/cpregs.h >+++ b/target/arm/cpregs.h >@@ -389,12 +389,16 @@ typedef enum CPAccessResult { > /* Indexes into fgt_read[] */ > #define FGTREG_HFGRTR 0 > #define FGTREG_HDFGRTR 1 >-/* Indexes into fgt_write[] */ >+/* 2 unused: FGWTE3 doesn't have read-traps */ >+#define FGTREG_ICH_HFGRTR 3 /* GICv5 */ >+/* Indexes into fgt_write[]; these must align with the fgt_read[] ones */ > #define FGTREG_HFGWTR 0 > #define FGTREG_HDFGWTR 1 > #define FGTREG_FGWTE3 2 >-/* Indexes into fgt_exec[] */ >+#define FGTREG_ICH_HFGWTR 3 /* GICv5 */ >+/* Indexes into fgt_exec[] (these don't have to line up with read/write) */ > #define FGTREG_HFGITR 0 >+#define FGTREG_ICH_HFGITR 1 /* GICv5 */ > > FIELD(HFGRTR_EL2, AFSR0_EL1, 0, 1) > FIELD(HFGRTR_EL2, AFSR1_EL1, 1, 1) >@@ -720,6 +724,45 @@ FIELD(FGWTE3_EL3, TTBR0_EL3, 20, 1) > FIELD(FGWTE3_EL3, VBAR_EL3, 21, 1) > FIELD(FGWTE3_EL3, GPCBW_EL3, 22, 1) > >+/* These are the GICv5 fine-grained trap registers */ >+FIELD(ICH_HFGRTR_EL2, ICC_APR_EL1, 0, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_IDRN_EL1, 1, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_CR0_EL1, 2, 1) >+/* Bit 3 is RES1 */ >+FIELD(ICH_HFGRTR_EL2, ICC_HPPIR_EL1, 4, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_PCR_EL1, 5, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_ICSR_EL1, 6, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_IAFFIDR_EL1, 7, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_PPI_HMRN_EL1, 16, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_PPI_ENABLERN_EL1, 17, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_PPI_PENDRN_EL1, 18, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_PPI_PRIORITYRN_EL1, 19, 1) >+FIELD(ICH_HFGRTR_EL2, ICC_PPI_ACTIVERN_EL1, 20, 1) >+/* All RES1 bits in this register */ >+#define ICH_HFGRTR_EL2_RES1_MASK (1 << 3) >+ >+/* Matches ICH_HFGRTR_EL2, but bits for RO regs are RES0 */ >+FIELD(ICH_HFGWTR_EL2, ICC_APR_EL1, 0, 1) >+FIELD(ICH_HFGWTR_EL2, ICC_CR0_EL1, 2, 1) >+FIELD(ICH_HFGWTR_EL2, ICC_PCR_EL1, 5, 1) >+FIELD(ICH_HFGWTR_EL2, ICC_ICSR_EL1, 6, 1) >+FIELD(ICH_HFGWTR_EL2, ICC_PPI_ENABLERN_EL1, 17, 1) >+FIELD(ICH_HFGWTR_EL2, ICC_PPI_PENDRN_EL1, 18, 1) >+FIELD(ICH_HFGWTR_EL2, ICC_PPI_PRIORITYRN_EL1, 19, 1) >+FIELD(ICH_HFGWTR_EL2, ICC_PPI_ACTIVERN_EL1, 20, 1) >+ >+FIELD(ICH_HFGITR_EL2, GICCDEN, 0, 1); >+FIELD(ICH_HFGITR_EL2, GICCDDIS, 1, 1); >+FIELD(ICH_HFGITR_EL2, GICCDPRI, 2, 1); >+FIELD(ICH_HFGITR_EL2, GICCDAFF, 3, 1); >+FIELD(ICH_HFGITR_EL2, GICCDPEND, 4, 1); >+FIELD(ICH_HFGITR_EL2, GICCDRCFG, 5, 1); >+FIELD(ICH_HFGITR_EL2, GICCDHM, 6, 1); >+FIELD(ICH_HFGITR_EL2, GICCDEOI, 7, 1); >+FIELD(ICH_HFGITR_EL2, GICCDDI, 8, 1); >+FIELD(ICH_HFGITR_EL2, GICRCDIA, 9, 1); >+FIELD(ICH_HFGITR_EL2, GICRCDNMIA, 10, 1); >+ > FIELD(FGT, NXS, 13, 1) /* Honour HCR_EL2.FGTnXS to suppress FGT */ > /* Which fine-grained trap bit register to check, if any */ > FIELD(FGT, TYPE, 10, 3) >@@ -798,6 +841,9 @@ typedef enum FGTBit { > FGT_HDFGWTR = FGT_W | (FGTREG_HDFGWTR << R_FGT_IDX_SHIFT), > FGT_HFGITR = FGT_EXEC | (FGTREG_HFGITR << R_FGT_IDX_SHIFT), > FGT_FGWTE3 = FGT_W | (FGTREG_FGWTE3 << R_FGT_IDX_SHIFT), >+ FGT_ICH_HFGRTR = FGT_RW | (FGTREG_ICH_HFGRTR << R_FGT_IDX_SHIFT), >+ FGT_ICH_HFGWTR = FGT_W | (FGTREG_ICH_HFGWTR << R_FGT_IDX_SHIFT), >+ FGT_ICH_HFGITR = FGT_EXEC | (FGTREG_ICH_HFGITR << R_FGT_IDX_SHIFT), > > /* Trap bits in HFGRTR_EL2 / HFGWTR_EL2, starting from bit 0. */ > DO_BIT(HFGRTR, AFSR0_EL1), >@@ -955,6 +1001,41 @@ typedef enum FGTBit { > DO_EL3_BIT(FGWTE3, TTBR0_EL3), > DO_EL3_BIT(FGWTE3, VBAR_EL3), > DO_EL3_BIT(FGWTE3, GPCBW_EL3), >+ >+ /* >+ * Trap bits in ICH_HFGRTR_EL2 / ICH_HFGWTR_EL2, starting from bit 0. >+ * These are all "trap on 0, don't trap on 1" and don't follow the >+ * "name starts with 'n' if sense is reversed" convention of the >+ * main FEAT_FGT registers. >+ */ >+ DO_REV_BIT(ICH_HFGRTR, ICC_APR_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_IDRN_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_CR0_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_HPPIR_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_PCR_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_ICSR_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_IAFFIDR_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_PPI_HMRN_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_PPI_ENABLERN_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_PPI_PENDRN_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_PPI_PRIORITYRN_EL1), >+ DO_REV_BIT(ICH_HFGRTR, ICC_PPI_ACTIVERN_EL1), >+ >+ /* >+ * Trap bits in ICH_HFGITR_EL2, starting from bit 0. These also >+ * are all "trap on 0". >+ */ >+ DO_REV_BIT(ICH_HFGITR, GICCDEN), >+ DO_REV_BIT(ICH_HFGITR, GICCDDIS), >+ DO_REV_BIT(ICH_HFGITR, GICCDPRI), >+ DO_REV_BIT(ICH_HFGITR, GICCDAFF), >+ DO_REV_BIT(ICH_HFGITR, GICCDPEND), >+ DO_REV_BIT(ICH_HFGITR, GICCDRCFG), >+ DO_REV_BIT(ICH_HFGITR, GICCDHM), >+ DO_REV_BIT(ICH_HFGITR, GICCDEOI), >+ DO_REV_BIT(ICH_HFGITR, GICCDDI), >+ DO_REV_BIT(ICH_HFGITR, GICRCDIA), >+ DO_REV_BIT(ICH_HFGITR, GICRCDNMIA), > } FGTBit; > > #undef DO_BIT >diff --git a/target/arm/cpu.h b/target/arm/cpu.h >index 5e52d552a8a..6db66c67362 100644 >--- a/target/arm/cpu.h >+++ b/target/arm/cpu.h >@@ -552,11 +552,13 @@ typedef struct CPUArchState { > * Fine-Grained Trap registers. We store these as arrays so the > * access checking code doesn't have to manually select > * HFGRTR_EL2 vs HFDFGRTR_EL2 etc when looking up the bit to test. >- * FEAT_FGT2 will add more elements to these arrays. >+ * These include the trap registers for all features which have >+ * FGT-style trapping: FEAT_FGT, FEAT_FGWTE3. GICv5, and (when we >+ * implement it) FEAT_FGT2. > */ >- uint64_t fgt_read[2]; /* HFGRTR, HDFGRTR */ >- uint64_t fgt_write[3]; /* HFGWTR, HDFGWTR, FGWTE3 */ >- uint64_t fgt_exec[1]; /* HFGITR */ >+ uint64_t fgt_read[4]; /* HFGRTR, HDFGRTR, unused, ICH_HFGRTR */ >+ uint64_t fgt_write[4]; /* HFGWTR, HDFGWTR, FGWTE3, ICH_HFGWTR */ >+ uint64_t fgt_exec[2]; /* HFGITR, ICH_HFGITR */ > > /* RME registers */ > uint64_t gpccr_el3; >diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c >index 1a89f56b94c..7ce3a2cc49a 100644 >--- a/target/arm/tcg/gicv5-cpuif.c >+++ b/target/arm/tcg/gicv5-cpuif.c >@@ -979,6 +979,28 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] = { > .accessfn = access_gicv5_ich_reg, > .fieldoffset = offsetof(CPUARMState, gicv5_cpuif.ich_apr_el2), > }, >+ { .name = "ICH_HFGRTR_EL2", .state = ARM_CP_STATE_AA64, >+ .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 9, .opc2 = 4, >+ .access = PL2_RW, .type = ARM_CP_NO_RAW, >+ .nv2_redirect_offset = 0xb10, >+ .accessfn = access_gicv5_ich_reg, >+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_read[FGTREG_ICH_HFGRTR]), >+ .resetvalue = ICH_HFGRTR_EL2_RES1_MASK, >+ }, >+ { .name = "ICH_HFGWTR_EL2", .state = ARM_CP_STATE_AA64, >+ .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 9, .opc2 = 6, >+ .access = PL2_RW, .type = ARM_CP_NO_RAW, >+ .nv2_redirect_offset = 0xb10, >+ .accessfn = access_gicv5_ich_reg, >+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_write[FGTREG_ICH_HFGWTR]), >+ }, >+ { .name = "ICH_HFGITR_EL2", .state = ARM_CP_STATE_AA64, >+ .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 9, .opc2 = 7, >+ .access = PL2_RW, .type = ARM_CP_NO_RAW, >+ .nv2_redirect_offset = 0xb10, >+ .accessfn = access_gicv5_ich_reg, >+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_exec[FGTREG_ICH_HFGITR]), >+ }, > /* > * Note that DVIR bits RAZ/WI when the PPI isn't assigned to the > * current domain, so we will need to mask them when we implement >-- >2.43.0 >