direct-io.hg

changeset 13812:625aa1547cb6

hvm: vcpu reset support for x86 INIT IPI, needed for CPU hotplug.
Signed-off-by: Xin Li <xin.b.li@intel.com>
author kfraser@localhost.localdomain
date Tue Feb 06 23:14:21 2007 +0000 (2007-02-06)
parents e1364f2c6867
children 383ade1b0da4
files xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmx/vmcs.c xen/include/asm-x86/hvm/hvm.h xen/include/asm-x86/hvm/vlapic.h
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Tue Feb 06 23:12:59 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Tue Feb 06 23:14:21 2007 +0000
     1.3 @@ -273,6 +273,24 @@ void hvm_vcpu_destroy(struct vcpu *v)
     1.4      /*free_xen_event_channel(v, v->arch.hvm_vcpu.xen_port);*/
     1.5  }
     1.6  
     1.7 +
     1.8 +void hvm_vcpu_reset(struct vcpu *v)
     1.9 +{
    1.10 +    vcpu_pause(v);
    1.11 +
    1.12 +    vlapic_reset(vcpu_vlapic(v));
    1.13 +
    1.14 +    hvm_funcs.vcpu_initialise(v);
    1.15 +
    1.16 +    set_bit(_VCPUF_down, &v->vcpu_flags);
    1.17 +    clear_bit(_VCPUF_initialised, &v->vcpu_flags);
    1.18 +    clear_bit(_VCPUF_fpu_initialised, &v->vcpu_flags);
    1.19 +    clear_bit(_VCPUF_fpu_dirtied, &v->vcpu_flags);
    1.20 +    clear_bit(_VCPUF_blocked, &v->vcpu_flags);
    1.21 +
    1.22 +    vcpu_unpause(v);
    1.23 +}
    1.24 +
    1.25  static void hvm_vcpu_down(void)
    1.26  {
    1.27      struct vcpu *v = current;
    1.28 @@ -624,20 +642,13 @@ void hvm_hypercall_page_initialise(struc
    1.29   */
    1.30  int hvm_bringup_ap(int vcpuid, int trampoline_vector)
    1.31  {
    1.32 -    struct vcpu *bsp = current, *v;
    1.33 -    struct domain *d = bsp->domain;
    1.34 +    struct vcpu *v;
    1.35 +    struct domain *d = current->domain;
    1.36      struct vcpu_guest_context *ctxt;
    1.37      int rc = 0;
    1.38  
    1.39      BUG_ON(!is_hvm_domain(d));
    1.40  
    1.41 -    if ( bsp->vcpu_id != 0 )
    1.42 -    {
    1.43 -        gdprintk(XENLOG_ERR, "Not calling hvm_bringup_ap from BSP context.\n");
    1.44 -        domain_crash(bsp->domain);
    1.45 -        return -EINVAL;
    1.46 -    }
    1.47 -
    1.48      if ( (v = d->vcpu[vcpuid]) == NULL )
    1.49          return -ENOENT;
    1.50  
    1.51 @@ -668,8 +679,8 @@ int hvm_bringup_ap(int vcpuid, int tramp
    1.52          goto out;
    1.53      }
    1.54  
    1.55 -    if ( test_and_clear_bit(_VCPUF_down, &d->vcpu[vcpuid]->vcpu_flags) )
    1.56 -        vcpu_wake(d->vcpu[vcpuid]);
    1.57 +    if ( test_and_clear_bit(_VCPUF_down, &v->vcpu_flags) )
    1.58 +        vcpu_wake(v);
    1.59      gdprintk(XENLOG_INFO, "AP %d bringup suceeded.\n", vcpuid);
    1.60  
    1.61   out:
     2.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Tue Feb 06 23:12:59 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Tue Feb 06 23:14:21 2007 +0000
     2.3 @@ -209,7 +209,8 @@ int svm_create_vmcb(struct vcpu *v)
     2.4      struct arch_svm_struct *arch_svm = &v->arch.hvm_svm;
     2.5      int rc;
     2.6  
     2.7 -    if ( (arch_svm->vmcb = alloc_vmcb()) == NULL )
     2.8 +    if ( (arch_svm->vmcb == NULL) &&
     2.9 +         (arch_svm->vmcb = alloc_vmcb()) == NULL )
    2.10      {
    2.11          printk("Failed to create a new VMCB\n");
    2.12          return -ENOMEM;
     3.1 --- a/xen/arch/x86/hvm/vlapic.c	Tue Feb 06 23:12:59 2007 +0000
     3.2 +++ b/xen/arch/x86/hvm/vlapic.c	Tue Feb 06 23:14:21 2007 +0000
     3.3 @@ -83,8 +83,6 @@ static unsigned int vlapic_lvt_mask[VLAP
     3.4  #define vlapic_base_address(vlapic)                             \
     3.5      (vlapic->hw.apic_base_msr & MSR_IA32_APICBASE_BASE)
     3.6  
     3.7 -static int vlapic_reset(struct vlapic *vlapic);
     3.8 -
     3.9  /*
    3.10   * Generic APIC bitmap vector update & search routines.
    3.11   */
    3.12 @@ -293,8 +291,11 @@ static int vlapic_accept_irq(struct vcpu
    3.13          break;
    3.14  
    3.15      case APIC_DM_SMI:
    3.16 +        gdprintk(XENLOG_WARNING, "Ignoring guest SMI\n");
    3.17 +        break;
    3.18 +
    3.19      case APIC_DM_NMI:
    3.20 -        gdprintk(XENLOG_WARNING, "Ignoring guest SMI/NMI\n");
    3.21 +        gdprintk(XENLOG_WARNING, "Ignoring guest NMI\n");
    3.22          break;
    3.23  
    3.24      case APIC_DM_INIT:
    3.25 @@ -303,10 +304,7 @@ static int vlapic_accept_irq(struct vcpu
    3.26              break;
    3.27          /* FIXME How to check the situation after vcpu reset? */
    3.28          if ( test_bit(_VCPUF_initialised, &v->vcpu_flags) )
    3.29 -        {
    3.30 -            gdprintk(XENLOG_ERR, "Reset hvm vcpu not supported yet\n");
    3.31 -            goto exit_and_crash;
    3.32 -        }
    3.33 +            hvm_vcpu_reset(v);
    3.34          v->arch.hvm_vcpu.init_sipi_sipi_state =
    3.35              HVM_VCPU_INIT_SIPI_SIPI_STATE_WAIT_SIPI;
    3.36          result = 1;
    3.37 @@ -764,7 +762,7 @@ int cpu_get_apic_interrupt(struct vcpu *
    3.38  }
    3.39  
    3.40  /* Reset the VLPAIC back to its power-on/reset state. */
    3.41 -static int vlapic_reset(struct vlapic *vlapic)
    3.42 +void vlapic_reset(struct vlapic *vlapic)
    3.43  {
    3.44      struct vcpu *v = vlapic_vcpu(vlapic);
    3.45      int i;
    3.46 @@ -793,8 +791,6 @@ static int vlapic_reset(struct vlapic *v
    3.47  
    3.48      vlapic_set_reg(vlapic, APIC_SPIV, 0xff);
    3.49      vlapic->hw.disabled |= VLAPIC_SW_DISABLED;
    3.50 -
    3.51 -    return 1;
    3.52  }
    3.53  
    3.54  #ifdef HVM_DEBUG_SUSPEND
    3.55 @@ -922,7 +918,6 @@ int vlapic_init(struct vcpu *v)
    3.56      {
    3.57          dprintk(XENLOG_ERR, "malloc vlapic regs error for vcpu %x\n",
    3.58                  v->vcpu_id);
    3.59 -        xfree(vlapic);
    3.60          return -ENOMEM;
    3.61      }
    3.62  
     4.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Tue Feb 06 23:12:59 2007 +0000
     4.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Tue Feb 06 23:14:21 2007 +0000
     4.3 @@ -295,6 +295,11 @@ static void construct_vmcs(struct vcpu *
     4.4  
     4.5      vmx_vmcs_enter(v);
     4.6  
     4.7 +    v->arch.hvm_vmx.cpu_cr2 = 0;
     4.8 +    v->arch.hvm_vmx.cpu_cr3 = 0;
     4.9 +    memset(&v->arch.hvm_vmx.msr_state, 0, sizeof(v->arch.hvm_vmx.msr_state));
    4.10 +    v->arch.hvm_vmx.vmxassist_enabled = 0;
    4.11 +
    4.12      /* VMCS controls. */
    4.13      __vmwrite(PIN_BASED_VM_EXEC_CONTROL, vmx_pin_based_exec_control);
    4.14      __vmwrite(VM_EXIT_CONTROLS, vmx_vmexit_control);
    4.15 @@ -448,10 +453,13 @@ static void construct_vmcs(struct vcpu *
    4.16  
    4.17  int vmx_create_vmcs(struct vcpu *v)
    4.18  {
    4.19 -    if ( (v->arch.hvm_vmx.vmcs = vmx_alloc_vmcs()) == NULL )
    4.20 -        return -ENOMEM;
    4.21 - 
    4.22 -    __vmx_clear_vmcs(v);
    4.23 +    if ( v->arch.hvm_vmx.vmcs == NULL )
    4.24 +    {
    4.25 +        if ( (v->arch.hvm_vmx.vmcs = vmx_alloc_vmcs()) == NULL )
    4.26 +            return -ENOMEM;
    4.27 +
    4.28 +        __vmx_clear_vmcs(v);
    4.29 +    }
    4.30  
    4.31      construct_vmcs(v);
    4.32  
     5.1 --- a/xen/include/asm-x86/hvm/hvm.h	Tue Feb 06 23:12:59 2007 +0000
     5.2 +++ b/xen/include/asm-x86/hvm/hvm.h	Tue Feb 06 23:14:21 2007 +0000
     5.3 @@ -153,6 +153,7 @@ void hvm_domain_destroy(struct domain *d
     5.4  
     5.5  int hvm_vcpu_initialise(struct vcpu *v);
     5.6  void hvm_vcpu_destroy(struct vcpu *v);
     5.7 +void hvm_vcpu_reset(struct vcpu *vcpu);
     5.8  
     5.9  void hvm_send_assist_req(struct vcpu *v);
    5.10  
     6.1 --- a/xen/include/asm-x86/hvm/vlapic.h	Tue Feb 06 23:12:59 2007 +0000
     6.2 +++ b/xen/include/asm-x86/hvm/vlapic.h	Tue Feb 06 23:14:21 2007 +0000
     6.3 @@ -78,6 +78,8 @@ int cpu_get_apic_interrupt(struct vcpu *
     6.4  int  vlapic_init(struct vcpu *v);
     6.5  void vlapic_destroy(struct vcpu *v);
     6.6  
     6.7 +void vlapic_reset(struct vlapic *vlapic);
     6.8 +
     6.9  void vlapic_msr_set(struct vlapic *vlapic, uint64_t value);
    6.10  
    6.11  int vlapic_accept_pic_intr(struct vcpu *v);