qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Glenn Miles" <milesg@linux.ibm.com>,
	"Michael Kowal" <kowal@linux.ibm.com>,
	"Gautam Menghani" <gautam@linux.ibm.com>,
	"Cédric Le Goater" <clg@redhat.com>
Subject: [PULL 31/50] ppc/xive: Fix high prio group interrupt being preempted by low prio VP
Date: Mon, 21 Jul 2025 18:22:14 +0200	[thread overview]
Message-ID: <20250721162233.686837-32-clg@redhat.com> (raw)
In-Reply-To: <20250721162233.686837-1-clg@redhat.com>

From: Nicholas Piggin <npiggin@gmail.com>

xive_tctx_pipr_present() as implemented with xive_tctx_pipr_update()
causes VP-directed (group==0) interrupt to be presented in PIPR and NSR
despite being a lower priority than the currently presented group
interrupt.

This must not happen. The IPB bit should record the low priority VP
interrupt, but PIPR and NSR must not present the lower priority
interrupt.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
Reviewed-by: Michael Kowal <kowal@linux.ibm.com>
Tested-by: Gautam Menghani <gautam@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20250512031100.439842-32-npiggin@gmail.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
 hw/intc/xive.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index 038c35846d94..7110cf45d74f 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -228,7 +228,23 @@ void xive_tctx_pipr_update(XiveTCTX *tctx, uint8_t ring, uint8_t priority,
 void xive_tctx_pipr_present(XiveTCTX *tctx, uint8_t ring, uint8_t priority,
                             uint8_t group_level)
 {
-    xive_tctx_pipr_update(tctx, ring, priority, group_level);
+    /* HV_POOL ring uses HV_PHYS NSR, CPPR and PIPR registers */
+    uint8_t alt_ring = (ring == TM_QW2_HV_POOL) ? TM_QW3_HV_PHYS : ring;
+    uint8_t *aregs = &tctx->regs[alt_ring];
+    uint8_t *regs = &tctx->regs[ring];
+    uint8_t pipr = xive_priority_to_pipr(priority);
+
+    if (group_level == 0) {
+        regs[TM_IPB] |= xive_priority_to_ipb(priority);
+        if (pipr >= aregs[TM_PIPR]) {
+            /* VP interrupts can come here with lower priority than PIPR */
+            return;
+        }
+    }
+    g_assert(pipr <= xive_ipb_to_pipr(regs[TM_IPB]));
+    g_assert(pipr < aregs[TM_PIPR]);
+    aregs[TM_PIPR] = pipr;
+    xive_tctx_notify(tctx, ring, group_level);
 }
 
 /*
-- 
2.50.1



  parent reply	other threads:[~2025-07-21 16:42 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-21 16:21 [PULL 00/50] ppc queue Cédric Le Goater
2025-07-21 16:21 ` [PULL 01/50] ppc/xive: Fix xive trace event output Cédric Le Goater
2025-07-21 16:21 ` [PULL 02/50] ppc/xive: Report access size in XIVE TM operation error logs Cédric Le Goater
2025-07-21 16:21 ` [PULL 03/50] ppc/xive2: Fix calculation of END queue sizes Cédric Le Goater
2025-07-21 16:21 ` [PULL 04/50] ppc/xive2: Remote VSDs need to match on forwarding address Cédric Le Goater
2025-07-21 16:21 ` [PULL 05/50] ppc/xive2: fix context push calculation of IPB priority Cédric Le Goater
2025-07-21 16:21 ` [PULL 06/50] ppc/xive: Fix PHYS NSR ring matching Cédric Le Goater
2025-07-21 16:21 ` [PULL 07/50] ppc/xive2: Reset Generation Flipped bit on END Cache Watch Cédric Le Goater
2025-07-21 16:21 ` [PULL 08/50] ppc/xive2: Use fair irq target search algorithm Cédric Le Goater
2025-07-21 16:21 ` [PULL 09/50] ppc/xive2: Fix irq preempted by lower priority group irq Cédric Le Goater
2025-07-21 16:21 ` [PULL 10/50] ppc/xive2: Fix treatment of PIPR in CPPR update Cédric Le Goater
2025-07-21 16:21 ` [PULL 11/50] ppc/xive2: Do not present group interrupt on OS-push if precluded by CPPR Cédric Le Goater
2025-07-21 16:21 ` [PULL 12/50] ppc/xive2: Set CPPR delivery should account for group priority Cédric Le Goater
2025-07-21 16:21 ` [PULL 13/50] ppc/xive: tctx_notify should clear the precluded interrupt Cédric Le Goater
2025-07-21 16:21 ` [PULL 14/50] ppc/xive: Explicitly zero NSR after accepting Cédric Le Goater
2025-07-21 16:21 ` [PULL 15/50] ppc/xive: Move NSR decoding into helper functions Cédric Le Goater
2025-07-21 16:21 ` [PULL 16/50] ppc/xive: Fix pulling pool and phys contexts Cédric Le Goater
2025-07-21 16:22 ` [PULL 17/50] pnv/xive2: Support ESB Escalation Cédric Le Goater
2025-07-21 16:22 ` [PULL 18/50] pnv/xive2: Print value in invalid register write logging Cédric Le Goater
2025-07-21 16:22 ` [PULL 19/50] pnv/xive2: VC_ENDC_WATCH_SPEC regs should read back WATCH_FULL Cédric Le Goater
2025-07-21 16:22 ` [PULL 20/50] pnv/xive2: Permit valid writes to VC/PC Flush Control registers Cédric Le Goater
2025-07-21 16:22 ` [PULL 21/50] ppc/xive2: add interrupt priority configuration flags Cédric Le Goater
2025-07-21 16:22 ` [PULL 22/50] ppc/xive2: Support redistribution of group interrupts Cédric Le Goater
2025-07-21 16:22 ` [PULL 23/50] ppc/xive: Add more interrupt notification tracing Cédric Le Goater
2025-07-21 16:22 ` [PULL 24/50] ppc/xive2: Improve pool regs variable name Cédric Le Goater
2025-07-21 16:22 ` [PULL 25/50] ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op Cédric Le Goater
2025-07-21 16:22 ` [PULL 26/50] ppc/xive2: Redistribute group interrupt precluded by CPPR update Cédric Le Goater
2025-07-21 16:22 ` [PULL 27/50] ppc/xive2: redistribute irqs for pool and phys ctx pull Cédric Le Goater
2025-07-21 16:22 ` [PULL 28/50] ppc/xive: Change presenter .match_nvt to match not present Cédric Le Goater
2025-07-21 16:22 ` [PULL 29/50] ppc/xive2: Redistribute group interrupt preempted by higher priority interrupt Cédric Le Goater
2025-07-21 16:22 ` [PULL 30/50] ppc/xive: Add xive_tctx_pipr_present() to present new interrupt Cédric Le Goater
2025-07-21 16:22 ` Cédric Le Goater [this message]
2025-07-21 16:22 ` [PULL 32/50] ppc/xive: Split xive recompute from IPB function Cédric Le Goater
2025-07-21 16:22 ` [PULL 33/50] ppc/xive: tctx signaling registers rework Cédric Le Goater
2025-07-21 16:22 ` [PULL 34/50] ppc/xive: tctx_accept only lower irq line if an interrupt was presented Cédric Le Goater
2025-07-21 16:22 ` [PULL 35/50] ppc/xive: Add xive_tctx_pipr_set() helper function Cédric Le Goater
2025-07-21 16:22 ` [PULL 36/50] ppc/xive2: split tctx presentation processing from set CPPR Cédric Le Goater
2025-07-21 16:22 ` [PULL 37/50] ppc/xive2: Consolidate presentation processing in context push Cédric Le Goater
2025-07-21 16:22 ` [PULL 38/50] ppc/xive2: Avoid needless interrupt re-check on CPPR set Cédric Le Goater
2025-07-21 16:22 ` [PULL 39/50] ppc/xive: Assert group interrupts were redistributed Cédric Le Goater
2025-07-21 16:22 ` [PULL 40/50] ppc/xive2: implement NVP context save restore for POOL ring Cédric Le Goater
2025-07-21 16:22 ` [PULL 41/50] ppc/xive2: Prevent pulling of pool context losing phys interrupt Cédric Le Goater
2025-07-21 16:22 ` [PULL 42/50] ppc/xive: Redistribute phys after pulling of pool context Cédric Le Goater
2025-07-21 16:22 ` [PULL 43/50] ppc/xive: Check TIMA operations validity Cédric Le Goater
2025-07-21 16:22 ` [PULL 44/50] ppc/xive2: Implement pool context push TIMA op Cédric Le Goater
2025-07-21 16:22 ` [PULL 45/50] ppc/xive2: redistribute group interrupts on context push Cédric Le Goater
2025-07-21 16:22 ` [PULL 46/50] ppc/xive2: Implement set_os_pending TIMA op Cédric Le Goater
2025-07-21 16:22 ` [PULL 47/50] ppc/xive2: Implement POOL LGS push " Cédric Le Goater
2025-07-21 16:22 ` [PULL 48/50] ppc/xive2: Implement PHYS ring VP " Cédric Le Goater
2025-07-21 16:22 ` [PULL 49/50] ppc/xive: Split need_resend into restore_nvp Cédric Le Goater
2025-07-21 16:22 ` [PULL 50/50] ppc/xive2: Enable lower level contexts on VP push Cédric Le Goater
2025-07-22 11:20 ` [PULL 00/50] ppc queue Stefan Hajnoczi
2025-07-22 11:44 ` Michael Tokarev
2025-07-22 13:37   ` Cédric Le Goater
2025-07-22 14:25     ` Michael Tokarev
2025-08-05 16:26       ` Miles Glenn
2025-08-05 16:33         ` Michael Tokarev
2025-08-05 20:17           ` Cédric Le Goater
2025-08-05 20:07         ` Cédric Le Goater
2025-08-06 20:46           ` Miles Glenn
2025-08-08  6:07             ` Michael Tokarev
2025-08-08  8:17               ` Cédric Le Goater
2025-08-08 16:37                 ` Miles Glenn
2025-08-12 20:38                 ` Mike Kowal
2025-08-19 12:56                 ` Gautam Menghani
2025-09-01  6:23                   ` Cédric Le Goater
2025-08-08 16:17               ` Miles Glenn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250721162233.686837-32-clg@redhat.com \
    --to=clg@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=gautam@linux.ibm.com \
    --cc=kowal@linux.ibm.com \
    --cc=milesg@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).