ppc/pnv: add XIVE support for KVM guests
cover ppc/pnv: add XIVE support for KVM guests
Hello,
The QEMU PowerNV machine emulates a baremetal OpenPOWER system and acts as an hypervisor (L0). Supporting emulation of KVM to run guests (L1) requires a few more extensions, among which support for the XIVE interrupt controller on POWER9 processor.
The following changes fix some parts of the XIVE model and provide support for escalations and resend. This mechanism is used by KVM to kick a vCPU when it is not dispatched on a HW thread.
A series from Suraj adding guest support in the Radix MMU model of the QEMU PowerNV machine is still required and will be send later. The whole patchset can be found under :
https://github.com/legoater/qemu/tree/powernv-4.1
Thanks,
C.
Cédric Le Goater (10):
ppc/xive: Force the Physical CAM line value to group mode ppc/xive: Make the PIPR register readonly
ppc/pnv: Rework cache watch model of PnvXIVE ppc/xive: Fix TM_PULL_POOL_CTX special operation ppc/xive: Implement TM_PULL_OS_CTX special command ppc/xive: Provide escalation support
ppc/xive: Improve 'info pic' support
ppc/xive: Extend XiveTCTX with an router object pointer ppc/xive: Synthesize interrupt from the saved IPB in the NVT ppc/pnv: Dump the XIVE NVT table
include/hw/ppc/xive.h | 23 ++- include/hw/ppc/xive_regs.h | 13 ++ hw/intc/pnv_xive.c | 211 +++++++++++++++++++---- hw/intc/spapr_xive.c | 1 - hw/intc/xive.c | 341 +++++++++++++++++++++++++++++-------- hw/ppc/pnv.c | 2 +- hw/ppc/spapr_irq.c | 2 +- 7 files changed, 479 insertions(+), 114 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/10 ppc/xive: Force the Physical CAM line value to group mode
When an interrupt needs to be delivered, the XIVE interrupt controller presenter scans the CAM lines of the thread interrupt contexts of the HW threads of the chip to find a matching vCPU. The interrupt context is composed of 4 different sets of registers: Physical, HV, OS and User.
The encoding of the Physical CAM line depends on the mode in which the interrupt controller is operating: CAM mode or block group mode. Block group mode being the default configuration today on POWER9 and the only one available on the next POWER10 generation, enforce this encoding in the Physical CAM line :
chip << 19 | 0000000 0 0001 thread (7Bit)
It fits the overall encoding of the NVT ids and simplifies the matching algorithm in the presenter.
--- hw/intc/xive.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
hw/intc/xive.c +5 -16
@@ -1229,27 +1229,16 @@ XiveTCTX *xive_router_get_tctx(XiveRouter *xrtr, CPUState *cs) }/* -* By default on P9, the HW CAM line (23bits) is hardwired to : +* Encode the HW CAM line in the block group mode format : * -* 0x000||0b1||4Bit chip number||7Bit Thread number. -* -* When the block grouping is enabled, the CAM line is changed to : -* -* 4Bit chip number||0x001||7Bit Thread number. +* chip << 19 | 0000000 0 0001 thread (7Bit) */ -static uint32_t hw_cam_line (uint8_t chip_id,uint8_t tid) -{ -return 1 <<11 | (chip_id &0xf ) <<7 | (tid &0x7f ); -} - -static bool xive_presenter_tctx_match_hw (XiveTCTX *tctx, -uint8_t nvt_blk,uint32_t nvt_idx) +static uint32_t xive_tctx_hw_cam_line (XiveTCTX *tctx) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value; -return hw_cam_line ((pir >>8 ) &0xf , pir &0x7f ) == -hw_cam_line (nvt_blk, nvt_idx); +return xive_nvt_cam_line ((pir >>8 ) &0xf ,1 <<7 | (pir &0x7f )); }/*
@@ -1285,7 +1274,7 @@ static int xive_presenter_tctx_match(XiveTCTX *tctx, uint8_t format,/* PHYS ring */ if ((be32_to_cpu (qw3w2) &TM_QW3W2_VT ) && -xive_presenter_tctx_match_hw (tctx, nvt_blk, nvt_idx)) { + cam ==xive_tctx_hw_cam_line (tctx)) {return TM_QW3_HV_PHYS ; }
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 01/10] ppc/xive: Force the Physical CAM line value to group mode
Quoted 12 lines · Cédric Le Goater
When an interrupt needs to be delivered, the XIVE interrupt controller presenter scans the CAM lines of the thread interrupt contexts of the HW threads of the chip to find a matching vCPU. The interrupt context is composed of 4 different sets of registers: Physical, HV, OS and User.
The encoding of the Physical CAM line depends on the mode in which the interrupt controller is operating: CAM mode or block group mode. Block group mode being the default configuration today on POWER9 and the only one available on the next POWER10 generation, enforce this encoding in the Physical CAM line :
Quoted 7 lines
chip << 19 | 0000000 0 0001 thread (7Bit)It fits the overall encoding of the NVT ids and simplifies the matching algorithm in the presenter.
Fixes d514c48d41fb ("ppc/xive: hardwire the Physical CAM line of the thread context")Signed-off-by Cédric Le Goater <[email protected]>
Since this appears to be a fix, applied to ppc-for-4.1.
Quoted 49 lines
--- hw/intc/xive.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)hw/intc/xive.c +5
-16@@ -1229,27 +1229,16 @@ XiveTCTX *xive_router_get_tctx(XiveRouter *xrtr, CPUState *cs) }/* -* By default on P9, the HW CAM line (23bits) is hardwired to : +* Encode the HW CAM line in the block group mode format : * -* 0x000||0b1||4Bit chip number||7Bit Thread number. -* -* When the block grouping is enabled, the CAM line is changed to : -* -* 4Bit chip number||0x001||7Bit Thread number. +* chip << 19 | 0000000 0 0001 thread (7Bit) */ -static uint32_t hw_cam_line (uint8_t chip_id,uint8_t tid) -{ -return 1 <<11 | (chip_id &0xf ) <<7 | (tid &0x7f ); -} - -static bool xive_presenter_tctx_match_hw (XiveTCTX *tctx, -uint8_t nvt_blk,uint32_t nvt_idx) +static uint32_t xive_tctx_hw_cam_line (XiveTCTX *tctx) {CPUPPCState *env = &POWERPC_CPU (tctx->cs)->env;uint32_t pir = env->spr_cb[SPR_PIR ].default_value; -return hw_cam_line ((pir >>8 ) &0xf , pir &0x7f ) == -hw_cam_line (nvt_blk, nvt_idx); +return xive_nvt_cam_line ((pir >>8 ) &0xf ,1 <<7 | (pir &0x7f )); }/* @@ -1285,7 +1274,7 @@ static int xive_presenter_tctx_match(XiveTCTX *tctx, uint8_t format,/* PHYS ring */ if ((be32_to_cpu (qw3w2) &TM_QW3W2_VT ) && -xive_presenter_tctx_match_hw (tctx, nvt_blk, nvt_idx)) { + cam ==xive_tctx_hw_cam_line (tctx)) {return TM_QW3_HV_PHYS ; }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 2/10 ppc/xive: Make the PIPR register readonly
In reply to Cédric Le GoaterWhen the hypervisor (KVM) dispatches a vCPU on a HW thread, it restores its thread interrupt context. The Pending Interrupt Priority Register (PIPR) is computed from the Interrupt Pending Buffer (IPB) and stores should not be allowed to change its value.
--- hw/intc/xive.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
hw/intc/xive.c +16 -16
@@ -182,31 +182,31 @@ static uint64_t xive_tm_vt_poll(XiveTCTX *tctx, hwaddr offset, unsigned size)*/ static const uint8_t xive_tm_hw_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 3 ,3 ,3 ,3 ,3 ,3 ,0 ,3 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 3 ,3 ,3 ,3 ,0 ,3 ,0 ,3 ,3 ,0 ,0 ,3 ,3 ,3 ,3 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +3 ,3 ,3 ,3 ,3 ,3 ,0 ,2 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +3 ,3 ,3 ,3 ,0 ,3 ,0 ,2 ,3 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,/* QW-3 PHYS */ };static const uint8_t xive_tm_hv_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 3 ,3 ,3 ,3 ,3 ,3 ,0 ,3 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 3 ,3 ,3 ,3 ,0 ,3 ,0 ,3 ,3 ,0 ,0 ,3 ,0 ,0 ,0 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +3 ,3 ,3 ,3 ,3 ,3 ,0 ,2 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +3 ,3 ,3 ,3 ,0 ,3 ,0 ,2 ,3 ,0 ,0 ,3 ,0 ,0 ,0 ,0 ,/* QW-3 PHYS */ };static const uint8_t xive_tm_os_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 2 ,3 ,2 ,2 ,2 ,2 ,0 ,2 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +2 ,3 ,2 ,2 ,2 ,2 ,0 ,2 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-3 PHYS */ };static const uint8_t xive_tm_user_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-3 PHYS */ };/*
Signature · 1 line
2.21.0
David Gibson
AppliedRe: [Qemu-devel] [PATCH 02/10] ppc/xive: Make the PIPR register readonly
Quoted 7 lines · Cédric Le Goater
When the hypervisor (KVM) dispatches a vCPU on a HW thread, it restores its thread interrupt context. The Pending Interrupt Priority Register (PIPR) is computed from the Interrupt Pending Buffer (IPB) and stores should not be allowed to change its value.
Fixes 207d9fe98510 ("ppc/xive: introduce the XIVE interrupt thread context")Signed-off-by Cédric Le Goater <[email protected]>
Applied to ppc-for-4.1.
Quoted 56 lines
--- hw/intc/xive.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)hw/intc/xive.c +16
-16@@ -182,31 +182,31 @@ static uint64_t xive_tm_vt_poll(XiveTCTX *tctx, hwaddr offset, unsigned size)*/ static const uint8_t xive_tm_hw_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 3 ,3 ,3 ,3 ,3 ,3 ,0 ,3 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 3 ,3 ,3 ,3 ,0 ,3 ,0 ,3 ,3 ,0 ,0 ,3 ,3 ,3 ,3 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +3 ,3 ,3 ,3 ,3 ,3 ,0 ,2 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +3 ,3 ,3 ,3 ,0 ,3 ,0 ,2 ,3 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,/* QW-3 PHYS */ };static const uint8_t xive_tm_hv_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 3 ,3 ,3 ,3 ,3 ,3 ,0 ,3 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 3 ,3 ,3 ,3 ,0 ,3 ,0 ,3 ,3 ,0 ,0 ,3 ,0 ,0 ,0 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +3 ,3 ,3 ,3 ,3 ,3 ,0 ,2 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,3 ,3 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +3 ,3 ,3 ,3 ,0 ,3 ,0 ,2 ,3 ,0 ,0 ,3 ,0 ,0 ,0 ,0 ,/* QW-3 PHYS */ };static const uint8_t xive_tm_os_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 2 ,3 ,2 ,2 ,2 ,2 ,0 ,2 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,3 ,3 ,3 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +2 ,3 ,2 ,2 ,2 ,2 ,0 ,2 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-3 PHYS */ };static const uint8_t xive_tm_user_view[] = { -/* QW-0 User */ 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-1 OS */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-2 POOL */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/* QW-3 PHYS */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-0 User */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-1 OS */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-2 POOL */ +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* QW-3 PHYS */ };/*
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 3/10 ppc/pnv: Rework cache watch model of PnvXIVE
In reply to Cédric Le GoaterWhen the software modifies the XIVE internal structures, ESB, EAS, END, NVT, it also must update the caches of the different XIVE sub-engines. HW offers a set of common interface for such purpose.
The CWATCH_SPEC register defines the block/index of the target and a set of flags to perform a full update and to watch for update conflicts.
The cache watch CWATCH_DATAX registers are then loaded with the target data with a first read on CWATCH_DATA0. Writing back is done in the opposit order, CWATCH_DATA0 triggering the update.
The SCRUB_TRIG registers are used to flush the cache in RAM, and to possibly invalidate it. Cache disablement is also an option but as we do not model the cache, these registers are no-ops
Today, the modeling of these registers is incorrect but it did not impact the set up of a baremetal system. However, running KVM requires a rework.
--- hw/intc/pnv_xive.c | 142 +++++++++++++++++++++++++++++++++------------ 1 file changed, 106 insertions(+), 36 deletions(-)
hw/intc/pnv_xive.c +106 -36
@@ -169,7 +169,7 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, vsd =ldq_be_dma (&address_space_memory, vsd_addr);if (!(vsd &VSD_ADDRESS_MASK )) { -xive_error (xive,"VST: invalid %s entry %x !?" , info->name,0 ); +xive_error (xive,"VST: invalid %s entry %x !?" , info->name, idx);return 0 ; }
@@ -190,7 +190,7 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, vsd =ldq_be_dma (&address_space_memory, vsd_addr);if (!(vsd &VSD_ADDRESS_MASK )) { -xive_error (xive,"VST: invalid %s entry %x !?" , info->name,0 ); +xive_error (xive,"VST: invalid %s entry %x !?" , info->name, idx);return 0 ; }
@@ -294,8 +294,12 @@ static int pnv_xive_write_end(XiveRouter *xrtr, uint8_t blk, uint32_t idx, word_number); } -static int pnv_xive_end_update (PnvXive *xive,uint8_t blk,uint32_t idx) +static int pnv_xive_end_update (PnvXive *xive) { +uint8_t blk =GETFIELD (VC_EQC_CWATCH_BLOCKID , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (VC_EQC_CWATCH_OFFSET , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]);int i;uint64_t eqc_watch[4 ];
@@ -307,6 +311,24 @@ static int pnv_xive_end_update(PnvXive *xive, uint8_t blk, uint32_t idx) XIVE_VST_WORD_ALL); } +static void pnv_xive_end_cache_load (PnvXive *xive) +{ +uint8_t blk =GETFIELD (VC_EQC_CWATCH_BLOCKID , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (VC_EQC_CWATCH_OFFSET , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]); +uint64_t eqc_watch[4 ] = {0 }; +int i; + +if (pnv_xive_vst_read (xive,VST_TSEL_EQDT , blk, idx, eqc_watch)) { +xive_error (xive,"VST: no END entry %x/%x !?" , blk, idx); + } + +for (i =0 ; i <ARRAY_SIZE (eqc_watch); i++) { + xive->regs[(VC_EQC_CWATCH_DAT0 >>3 ) + i] =be64_to_cpu (eqc_watch[i]); + } +} +static int pnv_xive_get_nvt (XiveRouter *xrtr,uint8_t blk,uint32_t idx,XiveNVT *nvt) {
@@ -320,8 +342,12 @@ static int pnv_xive_write_nvt(XiveRouter *xrtr, uint8_t blk, uint32_t idx, word_number); } -static int pnv_xive_nvt_update (PnvXive *xive,uint8_t blk,uint32_t idx) +static int pnv_xive_nvt_update (PnvXive *xive) { +uint8_t blk =GETFIELD (PC_VPC_CWATCH_BLOCKID , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (PC_VPC_CWATCH_OFFSET , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]);int i;uint64_t vpc_watch[8 ];
@@ -333,6 +359,24 @@ static int pnv_xive_nvt_update(PnvXive *xive, uint8_t blk, uint32_t idx) XIVE_VST_WORD_ALL); } +static void pnv_xive_nvt_cache_load (PnvXive *xive) +{ +uint8_t blk =GETFIELD (PC_VPC_CWATCH_BLOCKID , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (PC_VPC_CWATCH_OFFSET , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]); +uint64_t vpc_watch[8 ] = {0 }; +int i; + +if (pnv_xive_vst_read (xive,VST_TSEL_VPDT , blk, idx, vpc_watch)) { +xive_error (xive,"VST: no NVT entry %x/%x !?" , blk, idx); + } + +for (i =0 ; i <ARRAY_SIZE (vpc_watch); i++) { + xive->regs[(PC_VPC_CWATCH_DAT0 >>3 ) + i] =be64_to_cpu (vpc_watch[i]); + } +} +static int pnv_xive_get_eas (XiveRouter *xrtr,uint8_t blk,uint32_t idx,XiveEAS *eas) {
@@ -346,12 +390,6 @@ static int pnv_xive_get_eas(XiveRouter *xrtr, uint8_t blk, uint32_t idx,return pnv_xive_vst_read (xive,VST_TSEL_IVT , blk, idx, eas); } -static int pnv_xive_eas_update (PnvXive *xive,uint8_t blk,uint32_t idx) -{ -/* All done. */ -return 0 ; -} -static XiveTCTX *pnv_xive_get_tctx (XiveRouter *xrtr,CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);
@@ -950,28 +988,43 @@ static void pnv_xive_ic_reg_write(void *opaque, hwaddr offset,* XIVE PC & VC cache updates for EAS, NVT and END */ case VC_IVC_SCRUB_MASK : -break ;case VC_IVC_SCRUB_TRIG : -pnv_xive_eas_update (xive,GETFIELD (PC_SCRUB_BLOCK_ID , val), -GETFIELD (VC_SCRUB_OFFSET , val));break ; -case VC_EQC_SCRUB_MASK :case VC_EQC_CWATCH_SPEC : - case VC_EQC_CWATCH_DAT0 ... VC_EQC_CWATCH_DAT3: + val &= ~VC_EQC_CWATCH_CONFLICT ;/* HW resets this bit */ +break ; + case VC_EQC_CWATCH_DAT1 ... VC_EQC_CWATCH_DAT3:break ; +case VC_EQC_CWATCH_DAT0 : +/* writing to DATA0 triggers the cache write */ + xive->regs[reg] = val; +pnv_xive_end_update (xive); +break ; +case VC_EQC_SCRUB_MASK :case VC_EQC_SCRUB_TRIG : -pnv_xive_end_update (xive,GETFIELD (VC_SCRUB_BLOCK_ID , val), -GETFIELD (VC_SCRUB_OFFSET , val)); +/* +* The scrubbing registers flush the cache in RAM and can also +* invalidate. +*/ break ; -case PC_VPC_SCRUB_MASK :case PC_VPC_CWATCH_SPEC : - case PC_VPC_CWATCH_DAT0 ... PC_VPC_CWATCH_DAT7: + val &= ~PC_VPC_CWATCH_CONFLICT ;/* HW resets this bit */ +break ; + case PC_VPC_CWATCH_DAT1 ... PC_VPC_CWATCH_DAT7:break ; +case PC_VPC_CWATCH_DAT0 : +/* writing to DATA0 triggers the cache write */ + xive->regs[reg] = val; +pnv_xive_nvt_update (xive); +break ; +case PC_VPC_SCRUB_MASK :case PC_VPC_SCRUB_TRIG : -pnv_xive_nvt_update (xive,GETFIELD (PC_SCRUB_BLOCK_ID , val), -GETFIELD (PC_SCRUB_OFFSET , val)); +/* +* The scrubbing registers flush the cache in RAM and can also +* invalidate. +*/ break ;
@@ -1022,15 +1075,6 @@ static uint64_t pnv_xive_ic_reg_read(void *opaque, hwaddr offset, unsigned size)case PC_GLOBAL_CONFIG :case PC_VPC_SCRUB_MASK : -case PC_VPC_CWATCH_SPEC : -case PC_VPC_CWATCH_DAT0 : -case PC_VPC_CWATCH_DAT1 : -case PC_VPC_CWATCH_DAT2 : -case PC_VPC_CWATCH_DAT3 : -case PC_VPC_CWATCH_DAT4 : -case PC_VPC_CWATCH_DAT5 : -case PC_VPC_CWATCH_DAT6 : -case PC_VPC_CWATCH_DAT7 :case VC_GLOBAL_CONFIG :case VC_AIB_TX_ORDER_TAG2 :
@@ -1043,12 +1087,6 @@ static uint64_t pnv_xive_ic_reg_read(void *opaque, hwaddr offset, unsigned size)case VC_IRQ_CONFIG_IPI_CASC :case VC_EQC_SCRUB_MASK : -case VC_EQC_CWATCH_DAT0 : -case VC_EQC_CWATCH_DAT1 : -case VC_EQC_CWATCH_DAT2 : -case VC_EQC_CWATCH_DAT3 : - -case VC_EQC_CWATCH_SPEC :case VC_IVC_SCRUB_MASK :case VC_SBC_CONFIG :case VC_AT_MACRO_KILL_MASK :
@@ -1080,6 +1118,38 @@ static uint64_t pnv_xive_ic_reg_read(void *opaque, hwaddr offset, unsigned size)/* * XIVE PC & VC cache updates for EAS, NVT and END */ +case VC_EQC_CWATCH_SPEC : + xive->regs[reg] = ~(VC_EQC_CWATCH_FULL |VC_EQC_CWATCH_CONFLICT ); + val = xive->regs[reg]; +break ; +case VC_EQC_CWATCH_DAT0 : +/* +* Load DATA registers from cache with data requested by the +* SPEC register +*/ +pnv_xive_end_cache_load (xive); + val = xive->regs[reg]; +break ; + case VC_EQC_CWATCH_DAT1 ... VC_EQC_CWATCH_DAT3: + val = xive->regs[reg]; +break ; + +case PC_VPC_CWATCH_SPEC : + xive->regs[reg] = ~(PC_VPC_CWATCH_FULL |PC_VPC_CWATCH_CONFLICT ); + val = xive->regs[reg]; +break ; +case PC_VPC_CWATCH_DAT0 : +/* +* Load DATA registers from cache with data requested by the +* SPEC register +*/ +pnv_xive_nvt_cache_load (xive); + val = xive->regs[reg]; +break ; + case PC_VPC_CWATCH_DAT1 ... PC_VPC_CWATCH_DAT7: + val = xive->regs[reg]; +break ; +case PC_VPC_SCRUB_TRIG :case VC_IVC_SCRUB_TRIG :case VC_EQC_SCRUB_TRIG :
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 03/10] ppc/pnv: Rework cache watch model of PnvXIVE
Quoted 16 lines · Cédric Le Goater
When the software modifies the XIVE internal structures, ESB, EAS, END, NVT, it also must update the caches of the different XIVE sub-engines. HW offers a set of common interface for such purpose.
The
CWATCH_SPECregister defines the block/index of the target and a set of flags to perform a full update and to watch for update conflicts.The cache watch
CWATCH_DATAXregisters are then loaded with the target data with a first read onCWATCH_DATA0. Writing back is done in the opposit order,CWATCH_DATA0triggering the update.The
SCRUB_TRIGregisters are used to flush the cache in RAM, and to possibly invalidate it. Cache disablement is also an option but as we do not model the cache, these registers are no-ops
Quoted 6 lines
Today, the modeling of these registers is incorrect but it did not impact the set up of a baremetal system. However, running KVM requires a rework.
Fixes 2dfa91a2aa5a ("ppc/pnv: add a XIVE interrupt controller model for POWER9")Signed-off-by Cédric Le Goater <[email protected]>
Pushing it for what counts as a bugfix this close to freeze, but I'll take it. Applied to ppc-for-4.1.
Quoted 240 lines
--- hw/intc/pnv_xive.c | 142 +++++++++++++++++++++++++++++++++------------ 1 file changed, 106 insertions(+), 36 deletions(-)hw/intc/pnv_xive.c +106
-36@@ -169,7 +169,7 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, vsd =ldq_be_dma (&address_space_memory, vsd_addr);if (!(vsd &VSD_ADDRESS_MASK )) { -xive_error (xive,"VST: invalid %s entry %x !?" , info->name,0 ); +xive_error (xive,"VST: invalid %s entry %x !?" , info->name, idx);return 0 ; }@@ -190,7 +190,7 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, vsd =ldq_be_dma (&address_space_memory, vsd_addr);if (!(vsd &VSD_ADDRESS_MASK )) { -xive_error (xive,"VST: invalid %s entry %x !?" , info->name,0 ); +xive_error (xive,"VST: invalid %s entry %x !?" , info->name, idx);return 0 ; }@@ -294,8 +294,12 @@ static int pnv_xive_write_end(XiveRouter *xrtr, uint8_t blk, uint32_t idx, word_number); } -static int pnv_xive_end_update (PnvXive *xive,uint8_t blk,uint32_t idx) +static int pnv_xive_end_update (PnvXive *xive) { +uint8_t blk =GETFIELD (VC_EQC_CWATCH_BLOCKID , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (VC_EQC_CWATCH_OFFSET , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]);int i;uint64_t eqc_watch[4 ];@@ -307,6 +311,24 @@ static int pnv_xive_end_update(PnvXive *xive, uint8_t blk, uint32_t idx) XIVE_VST_WORD_ALL); } +static void pnv_xive_end_cache_load (PnvXive *xive) +{ +uint8_t blk =GETFIELD (VC_EQC_CWATCH_BLOCKID , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (VC_EQC_CWATCH_OFFSET , + xive->regs[(VC_EQC_CWATCH_SPEC >>3 )]); +uint64_t eqc_watch[4 ] = {0 }; +int i; + +if (pnv_xive_vst_read (xive,VST_TSEL_EQDT , blk, idx, eqc_watch)) { +xive_error (xive,"VST: no END entry %x/%x !?" , blk, idx); + } + +for (i =0 ; i <ARRAY_SIZE (eqc_watch); i++) { + xive->regs[(VC_EQC_CWATCH_DAT0 >>3 ) + i] =be64_to_cpu (eqc_watch[i]); + } +} +static int pnv_xive_get_nvt (XiveRouter *xrtr,uint8_t blk,uint32_t idx,XiveNVT *nvt) {@@ -320,8 +342,12 @@ static int pnv_xive_write_nvt(XiveRouter *xrtr, uint8_t blk, uint32_t idx, word_number); } -static int pnv_xive_nvt_update (PnvXive *xive,uint8_t blk,uint32_t idx) +static int pnv_xive_nvt_update (PnvXive *xive) { +uint8_t blk =GETFIELD (PC_VPC_CWATCH_BLOCKID , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (PC_VPC_CWATCH_OFFSET , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]);int i;uint64_t vpc_watch[8 ];@@ -333,6 +359,24 @@ static int pnv_xive_nvt_update(PnvXive *xive, uint8_t blk, uint32_t idx) XIVE_VST_WORD_ALL); } +static void pnv_xive_nvt_cache_load (PnvXive *xive) +{ +uint8_t blk =GETFIELD (PC_VPC_CWATCH_BLOCKID , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]); +uint32_t idx =GETFIELD (PC_VPC_CWATCH_OFFSET , + xive->regs[(PC_VPC_CWATCH_SPEC >>3 )]); +uint64_t vpc_watch[8 ] = {0 }; +int i; + +if (pnv_xive_vst_read (xive,VST_TSEL_VPDT , blk, idx, vpc_watch)) { +xive_error (xive,"VST: no NVT entry %x/%x !?" , blk, idx); + } + +for (i =0 ; i <ARRAY_SIZE (vpc_watch); i++) { + xive->regs[(PC_VPC_CWATCH_DAT0 >>3 ) + i] =be64_to_cpu (vpc_watch[i]); + } +} +static int pnv_xive_get_eas (XiveRouter *xrtr,uint8_t blk,uint32_t idx,XiveEAS *eas) {@@ -346,12 +390,6 @@ static int pnv_xive_get_eas(XiveRouter *xrtr, uint8_t blk, uint32_t idx,return pnv_xive_vst_read (xive,VST_TSEL_IVT , blk, idx, eas); } -static int pnv_xive_eas_update (PnvXive *xive,uint8_t blk,uint32_t idx) -{ -/* All done. */ -return 0 ; -} -static XiveTCTX *pnv_xive_get_tctx (XiveRouter *xrtr,CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);@@ -950,28 +988,43 @@ static void pnv_xive_ic_reg_write(void *opaque, hwaddr offset,* XIVE PC & VC cache updates for EAS, NVT and END */ case VC_IVC_SCRUB_MASK : -break ;case VC_IVC_SCRUB_TRIG : -pnv_xive_eas_update (xive,GETFIELD (PC_SCRUB_BLOCK_ID , val), -GETFIELD (VC_SCRUB_OFFSET , val));break ; -case VC_EQC_SCRUB_MASK :case VC_EQC_CWATCH_SPEC : - case VC_EQC_CWATCH_DAT0 ... VC_EQC_CWATCH_DAT3: + val &= ~VC_EQC_CWATCH_CONFLICT ;/* HW resets this bit */ +break ; + case VC_EQC_CWATCH_DAT1 ... VC_EQC_CWATCH_DAT3:break ; +case VC_EQC_CWATCH_DAT0 : +/* writing to DATA0 triggers the cache write */ + xive->regs[reg] = val; +pnv_xive_end_update (xive); +break ; +case VC_EQC_SCRUB_MASK :case VC_EQC_SCRUB_TRIG : -pnv_xive_end_update (xive,GETFIELD (VC_SCRUB_BLOCK_ID , val), -GETFIELD (VC_SCRUB_OFFSET , val)); +/* +* The scrubbing registers flush the cache in RAM and can also +* invalidate. +*/ break ; -case PC_VPC_SCRUB_MASK :case PC_VPC_CWATCH_SPEC : - case PC_VPC_CWATCH_DAT0 ... PC_VPC_CWATCH_DAT7: + val &= ~PC_VPC_CWATCH_CONFLICT ;/* HW resets this bit */ +break ; + case PC_VPC_CWATCH_DAT1 ... PC_VPC_CWATCH_DAT7:break ; +case PC_VPC_CWATCH_DAT0 : +/* writing to DATA0 triggers the cache write */ + xive->regs[reg] = val; +pnv_xive_nvt_update (xive); +break ; +case PC_VPC_SCRUB_MASK :case PC_VPC_SCRUB_TRIG : -pnv_xive_nvt_update (xive,GETFIELD (PC_SCRUB_BLOCK_ID , val), -GETFIELD (PC_SCRUB_OFFSET , val)); +/* +* The scrubbing registers flush the cache in RAM and can also +* invalidate. +*/ break ;@@ -1022,15 +1075,6 @@ static uint64_t pnv_xive_ic_reg_read(void *opaque, hwaddr offset, unsigned size)case PC_GLOBAL_CONFIG :case PC_VPC_SCRUB_MASK : -case PC_VPC_CWATCH_SPEC : -case PC_VPC_CWATCH_DAT0 : -case PC_VPC_CWATCH_DAT1 : -case PC_VPC_CWATCH_DAT2 : -case PC_VPC_CWATCH_DAT3 : -case PC_VPC_CWATCH_DAT4 : -case PC_VPC_CWATCH_DAT5 : -case PC_VPC_CWATCH_DAT6 : -case PC_VPC_CWATCH_DAT7 :case VC_GLOBAL_CONFIG :case VC_AIB_TX_ORDER_TAG2 :@@ -1043,12 +1087,6 @@ static uint64_t pnv_xive_ic_reg_read(void *opaque, hwaddr offset, unsigned size)case VC_IRQ_CONFIG_IPI_CASC :case VC_EQC_SCRUB_MASK : -case VC_EQC_CWATCH_DAT0 : -case VC_EQC_CWATCH_DAT1 : -case VC_EQC_CWATCH_DAT2 : -case VC_EQC_CWATCH_DAT3 : - -case VC_EQC_CWATCH_SPEC :case VC_IVC_SCRUB_MASK :case VC_SBC_CONFIG :case VC_AT_MACRO_KILL_MASK :@@ -1080,6 +1118,38 @@ static uint64_t pnv_xive_ic_reg_read(void *opaque, hwaddr offset, unsigned size)/* * XIVE PC & VC cache updates for EAS, NVT and END */ +case VC_EQC_CWATCH_SPEC : + xive->regs[reg] = ~(VC_EQC_CWATCH_FULL |VC_EQC_CWATCH_CONFLICT ); + val = xive->regs[reg]; +break ; +case VC_EQC_CWATCH_DAT0 : +/* +* Load DATA registers from cache with data requested by the +* SPEC register +*/ +pnv_xive_end_cache_load (xive); + val = xive->regs[reg]; +break ; + case VC_EQC_CWATCH_DAT1 ... VC_EQC_CWATCH_DAT3: + val = xive->regs[reg]; +break ; + +case PC_VPC_CWATCH_SPEC : + xive->regs[reg] = ~(PC_VPC_CWATCH_FULL |PC_VPC_CWATCH_CONFLICT ); + val = xive->regs[reg]; +break ; +case PC_VPC_CWATCH_DAT0 : +/* +* Load DATA registers from cache with data requested by the +* SPEC register +*/ +pnv_xive_nvt_cache_load (xive); + val = xive->regs[reg]; +break ; + case PC_VPC_CWATCH_DAT1 ... PC_VPC_CWATCH_DAT7: + val = xive->regs[reg]; +break ; +case PC_VPC_SCRUB_TRIG :case VC_IVC_SCRUB_TRIG :case VC_EQC_SCRUB_TRIG :
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 4/10 ppc/xive: Fix TM_PULL_POOL_CTX special operation
In reply to Cédric Le GoaterWhen a CPU is reseted, the hypervisor (Linux or OPAL) invalidates the POOL interrupt context of a CPU with this special command. It returns the POOL CAM line value and resets the VP bit.
--- hw/intc/xive.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
hw/intc/xive.c +10 -9
@@ -132,6 +132,11 @@ static void xive_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr)xive_tctx_notify (tctx, ring); } +static inline uint32_t xive_tctx_word2 (uint8_t *ring) +{ +return *((uint32_t *) &ring[TM_WORD2 ]); +} +/* * XIVE Thread Interrupt Management Area (TIMA) */
@@ -150,11 +155,12 @@ static uint64_t xive_tm_ack_hv_reg(XiveTCTX *tctx, hwaddr offset, unsigned size)static uint64_t xive_tm_pull_pool_ctx (XiveTCTX *tctx,hwaddr offset,unsigned size) { -uint64_t ret; +uint32_t qw2w2_prev =xive_tctx_word2 (&tctx->regs[TM_QW2_HV_POOL ]); +uint32_t qw2w2; - ret = tctx->regs[TM_QW2_HV_POOL +TM_WORD2 ] &TM_QW2W2_POOL_CAM ; - tctx->regs[TM_QW2_HV_POOL +TM_WORD2 ] &= ~TM_QW2W2_POOL_CAM ; -return ret; + qw2w2 =xive_set_field32 (TM_QW2W2_VP , qw2w2_prev,0 ); +memcpy (&tctx->regs[TM_QW2_HV_POOL +TM_WORD2 ], &qw2w2,4 ); +return qw2w2; } static void xive_tm_vt_push(XiveTCTX *tctx, hwaddr offset,
@@ -484,11 +490,6 @@ const MemoryRegionOps xive_tm_ops = { }, }; -static inline uint32_t xive_tctx_word2 (uint8_t *ring) -{ -return *((uint32_t *) &ring[TM_WORD2 ]); -} -static char *xive_tctx_ring_print (uint8_t *ring) {uint32_t w2 =xive_tctx_word2 (ring);
Signature · 1 line
2.21.0
David Gibson
AppliedRe: [Qemu-devel] [PATCH 04/10] ppc/xive: Fix TM_PULL_POOL_CTX special operation
Quoted 6 lines · Cédric Le Goater
When a CPU is reseted, the hypervisor (Linux or OPAL) invalidates the POOL interrupt context of a CPU with this special command. It returns the POOL CAM line value and resets the VP bit.
Fixes 4836b45510aa ("ppc/xive: activate HV support")Signed-off-by Cédric Le Goater <[email protected]>
Applied to ppc-for-4.1.
Quoted 49 lines
--- hw/intc/xive.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)hw/intc/xive.c +10
-9@@ -132,6 +132,11 @@ static void xive_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr)xive_tctx_notify (tctx, ring); } +static inline uint32_t xive_tctx_word2 (uint8_t *ring) +{ +return *((uint32_t *) &ring[TM_WORD2 ]); +} +/* * XIVE Thread Interrupt Management Area (TIMA) */ @@ -150,11 +155,12 @@ static uint64_t xive_tm_ack_hv_reg(XiveTCTX *tctx, hwaddr offset, unsigned size)static uint64_t xive_tm_pull_pool_ctx (XiveTCTX *tctx,hwaddr offset,unsigned size) { -uint64_t ret; +uint32_t qw2w2_prev =xive_tctx_word2 (&tctx->regs[TM_QW2_HV_POOL ]); +uint32_t qw2w2; - ret = tctx->regs[TM_QW2_HV_POOL +TM_WORD2 ] &TM_QW2W2_POOL_CAM ; - tctx->regs[TM_QW2_HV_POOL +TM_WORD2 ] &= ~TM_QW2W2_POOL_CAM ; -return ret; + qw2w2 =xive_set_field32 (TM_QW2W2_VP , qw2w2_prev,0 ); +memcpy (&tctx->regs[TM_QW2_HV_POOL +TM_WORD2 ], &qw2w2,4 ); +return qw2w2; } static void xive_tm_vt_push(XiveTCTX *tctx, hwaddr offset,@@ -484,11 +490,6 @@ const MemoryRegionOps xive_tm_ops = { }, }; -static inline uint32_t xive_tctx_word2 (uint8_t *ring) -{ -return *((uint32_t *) &ring[TM_WORD2 ]); -} -static char *xive_tctx_ring_print (uint8_t *ring) {uint32_t w2 =xive_tctx_word2 (ring);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 5/10 ppc/xive: Implement TM_PULL_OS_CTX special command
In reply to Cédric Le GoaterWhen a vCPU is not dispatched anymore on a HW thread, the Hypervisor (KVM) invalidates the OS interrupt context of a vCPU with this special command. It returns the OS CAM line value and resets the VO bit.
--- hw/intc/xive.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
hw/intc/xive.c +14 -1
@@ -334,6 +334,17 @@ static void xive_tm_set_os_pending(XiveTCTX *tctx, hwaddr offset,xive_tctx_notify (tctx,TM_QW1_OS ); } +static uint64_t xive_tm_pull_os_ctx (XiveTCTX *tctx,hwaddr offset, +unsigned size) +{ +uint32_t qw1w2_prev =xive_tctx_word2 (&tctx->regs[TM_QW1_OS ]); +uint32_t qw1w2; + + qw1w2 =xive_set_field32 (TM_QW1W2_VO , qw1w2_prev,0 ); +memcpy (&tctx->regs[TM_QW1_OS +TM_WORD2 ], &qw1w2,4 ); +return qw1w2; +} +/* * Define a mapping of "special" operations depending on the TIMA page * offset and the size of the operation.
@@ -360,6 +371,8 @@ static const XiveTmOp xive_tm_operations[] = {/* 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 },
@@ -403,7 +416,7 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,if (offset &0x800 ) { xto =xive_tm_find_op (offset, size, true);if (!xto) { -qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid write access at TIMA" +qemu_log_mask (LOG_GUEST_ERROR ,"XIVE: invalid write access at TIMA " "@%" HWADDR_PRIx"\n" , offset); }else { xto->write_handler (tctx, offset, value, size);
Signature · 1 line
2.21.0
PATCH 6/10 ppc/xive: Provide escalation support
In reply to Cédric Le GoaterIf the XIVE presenter can not find the NVT dispatched on any of the HW threads, it can not deliver the interrupt. XIVE offers a mechanism to handle such scenarios and inform the hypervisor that an action should be taken.
The first action is to keep track of the pending priority of the missed event. It is recorded in the IPB field of the NVT for a later resend if backlog is activated ('b' bit) on the END.
An END can also escalate if configured: 'e' bit and setting of the EAS in word 4 & 5 to let the HW look for the escalation END on which to trigger a new event. Escalation has its own options to program different behaviors :
- unconditional escalation ('u' bit) with which the ESe PQ bits are not used.
- silent/gather escalation ('s' bit), the sequence skips the notification process and jumps directly to the escalation.
KVM uses a combination of these. The first level END is configured to enqueue, unconditionally notify, backlog and escalate and points to an escalation END which is configured to escalate silently.
--- include/hw/ppc/xive_regs.h | 4 ++ hw/intc/xive.c | 130 +++++++++++++++++++++++++++++++------ 2 files changed, 115 insertions(+), 19 deletions(-)
include/hw/ppc/xive_regs.h +4 -0
@@ -207,6 +207,10 @@ typedef struct XiveEND {#define xive_end_is_notify (end) (be32_to_cpu((end)->w0) & END_W0_UCOND_NOTIFY)#define xive_end_is_backlog (end) (be32_to_cpu((end)->w0) & END_W0_BACKLOG)#define xive_end_is_escalate (end) (be32_to_cpu((end)->w0) & END_W0_ESCALATE_CTL) +#define xive_end_is_uncond_escalation (end) \ + (be32_to_cpu((end)->w0) & END_W0_UNCOND_ESCALATE) +#define xive_end_is_silent_escalation (end) \ + (be32_to_cpu((end)->w0) & END_W0_SILENT_ESCALATE)static inline uint64_t xive_end_qaddr (XiveEND *end) {
hw/intc/xive.c +111 -19
191 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 7/10 ppc/xive: Improve 'info pic' support
In reply to Cédric Le GoaterProvide a better output of the XIVE END structures including the escalation information and extend the PowerNV machine 'info pic' command with a dump of the END EAS table used for escalations.
--- include/hw/ppc/xive.h | 5 ---- include/hw/ppc/xive_regs.h | 6 +++++ hw/intc/pnv_xive.c | 9 +++++++ hw/intc/spapr_xive.c | 1 - hw/intc/xive.c | 48 +++++++++++++++++++++++++++++++++----- 5 files changed, 57 insertions(+), 12 deletions(-)
include/hw/ppc/xive.h +0 -5
@@ -356,8 +356,6 @@ typedef struct XiveRouterClass { XiveTCTX *(*get_tctx)(XiveRouter *xrtr, CPUState *cs); } XiveRouterClass; -void xive_eas_pic_print_info (XiveEAS *eas,uint32_t lisn,Monitor *mon); -int xive_router_get_eas (XiveRouter *xrtr,uint8_t eas_blk,uint32_t eas_idx,XiveEAS *eas); int xive_router_get_end(XiveRouter *xrtr, uint8_t end_blk, uint32_t end_idx,
@@ -399,9 +397,6 @@ typedef struct XiveENDSource {*/ #define XIVE_PRIORITY_MAX 7 -void xive_end_pic_print_info (XiveEND *end,uint32_t end_idx,Monitor *mon); -void xive_end_queue_pic_print_info (XiveEND *end,uint32_t width,Monitor *mon); -/* * XIVE Thread Interrupt Management Aera (TIMA) *
include/hw/ppc/xive_regs.h +6 -0
@@ -128,6 +128,8 @@ typedef struct XiveEAS {#define xive_eas_is_valid (eas) (be64_to_cpu((eas)->w) & EAS_VALID)#define xive_eas_is_masked (eas) (be64_to_cpu((eas)->w) & EAS_MASKED) +void xive_eas_pic_print_info (XiveEAS *eas,uint32_t lisn,Monitor *mon); +static inline uint64_t xive_get_field64 (uint64_t mask,uint64_t word) {return (be64_to_cpu (word) & mask) >>ctz64 (mask);
@@ -218,6 +220,10 @@ static inline uint64_t xive_end_qaddr(XiveEND *end)be32_to_cpu (end->w3); } +void xive_end_pic_print_info (XiveEND *end,uint32_t end_idx,Monitor *mon); +void xive_end_queue_pic_print_info (XiveEND *end,uint32_t width,Monitor *mon); +void xive_end_eas_pic_print_info (XiveEND *end,uint32_t end_idx,Monitor *mon); +/* Notification Virtual Target (NVT) */ typedef struct XiveNVT { uint32_t w0;
hw/intc/pnv_xive.c +9 -0
@@ -1593,6 +1593,15 @@ void pnv_xive_pic_print_info(PnvXive *xive, Monitor *mon) }xive_end_pic_print_info (&end, i, mon); } + +monitor_printf (mon,"XIVE[%x] END Escalation %08x .. %08x\n" , blk,0 , + nr_ends -1 ); +for (i =0 ; i < nr_ends; i++) { +if (xive_router_get_end (xrtr, blk, i, &end)) { +break ; + } +xive_end_eas_pic_print_info (&end, i, mon); + } }static void pnv_xive_reset (void *dev)
hw/intc/spapr_xive.c +0 -1
@@ -143,7 +143,6 @@ static void spapr_xive_end_pic_print_info(SpaprXive *xive, XiveEND *end, priority, qindex, qentries, qaddr_base, qgen);xive_end_queue_pic_print_info (end,6 , mon); -monitor_printf (mon,"]" ); }void spapr_xive_pic_print_info (SpaprXive *xive,Monitor *mon)
hw/intc/xive.c +42 -6
78 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 8/10 ppc/xive: Extend XiveTCTX with an router object pointer
In reply to Cédric Le GoaterThis is to perform lookups in the NVT table when a vCPU is dispatched and possibly resend interrupts.
Future XIVE chip will use a different class for the model of the interrupt controller. So use an 'Object *' instead of a 'XiveRouter *'.
--- include/hw/ppc/xive.h | 4 +++- hw/intc/xive.c | 11 ++++++++++- hw/ppc/pnv.c | 2 +- hw/ppc/spapr_irq.c | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-)
include/hw/ppc/xive.h +3 -1
@@ -321,6 +321,8 @@ typedef struct XiveTCTX {qemu_irq os_output;uint8_t regs[XIVE_TM_RING_COUNT *XIVE_TM_RING_SIZE ]; + +Object *xrtr; } XiveTCTX;/*
@@ -416,7 +418,7 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,uint64_t xive_tctx_tm_read (XiveTCTX *tctx,hwaddr offset,unsigned size);void xive_tctx_pic_print_info (XiveTCTX *tctx,Monitor *mon); -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp); +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp);static inline uint32_t xive_nvt_cam_line (uint8_t nvt_blk,uint32_t nvt_idx) {
hw/intc/xive.c +10 -1
@@ -573,6 +573,14 @@ static void xive_tctx_realize(DeviceState *dev, Error **errp)Object *obj;Error *local_err =NULL ; + obj =object_property_get_link (OBJECT (dev),"xrtr" , &local_err); +if (!obj) { +error_propagate (errp, local_err); +error_prepend (errp,"required link 'xrtr' not found: " ); +return ; + } + tctx->xrtr = obj; + obj =object_property_get_link (OBJECT (dev),"cpu" , &local_err);if (!obj) {error_propagate (errp, local_err);
@@ -657,7 +665,7 @@ static const TypeInfo xive_tctx_info = { .class_init = xive_tctx_class_init, }; -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp) +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp) {Error *local_err =NULL ;Object *obj;
@@ -666,6 +674,7 @@ Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)object_property_add_child (cpu,TYPE_XIVE_TCTX , obj, &error_abort);object_unref (obj);object_property_add_const_link (obj,"cpu" , cpu, &error_abort); +object_property_add_const_link (obj,"xrtr" , xrtr, &error_abort);object_property_set_bool (obj, true,"realized" , &local_err);if (local_err) { goto error;
hw/ppc/pnv.c +1 -1
@@ -765,7 +765,7 @@ static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,* controller object is initialized afterwards. Hopefully, it's * only used at runtime. */ - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (&chip9->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (&chip9->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;
hw/ppc/spapr_irq.c +1 -1
@@ -353,7 +353,7 @@ static void spapr_irq_cpu_intc_create_xive(SpaprMachineState *spapr,Object *obj;SpaprCpuState *spapr_cpu =spapr_cpu_state (cpu); - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (spapr->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (spapr->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 08/10] ppc/xive: Extend XiveTCTX with an router object pointer
Quoted 2 lines · Cédric Le Goater
This is to perform lookups in the NVT table when a vCPU is dispatched and possibly resend interrupts.
I'm slightly confused by this one. Aren't there multiple router objects, each of which can deliver to any thread? In which case what router object is associated with a specific TCTX?
Quoted 2 lines
Future XIVE chip will use a different class for the model of the interrupt controller. So use an 'Object *' instead of a 'XiveRouter *'.
This seems odd to me, shouldn't it be an interface pointer or something in that case?
Quoted 93 lines
Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/ppc/xive.h | 4 +++- hw/intc/xive.c | 11 ++++++++++- hw/ppc/pnv.c | 2 +- hw/ppc/spapr_irq.c | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-)include/hw/ppc/xive.h +3
-1@@ -321,6 +321,8 @@ typedef struct XiveTCTX {qemu_irq os_output;uint8_t regs[XIVE_TM_RING_COUNT *XIVE_TM_RING_SIZE ]; + +Object *xrtr; } XiveTCTX;/* @@ -416,7 +418,7 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,uint64_t xive_tctx_tm_read (XiveTCTX *tctx,hwaddr offset,unsigned size);void xive_tctx_pic_print_info (XiveTCTX *tctx,Monitor *mon); -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp); +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp);static inline uint32_t xive_nvt_cam_line (uint8_t nvt_blk,uint32_t nvt_idx) {hw/intc/xive.c +10
-1@@ -573,6 +573,14 @@ static void xive_tctx_realize(DeviceState *dev, Error **errp)Object *obj;Error *local_err =NULL ; + obj =object_property_get_link (OBJECT (dev),"xrtr" , &local_err); +if (!obj) { +error_propagate (errp, local_err); +error_prepend (errp,"required link 'xrtr' not found: " ); +return ; + } + tctx->xrtr = obj; + obj =object_property_get_link (OBJECT (dev),"cpu" , &local_err);if (!obj) {error_propagate (errp, local_err);@@ -657,7 +665,7 @@ static const TypeInfo xive_tctx_info = { .class_init = xive_tctx_class_init, }; -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp) +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp) {Error *local_err =NULL ;Object *obj;@@ -666,6 +674,7 @@ Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)object_property_add_child (cpu,TYPE_XIVE_TCTX , obj, &error_abort);object_unref (obj);object_property_add_const_link (obj,"cpu" , cpu, &error_abort); +object_property_add_const_link (obj,"xrtr" , xrtr, &error_abort);object_property_set_bool (obj, true,"realized" , &local_err);if (local_err) { goto error;hw/ppc/pnv.c +1
-1@@ -765,7 +765,7 @@ static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,* controller object is initialized afterwards. Hopefully, it's * only used at runtime. */ - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (&chip9->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (&chip9->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;hw/ppc/spapr_irq.c +1
-1@@ -353,7 +353,7 @@ static void spapr_irq_cpu_intc_create_xive(SpaprMachineState *spapr,Object *obj;SpaprCpuState *spapr_cpu =spapr_cpu_state (cpu); - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (spapr->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (spapr->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 08/10] ppc/xive: Extend XiveTCTX with an router object pointer
Quoted 7 lines · David Gibson
Quoted 2 lines · Cédric Le Goater
This is to perform lookups in the NVT table when a vCPU is dispatched and possibly resend interrupts.
I'm slightly confused by this one. Aren't there multiple router objects, each of which can deliver to any thread? In which case what router object is associated with a specific TCTX?
when a vCPU is dispatched on a HW thread, the hypervisor does a store on the CAM line to store the VP id. At that time, it checks the IPB in the associated NVT structure and notifies the thread if an interrupt is pending.
We need to do a NVT lookup, just like the presenter in HW, hence the router pointer. You should look at the following patch which clarifies the resend sequence.
Quoted 5 lines
Quoted 2 lines
Future XIVE chip will use a different class for the model of the interrupt controller. So use an 'Object *' instead of a 'XiveRouter *'.
This seems odd to me, shouldn't it be an interface pointer or something in that case?
I have duplicated most of the XIVE models for P10 because the internal structures have changed. I managed to keep the XiveSource and XiveTCTX but we now have a Xive10Router, this is the reason why.
If I was to duplicate XiveTCTX also, I will switch it back to a XiveRouter pointer in the P9 version.
C.
Quoted 94 lines
Quoted 93 lines
Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/ppc/xive.h | 4 +++- hw/intc/xive.c | 11 ++++++++++- hw/ppc/pnv.c | 2 +- hw/ppc/spapr_irq.c | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-)include/hw/ppc/xive.h +3
-1@@ -321,6 +321,8 @@ typedef struct XiveTCTX {qemu_irq os_output;uint8_t regs[XIVE_TM_RING_COUNT *XIVE_TM_RING_SIZE ]; + +Object *xrtr; } XiveTCTX;/* @@ -416,7 +418,7 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,uint64_t xive_tctx_tm_read (XiveTCTX *tctx,hwaddr offset,unsigned size);void xive_tctx_pic_print_info (XiveTCTX *tctx,Monitor *mon); -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp); +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp);static inline uint32_t xive_nvt_cam_line (uint8_t nvt_blk,uint32_t nvt_idx) {hw/intc/xive.c +10
-1@@ -573,6 +573,14 @@ static void xive_tctx_realize(DeviceState *dev, Error **errp)Object *obj;Error *local_err =NULL ; + obj =object_property_get_link (OBJECT (dev),"xrtr" , &local_err); +if (!obj) { +error_propagate (errp, local_err); +error_prepend (errp,"required link 'xrtr' not found: " ); +return ; + } + tctx->xrtr = obj; + obj =object_property_get_link (OBJECT (dev),"cpu" , &local_err);if (!obj) {error_propagate (errp, local_err);@@ -657,7 +665,7 @@ static const TypeInfo xive_tctx_info = { .class_init = xive_tctx_class_init, }; -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp) +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp) {Error *local_err =NULL ;Object *obj;@@ -666,6 +674,7 @@ Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)object_property_add_child (cpu,TYPE_XIVE_TCTX , obj, &error_abort);object_unref (obj);object_property_add_const_link (obj,"cpu" , cpu, &error_abort); +object_property_add_const_link (obj,"xrtr" , xrtr, &error_abort);object_property_set_bool (obj, true,"realized" , &local_err);if (local_err) { goto error;hw/ppc/pnv.c +1
-1@@ -765,7 +765,7 @@ static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,* controller object is initialized afterwards. Hopefully, it's * only used at runtime. */ - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (&chip9->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (&chip9->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;hw/ppc/spapr_irq.c +1
-1@@ -353,7 +353,7 @@ static void spapr_irq_cpu_intc_create_xive(SpaprMachineState *spapr,Object *obj;SpaprCpuState *spapr_cpu =spapr_cpu_state (cpu); - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (spapr->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (spapr->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;
Re: [Qemu-devel] [PATCH 08/10] ppc/xive: Extend XiveTCTX with an router object pointer
Quoted 9 lines · Cédric Le Goater
Quoted 7 lines · David Gibson
Quoted 2 lines · Cédric Le Goater
This is to perform lookups in the NVT table when a vCPU is dispatched and possibly resend interrupts.
I'm slightly confused by this one. Aren't there multiple router objects, each of which can deliver to any thread? In which case what router object is associated with a specific TCTX?
Quoted 8 lines
when a vCPU is dispatched on a HW thread, the hypervisor does a store on the CAM line to store the VP id. At that time, it checks the IPB in the associated NVT structure and notifies the thread if an interrupt is pending.
We need to do a NVT lookup, just like the presenter in HW, hence the router pointer. You should look at the following patch which clarifies the resend sequence.
Hm, ok.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Future XIVE chip will use a different class for the model of the interrupt controller. So use an 'Object *' instead of a 'XiveRouter *'.
This seems odd to me, shouldn't it be an interface pointer or something in that case?
I have duplicated most of the XIVE models for P10 because the internal structures have changed. I managed to keep the XiveSource and XiveTCTX but we now have a Xive10Router, this is the reason why.
Right, but XiveRouter and Xive10Router must have something in common if they can both be used here. Usually that's expressed as a shared QOM interface - in which case you can use a pointer to the interface, rathe than using Object * which kind of implies *anything* can go here.
Quoted 102 lines
If I was to duplicate XiveTCTX also, I will switch it back to a XiveRouter pointer in the P9 version.
C.
Quoted 94 lines
Quoted 93 lines
Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/ppc/xive.h | 4 +++- hw/intc/xive.c | 11 ++++++++++- hw/ppc/pnv.c | 2 +- hw/ppc/spapr_irq.c | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-)include/hw/ppc/xive.h +3
-1@@ -321,6 +321,8 @@ typedef struct XiveTCTX {qemu_irq os_output;uint8_t regs[XIVE_TM_RING_COUNT *XIVE_TM_RING_SIZE ]; + +Object *xrtr; } XiveTCTX;/* @@ -416,7 +418,7 @@ void xive_tctx_tm_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,uint64_t xive_tctx_tm_read (XiveTCTX *tctx,hwaddr offset,unsigned size);void xive_tctx_pic_print_info (XiveTCTX *tctx,Monitor *mon); -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp); +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp);static inline uint32_t xive_nvt_cam_line (uint8_t nvt_blk,uint32_t nvt_idx) {hw/intc/xive.c +10
-1@@ -573,6 +573,14 @@ static void xive_tctx_realize(DeviceState *dev, Error **errp)Object *obj;Error *local_err =NULL ; + obj =object_property_get_link (OBJECT (dev),"xrtr" , &local_err); +if (!obj) { +error_propagate (errp, local_err); +error_prepend (errp,"required link 'xrtr' not found: " ); +return ; + } + tctx->xrtr = obj; + obj =object_property_get_link (OBJECT (dev),"cpu" , &local_err);if (!obj) {error_propagate (errp, local_err);@@ -657,7 +665,7 @@ static const TypeInfo xive_tctx_info = { .class_init = xive_tctx_class_init, }; -Object *xive_tctx_create (Object *cpu,XiveRouter *xrtr,Error **errp) +Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp) {Error *local_err =NULL ;Object *obj;@@ -666,6 +674,7 @@ Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)object_property_add_child (cpu,TYPE_XIVE_TCTX , obj, &error_abort);object_unref (obj);object_property_add_const_link (obj,"cpu" , cpu, &error_abort); +object_property_add_const_link (obj,"xrtr" , xrtr, &error_abort);object_property_set_bool (obj, true,"realized" , &local_err);if (local_err) { goto error;hw/ppc/pnv.c +1
-1@@ -765,7 +765,7 @@ static void pnv_chip_power9_intc_create(PnvChip *chip, PowerPCCPU *cpu,* controller object is initialized afterwards. Hopefully, it's * only used at runtime. */ - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (&chip9->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (&chip9->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;hw/ppc/spapr_irq.c +1
-1@@ -353,7 +353,7 @@ static void spapr_irq_cpu_intc_create_xive(SpaprMachineState *spapr,Object *obj;SpaprCpuState *spapr_cpu =spapr_cpu_state (cpu); - obj =xive_tctx_create (OBJECT (cpu),XIVE_ROUTER (spapr->xive), &local_err); + obj =xive_tctx_create (OBJECT (cpu),OBJECT (spapr->xive), &local_err);if (local_err) {error_propagate (errp, local_err);return ;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 08/10] ppc/xive: Extend XiveTCTX with an router object pointer
Quoted 31 lines · David Gibson
Quoted 9 lines · Cédric Le Goater
Quoted 7 lines · David Gibson
Quoted 2 lines · Cédric Le Goater
This is to perform lookups in the NVT table when a vCPU is dispatched and possibly resend interrupts.
I'm slightly confused by this one. Aren't there multiple router objects, each of which can deliver to any thread? In which case what router object is associated with a specific TCTX?
Quoted 8 lines
when a vCPU is dispatched on a HW thread, the hypervisor does a store on the CAM line to store the VP id. At that time, it checks the IPB in the associated NVT structure and notifies the thread if an interrupt is pending.
We need to do a NVT lookup, just like the presenter in HW, hence the router pointer. You should look at the following patch which clarifies the resend sequence.
Hm, ok.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Future XIVE chip will use a different class for the model of the interrupt controller. So use an 'Object *' instead of a 'XiveRouter *'.
This seems odd to me, shouldn't it be an interface pointer or something in that case?
I have duplicated most of the XIVE models for P10 because the internal structures have changed. I managed to keep the XiveSource and XiveTCTX but we now have a Xive10Router, this is the reason why.
Quoted 5 lines
Right, but XiveRouter and Xive10Router must have something in common if they can both be used here. Usually that's expressed as a shared QOM interface - in which case you can use a pointer to the interface, rathe than using Object * which kind of implies *anything* can go here.
Yeah. I also think it would be better to have a common base object but the class don't have much in common. Here is what I have for now :
P9:
typedef struct XiveRouterClass {
SysBusDeviceClass parent;
/* XIVE table accessors */
int (*get_eas)(XiveRouter *xrtr, uint8_t eas_blk, uint32_t eas_idx,
XiveEAS *eas);
int (*get_end)(XiveRouter *xrtr, uint8_t end_blk, uint32_t end_idx,
XiveEND *end);
int (*write_end)(XiveRouter *xrtr, uint8_t end_blk, uint32_t end_idx,
XiveEND *end, uint8_t word_number);
int (*get_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx,
XiveNVT *nvt);
int (*write_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx,
XiveNVT *nvt, uint8_t word_number);
XiveTCTX *(*get_tctx)(XiveRouter *xrtr, CPUState *cs);
uint8_t (*get_block_id)(XiveRouter *xrtr);
} XiveRouterClass;and P10:
typedef struct Xive10RouterClass {
SysBusDeviceClass parent;
/* XIVE table accessors */
int (*get_eas)(Xive10Router *xrtr, uint8_t eas_blk, uint32_t eas_idx,
Xive10EAS *eas);
int (*get_end)(Xive10Router *xrtr, uint8_t end_blk, uint32_t end_idx,
Xive10END *end);
int (*write_end)(Xive10Router *xrtr, uint8_t end_blk, uint32_t end_idx,
Xive10END *end, uint8_t word_number);
int (*get_nvp)(Xive10Router *xrtr, uint8_t nvt_blk, uint32_t nvt_idx,
Xive10NVP *nvt);
int (*write_nvp)(Xive10Router *xrtr, uint8_t nvt_blk, uint32_t nvt_idx,
Xive10NVP *nvt, uint8_t word_number);
XiveTCTX *(*get_tctx)(Xive10Router *xrtr, CPUState *cs);
uint8_t (*get_block_id)(XiveRouter *xrtr);
uint32_t (*get_config)(Xive10Router *xrtr);
} Xive10RouterClass;Only get_tctx() is common.
The XIVE structures (END, NV*) used by the routing algo have changed a lot. Even the presenter has changed, because all the CAM lines have a slightly different format.
C.
Re: [Qemu-devel] [PATCH 08/10] ppc/xive: Extend XiveTCTX with an router object pointer
Quoted 32 lines · Cédric Le Goater
Quoted 31 lines · David Gibson
Quoted 9 lines · Cédric Le Goater
Quoted 7 lines · David Gibson
Quoted 2 lines · Cédric Le Goater
This is to perform lookups in the NVT table when a vCPU is dispatched and possibly resend interrupts.
I'm slightly confused by this one. Aren't there multiple router objects, each of which can deliver to any thread? In which case what router object is associated with a specific TCTX?
Quoted 8 lines
when a vCPU is dispatched on a HW thread, the hypervisor does a store on the CAM line to store the VP id. At that time, it checks the IPB in the associated NVT structure and notifies the thread if an interrupt is pending.
We need to do a NVT lookup, just like the presenter in HW, hence the router pointer. You should look at the following patch which clarifies the resend sequence.
Hm, ok.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Future XIVE chip will use a different class for the model of the interrupt controller. So use an 'Object *' instead of a 'XiveRouter *'.
This seems odd to me, shouldn't it be an interface pointer or something in that case?
I have duplicated most of the XIVE models for P10 because the internal structures have changed. I managed to keep the XiveSource and XiveTCTX but we now have a Xive10Router, this is the reason why.
Quoted 8 lines
Quoted 5 lines
Right, but XiveRouter and Xive10Router must have something in common if they can both be used here. Usually that's expressed as a shared QOM interface - in which case you can use a pointer to the interface, rathe than using Object * which kind of implies *anything* can go here.
Yeah. I also think it would be better to have a common base object but the class don't have much in common. Here is what I have for now :
Uh.. QOM interfaces don't require there to be a common base object, only common methods.
Quoted 51 lines
P9:
typedef struct XiveRouterClass { SysBusDeviceClass parent; /* XIVE table accessors */ int (*get_eas)(XiveRouter *xrtr, uint8_t eas_blk, uint32_t eas_idx, XiveEAS *eas); int (*get_end)(XiveRouter *xrtr, uint8_t end_blk, uint32_t end_idx, XiveEND *end); int (*write_end)(XiveRouter *xrtr, uint8_t end_blk, uint32_t end_idx, XiveEND *end, uint8_t word_number); int (*get_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, XiveNVT *nvt); int (*write_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, XiveNVT *nvt, uint8_t word_number); XiveTCTX *(*get_tctx)(XiveRouter *xrtr, CPUState *cs); uint8_t (*get_block_id)(XiveRouter *xrtr); } XiveRouterClass;and P10:
typedef struct Xive10RouterClass { SysBusDeviceClass parent; /* XIVE table accessors */ int (*get_eas)(Xive10Router *xrtr, uint8_t eas_blk, uint32_t eas_idx, Xive10EAS *eas); int (*get_end)(Xive10Router *xrtr, uint8_t end_blk, uint32_t end_idx, Xive10END *end); int (*write_end)(Xive10Router *xrtr, uint8_t end_blk, uint32_t end_idx, Xive10END *end, uint8_t word_number); int (*get_nvp)(Xive10Router *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, Xive10NVP *nvt); int (*write_nvp)(Xive10Router *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, Xive10NVP *nvt, uint8_t word_number); XiveTCTX *(*get_tctx)(Xive10Router *xrtr, CPUState *cs); uint8_t (*get_block_id)(XiveRouter *xrtr); uint32_t (*get_config)(Xive10Router *xrtr); } Xive10RouterClass;Only
get_tctx()is common.The XIVE structures (END, NV*) used by the routing algo have changed a lot. Even the presenter has changed, because all the CAM lines have a slightly different format.
C.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 08/10] ppc/xive: Extend XiveTCTX with an router object pointer
Quoted 39 lines · David Gibson
Quoted 38 lines · Cédric Le Goater
Quoted 36 lines · David Gibson
Quoted 9 lines · Cédric Le Goater
Quoted 7 lines · David Gibson
Quoted 2 lines · Cédric Le Goater
This is to perform lookups in the NVT table when a vCPU is dispatched and possibly resend interrupts.
I'm slightly confused by this one. Aren't there multiple router objects, each of which can deliver to any thread? In which case what router object is associated with a specific TCTX?
Quoted 8 lines
when a vCPU is dispatched on a HW thread, the hypervisor does a store on the CAM line to store the VP id. At that time, it checks the IPB in the associated NVT structure and notifies the thread if an interrupt is pending.
We need to do a NVT lookup, just like the presenter in HW, hence the router pointer. You should look at the following patch which clarifies the resend sequence.
Hm, ok.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Future XIVE chip will use a different class for the model of the interrupt controller. So use an 'Object *' instead of a 'XiveRouter *'.
This seems odd to me, shouldn't it be an interface pointer or something in that case?
I have duplicated most of the XIVE models for P10 because the internal structures have changed. I managed to keep the XiveSource and XiveTCTX but we now have a Xive10Router, this is the reason why.
Right, but XiveRouter and Xive10Router must have something in common if they can both be used here. Usually that's expressed as a shared QOM interface - in which case you can use a pointer to the interface, rathe than using Object * which kind of implies *anything* can go here.
Quoted 5 lines
Quoted 2 lines
Yeah. I also think it would be better to have a common base object but the class don't have much in common. Here is what I have for now :
Uh.. QOM interfaces don't require there to be a common base object, only common methods.
It's not a QOM interface today because it already uses an interface.
Quoted 52 lines
Quoted 51 lines
P9:
typedef struct XiveRouterClass { SysBusDeviceClass parent; /* XIVE table accessors */ int (*get_eas)(XiveRouter *xrtr, uint8_t eas_blk, uint32_t eas_idx, XiveEAS *eas); int (*get_end)(XiveRouter *xrtr, uint8_t end_blk, uint32_t end_idx, XiveEND *end); int (*write_end)(XiveRouter *xrtr, uint8_t end_blk, uint32_t end_idx, XiveEND *end, uint8_t word_number); int (*get_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, XiveNVT *nvt); int (*write_nvt)(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, XiveNVT *nvt, uint8_t word_number); XiveTCTX *(*get_tctx)(XiveRouter *xrtr, CPUState *cs); uint8_t (*get_block_id)(XiveRouter *xrtr); } XiveRouterClass;and P10:
typedef struct Xive10RouterClass { SysBusDeviceClass parent; /* XIVE table accessors */ int (*get_eas)(Xive10Router *xrtr, uint8_t eas_blk, uint32_t eas_idx, Xive10EAS *eas); int (*get_end)(Xive10Router *xrtr, uint8_t end_blk, uint32_t end_idx, Xive10END *end); int (*write_end)(Xive10Router *xrtr, uint8_t end_blk, uint32_t end_idx, Xive10END *end, uint8_t word_number); int (*get_nvp)(Xive10Router *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, Xive10NVP *nvt); int (*write_nvp)(Xive10Router *xrtr, uint8_t nvt_blk, uint32_t nvt_idx, Xive10NVP *nvt, uint8_t word_number); XiveTCTX *(*get_tctx)(Xive10Router *xrtr, CPUState *cs); uint8_t (*get_block_id)(XiveRouter *xrtr); uint32_t (*get_config)(Xive10Router *xrtr); } Xive10RouterClass;Only
get_tctx()is common.The XIVE structures (END, NV*) used by the routing algo have changed a lot. Even the presenter has changed, because all the CAM lines have a slightly different format.
C.
PATCH 9/10 ppc/xive: Synthesize interrupt from the saved IPB in the NVT
In reply to Cédric Le GoaterWhen an interrupt can not be presented to a vCPU, the XIVE presenter updates the Interrupt Pending Buffer of the XIVE NVT if backlog is activated in the END.
Later, when the same vCPU is dispatched, its context is pushed in the thread context registers and the VO bit is set in the CAM line word. The HW grabs the associated NVT to pull the pending bits, and merge them with the IPB of the TIMA. If interrupts were missed while the vCPU was not dispatched, these are synthesized in this sequence.
--- include/hw/ppc/xive.h | 14 ++++++++ include/hw/ppc/xive_regs.h | 1 + hw/intc/xive.c | 67 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 80 insertions(+), 2 deletions(-)
include/hw/ppc/xive.h +14 -0
@@ -420,11 +420,25 @@ uint64_t xive_tctx_tm_read(XiveTCTX *tctx, hwaddr offset, unsigned size);void xive_tctx_pic_print_info (XiveTCTX *tctx,Monitor *mon);Object *xive_tctx_create (Object *cpu,Object *xrtr,Error **errp); +/* +* The VP number space in a block is defined by the END_W6_NVT_INDEX +* field of the XIVE END +*/ static inline uint32_t xive_nvt_cam_line (uint8_t nvt_blk,uint32_t nvt_idx) {return (nvt_blk <<19 ) | nvt_idx; } +static inline uint32_t xive_nvt_idx (uint32_t cam_line) +{ +return cam_line &0x7ffff ; +} + +static inline uint32_t xive_nvt_blk (uint32_t cam_line) +{ +return (cam_line >>19 ) &0xf ; +} +/* * KVM XIVE device helpers */
include/hw/ppc/xive_regs.h +1 -0
@@ -232,6 +232,7 @@ typedef struct XiveNVT {uint32_t w2;uint32_t w3;uint32_t w4; +#define NVT_W4_IPB PPC_BITMASK32(16, 23)uint32_t w5;uint32_t w6;uint32_t w7;
hw/intc/xive.c +65 -2
91 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 10/10 ppc/pnv: Dump the XIVE NVT table
In reply to Cédric Le GoaterThis is to track the configuration of the base END index of the vCPU and the Interrupt Pending Buffer. The NVT IPB is updated when an interrupt can not be presented to a vCPU.
We try to loop on the full table skipping empty indirect pages which are not necessarily allocated.
--- include/hw/ppc/xive_regs.h | 2 ++ hw/intc/pnv_xive.c | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+)
include/hw/ppc/xive_regs.h +2 -0
@@ -229,6 +229,8 @@ typedef struct XiveNVT {uint32_t w0;#define NVT_W0_VALID PPC_BIT32(0)uint32_t w1; +#define NVT_W1_EQ_BLOCK PPC_BITMASK32(0, 3) +#define NVT_W1_EQ_INDEX PPC_BITMASK32(4, 31)uint32_t w2;uint32_t w3;uint32_t w4;
hw/intc/pnv_xive.c +60 -0
92 lines not on this page · raw message
Signature · 1 line
2.21.0
Quoted 11 lines · Cédric Le Goater
Hello,
The QEMU PowerNV machine emulates a baremetal OpenPOWER system and acts as an hypervisor (L0). Supporting emulation of KVM to run guests (L1) requires a few more extensions, among which support for the XIVE interrupt controller on POWER9 processor.
The following changes fix some parts of the XIVE model and provide support for escalations and resend. This mechanism is used by KVM to kick a vCPU when it is not dispatched on a HW thread.
Quoted 5 lines
A series from Suraj adding guest support in the Radix MMU model of the QEMU PowerNV machine is still required and will be send later. The whole patchset can be found under :
The rest of this series is essentially a new feature, and so will have to wait until 4.2 now we're in soft freeze.
Quoted 26 lines
Thanks,
C.
Cédric Le Goater (10):
ppc/xive: Force the Physical CAM line value to group mode ppc/xive: Make the PIPR register readonly
ppc/pnv: Rework cache watch model of PnvXIVE ppc/xive: FixTM_PULL_POOL_CTXspecial operation ppc/xive: ImplementTM_PULL_OS_CTXspecial command ppc/xive: Provide escalation support
ppc/xive: Improve 'info pic' support
ppc/xive: Extend XiveTCTX with an router object pointer ppc/xive: Synthesize interrupt from the saved IPB in the NVT ppc/pnv: Dump the XIVE NVT tableinclude/hw/ppc/xive.h | 23 ++- include/hw/ppc/xive_regs.h | 13 ++ hw/intc/pnv_xive.c | 211 +++++++++++++++++++---- hw/intc/spapr_xive.c | 1 - hw/intc/xive.c | 341 +++++++++++++++++++++++++++++-------- hw/ppc/pnv.c | 2 +- hw/ppc/spapr_irq.c | 2 +- 7 files changed, 479 insertions(+), 114 deletions(-)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 12 lines · David Gibson
Quoted 11 lines · Cédric Le Goater
Hello,
The QEMU PowerNV machine emulates a baremetal OpenPOWER system and acts as an hypervisor (L0). Supporting emulation of KVM to run guests (L1) requires a few more extensions, among which support for the XIVE interrupt controller on POWER9 processor.
The following changes fix some parts of the XIVE model and provide support for escalations and resend. This mechanism is used by KVM to kick a vCPU when it is not dispatched on a HW thread.
Quoted 8 lines
Quoted 5 lines
A series from Suraj adding guest support in the Radix MMU model of the QEMU PowerNV machine is still required and will be send later. The whole patchset can be found under :
The rest of this series is essentially a new feature, and so will have to wait until 4.2 now we're in soft freeze.
Yes. That's fine. This is to let you know what is in preparation:
escalations, KVM under PowerNV, PowerNV POWER10. It's all in the pipe.
Thanks,
C.