Skip to contentSkip to conversation

gicv3: Use right number of prio bits for the CPU

PATCH Superseded Peter Maydell 4 participants 13 messages May 6, 2022 – May 12, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover gicv3: Use right number of prio bits for the CPU

This patchset fills in an odd inconsistency in our GICv3 emulation that I noticed while I was doing the GICv4 work. At the moment we allow the CPU to specify the number of bits of virtual priority (via the ARMCPU::gic_vpribits field), but we always use 8 bits of physical priority, even though to my knowledge no real Arm CPU hardware has that many.

This series makes the GICv3 emulation use a runtime-configurable number of physical priority bits, and sets it to match the number used by the various CPUs we implement (which is 5 for all the Cortex-Axx CPUs we emulate). Because changing the number of priority bits is a migration compatibility break, we use a compat property to keep the number of priority bits at 8 for older versions of the virt board.

There is one TODO left in this series, which is that I don't know the right value to use for the A64FX, so I've guessed that it is 5, like all the Arm implementations.

Patch 1 is an independent bugfix; patch 5 is cleanup.

thanks
-- PMM

Peter Maydell (5):
hw/intc/arm_gicv3: report correct PRIbits field in ICV_CTLR_EL1 hw/intc/arm_gicv3_kvm.c: Stop using GIC_MIN_BPR constant hw/intc/arm_gicv3: Support configurable number of physical priority
bits
hw/intc/arm_gicv3: Use correct number of priority bits for the CPU hw/intc/arm_gicv3: Provide ich_num_aprs()

 include/hw/intc/arm_gicv3_common.h |   8 +-
 target/arm/cpu.h                   |   1 +
 hw/core/machine.c                  |   4 +-
 hw/intc/arm_gicv3_common.c         |   5 +
 hw/intc/arm_gicv3_cpuif.c          | 208 ++++++++++++++++++++---------
 hw/intc/arm_gicv3_kvm.c            |  16 ++-
 target/arm/cpu64.c                 |   9 ++
 7 files changed, 179 insertions(+), 72 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/5 hw/intc/arm_gicv3: report correct PRIbits field in ICV_CTLR_EL1

As noted in the comment, the PRIbits field in ICV_CTLR_EL1 is supposed to match the ICH_VTR_EL2 PRIbits setting; that is, it is the virtual priority bit setting, not the physical priority bit setting. (For QEMU currently we always implement 8 bits of physical priority, so the PRIbits field was previously 7, since it is defined to be "priority bits - 1".)

---
 hw/intc/arm_gicv3_cpuif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gicv3_cpuif.c +1 -1
index 9efba798f82..d3b92a36636 100644
@@ -657,7 +657,7 @@ static uint64_t icv_ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
      * should match the ones reported in ich_vtr_read().
      */
     value = ICC_CTLR_EL1_A3V | (1 << ICC_CTLR_EL1_IDBITS_SHIFT) |
