Commit 19d31c5f authored by Jordan Niethe's avatar Jordan Niethe Committed by Michael Ellerman
Browse files

KVM: PPC: Add support for nestedv2 guests



A series of hcalls have been added to the PAPR which allow a regular
guest partition to create and manage guest partitions of its own. KVM
already had an interface that allowed this on powernv platforms. This
existing interface will now be called "nestedv1". The newly added PAPR
interface will be called "nestedv2".  PHYP will support the nestedv2
interface. At this time the host side of the nestedv2 interface has not
been implemented on powernv but there is no technical reason why it
could not be added.

The nestedv1 interface is still supported.

Add support to KVM to utilize these hcalls to enable running nested
guests as a pseries guest on PHYP.

Overview of the new hcall usage:

- L1 and L0 negotiate capabilities with
  H_GUEST_{G,S}ET_CAPABILITIES()

- L1 requests the L0 create a L2 with
  H_GUEST_CREATE() and receives a handle to use in future hcalls

- L1 requests the L0 create a L2 vCPU with
  H_GUEST_CREATE_VCPU()

- L1 sets up the L2 using H_GUEST_SET and the
  H_GUEST_VCPU_RUN input buffer

- L1 requests the L0 runs the L2 vCPU using H_GUEST_VCPU_RUN()

- L2 returns to L1 with an exit reason and L1 reads the
  H_GUEST_VCPU_RUN output buffer populated by the L0

- L1 handles the exit using H_GET_STATE if necessary

- L1 reruns L2 vCPU with H_GUEST_VCPU_RUN

- L1 frees the L2 in the L0 with H_GUEST_DELETE()

Support for the new API is determined by trying
H_GUEST_GET_CAPABILITIES. On a successful return, use the nestedv2
interface.

Use the vcpu register state setters for tracking modified guest state
elements and copy the thread wide values into the H_GUEST_VCPU_RUN input
buffer immediately before running a L2. The guest wide
elements can not be added to the input buffer so send them with a
separate H_GUEST_SET call if necessary.

Make the vcpu register getter load the corresponding value from the real
host with H_GUEST_GET. To avoid unnecessarily calling H_GUEST_GET, track
which values have already been loaded between H_GUEST_VCPU_RUN calls. If
an element is present in the H_GUEST_VCPU_RUN output buffer it also does
not need to be loaded again.

Tested-by: default avatarSachin Sant <sachinp@linux.ibm.com>
Signed-off-by: default avatarVaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: default avatarGautam Menghani <gautam@linux.ibm.com>
Signed-off-by: default avatarKautuk Consul <kconsul@linux.vnet.ibm.com>
Signed-off-by: default avatarAmit Machhiwal <amachhiw@linux.vnet.ibm.com>
Signed-off-by: default avatarJordan Niethe <jniethe5@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230914030600.16993-11-jniethe5@gmail.com
parent dfcaacc8
Loading
Loading
Loading
Loading
+91 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#ifndef _ASM_POWERPC_GUEST_STATE_BUFFER_H
#define _ASM_POWERPC_GUEST_STATE_BUFFER_H

#include "asm/hvcall.h"
#include <linux/gfp.h>
#include <linux/bitmap.h>
#include <asm/plpar_wrappers.h>
@@ -313,6 +314,8 @@ struct kvmppc_gs_buff *kvmppc_gsb_new(size_t size, unsigned long guest_id,
				      unsigned long vcpu_id, gfp_t flags);
void kvmppc_gsb_free(struct kvmppc_gs_buff *gsb);
void *kvmppc_gsb_put(struct kvmppc_gs_buff *gsb, size_t size);
int kvmppc_gsb_send(struct kvmppc_gs_buff *gsb, unsigned long flags);
int kvmppc_gsb_recv(struct kvmppc_gs_buff *gsb, unsigned long flags);

/**
 * kvmppc_gsb_header() - the header of a guest state buffer
@@ -901,4 +904,92 @@ static inline void kvmppc_gsm_reset(struct kvmppc_gs_msg *gsm)
	kvmppc_gsbm_zero(&gsm->bitmap);
}

/**
 * kvmppc_gsb_receive_data - flexibly update values from a guest state buffer
 * @gsb: guest state buffer
 * @gsm: guest state message
 *
 * Requests updated values for the guest state values included in the guest
 * state message. The guest state message will then deserialize the guest state
 * buffer.
 */
static inline int kvmppc_gsb_receive_data(struct kvmppc_gs_buff *gsb,
					  struct kvmppc_gs_msg *gsm)
{
	int rc;

