Skip to contentSkip to conversation

KVM: VMX: update cr0 read shadow when deactivating cr0.ts passthrough

PATCH Applied Marcelo Tosatti 2 participants 2 messages Feb 1, 2010 – Feb 7, 2010

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

On fpu deactivation, the cr0 read shadow is not properly updated, since it assumes vcpu->arch.cr0 contains the guest visible cr0 value before guest had control of cr0.ts.

This is not true, since cr0 has been decached (from vmx_fpu_deactivate itself or somewhere else).

Fix by unconditionally updating cr0 read shadow (this is not a hot path, in comparison with entry/exit).

Fixes FC8 64 install.

arch/x86/kvm/vmx.c +4 -7
index c1d864a..334b016 100644
@@ -805,19 +805,16 @@ static void vmx_fpu_activate(struct kvm_vcpu *vcpu)
 	vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits);
 }
 
+static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu);
+
 static void vmx_fpu_deactivate(struct kvm_vcpu *vcpu)
 {
-	ulong old_ts, old_cr0;
-
-	old_ts = kvm_read_cr0_bits(vcpu, X86_CR0_TS);
+	vmx_decache_cr0_guest_bits(vcpu);
 	vmcs_set_bits(GUEST_CR0, X86_CR0_TS | X86_CR0_MP);
 	update_exception_bitmap(vcpu);
 	vcpu->arch.cr0_guest_owned_bits = 0;
 	vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits);
-	old_cr0 = vcpu->arch.cr0;
-	vcpu->arch.cr0 = (vcpu->arch.cr0 & ~X86_CR0_TS) | old_ts;
-	if (vcpu->arch.cr0 != old_cr0)
-		vmcs_writel(CR0_READ_SHADOW, vcpu->arch.cr0);
+	vmcs_writel(CR0_READ_SHADOW, vcpu->arch.cr0);
 }
 
 static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu)
Applied
#1 lore raw
Quoted 4 lines · Marcelo Tosatti

On fpu deactivation, the cr0 read shadow is not properly updated, since it assumes vcpu->arch.cr0 contains the guest visible cr0 value before guest had control of cr0.ts.

Quoted 8 lines

This is not true, since cr0 has been decached (from vmx_fpu_deactivate itself or somewhere else).

Fix by unconditionally updating cr0 read shadow (this is not a hot path, in comparison with entry/exit).

Fixes FC8 64 install.

Applied, thanks.

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