Skip to contentSkip to conversation

target/arm: Minor GICv5 cpuif bugfixes

PATCH In review Peter Maydell 3 participants 7 messages Jul 14

lore
Share & tools
lore
#0 lore raw

cover target/arm: Minor GICv5 cpuif bugfixes

This patchset is a couple of fixes for minor bugs in the GICv5 cpu interface code that I noticed while I was working on adding virtualization support to it.

thanks
-- PMM

Peter Maydell (2):
target/arm: GICv5 cpuif: gicr_cdia_read() ppibit should be 64 bits target/arm: GICv5 cpuif: Writes to ICC_APR_EL1 can change IRQ/FIQ

 target/arm/tcg/gicv5-cpuif.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 target/arm: GICv5 cpuif: gicr_cdia_read() ppibit should be 64 bits

In gicr_cdia_read() we turn a PPI interrupt ID into a register index and a bit mask with a 1 for the bit we want to change:

        ppireg = id / 64;
        ppibit = 1ULL << (id % 64);

However, we used the wrong type for ppibit, making it a uint32_t. If 'id' is too large we'll shift off the end, so we won't ever update the state of PPIs with indexes above 31.

This didn't have any visible effects because the currently allocated architected PPIs are indexes 0..31, so you'd only see this if for some reason a guest was manually marking as pending a PPI in 32..63.

Fix the type of ppibit to the intended 64 bit width.

Fixes 3f79212abae89 ("target/arm: GICv5 cpuif: Implement GICR CDIA command")
---
 target/arm/tcg/gicv5-cpuif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/arm/tcg/gicv5-cpuif.c +2 -1
index 1cdd4103d0e..8e2a08fdb6f 100644
@@ -633,7 +633,8 @@ static uint64_t gicr_cdia_read(CPUARMState *env, const ARMCPRegInfo *ri)
     switch (type) {
     case GICV5_PPI:
     {
-        uint32_t ppireg, ppibit;
+        uint32_t ppireg;
+        uint64_t ppibit;
 
         assert(id < GICV5_NUM_PPIS);
         ppireg = id / 64;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] target/arm: GICv5 cpuif: gicr_cdia_read() ppibit should be 64 bits

Quoted 14 lines · Peter Maydell

In gicr_cdia_read() we turn a PPI interrupt ID into a register index and a bit mask with a 1 for the bit we want to change:

         ppireg = id / 64;
         ppibit = 1ULL << (id % 64);

However, we used the wrong type for ppibit, making it a uint32_t. If 'id' is too large we'll shift off the end, so we won't ever update the state of PPIs with indexes above 31.

This didn't have any visible effects because the currently allocated architected PPIs are indexes 0..31, so you'd only see this if for some reason a guest was manually marking as pending a PPI in 32..63.

Quoted 7 lines

Fix the type of ppibit to the intended 64 bit width.

Fixes 3f79212abae89 ("target/arm: GICv5 cpuif: Implement GICR CDIA command")
---
  target/arm/tcg/gicv5-cpuif.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] target/arm: GICv5 cpuif: gicr_cdia_read() ppibit should be 64 bits

In reply to Peter Maydell
Quoted 14 lines · Peter Maydell

In gicr_cdia_read() we turn a PPI interrupt ID into a register index and a bit mask with a 1 for the bit we want to change:

         ppireg = id / 64;
         ppibit = 1ULL << (id % 64);

However, we used the wrong type for ppibit, making it a uint32_t. If 'id' is too large we'll shift off the end, so we won't ever update the state of PPIs with indexes above 31.

This didn't have any visible effects because the currently allocated architected PPIs are indexes 0..31, so you'd only see this if for some reason a guest was manually marking as pending a PPI in 32..63.

Quoted 7 lines

Fix the type of ppibit to the intended 64 bit width.

Fixes 3f79212abae89 ("target/arm: GICv5 cpuif: Implement GICR CDIA command")
---
  target/arm/tcg/gicv5-cpuif.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

r~

#4 lore raw

PATCH 2/2 target/arm: GICv5 cpuif: Writes to ICC_APR_EL1 can change IRQ/FIQ

In reply to Peter Maydell

The ICC_APR_EL1 register values change the current running priority, which we use in our calculations in gic_hppi(). Changing them can affect whether we have a HPPI, and so the value of the IRQ/FIQ outputs. We need to trigger an update in the register writefn.

Fixes 9bd90bddb79 ("target/arm: GICv5 cpuif: Signal IRQ or FIQ")
---
 target/arm/tcg/gicv5-cpuif.c | 1 +
 1 file changed, 1 insertion(+)
target/arm/tcg/gicv5-cpuif.c +1 -0
index 8e2a08fdb6f..a6e6c440849 100644
@@ -495,6 +495,7 @@ static void gic_icc_apr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri,
     GICv5Domain domain = gicv5_logical_domain(env);
     value &= 0xffffffff;
     env->gicv5_cpuif.icc_apr[domain] = value;
+    gicv5_update_irq_fiq(env);
 }
 
 static uint64_t gic_icc_apr_el1_read(CPUARMState *env, const ARMCPRegInfo *ri)
Signature · 1 line
2.43.0
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] target/arm: GICv5 cpuif: Writes to ICC_APR_EL1 can change IRQ/FIQ

Quoted 10 lines · Peter Maydell

The ICC_APR_EL1 register values change the current running priority, which we use in our calculations in gic_hppi(). Changing them can affect whether we have a HPPI, and so the value of the IRQ/FIQ outputs. We need to trigger an update in the register writefn.

Fixes 9bd90bddb79 ("target/arm: GICv5 cpuif: Signal IRQ or FIQ")
---
  target/arm/tcg/gicv5-cpuif.c | 1 +
  1 file changed, 1 insertion(+)
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] target/arm: GICv5 cpuif: Writes to ICC_APR_EL1 can change IRQ/FIQ

In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

The ICC_APR_EL1 register values change the current running priority, which we use in our calculations in gic_hppi(). Changing them can affect whether we have a HPPI, and so the value of the IRQ/FIQ outputs. We need to trigger an update in the register writefn.

Fixes 9bd90bddb79 ("target/arm: GICv5 cpuif: Signal IRQ or FIQ")
---
  target/arm/tcg/gicv5-cpuif.c | 1 +
  1 file changed, 1 insertion(+)

r~