From 69633efbca3c254127f35ba908dfc4c763d8d102 Mon Sep 17 00:00:00 2001 From: Ross Lagerwall Date: Tue, 6 Oct 2026 15:48:05 +0100 Subject: [PATCH] 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 Reviewed-by: Jason Andryuk Reviewed-by: Andrew Cooper --- 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) )