-        (7 << ICC_CTLR_EL1_PRIBITS_SHIFT);
+        ((cs->vpribits - 1) << ICC_CTLR_EL1_PRIBITS_SHIFT);
 
     if (cs->ich_vmcr_el2 & ICH_VMCR_EL2_VEOIM) {
         value |= ICC_CTLR_EL1_EOIMODE;
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/5 hw/intc/arm_gicv3_kvm.c: Stop using GIC_MIN_BPR constant

In reply to Peter Maydell

The GIC_MIN_BPR constant defines the minimum BPR value that the TCG emulated GICv3 supports. We're currently using this also as the value we reset the KVM GICv3 ICC_BPR registers to, but this is only right by accident.

We want to make the emulated GICv3 use a configurable number of priority bits, which means that GIC_MIN_BPR will no longer be a constant. Replace the uses in the KVM reset code with literal 0, plus a constant explaining why this is reasonable.

---
 hw/intc/arm_gicv3_kvm.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
hw/intc/arm_gicv3_kvm.c +13 -3
index 2922c516e56..3ca643ecba4 100644
@@ -673,9 +673,19 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     s = c->gic;
 
     c->icc_pmr_el1 = 0;
-    c->icc_bpr[GICV3_G0] = GIC_MIN_BPR;
-    c->icc_bpr[GICV3_G1] = GIC_MIN_BPR;
-    c->icc_bpr[GICV3_G1NS] = GIC_MIN_BPR;
+    /*
+     * Architecturally the reset value of the ICC_BPR registers
+     * is UNKNOWN. We set them all to 0 here; when the kernel
+     * uses these values to program the ICH_VMCR_EL2 fields that
+     * determine the guest-visible ICC_BPR register values, the
+     * hardware's "writing a value less than the minimum sets
+     * the field to the minimum value" behaviour will result in
+     * them effectively resetting to the correct minimum value
+     * for the host GIC.
+     */
+    c->icc_bpr[GICV3_G0] = 0;
+    c->icc_bpr[GICV3_G1] = 0;
+    c->icc_bpr[GICV3_G1NS] = 0;
 
     c->icc_sre_el1 = 0x7;
     memset(c->icc_apr, 0, sizeof(c->icc_apr));
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/5 hw/intc/arm_gicv3: Support configurable number of physical priority bits

In reply to Peter Maydell

The GICv3 code has always supported a configurable number of virtual priority and preemption bits, but our implementation currently hardcodes the number of physical priority bits at 8. This is not what most hardware implementations provide; for instance the Cortex-A53 provides only 5 bits of physical priority.

Make the number of physical priority/preemption bits driven by fields in the GICv3CPUState, the way that we already do for virtual priority/preemption bits. We set cs->pribits to 8, so there is no behavioural change in this commit. A following commit will add the machinery for CPUs to set this to the correct value for their implementation.

Note that changing the number of priority bits would be a migration compatibility break, because the semantics of the icc_apr[][] array changes.

---
 include/hw/intc/arm_gicv3_common.h |   7 +-
 hw/intc/arm_gicv3_cpuif.c          | 182 ++++++++++++++++++++---------
 2 files changed, 130 insertions(+), 59 deletions(-)
include/hw/intc/arm_gicv3_common.h +2 -5
index 4e416100559..46677ec345c 100644
@@ -51,11 +51,6 @@
 /* Maximum number of list registers (architectural limit) */
 #define GICV3_LR_MAX 16
 
-/* Minimum BPR for Secure, or when security not enabled */
-#define GIC_MIN_BPR 0
-/* Minimum BPR for Nonsecure when security is enabled */
-#define GIC_MIN_BPR_NS (GIC_MIN_BPR + 1)
-
 /* For some distributor fields we want to model the array of 32-bit
  * register values which hold various bitmaps corresponding to enabled,
  * pending, etc bits. These macros and functions facilitate that; the
@@ -206,6 +201,8 @@ struct GICv3CPUState {
     int num_list_regs;
     int vpribits; /* number of virtual priority bits */
     int vprebits; /* number of virtual preemption bits */
+    int pribits; /* number of physical priority bits */
+    int prebits; /* number of physical preemption bits */
 
     /* Current highest priority pending interrupt for this CPU.
      * This is cached information that can be recalculated from the
hw/intc/arm_gicv3_cpuif.c +128 -54

261 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/5 hw/intc/arm_gicv3: Use correct number of priority bits for the CPU

In reply to Peter Maydell

Make the GICv3 set its number of bits of physical priority from the implementation-specific value provided in the CPU state struct, in the same way we already do for virtual priority bits. Because this would be a migration compatibility break, we provide a property force-8-bit-prio which is enabled for 7.0 and earlier versioned board models to retain the legacy "always use 8 bits" behaviour.

---
I have guessed at the right value for the A64FX, but if we can find the correct ICC_CTLR_EL1 value that would be better.

---
 include/hw/intc/arm_gicv3_common.h |  1 +
 target/arm/cpu.h                   |  1 +
 hw/core/machine.c                  |  4 +++-
 hw/intc/arm_gicv3_common.c         |  5 +++++
 hw/intc/arm_gicv3_cpuif.c          | 14 ++++++++++----
 target/arm/cpu64.c                 |  9 +++++++++
 6 files changed, 29 insertions(+), 5 deletions(-)
include/hw/intc/arm_gicv3_common.h +1 -0
index 46677ec345c..ab5182a28a2 100644
@@ -248,6 +248,7 @@ struct GICv3State {
     uint32_t revision;
     bool lpi_enable;
     bool security_extn;
+    bool force_8bit_prio;
     bool irq_reset_nonsecure;
     bool gicd_no_migration_shift_bug;
 
target/arm/cpu.h +1 -0
index ca01f909a86..f8873bdbb97 100644
@@ -993,6 +993,7 @@ struct ArchCPU {
     int gic_num_lrs; /* number of list registers */
     int gic_vpribits; /* number of virtual priority bits */
     int gic_vprebits; /* number of virtual preemption bits */
+    int gic_pribits; /* number of physical priority bits */
 
     /* Whether the cfgend input is high (i.e. this CPU should reset into
      * big-endian mode).  This setting isn't used directly: instead it modifies
hw/core/machine.c +3 -1
index cb9bbc844d2..db012376785 100644
@@ -37,7 +37,9 @@
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-pci.h"
 
-GlobalProperty hw_compat_7_0[] = {};
+GlobalProperty hw_compat_7_0[] = {
+    { "arm-gicv3-common", "force-8-bit-prio", "on" },
+};
 const size_t hw_compat_7_0_len = G_N_ELEMENTS(hw_compat_7_0);
 
 GlobalProperty hw_compat_6_2[] = {
hw/intc/arm_gicv3_common.c +5 -0
index 5634c6fc788..351843db4aa 100644
@@ -563,6 +563,11 @@ static Property arm_gicv3_common_properties[] = {
     DEFINE_PROP_UINT32("revision", GICv3State, revision, 3),
     DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0),
     DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0),
+    /*
+     * Compatibility property: force 8 bits of physical priority, even
+     * if the CPU being emulated should have fewer.
+     */
+    DEFINE_PROP_BOOL("force-8-bit-prio", GICv3State, force_8bit_prio, 0),
     DEFINE_PROP_ARRAY("redist-region-count", GICv3State, nb_redist_regions,
                       redist_region_count, qdev_prop_uint32, uint32_t),
     DEFINE_PROP_LINK("sysmem", GICv3State, dma, TYPE_MEMORY_REGION,
hw/intc/arm_gicv3_cpuif.c +10 -4
index 8499a49be39..e277a807bd5 100644
@@ -2801,11 +2801,17 @@ void gicv3_init_cpuif(GICv3State *s)
         define_arm_cp_regs(cpu, gicv3_cpuif_reginfo);
 
         /*
-         * For the moment, retain the existing behaviour of 8 priority bits;
-         * in a following commit we will take this from the CPU state,
-         * as we do for the virtual priority bits.
+         * The CPU implementation specifies the number of supported
+         * bits of physical priority. For backwards compatibility
+         * of migration, we have a compat property that forces use
+         * of 8 priority bits regardless of what the CPU really has.
          */
-        cs->pribits = 8;
+        if (s->force_8bit_prio) {
+            cs->pribits = 8;
+        } else {
+            cs->pribits = cpu->gic_pribits;
+        }
+
         /*
          * The GICv3 has separate ID register fields for virtual priority
          * and preemption bit values, but only a single ID register field
target/arm/cpu64.c +9 -0
index c841d55d0e9..490231b90f3 100644
@@ -143,6 +143,7 @@ static void aarch64_a57_initfn(Object *obj)
     cpu->gic_num_lrs = 4;
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
+    cpu->gic_pribits = 5;
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
 }
 
@@ -196,6 +197,7 @@ static void aarch64_a53_initfn(Object *obj)
     cpu->gic_num_lrs = 4;
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
+    cpu->gic_pribits = 5;
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
 }
 
@@ -247,6 +249,7 @@ static void aarch64_a72_initfn(Object *obj)
     cpu->gic_num_lrs = 4;
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
+    cpu->gic_pribits = 5;
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
 }
 
@@ -961,6 +964,12 @@ static void aarch64_a64fx_initfn(Object *obj)
     cpu->gic_num_lrs = 4;
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
+    /*
+     * TODO: What does the real A64FX GICv3 provide ?
+     * This is a guess based on what other Arm CPUs do; to find the correct
+     * answer we need the value of the A64FX's ICC_CTLR_EL1 register.
+     */
+    cpu->gic_pribits = 5;
 
     /* Suppport of A64FX's vector length are 128,256 and 512bit only */
     aarch64_add_sve_properties(obj);
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH 4/5] hw/intc/arm_gicv3: Use correct number of priority bits for the CPU

Quoted 8 lines · Peter Maydell

Make the GICv3 set its number of bits of physical priority from the implementation-specific value provided in the CPU state struct, in the same way we already do for virtual priority bits. Because this would be a migration compatibility break, we provide a property force-8-bit-prio which is enabled for 7.0 and earlier versioned board models to retain the legacy "always use 8 bits" behaviour.

Quoted 4 lines

---
I have guessed at the right value for the A64FX, but if we can find the correct ICC_CTLR_EL1 value that would be better.

Shuuichirou, Itaru: do either of you know the right setting for the A64FX for this? If you can find what the hardware value of the ICC_CTLR_EL3 or ICC_CTLR_EL1 register is (more specifically, the PRIBits subfield) that should be enough to tell us.

Quoted 14 lines
target/arm/cpu64.c +6 -1
@@ -961,6 +964,12 @@ static void aarch64_a64fx_initfn(Object *obj)
     cpu->gic_num_lrs = 4;
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
+    /*
+     * TODO: What does the real A64FX GICv3 provide ?
+     * This is a guess based on what other Arm CPUs do; to find the correct
+     * answer we need the value of the A64FX's ICC_CTLR_EL1 register.
+     */
+    cpu->gic_pribits = 5;
 
     /* Suppport of A64FX's vector length are 128,256 and 512bit only */
     aarch64_add_sve_properties(obj);
--
Quoted 1 line

2.25.1

thanks
-- PMM

#6 lore raw

Re: [PATCH 4/5] hw/intc/arm_gicv3: Use correct number of priority bits for the CPU

Peter,
I’ll talk with Shuichiro this coming Monday (here most of us on vacation), and get back to you.

Itaru.

Quoted 40 lines · On Sat, May 7, 2022 at 1:34 Peter Maydell <[email protected]> wrote:
Quoted 8 lines · Peter Maydell

Make the GICv3 set its number of bits of physical priority from the implementation-specific value provided in the CPU state struct, in the same way we already do for virtual priority bits. Because this would be a migration compatibility break, we provide a property force-8-bit-prio which is enabled for 7.0 and earlier versioned board models to retain the legacy "always use 8 bits" behaviour.

Quoted 4 lines

---
I have guessed at the right value for the A64FX, but if we can find the correct ICC_CTLR_EL1 value that would be better.

Shuuichirou, Itaru: do either of you know the right setting for the A64FX for this? If you can find what the hardware value of the ICC_CTLR_EL3 or ICC_CTLR_EL1 register is (more specifically, the PRIBits subfield) that should be enough to tell us.

target/arm/cpu64.c static void aarch64_a64fx_initfn(Object *obj) · line 969

Quoted 7 lines
target/arm/cpu64.c +3 -0
@@ -961,6 +964,12 @@ static void aarch64_a64fx_initfn(Object *obj)
     cpu->gic_num_lrs = 4;
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
+    /*
+     * TODO: What does the real A64FX GICv3 provide ?
+     * This is a guess based on what other Arm CPUs do; to find the

correct

Quoted 8 lines
target/arm/cpu64.c +3 -1
+     * answer we need the value of the A64FX's ICC_CTLR_EL1 register.
+     */
+    cpu->gic_pribits = 5;
 
     /* Suppport of A64FX's vector length are 128,256 and 512bit only */
     aarch64_add_sve_properties(obj);
--

2.25.1

thanks
-- PMM

#7 lore raw

RE: [PATCH 4/5] hw/intc/arm_gicv3: Use correct number of priority bits for the CPU

In reply to Peter Maydell

Hi, Peter.

Quoted 4 lines

Shuuichirou, Itaru: do either of you know the right setting for the A64FX for this? If you can find what the hardware value of the ICC_CTLR_EL3 or ICC_CTLR_EL1 register is (more specifically, the PRIBits subfield) that should be enough to tell us.

The value of the PRIbits field in the A64FX is 0x4. Therefore, the following values is fine.

Quoted 1 line
Quoted 1 line

+ cpu->gic_pribits = 5;

Best regards,
Shuuichirou.

P.S.
Itaru, thank you for the follow-up.

Quoted 46 lines

-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Saturday, May 7, 2022 1:34 AM
To: [email protected]; [email protected]
Cc: Ishii, Shuuichirou/石井 周一郎 <[email protected]>; Itaru Kitayama <[email protected]>
Subject: Re: [PATCH 4/5] hw/intc/arm_gicv3: Use correct number of priority bits for the CPU

Quoted 8 lines · Peter Maydell

Make the GICv3 set its number of bits of physical priority from the implementation-specific value provided in the CPU state struct, in the same way we already do for virtual priority bits. Because this would be a migration compatibility break, we provide a property force-8-bit-prio which is enabled for 7.0 and earlier versioned board models to retain the legacy "always use 8 bits" behaviour.

Quoted 4 lines

---
I have guessed at the right value for the A64FX, but if we can find the correct ICC_CTLR_EL1 value that would be better.

Shuuichirou, Itaru: do either of you know the right setting for the A64FX for this? If you can find what the hardware value of the ICC_CTLR_EL3 or ICC_CTLR_EL1 register is (more specifically, the PRIBits subfield) that should be enough to tell us.

Quoted 14 lines
target/arm/cpu64.c +6 -1
@@ -961,6 +964,12 @@ static void aarch64_a64fx_initfn(Object *obj)
     cpu->gic_num_lrs = 4;
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
+    /*
+     * TODO: What does the real A64FX GICv3 provide ?
+     * This is a guess based on what other Arm CPUs do; to find the correct
+     * answer we need the value of the A64FX's ICC_CTLR_EL1 register.
+     */
+    cpu->gic_pribits = 5;
 
     /* Suppport of A64FX's vector length are 128,256 and 512bit only */
     aarch64_add_sve_properties(obj);
--
Quoted 1 line

2.25.1

thanks
-- PMM

#8 lore raw

Re: [PATCH 4/5] hw/intc/arm_gicv3: Use correct number of priority bits for the CPU

Quoted 12 lines · On Mon, 9 May 2022 at 23:55, [email protected]…

Hi, Peter.

Quoted 4 lines

Shuuichirou, Itaru: do either of you know the right setting for the A64FX for this? If you can find what the hardware value of the ICC_CTLR_EL3 or ICC_CTLR_EL1 register is (more specifically, the PRIBits subfield) that should be enough to tell us.

The value of the PRIbits field in the A64FX is 0x4. Therefore, the following values is fine.

Quoted 1 line
Quoted 1 line

+ cpu->gic_pribits = 5;

Great, thanks very much for confirming this.

-- PMM

#9 lore raw

PATCH 5/5 hw/intc/arm_gicv3: Provide ich_num_aprs()

In reply to Peter Maydell

We previously open-coded the expression for the number of virtual APR registers and the assertion that it was not going to cause us to overflow the cs->ich_apr[] array. Factor this out into a new ich_num_aprs() function, for consistency with the icc_num_aprs() function we just added for the physical APR handling.

---
 hw/intc/arm_gicv3_cpuif.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
hw/intc/arm_gicv3_cpuif.c +10 -8
index e277a807bd5..5418ad9bbc5 100644
@@ -49,6 +49,14 @@ static inline int icv_min_vbpr(GICv3CPUState *cs)
     return 7 - cs->vprebits;
 }
 
