]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: x86: Introduce .hv_inject_synthetic_vmexit_post_tlb_flush() nested hook
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 1 Nov 2022 14:53:59 +0000 (15:53 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 18 Nov 2022 17:59:13 +0000 (12:59 -0500)
Hyper-V supports injecting synthetic L2->L1 exit after performing
L2 TLB flush operation but the procedure is vendor specific. Introduce
.hv_inject_synthetic_vmexit_post_tlb_flush nested hook for it.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20221101145426.251680-22-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/Makefile
arch/x86/kvm/svm/hyperv.c [new file with mode: 0644]
arch/x86/kvm/svm/hyperv.h
arch/x86/kvm/svm/nested.c
arch/x86/kvm/vmx/hyperv.c
arch/x86/kvm/vmx/hyperv.h
arch/x86/kvm/vmx/nested.c

index 63dad1e129698043e208debc4488730407166ad1..ebf90f4f1a21e5b289d19c0e60b3f5b71718462b 100644 (file)
@@ -1722,6 +1722,7 @@ struct kvm_x86_nested_ops {
        int (*enable_evmcs)(struct kvm_vcpu *vcpu,
                            uint16_t *vmcs_version);
        uint16_t (*get_evmcs_version)(struct kvm_vcpu *vcpu);
+       void (*hv_inject_synthetic_vmexit_post_tlb_flush)(struct kvm_vcpu *vcpu);
 };
 
 struct kvm_x86_init_ops {
index 4cf407563feeaa02f86142483be89f8669d16ff9..80e3fe184d17e64984d2f2d4adba00ec9d5ad57e 100644 (file)
@@ -26,7 +26,8 @@ kvm-intel-y           += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o \
                           vmx/hyperv.o vmx/nested.o vmx/posted_intr.o
 kvm-intel-$(CONFIG_X86_SGX_KVM)        += vmx/sgx.o
 
-kvm-amd-y              += svm/svm.o svm/vmenter.o svm/pmu.o svm/nested.o svm/avic.o svm/sev.o
+kvm-amd-y              += svm/svm.o svm/vmenter.o svm/pmu.o svm/nested.o svm/avic.o \
+                          svm/sev.o svm/hyperv.o
 
 ifdef CONFIG_HYPERV
 kvm-amd-y              += svm/svm_onhyperv.o
diff --git a/arch/x86/kvm/svm/hyperv.c b/arch/x86/kvm/svm/hyperv.c
new file mode 100644 (file)
index 0000000..911f510
--- /dev/null
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * AMD SVM specific code for Hyper-V on KVM.
+ *
+ * Copyright 2022 Red Hat, Inc. and/or its affiliates.
+ */
+#include "hyperv.h"
+
+void svm_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu)
+{
+}
index e97d80974e7203fea40c148af7c4ac80ad40cdbe..7564bdf652e4713bd7c5d00dd76fd4952c4b4e76 100644 (file)
@@ -25,4 +25,6 @@ static inline void nested_svm_hv_update_vm_vp_ids(struct kvm_vcpu *vcpu)
        hv_vcpu->nested.vp_id = hve->hv_vp_id;
 }
 
+void svm_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu);
+
 #endif /* __ARCH_X86_KVM_SVM_HYPERV_H__ */
index aa36c349da43027b67d964acdc345904afd41f0c..748e4de40c8fa0b502914f6e21fa7232a7f70fae 100644 (file)
@@ -1730,4 +1730,5 @@ struct kvm_x86_nested_ops svm_nested_ops = {
        .get_nested_state_pages = svm_get_nested_state_pages,
        .get_state = svm_get_nested_state,
        .set_state = svm_set_nested_state,
+       .hv_inject_synthetic_vmexit_post_tlb_flush = svm_hv_inject_synthetic_vmexit_post_tlb_flush,
 };
index 5e239158174ead06905e7655b95f434f4fa5ed60..f05464db4fdc1201c12945b49ae584976a0d1351 100644 (file)
@@ -506,3 +506,7 @@ int nested_enable_evmcs(struct kvm_vcpu *vcpu,
 
        return 0;
 }
+
+void vmx_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu)
+{
+}
index 99a151af7a8177b663643e6581da9be6a94a4f18..8efaffe9215bf2ce9b58a6874c8ebdd93046862d 100644 (file)
@@ -243,5 +243,6 @@ int nested_enable_evmcs(struct kvm_vcpu *vcpu,
                        uint16_t *vmcs_version);
 void nested_evmcs_filter_control_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata);
 int nested_evmcs_check_controls(struct vmcs12 *vmcs12);
+void vmx_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu);
 
 #endif /* __KVM_X86_VMX_HYPERV_H */
index cce68fd5befbc0a7850478f425db630a1767a7f7..396712d13211fc63bdafea4e6fdfaf8ba12d4512 100644 (file)
@@ -6995,4 +6995,5 @@ struct kvm_x86_nested_ops vmx_nested_ops = {
        .write_log_dirty = nested_vmx_write_pml_buffer,
        .enable_evmcs = nested_enable_evmcs,
        .get_evmcs_version = nested_get_evmcs_version,
+       .hv_inject_synthetic_vmexit_post_tlb_flush = vmx_hv_inject_synthetic_vmexit_post_tlb_flush,
 };