# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID b180310a0d2ce3b76ca435269c7c99da62f8beec
# Parent 2e880b1fbe84645841e3b024940150d0b5a9c09a
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@xxxxxxxxx>
diff -r 2e880b1fbe84 -r b180310a0d2c xen/arch/x86/vmx_vlapic.c
--- a/xen/arch/x86/vmx_vlapic.c Sat Nov 5 09:55:38 2005
+++ b/xen/arch/x86/vmx_vlapic.c Sat Nov 5 10:23:02 2005
@@ -659,7 +659,7 @@
vlapic->spurious_vec = val & 0x1ff;
if (!(vlapic->spurious_vec & 0x100)) {
int i = 0;
- for (i=0; i < VLAPIC_LVT_NUM; i++)
+ for (i = 0; i < VLAPIC_LVT_NUM; i++)
vlapic->lvt[i] |= 0x10000;
vlapic->status |= VLAPIC_SOFTWARE_DISABLE_MASK;
}
@@ -723,10 +723,12 @@
vlapic->timer_current = val;
vlapic->timer_current_update = NOW();
- VMX_DBG_LOG(DBG_LEVEL_VLAPIC,
- "timer_init %x timer_current %x timer_current_update %08x%08x",
- vlapic->timer_initial, vlapic->timer_current,
(uint32_t)(vlapic->timer_current_update>>32),
(uint32_t)vlapic->timer_current_update);
- vlapic_begin_timer(vlapic);
+ VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "timer_init %x timer_current %x"
+ "timer_current_update %08x%08x",
+ vlapic->timer_initial, vlapic->timer_current,
+ (uint32_t)(vlapic->timer_current_update >> 32),
+ (uint32_t)vlapic->timer_current_update);
+ vlapic_begin_timer(vlapic);
break;
case APIC_TDCR:
@@ -920,19 +922,22 @@
static int vlapic_reset(struct vlapic *vlapic)
{
- struct vcpu *v = vlapic->vcpu;
- int apic_id = v->vcpu_id, i;
-
- if (!v || !vlapic)
- return 0;
-
- memset(vlapic, 0,sizeof(struct vlapic));
-
- v->arch.arch_vmx.vlapic = vlapic;
+ struct vcpu *v;
+ int apic_id, i;
+
+ ASSERT( vlapic != NULL );
+
+ v = vlapic->vcpu;
+
+ ASSERT( v != NULL );
+
+ apic_id = v->vcpu_id;
vlapic->domain = v->domain;
vlapic->id = apic_id;
+
+ vlapic->vcpu_id = v->vcpu_id;
vlapic->version = VLAPIC_VERSION;
@@ -940,6 +945,7 @@
if (apic_id == 0)
vlapic->apic_base_msr |= MSR_IA32_APICBASE_BSP;
+
vlapic->base_address = vlapic_get_base_address(vlapic);
for (i = 0; i < VLAPIC_LVT_NUM; i++)
@@ -949,9 +955,8 @@
vlapic->spurious_vec = 0xff;
-
init_ac_timer(&vlapic->vlapic_timer,
- vlapic_timer_fn, vlapic, v->processor);
+ vlapic_timer_fn, vlapic, v->processor);
#ifdef VLAPIC_NO_BIOS
/*
@@ -966,10 +971,10 @@
#endif
VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_reset: "
- "vcpu=%p id=%d vlapic_apic_base_msr=%08x%08x "
- "vlapic_base_address=%0lx",
- v, vlapic->id, (uint32_t)(vlapic->apic_base_msr >> 32),
- (uint32_t)vlapic->apic_base_msr, vlapic->base_address);
+ "vcpu=%p id=%d vlapic_apic_base_msr=%08x%08x "
+ "vlapic_base_address=%0lx",
+ v, vlapic->id, (uint32_t)(vlapic->apic_base_msr >> 32),
+ (uint32_t)vlapic->apic_base_msr, vlapic->base_address);
return 1;
}
@@ -978,15 +983,20 @@
{
struct vlapic *vlapic = NULL;
+ ASSERT( v != NULL );
+
VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_init %d", v->vcpu_id);
vlapic = xmalloc_bytes(sizeof(struct vlapic));
-
if (!vlapic) {
printk("malloc vlapic error for vcpu %x\n", v->vcpu_id);
return -ENOMEM;
}
+ memset(vlapic, 0, sizeof(struct vlapic));
+
+ VLAPIC(v) = vlapic;
+
vlapic->vcpu = v;
vlapic_reset(vlapic);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|