nestedsvm: fix tlb_control
authorChristoph Egger <Christoph.Egger@amd.com>
Tue, 31 May 2011 12:55:50 +0000 (13:55 +0100)
committerChristoph Egger <Christoph.Egger@amd.com>
Tue, 31 May 2011 12:55:50 +0000 (13:55 +0100)
On VMRUN emulation evaluate the virtual tlb_control only to match
hw behaviour. Deal with l1 guests which use flush-by-asid w/o
checking cpuid bits or fill tlb_control with random data.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
xen/arch/x86/hvm/svm/nestedsvm.c

index 44668fcfdf498d5425ef4491a0c12724fc4fc410..86af8ed1a7fa822d5c1600cb19501ca0f54fff5f 100644 (file)
@@ -460,7 +460,7 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
     /* ASID - Emulation handled in hvm_asid_handle_vmenter() */
 
     /* TLB control */
-    n2vmcb->tlb_control = n1vmcb->tlb_control | ns_vmcb->tlb_control;
+    n2vmcb->tlb_control = ns_vmcb->tlb_control;
 
     /* Virtual Interrupts */
     if (!vcleanbit_set(tpr)) {
@@ -655,7 +655,9 @@ nsvm_vcpu_vmentry(struct vcpu *v, struct cpu_user_regs *regs,
     svm->ns_vmcb_guestcr3 = ns_vmcb->_cr3;
     svm->ns_vmcb_hostcr3 = ns_vmcb->_h_cr3;
 
-    nv->nv_flushp2m = ns_vmcb->tlb_control;
+    /* Convert explicitely to boolean. Deals with l1 guests
+     * that use flush-by-asid w/o checking the cpuid bits */
+    nv->nv_flushp2m = !!ns_vmcb->tlb_control;
     if ( svm->ns_guest_asid != ns_vmcb->_guest_asid )
     {
         nv->nv_flushp2m = 1;