KVM: PPC: Book3S HV: Provide a way for userspace to get/set per-vCPU areas
Subsystems (3)
PATCH 55/56 KVM: PPC: Book3S HV: Provide a way for userspace to get/set per-vCPU areas
From: Paul Mackerras <[email protected]>
The PAPR paravirtualization interface lets guests register three different types of per-vCPU buffer areas in its memory for communication with the hypervisor. These are called virtual processor areas (VPAs). Currently the hypercalls to register and unregister VPAs are handled by KVM in the kernel, and userspace has no way to know about or save and restore these registrations across a migration.
This adds "register" codes for these three areas that userspace can use with the KVM_GET/SET_ONE_REG ioctls to see what addresses have been registered, and to register or unregister them. This will be needed for guest hibernation and migration, and is also needed so that userspace can unregister them on reset (otherwise we corrupt guest memory after reboot by writing to the VPAs registered by the previous kernel).
The "register" for the VPA is a 64-bit value containing the address, since the length of the VPA is fixed. The "registers" for the SLB shadow buffer and dispatch trace log (DTL) are 128 bits long, consisting of the guest physical address in the high (first) 64 bits and the length in the low 64 bits.
This also fixes a bug where we were calling init_vpa unconditionally, leading to an oops when unregistering the VPA.
--- Documentation/virtual/kvm/api.txt | 3 ++ arch/powerpc/include/asm/kvm.h | 6 +++ arch/powerpc/include/asm/kvm_ppc.h | 4 ++ arch/powerpc/kvm/book3s_hv.c | 64 +++++++++++++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 1 deletions(-)
Documentation/virtual/kvm/api.txt +3 -0
@@ -1770,6 +1770,9 @@ registers, find a list below: PPC | KVM_REG_PPC_VSR31 | 128 PPC | KVM_REG_PPC_FPSCR | 64 PPC | KVM_REG_PPC_VSCR | 32 + PPC | KVM_REG_PPC_VPA_ADDR | 64 + PPC | KVM_REG_PPC_VPA_SLB | 128 + PPC | KVM_REG_PPC_VPA_DTL | 128 4.69 KVM_GET_ONE_REG
arch/powerpc/include/asm/kvm.h +6 -0
@@ -380,4 +380,10 @@ struct kvm_book3e_206_tlb_params {#define KVM_REG_PPC_FPSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x80)#define KVM_REG_PPC_VSCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x81) +/* Virtual processor areas */ +/* For SLB & DTL, address in high (first) half, length in low half */ +#define KVM_REG_PPC_VPA_ADDR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x82) +#define KVM_REG_PPC_VPA_SLB (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x83) +#define KVM_REG_PPC_VPA_DTL (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84) +#endif /* __LINUX_KVM_POWERPC_H */
arch/powerpc/include/asm/kvm_ppc.h +4 -0
@@ -202,6 +202,10 @@ union kvmppc_one_reg {u64 dval;vector128 vval;u64 vsxval[2 ]; +struct { +u64 addr; +u64 length; + } vpaval; };#define one_reg_size (id) \
arch/powerpc/kvm/book3s_hv.c +63 -1
94 lines not on this page · raw message
Signature · 1 line
1.6.0.2