Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4429e53 authored by Wanpeng Li's avatar Wanpeng Li Committed by Radim Krčmář
Browse files

KVM: Introduce paravirtualization hints and KVM_HINTS_DEDICATED



This patch introduces kvm_para_has_hint() to query for hints about
the configuration of the guests.  The first hint KVM_HINTS_DEDICATED,
is set if the guest has dedicated physical CPUs for each vCPU (i.e.
pinning and no over-commitment).  This allows optimizing spinlocks
and tells the guest to avoid PV TLB flush.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: default avatarWanpeng Li <wanpengli@tencent.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent d4c67a7a
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ This function queries the presence of KVM cpuid leafs.


function: define KVM_CPUID_FEATURES (0x40000001)
returns : ebx, ecx, edx = 0
          eax = and OR'ed group of (1 << flag), where each flags is:
returns : ebx, ecx
          eax = an OR'ed group of (1 << flag), where each flags is:


flag                               || value || meaning
@@ -66,3 +66,14 @@ KVM_FEATURE_CLOCKSOURCE_STABLE_BIT || 24 || host will warn if no guest-side
                                   ||       || per-cpu warps are expected in
                                   ||       || kvmclock.
------------------------------------------------------------------------------

          edx = an OR'ed group of (1 << flag), where each flags is:


flag                               || value || meaning
==================================================================================
KVM_HINTS_DEDICATED                ||     0 || guest checks this feature bit to
                                   ||       || determine if there is vCPU pinning
                                   ||       || and there is no vCPU over-commitment,
                                   ||       || allowing optimizations
----------------------------------------------------------------------------------
+5 −0
Original line number Diff line number Diff line
@@ -94,6 +94,11 @@ static inline unsigned int kvm_arch_para_features(void)
	return 0;
}

static inline unsigned int kvm_arch_para_hints(void)
{
	return 0;
}

#ifdef CONFIG_MIPS_PARAVIRT
static inline bool kvm_para_available(void)
{
+5 −0
Original line number Diff line number Diff line
@@ -61,6 +61,11 @@ static inline unsigned int kvm_arch_para_features(void)
	return r;
}

static inline unsigned int kvm_arch_para_hints(void)
{
	return 0;
}

static inline bool kvm_check_and_clear_guest_paused(void)
{
	return false;
+5 −0
Original line number Diff line number Diff line
@@ -193,6 +193,11 @@ static inline unsigned int kvm_arch_para_features(void)
	return 0;
}

static inline unsigned int kvm_arch_para_hints(void)
{
	return 0;
}

static inline bool kvm_check_and_clear_guest_paused(void)
{
	return false;
+6 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
#ifdef CONFIG_KVM_GUEST
bool kvm_para_available(void);
unsigned int kvm_arch_para_features(void);
unsigned int kvm_arch_para_hints(void);
void kvm_async_pf_task_wait(u32 token, int interrupt_kernel);
void kvm_async_pf_task_wake(u32 token);
u32 kvm_read_and_reset_pf_reason(void);
@@ -115,6 +116,11 @@ static inline unsigned int kvm_arch_para_features(void)
	return 0;
}

static inline unsigned int kvm_arch_para_hints(void)
{
	return 0;
}

static inline u32 kvm_read_and_reset_pf_reason(void)
{
	return 0;
Loading