mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-20 01:24:39 +08:00
3f4a812edf
Implement Hyper-V L2 TLB flush for nSVM. The feature needs to be enabled both in extended 'nested controls' in VMCB and VP assist page. According to Hyper-V TLFS, synthetic vmexit to L1 is performed with - HV_SVM_EXITCODE_ENL exit_code. - HV_SVM_ENL_EXITCODE_TRAP_AFTER_FLUSH exit_info_1. Note: VP assist page is cached in 'struct kvm_vcpu_hv' so recalc_intercepts() doesn't need to read from guest's memory. KVM needs to update the case upon each VMRUN and after svm_set_nested_state (svm_get_nested_state_pages()) to handle the case when the guest got migrated while L2 was running. 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-29-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Common Hyper-V on KVM and KVM on Hyper-V definitions (SVM).
|
|
*/
|
|
|
|
#ifndef __ARCH_X86_KVM_SVM_HYPERV_H__
|
|
#define __ARCH_X86_KVM_SVM_HYPERV_H__
|
|
|
|
#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;
|
|
}
|
|
|
|
static inline bool nested_svm_l2_tlb_flush_enabled(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 false;
|
|
|
|
if (!hve->hv_enlightenments_control.nested_flush_hypercall)
|
|
return false;
|
|
|
|
return hv_vcpu->vp_assist_page.nested_control.features.directhypercall;
|
|
}
|
|
|
|
void svm_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu);
|
|
|
|
#endif /* __ARCH_X86_KVM_SVM_HYPERV_H__ */
|