qemu/include/hw/ppc
Vaibhav Jain 5f7d861e65 spapr: nested: Add support for reporting Hostwide state counter
Add support for reporting Hostwide state counters for nested KVM pseries
guests running with 'cap-nested-papr' on Qemu-TCG acting as
L0-hypervisor. The Hostwide state counters are statistics about state that
L0-hypervisor maintains for the L2-guests and represent the state of all
L2-guests, not just a specific one.

These stats counters are exposed to L1-Hypervisor by the L0-Hypervisor via a
new bit-flag named 'getHostWideState' for the H_GUEST_GET_STATE hcall which
is documented at [1]. Once this flag is set the hcall should populate the
Guest-State-Elements in the requested GSB with the stat counter
values. Currently following five counters are supported:

* l0_guest_heap_size_inuse
* l0_guest_heap_size_max
* l0_guest_pagetable_size_inuse
* l0_guest_pagetable_size_max
* l0_guest_pagetable_reclaimed

At the moment '0' is being reported for all these counters as these
counters doesn't align with how L0-Qemu manages Guest memory.

The patch implements support for these counters by adding new members to
the 'struct SpaprMachineStateNested'. These new members are then plugged
into the existing 'guest_state_element_types[]' with the help of a new
macro 'GSBE_NESTED_MACHINE_DW' together with a new helper
'get_machine_ptr()'. guest_state_request_check() is updated to ensure
correctness of the requested GSB and finally h_guest_getset_state() is
updated to handle the newly introduced flag
'GUEST_STATE_REQUEST_HOST_WIDE'.

This patch is tested with the proposed linux-kernel implementation to
expose these stat-counter as perf-events at [2].

[1]
https://lore.kernel.org/all/20241222140247.174998-2-vaibhav@linux.ibm.com

[2]
https://lore.kernel.org/all/20241222140247.174998-1-vaibhav@linux.ibm.com

Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Message-ID: <20250221155449.530645-1-vaibhav@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
2025-03-11 22:43:32 +10:00
..
fdt.h hw/ppc: Clean up local variable shadowing in _FDT helper routine 2023-09-29 10:07:17 +02:00
mac_dbdma.h include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
openpic.h ppc: spelling fixes 2023-09-20 07:54:34 +03:00
openpic_kvm.h openpic: move KVM-specific declarations into separate openpic_kvm.h file 2018-03-06 13:16:29 +11:00
pnv.h ppc/pnv/homer: class-based base and size 2025-03-11 22:43:30 +10:00
pnv_adu.h ppc/pnv: Implement ADU access to LPC space 2024-07-26 09:21:06 +10:00
pnv_chip.h pnv/xive: Support cache flush and queue sync inject with notifications 2024-07-26 09:51:20 +10:00
pnv_chiptod.h ppc/pnv: Implement the ChipTOD to Core transfer 2024-02-23 23:24:43 +10:00
pnv_core.h ppc/pnv: Add an LPAR per core machine option 2024-07-26 09:21:06 +10:00
pnv_homer.h ppc/pnv: Make HOMER memory a RAM region 2025-03-11 22:43:30 +10:00
pnv_i2c.h ppc/pnv: Add an I2C controller model 2023-11-07 15:49:41 -03:00
pnv_lpc.h ppc/pnv: Implement ADU access to LPC space 2024-07-26 09:21:06 +10:00
pnv_n1_chiplet.h hw/ppc: Add N1 chiplet model 2024-02-23 23:24:42 +10:00
pnv_nest_pervasive.h hw/ppc: Add pnv nest pervasive common chiplet model 2024-02-23 23:24:42 +10:00
pnv_occ.h ppc/pnv/occ: Implement a basic dynamic OCC model 2025-03-11 22:43:30 +10:00
pnv_pnor.h ppc/pnv: Move PNOR to offset 0 in the ISA FW space 2025-03-11 22:43:30 +10:00
pnv_psi.h hw/ppc: Avoid using Monitor in pnv_psi_pic_print_info() 2024-06-19 12:40:49 +02:00
pnv_sbe.h include/hw/ppc: Supply a few missing includes 2023-01-20 07:25:14 +01:00
pnv_xive.h hw/ppc: Avoid using Monitor in pnv_xive2_pic_print_info() 2024-06-19 12:40:49 +02:00
pnv_xscom.h ppc/pnv/phb4: Add pervasive chiplet support to PHB4/5 2025-03-11 22:43:30 +10:00
ppc.h hw/ppc: Consolidate ppc440 initial mapping creation functions 2024-11-04 10:09:36 +10:00
ppc4xx.h hw/ppc/ppc4xx_pci: Extract PCI host definitions to hw/pci-host/ppc4xx.h 2024-02-22 12:47:40 +01:00
ppc_e500.h intc/openpic: Build openpic only once 2013-07-09 21:33:02 +02:00
spapr.h ppc: spapr: Enable 2nd DAWR on Power10 pSeries machine 2025-03-11 22:43:32 +10:00
spapr_cpu_core.h ppc/spapr: remove deprecated machine pseries-2.12 2024-11-04 09:10:32 +10:00
spapr_drc.h include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
spapr_irq.h hw/ppc: Avoid using Monitor in spapr_irq_print_info() 2024-06-19 12:40:49 +02:00
spapr_nested.h spapr: nested: Add support for reporting Hostwide state counter 2025-03-11 22:43:32 +10:00
spapr_numa.h spapr: move FORM1 verifications to post CAS 2021-09-30 12:26:06 +10:00
spapr_nvdimm.h spapr: nvdimm: Implement H_SCM_FLUSH hcall 2022-02-18 08:34:14 +01:00
spapr_ovec.h spapr_numa.c: FORM2 NUMA affinity support 2021-09-30 12:26:06 +10:00
spapr_tpm_proxy.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
spapr_vio.h include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
spapr_xive.h spapr/xive: Make spapr_xive_pic_print_info() static 2021-01-06 11:09:59 +11:00
vof.h hw/ppc/vof: Do not include the full "cpu.h" 2022-12-21 14:17:55 -03:00
xics.h hw/ppc: Avoid using Monitor in ics_pic_print_info() 2024-06-19 12:40:49 +02:00
xics_spapr.h spapr/xics: Drop unused argument to xics_kvm_has_broken_disconnect() 2020-12-14 15:50:55 +11:00
xive.h ppc/xive2: Support crowd-matching when looking for target 2025-03-11 22:43:31 +10:00
xive2.h ppc/xive2: Support crowd-matching when looking for target 2025-03-11 22:43:31 +10:00
xive2_regs.h ppc/xive2: Check crowd backlog when scanning group backlog 2025-03-11 22:43:31 +10:00
xive_regs.h ppc/xive2: Add grouping level to notification 2025-03-11 22:43:31 +10:00