Skip to contentSkip to conversation

KVM: VMX: flush TLB with INVEPT on cpu migration

PATCH Marcelo Tosatti 4 participants 4 messages Oct 1, 2009 – Oct 22, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

It is possible that stale EPTP-tagged mappings are used, if a vcpu migrates to a different pcpu.

Set KVM_REQ_TLB_FLUSH in vmx_vcpu_load, when switching pcpus, which will invalidate both VPID and EPT mappings on the next vm-entry.

arch/x86/kvm/vmx.c +1 -1
index e86f1a6..97f4265 100644
@@ -708,7 +708,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 	if (vcpu->cpu != cpu) {
 		vcpu_clear(vmx);
 		kvm_migrate_timers(vcpu);
-		vpid_sync_vcpu_all(vmx);
+		set_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests);
 		local_irq_disable();
 		list_add(&vmx->local_vcpus_link,
 			 &per_cpu(vcpus_on_cpu, cpu));
#1 lore raw
Quoted 13 lines · Marcelo Tosatti

It is possible that stale EPTP-tagged mappings are used, if a vcpu migrates to a different pcpu.

Set KVM_REQ_TLB_FLUSH in vmx_vcpu_load, when switching pcpus, which will invalidate both VPID and EPT mappings on the next vm-entry.

arch/x86/kvm/vmx.c +0 -0
index e86f1a6..97f4265 100644

arch/x86/kvm/vmx.c static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)

Quoted 9 lines
arch/x86/kvm/vmx.c +1 -2
@@ -708,7 +708,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 	if (vcpu->cpu != cpu) {
 		vcpu_clear(vmx);
 		kvm_migrate_timers(vcpu);
-		vpid_sync_vcpu_all(vmx);
+		set_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests);
 		local_irq_disable();
 		list_add(&vmx->local_vcpus_link,
 			 &per_cpu(vcpus_on_cpu, cpu));
--

This patch fixes my ept misconfig problem seen very so often while installing sles11 guest.

thanks,
RP

#2 lore raw
In reply to Marcelo Tosatti
Quoted 5 lines · On Friday 02 October 2009 00:16:58 you wrote:

It is possible that stale EPTP-tagged mappings are used, if a vcpu migrates to a different pcpu.

Set KVM_REQ_TLB_FLUSH in vmx_vcpu_load, when switching pcpus, which will invalidate both VPID and EPT mappings on the next vm-entry.

Thank you - I was at the brink of a nervous break-down before discovering this. Maybe it would help for the future to add a comment to ept_misconfig_inspect_spte that explains that this might be caused by out of sync tlbs, too (esp. when it doesn't show an apparent cause of the misconfig)

Quoted 23 lines
arch/x86/kvm/vmx.c +1 -2
index e86f1a6..97f4265 100644
@@ -708,7 +708,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int
 cpu) if (vcpu->cpu != cpu) {
 		vcpu_clear(vmx);
 		kvm_migrate_timers(vcpu);
-		vpid_sync_vcpu_all(vmx);
+		set_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests);
 		local_irq_disable();
 		list_add(&vmx->local_vcpus_link,
 			 &per_cpu(vcpus_on_cpu, cpu));
--

To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

!DSPAM:4ac52dbb832371894110002!

Signature · 4 lines
/"\  Best regards,                      | [email protected]
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
#3 lore raw
Quoted 5 lines · Max Laier
Quoted 3 lines · On Friday 02 October 2009 00:16:58 you wrote:

It is possible that stale EPTP-tagged mappings are used, if a vcpu migrates to a different pcpu.

Quoted 8 lines
Quoted 3 lines

Set KVM_REQ_TLB_FLUSH in vmx_vcpu_load, when switching pcpus, which will invalidate both VPID and EPT mappings on the next vm-entry.

Thank you - I was at the brink of a nervous break-down before discovering this. Maybe it would help for the future to add a comment to ept_misconfig_inspect_spte that explains that this might be caused by out of sync tlbs, too (esp. when it doesn't show an apparent cause of the misconfig)

In fact ept_misconfig_inspect_spte() was added in order to track down this bug, so it will probably be removed in the future.

Signature · 1 line
error compiling committee.c: too many arguments to function