pnv/xive: Expand implementation of XIVE physical thread enables
PATCH 1/1 pnv/xive: Expand implementation of XIVE physical thread enables
Clearing the physical thread enable register should reset the TCTX state and reject accesses to it. xive currently does not model this.
skiboot firmware uses this register to reset the XIVE TIMA state (see xive_reset_enable_thread()), which can be in an arbitrary state e.g., when called by OPAL_XIVE_RESET after kexec, or by skiboot's fast-reboot feature).
---
I posted a skiboot patch to detect an improperly reset TIMA and warn, which fires before this QEMU patch and is solved afterward.
https://lists.ozlabs.org/pipermail/skiboot/2025-March/019172.html
A not-yet posted QEMU xive patch that checks for validity of TIMA operations based on whether or not CAM rings are enabled is what detected this issue in the first place.
This implementation seems to solve the problem.
Thanks,
Nick
include/hw/ppc/xive.h | 1 + hw/intc/pnv_xive.c | 126 ++++++++++++++++++++++++++++++++---------- hw/intc/pnv_xive2.c | 122 +++++++++++++++++++++++++++++----------- hw/intc/xive.c | 11 ++++ hw/intc/trace-events | 2 + 5 files changed, 202 insertions(+), 60 deletions(-)
include/hw/ppc/xive.h +1 -0
@@ -352,6 +352,7 @@ struct XiveTCTX {DeviceState parent_obj;CPUState *cs; +bool cpu_enabled;/* Physical Thread Enabled (used by pnv_xive) */ qemu_irq hv_output;qemu_irq os_output;
hw/intc/pnv_xive.c +97 -29
209 lines not on this page · raw message
hw/intc/pnv_xive2.c +91 -31
214 lines not on this page · raw message
hw/intc/xive.c +11 -0
@@ -677,6 +677,8 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,trace_xive_tctx_tm_write (tctx->cs->cpu_index, offset, size, value); +g_assert (tctx->cpu_enabled); +/* * TODO: check V bit in Q[0-3]W2 */
@@ -716,6 +718,13 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,const XiveTmOp *xto;uint64_t ret; +if (!tctx->cpu_enabled) { +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid read access to TIMA " +"with physical thread enable cleared\n" ); +/* TODO: This should set a FIR bit */ +return -1 ; + } +/* * TODO: check V bit in Q[0-3]W2 */
@@ -822,6 +831,8 @@ void xive_tctx_pic_print_info(XiveTCTX *tctx, GString *buf)void xive_tctx_reset (XiveTCTX *tctx) { + tctx->cpu_enabled = false; +memset (tctx->regs,0 ,sizeof (tctx->regs));/* Set some defaults */
hw/intc/trace-events +2 -0
@@ -291,6 +291,8 @@ xive_nvp_backlog_op(uint8_t blk, uint32_t idx, uint8_t op, uint8_t priority, uin xive_nvgc_backlog_op(bool c, uint8_t blk, uint32_t idx, uint8_t op, uint8_t priority, uint32_t rc) "NVGC crowd=%d 0x%x/0x%x operation=%d priority=%d rc=%d" # pnv_xive.c +pnv_xive_pter_enable(int cpu_index) "CPU[%d]" +pnv_xive_pter_disable(int cpu_index) "CPU[%d]" pnv_xive_ic_hw_trigger(uint64_t addr, uint64_t val) "@0x%"PRIx64" val=0x%"PRIx64 # goldfish_pic.c
Signature · 1 line
2.47.1