ts

2010-03-09 Thread Karl




http://aneqedom.maddsites.com/uqyvewox.html
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: VMX: update cr0 read shadow when deactivating cr0.ts passthrough

2010-02-07 Thread Avi Kivity
From: 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.

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.

Signed-off-by: Marcelo Tosatti 
Signed-off-by: Avi Kivity 

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c97bca7..b400be0 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -803,19 +803,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)
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: VMX: Give the guest ownership of cr0.ts when the fpu is active

2010-01-14 Thread Avi Kivity
From: Avi Kivity 

If the guest fpu is loaded, there is nothing interesing about cr0.ts; let
the guest play with it as it will.  This makes context switches between fpu
intensive guest processes faster, as we won't trap the clts and cr0 write
instructions.

Signed-off-by: Avi Kivity 

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 6075192..4612728 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -803,12 +803,23 @@ static void vmx_fpu_activate(struct kvm_vcpu *vcpu)
if (kvm_read_cr0_bits(vcpu, X86_CR0_TS))
vmcs_set_bits(GUEST_CR0, X86_CR0_TS);
update_exception_bitmap(vcpu);
+   vcpu->arch.cr0_guest_owned_bits = X86_CR0_TS;
+   vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits);
 }
 
 static void vmx_fpu_deactivate(struct kvm_vcpu *vcpu)
 {
+   ulong old_ts, old_cr0;
+
+   old_ts = kvm_read_cr0_bits(vcpu, X86_CR0_TS);
vmcs_set_bits(GUEST_CR0, X86_CR0_TS);
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);
 }
 
 static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu)
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html