ia64/xen-unstable

changeset 14470:ed1e4cc4a5b7

[SVM] Move vmcb setup code for AP bringup out of the launch path
and into the earlier AP bringup code. This stops it from resetting
the VCPUs of SMP guests into real mode on restore or migrate.

Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Mon Mar 19 16:28:24 2007 +0000 (2007-03-19)
parents 126a2c3c6a9d
children 36e6f85cd572
files xen/arch/x86/hvm/svm/svm.c
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Mon Mar 19 14:46:51 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Mon Mar 19 16:28:24 2007 +0000
     1.3 @@ -749,6 +749,14 @@ static void svm_set_tsc_offset(struct vc
     1.4  static void svm_init_ap_context(
     1.5      struct vcpu_guest_context *ctxt, int vcpuid, int trampoline_vector)
     1.6  {
     1.7 +    struct vcpu *v;
     1.8 +    cpu_user_regs_t *regs;
     1.9 +    u16 cs_sel;
    1.10 +
    1.11 +    /* We know this is safe because hvm_bringup_ap() does it */
    1.12 +    v = current->domain->vcpu[vcpuid];
    1.13 +    regs = &v->arch.guest_context.user_regs;
    1.14 +
    1.15      memset(ctxt, 0, sizeof(*ctxt));
    1.16  
    1.17      /*
    1.18 @@ -756,8 +764,19 @@ static void svm_init_ap_context(
    1.19       * passed to us is page alligned and is the physicall frame number for
    1.20       * the code. We will execute this code in real mode. 
    1.21       */
    1.22 +    cs_sel = trampoline_vector << 8;
    1.23      ctxt->user_regs.eip = 0x0;
    1.24 -    ctxt->user_regs.cs = (trampoline_vector << 8);
    1.25 +    ctxt->user_regs.cs = cs_sel;
    1.26 +
    1.27 +    /*
    1.28 +     * This is the launch of an AP; set state so that we begin executing
    1.29 +     * the trampoline code in real-mode.
    1.30 +     */
    1.31 +    svm_do_vmmcall_reset_to_realmode(v, regs);  
    1.32 +    /* Adjust the vmcb's hidden register state. */
    1.33 +    v->arch.hvm_svm.vmcb->rip = 0;
    1.34 +    v->arch.hvm_svm.vmcb->cs.sel = cs_sel;
    1.35 +    v->arch.hvm_svm.vmcb->cs.base = (cs_sel << 4);
    1.36  }
    1.37  
    1.38  static void svm_init_hypercall_page(struct domain *d, void *hypercall_page)
    1.39 @@ -910,21 +929,6 @@ static void arch_svm_do_launch(struct vc
    1.40          v->arch.hvm_svm.vmcb->h_cr3 = pagetable_get_paddr(v->domain->arch.phys_table);
    1.41      }
    1.42  
    1.43 -    if ( v->vcpu_id != 0 )
    1.44 -    {
    1.45 -        cpu_user_regs_t *regs = &current->arch.guest_context.user_regs;
    1.46 -        u16 cs_sel = regs->cs;
    1.47 -        /*
    1.48 -         * This is the launch of an AP; set state so that we begin executing
    1.49 -         * the trampoline code in real-mode.
    1.50 -         */
    1.51 -        svm_do_vmmcall_reset_to_realmode(v, regs);  
    1.52 -        /* Adjust the state to execute the trampoline code.*/
    1.53 -        v->arch.hvm_svm.vmcb->rip = 0;
    1.54 -        v->arch.hvm_svm.vmcb->cs.sel= cs_sel;
    1.55 -        v->arch.hvm_svm.vmcb->cs.base = (cs_sel << 4);
    1.56 -    }
    1.57 -      
    1.58      reset_stack_and_jump(svm_asm_do_launch);
    1.59  }
    1.60