[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86/svm: Don't clear clean bits on every context switch



commit 69633efbca3c254127f35ba908dfc4c763d8d102
Author:     Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
AuthorDate: Tue Oct 6 15:48:05 2026 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Oct 26 18:36:52 2026 +0000

    x86/svm: Don't clear clean bits on every context switch
    
    This is overly agressive.  The APM says:
    
      The hypervisor must clear the entire VMCB field to 0 for a guest, under 
the
      following circumstances:
    
        * The hypervisor executes the guest on a different CPU core than one 
used
          the last time that guest was executed.
    
    Clear the cleanbits only when the VMCB is used on a different pCPU rather 
than
    on every context switch to the vCPU.
    
    Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
    Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/svm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 71e48351f2..4e22322f4b 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -890,7 +890,6 @@ static void cf_check svm_ctxt_switch_from(struct vcpu *v)
 
 static void cf_check svm_ctxt_switch_to(struct vcpu *v)
 {
-    struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb;
     int cpu = smp_processor_id();
 
     /*
@@ -908,7 +907,6 @@ static void cf_check svm_ctxt_switch_to(struct vcpu *v)
 
     svm_restore_dr(v);
 
-    vmcb->cleanbits.raw = 0;
     svm_tsc_ratio_load(v);
 
     if ( cpu_has_msr_tsc_aux )
@@ -953,6 +951,7 @@ static void noreturn cf_check svm_do_resume(void)
         hvm_migrate_pirqs(v);
         /* Migrating to another ASID domain.  Request a new ASID. */
         hvm_asid_flush_vcpu(v);
+        vmcb->cleanbits.raw = 0;
     }
 
     if ( !vcpu_guestmode && !vlapic_hw_disabled(vlapic) )
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.