aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/vmx.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2007-04-27 02:29:21 -0400
committerAvi Kivity <avi@qumranet.com>2007-05-03 03:52:31 -0400
commit25c4c2762e31a75403eca0dd59f2cab85e3a2532 (patch)
tree151c4a309da81608bdf729d701dcbfc3d4e1e9d7 /drivers/kvm/vmx.c
parente0e5127d06957e76da3906b7a58d5d2665e81f59 (diff)
KVM: VMX: Properly shadow the CR0 register in the vcpu struct
Set all of the host mask bits for CR0 so that we can maintain a proper shadow of CR0. This exposes CR0.TS, paving the way for lazy fpu handling. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/vmx.c')
-rw-r--r--drivers/kvm/vmx.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index d28c848138ce..09608114e29a 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -810,11 +810,8 @@ static void exit_lmode(struct kvm_vcpu *vcpu)
810 810
811#endif 811#endif
812 812
813static void vmx_decache_cr0_cr4_guest_bits(struct kvm_vcpu *vcpu) 813static void vmx_decache_cr4_guest_bits(struct kvm_vcpu *vcpu)
814{ 814{
815 vcpu->cr0 &= KVM_GUEST_CR0_MASK;
816 vcpu->cr0 |= vmcs_readl(GUEST_CR0) & ~KVM_GUEST_CR0_MASK;
817
818 vcpu->cr4 &= KVM_GUEST_CR4_MASK; 815 vcpu->cr4 &= KVM_GUEST_CR4_MASK;
819 vcpu->cr4 |= vmcs_readl(GUEST_CR4) & ~KVM_GUEST_CR4_MASK; 816 vcpu->cr4 |= vmcs_readl(GUEST_CR4) & ~KVM_GUEST_CR4_MASK;
820} 817}
@@ -1205,7 +1202,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
1205 vmcs_writel(TPR_THRESHOLD, 0); 1202 vmcs_writel(TPR_THRESHOLD, 0);
1206#endif 1203#endif
1207 1204
1208 vmcs_writel(CR0_GUEST_HOST_MASK, KVM_GUEST_CR0_MASK); 1205 vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL);
1209 vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); 1206 vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK);
1210 1207
1211 vcpu->cr0 = 0x60000010; 1208 vcpu->cr0 = 0x60000010;
@@ -1557,6 +1554,11 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1557 return 1; 1554 return 1;
1558 }; 1555 };
1559 break; 1556 break;
1557 case 2: /* clts */
1558 vcpu_load_rsp_rip(vcpu);
1559 set_cr0(vcpu, vcpu->cr0 & ~CR0_TS_MASK);
1560 skip_emulated_instruction(vcpu);
1561 return 1;
1560 case 1: /*mov from cr*/ 1562 case 1: /*mov from cr*/
1561 switch (cr) { 1563 switch (cr) {
1562 case 3: 1564 case 3:
@@ -2112,7 +2114,7 @@ static struct kvm_arch_ops vmx_arch_ops = {
2112 .get_segment = vmx_get_segment, 2114 .get_segment = vmx_get_segment,
2113 .set_segment = vmx_set_segment, 2115 .set_segment = vmx_set_segment,
2114 .get_cs_db_l_bits = vmx_get_cs_db_l_bits, 2116 .get_cs_db_l_bits = vmx_get_cs_db_l_bits,
2115 .decache_cr0_cr4_guest_bits = vmx_decache_cr0_cr4_guest_bits, 2117 .decache_cr4_guest_bits = vmx_decache_cr4_guest_bits,
2116 .set_cr0 = vmx_set_cr0, 2118 .set_cr0 = vmx_set_cr0,
2117 .set_cr3 = vmx_set_cr3, 2119 .set_cr3 = vmx_set_cr3,
2118 .set_cr4 = vmx_set_cr4, 2120 .set_cr4 = vmx_set_cr4,