	kvmppc_gsb_reset(gsb);
	rc = kvmppc_gsm_fill_info(gsm, gsb);
	if (rc < 0)
		return rc;

	rc = kvmppc_gsb_recv(gsb, gsm->flags);
	if (rc < 0)
		return rc;

	rc = kvmppc_gsm_refresh_info(gsm, gsb);
	if (rc < 0)
		return rc;
	return 0;
}

/**
 * kvmppc_gsb_recv - receive a single guest state ID
 * @gsb: guest state buffer
 * @gsm: guest state message
 * @iden: guest state identity
 */
static inline int kvmppc_gsb_receive_datum(struct kvmppc_gs_buff *gsb,
					   struct kvmppc_gs_msg *gsm, u16 iden)
{
	int rc;

	kvmppc_gsm_include(gsm, iden);
	rc = kvmppc_gsb_receive_data(gsb, gsm);
	if (rc < 0)
		return rc;
	kvmppc_gsm_reset(gsm);
	return 0;
}

/**
 * kvmppc_gsb_send_data - flexibly send values from a guest state buffer
 * @gsb: guest state buffer
 * @gsm: guest state message
 *
 * Sends the guest state values included in the guest state message.
 */
static inline int kvmppc_gsb_send_data(struct kvmppc_gs_buff *gsb,
				       struct kvmppc_gs_msg *gsm)
{
	int rc;

	kvmppc_gsb_reset(gsb);
	rc = kvmppc_gsm_fill_info(gsm, gsb);
	if (rc < 0)
		return rc;
	rc = kvmppc_gsb_send(gsb, gsm->flags);

	return rc;
}

/**
 * kvmppc_gsb_recv - send a single guest state ID
 * @gsb: guest state buffer
 * @gsm: guest state message
 * @iden: guest state identity
 */
static inline int kvmppc_gsb_send_datum(struct kvmppc_gs_buff *gsb,
					struct kvmppc_gs_msg *gsm, u16 iden)
{
	int rc;

	kvmppc_gsm_include(gsm, iden);
	rc = kvmppc_gsb_send_data(gsb, gsm);
	if (rc < 0)
		return rc;
	kvmppc_gsm_reset(gsm);
	return 0;
}

#endif /* _ASM_POWERPC_GUEST_STATE_BUFFER_H */
+30 −0
Original line number Diff line number Diff line
@@ -100,6 +100,18 @@
#define H_COP_HW	-74
#define H_STATE		-75
#define H_IN_USE	-77

#define H_INVALID_ELEMENT_ID			-79
#define H_INVALID_ELEMENT_SIZE			-80
#define H_INVALID_ELEMENT_VALUE			-81
#define H_INPUT_BUFFER_NOT_DEFINED		-82
#define H_INPUT_BUFFER_TOO_SMALL		-83
#define H_OUTPUT_BUFFER_NOT_DEFINED		-84
#define H_OUTPUT_BUFFER_TOO_SMALL		-85
#define H_PARTITION_PAGE_TABLE_NOT_DEFINED	-86
#define H_GUEST_VCPU_STATE_NOT_HV_OWNED		-87


#define H_UNSUPPORTED_FLAG_START	-256
#define H_UNSUPPORTED_FLAG_END		-511
#define H_MULTI_THREADS_ACTIVE	-9005
@@ -381,6 +393,15 @@
#define H_ENTER_NESTED		0xF804
#define H_TLB_INVALIDATE	0xF808
#define H_COPY_TOFROM_GUEST	0xF80C
#define H_GUEST_GET_CAPABILITIES 0x460
#define H_GUEST_SET_CAPABILITIES 0x464
#define H_GUEST_CREATE		0x470
#define H_GUEST_CREATE_VCPU	0x474
#define H_GUEST_GET_STATE	0x478
#define H_GUEST_SET_STATE	0x47C
#define H_GUEST_RUN_VCPU	0x480
#define H_GUEST_COPY_MEMORY	0x484
#define H_GUEST_DELETE		0x488

/* Flags for H_SVM_PAGE_IN */
#define H_PAGE_IN_SHARED        0x1
@@ -467,6 +488,15 @@
#define H_RPTI_PAGE_1G	0x08
#define H_RPTI_PAGE_ALL (-1UL)

/* Flags for H_GUEST_{S,G}_STATE */
#define H_GUEST_FLAGS_WIDE     (1UL<<(63-0))

/* Flag values used for H_{S,G}SET_GUEST_CAPABILITIES */
#define H_GUEST_CAP_COPY_MEM	(1UL<<(63-0))
#define H_GUEST_CAP_POWER9	(1UL<<(63-1))
#define H_GUEST_CAP_POWER10	(1UL<<(63-2))
#define H_GUEST_CAP_BITMAP2	(1UL<<(63-63))

