]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: nSVM: Keep track of Hyper-V hv_vm_id/hv_vp_id
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 1 Nov 2022 14:53:58 +0000 (15:53 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 18 Nov 2022 17:59:12 +0000 (12:59 -0500)
Similar to nSVM, KVM needs to know L2's VM_ID/VP_ID and Partition
assist page address to handle L2 TLB flush requests.

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-21-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/hyperv.h
arch/x86/kvm/svm/nested.c

index c59544cdf03b7ce51dff327f911c7928fab07130..e97d80974e7203fea40c148af7c4ac80ad40cdbe 100644 (file)
@@ -9,5 +9,20 @@
 #include <asm/mshyperv.h>
 
 #include "../hyperv.h"
+#include "svm.h"
+
+static inline void nested_svm_hv_update_vm_vp_ids(struct kvm_vcpu *vcpu)
+{
+       struct vcpu_svm *svm = to_svm(vcpu);
+       struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
+       struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
+
+       if (!hv_vcpu)
+               return;
+
+       hv_vcpu->nested.pa_page_gpa = hve->partition_assist_page;
+       hv_vcpu->nested.vm_id = hve->hv_vm_id;
+       hv_vcpu->nested.vp_id = hve->hv_vp_id;
+}
 
 #endif /* __ARCH_X86_KVM_SVM_HYPERV_H__ */
index cc8f47e7e294db1351d1b8a932dfbc1ce305443b..aa36c349da43027b67d964acdc345904afd41f0c 100644 (file)
@@ -800,6 +800,8 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa,
        if (kvm_vcpu_apicv_active(vcpu))
                kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu);
 
+       nested_svm_hv_update_vm_vp_ids(vcpu);
+
        return 0;
 }