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@citrix.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
Ross Lagerwall authored and Andrew Cooper committed 2026-10-26 18:36:52 +00:00
1 parent d97847e858
commit 69633efbca
1 file changed
+1 -2
+1 -2
View File
@@ -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) )
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.