+static inline int ich_num_aprs(GICv3CPUState *cs)
+{
+    /* Return the number of virtual APR registers (1, 2, or 4) */
+    int aprmax = 1 << (cs->vprebits - 5);
+    assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0]));
+    return aprmax;
+}
+
 /* Simple accessor functions for LR fields */
 static uint32_t ich_lr_vintid(uint64_t lr)
 {
@@ -145,11 +153,8 @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs)
      * in the ICH Active Priority Registers.
      */
     int i;
-    int aprmax = 1 << (cs->vprebits - 5);
 
-    assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0]));
-
-    for (i = 0; i < aprmax; i++) {
+    for (i = 0; i < ich_num_aprs(cs); i++) {
         uint32_t apr = cs->ich_apr[GICV3_G0][i] |
             cs->ich_apr[GICV3_G1NS][i];
 
@@ -1333,11 +1338,8 @@ static int icv_drop_prio(GICv3CPUState *cs)
      * 32 bits are actually relevant.
      */
     int i;
-    int aprmax = 1 << (cs->vprebits - 5);
 
-    assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0]));
-
-    for (i = 0; i < aprmax; i++) {
+    for (i = 0; i < ich_num_aprs(cs); i++) {
         uint64_t *papr0 = &cs->ich_apr[GICV3_G0][i];
         uint64_t *papr1 = &cs->ich_apr[GICV3_G1NS][i];
         int apr0count, apr1count;
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH 5/5] hw/intc/arm_gicv3: Provide ich_num_aprs()

hw/intc/arm_gicv3_cpuif.c static int ich_highest_active_virt_prio(GICv3CPUState *cs) · line 157

Quoted 10 lines · Peter Maydell
hw/intc/arm_gicv3_cpuif.c +1 -4
@@ -145,11 +153,8 @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs)
       * in the ICH Active Priority Registers.
       */
      int i;