#ifndef __ASSEMBLY__
#include <linux/types.h>

+116 −21
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/types.h>
#include <linux/kvm_host.h>
#include <asm/kvm_book3s_asm.h>
#include <asm/guest-state-buffer.h>

struct kvmppc_bat {
	u64 raw;
@@ -295,6 +296,7 @@ static inline void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu) {}
static inline void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu) {}
#endif

extern unsigned long nested_capabilities;
long kvmhv_nested_init(void);
void kvmhv_nested_exit(void);
void kvmhv_vm_nested_init(struct kvm *kvm);
@@ -316,6 +318,69 @@ long int kvmhv_nested_page_fault(struct kvm_vcpu *vcpu);

void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac);


#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE

extern struct static_key_false __kvmhv_is_nestedv2;

static inline bool kvmhv_is_nestedv2(void)
{
	return static_branch_unlikely(&__kvmhv_is_nestedv2);
}

static inline bool kvmhv_is_nestedv1(void)
{
	return !static_branch_likely(&__kvmhv_is_nestedv2);
}

#else

static inline bool kvmhv_is_nestedv2(void)
{
	return false;
}

static inline bool kvmhv_is_nestedv1(void)
{
	return false;
}

#endif

int __kvmhv_nestedv2_reload_ptregs(struct kvm_vcpu *vcpu, struct pt_regs *regs);
int __kvmhv_nestedv2_mark_dirty_ptregs(struct kvm_vcpu *vcpu, struct pt_regs *regs);
int __kvmhv_nestedv2_mark_dirty(struct kvm_vcpu *vcpu, u16 iden);
int __kvmhv_nestedv2_cached_reload(struct kvm_vcpu *vcpu, u16 iden);

static inline int kvmhv_nestedv2_reload_ptregs(struct kvm_vcpu *vcpu,
					       struct pt_regs *regs)
{
	if (kvmhv_is_nestedv2())
		return __kvmhv_nestedv2_reload_ptregs(vcpu, regs);
	return 0;
}
static inline int kvmhv_nestedv2_mark_dirty_ptregs(struct kvm_vcpu *vcpu,
						   struct pt_regs *regs)
{
	if (kvmhv_is_nestedv2())
		return __kvmhv_nestedv2_mark_dirty_ptregs(vcpu, regs);
	return 0;
}

static inline int kvmhv_nestedv2_mark_dirty(struct kvm_vcpu *vcpu, u16 iden)
{
	if (kvmhv_is_nestedv2())
		return __kvmhv_nestedv2_mark_dirty(vcpu, iden);
	return 0;
}

static inline int kvmhv_nestedv2_cached_reload(struct kvm_vcpu *vcpu, u16 iden)
{
	if (kvmhv_is_nestedv2())
		return __kvmhv_nestedv2_cached_reload(vcpu, iden);
	return 0;
}

extern int kvm_irq_bypass;

static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
@@ -335,60 +400,72 @@ static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
{
	vcpu->arch.regs.gpr[num] = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_GPR(num));
}

static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_GPR(num)) < 0);
	return vcpu->arch.regs.gpr[num];
}

static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
{
	vcpu->arch.regs.ccr = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_CR);
}

static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_CR) < 0);
	return vcpu->arch.regs.ccr;
}

static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
{
	vcpu->arch.regs.xer = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_XER);
}

static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_XER) < 0);
	return vcpu->arch.regs.xer;
}

static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
{
	vcpu->arch.regs.ctr = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_CTR);
}

static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_CTR) < 0);
	return vcpu->arch.regs.ctr;
}

static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
{
	vcpu->arch.regs.link = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_LR);
}

static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_LR) < 0);
	return vcpu->arch.regs.link;
}

static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
{
	vcpu->arch.regs.nip = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_NIA);
}

static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_NIA) < 0);
	return vcpu->arch.regs.nip;
}

@@ -405,27 +482,32 @@ static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)

static inline u64 kvmppc_get_fpr(struct kvm_vcpu *vcpu, int i)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_VSRS(i)) < 0);
	return vcpu->arch.fp.fpr[i][TS_FPROFFSET];
}

static inline void kvmppc_set_fpr(struct kvm_vcpu *vcpu, int i, u64 val)
{
	vcpu->arch.fp.fpr[i][TS_FPROFFSET] = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_VSRS(i));
}

static inline u64 kvmppc_get_fpscr(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_FPSCR) < 0);
	return vcpu->arch.fp.fpscr;
}

