[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/6] kvm/i386: Avoid multiple calls to check_extension(KVM_CAP_HY
From: |
Siddharth Chandrasekaran |
Subject: |
[PATCH 4/6] kvm/i386: Avoid multiple calls to check_extension(KVM_CAP_HYPERV) |
Date: |
Mon, 24 May 2021 21:54:07 +0200 |
KVM_CAP_HYPERV is a VM ioctl and can be cached at kvm_arch_init()
instead of performing an ioctl each time in hyperv_enabled() which is
called foreach vCPU. Apart from that, this variable will come in handy
in a subsequent patch.
Signed-off-by: Siddharth Chandrasekaran <sidcha@amazon.de>
---
target/i386/kvm/kvm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d19a2913fd..362f04ab3f 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -93,6 +93,7 @@ static bool has_msr_misc_enable;
static bool has_msr_smbase;
static bool has_msr_bndcfgs;
static int lm_capable_kernel;
+static bool has_hyperv;
static bool has_msr_hv_hypercall;
static bool has_msr_hv_crash;
static bool has_msr_hv_reset;
@@ -715,8 +716,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs)
static bool hyperv_enabled(X86CPU *cpu)
{
- CPUState *cs = CPU(cpu);
- return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 &&
+ return has_hyperv &&
((cpu->hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_NOTIFY) ||
cpu->hyperv_features || cpu->hyperv_passthrough);
}
@@ -2172,6 +2172,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
+ has_hyperv = kvm_check_extension(s, KVM_CAP_HYPERV);
hv_vpindex_settable = kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX);
--
2.17.1
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
- [PATCH 0/6] Handle hypercall code overlay page in userspace, Siddharth Chandrasekaran, 2021/05/24
- [PATCH 1/6] hyper-v: Overlay abstraction for synic event and msg pages, Siddharth Chandrasekaran, 2021/05/24
- [PATCH 3/6] kvm/i386: Stop using cpu->kvm_msr_buf in kvm_put_one_msr(), Siddharth Chandrasekaran, 2021/05/24
- [PATCH 2/6] hyper-v: Use -1 as invalid overlay address, Siddharth Chandrasekaran, 2021/05/24
- [PATCH 4/6] kvm/i386: Avoid multiple calls to check_extension(KVM_CAP_HYPERV),
Siddharth Chandrasekaran <=
- [PATCH 5/6] kvm/i386: Add support for user space MSR filtering, Siddharth Chandrasekaran, 2021/05/24
- [PATCH 6/6] hyper-v: Handle hypercall code page as an overlay page, Siddharth Chandrasekaran, 2021/05/24