-    int aprmax = 1 << (cs->vprebits - 5);
 
-    assert(aprmax <= ARRAY_SIZE(cs->ich_apr[0]));
-
-    for (i = 0; i < aprmax; i++) {
+    for (i = 0; i < ich_num_aprs(cs); i++) {

Better to retain the local variable for the loop bound.

r~

Reviewed-by on the v1 series
#11 lore raw
In reply to Peter Maydell
Quoted 24 lines · Peter Maydell

This patchset fills in an odd inconsistency in our GICv3 emulation that I noticed while I was doing the GICv4 work. At the moment we allow the CPU to specify the number of bits of virtual priority (via the ARMCPU::gic_vpribits field), but we always use 8 bits of physical priority, even though to my knowledge no real Arm CPU hardware has that many.

This series makes the GICv3 emulation use a runtime-configurable number of physical priority bits, and sets it to match the number used by the various CPUs we implement (which is 5 for all the Cortex-Axx CPUs we emulate). Because changing the number of priority bits is a migration compatibility break, we use a compat property to keep the number of priority bits at 8 for older versions of the virt board.

There is one TODO left in this series, which is that I don't know the right value to use for the A64FX, so I've guessed that it is 5, like all the Arm implementations.

Patch 1 is an independent bugfix; patch 5 is cleanup.

thanks
-- PMM

Quoted 8 lines

Peter Maydell (5):
hw/intc/arm_gicv3: report correct PRIbits field in ICV_CTLR_EL1 hw/intc/arm_gicv3_kvm.c: Stop using GIC_MIN_BPR constant hw/intc/arm_gicv3: Support configurable number of physical priority
bits
hw/intc/arm_gicv3: Use correct number of priority bits for the CPU hw/intc/arm_gicv3: Provide ich_num_aprs()

r~

#12 lore raw
Quoted 35 lines · Richard Henderson
Quoted 24 lines · Peter Maydell

This patchset fills in an odd inconsistency in our GICv3 emulation that I noticed while I was doing the GICv4 work. At the moment we allow the CPU to specify the number of bits of virtual priority (via the ARMCPU::gic_vpribits field), but we always use 8 bits of physical priority, even though to my knowledge no real Arm CPU hardware has that many.

This series makes the GICv3 emulation use a runtime-configurable number of physical priority bits, and sets it to match the number used by the various CPUs we implement (which is 5 for all the Cortex-Axx CPUs we emulate). Because changing the number of priority bits is a migration compatibility break, we use a compat property to keep the number of priority bits at 8 for older versions of the virt board.

There is one TODO left in this series, which is that I don't know the right value to use for the A64FX, so I've guessed that it is 5, like all the Arm implementations.

Patch 1 is an independent bugfix; patch 5 is cleanup.

thanks
-- PMM

Quoted 8 lines

Peter Maydell (5):
hw/intc/arm_gicv3: report correct PRIbits field in ICV_CTLR_EL1 hw/intc/arm_gicv3_kvm.c: Stop using GIC_MIN_BPR constant hw/intc/arm_gicv3: Support configurable number of physical priority
bits
hw/intc/arm_gicv3: Use correct number of priority bits for the CPU hw/intc/arm_gicv3: Provide ich_num_aprs()

Quoted 1 line

Thanks; I've applied this to target-arm.next, with the 'TODO' note for the A64FX removed, with the "retain local variable" tweak in the last patch made, and with "cpu->gic_pribits = 5" statements added for the new cortex-a76 and neoverse-n1 CPU types (confirmed correct via their TRMs).

-- PMM