ia64/xen-unstable

changeset 7633:b180310a0d2c

vlapic_init alloc memory for struct vlapic, so it should do a memset on
it, not vlapic_reset.

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Nov 05 11:23:02 2005 +0100 (2005-11-05)
parents 2e880b1fbe84
children 65c3b9382caa
files xen/arch/x86/vmx_vlapic.c
line diff
     1.1 --- a/xen/arch/x86/vmx_vlapic.c	Sat Nov 05 10:55:38 2005 +0100
     1.2 +++ b/xen/arch/x86/vmx_vlapic.c	Sat Nov 05 11:23:02 2005 +0100
     1.3 @@ -659,7 +659,7 @@ unsigned long vlapic_write(struct vcpu *
     1.4          vlapic->spurious_vec = val & 0x1ff;
     1.5          if (!(vlapic->spurious_vec & 0x100)) {
     1.6              int i = 0;
     1.7 -            for (i=0; i < VLAPIC_LVT_NUM; i++) 
     1.8 +            for (i = 0; i < VLAPIC_LVT_NUM; i++)
     1.9                  vlapic->lvt[i] |= 0x10000;
    1.10              vlapic->status |= VLAPIC_SOFTWARE_DISABLE_MASK;
    1.11          }
    1.12 @@ -723,10 +723,12 @@ unsigned long vlapic_write(struct vcpu *
    1.13          vlapic->timer_current = val;
    1.14          vlapic->timer_current_update = NOW();
    1.15  
    1.16 -        VMX_DBG_LOG(DBG_LEVEL_VLAPIC,
    1.17 -          "timer_init %x timer_current %x timer_current_update %08x%08x",
    1.18 -          vlapic->timer_initial, vlapic->timer_current, (uint32_t)(vlapic->timer_current_update>>32), (uint32_t)vlapic->timer_current_update);
    1.19 -        vlapic_begin_timer(vlapic);
    1.20 +        VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "timer_init %x timer_current %x"
    1.21 +                    "timer_current_update %08x%08x",
    1.22 +                    vlapic->timer_initial, vlapic->timer_current,
    1.23 +                    (uint32_t)(vlapic->timer_current_update >> 32),
    1.24 +                    (uint32_t)vlapic->timer_current_update);
    1.25 +                    vlapic_begin_timer(vlapic);
    1.26          break;
    1.27  
    1.28      case APIC_TDCR:
    1.29 @@ -920,26 +922,30 @@ void vlapic_post_injection(struct vcpu *
    1.30  
    1.31  static int vlapic_reset(struct vlapic *vlapic)
    1.32  {
    1.33 -    struct vcpu *v = vlapic->vcpu;
    1.34 -    int apic_id = v->vcpu_id, i;
    1.35 +    struct vcpu *v;
    1.36 +    int apic_id, i;
    1.37 +
    1.38 +    ASSERT( vlapic != NULL );
    1.39  
    1.40 -    if (!v || !vlapic)
    1.41 -        return 0;
    1.42 +    v = vlapic->vcpu;
    1.43  
    1.44 -    memset(vlapic, 0,sizeof(struct vlapic));
    1.45 +    ASSERT( v != NULL );
    1.46  
    1.47 -    v->arch.arch_vmx.vlapic = vlapic;
    1.48 +    apic_id = v->vcpu_id;
    1.49  
    1.50      vlapic->domain = v->domain;
    1.51  
    1.52      vlapic->id = apic_id;
    1.53  
    1.54 +    vlapic->vcpu_id = v->vcpu_id;
    1.55 +
    1.56      vlapic->version = VLAPIC_VERSION;
    1.57  
    1.58      vlapic->apic_base_msr = VLAPIC_BASE_MSR_INIT_VALUE;
    1.59  
    1.60      if (apic_id == 0)
    1.61          vlapic->apic_base_msr |= MSR_IA32_APICBASE_BSP;
    1.62 +
    1.63      vlapic->base_address = vlapic_get_base_address(vlapic);
    1.64  
    1.65      for (i = 0; i < VLAPIC_LVT_NUM; i++)
    1.66 @@ -949,9 +955,8 @@ static int vlapic_reset(struct vlapic *v
    1.67  
    1.68      vlapic->spurious_vec = 0xff;
    1.69  
    1.70 -
    1.71      init_ac_timer(&vlapic->vlapic_timer,
    1.72 -      vlapic_timer_fn, vlapic, v->processor);
    1.73 +                  vlapic_timer_fn, vlapic, v->processor);
    1.74  
    1.75  #ifdef VLAPIC_NO_BIOS
    1.76      /*
    1.77 @@ -966,10 +971,10 @@ static int vlapic_reset(struct vlapic *v
    1.78  #endif
    1.79  
    1.80      VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_reset: "
    1.81 -      "vcpu=%p id=%d vlapic_apic_base_msr=%08x%08x "
    1.82 -      "vlapic_base_address=%0lx",
    1.83 -      v, vlapic->id, (uint32_t)(vlapic->apic_base_msr >> 32),
    1.84 -      (uint32_t)vlapic->apic_base_msr, vlapic->base_address);
    1.85 +                "vcpu=%p id=%d vlapic_apic_base_msr=%08x%08x "
    1.86 +                "vlapic_base_address=%0lx",
    1.87 +                v, vlapic->id, (uint32_t)(vlapic->apic_base_msr >> 32),
    1.88 +                (uint32_t)vlapic->apic_base_msr, vlapic->base_address);
    1.89  
    1.90      return 1;
    1.91  }
    1.92 @@ -978,15 +983,20 @@ int vlapic_init(struct vcpu *v)
    1.93  {
    1.94      struct vlapic *vlapic = NULL;
    1.95  
    1.96 +    ASSERT( v != NULL );
    1.97 +
    1.98      VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_init %d", v->vcpu_id);
    1.99  
   1.100      vlapic = xmalloc_bytes(sizeof(struct vlapic));
   1.101 -
   1.102      if (!vlapic) {
   1.103          printk("malloc vlapic error for vcpu %x\n", v->vcpu_id);
   1.104          return -ENOMEM;
   1.105      }
   1.106  
   1.107 +    memset(vlapic, 0, sizeof(struct vlapic));
   1.108 +
   1.109 +    VLAPIC(v) = vlapic;
   1.110 +
   1.111      vlapic->vcpu = v;
   1.112  
   1.113      vlapic_reset(vlapic);