svm guest timer migration fix
PATCH 2/4 svm guest timer migration fix
Svm patch to fix guest pin timer migration logic.
Applies cleanly to 8990.
Please apply.
Signed-off-by Tom Woller <[email protected]>
# HG changeset patch
# User [email protected]
# Node ID 642f19f235302f1e7e5cd8a48aa52a5cce39409e # Parent 5b743dd9b23133e84965e148e26f4946fe3dd563 port guest pin timer migration to SVM.
xen/arch/x86/hvm/svm/svm.c +37 -19
@@ -820,8 +820,29 @@void arch_svm_do_resume (struct vcpu *v) { -svm_do_resume (v); -reset_stack_and_jump (svm_asm_do_resume); +/* pinning VCPU to a different core? */ +if ( v->arch.hvm_svm.launch_core ==smp_processor_id ()) { +svm_do_resume ( v ); +reset_stack_and_jump ( svm_asm_do_resume ); + } +else { +printk ("VCPU core pinned: %d to %d\n" , v->arch.hvm_svm.launch_core,smp_processor_id () ); + v->arch.hvm_svm.launch_core =smp_processor_id (); +svm_migrate_timers ( v ); +svm_do_resume ( v ); +reset_stack_and_jump ( svm_asm_do_resume ); + } +} + + +void svm_migrate_timers (struct vcpu *v) +{ +struct hvm_virpit *vpit = &(v->domain->arch.hvm_domain.vpit); + +migrate_timer ( &vpit->pit_timer, v->processor ); +migrate_timer ( &v->arch.hvm_svm.hlt_timer, v->processor ); +if (hvm_apic_support (v->domain) &&VLAPIC ( v )) +migrate_timer ( &(VLAPIC (v)->vlapic_timer ), v->processor ); }
@@ -2666,26 +2687,23 @@ {struct vcpu *v = current;struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; -int core =smp_processor_id (); -int oldcore = v->arch.hvm_svm.core; -/* -* if need to assign new asid or if switching cores, -* then retire asid for old core, and assign new for new core. -*/ -if ( v->arch.hvm_svm.core != core ) { -if (svm_dbg_on) -printk ("old core %d new core %d\n" ,(int )v->arch.hvm_svm.core,(int )core); - v->arch.hvm_svm.core = core; - } -if (test_bit (ARCH_SVM_VMCB_ASSIGN_ASID , &v->arch.hvm_svm.flags) || - (oldcore != core)) { -if (!asidpool_assign_next (vmcb,1 , - oldcore, core)) { + +/* +* if need to assign new asid, or if switching cores, +* retire asid for the old core, and assign a new asid to the current core. +*/ +if (test_bit (ARCH_SVM_VMCB_ASSIGN_ASID , &v->arch.hvm_svm.flags ) || + ( v->arch.hvm_svm.asid_core != v->arch.hvm_svm.launch_core )) { +/* recycle asid */ +if ( !asidpool_assign_next ( vmcb,1 , + v->arch.hvm_svm.asid_core, v->arch.hvm_svm.launch_core )) {/* If we get here, we have a major problem */ domain_crash_synchronous (); } - } -clear_bit (ARCH_SVM_VMCB_ASSIGN_ASID , &v->arch.hvm_svm.flags); + + v->arch.hvm_svm.asid_core = v->arch.hvm_svm.launch_core; +clear_bit (ARCH_SVM_VMCB_ASSIGN_ASID , &v->arch.hvm_svm.flags ); + } }/*
xen/arch/x86/hvm/svm/vmcb.c +8 -9
@@ -306,7 +306,7 @@ {if (arch_svm->vmcb !=NULL ) { -asidpool_retire (arch_svm->vmcb, arch_svm->core); +asidpool_retire (arch_svm->vmcb, arch_svm->asid_core);free_vmcb (arch_svm->vmcb); }if (arch_svm->iopm !=NULL ) {
@@ -404,18 +404,17 @@void svm_do_launch (struct vcpu *v) { +struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; +int core =smp_processor_id (); +ASSERT (vmcb); +/* Update CR3, GDT, LDT, TR */ -struct vmcb_struct *vmcb; -int core =smp_processor_id (); - vmcb = v->arch.hvm_svm.vmcb; -ASSERT (vmcb); -svm_stts (v); -/* current core is the one we will perform the vmrun on */ - v->arch.hvm_svm.core = core; +/* current core is the one we intend to perform the VMRUN on */ + v->arch.hvm_svm.launch_core = v->arch.hvm_svm.asid_core = core;clear_bit (ARCH_SVM_VMCB_ASSIGN_ASID , &v->arch.hvm_svm.flags); -if ( !asidpool_assign_next (vmcb,0 , core, core) ) +if ( !asidpool_assign_next ( vmcb,0 , core, core ))BUG ();if (v->vcpu_id ==0 )
xen/include/asm-x86/hvm/svm/svm.h +2 -0
@@ -54,6 +54,8 @@/* For debugging. Remove when no longer needed. */ extern void svm_dump_host_regs (const char *from); +extern void svm_migrate_timers (struct vcpu *v); +/* ASID API */ enum {ASID_AVAILABLE =0 ,
xen/include/asm-x86/hvm/svm/vmcb.h +2 -1
@@ -457,7 +457,8 @@u64 vmexit_tsc;/* tsc read at #VMEXIT. for TSC_OFFSET */ int injecting_event;int saved_irq_vector; -u32 core;/* cpu of last vmexit */ +u32 launch_core; +u32 asid_core;unsigned long flags;/* VMCB flags */ unsigned long cpu_shadow_cr0;/* copy of guest read shadow CR0 */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel