|
@@ -4024,6 +4024,12 @@ static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
|
|
|
__vmx_flush_tlb(vcpu, to_vmx(vcpu)->vpid);
|
|
|
}
|
|
|
|
|
|
+static void vmx_flush_tlb_ept_only(struct kvm_vcpu *vcpu)
|
|
|
+{
|
|
|
+ if (enable_ept)
|
|
|
+ vmx_flush_tlb(vcpu);
|
|
|
+}
|
|
|
+
|
|
|
static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
|
ulong cr0_guest_owned_bits = vcpu->arch.cr0_guest_owned_bits;
|
|
@@ -8548,6 +8554,7 @@ static void vmx_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set)
|
|
|
} else {
|
|
|
sec_exec_control &= ~SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE;
|
|
|
sec_exec_control |= SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
|
|
|
+ vmx_flush_tlb_ept_only(vcpu);
|
|
|
}
|
|
|
vmcs_write32(SECONDARY_VM_EXEC_CONTROL, sec_exec_control);
|
|
|
|
|
@@ -8573,8 +8580,10 @@ static void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu, hpa_t hpa)
|
|
|
*/
|
|
|
if (!is_guest_mode(vcpu) ||
|
|
|
!nested_cpu_has2(get_vmcs12(&vmx->vcpu),
|
|
|
- SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES))
|
|
|
+ SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) {
|
|
|
vmcs_write64(APIC_ACCESS_ADDR, hpa);
|
|
|
+ vmx_flush_tlb_ept_only(vcpu);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static void vmx_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr)
|
|
@@ -10256,6 +10265,9 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
|
|
|
if (nested_cpu_has_ept(vmcs12)) {
|
|
|
kvm_mmu_unload(vcpu);
|
|
|
nested_ept_init_mmu_context(vcpu);
|
|
|
+ } else if (nested_cpu_has2(vmcs12,
|
|
|
+ SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) {
|
|
|
+ vmx_flush_tlb_ept_only(vcpu);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -11055,6 +11067,10 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
|
|
|
vmx->nested.change_vmcs01_virtual_x2apic_mode = false;
|
|
|
vmx_set_virtual_x2apic_mode(vcpu,
|
|
|
vcpu->arch.apic_base & X2APIC_ENABLE);
|
|
|
+ } else if (!nested_cpu_has_ept(vmcs12) &&
|
|
|
+ nested_cpu_has2(vmcs12,
|
|
|
+ SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) {
|
|
|
+ vmx_flush_tlb_ept_only(vcpu);
|
|
|
}
|
|
|
|
|
|
/* This is needed for same reason as it was needed in prepare_vmcs02 */
|