Skip to content

Commit 6ccbbc3

Browse files
iamjpnmpe
authored andcommitted
KVM: PPC: Add helper library for Guest State Buffers
The PAPR "Nestedv2" guest API introduces the concept of a Guest State Buffer for communication about L2 guests between L1 and L0 hosts. In the new API, the L0 manages the L2 on behalf of the L1. This means that if the L1 needs to change L2 state (e.g. GPRs, SPRs, partition table...), it must request the L0 perform the modification. If the nested host needs to read L2 state likewise this request must go through the L0. The Guest State Buffer is a Type-Length-Value style data format defined in the PAPR which assigns all relevant partition state a unique identity. Unlike a typical TLV format the length is redundant as the length of each identity is fixed but is included for checking correctness. A guest state buffer consists of an element count followed by a stream of elements, where elements are composed of an ID number, data length, then the data: Header: <---4 bytes---> +----------------+----- | Element Count | Elements... +----------------+----- Element: <----2 bytes---> <-2 bytes-> <-Length bytes-> +----------------+-----------+----------------+ | Guest State ID | Length | Data | +----------------+-----------+----------------+ Guest State IDs have other attributes defined in the PAPR such as whether they are per thread or per guest, or read-only. Introduce a library for using guest state buffers. This includes support for actions such as creating buffers, adding elements to buffers, reading the value of elements and parsing buffers. This will be used later by the nestedv2 guest support. Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230914030600.16993-9-jniethe5@gmail.com
1 parent 6de2e83 commit 6ccbbc3

File tree

5 files changed

+1818
-0
lines changed

5 files changed

+1818
-0
lines changed

arch/powerpc/Kconfig.debug

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ config MSI_BITMAP_SELFTEST
8282
bool "Run self-tests of the MSI bitmap code"
8383
depends on DEBUG_KERNEL
8484

85+
config GUEST_STATE_BUFFER_TEST
86+
def_tristate n
87+
prompt "Enable Guest State Buffer unit tests"
88+
depends on KUNIT
89+
depends on KVM_BOOK3S_HV_POSSIBLE
90+
default KUNIT_ALL_TESTS
91+
help
92+
The Guest State Buffer is a data format specified in the PAPR.
93+
It is by hcalls to communicate the state of L2 guests between
94+
the L1 and L0 hypervisors. Enable unit tests for the library
95+
used to create and use guest state buffers.
96+
8597
config PPC_IRQ_SOFT_MASK_DEBUG
8698
bool "Include extra checks for powerpc irq soft masking"
8799
depends on PPC64

0 commit comments

Comments
 (0)