Commit cdc118f8 authored by Bibo Mao's avatar Bibo Mao Committed by Huacai Chen
Browse files

LoongArch: KVM: Enable paravirt feature control from VMM



Export kernel paravirt features to user space, so that VMM can control
each single paravirt feature. By default paravirt features will be the
same with kvm supported features if VMM does not set it.

Also a new feature KVM_FEATURE_VIRT_EXTIOI is added which can be set
from user space. This feature indicates that the virt EIOINTC can route
interrupts to 256 vCPUs, rather than 4 vCPUs like with real HW.

Signed-off-by: default avatarBibo Mao <maobibo@loongson.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent f4e40ea9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ struct kvm_arch {
	unsigned int  root_level;
	spinlock_t    phyid_map_lock;
	struct kvm_phyid_map  *phyid_map;
	/* Enabled PV features */
	unsigned long pv_features;

	s64 time_offset;
	struct kvm_context __percpu *vmcs;
@@ -143,6 +145,11 @@ enum emulation_result {
#define KVM_LARCH_SWCSR_LATEST	(0x1 << 5)
#define KVM_LARCH_HWCSR_USABLE	(0x1 << 6)

#define LOONGARCH_PV_FEAT_UPDATED	BIT_ULL(63)
#define LOONGARCH_PV_FEAT_MASK		(BIT(KVM_FEATURE_IPI) |		\
					 BIT(KVM_FEATURE_STEAL_TIME) |	\
					 BIT(KVM_FEATURE_VIRT_EXTIOI))

struct kvm_vcpu_arch {
	/*
	 * Switch pointer-to-function type to unsigned long
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
#ifndef _ASM_LOONGARCH_KVM_PARA_H
#define _ASM_LOONGARCH_KVM_PARA_H

#include <uapi/asm/kvm_para.h>

/*
 * Hypercall code field
 */
+5 −0
Original line number Diff line number Diff line
@@ -130,4 +130,9 @@ static inline bool kvm_pvtime_supported(void)
	return !!sched_info_on();
}

static inline bool kvm_guest_has_pv_feature(struct kvm_vcpu *vcpu, unsigned int feature)
{
	return vcpu->kvm->arch.pv_features & BIT(feature);
}

#endif /* __ASM_LOONGARCH_KVM_VCPU_H__ */
+1 −9
Original line number Diff line number Diff line
@@ -161,16 +161,8 @@

/*
 * CPUCFG index area: 0x40000000 -- 0x400000ff
 * SW emulation for KVM hypervirsor
 * SW emulation for KVM hypervirsor, see arch/loongarch/include/uapi/asm/kvm_para.h
 */
#define CPUCFG_KVM_BASE			0x40000000
#define CPUCFG_KVM_SIZE			0x100

#define CPUCFG_KVM_SIG			(CPUCFG_KVM_BASE + 0)
#define  KVM_SIGNATURE			"KVM\0"
#define CPUCFG_KVM_FEATURE		(CPUCFG_KVM_BASE + 4)
#define  KVM_FEATURE_IPI		BIT(1)
#define  KVM_FEATURE_STEAL_TIME		BIT(2)

#ifndef __ASSEMBLY__

+0 −2
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
syscall-y += unistd_64.h

generic-y += kvm_para.h
Loading