ppc/xive: updates for PowerVM
PATCH 35/50 ppc/xive: Add xive_tctx_pipr_set() helper function
In reply to Nicholas PigginHave xive_tctx_notify() also set the new PIPR value and rename it to xive_tctx_pipr_set(). This can replace the last xive_tctx_pipr_update() caller because it does not need to update IPB (it already sets it).
--- hw/intc/xive.c | 39 +++++++++++---------------------------- hw/intc/xive2.c | 16 +++++++--------- include/hw/ppc/xive.h | 5 ++--- 3 files changed, 20 insertions(+), 40 deletions(-)
hw/intc/xive.c +11 -28
@@ -125,12 +125,16 @@ uint64_t xive_tctx_accept(XiveTCTX *tctx, uint8_t sig_ring)return ((uint64_t )nsr <<8 ) | sig_regs[TM_CPPR ]; } -void xive_tctx_notify (XiveTCTX *tctx,uint8_t ring,uint8_t group_level) +/* Change PIPR and calculate NSR and irq based on PIPR, CPPR, group */ +void xive_tctx_pipr_set (XiveTCTX *tctx,uint8_t ring,uint8_t pipr, +uint8_t group_level) {uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; -if (sig_regs[TM_PIPR ] < sig_regs[TM_CPPR ]) { + sig_regs[TM_PIPR ] = pipr; + +if (pipr < sig_regs[TM_CPPR ]) {switch (ring) {case TM_QW1_OS : sig_regs[TM_NSR ] =TM_QW1_NSR_EO | (group_level &0x3F );
@@ -145,7 +149,7 @@ void xive_tctx_notify(XiveTCTX *tctx, uint8_t ring, uint8_t group_level)g_assert_not_reached (); }trace_xive_tctx_notify (tctx->cs->cpu_index, ring, - regs[TM_IPB ], sig_regs[TM_PIPR ], + regs[TM_IPB ], pipr, sig_regs[TM_CPPR ], sig_regs[TM_NSR ]);qemu_irq_raise (xive_tctx_output (tctx, ring)); }else {
@@ -213,29 +217,10 @@ static void xive_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr) } } - sig_regs[TM_PIPR ] = pipr_min; - -/* CPPR has changed, check if we need to raise a pending exception */ -xive_tctx_notify (tctx, ring_min,0 ); +/* CPPR has changed, this may present or preclude a pending exception */ +xive_tctx_pipr_set (tctx, ring_min, pipr_min,0 ); } -void xive_tctx_pipr_update (XiveTCTX *tctx,uint8_t ring,uint8_t priority, -uint8_t group_level) -{ -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); -uint8_t *regs = &tctx->regs[ring]; - -if (group_level ==0 ) { -/* VP-specific */ - regs[TM_IPB ] |=xive_priority_to_ipb (priority); - sig_regs[TM_PIPR ] =xive_ipb_to_pipr (regs[TM_IPB ]); - }else { -/* VP-group */ - sig_regs[TM_PIPR ] =xive_priority_to_pipr (priority); - } -xive_tctx_notify (tctx, ring, group_level); - } -static void xive_tctx_pipr_recompute_from_ipb (XiveTCTX *tctx,uint8_t ring) {uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);
@@ -244,8 +229,7 @@ static void xive_tctx_pipr_recompute_from_ipb(XiveTCTX *tctx, uint8_t ring)/* Does not support a presented group interrupt */ g_assert (!xive_nsr_indicates_group_exception (ring, sig_regs[TM_NSR ])); - sig_regs[TM_PIPR ] =xive_ipb_to_pipr (regs[TM_IPB ]); -xive_tctx_notify (tctx, ring,0 ); +xive_tctx_pipr_set (tctx, ring,xive_ipb_to_pipr (regs[TM_IPB ]),0 ); } void xive_tctx_pipr_present(XiveTCTX *tctx, uint8_t ring, uint8_t priority,
@@ -264,8 +248,7 @@ void xive_tctx_pipr_present(XiveTCTX *tctx, uint8_t ring, uint8_t priority, }g_assert (pipr <=xive_ipb_to_pipr (regs[TM_IPB ]));g_assert (pipr < sig_regs[TM_PIPR ]); - sig_regs[TM_PIPR ] = pipr; -xive_tctx_notify (tctx, ring, group_level); +xive_tctx_pipr_set (tctx, ring, pipr, group_level); }/*
hw/intc/xive2.c +7 -9
@@ -966,10 +966,10 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* -* Compute the PIPR based on the restored state. +* Set the PIPR/NSR based on the restored state. * It will raise the External interrupt signal if needed. */ -xive_tctx_pipr_update (tctx,TM_QW1_OS , backlog_prio, backlog_level); +xive_tctx_pipr_set (tctx,TM_QW1_OS , backlog_prio, backlog_level); }/*
@@ -1144,8 +1144,7 @@ static void xive2_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr) }/* interrupt is VP directed, pending in IPB */ - sig_regs[TM_PIPR ] = cppr; -xive_tctx_notify (tctx, ring,0 );/* Ensure interrupt is cleared */ +xive_tctx_pipr_set (tctx, ring, cppr,0 );return ; }else {/* CPPR was lowered, but still above PIPR. No action needed. */
@@ -1255,11 +1254,10 @@ again: pipr_min = backlog_prio; } -/* PIPR should not be set to a value greater than CPPR */ - sig_regs[TM_PIPR ] = (pipr_min > cppr) ? cppr : pipr_min; - -/* CPPR has changed, check if we need to raise a pending exception */ -xive_tctx_notify (tctx, ring_min, group_level); +if (pipr_min > cppr) { + pipr_min = cppr; + } +xive_tctx_pipr_set (tctx, ring_min, pipr_min, group_level); } void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx,
include/hw/ppc/xive.h +2 -3
@@ -584,12 +584,11 @@ void xive_tctx_pic_print_info(XiveTCTX *tctx, GString *buf);Object *xive_tctx_create (Object *cpu,XivePresenter *xptr,Error **errp);void xive_tctx_reset (XiveTCTX *tctx);void xive_tctx_destroy (XiveTCTX *tctx); -void xive_tctx_pipr_update (XiveTCTX *tctx,uint8_t ring,uint8_t priority, -uint8_t group_level); +void xive_tctx_pipr_set (XiveTCTX *tctx,uint8_t ring,uint8_t priority, +uint8_t group_level);void xive_tctx_pipr_present (XiveTCTX *tctx,uint8_t ring,uint8_t priority,uint8_t group_level);void xive_tctx_reset_signal (XiveTCTX *tctx,uint8_t ring); -void xive_tctx_notify (XiveTCTX *tctx,uint8_t ring,uint8_t group_level);uint64_t xive_tctx_accept (XiveTCTX *tctx,uint8_t ring);/*
Signature · 1 line
2.47.1
Re: [PATCH 35/50] ppc/xive: Add xive_tctx_pipr_set() helper function
Quoted 3 lines · Nicholas Piggin
Have
xive_tctx_notify()also set the new PIPR value and rename it toxive_tctx_pipr_set(). This can replace the lastxive_tctx_pipr_update()caller because it does not need to update IPB (it already sets it).
Thanks, MAK
Quoted 154 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 39 +++++++++++---------------------------- hw/intc/xive2.c | 16 +++++++--------- include/hw/ppc/xive.h | 5 ++--- 3 files changed, 20 insertions(+), 40 deletions(-)hw/intc/xive.c +11
-28@@ -125,12 +125,16 @@ uint64_t xive_tctx_accept(XiveTCTX *tctx, uint8_t sig_ring)return ((uint64_t )nsr <<8 ) | sig_regs[TM_CPPR ]; } -void xive_tctx_notify (XiveTCTX *tctx,uint8_t ring,uint8_t group_level) +/* Change PIPR and calculate NSR and irq based on PIPR, CPPR, group */ +void xive_tctx_pipr_set (XiveTCTX *tctx,uint8_t ring,uint8_t pipr, +uint8_t group_level) {uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; -if (sig_regs[TM_PIPR ] < sig_regs[TM_CPPR ]) { + sig_regs[TM_PIPR ] = pipr; + +if (pipr < sig_regs[TM_CPPR ]) {switch (ring) {case TM_QW1_OS : sig_regs[TM_NSR ] =TM_QW1_NSR_EO | (group_level &0x3F );@@ -145,7 +149,7 @@ void xive_tctx_notify(XiveTCTX *tctx, uint8_t ring, uint8_t group_level)g_assert_not_reached (); }trace_xive_tctx_notify (tctx->cs->cpu_index, ring, - regs[TM_IPB ], sig_regs[TM_PIPR ], + regs[TM_IPB ], pipr, sig_regs[TM_CPPR ], sig_regs[TM_NSR ]);qemu_irq_raise (xive_tctx_output (tctx, ring)); }else {@@ -213,29 +217,10 @@ static void xive_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr) } } - sig_regs[TM_PIPR ] = pipr_min; - -/* CPPR has changed, check if we need to raise a pending exception */ -xive_tctx_notify (tctx, ring_min,0 ); +/* CPPR has changed, this may present or preclude a pending exception */ +xive_tctx_pipr_set (tctx, ring_min, pipr_min,0 ); } -void xive_tctx_pipr_update (XiveTCTX *tctx,uint8_t ring,uint8_t priority, -uint8_t group_level) -{ -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); -uint8_t *regs = &tctx->regs[ring]; - -if (group_level ==0 ) { -/* VP-specific */ - regs[TM_IPB ] |=xive_priority_to_ipb (priority); - sig_regs[TM_PIPR ] =xive_ipb_to_pipr (regs[TM_IPB ]); - }else { -/* VP-group */ - sig_regs[TM_PIPR ] =xive_priority_to_pipr (priority); - } -xive_tctx_notify (tctx, ring, group_level); - } -static void xive_tctx_pipr_recompute_from_ipb (XiveTCTX *tctx,uint8_t ring) {uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);@@ -244,8 +229,7 @@ static void xive_tctx_pipr_recompute_from_ipb(XiveTCTX *tctx, uint8_t ring)/* Does not support a presented group interrupt */ g_assert (!xive_nsr_indicates_group_exception (ring, sig_regs[TM_NSR ])); - sig_regs[TM_PIPR ] =xive_ipb_to_pipr (regs[TM_IPB ]); -xive_tctx_notify (tctx, ring,0 ); +xive_tctx_pipr_set (tctx, ring,xive_ipb_to_pipr (regs[TM_IPB ]),0 ); } void xive_tctx_pipr_present(XiveTCTX *tctx, uint8_t ring, uint8_t priority,@@ -264,8 +248,7 @@ void xive_tctx_pipr_present(XiveTCTX *tctx, uint8_t ring, uint8_t priority, }g_assert (pipr <=xive_ipb_to_pipr (regs[TM_IPB ]));g_assert (pipr < sig_regs[TM_PIPR ]); - sig_regs[TM_PIPR ] = pipr; -xive_tctx_notify (tctx, ring, group_level); +xive_tctx_pipr_set (tctx, ring, pipr, group_level); }/* hw/intc/xive2.c +7
-9@@ -966,10 +966,10 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* -* Compute the PIPR based on the restored state. +* Set the PIPR/NSR based on the restored state. * It will raise the External interrupt signal if needed. */ -xive_tctx_pipr_update (tctx,TM_QW1_OS , backlog_prio, backlog_level); +xive_tctx_pipr_set (tctx,TM_QW1_OS , backlog_prio, backlog_level); }/* @@ -1144,8 +1144,7 @@ static void xive2_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr) }/* interrupt is VP directed, pending in IPB */ - sig_regs[TM_PIPR ] = cppr; -xive_tctx_notify (tctx, ring,0 );/* Ensure interrupt is cleared */ +xive_tctx_pipr_set (tctx, ring, cppr,0 );return ; }else {/* CPPR was lowered, but still above PIPR. No action needed. */ @@ -1255,11 +1254,10 @@ again: pipr_min = backlog_prio; } -/* PIPR should not be set to a value greater than CPPR */ - sig_regs[TM_PIPR ] = (pipr_min > cppr) ? cppr : pipr_min; - -/* CPPR has changed, check if we need to raise a pending exception */ -xive_tctx_notify (tctx, ring_min, group_level); +if (pipr_min > cppr) { + pipr_min = cppr; + } +xive_tctx_pipr_set (tctx, ring_min, pipr_min, group_level); } void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx,include/hw/ppc/xive.h +2
-3@@ -584,12 +584,11 @@ void xive_tctx_pic_print_info(XiveTCTX *tctx, GString *buf);Object *xive_tctx_create (Object *cpu,XivePresenter *xptr,Error **errp);void xive_tctx_reset (XiveTCTX *tctx);void xive_tctx_destroy (XiveTCTX *tctx); -void xive_tctx_pipr_update (XiveTCTX *tctx,uint8_t ring,uint8_t priority, -uint8_t group_level); +void xive_tctx_pipr_set (XiveTCTX *tctx,uint8_t ring,uint8_t priority, +uint8_t group_level);void xive_tctx_pipr_present (XiveTCTX *tctx,uint8_t ring,uint8_t priority,uint8_t group_level);void xive_tctx_reset_signal (XiveTCTX *tctx,uint8_t ring); -void xive_tctx_notify (XiveTCTX *tctx,uint8_t ring,uint8_t group_level);uint64_t xive_tctx_accept (XiveTCTX *tctx,uint8_t ring);/*
Re: [PATCH 35/50] ppc/xive: Add xive_tctx_pipr_set() helper function
In reply to Nicholas PigginQuoted 157 lines · Nicholas Piggin
Have
xive_tctx_notify()also set the new PIPR value and rename it toxive_tctx_pipr_set(). This can replace the lastxive_tctx_pipr_update()caller because it does not need to update IPB (it already sets it).Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 39 +++++++++++---------------------------- hw/intc/xive2.c | 16 +++++++--------- include/hw/ppc/xive.h | 5 ++--- 3 files changed, 20 insertions(+), 40 deletions(-)hw/intc/xive.c +11
-28@@ -125,12 +125,16 @@ uint64_t xive_tctx_accept(XiveTCTX *tctx, uint8_t sig_ring)return ((uint64_t )nsr <<8 ) | sig_regs[TM_CPPR ]; } -void xive_tctx_notify (XiveTCTX *tctx,uint8_t ring,uint8_t group_level) +/* Change PIPR and calculate NSR and irq based on PIPR, CPPR, group */ +void xive_tctx_pipr_set (XiveTCTX *tctx,uint8_t ring,uint8_t pipr, +uint8_t group_level) {uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; -if (sig_regs[TM_PIPR ] < sig_regs[TM_CPPR ]) { + sig_regs[TM_PIPR ] = pipr; + +if (pipr < sig_regs[TM_CPPR ]) {switch (ring) {case TM_QW1_OS : sig_regs[TM_NSR ] =TM_QW1_NSR_EO | (group_level &0x3F );@@ -145,7 +149,7 @@ void xive_tctx_notify(XiveTCTX *tctx, uint8_t ring, uint8_t group_level)g_assert_not_reached (); }trace_xive_tctx_notify (tctx->cs->cpu_index, ring, - regs[TM_IPB ], sig_regs[TM_PIPR ], + regs[TM_IPB ], pipr, sig_regs[TM_CPPR ], sig_regs[TM_NSR ]);qemu_irq_raise (xive_tctx_output (tctx, ring)); }else {@@ -213,29 +217,10 @@ static void xive_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr) } } - sig_regs[TM_PIPR ] = pipr_min; - -/* CPPR has changed, check if we need to raise a pending exception */ -xive_tctx_notify (tctx, ring_min,0 ); +/* CPPR has changed, this may present or preclude a pending exception */ +xive_tctx_pipr_set (tctx, ring_min, pipr_min,0 ); } -void xive_tctx_pipr_update (XiveTCTX *tctx,uint8_t ring,uint8_t priority, -uint8_t group_level) -{ -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); -uint8_t *regs = &tctx->regs[ring]; - -if (group_level ==0 ) { -/* VP-specific */ - regs[TM_IPB ] |=xive_priority_to_ipb (priority); - sig_regs[TM_PIPR ] =xive_ipb_to_pipr (regs[TM_IPB ]); - }else { -/* VP-group */ - sig_regs[TM_PIPR ] =xive_priority_to_pipr (priority); - } -xive_tctx_notify (tctx, ring, group_level); - } -static void xive_tctx_pipr_recompute_from_ipb (XiveTCTX *tctx,uint8_t ring) {uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);@@ -244,8 +229,7 @@ static void xive_tctx_pipr_recompute_from_ipb(XiveTCTX *tctx, uint8_t ring)/* Does not support a presented group interrupt */ g_assert (!xive_nsr_indicates_group_exception (ring, sig_regs[TM_NSR ])); - sig_regs[TM_PIPR ] =xive_ipb_to_pipr (regs[TM_IPB ]); -xive_tctx_notify (tctx, ring,0 ); +xive_tctx_pipr_set (tctx, ring,xive_ipb_to_pipr (regs[TM_IPB ]),0 ); } void xive_tctx_pipr_present(XiveTCTX *tctx, uint8_t ring, uint8_t priority,@@ -264,8 +248,7 @@ void xive_tctx_pipr_present(XiveTCTX *tctx, uint8_t ring, uint8_t priority, }g_assert (pipr <=xive_ipb_to_pipr (regs[TM_IPB ]));g_assert (pipr < sig_regs[TM_PIPR ]); - sig_regs[TM_PIPR ] = pipr; -xive_tctx_notify (tctx, ring, group_level); +xive_tctx_pipr_set (tctx, ring, pipr, group_level); }/* hw/intc/xive2.c +7
-9@@ -966,10 +966,10 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* -* Compute the PIPR based on the restored state. +* Set the PIPR/NSR based on the restored state. * It will raise the External interrupt signal if needed. */ -xive_tctx_pipr_update (tctx,TM_QW1_OS , backlog_prio, backlog_level); +xive_tctx_pipr_set (tctx,TM_QW1_OS , backlog_prio, backlog_level); }/* @@ -1144,8 +1144,7 @@ static void xive2_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr) }/* interrupt is VP directed, pending in IPB */ - sig_regs[TM_PIPR ] = cppr; -xive_tctx_notify (tctx, ring,0 );/* Ensure interrupt is cleared */ +xive_tctx_pipr_set (tctx, ring, cppr,0 );return ; }else {/* CPPR was lowered, but still above PIPR. No action needed. */ @@ -1255,11 +1254,10 @@ again: pipr_min = backlog_prio; } -/* PIPR should not be set to a value greater than CPPR */ - sig_regs[TM_PIPR ] = (pipr_min > cppr) ? cppr : pipr_min; - -/* CPPR has changed, check if we need to raise a pending exception */ -xive_tctx_notify (tctx, ring_min, group_level); +if (pipr_min > cppr) { + pipr_min = cppr; + } +xive_tctx_pipr_set (tctx, ring_min, pipr_min, group_level); } void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx,include/hw/ppc/xive.h +2
-3@@ -584,12 +584,11 @@ void xive_tctx_pic_print_info(XiveTCTX *tctx, GString *buf);Object *xive_tctx_create (Object *cpu,XivePresenter *xptr,Error **errp);void xive_tctx_reset (XiveTCTX *tctx);void xive_tctx_destroy (XiveTCTX *tctx); -void xive_tctx_pipr_update (XiveTCTX *tctx,uint8_t ring,uint8_t priority, -uint8_t group_level); +void xive_tctx_pipr_set (XiveTCTX *tctx,uint8_t ring,uint8_t priority, +uint8_t group_level);void xive_tctx_pipr_present (XiveTCTX *tctx,uint8_t ring,uint8_t priority,uint8_t group_level);void xive_tctx_reset_signal (XiveTCTX *tctx,uint8_t ring); -void xive_tctx_notify (XiveTCTX *tctx,uint8_t ring,uint8_t group_level);uint64_t xive_tctx_accept (XiveTCTX *tctx,uint8_t ring);/*
PATCH 36/50 ppc/xive2: split tctx presentation processing from set CPPR
In reply to Nicholas PigginThe second part of the set CPPR operation is to process (or re-present) any pending interrupts after CPPR is adjusted.
Split this presentation processing out into a standalone function that can be used in other places.
--- hw/intc/xive2.c | 137 +++++++++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 61 deletions(-)
hw/intc/xive2.c +76 -61
@@ -1098,66 +1098,19 @@ void xive2_tm_ack_os_el(XivePresenter *xptr, XiveTCTX *tctx,xive2_tctx_accept_el (xptr, tctx,TM_QW1_OS ,TM_QW1_OS ); } -/* NOTE: CPPR only exists for TM_QW1_OS and TM_QW3_HV_PHYS */ -static void xive2_tctx_set_cppr (XiveTCTX *tctx,uint8_t ring,uint8_t cppr) +/* Re-calculate and present pending interrupts */ +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring) { -uint8_t *sig_regs = &tctx->regs[ring]; +uint8_t *sig_regs = &tctx->regs[sig_ring];Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); -uint8_t old_cppr, backlog_prio, first_group, group_level; +uint8_t backlog_prio, first_group, group_level;uint8_t pipr_min, lsmfb_min, ring_min; +uint8_t cppr = sig_regs[TM_CPPR ];bool group_enabled; -uint8_t nvp_blk; -uint32_t nvp_idx;Xive2Nvp nvp;int rc; -uint8_t nsr = sig_regs[TM_NSR ]; - -g_assert (ring ==TM_QW1_OS || ring ==TM_QW3_HV_PHYS ); - -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_NSR ] ==0 ); -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_PIPR ] ==0 ); -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_CPPR ] ==0 ); - -/* XXX: should show pool IPB for PHYS ring */ -trace_xive_tctx_set_cppr (tctx->cs->cpu_index, ring, - sig_regs[TM_IPB ], sig_regs[TM_PIPR ], - cppr, nsr); - -if (cppr >XIVE_PRIORITY_MAX ) { - cppr =0xff ; - } - - old_cppr = sig_regs[TM_CPPR ]; - sig_regs[TM_CPPR ] = cppr; - -/* Handle increased CPPR priority (lower value) */ -if (cppr < old_cppr) { -if (cppr <= sig_regs[TM_PIPR ]) { -/* CPPR lowered below PIPR, must un-present interrupt */ -if (xive_nsr_indicates_exception (ring, nsr)) { -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -xive2_redistribute (xrtr, tctx, -xive_nsr_exception_ring (ring, nsr)); -return ; - } - } -/* interrupt is VP directed, pending in IPB */ -xive_tctx_pipr_set (tctx, ring, cppr,0 ); -return ; - }else { -/* CPPR was lowered, but still above PIPR. No action needed. */ -return ; - } - } - -/* CPPR didn't change, nothing needs to be done */ -if (cppr == old_cppr) { -return ; - } - -/* CPPR priority decreased (higher value) */ +g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS );/* * Recompute the PIPR based on local pending interrupts. It will
@@ -1167,11 +1120,11 @@ again: pipr_min =xive_ipb_to_pipr (sig_regs[TM_IPB ]); group_enabled = !!sig_regs[TM_LGS ]; lsmfb_min = group_enabled ? sig_regs[TM_LSMFB ] :0xff ; - ring_min = ring; + ring_min = sig_ring; group_level =0 ;/* PHYS updates also depend on POOL values */ -if (ring ==TM_QW3_HV_PHYS ) { +if (sig_ring ==TM_QW3_HV_PHYS ) {uint8_t *pool_regs = &tctx->regs[TM_QW2_HV_POOL ];/* POOL values only matter if POOL ctx is valid */
@@ -1201,20 +1154,25 @@ again: } } - rc =xive2_tctx_get_nvp_indexes (tctx, ring_min, &nvp_blk, &nvp_idx); -if (rc) { -qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: set CPPR on invalid context\n" ); -return ; - } -if (group_enabled && lsmfb_min < cppr && lsmfb_min < pipr_min) { + +uint8_t nvp_blk; +uint32_t nvp_idx; +/* * Thread has seen a group interrupt with a higher priority * than the new cppr or pending local interrupt. Check the * backlog */ + rc =xive2_tctx_get_nvp_indexes (tctx, ring_min, &nvp_blk, &nvp_idx); +if (rc) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: set CPPR on invalid " +"context\n" ); +return ; + } +if (xive2_router_get_nvp (xrtr, nvp_blk, nvp_idx, &nvp)) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: No NVP %x/%x\n" , nvp_blk, nvp_idx);
@@ -1260,6 +1218,63 @@ again:xive_tctx_pipr_set (tctx, ring_min, pipr_min, group_level); } +/* NOTE: CPPR only exists for TM_QW1_OS and TM_QW3_HV_PHYS */ +static void xive2_tctx_set_cppr (XiveTCTX *tctx,uint8_t sig_ring,uint8_t cppr) +{ +uint8_t *sig_regs = &tctx->regs[sig_ring]; +Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); +uint8_t old_cppr; +uint8_t nsr = sig_regs[TM_NSR ]; + +g_assert (sig_ring ==TM_QW1_OS || sig_ring ==TM_QW3_HV_PHYS ); + +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_NSR ] ==0 ); +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_PIPR ] ==0 ); +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_CPPR ] ==0 ); + +/* XXX: should show pool IPB for PHYS ring */ +trace_xive_tctx_set_cppr (tctx->cs->cpu_index, sig_ring, + sig_regs[TM_IPB ], sig_regs[TM_PIPR ], + cppr, nsr); + +if (cppr >XIVE_PRIORITY_MAX ) { + cppr =0xff ; + } + + old_cppr = sig_regs[TM_CPPR ]; + sig_regs[TM_CPPR ] = cppr; + +/* Handle increased CPPR priority (lower value) */ +if (cppr < old_cppr) { +if (cppr <= sig_regs[TM_PIPR ]) { +/* CPPR lowered below PIPR, must un-present interrupt */ +if (xive_nsr_indicates_exception (sig_ring, nsr)) { +if (xive_nsr_indicates_group_exception (sig_ring, nsr)) { +/* redistribute precluded active grp interrupt */ +xive2_redistribute (xrtr, tctx, +xive_nsr_exception_ring (sig_ring, nsr)); +return ; + } + } + +/* interrupt is VP directed, pending in IPB */ +xive_tctx_pipr_set (tctx, sig_ring, cppr,0 ); +return ; + }else { +/* CPPR was lowered, but still above PIPR. No action needed. */ +return ; + } + } + +/* CPPR didn't change, nothing needs to be done */ +if (cppr == old_cppr) { +return ; + } + +/* CPPR priority decreased (higher value) */ +xive2_tctx_process_pending (tctx, sig_ring); +} +void xive2_tm_set_hv_cppr (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size) {
Signature · 1 line
2.47.1
Re: [PATCH 36/50] ppc/xive2: split tctx presentation processing from set CPPR
Quoted 5 lines · Nicholas Piggin
The second part of the set CPPR operation is to process (or re-present) any pending interrupts after CPPR is adjusted.
Split this presentation processing out into a standalone function that can be used in other places.
Thanks, MAK
Quoted 193 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 137 +++++++++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 61 deletions(-)hw/intc/xive2.c +76
-61@@ -1098,66 +1098,19 @@ void xive2_tm_ack_os_el(XivePresenter *xptr, XiveTCTX *tctx,xive2_tctx_accept_el (xptr, tctx,TM_QW1_OS ,TM_QW1_OS ); } -/* NOTE: CPPR only exists for TM_QW1_OS and TM_QW3_HV_PHYS */ -static void xive2_tctx_set_cppr (XiveTCTX *tctx,uint8_t ring,uint8_t cppr) +/* Re-calculate and present pending interrupts */ +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring) { -uint8_t *sig_regs = &tctx->regs[ring]; +uint8_t *sig_regs = &tctx->regs[sig_ring];Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); -uint8_t old_cppr, backlog_prio, first_group, group_level; +uint8_t backlog_prio, first_group, group_level;uint8_t pipr_min, lsmfb_min, ring_min; +uint8_t cppr = sig_regs[TM_CPPR ];bool group_enabled; -uint8_t nvp_blk; -uint32_t nvp_idx;Xive2Nvp nvp;int rc; -uint8_t nsr = sig_regs[TM_NSR ]; - -g_assert (ring ==TM_QW1_OS || ring ==TM_QW3_HV_PHYS ); - -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_NSR ] ==0 ); -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_PIPR ] ==0 ); -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_CPPR ] ==0 ); - -/* XXX: should show pool IPB for PHYS ring */ -trace_xive_tctx_set_cppr (tctx->cs->cpu_index, ring, - sig_regs[TM_IPB ], sig_regs[TM_PIPR ], - cppr, nsr); - -if (cppr >XIVE_PRIORITY_MAX ) { - cppr =0xff ; - } - - old_cppr = sig_regs[TM_CPPR ]; - sig_regs[TM_CPPR ] = cppr; - -/* Handle increased CPPR priority (lower value) */ -if (cppr < old_cppr) { -if (cppr <= sig_regs[TM_PIPR ]) { -/* CPPR lowered below PIPR, must un-present interrupt */ -if (xive_nsr_indicates_exception (ring, nsr)) { -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -xive2_redistribute (xrtr, tctx, -xive_nsr_exception_ring (ring, nsr)); -return ; - } - } -/* interrupt is VP directed, pending in IPB */ -xive_tctx_pipr_set (tctx, ring, cppr,0 ); -return ; - }else { -/* CPPR was lowered, but still above PIPR. No action needed. */ -return ; - } - } - -/* CPPR didn't change, nothing needs to be done */ -if (cppr == old_cppr) { -return ; - } - -/* CPPR priority decreased (higher value) */ +g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS );/* * Recompute the PIPR based on local pending interrupts. It will @@ -1167,11 +1120,11 @@ again: pipr_min =xive_ipb_to_pipr (sig_regs[TM_IPB ]); group_enabled = !!sig_regs[TM_LGS ]; lsmfb_min = group_enabled ? sig_regs[TM_LSMFB ] :0xff ; - ring_min = ring; + ring_min = sig_ring; group_level =0 ;/* PHYS updates also depend on POOL values */ -if (ring ==TM_QW3_HV_PHYS ) { +if (sig_ring ==TM_QW3_HV_PHYS ) {uint8_t *pool_regs = &tctx->regs[TM_QW2_HV_POOL ];/* POOL values only matter if POOL ctx is valid */ @@ -1201,20 +1154,25 @@ again: } } - rc =xive2_tctx_get_nvp_indexes (tctx, ring_min, &nvp_blk, &nvp_idx); -if (rc) { -qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: set CPPR on invalid context\n" ); -return ; - } -if (group_enabled && lsmfb_min < cppr && lsmfb_min < pipr_min) { + +uint8_t nvp_blk; +uint32_t nvp_idx; +/* * Thread has seen a group interrupt with a higher priority * than the new cppr or pending local interrupt. Check the * backlog */ + rc =xive2_tctx_get_nvp_indexes (tctx, ring_min, &nvp_blk, &nvp_idx); +if (rc) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: set CPPR on invalid " +"context\n" ); +return ; + } +if (xive2_router_get_nvp (xrtr, nvp_blk, nvp_idx, &nvp)) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: No NVP %x/%x\n" , nvp_blk, nvp_idx);@@ -1260,6 +1218,63 @@ again:xive_tctx_pipr_set (tctx, ring_min, pipr_min, group_level); } +/* NOTE: CPPR only exists for TM_QW1_OS and TM_QW3_HV_PHYS */ +static void xive2_tctx_set_cppr (XiveTCTX *tctx,uint8_t sig_ring,uint8_t cppr) +{ +uint8_t *sig_regs = &tctx->regs[sig_ring]; +Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); +uint8_t old_cppr; +uint8_t nsr = sig_regs[TM_NSR ]; + +g_assert (sig_ring ==TM_QW1_OS || sig_ring ==TM_QW3_HV_PHYS ); + +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_NSR ] ==0 ); +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_PIPR ] ==0 ); +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_CPPR ] ==0 ); + +/* XXX: should show pool IPB for PHYS ring */ +trace_xive_tctx_set_cppr (tctx->cs->cpu_index, sig_ring, + sig_regs[TM_IPB ], sig_regs[TM_PIPR ], + cppr, nsr); + +if (cppr >XIVE_PRIORITY_MAX ) { + cppr =0xff ; + } + + old_cppr = sig_regs[TM_CPPR ]; + sig_regs[TM_CPPR ] = cppr; + +/* Handle increased CPPR priority (lower value) */ +if (cppr < old_cppr) { +if (cppr <= sig_regs[TM_PIPR ]) { +/* CPPR lowered below PIPR, must un-present interrupt */ +if (xive_nsr_indicates_exception (sig_ring, nsr)) { +if (xive_nsr_indicates_group_exception (sig_ring, nsr)) { +/* redistribute precluded active grp interrupt */ +xive2_redistribute (xrtr, tctx, +xive_nsr_exception_ring (sig_ring, nsr)); +return ; + } + } + +/* interrupt is VP directed, pending in IPB */ +xive_tctx_pipr_set (tctx, sig_ring, cppr,0 ); +return ; + }else { +/* CPPR was lowered, but still above PIPR. No action needed. */ +return ; + } + } + +/* CPPR didn't change, nothing needs to be done */ +if (cppr == old_cppr) { +return ; + } + +/* CPPR priority decreased (higher value) */ +xive2_tctx_process_pending (tctx, sig_ring); +} +void xive2_tm_set_hv_cppr (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size) {
Re: [PATCH 36/50] ppc/xive2: split tctx presentation processing from set CPPR
In reply to Nicholas PigginQuoted 198 lines · Nicholas Piggin
The second part of the set CPPR operation is to process (or re-present) any pending interrupts after CPPR is adjusted.
Split this presentation processing out into a standalone function that can be used in other places.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 137 +++++++++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 61 deletions(-)hw/intc/xive2.c +76
-61@@ -1098,66 +1098,19 @@ void xive2_tm_ack_os_el(XivePresenter *xptr, XiveTCTX *tctx,xive2_tctx_accept_el (xptr, tctx,TM_QW1_OS ,TM_QW1_OS ); } -/* NOTE: CPPR only exists for TM_QW1_OS and TM_QW3_HV_PHYS */ -static void xive2_tctx_set_cppr (XiveTCTX *tctx,uint8_t ring,uint8_t cppr) +/* Re-calculate and present pending interrupts */ +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring) { -uint8_t *sig_regs = &tctx->regs[ring]; +uint8_t *sig_regs = &tctx->regs[sig_ring];Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); -uint8_t old_cppr, backlog_prio, first_group, group_level; +uint8_t backlog_prio, first_group, group_level;uint8_t pipr_min, lsmfb_min, ring_min; +uint8_t cppr = sig_regs[TM_CPPR ];bool group_enabled; -uint8_t nvp_blk; -uint32_t nvp_idx;Xive2Nvp nvp;int rc; -uint8_t nsr = sig_regs[TM_NSR ]; - -g_assert (ring ==TM_QW1_OS || ring ==TM_QW3_HV_PHYS ); - -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_NSR ] ==0 ); -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_PIPR ] ==0 ); -g_assert (tctx->regs[TM_QW2_HV_POOL +TM_CPPR ] ==0 ); - -/* XXX: should show pool IPB for PHYS ring */ -trace_xive_tctx_set_cppr (tctx->cs->cpu_index, ring, - sig_regs[TM_IPB ], sig_regs[TM_PIPR ], - cppr, nsr); - -if (cppr >XIVE_PRIORITY_MAX ) { - cppr =0xff ; - } - - old_cppr = sig_regs[TM_CPPR ]; - sig_regs[TM_CPPR ] = cppr; - -/* Handle increased CPPR priority (lower value) */ -if (cppr < old_cppr) { -if (cppr <= sig_regs[TM_PIPR ]) { -/* CPPR lowered below PIPR, must un-present interrupt */ -if (xive_nsr_indicates_exception (ring, nsr)) { -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -xive2_redistribute (xrtr, tctx, -xive_nsr_exception_ring (ring, nsr)); -return ; - } - } -/* interrupt is VP directed, pending in IPB */ -xive_tctx_pipr_set (tctx, ring, cppr,0 ); -return ; - }else { -/* CPPR was lowered, but still above PIPR. No action needed. */ -return ; - } - } - -/* CPPR didn't change, nothing needs to be done */ -if (cppr == old_cppr) { -return ; - } - -/* CPPR priority decreased (higher value) */ +g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS );/* * Recompute the PIPR based on local pending interrupts. It will @@ -1167,11 +1120,11 @@ again: pipr_min =xive_ipb_to_pipr (sig_regs[TM_IPB ]); group_enabled = !!sig_regs[TM_LGS ]; lsmfb_min = group_enabled ? sig_regs[TM_LSMFB ] :0xff ; - ring_min = ring; + ring_min = sig_ring; group_level =0 ;/* PHYS updates also depend on POOL values */ -if (ring ==TM_QW3_HV_PHYS ) { +if (sig_ring ==TM_QW3_HV_PHYS ) {uint8_t *pool_regs = &tctx->regs[TM_QW2_HV_POOL ];/* POOL values only matter if POOL ctx is valid */ @@ -1201,20 +1154,25 @@ again: } } - rc =xive2_tctx_get_nvp_indexes (tctx, ring_min, &nvp_blk, &nvp_idx); -if (rc) { -qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: set CPPR on invalid context\n" ); -return ; - } -if (group_enabled && lsmfb_min < cppr && lsmfb_min < pipr_min) { + +uint8_t nvp_blk; +uint32_t nvp_idx; +/* * Thread has seen a group interrupt with a higher priority * than the new cppr or pending local interrupt. Check the * backlog */ + rc =xive2_tctx_get_nvp_indexes (tctx, ring_min, &nvp_blk, &nvp_idx); +if (rc) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: set CPPR on invalid " +"context\n" ); +return ; + } +if (xive2_router_get_nvp (xrtr, nvp_blk, nvp_idx, &nvp)) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: No NVP %x/%x\n" , nvp_blk, nvp_idx);@@ -1260,6 +1218,63 @@ again:xive_tctx_pipr_set (tctx, ring_min, pipr_min, group_level); } +/* NOTE: CPPR only exists for TM_QW1_OS and TM_QW3_HV_PHYS */ +static void xive2_tctx_set_cppr (XiveTCTX *tctx,uint8_t sig_ring,uint8_t cppr) +{ +uint8_t *sig_regs = &tctx->regs[sig_ring]; +Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); +uint8_t old_cppr; +uint8_t nsr = sig_regs[TM_NSR ]; + +g_assert (sig_ring ==TM_QW1_OS || sig_ring ==TM_QW3_HV_PHYS ); + +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_NSR ] ==0 ); +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_PIPR ] ==0 ); +g_assert (tctx->regs[TM_QW2_HV_POOL +TM_CPPR ] ==0 ); + +/* XXX: should show pool IPB for PHYS ring */ +trace_xive_tctx_set_cppr (tctx->cs->cpu_index, sig_ring, + sig_regs[TM_IPB ], sig_regs[TM_PIPR ], + cppr, nsr); + +if (cppr >XIVE_PRIORITY_MAX ) { + cppr =0xff ; + } + + old_cppr = sig_regs[TM_CPPR ]; + sig_regs[TM_CPPR ] = cppr; + +/* Handle increased CPPR priority (lower value) */ +if (cppr < old_cppr) { +if (cppr <= sig_regs[TM_PIPR ]) { +/* CPPR lowered below PIPR, must un-present interrupt */ +if (xive_nsr_indicates_exception (sig_ring, nsr)) { +if (xive_nsr_indicates_group_exception (sig_ring, nsr)) { +/* redistribute precluded active grp interrupt */ +xive2_redistribute (xrtr, tctx, +xive_nsr_exception_ring (sig_ring, nsr)); +return ; + } + } + +/* interrupt is VP directed, pending in IPB */ +xive_tctx_pipr_set (tctx, sig_ring, cppr,0 ); +return ; + }else { +/* CPPR was lowered, but still above PIPR. No action needed. */ +return ; + } + } + +/* CPPR didn't change, nothing needs to be done */ +if (cppr == old_cppr) { +return ; + } + +/* CPPR priority decreased (higher value) */ +xive2_tctx_process_pending (tctx, sig_ring); +} +void xive2_tm_set_hv_cppr (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size) {
PATCH 37/50 ppc/xive2: Consolidate presentation processing in context push
In reply to Nicholas PigginOS-push operation must re-present pending interrupts. Use the newly created xive2_tctx_process_pending() function instead of duplicating the logic.
--- hw/intc/xive2.c | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-)
hw/intc/xive2.c +10 -32
@@ -903,18 +903,14 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); +static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -XivePresenter *xptr =XIVE_PRESENTER (xrtr); -uint8_t ipb; -uint8_t backlog_level; -uint8_t group_level; -uint8_t first_group; -uint8_t backlog_prio; -uint8_t group_prio;uint8_t *regs = &tctx->regs[TM_QW1_OS ]; +uint8_t ipb;Xive2Nvp nvp;/*
@@ -946,30 +942,8 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; - backlog_prio =xive_ipb_to_pipr (regs[TM_IPB ]); - backlog_level =0 ; - - first_group =xive_get_field32 (NVP2_W0_PGOFIRST , nvp.w0); -if (first_group && regs[TM_LSMFB ] < backlog_prio) { - group_prio =xive2_presenter_backlog_scan (xptr, nvp_blk, nvp_idx, - first_group, &group_level); - regs[TM_LSMFB ] = group_prio; -if (regs[TM_LGS ] && group_prio < backlog_prio && - group_prio < regs[TM_CPPR ]) { - -/* VP can take a group interrupt */ -xive2_presenter_backlog_decr (xptr, nvp_blk, nvp_idx, - group_prio, group_level); - backlog_prio = group_prio; - backlog_level = group_level; - } - } -/* -* Set the PIPR/NSR based on the restored state. -* It will raise the External interrupt signal if needed. -*/ -xive_tctx_pipr_set (tctx,TM_QW1_OS , backlog_prio, backlog_level); +xive2_tctx_process_pending (tctx,TM_QW1_OS ); }/*
@@ -1103,8 +1077,12 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring) {uint8_t *sig_regs = &tctx->regs[sig_ring];Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); -uint8_t backlog_prio, first_group, group_level; -uint8_t pipr_min, lsmfb_min, ring_min; +uint8_t backlog_prio; +uint8_t first_group; +uint8_t group_level; +uint8_t pipr_min; +uint8_t lsmfb_min; +uint8_t ring_min;uint8_t cppr = sig_regs[TM_CPPR ];bool group_enabled;Xive2Nvp nvp;
Signature · 1 line
2.47.1
Re: [PATCH 37/50] ppc/xive2: Consolidate presentation processing in context push
Quoted 3 lines · Nicholas Piggin
OS-push operation must re-present pending interrupts. Use the newly created
xive2_tctx_process_pending()function instead of duplicating the logic.
Thanks, MAK
Quoted 79 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-)hw/intc/xive2.c +10
-32@@ -903,18 +903,14 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); +static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -XivePresenter *xptr =XIVE_PRESENTER (xrtr); -uint8_t ipb; -uint8_t backlog_level; -uint8_t group_level; -uint8_t first_group; -uint8_t backlog_prio; -uint8_t group_prio;uint8_t *regs = &tctx->regs[TM_QW1_OS ]; +uint8_t ipb;Xive2Nvp nvp;/* @@ -946,30 +942,8 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; - backlog_prio =xive_ipb_to_pipr (regs[TM_IPB ]); - backlog_level =0 ; - - first_group =xive_get_field32 (NVP2_W0_PGOFIRST , nvp.w0); -if (first_group && regs[TM_LSMFB ] < backlog_prio) { - group_prio =xive2_presenter_backlog_scan (xptr, nvp_blk, nvp_idx, - first_group, &group_level); - regs[TM_LSMFB ] = group_prio; -if (regs[TM_LGS ] && group_prio < backlog_prio && - group_prio < regs[TM_CPPR ]) { - -/* VP can take a group interrupt */ -xive2_presenter_backlog_decr (xptr, nvp_blk, nvp_idx, - group_prio, group_level); - backlog_prio = group_prio; - backlog_level = group_level; - } - } -/* -* Set the PIPR/NSR based on the restored state. -* It will raise the External interrupt signal if needed. -*/ -xive_tctx_pipr_set (tctx,TM_QW1_OS , backlog_prio, backlog_level); +xive2_tctx_process_pending (tctx,TM_QW1_OS ); }/* @@ -1103,8 +1077,12 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring) {uint8_t *sig_regs = &tctx->regs[sig_ring];Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); -uint8_t backlog_prio, first_group, group_level; -uint8_t pipr_min, lsmfb_min, ring_min; +uint8_t backlog_prio; +uint8_t first_group; +uint8_t group_level; +uint8_t pipr_min; +uint8_t lsmfb_min; +uint8_t ring_min;uint8_t cppr = sig_regs[TM_CPPR ];bool group_enabled;Xive2Nvp nvp;
Re: [PATCH 37/50] ppc/xive2: Consolidate presentation processing in context push
In reply to Nicholas PigginQuoted 82 lines · Nicholas Piggin
OS-push operation must re-present pending interrupts. Use the newly created
xive2_tctx_process_pending()function instead of duplicating the logic.Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-)hw/intc/xive2.c +10
-32@@ -903,18 +903,14 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); +static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -XivePresenter *xptr =XIVE_PRESENTER (xrtr); -uint8_t ipb; -uint8_t backlog_level; -uint8_t group_level; -uint8_t first_group; -uint8_t backlog_prio; -uint8_t group_prio;uint8_t *regs = &tctx->regs[TM_QW1_OS ]; +uint8_t ipb;Xive2Nvp nvp;/* @@ -946,30 +942,8 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; - backlog_prio =xive_ipb_to_pipr (regs[TM_IPB ]); - backlog_level =0 ; - - first_group =xive_get_field32 (NVP2_W0_PGOFIRST , nvp.w0); -if (first_group && regs[TM_LSMFB ] < backlog_prio) { - group_prio =xive2_presenter_backlog_scan (xptr, nvp_blk, nvp_idx, - first_group, &group_level); - regs[TM_LSMFB ] = group_prio; -if (regs[TM_LGS ] && group_prio < backlog_prio && - group_prio < regs[TM_CPPR ]) { - -/* VP can take a group interrupt */ -xive2_presenter_backlog_decr (xptr, nvp_blk, nvp_idx, - group_prio, group_level); - backlog_prio = group_prio; - backlog_level = group_level; - } - } -/* -* Set the PIPR/NSR based on the restored state. -* It will raise the External interrupt signal if needed. -*/ -xive_tctx_pipr_set (tctx,TM_QW1_OS , backlog_prio, backlog_level); +xive2_tctx_process_pending (tctx,TM_QW1_OS ); }/* @@ -1103,8 +1077,12 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring) {uint8_t *sig_regs = &tctx->regs[sig_ring];Xive2Router *xrtr =XIVE2_ROUTER (tctx->xptr); -uint8_t backlog_prio, first_group, group_level; -uint8_t pipr_min, lsmfb_min, ring_min; +uint8_t backlog_prio; +uint8_t first_group; +uint8_t group_level; +uint8_t pipr_min; +uint8_t lsmfb_min; +uint8_t ring_min;uint8_t cppr = sig_regs[TM_CPPR ];bool group_enabled;Xive2Nvp nvp;
PATCH 38/50 ppc/xive2: Avoid needless interrupt re-check on CPPR set
In reply to Nicholas PigginWhen CPPR priority is decreased, pending interrupts do not need to be re-checked if one is already presented because by definition that will be the highest priority.
This prevents a presented group interrupt from being lost.
--- hw/intc/xive2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/intc/xive2.c +3 -1
@@ -1250,7 +1250,9 @@ static void xive2_tctx_set_cppr(XiveTCTX *tctx, uint8_t sig_ring, uint8_t cppr) }/* CPPR priority decreased (higher value) */ -xive2_tctx_process_pending (tctx, sig_ring); +if (!xive_nsr_indicates_exception (sig_ring, nsr)) { +xive2_tctx_process_pending (tctx, sig_ring); + } } void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx,
Signature · 1 line
2.47.1
Re: [PATCH 38/50] ppc/xive2: Avoid needless interrupt re-check on CPPR set
Quoted 5 lines · Nicholas Piggin
When CPPR priority is decreased, pending interrupts do not need to be re-checked if one is already presented because by definition that will be the highest priority.
This prevents a presented group interrupt from being lost.
Thanks, MAK
Quoted 21 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/intc/xive2.c +3
-1@@ -1250,7 +1250,9 @@ static void xive2_tctx_set_cppr(XiveTCTX *tctx, uint8_t sig_ring, uint8_t cppr) }/* CPPR priority decreased (higher value) */ -xive2_tctx_process_pending (tctx, sig_ring); +if (!xive_nsr_indicates_exception (sig_ring, nsr)) { +xive2_tctx_process_pending (tctx, sig_ring); + } } void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx,
Re: [PATCH 38/50] ppc/xive2: Avoid needless interrupt re-check on CPPR set
In reply to Nicholas PigginQuoted 26 lines · Nicholas Piggin
When CPPR priority is decreased, pending interrupts do not need to be re-checked if one is already presented because by definition that will be the highest priority.
This prevents a presented group interrupt from being lost.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/intc/xive2.c +3
-1@@ -1250,7 +1250,9 @@ static void xive2_tctx_set_cppr(XiveTCTX *tctx, uint8_t sig_ring, uint8_t cppr) }/* CPPR priority decreased (higher value) */ -xive2_tctx_process_pending (tctx, sig_ring); +if (!xive_nsr_indicates_exception (sig_ring, nsr)) { +xive2_tctx_process_pending (tctx, sig_ring); + } } void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx,
PATCH 39/50 ppc/xive: Assert group interrupts were redistributed
In reply to Nicholas PigginAdd some assertions to try to ensure presented group interrupts do not get lost without being redistributed, if they become precluded by CPPR or preempted by a higher priority interrupt.
--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 1 + 2 files changed, 3 insertions(+)
hw/intc/xive.c +2 -0
@@ -132,6 +132,8 @@ void xive_tctx_pipr_set(XiveTCTX *tctx, uint8_t ring, uint8_t pipr,uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; +g_assert (!xive_nsr_indicates_group_exception (ring, sig_regs[TM_NSR ])); + sig_regs[TM_PIPR ] = pipr;if (pipr < sig_regs[TM_CPPR ]) {
hw/intc/xive2.c +1 -0
@@ -1089,6 +1089,7 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring)int rc;g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS ); +g_assert (!xive_nsr_indicates_group_exception (sig_ring, sig_regs[TM_NSR ]));/* * Recompute the PIPR based on local pending interrupts. It will
Signature · 1 line
2.47.1
Re: [PATCH 39/50] ppc/xive: Assert group interrupts were redistributed
Quoted 3 lines · Nicholas Piggin
Add some assertions to try to ensure presented group interrupts do not get lost without being redistributed, if they become precluded by CPPR or preempted by a higher priority interrupt.
Thanks, MAK
Quoted 32 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 1 + 2 files changed, 3 insertions(+)hw/intc/xive.c +2
-0@@ -132,6 +132,8 @@ void xive_tctx_pipr_set(XiveTCTX *tctx, uint8_t ring, uint8_t pipr,uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; +g_assert (!xive_nsr_indicates_group_exception (ring, sig_regs[TM_NSR ])); + sig_regs[TM_PIPR ] = pipr;if (pipr < sig_regs[TM_CPPR ]) {hw/intc/xive2.c +1
-0@@ -1089,6 +1089,7 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring)int rc;g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS ); +g_assert (!xive_nsr_indicates_group_exception (sig_ring, sig_regs[TM_NSR ]));/* * Recompute the PIPR based on local pending interrupts. It will
Re: [PATCH 39/50] ppc/xive: Assert group interrupts were redistributed
In reply to Nicholas PigginQuoted 35 lines · Nicholas Piggin
Add some assertions to try to ensure presented group interrupts do not get lost without being redistributed, if they become precluded by CPPR or preempted by a higher priority interrupt.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 1 + 2 files changed, 3 insertions(+)hw/intc/xive.c +2
-0@@ -132,6 +132,8 @@ void xive_tctx_pipr_set(XiveTCTX *tctx, uint8_t ring, uint8_t pipr,uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; +g_assert (!xive_nsr_indicates_group_exception (ring, sig_regs[TM_NSR ])); + sig_regs[TM_PIPR ] = pipr;if (pipr < sig_regs[TM_CPPR ]) {hw/intc/xive2.c +1
-0@@ -1089,6 +1089,7 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring)int rc;g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS ); +g_assert (!xive_nsr_indicates_group_exception (sig_ring, sig_regs[TM_NSR ]));/* * Recompute the PIPR based on local pending interrupts. It will
PATCH 40/50 ppc/xive2: implement NVP context save restore for POOL ring
In reply to Nicholas PigginIn preparation to implement POOL context push, add support for POOL NVP context save/restore.
The NVP p bit is defined in the spec as follows:
If TRUE, the CPPR of a Pool VP in the NVP is updated during store of the context with the CPPR of the Hard context it was running under.
It's not clear whether non-pool VPs always or never get CPPR updated. Before this patch, OS contexts always save CPPR, so we will assume that is the behaviour.
--- hw/intc/xive2.c | 51 +++++++++++++++++++++++++------------ include/hw/ppc/xive2_regs.h | 1 + 2 files changed, 36 insertions(+), 16 deletions(-)
hw/intc/xive2.c +35 -16
@@ -512,12 +512,13 @@ static void xive2_presenter_backlog_decr(XivePresenter *xptr,*/ static void xive2_tctx_save_ctx (Xive2Router *xrtr,XiveTCTX *tctx, -uint8_t nvp_blk,uint32_t nvp_idx, -uint8_t ring) +uint8_t ring, +uint8_t nvp_blk,uint32_t nvp_idx) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value;Xive2Nvp nvp; +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring];if (xive2_router_get_nvp (xrtr, nvp_blk, nvp_idx, &nvp)) {
@@ -553,7 +554,14 @@ static void xive2_tctx_save_ctx(Xive2Router *xrtr, XiveTCTX *tctx, } nvp.w2 =xive_set_field32 (NVP2_W2_IPB , nvp.w2, regs[TM_IPB ]); - nvp.w2 =xive_set_field32 (NVP2_W2_CPPR , nvp.w2, regs[TM_CPPR ]); + +if ((nvp.w0 &NVP2_W0_P ) || ring !=TM_QW2_HV_POOL ) { +/* +* Non-pool contexts always save CPPR (ignore p bit). XXX: Clarify +* whether that is the correct behaviour. +*/ + nvp.w2 =xive_set_field32 (NVP2_W2_CPPR , nvp.w2, sig_regs[TM_CPPR ]); + }if (nvp.w0 &NVP2_W0_L ) {/* * Typically not used. If LSMFB is restored with 0, it will
@@ -722,7 +730,7 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx, }if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) { -xive2_tctx_save_ctx (xrtr, tctx, nvp_blk, nvp_idx, ring); +xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); }/*
@@ -863,12 +871,15 @@ void xive2_tm_pull_phys_ctx_ol(XivePresenter *xptr, XiveTCTX *tctx,xive2_tm_pull_ctx_ol (xptr, tctx, offset, value, size,TM_QW3_HV_PHYS ); } -static uint8_t xive2_tctx_restore_os_ctx (Xive2Router *xrtr,XiveTCTX *tctx, -uint8_t nvp_blk,uint32_t nvp_idx, -Xive2Nvp *nvp) +static uint8_t xive2_tctx_restore_ctx (Xive2Router *xrtr,XiveTCTX *tctx, +uint8_t ring, +uint8_t nvp_blk,uint32_t nvp_idx, +Xive2Nvp *nvp) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value; +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); +uint8_t *regs = &tctx->regs[ring];uint8_t cppr;if (!xive2_nvp_is_hw (nvp)) {
@@ -881,10 +892,10 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx, nvp->w2 =xive_set_field32 (NVP2_W2_CPPR , nvp->w2,0 );xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, nvp,2 ); - tctx->regs[TM_QW1_OS +TM_CPPR ] = cppr; - tctx->regs[TM_QW1_OS +TM_LSMFB ] =xive_get_field32 (NVP2_W2_LSMFB , nvp->w2); - tctx->regs[TM_QW1_OS +TM_LGS ] =xive_get_field32 (NVP2_W2_LGS , nvp->w2); - tctx->regs[TM_QW1_OS +TM_T ] =xive_get_field32 (NVP2_W2_T , nvp->w2); + sig_regs[TM_CPPR ] = cppr; + regs[TM_LSMFB ] =xive_get_field32 (NVP2_W2_LSMFB , nvp->w2); + regs[TM_LGS ] =xive_get_field32 (NVP2_W2_LGS , nvp->w2); + regs[TM_T ] =xive_get_field32 (NVP2_W2_T , nvp->w2); nvp->w1 =xive_set_field32 (NVP2_W1_CO , nvp->w1,1 ); nvp->w1 =xive_set_field32 (NVP2_W1_CO_THRID_VALID , nvp->w1,1 );
@@ -893,9 +904,18 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx,/* * Checkout privilege: 0:OS, 1:Pool, 2:Hard * -* TODO: we only support OS push/pull +* TODO: we don't support hard push/pull */ - nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,0 ); +switch (ring) { +case TM_QW1_OS : + nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,0 ); +break ; +case TM_QW2_HV_POOL : + nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,1 ); +break ; +default : +g_assert_not_reached (); + }xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, nvp,1 );
@@ -930,9 +950,8 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* Automatically restore thread context registers */ -if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && - do_restore) { -xive2_tctx_restore_os_ctx (xrtr, tctx, nvp_blk, nvp_idx, &nvp); +if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_restore) { +xive2_tctx_restore_ctx (xrtr, tctx,TM_QW1_OS , nvp_blk, nvp_idx, &nvp); } ipb =xive_get_field32 (NVP2_W2_IPB , nvp.w2);
include/hw/ppc/xive2_regs.h +1 -0
@@ -158,6 +158,7 @@ typedef struct Xive2Nvp {#define NVP2_W0_L PPC_BIT32(8)#define NVP2_W0_G PPC_BIT32(9)#define NVP2_W0_T PPC_BIT32(10) +#define NVP2_W0_P PPC_BIT32(11)#define NVP2_W0_ESC_END PPC_BIT32(25)/* 'N' bit 0:ESB 1:END */ #define NVP2_W0_PGOFIRST PPC_BITMASK32(26, 31)uint32_t w1;
Signature · 1 line
2.47.1
Re: [PATCH 40/50] ppc/xive2: implement NVP context save restore for POOL ring
Quoted 11 lines · Nicholas Piggin
In preparation to implement POOL context push, add support for POOL NVP context save/restore.
The NVP p bit is defined in the spec as follows:
If TRUE, the CPPR of a Pool VP in the NVP is updated during store of the context with the CPPR of the Hard context it was running under.
It's not clear whether non-pool VPs always or never get CPPR updated. Before this patch, OS contexts always save CPPR, so we will assume that is the behaviour.
Thanks, MAK
Quoted 131 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 51 +++++++++++++++++++++++++------------ include/hw/ppc/xive2_regs.h | 1 + 2 files changed, 36 insertions(+), 16 deletions(-)hw/intc/xive2.c +35
-16@@ -512,12 +512,13 @@ static void xive2_presenter_backlog_decr(XivePresenter *xptr,*/ static void xive2_tctx_save_ctx (Xive2Router *xrtr,XiveTCTX *tctx, -uint8_t nvp_blk,uint32_t nvp_idx, -uint8_t ring) +uint8_t ring, +uint8_t nvp_blk,uint32_t nvp_idx) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value;Xive2Nvp nvp; +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring];if (xive2_router_get_nvp (xrtr, nvp_blk, nvp_idx, &nvp)) {@@ -553,7 +554,14 @@ static void xive2_tctx_save_ctx(Xive2Router *xrtr, XiveTCTX *tctx, } nvp.w2 =xive_set_field32 (NVP2_W2_IPB , nvp.w2, regs[TM_IPB ]); - nvp.w2 =xive_set_field32 (NVP2_W2_CPPR , nvp.w2, regs[TM_CPPR ]); + +if ((nvp.w0 &NVP2_W0_P ) || ring !=TM_QW2_HV_POOL ) { +/* +* Non-pool contexts always save CPPR (ignore p bit). XXX: Clarify +* whether that is the correct behaviour. +*/ + nvp.w2 =xive_set_field32 (NVP2_W2_CPPR , nvp.w2, sig_regs[TM_CPPR ]); + }if (nvp.w0 &NVP2_W0_L ) {/* * Typically not used. If LSMFB is restored with 0, it will @@ -722,7 +730,7 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx, }if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) { -xive2_tctx_save_ctx (xrtr, tctx, nvp_blk, nvp_idx, ring); +xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); }/* @@ -863,12 +871,15 @@ void xive2_tm_pull_phys_ctx_ol(XivePresenter *xptr, XiveTCTX *tctx,xive2_tm_pull_ctx_ol (xptr, tctx, offset, value, size,TM_QW3_HV_PHYS ); } -static uint8_t xive2_tctx_restore_os_ctx (Xive2Router *xrtr,XiveTCTX *tctx, -uint8_t nvp_blk,uint32_t nvp_idx, -Xive2Nvp *nvp) +static uint8_t xive2_tctx_restore_ctx (Xive2Router *xrtr,XiveTCTX *tctx, +uint8_t ring, +uint8_t nvp_blk,uint32_t nvp_idx, +Xive2Nvp *nvp) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value; +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); +uint8_t *regs = &tctx->regs[ring];uint8_t cppr;if (!xive2_nvp_is_hw (nvp)) {@@ -881,10 +892,10 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx, nvp->w2 =xive_set_field32 (NVP2_W2_CPPR , nvp->w2,0 );xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, nvp,2 ); - tctx->regs[TM_QW1_OS +TM_CPPR ] = cppr; - tctx->regs[TM_QW1_OS +TM_LSMFB ] =xive_get_field32 (NVP2_W2_LSMFB , nvp->w2); - tctx->regs[TM_QW1_OS +TM_LGS ] =xive_get_field32 (NVP2_W2_LGS , nvp->w2); - tctx->regs[TM_QW1_OS +TM_T ] =xive_get_field32 (NVP2_W2_T , nvp->w2); + sig_regs[TM_CPPR ] = cppr; + regs[TM_LSMFB ] =xive_get_field32 (NVP2_W2_LSMFB , nvp->w2); + regs[TM_LGS ] =xive_get_field32 (NVP2_W2_LGS , nvp->w2); + regs[TM_T ] =xive_get_field32 (NVP2_W2_T , nvp->w2); nvp->w1 =xive_set_field32 (NVP2_W1_CO , nvp->w1,1 ); nvp->w1 =xive_set_field32 (NVP2_W1_CO_THRID_VALID , nvp->w1,1 );@@ -893,9 +904,18 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx,/* * Checkout privilege: 0:OS, 1:Pool, 2:Hard * -* TODO: we only support OS push/pull +* TODO: we don't support hard push/pull */ - nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,0 ); +switch (ring) { +case TM_QW1_OS : + nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,0 ); +break ; +case TM_QW2_HV_POOL : + nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,1 ); +break ; +default : +g_assert_not_reached (); + }xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, nvp,1 );@@ -930,9 +950,8 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* Automatically restore thread context registers */ -if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && - do_restore) { -xive2_tctx_restore_os_ctx (xrtr, tctx, nvp_blk, nvp_idx, &nvp); +if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_restore) { +xive2_tctx_restore_ctx (xrtr, tctx,TM_QW1_OS , nvp_blk, nvp_idx, &nvp); } ipb =xive_get_field32 (NVP2_W2_IPB , nvp.w2);include/hw/ppc/xive2_regs.h +1
-0@@ -158,6 +158,7 @@ typedef struct Xive2Nvp {#define NVP2_W0_L PPC_BIT32(8)#define NVP2_W0_G PPC_BIT32(9)#define NVP2_W0_T PPC_BIT32(10) +#define NVP2_W0_P PPC_BIT32(11)#define NVP2_W0_ESC_END PPC_BIT32(25)/* 'N' bit 0:ESB 1:END */ #define NVP2_W0_PGOFIRST PPC_BITMASK32(26, 31)uint32_t w1;
Re: [PATCH 40/50] ppc/xive2: implement NVP context save restore for POOL ring
In reply to Nicholas PigginQuoted 142 lines · Nicholas Piggin
In preparation to implement POOL context push, add support for POOL NVP context save/restore.
The NVP p bit is defined in the spec as follows:
If TRUE, the CPPR of a Pool VP in the NVP is updated during store of the context with the CPPR of the Hard context it was running under.
It's not clear whether non-pool VPs always or never get CPPR updated. Before this patch, OS contexts always save CPPR, so we will assume that is the behaviour.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 51 +++++++++++++++++++++++++------------ include/hw/ppc/xive2_regs.h | 1 + 2 files changed, 36 insertions(+), 16 deletions(-)hw/intc/xive2.c +35
-16@@ -512,12 +512,13 @@ static void xive2_presenter_backlog_decr(XivePresenter *xptr,*/ static void xive2_tctx_save_ctx (Xive2Router *xrtr,XiveTCTX *tctx, -uint8_t nvp_blk,uint32_t nvp_idx, -uint8_t ring) +uint8_t ring, +uint8_t nvp_blk,uint32_t nvp_idx) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value;Xive2Nvp nvp; +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring];if (xive2_router_get_nvp (xrtr, nvp_blk, nvp_idx, &nvp)) {@@ -553,7 +554,14 @@ static void xive2_tctx_save_ctx(Xive2Router *xrtr, XiveTCTX *tctx, } nvp.w2 =xive_set_field32 (NVP2_W2_IPB , nvp.w2, regs[TM_IPB ]); - nvp.w2 =xive_set_field32 (NVP2_W2_CPPR , nvp.w2, regs[TM_CPPR ]); + +if ((nvp.w0 &NVP2_W0_P ) || ring !=TM_QW2_HV_POOL ) { +/* +* Non-pool contexts always save CPPR (ignore p bit). XXX: Clarify +* whether that is the correct behaviour. +*/ + nvp.w2 =xive_set_field32 (NVP2_W2_CPPR , nvp.w2, sig_regs[TM_CPPR ]); + }if (nvp.w0 &NVP2_W0_L ) {/* * Typically not used. If LSMFB is restored with 0, it will @@ -722,7 +730,7 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx, }if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) { -xive2_tctx_save_ctx (xrtr, tctx, nvp_blk, nvp_idx, ring); +xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); }/* @@ -863,12 +871,15 @@ void xive2_tm_pull_phys_ctx_ol(XivePresenter *xptr, XiveTCTX *tctx,xive2_tm_pull_ctx_ol (xptr, tctx, offset, value, size,TM_QW3_HV_PHYS ); } -static uint8_t xive2_tctx_restore_os_ctx (Xive2Router *xrtr,XiveTCTX *tctx, -uint8_t nvp_blk,uint32_t nvp_idx, -Xive2Nvp *nvp) +static uint8_t xive2_tctx_restore_ctx (Xive2Router *xrtr,XiveTCTX *tctx, +uint8_t ring, +uint8_t nvp_blk,uint32_t nvp_idx, +Xive2Nvp *nvp) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value; +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); +uint8_t *regs = &tctx->regs[ring];uint8_t cppr;if (!xive2_nvp_is_hw (nvp)) {@@ -881,10 +892,10 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx, nvp->w2 =xive_set_field32 (NVP2_W2_CPPR , nvp->w2,0 );xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, nvp,2 ); - tctx->regs[TM_QW1_OS +TM_CPPR ] = cppr; - tctx->regs[TM_QW1_OS +TM_LSMFB ] =xive_get_field32 (NVP2_W2_LSMFB , nvp->w2); - tctx->regs[TM_QW1_OS +TM_LGS ] =xive_get_field32 (NVP2_W2_LGS , nvp->w2); - tctx->regs[TM_QW1_OS +TM_T ] =xive_get_field32 (NVP2_W2_T , nvp->w2); + sig_regs[TM_CPPR ] = cppr; + regs[TM_LSMFB ] =xive_get_field32 (NVP2_W2_LSMFB , nvp->w2); + regs[TM_LGS ] =xive_get_field32 (NVP2_W2_LGS , nvp->w2); + regs[TM_T ] =xive_get_field32 (NVP2_W2_T , nvp->w2); nvp->w1 =xive_set_field32 (NVP2_W1_CO , nvp->w1,1 ); nvp->w1 =xive_set_field32 (NVP2_W1_CO_THRID_VALID , nvp->w1,1 );@@ -893,9 +904,18 @@ static uint8_t xive2_tctx_restore_os_ctx(Xive2Router *xrtr, XiveTCTX *tctx,/* * Checkout privilege: 0:OS, 1:Pool, 2:Hard * -* TODO: we only support OS push/pull +* TODO: we don't support hard push/pull */ - nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,0 ); +switch (ring) { +case TM_QW1_OS : + nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,0 ); +break ; +case TM_QW2_HV_POOL : + nvp->w1 =xive_set_field32 (NVP2_W1_CO_PRIV , nvp->w1,1 ); +break ; +default : +g_assert_not_reached (); + }xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, nvp,1 );@@ -930,9 +950,8 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* Automatically restore thread context registers */ -if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && - do_restore) { -xive2_tctx_restore_os_ctx (xrtr, tctx, nvp_blk, nvp_idx, &nvp); +if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_restore) { +xive2_tctx_restore_ctx (xrtr, tctx,TM_QW1_OS , nvp_blk, nvp_idx, &nvp); } ipb =xive_get_field32 (NVP2_W2_IPB , nvp.w2);include/hw/ppc/xive2_regs.h +1
-0@@ -158,6 +158,7 @@ typedef struct Xive2Nvp {#define NVP2_W0_L PPC_BIT32(8)#define NVP2_W0_G PPC_BIT32(9)#define NVP2_W0_T PPC_BIT32(10) +#define NVP2_W0_P PPC_BIT32(11)#define NVP2_W0_ESC_END PPC_BIT32(25)/* 'N' bit 0:ESB 1:END */ #define NVP2_W0_PGOFIRST PPC_BITMASK32(26, 31)uint32_t w1;
PATCH 41/50 ppc/xive2: Prevent pulling of pool context losing phys interrupt
In reply to Nicholas PigginWhen the pool context is pulled, the shared pool/phys signal is reset, which loses the qemu irq if a phys interrupt was presented.
Only reset the signal if a poll irq was presented.
--- hw/intc/xive2.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
hw/intc/xive2.c +10 -8
@@ -727,20 +727,22 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive2_redistribute (xrtr, tctx, cur_ring); } } + +/* +* Lower external interrupt line of requested ring and below except for +* USER, which doesn't exist. +*/ +if (xive_nsr_indicates_exception (cur_ring, nsr)) { +if (cur_ring ==xive_nsr_exception_ring (cur_ring, nsr)) { +xive_tctx_reset_signal (tctx, cur_ring); + } + } }if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) {xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); } -/* -* Lower external interrupt line of requested ring and below except for -* USER, which doesn't exist. -*/ -for (cur_ring =TM_QW1_OS ; cur_ring <= ring; - cur_ring +=XIVE_TM_RING_SIZE ) { -xive_tctx_reset_signal (tctx, cur_ring); - }return target_ringw2; }
Signature · 1 line
2.47.1
Re: [PATCH 41/50] ppc/xive2: Prevent pulling of pool context losing phys interrupt
Quoted 4 lines · Nicholas Piggin
When the pool context is pulled, the shared pool/phys signal is reset, which loses the qemu irq if a phys interrupt was presented.
Only reset the signal if a poll irq was presented.
Thanks, MAK
Quoted 41 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)hw/intc/xive2.c +10
-8@@ -727,20 +727,22 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive2_redistribute (xrtr, tctx, cur_ring); } } + +/* +* Lower external interrupt line of requested ring and below except for +* USER, which doesn't exist. +*/ +if (xive_nsr_indicates_exception (cur_ring, nsr)) { +if (cur_ring ==xive_nsr_exception_ring (cur_ring, nsr)) { +xive_tctx_reset_signal (tctx, cur_ring); + } + } }if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) {xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); } -/* -* Lower external interrupt line of requested ring and below except for -* USER, which doesn't exist. -*/ -for (cur_ring =TM_QW1_OS ; cur_ring <= ring; - cur_ring +=XIVE_TM_RING_SIZE ) { -xive_tctx_reset_signal (tctx, cur_ring); - }return target_ringw2; }
Re: [PATCH 41/50] ppc/xive2: Prevent pulling of pool context losing phys interrupt
In reply to Nicholas PigginQuoted 45 lines · Nicholas Piggin
When the pool context is pulled, the shared pool/phys signal is reset, which loses the qemu irq if a phys interrupt was presented.
Only reset the signal if a poll irq was presented.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)hw/intc/xive2.c +10
-8@@ -727,20 +727,22 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive2_redistribute (xrtr, tctx, cur_ring); } } + +/* +* Lower external interrupt line of requested ring and below except for +* USER, which doesn't exist. +*/ +if (xive_nsr_indicates_exception (cur_ring, nsr)) { +if (cur_ring ==xive_nsr_exception_ring (cur_ring, nsr)) { +xive_tctx_reset_signal (tctx, cur_ring); + } + } }if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) {xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); } -/* -* Lower external interrupt line of requested ring and below except for -* USER, which doesn't exist. -*/ -for (cur_ring =TM_QW1_OS ; cur_ring <= ring; - cur_ring +=XIVE_TM_RING_SIZE ) { -xive_tctx_reset_signal (tctx, cur_ring); - }return target_ringw2; }
PATCH 42/50 ppc/xive: Redistribute phys after pulling of pool context
In reply to Nicholas PigginAfter pulling the pool context, if a pool irq had been presented and was cleared in the process, there could be a pending irq in phys that should be presented. Process the phys irq ring after pulling pool ring to catch this case and avoid losing irqs.
--- hw/intc/xive.c | 3 +++ hw/intc/xive2.c | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
hw/intc/xive.c +3 -0
@@ -320,6 +320,9 @@ static uint64_t xive_tm_pull_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive_tctx_reset_signal (tctx,TM_QW1_OS );xive_tctx_reset_signal (tctx,TM_QW2_HV_POOL ); +/* Re-check phys for interrupts if pool was disabled */ +xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW3_HV_PHYS ); +return qw2w2; }
hw/intc/xive2.c +14 -2
@@ -683,6 +683,8 @@ static void xive2_redistribute(Xive2Router *xrtr, XiveTCTX *tctx, uint8_t ring)xive_tctx_reset_signal (tctx, ring); } +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); +static uint64_t xive2_tm_pull_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size,uint8_t ring) {
@@ -739,6 +741,18 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx, } } +if (ring ==TM_QW2_HV_POOL ) { +/* Re-check phys for interrupts if pool was disabled */ + nsr = tctx->regs[TM_QW3_HV_PHYS +TM_NSR ]; +if (xive_nsr_indicates_exception (TM_QW3_HV_PHYS , nsr)) { +/* Ring must be PHYS because POOL would have been redistributed */ +g_assert (xive_nsr_exception_ring (TM_QW3_HV_PHYS , nsr) == +TM_QW3_HV_PHYS ); + }else { +xive2_tctx_process_pending (tctx,TM_QW3_HV_PHYS ); + } + } +if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) {xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); }
@@ -925,8 +939,6 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } -static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); -static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore)
Signature · 1 line
2.47.1
Re: [PATCH 42/50] ppc/xive: Redistribute phys after pulling of pool context
Quoted 4 lines · Nicholas Piggin
After pulling the pool context, if a pool irq had been presented and was cleared in the process, there could be a pending irq in phys that should be presented. Process the phys irq ring after pulling pool ring to catch this case and avoid losing irqs.
Thanks, MAK
Quoted 62 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 3 +++ hw/intc/xive2.c | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)hw/intc/xive.c +3
-0@@ -320,6 +320,9 @@ static uint64_t xive_tm_pull_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive_tctx_reset_signal (tctx,TM_QW1_OS );xive_tctx_reset_signal (tctx,TM_QW2_HV_POOL ); +/* Re-check phys for interrupts if pool was disabled */ +xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW3_HV_PHYS ); +return qw2w2; }hw/intc/xive2.c +14
-2@@ -683,6 +683,8 @@ static void xive2_redistribute(Xive2Router *xrtr, XiveTCTX *tctx, uint8_t ring)xive_tctx_reset_signal (tctx, ring); } +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); +static uint64_t xive2_tm_pull_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size,uint8_t ring) {@@ -739,6 +741,18 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx, } } +if (ring ==TM_QW2_HV_POOL ) { +/* Re-check phys for interrupts if pool was disabled */ + nsr = tctx->regs[TM_QW3_HV_PHYS +TM_NSR ]; +if (xive_nsr_indicates_exception (TM_QW3_HV_PHYS , nsr)) { +/* Ring must be PHYS because POOL would have been redistributed */ +g_assert (xive_nsr_exception_ring (TM_QW3_HV_PHYS , nsr) == +TM_QW3_HV_PHYS ); + }else { +xive2_tctx_process_pending (tctx,TM_QW3_HV_PHYS ); + } + } +if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) {xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); }@@ -925,8 +939,6 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } -static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); -static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore)
Re: [PATCH 42/50] ppc/xive: Redistribute phys after pulling of pool context
In reply to Nicholas PigginQuoted 66 lines · Nicholas Piggin
After pulling the pool context, if a pool irq had been presented and was cleared in the process, there could be a pending irq in phys that should be presented. Process the phys irq ring after pulling pool ring to catch this case and avoid losing irqs.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 3 +++ hw/intc/xive2.c | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)hw/intc/xive.c +3
-0@@ -320,6 +320,9 @@ static uint64_t xive_tm_pull_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive_tctx_reset_signal (tctx,TM_QW1_OS );xive_tctx_reset_signal (tctx,TM_QW2_HV_POOL ); +/* Re-check phys for interrupts if pool was disabled */ +xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW3_HV_PHYS ); +return qw2w2; }hw/intc/xive2.c +14
-2@@ -683,6 +683,8 @@ static void xive2_redistribute(Xive2Router *xrtr, XiveTCTX *tctx, uint8_t ring)xive_tctx_reset_signal (tctx, ring); } +static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); +static uint64_t xive2_tm_pull_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size,uint8_t ring) {@@ -739,6 +741,18 @@ static uint64_t xive2_tm_pull_ctx(XivePresenter *xptr, XiveTCTX *tctx, } } +if (ring ==TM_QW2_HV_POOL ) { +/* Re-check phys for interrupts if pool was disabled */ + nsr = tctx->regs[TM_QW3_HV_PHYS +TM_NSR ]; +if (xive_nsr_indicates_exception (TM_QW3_HV_PHYS , nsr)) { +/* Ring must be PHYS because POOL would have been redistributed */ +g_assert (xive_nsr_exception_ring (TM_QW3_HV_PHYS , nsr) == +TM_QW3_HV_PHYS ); + }else { +xive2_tctx_process_pending (tctx,TM_QW3_HV_PHYS ); + } + } +if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_save) {xive2_tctx_save_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx); }@@ -925,8 +939,6 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } -static void xive2_tctx_process_pending (XiveTCTX *tctx,uint8_t sig_ring); -static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore)
PATCH 43/50 ppc/xive: Check TIMA operations validity
In reply to Nicholas PigginCertain TIMA operations should only be performed when a ring is valid, others when the ring is invalid, and they are considered undefined if used incorrectly. Add checks for this condition.
--- hw/intc/xive.c | 196 +++++++++++++++++++++++++----------------- include/hw/ppc/xive.h | 1 + 2 files changed, 116 insertions(+), 81 deletions(-)
hw/intc/xive.c +115 -81
@@ -25,6 +25,19 @@/* * XIVE Thread Interrupt Management context */ +bool xive_ring_valid (XiveTCTX *tctx,uint8_t ring) +{ +uint8_t cur_ring; + +for (cur_ring = ring; cur_ring <=TM_QW3_HV_PHYS ; + cur_ring +=XIVE_TM_RING_SIZE ) { +if (!(tctx->regs[cur_ring +TM_WORD2 ] &0x80 )) { +return false; + } + } +return true; +} +bool xive_nsr_indicates_exception (uint8_t ring,uint8_t nsr) {switch (ring) {
@@ -663,6 +676,8 @@ typedef struct XiveTmOp {uint8_t page_offset;uint32_t op_offset;unsigned size; +bool hw_ok; +bool sw_ok;void (*write_handler)(XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size);
@@ -675,34 +690,34 @@ static const XiveTmOp xive_tm_operations[] = {* MMIOs below 2K : raw values and special operations without side * effects */ - {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , xive_tm_set_os_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, xive_tm_push_os_ctx, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, xive_tm_set_hv_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, xive_tm_vt_push, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, NULL, - xive_tm_vt_poll }, + {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , true, true, + xive_tm_set_os_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, true, true, + xive_tm_push_os_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, + xive_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, false, true, + xive_tm_vt_push, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, + NULL, xive_tm_vt_poll },/* MMIOs above 2K : special operations with side effects */ - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, NULL, - xive_tm_ack_os_reg }, - { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, xive_tm_set_os_pending, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, NULL, - xive_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, NULL, - xive_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, NULL, - xive_tm_ack_hv_reg }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, NULL, - xive_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, NULL, - xive_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, NULL, - xive_tm_pull_phys_ctx }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, true, false, + NULL, xive_tm_ack_os_reg }, + { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, true, false, + xive_tm_set_os_pending, NULL }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false, + NULL, xive_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, true, false, + NULL, xive_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, true, false, + NULL, xive_tm_ack_hv_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, true, false, + NULL, xive_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, true, false, + NULL, xive_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, true, false, + NULL, xive_tm_pull_phys_ctx }, }; static const XiveTmOp xive2_tm_operations[] = {
@@ -710,52 +725,48 @@ static const XiveTmOp xive2_tm_operations[] = {* MMIOs below 2K : raw values and special operations without side * effects */ - {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , xive2_tm_set_os_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, xive2_tm_push_os_ctx, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 8, xive2_tm_push_os_ctx, - NULL }, - { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, xive_tm_set_os_lgs, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, xive2_tm_set_hv_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, xive_tm_vt_push, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, NULL, - xive_tm_vt_poll }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, xive2_tm_set_hv_target, - NULL }, + {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , true, true, + xive2_tm_set_os_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, true, true, + xive2_tm_push_os_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 8, true, true, + xive2_tm_push_os_ctx, NULL }, + { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, true, true, + xive_tm_set_os_lgs, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, + xive2_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, + NULL, xive_tm_vt_poll }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, true, true, + xive2_tm_set_hv_target, NULL },/* MMIOs above 2K : special operations with side effects */ - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, NULL, - xive_tm_ack_os_reg }, - { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, xive_tm_set_os_pending, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, NULL, - xive_tm_ack_hv_reg }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX_G2, 4, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_OL, 1, xive2_tm_pull_os_ctx_ol, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_G2, 4, NULL, - xive2_tm_pull_phys_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, NULL, - xive2_tm_pull_phys_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_OL, 1, xive2_tm_pull_phys_ctx_ol, - NULL }, - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_EL, 1, xive2_tm_ack_os_el, - NULL }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, true, false, + NULL, xive_tm_ack_os_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, true, false, + NULL, xive_tm_ack_hv_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_OL, 1, true, false, + xive2_tm_pull_os_ctx_ol, NULL }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_phys_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, true, false, + NULL, xive2_tm_pull_phys_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_OL, 1, true, false, + xive2_tm_pull_phys_ctx_ol, NULL }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_EL, 1, true, false, + xive2_tm_ack_os_el, NULL }, }; static const XiveTmOp *xive_tm_find_op(XivePresenter *xptr, hwaddr offset,
@@ -797,18 +808,28 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size) {const XiveTmOp *xto; +uint8_t ring = offset &TM_RING_OFFSET ; +bool is_valid =xive_ring_valid (tctx, ring); +bool hw_owned = is_valid;trace_xive_tctx_tm_write (tctx->cs->cpu_index, offset, size, value); -/* -* TODO: check V bit in Q[0-3]W2 -*/ -/* * First, check for special operations in the 2K region */ + xto =xive_tm_find_op (tctx->xptr, offset, size, true); +if (xto) { +if (hw_owned && !xto->hw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } +if (!hw_owned && !xto->sw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to SW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } + } +if (offset &TM_SPECIAL_OP ) { - xto =xive_tm_find_op (tctx->xptr, offset, size, true);if (!xto) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid write access at TIMA " "@%" HWADDR_PRIx" size %d\n" , offset, size);
@@ -821,7 +842,6 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Then, for special operations in the region below 2K. */ - xto =xive_tm_find_op (tctx->xptr, offset, size, true);if (xto) { xto->write_handler (xptr, tctx, offset, value, size);return ;
@@ -830,6 +850,11 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Finish with raw access to the register values */ +if (hw_owned) { +/* Store context operations are dangerous when context is valid */ +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + }xive_tm_raw_write (tctx, offset, value, size); }
@@ -837,17 +862,27 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, unsigned size) {const XiveTmOp *xto; +uint8_t ring = offset &TM_RING_OFFSET ; +bool is_valid =xive_ring_valid (tctx, ring); +bool hw_owned = is_valid;uint64_t ret; -/* -* TODO: check V bit in Q[0-3]W2 -*/ + xto =xive_tm_find_op (tctx->xptr, offset, size, false); +if (xto) { +if (hw_owned && !xto->hw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined read to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } +if (!hw_owned && !xto->sw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined read to SW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } + }/* * First, check for special operations in the 2K region */ if (offset &TM_SPECIAL_OP ) { - xto =xive_tm_find_op (tctx->xptr, offset, size, false);if (!xto) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid read access to TIMA" "@%" HWADDR_PRIx" size %d\n" , offset, size);
@@ -860,7 +895,6 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Then, for special operations in the region below 2K. */ - xto =xive_tm_find_op (tctx->xptr, offset, size, false);if (xto) { ret = xto->read_handler (xptr, tctx, offset, size); goto out;
include/hw/ppc/xive.h +1 -0
@@ -365,6 +365,7 @@ static inline uint32_t xive_tctx_word2(uint8_t *ring)return *((uint32_t *) &ring[TM_WORD2 ]); } +bool xive_ring_valid (XiveTCTX *tctx,uint8_t ring);bool xive_nsr_indicates_exception (uint8_t ring,uint8_t nsr);bool xive_nsr_indicates_group_exception (uint8_t ring,uint8_t nsr);uint8_t xive_nsr_exception_ring (uint8_t ring,uint8_t nsr);
Signature · 1 line
2.47.1
Re: [PATCH 43/50] ppc/xive: Check TIMA operations validity
Quoted 3 lines · Nicholas Piggin
Certain TIMA operations should only be performed when a ring is valid, others when the ring is invalid, and they are considered undefined if used incorrectly. Add checks for this condition.
Thanks, MAK
Quoted 300 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 196 +++++++++++++++++++++++++----------------- include/hw/ppc/xive.h | 1 + 2 files changed, 116 insertions(+), 81 deletions(-)hw/intc/xive.c +115
-81@@ -25,6 +25,19 @@/* * XIVE Thread Interrupt Management context */ +bool xive_ring_valid (XiveTCTX *tctx,uint8_t ring) +{ +uint8_t cur_ring; + +for (cur_ring = ring; cur_ring <=TM_QW3_HV_PHYS ; + cur_ring +=XIVE_TM_RING_SIZE ) { +if (!(tctx->regs[cur_ring +TM_WORD2 ] &0x80 )) { +return false; + } + } +return true; +} +bool xive_nsr_indicates_exception (uint8_t ring,uint8_t nsr) {switch (ring) {@@ -663,6 +676,8 @@ typedef struct XiveTmOp {uint8_t page_offset;uint32_t op_offset;unsigned size; +bool hw_ok; +bool sw_ok;void (*write_handler)(XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size);@@ -675,34 +690,34 @@ static const XiveTmOp xive_tm_operations[] = {* MMIOs below 2K : raw values and special operations without side * effects */ - {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , xive_tm_set_os_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, xive_tm_push_os_ctx, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, xive_tm_set_hv_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, xive_tm_vt_push, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, NULL, - xive_tm_vt_poll }, + {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , true, true, + xive_tm_set_os_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, true, true, + xive_tm_push_os_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, + xive_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, false, true, + xive_tm_vt_push, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, + NULL, xive_tm_vt_poll },/* MMIOs above 2K : special operations with side effects */ - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, NULL, - xive_tm_ack_os_reg }, - { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, xive_tm_set_os_pending, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, NULL, - xive_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, NULL, - xive_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, NULL, - xive_tm_ack_hv_reg }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, NULL, - xive_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, NULL, - xive_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, NULL, - xive_tm_pull_phys_ctx }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, true, false, + NULL, xive_tm_ack_os_reg }, + { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, true, false, + xive_tm_set_os_pending, NULL }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false, + NULL, xive_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, true, false, + NULL, xive_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, true, false, + NULL, xive_tm_ack_hv_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, true, false, + NULL, xive_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, true, false, + NULL, xive_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, true, false, + NULL, xive_tm_pull_phys_ctx }, }; static const XiveTmOp xive2_tm_operations[] = {@@ -710,52 +725,48 @@ static const XiveTmOp xive2_tm_operations[] = {* MMIOs below 2K : raw values and special operations without side * effects */ - {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , xive2_tm_set_os_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, xive2_tm_push_os_ctx, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 8, xive2_tm_push_os_ctx, - NULL }, - { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, xive_tm_set_os_lgs, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, xive2_tm_set_hv_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, xive_tm_vt_push, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, NULL, - xive_tm_vt_poll }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, xive2_tm_set_hv_target, - NULL }, + {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , true, true, + xive2_tm_set_os_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, true, true, + xive2_tm_push_os_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 8, true, true, + xive2_tm_push_os_ctx, NULL }, + { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, true, true, + xive_tm_set_os_lgs, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, + xive2_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, + NULL, xive_tm_vt_poll }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, true, true, + xive2_tm_set_hv_target, NULL },/* MMIOs above 2K : special operations with side effects */ - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, NULL, - xive_tm_ack_os_reg }, - { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, xive_tm_set_os_pending, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, NULL, - xive_tm_ack_hv_reg }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX_G2, 4, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_OL, 1, xive2_tm_pull_os_ctx_ol, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_G2, 4, NULL, - xive2_tm_pull_phys_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, NULL, - xive2_tm_pull_phys_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_OL, 1, xive2_tm_pull_phys_ctx_ol, - NULL }, - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_EL, 1, xive2_tm_ack_os_el, - NULL }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, true, false, + NULL, xive_tm_ack_os_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, true, false, + NULL, xive_tm_ack_hv_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_OL, 1, true, false, + xive2_tm_pull_os_ctx_ol, NULL }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_phys_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, true, false, + NULL, xive2_tm_pull_phys_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_OL, 1, true, false, + xive2_tm_pull_phys_ctx_ol, NULL }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_EL, 1, true, false, + xive2_tm_ack_os_el, NULL }, }; static const XiveTmOp *xive_tm_find_op(XivePresenter *xptr, hwaddr offset,@@ -797,18 +808,28 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size) {const XiveTmOp *xto; +uint8_t ring = offset &TM_RING_OFFSET ; +bool is_valid =xive_ring_valid (tctx, ring); +bool hw_owned = is_valid;trace_xive_tctx_tm_write (tctx->cs->cpu_index, offset, size, value); -/* -* TODO: check V bit in Q[0-3]W2 -*/ -/* * First, check for special operations in the 2K region */ + xto =xive_tm_find_op (tctx->xptr, offset, size, true); +if (xto) { +if (hw_owned && !xto->hw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } +if (!hw_owned && !xto->sw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to SW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } + } +if (offset &TM_SPECIAL_OP ) { - xto =xive_tm_find_op (tctx->xptr, offset, size, true);if (!xto) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid write access at TIMA " "@%" HWADDR_PRIx" size %d\n" , offset, size);@@ -821,7 +842,6 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Then, for special operations in the region below 2K. */ - xto =xive_tm_find_op (tctx->xptr, offset, size, true);if (xto) { xto->write_handler (xptr, tctx, offset, value, size);return ;@@ -830,6 +850,11 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Finish with raw access to the register values */ +if (hw_owned) { +/* Store context operations are dangerous when context is valid */ +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + }xive_tm_raw_write (tctx, offset, value, size); }@@ -837,17 +862,27 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, unsigned size) {const XiveTmOp *xto; +uint8_t ring = offset &TM_RING_OFFSET ; +bool is_valid =xive_ring_valid (tctx, ring); +bool hw_owned = is_valid;uint64_t ret; -/* -* TODO: check V bit in Q[0-3]W2 -*/ + xto =xive_tm_find_op (tctx->xptr, offset, size, false); +if (xto) { +if (hw_owned && !xto->hw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined read to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } +if (!hw_owned && !xto->sw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined read to SW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } + }/* * First, check for special operations in the 2K region */ if (offset &TM_SPECIAL_OP ) { - xto =xive_tm_find_op (tctx->xptr, offset, size, false);if (!xto) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid read access to TIMA" "@%" HWADDR_PRIx" size %d\n" , offset, size);@@ -860,7 +895,6 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Then, for special operations in the region below 2K. */ - xto =xive_tm_find_op (tctx->xptr, offset, size, false);if (xto) { ret = xto->read_handler (xptr, tctx, offset, size); goto out;include/hw/ppc/xive.h +1
-0@@ -365,6 +365,7 @@ static inline uint32_t xive_tctx_word2(uint8_t *ring)return *((uint32_t *) &ring[TM_WORD2 ]); } +bool xive_ring_valid (XiveTCTX *tctx,uint8_t ring);bool xive_nsr_indicates_exception (uint8_t ring,uint8_t nsr);bool xive_nsr_indicates_group_exception (uint8_t ring,uint8_t nsr);uint8_t xive_nsr_exception_ring (uint8_t ring,uint8_t nsr);
Re: [PATCH 43/50] ppc/xive: Check TIMA operations validity
In reply to Nicholas PigginQuoted 303 lines · Nicholas Piggin
Certain TIMA operations should only be performed when a ring is valid, others when the ring is invalid, and they are considered undefined if used incorrectly. Add checks for this condition.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 196 +++++++++++++++++++++++++----------------- include/hw/ppc/xive.h | 1 + 2 files changed, 116 insertions(+), 81 deletions(-)hw/intc/xive.c +115
-81@@ -25,6 +25,19 @@/* * XIVE Thread Interrupt Management context */ +bool xive_ring_valid (XiveTCTX *tctx,uint8_t ring) +{ +uint8_t cur_ring; + +for (cur_ring = ring; cur_ring <=TM_QW3_HV_PHYS ; + cur_ring +=XIVE_TM_RING_SIZE ) { +if (!(tctx->regs[cur_ring +TM_WORD2 ] &0x80 )) { +return false; + } + } +return true; +} +bool xive_nsr_indicates_exception (uint8_t ring,uint8_t nsr) {switch (ring) {@@ -663,6 +676,8 @@ typedef struct XiveTmOp {uint8_t page_offset;uint32_t op_offset;unsigned size; +bool hw_ok; +bool sw_ok;void (*write_handler)(XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size);@@ -675,34 +690,34 @@ static const XiveTmOp xive_tm_operations[] = {* MMIOs below 2K : raw values and special operations without side * effects */ - {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , xive_tm_set_os_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, xive_tm_push_os_ctx, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, xive_tm_set_hv_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, xive_tm_vt_push, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, NULL, - xive_tm_vt_poll }, + {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , true, true, + xive_tm_set_os_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, true, true, + xive_tm_push_os_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, + xive_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, false, true, + xive_tm_vt_push, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, + NULL, xive_tm_vt_poll },/* MMIOs above 2K : special operations with side effects */ - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, NULL, - xive_tm_ack_os_reg }, - { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, xive_tm_set_os_pending, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, NULL, - xive_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, NULL, - xive_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, NULL, - xive_tm_ack_hv_reg }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, NULL, - xive_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, NULL, - xive_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, NULL, - xive_tm_pull_phys_ctx }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, true, false, + NULL, xive_tm_ack_os_reg }, + { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, true, false, + xive_tm_set_os_pending, NULL }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false, + NULL, xive_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, true, false, + NULL, xive_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, true, false, + NULL, xive_tm_ack_hv_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, true, false, + NULL, xive_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, true, false, + NULL, xive_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, true, false, + NULL, xive_tm_pull_phys_ctx }, }; static const XiveTmOp xive2_tm_operations[] = {@@ -710,52 +725,48 @@ static const XiveTmOp xive2_tm_operations[] = {* MMIOs below 2K : raw values and special operations without side * effects */ - {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , xive2_tm_set_os_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, xive2_tm_push_os_ctx, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 8, xive2_tm_push_os_ctx, - NULL }, - { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, xive_tm_set_os_lgs, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, xive2_tm_set_hv_cppr, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, xive_tm_vt_push, - NULL }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, NULL, - xive_tm_vt_poll }, - { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, xive2_tm_set_hv_target, - NULL }, + {XIVE_TM_OS_PAGE ,TM_QW1_OS +TM_CPPR ,1 , true, true, + xive2_tm_set_os_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 4, true, true, + xive2_tm_push_os_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW1_OS + TM_WORD2, 8, true, true, + xive2_tm_push_os_ctx, NULL }, + { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, true, true, + xive_tm_set_os_lgs, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, + xive2_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, + NULL, xive_tm_vt_poll }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, true, true, + xive2_tm_set_hv_target, NULL },/* MMIOs above 2K : special operations with side effects */ - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, NULL, - xive_tm_ack_os_reg }, - { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, xive_tm_set_os_pending, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, NULL, - xive2_tm_pull_os_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, NULL, - xive_tm_ack_hv_reg }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX_G2, 4, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, NULL, - xive2_tm_pull_pool_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_OL, 1, xive2_tm_pull_os_ctx_ol, - NULL }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_G2, 4, NULL, - xive2_tm_pull_phys_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, NULL, - xive2_tm_pull_phys_ctx }, - { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_OL, 1, xive2_tm_pull_phys_ctx_ol, - NULL }, - { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_EL, 1, xive2_tm_ack_os_el, - NULL }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_REG, 2, true, false, + NULL, xive_tm_ack_os_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 8, true, false, + NULL, xive2_tm_pull_os_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_ACK_HV_REG, 2, true, false, + NULL, xive_tm_ack_hv_reg }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 4, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_POOL_CTX, 8, true, false, + NULL, xive2_tm_pull_pool_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_OL, 1, true, false, + xive2_tm_pull_os_ctx_ol, NULL }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_G2, 4, true, false, + NULL, xive2_tm_pull_phys_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX, 1, true, false, + NULL, xive2_tm_pull_phys_ctx }, + { XIVE_TM_HV_PAGE, TM_SPC_PULL_PHYS_CTX_OL, 1, true, false, + xive2_tm_pull_phys_ctx_ol, NULL }, + { XIVE_TM_OS_PAGE, TM_SPC_ACK_OS_EL, 1, true, false, + xive2_tm_ack_os_el, NULL }, }; static const XiveTmOp *xive_tm_find_op(XivePresenter *xptr, hwaddr offset,@@ -797,18 +808,28 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size) {const XiveTmOp *xto; +uint8_t ring = offset &TM_RING_OFFSET ; +bool is_valid =xive_ring_valid (tctx, ring); +bool hw_owned = is_valid;trace_xive_tctx_tm_write (tctx->cs->cpu_index, offset, size, value); -/* -* TODO: check V bit in Q[0-3]W2 -*/ -/* * First, check for special operations in the 2K region */ + xto =xive_tm_find_op (tctx->xptr, offset, size, true); +if (xto) { +if (hw_owned && !xto->hw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } +if (!hw_owned && !xto->sw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to SW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } + } +if (offset &TM_SPECIAL_OP ) { - xto =xive_tm_find_op (tctx->xptr, offset, size, true);if (!xto) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid write access at TIMA " "@%" HWADDR_PRIx" size %d\n" , offset, size);@@ -821,7 +842,6 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Then, for special operations in the region below 2K. */ - xto =xive_tm_find_op (tctx->xptr, offset, size, true);if (xto) { xto->write_handler (xptr, tctx, offset, value, size);return ;@@ -830,6 +850,11 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Finish with raw access to the register values */ +if (hw_owned) { +/* Store context operations are dangerous when context is valid */ +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined write to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + }xive_tm_raw_write (tctx, offset, value, size); }@@ -837,17 +862,27 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, unsigned size) {const XiveTmOp *xto; +uint8_t ring = offset &TM_RING_OFFSET ; +bool is_valid =xive_ring_valid (tctx, ring); +bool hw_owned = is_valid;uint64_t ret; -/* -* TODO: check V bit in Q[0-3]W2 -*/ + xto =xive_tm_find_op (tctx->xptr, offset, size, false); +if (xto) { +if (hw_owned && !xto->hw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined read to HW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } +if (!hw_owned && !xto->sw_ok) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: undefined read to SW TIMA " +"@%" HWADDR_PRIx" size %d\n" , offset, size); + } + }/* * First, check for special operations in the 2K region */ if (offset &TM_SPECIAL_OP ) { - xto =xive_tm_find_op (tctx->xptr, offset, size, false);if (!xto) {qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid read access to TIMA" "@%" HWADDR_PRIx" size %d\n" , offset, size);@@ -860,7 +895,6 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,/* * Then, for special operations in the region below 2K. */ - xto =xive_tm_find_op (tctx->xptr, offset, size, false);if (xto) { ret = xto->read_handler (xptr, tctx, offset, size); goto out;include/hw/ppc/xive.h +1
-0@@ -365,6 +365,7 @@ static inline uint32_t xive_tctx_word2(uint8_t *ring)return *((uint32_t *) &ring[TM_WORD2 ]); } +bool xive_ring_valid (XiveTCTX *tctx,uint8_t ring);bool xive_nsr_indicates_exception (uint8_t ring,uint8_t nsr);bool xive_nsr_indicates_group_exception (uint8_t ring,uint8_t nsr);uint8_t xive_nsr_exception_ring (uint8_t ring,uint8_t nsr);
PATCH 44/50 ppc/xive2: Implement pool context push TIMA op
In reply to Nicholas PigginImplement pool context push TIMA op.
--- hw/intc/xive.c | 4 ++++ hw/intc/xive2.c | 50 ++++++++++++++++++++++++++++-------------- include/hw/ppc/xive2.h | 2 ++ 3 files changed, 39 insertions(+), 17 deletions(-)
hw/intc/xive.c +4 -0
@@ -733,6 +733,10 @@ static const XiveTmOp xive2_tm_operations[] = { xive2_tm_push_os_ctx, NULL }, { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, true, true, xive_tm_set_os_lgs, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 4, true, true, + xive2_tm_push_pool_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 8, true, true, + xive2_tm_push_pool_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true,
hw/intc/xive2.c +33 -17
104 lines not on this page · raw message
include/hw/ppc/xive2.h +2 -0
@@ -140,6 +140,8 @@ bool xive2_tm_irq_precluded(XiveTCTX *tctx, int ring, uint8_t priority);void xive2_tm_set_lsmfb (XiveTCTX *tctx,int ring,uint8_t priority);void xive2_tm_set_hv_target (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); +void xive2_tm_push_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);uint64_t xive2_tm_pull_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); uint64_t xive2_tm_pull_phys_ctx(XivePresenter *xptr, XiveTCTX *tctx,
Signature · 1 line
2.47.1
Re: [PATCH 44/50] ppc/xive2: Implement pool context push TIMA op
Quoted 1 line · Nicholas Piggin
Implement pool context push TIMA op.
Thanks, MAK
Quoted 148 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 4 ++++ hw/intc/xive2.c | 50 ++++++++++++++++++++++++++++-------------- include/hw/ppc/xive2.h | 2 ++ 3 files changed, 39 insertions(+), 17 deletions(-)hw/intc/xive.c +4
-0@@ -733,6 +733,10 @@ static const XiveTmOp xive2_tm_operations[] = { xive2_tm_push_os_ctx, NULL }, { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, true, true, xive_tm_set_os_lgs, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 4, true, true, + xive2_tm_push_pool_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 8, true, true, + xive2_tm_push_pool_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true,hw/intc/xive2.c +33
-17@@ -583,6 +583,7 @@ static void xive2_tctx_save_ctx(Xive2Router *xrtr, XiveTCTX *tctx,xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, &nvp,1 ); } +/* POOL cam is the same as OS cam encoding */ static void xive2_cam_decode (uint32_t cam,uint8_t *nvp_blk,uint32_t *nvp_idx,bool *valid,bool *hw) {@@ -940,10 +941,11 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx, }static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx, +uint8_t ring,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -uint8_t *regs = &tctx->regs[TM_QW1_OS ]; +uint8_t *regs = &tctx->regs[ring];uint8_t ipb;Xive2Nvp nvp;@@ -965,7 +967,7 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx,/* Automatically restore thread context registers */ if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_restore) { -xive2_tctx_restore_ctx (xrtr, tctx,TM_QW1_OS , nvp_blk, nvp_idx, &nvp); +xive2_tctx_restore_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx, &nvp); } ipb =xive_get_field32 (NVP2_W2_IPB , nvp.w2);@@ -976,48 +978,62 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx,/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; -xive2_tctx_process_pending (tctx,TM_QW1_OS ); +xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? +TM_QW3_HV_PHYS : ring); }/* -* Updating the OS CAM line can trigger a resend of interrupt +* Updating the ring CAM line can trigger a resend of interrupt */ -void xive2_tm_push_os_ctx (XivePresenter *xptr,XiveTCTX *tctx, -hwaddr offset,uint64_t value,unsigned size) +static void xive2_tm_push_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size, +uint8_t ring) {uint32_t cam; -uint32_t qw1w2; -uint64_t qw1dw1; +uint32_t w2; +uint64_t dw1;uint8_t nvp_blk;uint32_t nvp_idx; -bool vo; +bool v;bool do_restore;/* First update the thead context */ switch (size) {case 4 : cam = value; - qw1w2 =cpu_to_be32 (cam); -memcpy (&tctx->regs[TM_QW1_OS +TM_WORD2 ], &qw1w2,4 ); + w2 =cpu_to_be32 (cam); +memcpy (&tctx->regs[ring +TM_WORD2 ], &w2,4 );break ;case 8 : cam = value >>32 ; - qw1dw1 =cpu_to_be64 (value); -memcpy (&tctx->regs[TM_QW1_OS +TM_WORD2 ], &qw1dw1,8 ); + dw1 =cpu_to_be64 (value); +memcpy (&tctx->regs[ring +TM_WORD2 ], &dw1,8 );break ;default :g_assert_not_reached (); } -xive2_cam_decode (cam, &nvp_blk, &nvp_idx, &vo, &do_restore); +xive2_cam_decode (cam, &nvp_blk, &nvp_idx, &v, &do_restore);/* Check the interrupt pending bits */ -if (vo) { -xive2_tctx_need_resend (XIVE2_ROUTER (xptr), tctx, nvp_blk, nvp_idx, - do_restore); +if (v) { +xive2_tctx_need_resend (XIVE2_ROUTER (xptr), tctx, ring, + nvp_blk, nvp_idx, do_restore); } } +void xive2_tm_push_os_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW1_OS ); +} + +void xive2_tm_push_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW2_HV_POOL ); +} +/* returns -1 if ring is invalid, but still populates block and index */ static int xive2_tctx_get_nvp_indexes (XiveTCTX *tctx,uint8_t ring,uint8_t *nvp_blk,uint32_t *nvp_idx)include/hw/ppc/xive2.h +2
-0@@ -140,6 +140,8 @@ bool xive2_tm_irq_precluded(XiveTCTX *tctx, int ring, uint8_t priority);void xive2_tm_set_lsmfb (XiveTCTX *tctx,int ring,uint8_t priority);void xive2_tm_set_hv_target (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); +void xive2_tm_push_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);uint64_t xive2_tm_pull_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); uint64_t xive2_tm_pull_phys_ctx(XivePresenter *xptr, XiveTCTX *tctx,
Re: [PATCH 44/50] ppc/xive2: Implement pool context push TIMA op
In reply to Nicholas PigginQuoted 149 lines · Nicholas Piggin
Implement pool context push TIMA op.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 4 ++++ hw/intc/xive2.c | 50 ++++++++++++++++++++++++++++-------------- include/hw/ppc/xive2.h | 2 ++ 3 files changed, 39 insertions(+), 17 deletions(-)hw/intc/xive.c +4
-0@@ -733,6 +733,10 @@ static const XiveTmOp xive2_tm_operations[] = { xive2_tm_push_os_ctx, NULL }, { XIVE_TM_OS_PAGE, TM_QW1_OS + TM_LGS, 1, true, true, xive_tm_set_os_lgs, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 4, true, true, + xive2_tm_push_pool_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 8, true, true, + xive2_tm_push_pool_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true,hw/intc/xive2.c +33
-17@@ -583,6 +583,7 @@ static void xive2_tctx_save_ctx(Xive2Router *xrtr, XiveTCTX *tctx,xive2_router_write_nvp (xrtr, nvp_blk, nvp_idx, &nvp,1 ); } +/* POOL cam is the same as OS cam encoding */ static void xive2_cam_decode (uint32_t cam,uint8_t *nvp_blk,uint32_t *nvp_idx,bool *valid,bool *hw) {@@ -940,10 +941,11 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx, }static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx, +uint8_t ring,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -uint8_t *regs = &tctx->regs[TM_QW1_OS ]; +uint8_t *regs = &tctx->regs[ring];uint8_t ipb;Xive2Nvp nvp;@@ -965,7 +967,7 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx,/* Automatically restore thread context registers */ if (xive2_router_get_config (xrtr) &XIVE2_VP_SAVE_RESTORE && do_restore) { -xive2_tctx_restore_ctx (xrtr, tctx,TM_QW1_OS , nvp_blk, nvp_idx, &nvp); +xive2_tctx_restore_ctx (xrtr, tctx, ring, nvp_blk, nvp_idx, &nvp); } ipb =xive_get_field32 (NVP2_W2_IPB , nvp.w2);@@ -976,48 +978,62 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx,/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; -xive2_tctx_process_pending (tctx,TM_QW1_OS ); +xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? +TM_QW3_HV_PHYS : ring); }/* -* Updating the OS CAM line can trigger a resend of interrupt +* Updating the ring CAM line can trigger a resend of interrupt */ -void xive2_tm_push_os_ctx (XivePresenter *xptr,XiveTCTX *tctx, -hwaddr offset,uint64_t value,unsigned size) +static void xive2_tm_push_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size, +uint8_t ring) {uint32_t cam; -uint32_t qw1w2; -uint64_t qw1dw1; +uint32_t w2; +uint64_t dw1;uint8_t nvp_blk;uint32_t nvp_idx; -bool vo; +bool v;bool do_restore;/* First update the thead context */ switch (size) {case 4 : cam = value; - qw1w2 =cpu_to_be32 (cam); -memcpy (&tctx->regs[TM_QW1_OS +TM_WORD2 ], &qw1w2,4 ); + w2 =cpu_to_be32 (cam); +memcpy (&tctx->regs[ring +TM_WORD2 ], &w2,4 );break ;case 8 : cam = value >>32 ; - qw1dw1 =cpu_to_be64 (value); -memcpy (&tctx->regs[TM_QW1_OS +TM_WORD2 ], &qw1dw1,8 ); + dw1 =cpu_to_be64 (value); +memcpy (&tctx->regs[ring +TM_WORD2 ], &dw1,8 );break ;default :g_assert_not_reached (); } -xive2_cam_decode (cam, &nvp_blk, &nvp_idx, &vo, &do_restore); +xive2_cam_decode (cam, &nvp_blk, &nvp_idx, &v, &do_restore);/* Check the interrupt pending bits */ -if (vo) { -xive2_tctx_need_resend (XIVE2_ROUTER (xptr), tctx, nvp_blk, nvp_idx, - do_restore); +if (v) { +xive2_tctx_need_resend (XIVE2_ROUTER (xptr), tctx, ring, + nvp_blk, nvp_idx, do_restore); } } +void xive2_tm_push_os_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW1_OS ); +} + +void xive2_tm_push_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW2_HV_POOL ); +} +/* returns -1 if ring is invalid, but still populates block and index */ static int xive2_tctx_get_nvp_indexes (XiveTCTX *tctx,uint8_t ring,uint8_t *nvp_blk,uint32_t *nvp_idx)include/hw/ppc/xive2.h +2
-0@@ -140,6 +140,8 @@ bool xive2_tm_irq_precluded(XiveTCTX *tctx, int ring, uint8_t priority);void xive2_tm_set_lsmfb (XiveTCTX *tctx,int ring,uint8_t priority);void xive2_tm_set_hv_target (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); +void xive2_tm_push_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);uint64_t xive2_tm_pull_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); uint64_t xive2_tm_pull_phys_ctx(XivePresenter *xptr, XiveTCTX *tctx,
PATCH 45/50 ppc/xive2: redistribute group interrupts on context push
In reply to Nicholas PigginWhen pushing a context, any presented group interrupt should be redistributed before processing pending interrupts to present highest priority.
This can occur when pushing the POOL ring when the valid PHYS ring has a group interrupt presented, because they share signal registers.
--- hw/intc/xive2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/intc/xive2.c +7 -1
@@ -945,8 +945,9 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, uint8_t nvp_blk, uint32_t nvp_idx, bool do_restore) { + uint8_t *sig_regs = xive_tctx_signal_regs(tctx, ring);uint8_t *regs = &tctx->regs[ring]; -uint8_t ipb; +uint8_t ipb, nsr = sig_regs[TM_NSR ];Xive2Nvp nvp;/*
@@ -978,6 +979,11 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx,/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; +if (xive_nsr_indicates_group_exception (ring, nsr)) { +/* redistribute precluded active grp interrupt */ +g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the grp interrupt */ +xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); + }xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ?TM_QW3_HV_PHYS : ring); }
Signature · 1 line
2.47.1
Re: [PATCH 45/50] ppc/xive2: redistribute group interrupts on context push
Quoted 7 lines · Nicholas Piggin
When pushing a context, any presented group interrupt should be redistributed before processing pending interrupts to present highest priority.
This can occur when pushing the POOL ring when the valid PHYS ring has a group interrupt presented, because they share signal registers.
Thanks, MAK
Quoted 33 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)hw/intc/xive2.c +7
-1@@ -945,8 +945,9 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, uint8_t nvp_blk, uint32_t nvp_idx, bool do_restore) { + uint8_t *sig_regs = xive_tctx_signal_regs(tctx, ring);uint8_t *regs = &tctx->regs[ring]; -uint8_t ipb; +uint8_t ipb, nsr = sig_regs[TM_NSR ];Xive2Nvp nvp;/* @@ -978,6 +979,11 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx,/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; +if (xive_nsr_indicates_group_exception (ring, nsr)) { +/* redistribute precluded active grp interrupt */ +g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the grp interrupt */ +xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); + }xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ?TM_QW3_HV_PHYS : ring); }
Re: [PATCH 45/50] ppc/xive2: redistribute group interrupts on context push
In reply to Nicholas PigginQuoted 40 lines · Nicholas Piggin
When pushing a context, any presented group interrupt should be redistributed before processing pending interrupts to present highest priority.
This can occur when pushing the POOL ring when the valid PHYS ring has a group interrupt presented, because they share signal registers.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)hw/intc/xive2.c +7
-1@@ -945,8 +945,9 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, uint8_t nvp_blk, uint32_t nvp_idx, bool do_restore) { + uint8_t *sig_regs = xive_tctx_signal_regs(tctx, ring);uint8_t *regs = &tctx->regs[ring]; -uint8_t ipb; +uint8_t ipb, nsr = sig_regs[TM_NSR ];Xive2Nvp nvp;/* @@ -978,6 +979,11 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx,/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; +if (xive_nsr_indicates_group_exception (ring, nsr)) { +/* redistribute precluded active grp interrupt */ +g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the grp interrupt */ +xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); + }xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ?TM_QW3_HV_PHYS : ring); }
PATCH 46/50 ppc/xive2: Implement set_os_pending TIMA op
In reply to Nicholas Pigginxive2 must take into account redistribution of group interrupts if the VP directed priority exceeds the group interrupt priority after this operation. The xive1 code is not group aware so implement this for xive2.
--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 28 ++++++++++++++++++++++++++++ include/hw/ppc/xive2.h | 2 ++ 3 files changed, 32 insertions(+)
hw/intc/xive.c +2 -0
@@ -747,6 +747,8 @@ static const XiveTmOp xive2_tm_operations[] = {/* MMIOs above 2K : special operations with side effects */ {XIVE_TM_OS_PAGE ,TM_SPC_ACK_OS_REG ,2 , true, false, NULL, xive_tm_ack_os_reg }, + { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, true, false, + xive2_tm_set_os_pending, NULL }, { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, true, false, NULL, xive2_tm_pull_os_ctx }, { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false,
hw/intc/xive2.c +28 -0
@@ -1323,6 +1323,34 @@ void xive2_tm_set_os_cppr(XivePresenter *xptr, XiveTCTX *tctx,xive2_tctx_set_cppr (tctx,TM_QW1_OS , value &0xff ); } +/* +* Adjust the IPB to allow a CPU to process event queues of other +* priorities during one physical interrupt cycle. +*/ +void xive2_tm_set_os_pending (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +Xive2Router *xrtr =XIVE2_ROUTER (xptr); +uint8_t ring =TM_QW1_OS ; +uint8_t *regs = &tctx->regs[ring]; +uint8_t priority = value &0xff ; + +/* +* XXX: should this simply set a bit in IPB and wait for it to be picked +* up next cycle, or is it supposed to present it now? We implement the +* latter here. +*/ + regs[TM_IPB ] |=xive_priority_to_ipb (priority); +if (xive_ipb_to_pipr (regs[TM_IPB ]) >= regs[TM_PIPR ]) { +return ; + } +if (xive_nsr_indicates_group_exception (ring, regs[TM_NSR ])) { +xive2_redistribute (xrtr, tctx, ring); + } + +xive_tctx_pipr_present (tctx, ring, priority,0 ); +} +static void xive2_tctx_set_target (XiveTCTX *tctx,uint8_t ring,uint8_t target) {uint8_t *regs = &tctx->regs[ring];
include/hw/ppc/xive2.h +2 -0
@@ -130,6 +130,8 @@ void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size);void xive2_tm_set_os_cppr (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); +void xive2_tm_set_os_pending (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);void xive2_tm_push_os_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); uint64_t xive2_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,
Signature · 1 line
2.47.1
Re: [PATCH 46/50] ppc/xive2: Implement set_os_pending TIMA op
Quoted 4 lines · Nicholas Piggin
xive2 must take into account redistribution of group interrupts if the VP directed priority exceeds the group interrupt priority after this operation. The xive1 code is not group aware so implement this for xive2.
Thanks, MAK
Quoted 73 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 28 ++++++++++++++++++++++++++++ include/hw/ppc/xive2.h | 2 ++ 3 files changed, 32 insertions(+)hw/intc/xive.c +2
-0@@ -747,6 +747,8 @@ static const XiveTmOp xive2_tm_operations[] = {/* MMIOs above 2K : special operations with side effects */ {XIVE_TM_OS_PAGE ,TM_SPC_ACK_OS_REG ,2 , true, false, NULL, xive_tm_ack_os_reg }, + { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, true, false, + xive2_tm_set_os_pending, NULL }, { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, true, false, NULL, xive2_tm_pull_os_ctx }, { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false,hw/intc/xive2.c +28
-0@@ -1323,6 +1323,34 @@ void xive2_tm_set_os_cppr(XivePresenter *xptr, XiveTCTX *tctx,xive2_tctx_set_cppr (tctx,TM_QW1_OS , value &0xff ); } +/* +* Adjust the IPB to allow a CPU to process event queues of other +* priorities during one physical interrupt cycle. +*/ +void xive2_tm_set_os_pending (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +Xive2Router *xrtr =XIVE2_ROUTER (xptr); +uint8_t ring =TM_QW1_OS ; +uint8_t *regs = &tctx->regs[ring]; +uint8_t priority = value &0xff ; + +/* +* XXX: should this simply set a bit in IPB and wait for it to be picked +* up next cycle, or is it supposed to present it now? We implement the +* latter here. +*/ + regs[TM_IPB ] |=xive_priority_to_ipb (priority); +if (xive_ipb_to_pipr (regs[TM_IPB ]) >= regs[TM_PIPR ]) { +return ; + } +if (xive_nsr_indicates_group_exception (ring, regs[TM_NSR ])) { +xive2_redistribute (xrtr, tctx, ring); + } + +xive_tctx_pipr_present (tctx, ring, priority,0 ); +} +static void xive2_tctx_set_target (XiveTCTX *tctx,uint8_t ring,uint8_t target) {uint8_t *regs = &tctx->regs[ring];include/hw/ppc/xive2.h +2
-0@@ -130,6 +130,8 @@ void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size);void xive2_tm_set_os_cppr (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); +void xive2_tm_set_os_pending (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);void xive2_tm_push_os_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); uint64_t xive2_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,
Re: [PATCH 46/50] ppc/xive2: Implement set_os_pending TIMA op
In reply to Nicholas PigginQuoted 77 lines · Nicholas Piggin
xive2 must take into account redistribution of group interrupts if the VP directed priority exceeds the group interrupt priority after this operation. The xive1 code is not group aware so implement this for xive2.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 28 ++++++++++++++++++++++++++++ include/hw/ppc/xive2.h | 2 ++ 3 files changed, 32 insertions(+)hw/intc/xive.c +2
-0@@ -747,6 +747,8 @@ static const XiveTmOp xive2_tm_operations[] = {/* MMIOs above 2K : special operations with side effects */ {XIVE_TM_OS_PAGE ,TM_SPC_ACK_OS_REG ,2 , true, false, NULL, xive_tm_ack_os_reg }, + { XIVE_TM_OS_PAGE, TM_SPC_SET_OS_PENDING, 1, true, false, + xive2_tm_set_os_pending, NULL }, { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX_G2, 4, true, false, NULL, xive2_tm_pull_os_ctx }, { XIVE_TM_HV_PAGE, TM_SPC_PULL_OS_CTX, 4, true, false,hw/intc/xive2.c +28
-0@@ -1323,6 +1323,34 @@ void xive2_tm_set_os_cppr(XivePresenter *xptr, XiveTCTX *tctx,xive2_tctx_set_cppr (tctx,TM_QW1_OS , value &0xff ); } +/* +* Adjust the IPB to allow a CPU to process event queues of other +* priorities during one physical interrupt cycle. +*/ +void xive2_tm_set_os_pending (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +Xive2Router *xrtr =XIVE2_ROUTER (xptr); +uint8_t ring =TM_QW1_OS ; +uint8_t *regs = &tctx->regs[ring]; +uint8_t priority = value &0xff ; + +/* +* XXX: should this simply set a bit in IPB and wait for it to be picked +* up next cycle, or is it supposed to present it now? We implement the +* latter here. +*/ + regs[TM_IPB ] |=xive_priority_to_ipb (priority); +if (xive_ipb_to_pipr (regs[TM_IPB ]) >= regs[TM_PIPR ]) { +return ; + } +if (xive_nsr_indicates_group_exception (ring, regs[TM_NSR ])) { +xive2_redistribute (xrtr, tctx, ring); + } + +xive_tctx_pipr_present (tctx, ring, priority,0 ); +} +static void xive2_tctx_set_target (XiveTCTX *tctx,uint8_t ring,uint8_t target) {uint8_t *regs = &tctx->regs[ring];include/hw/ppc/xive2.h +2
-0@@ -130,6 +130,8 @@ void xive2_tm_set_hv_cppr(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size);void xive2_tm_set_os_cppr (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); +void xive2_tm_set_os_pending (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);void xive2_tm_push_os_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,uint64_t value,unsigned size); uint64_t xive2_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,
PATCH 47/50 ppc/xive2: Implement POOL LGS push TIMA op
In reply to Nicholas PigginImplement set LGS for the POOL ring.
--- hw/intc/xive.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/intc/xive.c +8 -0
@@ -532,6 +532,12 @@ static void xive_tm_set_os_lgs(XivePresenter *xptr, XiveTCTX *tctx,xive_tctx_set_lgs (tctx,TM_QW1_OS , value &0xff ); } +static void xive_tm_set_pool_lgs (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive_tctx_set_lgs (tctx,TM_QW2_HV_POOL , value &0xff ); +} +/* * Adjust the PIPR to allow a CPU to process event queues of other * priorities during one physical interrupt cycle.
@@ -737,6 +743,8 @@ static const XiveTmOp xive2_tm_operations[] = { xive2_tm_push_pool_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 8, true, true, xive2_tm_push_pool_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_LGS, 1, true, true, + xive_tm_set_pool_lgs, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true,
Signature · 1 line
2.47.1
Re: [PATCH 47/50] ppc/xive2: Implement POOL LGS push TIMA op
Quoted 1 line · Nicholas Piggin
Implement set LGS for the POOL ring.
Thanks, MAK
Quoted 32 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/intc/xive.c +8
-0@@ -532,6 +532,12 @@ static void xive_tm_set_os_lgs(XivePresenter *xptr, XiveTCTX *tctx,xive_tctx_set_lgs (tctx,TM_QW1_OS , value &0xff ); } +static void xive_tm_set_pool_lgs (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive_tctx_set_lgs (tctx,TM_QW2_HV_POOL , value &0xff ); +} +/* * Adjust the PIPR to allow a CPU to process event queues of other * priorities during one physical interrupt cycle. @@ -737,6 +743,8 @@ static const XiveTmOp xive2_tm_operations[] = { xive2_tm_push_pool_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 8, true, true, xive2_tm_push_pool_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_LGS, 1, true, true, + xive_tm_set_pool_lgs, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true,
Re: [PATCH 47/50] ppc/xive2: Implement POOL LGS push TIMA op
In reply to Nicholas PigginQuoted 33 lines · Nicholas Piggin
Implement set LGS for the POOL ring.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/intc/xive.c +8
-0@@ -532,6 +532,12 @@ static void xive_tm_set_os_lgs(XivePresenter *xptr, XiveTCTX *tctx,xive_tctx_set_lgs (tctx,TM_QW1_OS , value &0xff ); } +static void xive_tm_set_pool_lgs (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive_tctx_set_lgs (tctx,TM_QW2_HV_POOL , value &0xff ); +} +/* * Adjust the PIPR to allow a CPU to process event queues of other * priorities during one physical interrupt cycle. @@ -737,6 +743,8 @@ static const XiveTmOp xive2_tm_operations[] = { xive2_tm_push_pool_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_WORD2, 8, true, true, xive2_tm_push_pool_ctx, NULL }, + { XIVE_TM_HV_PAGE, TM_QW2_HV_POOL + TM_LGS, 1, true, true, + xive_tm_set_pool_lgs, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true,
PATCH 48/50 ppc/xive2: Implement PHYS ring VP push TIMA op
In reply to Nicholas PigginImplement the phys (aka hard) VP push. PowerVM uses this operation.
--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 11 +++++++++++ include/hw/ppc/xive2.h | 2 ++ 3 files changed, 15 insertions(+)
hw/intc/xive.c +2 -0
@@ -747,6 +747,8 @@ static const XiveTmOp xive2_tm_operations[] = { xive_tm_set_pool_lgs, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, false, true, + xive2_tm_push_phys_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, NULL, xive_tm_vt_poll }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, true, true,
hw/intc/xive2.c +11 -0
@@ -1005,6 +1005,11 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* First update the thead context */ switch (size) { +case 1 : + tctx->regs[ring +TM_WORD2 ] = value &0xff ; + cam =xive2_tctx_hw_cam_line (xptr, tctx); + cam |= ((value &0xc0 ) <<24 );/* V and H bits */ +break ;case 4 : cam = value; w2 =cpu_to_be32 (cam);
@@ -1040,6 +1045,12 @@ void xive2_tm_push_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW2_HV_POOL ); } +void xive2_tm_push_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW3_HV_PHYS ); +} +/* returns -1 if ring is invalid, but still populates block and index */ static int xive2_tctx_get_nvp_indexes (XiveTCTX *tctx,uint8_t ring,uint8_t *nvp_blk,uint32_t *nvp_idx)
include/hw/ppc/xive2.h +2 -0
@@ -146,6 +146,8 @@ void xive2_tm_push_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size);uint64_t xive2_tm_pull_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); +void xive2_tm_push_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);uint64_t xive2_tm_pull_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); void xive2_tm_pull_phys_ctx_ol(XivePresenter *xptr, XiveTCTX *tctx,
Signature · 1 line
2.47.1
Re: [PATCH 48/50] ppc/xive2: Implement PHYS ring VP push TIMA op
Quoted 1 line · Nicholas Piggin
Implement the phys (aka hard) VP push. PowerVM uses this operation.
Thanks, MAK
Quoted 63 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 11 +++++++++++ include/hw/ppc/xive2.h | 2 ++ 3 files changed, 15 insertions(+)hw/intc/xive.c +2
-0@@ -747,6 +747,8 @@ static const XiveTmOp xive2_tm_operations[] = { xive_tm_set_pool_lgs, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, false, true, + xive2_tm_push_phys_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, NULL, xive_tm_vt_poll }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, true, true,hw/intc/xive2.c +11
-0@@ -1005,6 +1005,11 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* First update the thead context */ switch (size) { +case 1 : + tctx->regs[ring +TM_WORD2 ] = value &0xff ; + cam =xive2_tctx_hw_cam_line (xptr, tctx); + cam |= ((value &0xc0 ) <<24 );/* V and H bits */ +break ;case 4 : cam = value; w2 =cpu_to_be32 (cam);@@ -1040,6 +1045,12 @@ void xive2_tm_push_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW2_HV_POOL ); } +void xive2_tm_push_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW3_HV_PHYS ); +} +/* returns -1 if ring is invalid, but still populates block and index */ static int xive2_tctx_get_nvp_indexes (XiveTCTX *tctx,uint8_t ring,uint8_t *nvp_blk,uint32_t *nvp_idx)include/hw/ppc/xive2.h +2
-0@@ -146,6 +146,8 @@ void xive2_tm_push_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size);uint64_t xive2_tm_pull_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); +void xive2_tm_push_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);uint64_t xive2_tm_pull_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); void xive2_tm_pull_phys_ctx_ol(XivePresenter *xptr, XiveTCTX *tctx,
Re: [PATCH 48/50] ppc/xive2: Implement PHYS ring VP push TIMA op
In reply to Nicholas PigginQuoted 64 lines · Nicholas Piggin
Implement the phys (aka hard) VP push. PowerVM uses this operation.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 2 ++ hw/intc/xive2.c | 11 +++++++++++ include/hw/ppc/xive2.h | 2 ++ 3 files changed, 15 insertions(+)hw/intc/xive.c +2
-0@@ -747,6 +747,8 @@ static const XiveTmOp xive2_tm_operations[] = { xive_tm_set_pool_lgs, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_CPPR, 1, true, true, xive2_tm_set_hv_cppr, NULL }, + { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, false, true, + xive2_tm_push_phys_ctx, NULL }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_WORD2, 1, true, true, NULL, xive_tm_vt_poll }, { XIVE_TM_HV_PAGE, TM_QW3_HV_PHYS + TM_T, 1, true, true,hw/intc/xive2.c +11
-0@@ -1005,6 +1005,11 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* First update the thead context */ switch (size) { +case 1 : + tctx->regs[ring +TM_WORD2 ] = value &0xff ; + cam =xive2_tctx_hw_cam_line (xptr, tctx); + cam |= ((value &0xc0 ) <<24 );/* V and H bits */ +break ;case 4 : cam = value; w2 =cpu_to_be32 (cam);@@ -1040,6 +1045,12 @@ void xive2_tm_push_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx,xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW2_HV_POOL ); } +void xive2_tm_push_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size) +{ +xive2_tm_push_ctx (xptr, tctx, offset, value, size,TM_QW3_HV_PHYS ); +} +/* returns -1 if ring is invalid, but still populates block and index */ static int xive2_tctx_get_nvp_indexes (XiveTCTX *tctx,uint8_t ring,uint8_t *nvp_blk,uint32_t *nvp_idx)include/hw/ppc/xive2.h +2
-0@@ -146,6 +146,8 @@ void xive2_tm_push_pool_ctx(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset, uint64_t value, unsigned size);uint64_t xive2_tm_pull_pool_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); +void xive2_tm_push_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx, +hwaddr offset,uint64_t value,unsigned size);uint64_t xive2_tm_pull_phys_ctx (XivePresenter *xptr,XiveTCTX *tctx,hwaddr offset,unsigned size); void xive2_tm_pull_phys_ctx_ol(XivePresenter *xptr, XiveTCTX *tctx,
PATCH 49/50 ppc/xive: Split need_resend into restore_nvp
In reply to Nicholas PigginThis is needed by the next patch which will re-send on all lower rings when pushing a context.
--- hw/intc/xive.c | 24 ++++++++++++------------ hw/intc/xive2.c | 28 ++++++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-)
hw/intc/xive.c +12 -12
@@ -606,7 +606,7 @@ static uint64_t xive_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,return qw1w2; } -static void xive_tctx_need_resend (XiveRouter *xrtr,XiveTCTX *tctx, +static void xive_tctx_restore_nvp (XiveRouter *xrtr,XiveTCTX *tctx,uint8_t nvt_blk,uint32_t nvt_idx) {XiveNVT nvt;
@@ -632,16 +632,6 @@ static void xive_tctx_need_resend(XiveRouter *xrtr, XiveTCTX *tctx,uint8_t *regs = &tctx->regs[TM_QW1_OS ]; regs[TM_IPB ] |= ipb; } - -/* -* Always call xive_tctx_recompute_from_ipb(). Even if there were no -* escalation triggered, there could be a pending interrupt which -* was saved when the context was pulled and that we need to take -* into account by recalculating the PIPR (which is not -* saved/restored). -* It will also raise the External interrupt signal if needed. -*/ -xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW1_OS );/* fxb */ }/*
@@ -663,7 +653,17 @@ static void xive_tm_push_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (vo) { -xive_tctx_need_resend (XIVE_ROUTER (xptr), tctx, nvt_blk, nvt_idx); +xive_tctx_restore_nvp (XIVE_ROUTER (xptr), tctx, nvt_blk, nvt_idx); + +/* +* Always call xive_tctx_recompute_from_ipb(). Even if there were no +* escalation triggered, there could be a pending interrupt which +* was saved when the context was pulled and that we need to take +* into account by recalculating the PIPR (which is not +* saved/restored). +* It will also raise the External interrupt signal if needed. +*/ +xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW1_OS );/* fxb */ } }
hw/intc/xive2.c +16 -12
@@ -940,14 +940,14 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } -static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx, +/* Restore TIMA VP context from NVP backlog */ +static void xive2_tctx_restore_nvp (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t ring,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; -uint8_t ipb, nsr = sig_regs[TM_NSR ]; +uint8_t ipb;Xive2Nvp nvp;/*
@@ -978,14 +978,6 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; - -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the grp interrupt */ -xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); - } -xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? -TM_QW3_HV_PHYS : ring); }/*
@@ -1028,8 +1020,20 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (v) { -xive2_tctx_need_resend (XIVE2_ROUTER (xptr), tctx, ring, +Xive2Router *xrtr =XIVE2_ROUTER (xptr); +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); +uint8_t nsr = sig_regs[TM_NSR ]; + +xive2_tctx_restore_nvp (xrtr, tctx, ring, nvp_blk, nvp_idx, do_restore); + +if (xive_nsr_indicates_group_exception (ring, nsr)) { +/* redistribute precluded active grp interrupt */ +g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the interrupt */ +xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); + } +xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? +TM_QW3_HV_PHYS : ring); } }
Signature · 1 line
2.47.1
Re: [PATCH 49/50] ppc/xive: Split need_resend into restore_nvp
Quoted 2 lines · Nicholas Piggin
This is needed by the next patch which will re-send on all lower rings when pushing a context.
Thanks, MAK
Quoted 115 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 24 ++++++++++++------------ hw/intc/xive2.c | 28 ++++++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-)hw/intc/xive.c +12
-12@@ -606,7 +606,7 @@ static uint64_t xive_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,return qw1w2; } -static void xive_tctx_need_resend (XiveRouter *xrtr,XiveTCTX *tctx, +static void xive_tctx_restore_nvp (XiveRouter *xrtr,XiveTCTX *tctx,uint8_t nvt_blk,uint32_t nvt_idx) {XiveNVT nvt;@@ -632,16 +632,6 @@ static void xive_tctx_need_resend(XiveRouter *xrtr, XiveTCTX *tctx,uint8_t *regs = &tctx->regs[TM_QW1_OS ]; regs[TM_IPB ] |= ipb; } - -/* -* Always call xive_tctx_recompute_from_ipb(). Even if there were no -* escalation triggered, there could be a pending interrupt which -* was saved when the context was pulled and that we need to take -* into account by recalculating the PIPR (which is not -* saved/restored). -* It will also raise the External interrupt signal if needed. -*/ -xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW1_OS );/* fxb */ }/* @@ -663,7 +653,17 @@ static void xive_tm_push_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (vo) { -xive_tctx_need_resend (XIVE_ROUTER (xptr), tctx, nvt_blk, nvt_idx); +xive_tctx_restore_nvp (XIVE_ROUTER (xptr), tctx, nvt_blk, nvt_idx); + +/* +* Always call xive_tctx_recompute_from_ipb(). Even if there were no +* escalation triggered, there could be a pending interrupt which +* was saved when the context was pulled and that we need to take +* into account by recalculating the PIPR (which is not +* saved/restored). +* It will also raise the External interrupt signal if needed. +*/ +xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW1_OS );/* fxb */ } }hw/intc/xive2.c +16
-12@@ -940,14 +940,14 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } -static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx, +/* Restore TIMA VP context from NVP backlog */ +static void xive2_tctx_restore_nvp (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t ring,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; -uint8_t ipb, nsr = sig_regs[TM_NSR ]; +uint8_t ipb;Xive2Nvp nvp;/* @@ -978,14 +978,6 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; - -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the grp interrupt */ -xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); - } -xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? -TM_QW3_HV_PHYS : ring); }/* @@ -1028,8 +1020,20 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (v) { -xive2_tctx_need_resend (XIVE2_ROUTER (xptr), tctx, ring, +Xive2Router *xrtr =XIVE2_ROUTER (xptr); +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); +uint8_t nsr = sig_regs[TM_NSR ]; + +xive2_tctx_restore_nvp (xrtr, tctx, ring, nvp_blk, nvp_idx, do_restore); + +if (xive_nsr_indicates_group_exception (ring, nsr)) { +/* redistribute precluded active grp interrupt */ +g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the interrupt */ +xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); + } +xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? +TM_QW3_HV_PHYS : ring); } }
Re: [PATCH 49/50] ppc/xive: Split need_resend into restore_nvp
In reply to Nicholas PigginQuoted 117 lines · Nicholas Piggin
This is needed by the next patch which will re-send on all lower rings when pushing a context.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive.c | 24 ++++++++++++------------ hw/intc/xive2.c | 28 ++++++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-)hw/intc/xive.c +12
-12@@ -606,7 +606,7 @@ static uint64_t xive_tm_pull_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,return qw1w2; } -static void xive_tctx_need_resend (XiveRouter *xrtr,XiveTCTX *tctx, +static void xive_tctx_restore_nvp (XiveRouter *xrtr,XiveTCTX *tctx,uint8_t nvt_blk,uint32_t nvt_idx) {XiveNVT nvt;@@ -632,16 +632,6 @@ static void xive_tctx_need_resend(XiveRouter *xrtr, XiveTCTX *tctx,uint8_t *regs = &tctx->regs[TM_QW1_OS ]; regs[TM_IPB ] |= ipb; } - -/* -* Always call xive_tctx_recompute_from_ipb(). Even if there were no -* escalation triggered, there could be a pending interrupt which -* was saved when the context was pulled and that we need to take -* into account by recalculating the PIPR (which is not -* saved/restored). -* It will also raise the External interrupt signal if needed. -*/ -xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW1_OS );/* fxb */ }/* @@ -663,7 +653,17 @@ static void xive_tm_push_os_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (vo) { -xive_tctx_need_resend (XIVE_ROUTER (xptr), tctx, nvt_blk, nvt_idx); +xive_tctx_restore_nvp (XIVE_ROUTER (xptr), tctx, nvt_blk, nvt_idx); + +/* +* Always call xive_tctx_recompute_from_ipb(). Even if there were no +* escalation triggered, there could be a pending interrupt which +* was saved when the context was pulled and that we need to take +* into account by recalculating the PIPR (which is not +* saved/restored). +* It will also raise the External interrupt signal if needed. +*/ +xive_tctx_pipr_recompute_from_ipb (tctx,TM_QW1_OS );/* fxb */ } }hw/intc/xive2.c +16
-12@@ -940,14 +940,14 @@ static uint8_t xive2_tctx_restore_ctx(Xive2Router *xrtr, XiveTCTX *tctx,return cppr; } -static void xive2_tctx_need_resend (Xive2Router *xrtr,XiveTCTX *tctx, +/* Restore TIMA VP context from NVP backlog */ +static void xive2_tctx_restore_nvp (Xive2Router *xrtr,XiveTCTX *tctx,uint8_t ring,uint8_t nvp_blk,uint32_t nvp_idx,bool do_restore) { -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring);uint8_t *regs = &tctx->regs[ring]; -uint8_t ipb, nsr = sig_regs[TM_NSR ]; +uint8_t ipb;Xive2Nvp nvp;/* @@ -978,14 +978,6 @@ static void xive2_tctx_need_resend(Xive2Router *xrtr, XiveTCTX *tctx, }/* IPB bits in the backlog are merged with the TIMA IPB bits */ regs[TM_IPB ] |= ipb; - -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the grp interrupt */ -xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); - } -xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? -TM_QW3_HV_PHYS : ring); }/* @@ -1028,8 +1020,20 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (v) { -xive2_tctx_need_resend (XIVE2_ROUTER (xptr), tctx, ring, +Xive2Router *xrtr =XIVE2_ROUTER (xptr); +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); +uint8_t nsr = sig_regs[TM_NSR ]; + +xive2_tctx_restore_nvp (xrtr, tctx, ring, nvp_blk, nvp_idx, do_restore); + +if (xive_nsr_indicates_group_exception (ring, nsr)) { +/* redistribute precluded active grp interrupt */ +g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the interrupt */ +xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); + } +xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? +TM_QW3_HV_PHYS : ring); } }
PATCH 50/50 ppc/xive2: Enable lower level contexts on VP push
In reply to Nicholas PigginWhen pushing a context, the lower-level context becomes valid if it had V=1, and so on. Iterate lower level contexts and send them pending interrupts if they become enabled.
--- hw/intc/xive2.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
hw/intc/xive2.c +28 -8
@@ -995,6 +995,12 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,bool v;bool do_restore; +if (xive_ring_valid (tctx, ring)) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: Attempt to push VP to enabled" +" ring 0x%02x\n" , ring); +return ; + } +/* First update the thead context */ switch (size) {case 1 :
@@ -1021,19 +1027,32 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (v) {Xive2Router *xrtr =XIVE2_ROUTER (xptr); -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); -uint8_t nsr = sig_regs[TM_NSR ]; +uint8_t cur_ring;xive2_tctx_restore_nvp (xrtr, tctx, ring, nvp_blk, nvp_idx, do_restore); -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the interrupt */ -xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); +for (cur_ring =TM_QW1_OS ; cur_ring <= ring; + cur_ring +=XIVE_TM_RING_SIZE ) { +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, cur_ring); +uint8_t nsr = sig_regs[TM_NSR ]; + +if (!xive_ring_valid (tctx, cur_ring)) { +continue ; + } + +if (cur_ring ==TM_QW2_HV_POOL ) { +if (xive_nsr_indicates_exception (cur_ring, nsr)) { +g_assert (xive_nsr_exception_ring (cur_ring, nsr) == +TM_QW3_HV_PHYS ); +xive2_redistribute (xrtr, tctx, +xive_nsr_exception_ring (ring, nsr)); + } +xive2_tctx_process_pending (tctx,TM_QW3_HV_PHYS ); +break ; + } +xive2_tctx_process_pending (tctx, cur_ring); } -xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? -TM_QW3_HV_PHYS : ring); } }
@@ -1159,6 +1178,7 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring)int rc;g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS ); +g_assert (sig_regs[TM_WORD2 ] &0x80 );g_assert (!xive_nsr_indicates_group_exception (sig_ring, sig_regs[TM_NSR ]));/*
Signature · 1 line
2.47.1
Re: [PATCH 50/50] ppc/xive2: Enable lower level contexts on VP push
Quoted 3 lines · Nicholas Piggin
When pushing a context, the lower-level context becomes valid if it had V=1, and so on. Iterate lower level contexts and send them pending interrupts if they become enabled.
Thanks, MAK
Quoted 72 lines
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)hw/intc/xive2.c +28
-8@@ -995,6 +995,12 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,bool v;bool do_restore; +if (xive_ring_valid (tctx, ring)) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: Attempt to push VP to enabled" +" ring 0x%02x\n" , ring); +return ; + } +/* First update the thead context */ switch (size) {case 1 :@@ -1021,19 +1027,32 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (v) {Xive2Router *xrtr =XIVE2_ROUTER (xptr); -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); -uint8_t nsr = sig_regs[TM_NSR ]; +uint8_t cur_ring;xive2_tctx_restore_nvp (xrtr, tctx, ring, nvp_blk, nvp_idx, do_restore); -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the interrupt */ -xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); +for (cur_ring =TM_QW1_OS ; cur_ring <= ring; + cur_ring +=XIVE_TM_RING_SIZE ) { +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, cur_ring); +uint8_t nsr = sig_regs[TM_NSR ]; + +if (!xive_ring_valid (tctx, cur_ring)) { +continue ; + } + +if (cur_ring ==TM_QW2_HV_POOL ) { +if (xive_nsr_indicates_exception (cur_ring, nsr)) { +g_assert (xive_nsr_exception_ring (cur_ring, nsr) == +TM_QW3_HV_PHYS ); +xive2_redistribute (xrtr, tctx, +xive_nsr_exception_ring (ring, nsr)); + } +xive2_tctx_process_pending (tctx,TM_QW3_HV_PHYS ); +break ; + } +xive2_tctx_process_pending (tctx, cur_ring); } -xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? -TM_QW3_HV_PHYS : ring); } }@@ -1159,6 +1178,7 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring)int rc;g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS ); +g_assert (sig_regs[TM_WORD2 ] &0x80 );g_assert (!xive_nsr_indicates_group_exception (sig_ring, sig_regs[TM_NSR ]));/*
Re: [PATCH 50/50] ppc/xive2: Enable lower level contexts on VP push
In reply to Nicholas PigginQuoted 75 lines · Nicholas Piggin
When pushing a context, the lower-level context becomes valid if it had V=1, and so on. Iterate lower level contexts and send them pending interrupts if they become enabled.
Signed-off-by Nicholas Piggin <[email protected]>--- hw/intc/xive2.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)hw/intc/xive2.c +28
-8@@ -995,6 +995,12 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,bool v;bool do_restore; +if (xive_ring_valid (tctx, ring)) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: Attempt to push VP to enabled" +" ring 0x%02x\n" , ring); +return ; + } +/* First update the thead context */ switch (size) {case 1 :@@ -1021,19 +1027,32 @@ static void xive2_tm_push_ctx(XivePresenter *xptr, XiveTCTX *tctx,/* Check the interrupt pending bits */ if (v) {Xive2Router *xrtr =XIVE2_ROUTER (xptr); -uint8_t *sig_regs =xive_tctx_signal_regs (tctx, ring); -uint8_t nsr = sig_regs[TM_NSR ]; +uint8_t cur_ring;xive2_tctx_restore_nvp (xrtr, tctx, ring, nvp_blk, nvp_idx, do_restore); -if (xive_nsr_indicates_group_exception (ring, nsr)) { -/* redistribute precluded active grp interrupt */ -g_assert (ring ==TM_QW2_HV_POOL );/* PHYS ring has the interrupt */ -xive2_redistribute (xrtr, tctx,xive_nsr_exception_ring (ring, nsr)); +for (cur_ring =TM_QW1_OS ; cur_ring <= ring; + cur_ring +=XIVE_TM_RING_SIZE ) { +uint8_t *sig_regs =xive_tctx_signal_regs (tctx, cur_ring); +uint8_t nsr = sig_regs[TM_NSR ]; + +if (!xive_ring_valid (tctx, cur_ring)) { +continue ; + } + +if (cur_ring ==TM_QW2_HV_POOL ) { +if (xive_nsr_indicates_exception (cur_ring, nsr)) { +g_assert (xive_nsr_exception_ring (cur_ring, nsr) == +TM_QW3_HV_PHYS ); +xive2_redistribute (xrtr, tctx, +xive_nsr_exception_ring (ring, nsr)); + } +xive2_tctx_process_pending (tctx,TM_QW3_HV_PHYS ); +break ; + } +xive2_tctx_process_pending (tctx, cur_ring); } -xive2_tctx_process_pending (tctx, ring ==TM_QW2_HV_POOL ? -TM_QW3_HV_PHYS : ring); } }@@ -1159,6 +1178,7 @@ static void xive2_tctx_process_pending(XiveTCTX *tctx, uint8_t sig_ring)int rc;g_assert (sig_ring ==TM_QW3_HV_PHYS || sig_ring ==TM_QW1_OS ); +g_assert (sig_regs[TM_WORD2 ] &0x80 );g_assert (!xive_nsr_indicates_group_exception (sig_ring, sig_regs[TM_NSR ]));/*
Quoted 84 lines · Nicholas Piggin
These changes gets the powernv xive2 to the point it is able to run PowerVM with good stability.
* Various bug fixes around lost interrupts particularly.
* Major group interrupt work, in particular around redistributing interrupts. Upstream group support is not in a complete or usable state as it is.
* Significant context push/pull improvements, particularly pool and phys context handling was quite incomplete beyond trivial OPAL case that pushes at boot.
* Improved tracing and checking for unimp and guest error situations.
* Various other missing feature support.The ordering and grouping of patches in the series is not perfect, because it had been an ongoing development, and PowerVM only started to become stable toward the end. I did try to rearrange and improve things, but some were not worth rebasing cost (e.g., some of the pool/phys pull redistribution patches should have ideally been squashed or moved together), so please bear that in mind. Suggestions for further rearranging the series are fine, but I might just find they are too much effort to be worthwhile.
Thanks,
NickGlenn Miles (12):
ppc/xive2: Fix calculation of END queue sizes ppc/xive2: Use fair irq target search algorithm ppc/xive2: Fix irq preempted by lower priority group irq ppc/xive2: Fix treatment of PIPR in CPPR update pnv/xive2: Support ESB Escalation
ppc/xive2: add interrupt priority configuration flags ppc/xive2: Support redistribution of group interrupts ppc/xive: Add more interrupt notification tracing ppc/xive2: Improve pool regs variable name
ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op ppc/xive2: Redistribute group interrupt precluded by CPPR update ppc/xive2: redistribute irqs for pool and phys ctx pullMichael Kowal (4):
ppc/xive2: Remote VSDs need to match on forwarding address ppc/xive2: Reset Generation Flipped bit on END Cache Watch pnv/xive2: Print value in invalid register write logging pnv/xive2: Permit valid writes to VC/PC Flush Control registersNicholas Piggin (34):
ppc/xive: Fix xive trace event output
ppc/xive: Report access size in XIVE TM operation error logs ppc/xive2: fix context push calculation of IPB priority ppc/xive: Fix PHYS NSR ring matching
ppc/xive2: Do not present group interrupt on OS-push if precluded by
CPPR
ppc/xive2: Set CPPR delivery should account for group priority ppc/xive:tctx_notifyshould clear the precluded interrupt ppc/xive: Explicitly zero NSR after accepting
ppc/xive: Move NSR decoding into helper functions ppc/xive: Fix pulling pool and phys contexts
pnv/xive2:VC_ENDC_WATCH_SPECregs should read backWATCH_FULLppc/xive: Change presenter .match_nvt to match not present ppc/xive2: Redistribute group interrupt preempted by higher priority
interrupt
ppc/xive: Addxive_tctx_pipr_present()to present new interrupt ppc/xive: Fix high prio group interrupt being preempted by low prio VP ppc/xive: Split xive recompute from IPB function
ppc/xive: tctx signaling registers rework
ppc/xive:tctx_acceptonly lower irq line if an interrupt was
presented
ppc/xive: Addxive_tctx_pipr_set()helper function ppc/xive2: split tctx presentation processing from set CPPR ppc/xive2: Consolidate presentation processing in context push ppc/xive2: Avoid needless interrupt re-check on CPPR set ppc/xive: Assert group interrupts were redistributed ppc/xive2: implement NVP context save restore for POOL ring ppc/xive2: Prevent pulling of pool context losing phys interrupt ppc/xive: Redistribute phys after pulling of pool context ppc/xive: Check TIMA operations validity
ppc/xive2: Implement pool context push TIMA op
ppc/xive2: redistribute group interrupts on context push ppc/xive2: Implementset_os_pendingTIMA op
ppc/xive2: Implement POOL LGS push TIMA op
ppc/xive2: Implement PHYS ring VP push TIMA op
ppc/xive: Splitneed_resendintorestore_nvp
ppc/xive2: Enable lower level contexts on VP push
Quoted 14 lines
hw/intc/pnv_xive.c | 16 +- hw/intc/pnv_xive2.c | 139 +++++-- hw/intc/pnv_xive2_regs.h | 1 + hw/intc/spapr_xive.c | 18 +- hw/intc/trace-events | 12 +- hw/intc/xive.c | 555 ++++++++++++++++++---------- hw/intc/xive2.c | 717 +++++++++++++++++++++++++++--------- hw/ppc/pnv.c | 48 +-- hw/ppc/spapr.c | 21 +- include/hw/ppc/xive.h | 66 +++- include/hw/ppc/xive2.h | 22 +- include/hw/ppc/xive2_regs.h | 22 +- 12 files changed, 1145 insertions(+), 492 deletions(-)
I am impressed :) and glad that you are still taking care of XIVE.
I suggest adding new names under the XIVE entry in the MAINTAINERS file.
Thanks,
C.
Quoted 100 lines · Cédric Le Goater
Quoted 84 lines · Nicholas Piggin
These changes gets the powernv xive2 to the point it is able to run PowerVM with good stability.
* Various bug fixes around lost interrupts particularly.
* Major group interrupt work, in particular around redistributing interrupts. Upstream group support is not in a complete or usable state as it is.
* Significant context push/pull improvements, particularly pool and phys context handling was quite incomplete beyond trivial OPAL case that pushes at boot.
* Improved tracing and checking for unimp and guest error situations.
* Various other missing feature support.The ordering and grouping of patches in the series is not perfect, because it had been an ongoing development, and PowerVM only started to become stable toward the end. I did try to rearrange and improve things, but some were not worth rebasing cost (e.g., some of the pool/phys pull redistribution patches should have ideally been squashed or moved together), so please bear that in mind. Suggestions for further rearranging the series are fine, but I might just find they are too much effort to be worthwhile.
Thanks,
NickGlenn Miles (12):
ppc/xive2: Fix calculation of END queue sizes ppc/xive2: Use fair irq target search algorithm ppc/xive2: Fix irq preempted by lower priority group irq ppc/xive2: Fix treatment of PIPR in CPPR update pnv/xive2: Support ESB Escalation
ppc/xive2: add interrupt priority configuration flags ppc/xive2: Support redistribution of group interrupts ppc/xive: Add more interrupt notification tracing ppc/xive2: Improve pool regs variable name
ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op ppc/xive2: Redistribute group interrupt precluded by CPPR update ppc/xive2: redistribute irqs for pool and phys ctx pullMichael Kowal (4):
ppc/xive2: Remote VSDs need to match on forwarding address ppc/xive2: Reset Generation Flipped bit on END Cache Watch pnv/xive2: Print value in invalid register write logging pnv/xive2: Permit valid writes to VC/PC Flush Control registersNicholas Piggin (34):
ppc/xive: Fix xive trace event output
ppc/xive: Report access size in XIVE TM operation error logs ppc/xive2: fix context push calculation of IPB priority ppc/xive: Fix PHYS NSR ring matching
ppc/xive2: Do not present group interrupt on OS-push if precluded by
CPPR
ppc/xive2: Set CPPR delivery should account for group priority ppc/xive:tctx_notifyshould clear the precluded interrupt ppc/xive: Explicitly zero NSR after accepting
ppc/xive: Move NSR decoding into helper functions ppc/xive: Fix pulling pool and phys contexts
pnv/xive2:VC_ENDC_WATCH_SPECregs should read backWATCH_FULLppc/xive: Change presenter .match_nvt to match not present ppc/xive2: Redistribute group interrupt preempted by higher priority
interrupt
ppc/xive: Addxive_tctx_pipr_present()to present new interrupt ppc/xive: Fix high prio group interrupt being preempted by low prio VP ppc/xive: Split xive recompute from IPB function
ppc/xive: tctx signaling registers rework
ppc/xive:tctx_acceptonly lower irq line if an interrupt was
presented
ppc/xive: Addxive_tctx_pipr_set()helper function ppc/xive2: split tctx presentation processing from set CPPR ppc/xive2: Consolidate presentation processing in context push ppc/xive2: Avoid needless interrupt re-check on CPPR set ppc/xive: Assert group interrupts were redistributed ppc/xive2: implement NVP context save restore for POOL ring ppc/xive2: Prevent pulling of pool context losing phys interrupt ppc/xive: Redistribute phys after pulling of pool context ppc/xive: Check TIMA operations validity
ppc/xive2: Implement pool context push TIMA op
ppc/xive2: redistribute group interrupts on context push ppc/xive2: Implementset_os_pendingTIMA op
ppc/xive2: Implement POOL LGS push TIMA op
ppc/xive2: Implement PHYS ring VP push TIMA op
ppc/xive: Splitneed_resendintorestore_nvp
ppc/xive2: Enable lower level contexts on VP pushQuoted 14 lines
hw/intc/pnv_xive.c | 16 +- hw/intc/pnv_xive2.c | 139 +++++-- hw/intc/pnv_xive2_regs.h | 1 + hw/intc/spapr_xive.c | 18 +- hw/intc/trace-events | 12 +- hw/intc/xive.c | 555 ++++++++++++++++++---------- hw/intc/xive2.c | 717 +++++++++++++++++++++++++++--------- hw/ppc/pnv.c | 48 +-- hw/ppc/spapr.c | 21 +- include/hw/ppc/xive.h | 66 +++- include/hw/ppc/xive2.h | 22 +- include/hw/ppc/xive2_regs.h | 22 +- 12 files changed, 1145 insertions(+), 492 deletions(-)
Quoted 3 lines
I am impressed :) and glad that you are still taking care of XIVE.
I suggest adding new names under the XIVE entry in the
MAINTAINERSfile.
Yeah it's good to see. They are building a lot more cool stuff with powernv at the moment, hopefully almost all should get upstreamed eventually.
I will try to convince them to add MAINTAINER entries :)
Thanks,
Nick
Quoted 105 lines · Nicholas Piggin
Quoted 100 lines · Cédric Le Goater
Quoted 84 lines · Nicholas Piggin
These changes gets the powernv xive2 to the point it is able to run PowerVM with good stability.
* Various bug fixes around lost interrupts particularly.
* Major group interrupt work, in particular around redistributing interrupts. Upstream group support is not in a complete or usable state as it is.
* Significant context push/pull improvements, particularly pool and phys context handling was quite incomplete beyond trivial OPAL case that pushes at boot.
* Improved tracing and checking for unimp and guest error situations.
* Various other missing feature support.The ordering and grouping of patches in the series is not perfect, because it had been an ongoing development, and PowerVM only started to become stable toward the end. I did try to rearrange and improve things, but some were not worth rebasing cost (e.g., some of the pool/phys pull redistribution patches should have ideally been squashed or moved together), so please bear that in mind. Suggestions for further rearranging the series are fine, but I might just find they are too much effort to be worthwhile.
Thanks,
NickGlenn Miles (12):
ppc/xive2: Fix calculation of END queue sizes ppc/xive2: Use fair irq target search algorithm ppc/xive2: Fix irq preempted by lower priority group irq ppc/xive2: Fix treatment of PIPR in CPPR update pnv/xive2: Support ESB Escalation
ppc/xive2: add interrupt priority configuration flags ppc/xive2: Support redistribution of group interrupts ppc/xive: Add more interrupt notification tracing ppc/xive2: Improve pool regs variable name
ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op ppc/xive2: Redistribute group interrupt precluded by CPPR update ppc/xive2: redistribute irqs for pool and phys ctx pullMichael Kowal (4):
ppc/xive2: Remote VSDs need to match on forwarding address ppc/xive2: Reset Generation Flipped bit on END Cache Watch pnv/xive2: Print value in invalid register write logging pnv/xive2: Permit valid writes to VC/PC Flush Control registersNicholas Piggin (34):
ppc/xive: Fix xive trace event output
ppc/xive: Report access size in XIVE TM operation error logs ppc/xive2: fix context push calculation of IPB priority ppc/xive: Fix PHYS NSR ring matching
ppc/xive2: Do not present group interrupt on OS-push if precluded by
CPPR
ppc/xive2: Set CPPR delivery should account for group priority ppc/xive:tctx_notifyshould clear the precluded interrupt ppc/xive: Explicitly zero NSR after accepting
ppc/xive: Move NSR decoding into helper functions ppc/xive: Fix pulling pool and phys contexts
pnv/xive2:VC_ENDC_WATCH_SPECregs should read backWATCH_FULLppc/xive: Change presenter .match_nvt to match not present ppc/xive2: Redistribute group interrupt preempted by higher priority
interrupt
ppc/xive: Addxive_tctx_pipr_present()to present new interrupt ppc/xive: Fix high prio group interrupt being preempted by low prio VP ppc/xive: Split xive recompute from IPB function
ppc/xive: tctx signaling registers rework
ppc/xive:tctx_acceptonly lower irq line if an interrupt was
presented
ppc/xive: Addxive_tctx_pipr_set()helper function ppc/xive2: split tctx presentation processing from set CPPR ppc/xive2: Consolidate presentation processing in context push ppc/xive2: Avoid needless interrupt re-check on CPPR set ppc/xive: Assert group interrupts were redistributed ppc/xive2: implement NVP context save restore for POOL ring ppc/xive2: Prevent pulling of pool context losing phys interrupt ppc/xive: Redistribute phys after pulling of pool context ppc/xive: Check TIMA operations validity
ppc/xive2: Implement pool context push TIMA op
ppc/xive2: redistribute group interrupts on context push ppc/xive2: Implementset_os_pendingTIMA op
ppc/xive2: Implement POOL LGS push TIMA op
ppc/xive2: Implement PHYS ring VP push TIMA op
ppc/xive: Splitneed_resendintorestore_nvp
ppc/xive2: Enable lower level contexts on VP pushQuoted 14 lines
hw/intc/pnv_xive.c | 16 +- hw/intc/pnv_xive2.c | 139 +++++-- hw/intc/pnv_xive2_regs.h | 1 + hw/intc/spapr_xive.c | 18 +- hw/intc/trace-events | 12 +- hw/intc/xive.c | 555 ++++++++++++++++++---------- hw/intc/xive2.c | 717 +++++++++++++++++++++++++++--------- hw/ppc/pnv.c | 48 +-- hw/ppc/spapr.c | 21 +- include/hw/ppc/xive.h | 66 +++- include/hw/ppc/xive2.h | 22 +- include/hw/ppc/xive2_regs.h | 22 +- 12 files changed, 1145 insertions(+), 492 deletions(-)Quoted 3 lines
I am impressed :) and glad that you are still taking care of XIVE.
I suggest adding new names under the XIVE entry in the
MAINTAINERSfile.
Quoted 9 lines
Yeah it's good to see. They are building a lot more cool stuff with powernv at the moment, hopefully almost all should get upstreamed eventually.
I will try to convince them to add MAINTAINER entries :)
Thanks,
Nick
This is a major update for XIVE and, since I am not sure anyone is going to send a PR for QEMU 10.1, I am volunteering to do it again on monday, once and only for these fixes.
We should clarify in the next cycle who is charge of ppc. IMO, If we don't have maintainers, we should orphan all non-pseries PPC components. I can send a maintainer update on this as soon as the QEMU 10.2 cycle opens.
Thanks,
C.
Quoted 126 lines · Cédric Le Goater
Quoted 105 lines · Nicholas Piggin
Quoted 100 lines · Cédric Le Goater
Quoted 84 lines · Nicholas Piggin
These changes gets the powernv xive2 to the point it is able to run PowerVM with good stability.
* Various bug fixes around lost interrupts particularly.
* Major group interrupt work, in particular around redistributing interrupts. Upstream group support is not in a complete or usable state as it is.
* Significant context push/pull improvements, particularly pool and phys context handling was quite incomplete beyond trivial OPAL case that pushes at boot.
* Improved tracing and checking for unimp and guest error situations.
* Various other missing feature support.The ordering and grouping of patches in the series is not perfect, because it had been an ongoing development, and PowerVM only started to become stable toward the end. I did try to rearrange and improve things, but some were not worth rebasing cost (e.g., some of the pool/phys pull redistribution patches should have ideally been squashed or moved together), so please bear that in mind. Suggestions for further rearranging the series are fine, but I might just find they are too much effort to be worthwhile.
Thanks,
NickGlenn Miles (12):
ppc/xive2: Fix calculation of END queue sizes ppc/xive2: Use fair irq target search algorithm ppc/xive2: Fix irq preempted by lower priority group irq ppc/xive2: Fix treatment of PIPR in CPPR update pnv/xive2: Support ESB Escalation
ppc/xive2: add interrupt priority configuration flags ppc/xive2: Support redistribution of group interrupts ppc/xive: Add more interrupt notification tracing ppc/xive2: Improve pool regs variable name
ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op ppc/xive2: Redistribute group interrupt precluded by CPPR update ppc/xive2: redistribute irqs for pool and phys ctx pullMichael Kowal (4):
ppc/xive2: Remote VSDs need to match on forwarding address ppc/xive2: Reset Generation Flipped bit on END Cache Watch pnv/xive2: Print value in invalid register write logging pnv/xive2: Permit valid writes to VC/PC Flush Control registersNicholas Piggin (34):
ppc/xive: Fix xive trace event output
ppc/xive: Report access size in XIVE TM operation error logs ppc/xive2: fix context push calculation of IPB priority ppc/xive: Fix PHYS NSR ring matching
ppc/xive2: Do not present group interrupt on OS-push if precluded by
CPPR
ppc/xive2: Set CPPR delivery should account for group priority ppc/xive:tctx_notifyshould clear the precluded interrupt ppc/xive: Explicitly zero NSR after accepting
ppc/xive: Move NSR decoding into helper functions ppc/xive: Fix pulling pool and phys contexts
pnv/xive2:VC_ENDC_WATCH_SPECregs should read backWATCH_FULLppc/xive: Change presenter .match_nvt to match not present ppc/xive2: Redistribute group interrupt preempted by higher priority
interrupt
ppc/xive: Addxive_tctx_pipr_present()to present new interrupt ppc/xive: Fix high prio group interrupt being preempted by low prio VP ppc/xive: Split xive recompute from IPB function
ppc/xive: tctx signaling registers rework
ppc/xive:tctx_acceptonly lower irq line if an interrupt was
presented
ppc/xive: Addxive_tctx_pipr_set()helper function ppc/xive2: split tctx presentation processing from set CPPR ppc/xive2: Consolidate presentation processing in context push ppc/xive2: Avoid needless interrupt re-check on CPPR set ppc/xive: Assert group interrupts were redistributed ppc/xive2: implement NVP context save restore for POOL ring ppc/xive2: Prevent pulling of pool context losing phys interrupt ppc/xive: Redistribute phys after pulling of pool context ppc/xive: Check TIMA operations validity
ppc/xive2: Implement pool context push TIMA op
ppc/xive2: redistribute group interrupts on context push ppc/xive2: Implementset_os_pendingTIMA op
ppc/xive2: Implement POOL LGS push TIMA op
ppc/xive2: Implement PHYS ring VP push TIMA op
ppc/xive: Splitneed_resendintorestore_nvp
ppc/xive2: Enable lower level contexts on VP pushQuoted 14 lines
hw/intc/pnv_xive.c | 16 +- hw/intc/pnv_xive2.c | 139 +++++-- hw/intc/pnv_xive2_regs.h | 1 + hw/intc/spapr_xive.c | 18 +- hw/intc/trace-events | 12 +- hw/intc/xive.c | 555 ++++++++++++++++++---------- hw/intc/xive2.c | 717 +++++++++++++++++++++++++++--------- hw/ppc/pnv.c | 48 +-- hw/ppc/spapr.c | 21 +- include/hw/ppc/xive.h | 66 +++- include/hw/ppc/xive2.h | 22 +- include/hw/ppc/xive2_regs.h | 22 +- 12 files changed, 1145 insertions(+), 492 deletions(-)Quoted 3 lines
I am impressed :) and glad that you are still taking care of XIVE.
I suggest adding new names under the XIVE entry in the
MAINTAINERSfile.Quoted 9 lines
Yeah it's good to see. They are building a lot more cool stuff with powernv at the moment, hopefully almost all should get upstreamed eventually.
I will try to convince them to add MAINTAINER entries :)
Thanks,
NickThis is a major update for XIVE and, since I am not sure anyone is going to send a PR for QEMU 10.1, I am volunteering to do it again on monday, once and only for these fixes.
We should clarify in the next cycle who is charge of ppc. IMO, If we don't have maintainers, we should orphan all non-pseries PPC components. I can send a maintainer update on this as soon as the QEMU 10.2 cycle opens.
Quoted 4 lines
Thanks,
C.
Cédric,
Thanks for doing the PR for these XIVE changes! It sounds like if we want to continue having our XIVE changes upstreamed we will need someone on our IBM QEMU development team to volunteer as a maintainer. Does becoming a maintainer still require physically attending a key signing party at KVM Forum?
Thanks,
Glenn
Hello Glenn,
+Harsh
Quoted 129 lines · Miles Glenn
Quoted 128 lines · Cédric Le Goater
Quoted 105 lines · Nicholas Piggin
Quoted 100 lines · Cédric Le Goater
Quoted 84 lines · Nicholas Piggin
These changes gets the powernv xive2 to the point it is able to run PowerVM with good stability.
* Various bug fixes around lost interrupts particularly.
* Major group interrupt work, in particular around redistributing interrupts. Upstream group support is not in a complete or usable state as it is.
* Significant context push/pull improvements, particularly pool and phys context handling was quite incomplete beyond trivial OPAL case that pushes at boot.
* Improved tracing and checking for unimp and guest error situations.
* Various other missing feature support.The ordering and grouping of patches in the series is not perfect, because it had been an ongoing development, and PowerVM only started to become stable toward the end. I did try to rearrange and improve things, but some were not worth rebasing cost (e.g., some of the pool/phys pull redistribution patches should have ideally been squashed or moved together), so please bear that in mind. Suggestions for further rearranging the series are fine, but I might just find they are too much effort to be worthwhile.
Thanks,
NickGlenn Miles (12):
ppc/xive2: Fix calculation of END queue sizes ppc/xive2: Use fair irq target search algorithm ppc/xive2: Fix irq preempted by lower priority group irq ppc/xive2: Fix treatment of PIPR in CPPR update pnv/xive2: Support ESB Escalation
ppc/xive2: add interrupt priority configuration flags ppc/xive2: Support redistribution of group interrupts ppc/xive: Add more interrupt notification tracing ppc/xive2: Improve pool regs variable name
ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op ppc/xive2: Redistribute group interrupt precluded by CPPR update ppc/xive2: redistribute irqs for pool and phys ctx pullMichael Kowal (4):
ppc/xive2: Remote VSDs need to match on forwarding address ppc/xive2: Reset Generation Flipped bit on END Cache Watch pnv/xive2: Print value in invalid register write logging pnv/xive2: Permit valid writes to VC/PC Flush Control registersNicholas Piggin (34):
ppc/xive: Fix xive trace event output
ppc/xive: Report access size in XIVE TM operation error logs ppc/xive2: fix context push calculation of IPB priority ppc/xive: Fix PHYS NSR ring matching
ppc/xive2: Do not present group interrupt on OS-push if precluded by
CPPR
ppc/xive2: Set CPPR delivery should account for group priority ppc/xive:tctx_notifyshould clear the precluded interrupt ppc/xive: Explicitly zero NSR after accepting
ppc/xive: Move NSR decoding into helper functions ppc/xive: Fix pulling pool and phys contexts
pnv/xive2:VC_ENDC_WATCH_SPECregs should read backWATCH_FULLppc/xive: Change presenter .match_nvt to match not present ppc/xive2: Redistribute group interrupt preempted by higher priority
interrupt
ppc/xive: Addxive_tctx_pipr_present()to present new interrupt ppc/xive: Fix high prio group interrupt being preempted by low prio VP ppc/xive: Split xive recompute from IPB function
ppc/xive: tctx signaling registers rework
ppc/xive:tctx_acceptonly lower irq line if an interrupt was
presented
ppc/xive: Addxive_tctx_pipr_set()helper function ppc/xive2: split tctx presentation processing from set CPPR ppc/xive2: Consolidate presentation processing in context push ppc/xive2: Avoid needless interrupt re-check on CPPR set ppc/xive: Assert group interrupts were redistributed ppc/xive2: implement NVP context save restore for POOL ring ppc/xive2: Prevent pulling of pool context losing phys interrupt ppc/xive: Redistribute phys after pulling of pool context ppc/xive: Check TIMA operations validity
ppc/xive2: Implement pool context push TIMA op
ppc/xive2: redistribute group interrupts on context push ppc/xive2: Implementset_os_pendingTIMA op
ppc/xive2: Implement POOL LGS push TIMA op
ppc/xive2: Implement PHYS ring VP push TIMA op
ppc/xive: Splitneed_resendintorestore_nvp
ppc/xive2: Enable lower level contexts on VP pushQuoted 14 lines
hw/intc/pnv_xive.c| 16 +-
hw/intc/pnv_xive2.c| 139 +++++--
hw/intc/pnv_xive2_regs.h| 1 +
hw/intc/spapr_xive.c| 18 +-
hw/intc/trace-events | 12 +-
hw/intc/xive.c| 555 ++++++++++++++++++----------
hw/intc/xive2.c| 717 +++++++++++++++++++++++++++---------
hw/ppc/pnv.c| 48 +--
hw/ppc/spapr.c| 21 +-
include/hw/ppc/xive.h| 66 +++-
include/hw/ppc/xive2.h| 22 +-
include/hw/ppc/xive2_regs.h| 22 +-
12 files changed, 1145 insertions(+), 492 deletions(-)Quoted 3 lines
I am impressed :) and glad that you are still taking care of XIVE.
I suggest adding new names under the XIVE entry in the
MAINTAINERSfile.Quoted 9 lines
Yeah it's good to see. They are building a lot more cool stuff with powernv at the moment, hopefully almost all should get upstreamed eventually.
I will try to convince them to add MAINTAINER entries :)
Thanks,
NickThis is a major update for XIVE and, since I am not sure anyone is going to send a PR for QEMU 10.1, I am volunteering to do it again on monday, once and only for these fixes.
We should clarify in the next cycle who is charge of ppc. IMO, If we don't have maintainers, we should orphan all non-pseries PPC components. I can send a maintainer update on this as soon as the QEMU 10.2 cycle opens.
Thanks,
Quoted 8 lines
Quoted 2 lines
C.
Cédric,
Thanks for doing the PR for these XIVE changes! It sounds like if we want to continue having our XIVE changes upstreamed we will need someone on our IBM QEMU development team to volunteer as a maintainer.
We did some updates recently :
https://lore.kernel.org/qemu-devel/[email protected]/
Given your knowledge of IBM Power servers, your relationships with the hardware team, and the quality of your work within QEMU, you should add your self as a Reviewer of PowerNV and XIVE (Needs a Maintainer also). I can merge that for QEMU 10.1.
Quoted 2 lines
Does becoming a maintainer still require physically attending a key signing party at KVM Forum?
To be able to send PRs, it is strongly recommended to have your key signed by the people pulling in your changes. Being physically present is always better to verify the identity of a person.
But that's not all, it's a chain of trust and a community involvement in all areas. It takes time.
Btw, in series [1], there are several patches tagged as Fixes, could you please reply to Michael [2] regarding which could be backported to the stable branches ?
Thanks,
C.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 167 lines · Cédric Le Goater
Hello Glenn,
+Harsh
Quoted 129 lines · Miles Glenn
Quoted 128 lines · Cédric Le Goater
Quoted 105 lines · Nicholas Piggin
Quoted 100 lines · Cédric Le Goater
Quoted 84 lines · Nicholas Piggin
These changes gets the powernv xive2 to the point it is able to run PowerVM with good stability.
* Various bug fixes around lost interrupts particularly.
* Major group interrupt work, in particular around redistributing interrupts. Upstream group support is not in a complete or usable state as it is.
* Significant context push/pull improvements, particularly pool and phys context handling was quite incomplete beyond trivial OPAL case that pushes at boot.
* Improved tracing and checking for unimp and guest error situations.
* Various other missing feature support.The ordering and grouping of patches in the series is not perfect, because it had been an ongoing development, and PowerVM only started to become stable toward the end. I did try to rearrange and improve things, but some were not worth rebasing cost (e.g., some of the pool/phys pull redistribution patches should have ideally been squashed or moved together), so please bear that in mind. Suggestions for further rearranging the series are fine, but I might just find they are too much effort to be worthwhile.
Thanks,
NickGlenn Miles (12):
ppc/xive2: Fix calculation of END queue sizes ppc/xive2: Use fair irq target search algorithm ppc/xive2: Fix irq preempted by lower priority group irq ppc/xive2: Fix treatment of PIPR in CPPR update pnv/xive2: Support ESB Escalation
ppc/xive2: add interrupt priority configuration flags ppc/xive2: Support redistribution of group interrupts ppc/xive: Add more interrupt notification tracing ppc/xive2: Improve pool regs variable name
ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op ppc/xive2: Redistribute group interrupt precluded by CPPR update ppc/xive2: redistribute irqs for pool and phys ctx pullMichael Kowal (4):
ppc/xive2: Remote VSDs need to match on forwarding address ppc/xive2: Reset Generation Flipped bit on END Cache Watch pnv/xive2: Print value in invalid register write logging pnv/xive2: Permit valid writes to VC/PC Flush Control registersNicholas Piggin (34):
ppc/xive: Fix xive trace event output
ppc/xive: Report access size in XIVE TM operation error logs ppc/xive2: fix context push calculation of IPB priority ppc/xive: Fix PHYS NSR ring matching
ppc/xive2: Do not present group interrupt on OS-push if precluded by
CPPR
ppc/xive2: Set CPPR delivery should account for group priority ppc/xive:tctx_notifyshould clear the precluded interrupt ppc/xive: Explicitly zero NSR after accepting
ppc/xive: Move NSR decoding into helper functions ppc/xive: Fix pulling pool and phys contexts
pnv/xive2:VC_ENDC_WATCH_SPECregs should read backWATCH_FULLppc/xive: Change presenter .match_nvt to match not present ppc/xive2: Redistribute group interrupt preempted by higher priority
interrupt
ppc/xive: Addxive_tctx_pipr_present()to present new interrupt ppc/xive: Fix high prio group interrupt being preempted by low prio VP ppc/xive: Split xive recompute from IPB function
ppc/xive: tctx signaling registers rework
ppc/xive:tctx_acceptonly lower irq line if an interrupt was
presented
ppc/xive: Addxive_tctx_pipr_set()helper function ppc/xive2: split tctx presentation processing from set CPPR ppc/xive2: Consolidate presentation processing in context push ppc/xive2: Avoid needless interrupt re-check on CPPR set ppc/xive: Assert group interrupts were redistributed ppc/xive2: implement NVP context save restore for POOL ring ppc/xive2: Prevent pulling of pool context losing phys interrupt ppc/xive: Redistribute phys after pulling of pool context ppc/xive: Check TIMA operations validity
ppc/xive2: Implement pool context push TIMA op
ppc/xive2: redistribute group interrupts on context push ppc/xive2: Implementset_os_pendingTIMA op
ppc/xive2: Implement POOL LGS push TIMA op
ppc/xive2: Implement PHYS ring VP push TIMA op
ppc/xive: Splitneed_resendintorestore_nvp
ppc/xive2: Enable lower level contexts on VP pushQuoted 14 lines
hw/intc/pnv_xive.c| 16 +-
hw/intc/pnv_xive2.c| 139 +++++--
hw/intc/pnv_xive2_regs.h| 1 +
hw/intc/spapr_xive.c| 18 +-
hw/intc/trace-events | 12 +-
hw/intc/xive.c| 555 ++++++++++++++++++----------
hw/intc/xive2.c| 717 +++++++++++++++++++++++++++---------
hw/ppc/pnv.c| 48 +--
hw/ppc/spapr.c| 21 +-
include/hw/ppc/xive.h| 66 +++-
include/hw/ppc/xive2.h| 22 +-
include/hw/ppc/xive2_regs.h| 22 +-
12 files changed, 1145 insertions(+), 492 deletions(-)Quoted 3 lines
I am impressed :) and glad that you are still taking care of XIVE.
I suggest adding new names under the XIVE entry in the
MAINTAINERSfile.Quoted 9 lines
Yeah it's good to see. They are building a lot more cool stuff with powernv at the moment, hopefully almost all should get upstreamed eventually.
I will try to convince them to add MAINTAINER entries :)
Thanks,
NickThis is a major update for XIVE and, since I am not sure anyone is going to send a PR for QEMU 10.1, I am volunteering to do it again on monday, once and only for these fixes.
We should clarify in the next cycle who is charge of ppc. IMO, If we don't have maintainers, we should orphan all non-pseries PPC components. I can send a maintainer update on this as soon as the QEMU 10.2 cycle opens.
Thanks,
Quoted 8 lines
Quoted 2 lines
C.
Cédric,
Thanks for doing the PR for these XIVE changes! It sounds like if we want to continue having our XIVE changes upstreamed we will need someone on our IBM QEMU development team to volunteer as a maintainer.
We did some updates recently :
https://lore.kernel.org/qemu-devel/[email protected]/Given your knowledge of IBM Power servers, your relationships with the hardware team, and the quality of your work within QEMU, you should add your self as a Reviewer of PowerNV and XIVE (Needs a Maintainer also). I can merge that for QEMU 10.1.
Quoted 2 lines
Does becoming a maintainer still require physically attending a key signing party at KVM Forum?
To be able to send PRs, it is strongly recommended to have your key signed by the people pulling in your changes. Being physically present is always better to verify the identity of a person.
But that's not all, it's a chain of trust and a community involvement in all areas. It takes time.
Btw, in series [1], there are several patches tagged as Fixes, could you please reply to Michael [2] regarding which could be backported to the stable branches ?
Quoted 8 lines
Thanks,
C.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
Thanks Cédric,
I'll go ahead and add my name as a reviewer for powernv and xive. As for a maintainer for the XIVE code, I would like to nominate Mike Kowal for that role. And, yes, I will respond to Michael Tokarev's question regarding backporting fixes.
Thanks,
Glenn
Quoted 173 lines · Miles Glenn
Quoted 172 lines · Cédric Le Goater
Hello Glenn,
+Harsh
Quoted 129 lines · Miles Glenn
Quoted 128 lines · Cédric Le Goater
Quoted 105 lines · Nicholas Piggin
Quoted 100 lines · Cédric Le Goater
Quoted 84 lines · Nicholas Piggin
These changes gets the powernv xive2 to the point it is able to run PowerVM with good stability.
* Various bug fixes around lost interrupts particularly.
* Major group interrupt work, in particular around redistributing interrupts. Upstream group support is not in a complete or usable state as it is.
* Significant context push/pull improvements, particularly pool and phys context handling was quite incomplete beyond trivial OPAL case that pushes at boot.
* Improved tracing and checking for unimp and guest error situations.
* Various other missing feature support.The ordering and grouping of patches in the series is not perfect, because it had been an ongoing development, and PowerVM only started to become stable toward the end. I did try to rearrange and improve things, but some were not worth rebasing cost (e.g., some of the pool/phys pull redistribution patches should have ideally been squashed or moved together), so please bear that in mind. Suggestions for further rearranging the series are fine, but I might just find they are too much effort to be worthwhile.
Thanks,
NickGlenn Miles (12):
ppc/xive2: Fix calculation of END queue sizes ppc/xive2: Use fair irq target search algorithm ppc/xive2: Fix irq preempted by lower priority group irq ppc/xive2: Fix treatment of PIPR in CPPR update pnv/xive2: Support ESB Escalation
ppc/xive2: add interrupt priority configuration flags ppc/xive2: Support redistribution of group interrupts ppc/xive: Add more interrupt notification tracing ppc/xive2: Improve pool regs variable name
ppc/xive2: Implement "Ack OS IRQ to even report line" TIMA op ppc/xive2: Redistribute group interrupt precluded by CPPR update ppc/xive2: redistribute irqs for pool and phys ctx pullMichael Kowal (4):
ppc/xive2: Remote VSDs need to match on forwarding address ppc/xive2: Reset Generation Flipped bit on END Cache Watch pnv/xive2: Print value in invalid register write logging pnv/xive2: Permit valid writes to VC/PC Flush Control registersNicholas Piggin (34):
ppc/xive: Fix xive trace event output
ppc/xive: Report access size in XIVE TM operation error logs ppc/xive2: fix context push calculation of IPB priority ppc/xive: Fix PHYS NSR ring matching
ppc/xive2: Do not present group interrupt on OS-push if precluded by
CPPR
ppc/xive2: Set CPPR delivery should account for group priority ppc/xive:tctx_notifyshould clear the precluded interrupt ppc/xive: Explicitly zero NSR after accepting
ppc/xive: Move NSR decoding into helper functions ppc/xive: Fix pulling pool and phys contexts
pnv/xive2:VC_ENDC_WATCH_SPECregs should read backWATCH_FULLppc/xive: Change presenter .match_nvt to match not present ppc/xive2: Redistribute group interrupt preempted by higher priority
interrupt
ppc/xive: Addxive_tctx_pipr_present()to present new interrupt ppc/xive: Fix high prio group interrupt being preempted by low prio VP ppc/xive: Split xive recompute from IPB function
ppc/xive: tctx signaling registers rework
ppc/xive:tctx_acceptonly lower irq line if an interrupt was
presented
ppc/xive: Addxive_tctx_pipr_set()helper function ppc/xive2: split tctx presentation processing from set CPPR ppc/xive2: Consolidate presentation processing in context push ppc/xive2: Avoid needless interrupt re-check on CPPR set ppc/xive: Assert group interrupts were redistributed ppc/xive2: implement NVP context save restore for POOL ring ppc/xive2: Prevent pulling of pool context losing phys interrupt ppc/xive: Redistribute phys after pulling of pool context ppc/xive: Check TIMA operations validity
ppc/xive2: Implement pool context push TIMA op
ppc/xive2: redistribute group interrupts on context push ppc/xive2: Implementset_os_pendingTIMA op
ppc/xive2: Implement POOL LGS push TIMA op
ppc/xive2: Implement PHYS ring VP push TIMA op
ppc/xive: Splitneed_resendintorestore_nvp
ppc/xive2: Enable lower level contexts on VP pushQuoted 14 lines
hw/intc/pnv_xive.c| 16 +-
hw/intc/pnv_xive2.c| 139 +++++--
hw/intc/pnv_xive2_regs.h| 1 +
hw/intc/spapr_xive.c| 18 +-
hw/intc/trace-events | 12 +-
hw/intc/xive.c| 555 ++++++++++++++++++----------
hw/intc/xive2.c| 717 +++++++++++++++++++++++++++---------
hw/ppc/pnv.c| 48 +--
hw/ppc/spapr.c| 21 +-
include/hw/ppc/xive.h| 66 +++-
include/hw/ppc/xive2.h| 22 +-
include/hw/ppc/xive2_regs.h| 22 +-
12 files changed, 1145 insertions(+), 492 deletions(-)Quoted 3 lines
I am impressed :) and glad that you are still taking care of XIVE.
I suggest adding new names under the XIVE entry in the
MAINTAINERSfile.Quoted 9 lines
Yeah it's good to see. They are building a lot more cool stuff with powernv at the moment, hopefully almost all should get upstreamed eventually.
I will try to convince them to add MAINTAINER entries :)
Thanks,
NickThis is a major update for XIVE and, since I am not sure anyone is going to send a PR for QEMU 10.1, I am volunteering to do it again on monday, once and only for these fixes.
We should clarify in the next cycle who is charge of ppc. IMO, If we don't have maintainers, we should orphan all non-pseries PPC components. I can send a maintainer update on this as soon as the QEMU 10.2 cycle opens.
Thanks,
Quoted 8 lines
Quoted 2 lines
C.
Cédric,
Thanks for doing the PR for these XIVE changes! It sounds like if we want to continue having our XIVE changes upstreamed we will need someone on our IBM QEMU development team to volunteer as a maintainer.
We did some updates recently :
https://lore.kernel.org/qemu-devel/[email protected]/Given your knowledge of IBM Power servers, your relationships with the hardware team, and the quality of your work within QEMU, you should add your self as a Reviewer of PowerNV and XIVE (Needs a Maintainer also). I can merge that for QEMU 10.1.
Quoted 2 lines
Does becoming a maintainer still require physically attending a key signing party at KVM Forum?
To be able to send PRs, it is strongly recommended to have your key signed by the people pulling in your changes. Being physically present is always better to verify the identity of a person.
But that's not all, it's a chain of trust and a community involvement in all areas. It takes time.
Btw, in series [1], there are several patches tagged as Fixes, could you please reply to Michael [2] regarding which could be backported to the stable branches ?
Thanks,
C.
Quoted 7 lines
Quoted 3 lines
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/Thanks Cédric,
I'll go ahead and add my name as a reviewer for powernv and xive.
Please send a patch !
Quoted 3 lines
As
for a maintainer for the XIVE code, I would like to nominate Mike Kowal for that role.
Ah ! I tried that in the past. Mike is the right person indeed.
Please send a patch :)
Quoted 2 lines
And, yes, I will respond to Michael Tokarev's question regarding backporting fixes.
Thanks,
C.
Hi Nick,
I did some sanity testing of this series on KVM on LPAR (P10) with the help of avocado test suites, LGTM