static inline void kvmppc_set_fpscr(struct kvm_vcpu *vcpu, u64 val)
{
	vcpu->arch.fp.fpscr = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_FPSCR);
}


static inline u64 kvmppc_get_vsx_fpr(struct kvm_vcpu *vcpu, int i, int j)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_VSRS(i)) < 0);
	return vcpu->arch.fp.fpr[i][j];
}

@@ -433,11 +515,13 @@ static inline void kvmppc_set_vsx_fpr(struct kvm_vcpu *vcpu, int i, int j,
				      u64 val)
{
	vcpu->arch.fp.fpr[i][j] = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_VSRS(i));
}

#ifdef CONFIG_ALTIVEC
static inline void kvmppc_get_vsx_vr(struct kvm_vcpu *vcpu, int i, vector128 *v)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_VSRS(32 + i)) < 0);
	*v =  vcpu->arch.vr.vr[i];
}

@@ -445,75 +529,86 @@ static inline void kvmppc_set_vsx_vr(struct kvm_vcpu *vcpu, int i,
				     vector128 *val)
{
	vcpu->arch.vr.vr[i] = *val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_VSRS(32 + i));
}

static inline u32 kvmppc_get_vscr(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_VSCR) < 0);
	return vcpu->arch.vr.vscr.u[3];
}

static inline void kvmppc_set_vscr(struct kvm_vcpu *vcpu, u32 val)
{
	vcpu->arch.vr.vscr.u[3] = val;
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_VSCR);
}
#endif

#define KVMPPC_BOOK3S_VCPU_ACCESSOR_SET(reg, size)			\
#define KVMPPC_BOOK3S_VCPU_ACCESSOR_SET(reg, size, iden)		\
static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val)	\
{									\
									\
	vcpu->arch.reg = val;						\
	kvmhv_nestedv2_mark_dirty(vcpu, iden);				\
}

#define KVMPPC_BOOK3S_VCPU_ACCESSOR_GET(reg, size)			\
#define KVMPPC_BOOK3S_VCPU_ACCESSOR_GET(reg, size, iden)		\
static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu)		\
{									\
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, iden) < 0);		\
	return vcpu->arch.reg;						\
}

#define KVMPPC_BOOK3S_VCPU_ACCESSOR(reg, size)				\
	KVMPPC_BOOK3S_VCPU_ACCESSOR_SET(reg, size)			\
	KVMPPC_BOOK3S_VCPU_ACCESSOR_GET(reg, size)			\
#define KVMPPC_BOOK3S_VCPU_ACCESSOR(reg, size, iden)			\
	KVMPPC_BOOK3S_VCPU_ACCESSOR_SET(reg, size, iden)		\
	KVMPPC_BOOK3S_VCPU_ACCESSOR_GET(reg, size, iden)		\

KVMPPC_BOOK3S_VCPU_ACCESSOR(pid, 32)
KVMPPC_BOOK3S_VCPU_ACCESSOR(tar, 64)
KVMPPC_BOOK3S_VCPU_ACCESSOR(ebbhr, 64)
KVMPPC_BOOK3S_VCPU_ACCESSOR(ebbrr, 64)
KVMPPC_BOOK3S_VCPU_ACCESSOR(bescr, 64)
KVMPPC_BOOK3S_VCPU_ACCESSOR(ic, 64)
KVMPPC_BOOK3S_VCPU_ACCESSOR(vrsave, 64)
KVMPPC_BOOK3S_VCPU_ACCESSOR(pid, 32, KVMPPC_GSID_PIDR)
KVMPPC_BOOK3S_VCPU_ACCESSOR(tar, 64, KVMPPC_GSID_TAR)
KVMPPC_BOOK3S_VCPU_ACCESSOR(ebbhr, 64, KVMPPC_GSID_EBBHR)
KVMPPC_BOOK3S_VCPU_ACCESSOR(ebbrr, 64, KVMPPC_GSID_EBBRR)
KVMPPC_BOOK3S_VCPU_ACCESSOR(bescr, 64, KVMPPC_GSID_BESCR)
KVMPPC_BOOK3S_VCPU_ACCESSOR(ic, 64, KVMPPC_GSID_IC)
KVMPPC_BOOK3S_VCPU_ACCESSOR(vrsave, 64, KVMPPC_GSID_VRSAVE)


#define KVMPPC_BOOK3S_VCORE_ACCESSOR_SET(reg, size)			\
#define KVMPPC_BOOK3S_VCORE_ACCESSOR_SET(reg, size, iden)		\
static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val)	\
{									\
	vcpu->arch.vcore->reg = val;					\
	kvmhv_nestedv2_mark_dirty(vcpu, iden);				\
}

