Skip to content

Commit 327c072

Browse files
Liran Alonbonzini
authored andcommitted
KVM: nVMX: Flush linear and combined mappings on VPID02 related flushes
All VPID12s used on a given L1 vCPU is translated to a single VPID02 (vmx->nested.vpid02 or vmx->vpid). Therefore, on L1->L2 VMEntry, we need to invalidate linear and combined mappings tagged by VPID02 in case L1 uses VPID and vmcs12->vpid was changed since last L1->L2 VMEntry. However, current code invalidates the wrong mappings as it calls __vmx_flush_tlb() with invalidate_gpa parameter set to true which will result in invalidating combined and guest-physical mappings tagged with active EPTP which is EPTP01. Similarly, INVVPID emulation have the exact same issue. Fix both issues by just setting invalidate_gpa parameter to false which will result in invalidating linear and combined mappings tagged with given VPID02 as required. Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com> Reviewed-by: Mark Kanda <mark.kanda@oracle.com> Signed-off-by: Liran Alon <liran.alon@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 3d5bdae commit 327c072

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/x86/kvm/vmx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9074,7 +9074,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
90749074
__invvpid(VMX_VPID_EXTENT_INDIVIDUAL_ADDR,
90759075
vpid02, operand.gla);
90769076
} else
9077-
__vmx_flush_tlb(vcpu, vpid02, true);
9077+
__vmx_flush_tlb(vcpu, vpid02, false);
90789078
break;
90799079
case VMX_VPID_EXTENT_SINGLE_CONTEXT:
90809080
case VMX_VPID_EXTENT_SINGLE_NON_GLOBAL:
@@ -9083,10 +9083,10 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
90839083
VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
90849084
return kvm_skip_emulated_instruction(vcpu);
90859085
}
9086-
__vmx_flush_tlb(vcpu, vpid02, true);
9086+
__vmx_flush_tlb(vcpu, vpid02, false);
90879087
break;
90889088
case VMX_VPID_EXTENT_ALL_CONTEXT:
9089-
__vmx_flush_tlb(vcpu, vpid02, true);
9089+
__vmx_flush_tlb(vcpu, vpid02, false);
90909090
break;
90919091
default:
90929092
WARN_ON_ONCE(1);
@@ -12295,7 +12295,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
1229512295
if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) {
1229612296
if (vmcs12->virtual_processor_id != vmx->nested.last_vpid) {
1229712297
vmx->nested.last_vpid = vmcs12->virtual_processor_id;
12298-
__vmx_flush_tlb(vcpu, vmx->nested.vpid02, true);
12298+
__vmx_flush_tlb(vcpu, vmx->nested.vpid02, false);
1229912299
}
1230012300
} else {
1230112301
/*

0 commit comments

Comments
 (0)