qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix GICv2 handling of pending interrupts
@ 2024-05-24 11:32 Sebastian Huber
  2024-05-24 11:32 ` [PATCH v2 1/2] hw/intc/arm_gic: Fix set pending of PPIs Sebastian Huber
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sebastian Huber @ 2024-05-24 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-arm, Peter Maydell, Luc Michel

v2:

* Fix handling of SPIs.

* Remove pending state if not in new target list.

Sebastian Huber (2):
  hw/intc/arm_gic: Fix set pending of PPIs
  hw/intc/arm_gic: Fix writes to GICD_ITARGETSRn

 hw/intc/arm_gic.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

-- 
2.35.3



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] hw/intc/arm_gic: Fix set pending of PPIs
  2024-05-24 11:32 [PATCH v2 0/2] Fix GICv2 handling of pending interrupts Sebastian Huber
@ 2024-05-24 11:32 ` Sebastian Huber
  2024-05-24 11:32 ` [PATCH v2 2/2] hw/intc/arm_gic: Fix writes to GICD_ITARGETSRn Sebastian Huber
  2024-05-30 10:25 ` [PATCH v2 0/2] Fix GICv2 handling of pending interrupts Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Huber @ 2024-05-24 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-arm, Peter Maydell, Luc Michel

According to the GICv2 specification section 4.3.7, "Interrupt Set-Pending
Registers, GICD_ISPENDRn":

"In a multiprocessor implementation, GICD_ISPENDR0 is banked for each connected
processor. This register holds the Set-pending bits for interrupts 0-31."

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 hw/intc/arm_gic.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index 074cf50af2..241255081d 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -1308,12 +1308,15 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
 
         for (i = 0; i < 8; i++) {
             if (value & (1 << i)) {
+                int mask = (irq < GIC_INTERNAL) ? (1 << cpu)
+                                                : GIC_DIST_TARGET(irq + i);
+
                 if (s->security_extn && !attrs.secure &&
                     !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) {
                     continue; /* Ignore Non-secure access of Group0 IRQ */
                 }
 
-                GIC_DIST_SET_PENDING(irq + i, GIC_DIST_TARGET(irq + i));
+                GIC_DIST_SET_PENDING(irq + i, mask);
             }
         }
     } else if (offset < 0x300) {
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] hw/intc/arm_gic: Fix writes to GICD_ITARGETSRn
  2024-05-24 11:32 [PATCH v2 0/2] Fix GICv2 handling of pending interrupts Sebastian Huber
  2024-05-24 11:32 ` [PATCH v2 1/2] hw/intc/arm_gic: Fix set pending of PPIs Sebastian Huber
@ 2024-05-24 11:32 ` Sebastian Huber
  2024-05-30 10:25 ` [PATCH v2 0/2] Fix GICv2 handling of pending interrupts Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Huber @ 2024-05-24 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-arm, Peter Maydell, Luc Michel

According to the GICv2 specification section 4.3.12, "Interrupt Processor
Targets Registers, GICD_ITARGETSRn":

"Any change to a CPU targets field value:
[...]
* Has an effect on any pending interrupts. This means:
  - adding a CPU interface to the target list of a pending interrupt makes that
    interrupt pending on that CPU interface
  - removing a CPU interface from the target list of a pending interrupt
    removes the pending state of that interrupt on that CPU interface."

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 hw/intc/arm_gic.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index 241255081d..1f9bffc88c 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -1410,6 +1410,13 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
                 value = ALL_CPU_MASK;
             }
             s->irq_target[irq] = value & ALL_CPU_MASK;
+            if (irq >= GIC_INTERNAL && s->irq_state[irq].pending) {
+                /*
+                 * Changing the target of an interrupt that is currently
+                 * pending updates the set of CPUs it is pending on.
+                 */
+                s->irq_state[irq].pending = value & ALL_CPU_MASK;
+            }
         }
     } else if (offset < 0xf00) {
         /* Interrupt Configuration.  */
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] Fix GICv2 handling of pending interrupts
  2024-05-24 11:32 [PATCH v2 0/2] Fix GICv2 handling of pending interrupts Sebastian Huber
  2024-05-24 11:32 ` [PATCH v2 1/2] hw/intc/arm_gic: Fix set pending of PPIs Sebastian Huber
  2024-05-24 11:32 ` [PATCH v2 2/2] hw/intc/arm_gic: Fix writes to GICD_ITARGETSRn Sebastian Huber
@ 2024-05-30 10:25 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2024-05-30 10:25 UTC (permalink / raw)
  To: Sebastian Huber; +Cc: qemu-devel, qemu-arm, Luc Michel

On Fri, 24 May 2024 at 12:33, Sebastian Huber
<sebastian.huber@embedded-brains.de> wrote:
>
> v2:
>
> * Fix handling of SPIs.
>
> * Remove pending state if not in new target list.
>
> Sebastian Huber (2):
>   hw/intc/arm_gic: Fix set pending of PPIs
>   hw/intc/arm_gic: Fix writes to GICD_ITARGETSRn



Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-30 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-24 11:32 [PATCH v2 0/2] Fix GICv2 handling of pending interrupts Sebastian Huber
2024-05-24 11:32 ` [PATCH v2 1/2] hw/intc/arm_gic: Fix set pending of PPIs Sebastian Huber
2024-05-24 11:32 ` [PATCH v2 2/2] hw/intc/arm_gic: Fix writes to GICD_ITARGETSRn Sebastian Huber
2024-05-30 10:25 ` [PATCH v2 0/2] Fix GICv2 handling of pending interrupts Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).