#define KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(reg, size)			\
#define KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(reg, size, iden)		\
static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu)		\
{									\
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, iden) < 0);		\
	return vcpu->arch.vcore->reg;					\
}

#define KVMPPC_BOOK3S_VCORE_ACCESSOR(reg, size)				\
	KVMPPC_BOOK3S_VCORE_ACCESSOR_SET(reg, size)			\
	KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(reg, size)			\
#define KVMPPC_BOOK3S_VCORE_ACCESSOR(reg, size, iden)			\
	KVMPPC_BOOK3S_VCORE_ACCESSOR_SET(reg, size, iden)		\
	KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(reg, size, iden)		\


KVMPPC_BOOK3S_VCORE_ACCESSOR(vtb, 64)
KVMPPC_BOOK3S_VCORE_ACCESSOR(tb_offset, 64)
KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(arch_compat, 32)
KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(lpcr, 64)
KVMPPC_BOOK3S_VCORE_ACCESSOR(vtb, 64, KVMPPC_GSID_VTB)
KVMPPC_BOOK3S_VCORE_ACCESSOR(tb_offset, 64, KVMPPC_GSID_TB_OFFSET)
KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(arch_compat, 32, KVMPPC_GSID_LOGICAL_PVR)
KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(lpcr, 64, KVMPPC_GSID_LPCR)

static inline u64 kvmppc_get_dec_expires(struct kvm_vcpu *vcpu)
{
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_TB_OFFSET) < 0);
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_DEC_EXPIRY_TB) < 0);
	return vcpu->arch.dec_expires;
}

static inline void kvmppc_set_dec_expires(struct kvm_vcpu *vcpu, u64 val)
{
	vcpu->arch.dec_expires = val;
	WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, KVMPPC_GSID_TB_OFFSET) < 0);
	kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_DEC_EXPIRY_TB);
}

/* Expiry time of vcpu DEC relative to host TB */
+6 −0
Original line number Diff line number Diff line
@@ -677,6 +677,12 @@ static inline pte_t *find_kvm_host_pte(struct kvm *kvm, unsigned long mmu_seq,
extern pte_t *find_kvm_nested_guest_pte(struct kvm *kvm, unsigned long lpid,
					unsigned long ea, unsigned *hshift);

int kvmhv_nestedv2_vcpu_create(struct kvm_vcpu *vcpu, struct kvmhv_nestedv2_io *io);
void kvmhv_nestedv2_vcpu_free(struct kvm_vcpu *vcpu, struct kvmhv_nestedv2_io *io);
int kvmhv_nestedv2_flush_vcpu(struct kvm_vcpu *vcpu, u64 time_limit);
int kvmhv_nestedv2_set_ptbl_entry(unsigned long lpid, u64 dw0, u64 dw1);
int kvmhv_nestedv2_parse_output(struct kvm_vcpu *vcpu);

#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */

#endif /* __ASM_KVM_BOOK3S_64_H__ */
+20 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <asm/cacheflush.h>
#include <asm/hvcall.h>
#include <asm/mce.h>
#include <asm/guest-state-buffer.h>

#define __KVM_HAVE_ARCH_VCPU_DEBUGFS

@@ -509,6 +510,23 @@ union xive_tma_w01 {
	__be64 w01;
};

 /* Nestedv2 H_GUEST_RUN_VCPU configuration */
struct kvmhv_nestedv2_config {
	struct kvmppc_gs_buff_info vcpu_run_output_cfg;
	struct kvmppc_gs_buff_info vcpu_run_input_cfg;
	u64 vcpu_run_output_size;
};

 /* Nestedv2 L1<->L0 communication state */
struct kvmhv_nestedv2_io {
	struct kvmhv_nestedv2_config cfg;
	struct kvmppc_gs_buff *vcpu_run_output;
	struct kvmppc_gs_buff *vcpu_run_input;
	struct kvmppc_gs_msg *vcpu_message;
	struct kvmppc_gs_msg *vcore_message;
	struct kvmppc_gs_bitmap valids;
};

struct kvm_vcpu_arch {
	ulong host_stack;
	u32 host_pid;
@@ -829,6 +847,8 @@ struct kvm_vcpu_arch {
	u64 nested_hfscr;	/* HFSCR that the L1 requested for the nested guest */
	u32 nested_vcpu_id;
	gpa_t nested_io_gpr;
	/* For nested APIv2 guests*/
	struct kvmhv_nestedv2_io nestedv2_io;
#endif

#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING
Loading