aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-11-07 15:48:10 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-11-07 15:48:10 +0000
commit1aa6e42118517949a420f1a402e9a9cd2dad273e (patch)
tree2da0a1cae47970099574f9a996424b3ec9e3d0f7
parent25f5b0ff1569004165e5dbdf2872f4e7617a5b60 (diff)
downloadxen-1aa6e42118517949a420f1a402e9a9cd2dad273e.tar.gz
xen-1aa6e42118517949a420f1a402e9a9cd2dad273e.tar.bz2
xen-1aa6e42118517949a420f1a402e9a9cd2dad273e.zip
[HVM] VLAPIC cleanups. vlapic tsruct is statically contained
inside the vcpu structure. Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r--xen/arch/x86/hvm/svm/svm.c17
-rw-r--r--xen/arch/x86/hvm/vioapic.c5
-rw-r--r--xen/arch/x86/hvm/vlapic.c116
-rw-r--r--xen/arch/x86/hvm/vmx/io.c4
-rw-r--r--xen/arch/x86/hvm/vmx/vmx.c21
-rw-r--r--xen/include/asm-x86/hvm/vcpu.h2
-rw-r--r--xen/include/asm-x86/hvm/vlapic.h7
7 files changed, 64 insertions, 108 deletions
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index ef9a9f1aaa..3e8c8cecae 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -855,8 +855,7 @@ static void svm_migrate_timers(struct vcpu *v)
migrate_timer(&pt->timer, v->processor);
migrate_timer(&v->arch.hvm_vcpu.hlt_timer, v->processor);
}
- if ( VLAPIC(v) != NULL )
- migrate_timer(&VLAPIC(v)->vlapic_timer, v->processor);
+ migrate_timer(&vcpu_vlapic(v)->vlapic_timer, v->processor);
migrate_timer(&vrtc->second_timer, v->processor);
migrate_timer(&vrtc->second_timer2, v->processor);
migrate_timer(&vpmt->timer, v->processor);
@@ -984,7 +983,7 @@ static void svm_vmexit_do_cpuid(struct vmcb_struct *vmcb, unsigned long input,
cpuid(input, &eax, &ebx, &ecx, &edx);
if (input == 0x00000001 || input == 0x80000001 )
{
- if ( !vlapic_global_enabled((VLAPIC(v))) )
+ if ( !vlapic_global_enabled(vcpu_vlapic(v)) )
{
/* Since the apic is disabled, avoid any confusion
about SMP cpus being available */
@@ -1550,7 +1549,7 @@ static void mov_from_cr(int cr, int gp, struct cpu_user_regs *regs)
{
unsigned long value = 0;
struct vcpu *v = current;
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
struct vmcb_struct *vmcb;
vmcb = v->arch.hvm_svm.vmcb;
@@ -1577,8 +1576,6 @@ static void mov_from_cr(int cr, int gp, struct cpu_user_regs *regs)
printk("CR4 read=%lx\n", value);
break;
case 8:
- if ( vlapic == NULL )
- break;
value = (unsigned long)vlapic_get_reg(vlapic, APIC_TASKPRI);
value = (value & 0xF0) >> 4;
break;
@@ -1607,7 +1604,7 @@ static int mov_to_cr(int gpreg, int cr, struct cpu_user_regs *regs)
unsigned long value;
unsigned long old_cr;
struct vcpu *v = current;
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
ASSERT(vmcb);
@@ -1747,8 +1744,6 @@ static int mov_to_cr(int gpreg, int cr, struct cpu_user_regs *regs)
case 8:
{
- if ( vlapic == NULL )
- break;
vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
break;
}
@@ -1907,7 +1902,7 @@ static inline void svm_do_msr_access(
msr_content = vmcb->sysenter_eip;
break;
case MSR_IA32_APICBASE:
- msr_content = VLAPIC(v) ? VLAPIC(v)->apic_base_msr : 0;
+ msr_content = vcpu_vlapic(v)->apic_base_msr;
break;
default:
if (long_mode_do_msr_read(regs))
@@ -1946,7 +1941,7 @@ static inline void svm_do_msr_access(
vmcb->sysenter_eip = msr_content;
break;
case MSR_IA32_APICBASE:
- vlapic_msr_set(VLAPIC(v), msr_content);
+ vlapic_msr_set(vcpu_vlapic(v), msr_content);
break;
default:
if ( !long_mode_do_msr_write(regs) )
diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index d470475f55..5b88280e9d 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -430,7 +430,6 @@ static void ioapic_deliver(hvm_vioapic_t *s, int irqno)
uint32_t deliver_bitmask;
struct vlapic *target;
-
HVM_DBG_LOG(DBG_LEVEL_IOAPIC,
"dest %x dest_mode %x delivery_mode %x vector %x trig_mode %x\n",
dest, dest_mode, delivery_mode, vector, trig_mode);
@@ -458,7 +457,7 @@ static void ioapic_deliver(hvm_vioapic_t *s, int irqno)
vector, deliver_bitmask);
if (target) {
ioapic_inj_irq(s, target, vector, trig_mode, delivery_mode);
- vcpu_kick(target->vcpu);
+ vcpu_kick(vlapic_vcpu(target));
} else
HVM_DBG_LOG(DBG_LEVEL_IOAPIC,
"null round robin mask %x vector %x delivery_mode %x\n",
@@ -482,7 +481,7 @@ static void ioapic_deliver(hvm_vioapic_t *s, int irqno)
target = s->lapic_info[bit];
if (target) {
ioapic_inj_irq(s, target, vector, trig_mode, delivery_mode);
- vcpu_kick(target->vcpu);
+ vcpu_kick(vlapic_vcpu(target));
}
}
break;
diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 5524dd7036..e1f477fce0 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -157,7 +157,7 @@ int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig)
s_time_t get_apictime_scheduled(struct vcpu *v)
{
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
if ( !vlapic_lvt_enabled(vlapic, APIC_LVTT) )
return -1;
@@ -202,7 +202,7 @@ static int vlapic_match_dest(struct vcpu *v, struct vlapic *source,
int delivery_mode)
{
int result = 0;
- struct vlapic *target = VLAPIC(v);
+ struct vlapic *target = vcpu_vlapic(v);
HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "target %p, source %p, dest 0x%x, "
"dest_mode 0x%x, short_hand 0x%x, delivery_mode 0x%x.",
@@ -285,7 +285,7 @@ static int vlapic_accept_irq(struct vcpu *v, int delivery_mode,
int vector, int level, int trig_mode)
{
int result = 0;
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
switch ( delivery_mode ) {
case APIC_DM_FIXED:
@@ -404,8 +404,7 @@ struct vlapic *apic_round_robin(struct domain *d,
if ( test_bit(next, &bitmap) )
{
- target = d->vcpu[next]->arch.hvm_vcpu.vlapic;
-
+ target = vcpu_vlapic(d->vcpu[next]);
if ( target == NULL || !vlapic_enabled(target) )
{
printk("warning: targe round robin local apic disabled\n");
@@ -433,7 +432,7 @@ void vlapic_EOI_set(struct vlapic *vlapic)
vlapic_clear_vector(vector, vlapic->regs + APIC_ISR);
if ( vlapic_test_and_clear_vector(vector, vlapic->regs + APIC_TMR) )
- ioapic_update_EOI(vlapic->domain, vector);
+ ioapic_update_EOI(vlapic_domain(vlapic), vector);
}
static void vlapic_ipi(struct vlapic *vlapic)
@@ -446,12 +445,12 @@ static void vlapic_ipi(struct vlapic *vlapic)
unsigned int trig_mode = icr_low & APIC_INT_LEVELTRIG;
unsigned int level = icr_low & APIC_INT_ASSERT;
unsigned int dest_mode = icr_low & APIC_DEST_MASK;
- unsigned int delivery_mode = icr_low & APIC_MODE_MASK;
+ unsigned int delivery_mode =icr_low & APIC_MODE_MASK;
unsigned int vector = icr_low & APIC_VECTOR_MASK;
struct vlapic *target;
- struct vcpu *v = NULL;
- uint32_t lpr_map=0;
+ struct vcpu *v;
+ uint32_t lpr_map = 0;
HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "icr_high 0x%x, icr_low 0x%x, "
"short_hand 0x%x, dest 0x%x, trig_mode 0x%x, level 0x%x, "
@@ -459,7 +458,7 @@ static void vlapic_ipi(struct vlapic *vlapic)
icr_high, icr_low, short_hand, dest,
trig_mode, level, dest_mode, delivery_mode, vector);
- for_each_vcpu ( vlapic->domain, v )
+ for_each_vcpu ( vlapic_domain(vlapic), v )
{
if ( vlapic_match_dest(v, vlapic, short_hand,
dest, dest_mode, delivery_mode) )
@@ -474,11 +473,10 @@ static void vlapic_ipi(struct vlapic *vlapic)
if ( delivery_mode == APIC_DM_LOWEST)
{
- v = vlapic->vcpu;
- target = apic_round_robin(v->domain, dest_mode, vector, lpr_map);
-
- if ( target )
- vlapic_accept_irq(target->vcpu, delivery_mode,
+ target = apic_round_robin(vlapic_domain(v), dest_mode,
+ vector, lpr_map);
+ if ( target != NULL )
+ vlapic_accept_irq(vlapic_vcpu(target), delivery_mode,
vector, level, trig_mode);
}
}
@@ -489,8 +487,6 @@ static uint32_t vlapic_get_tmcct(struct vlapic *vlapic)
s_time_t passed, now = NOW();
uint32_t tmcct = vlapic_get_reg(vlapic, APIC_TMCCT);
- ASSERT(vlapic != NULL);
-
if ( unlikely(now <= vlapic->timer_last_update) )
{
passed = ~0x0LL - vlapic->timer_last_update + now;
@@ -564,7 +560,7 @@ static unsigned long vlapic_read(struct vcpu *v, unsigned long address,
unsigned int alignment;
unsigned int tmp;
unsigned long result;
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
unsigned int offset = address - vlapic->base_address;
if ( offset > APIC_TDCR)
@@ -609,7 +605,7 @@ static unsigned long vlapic_read(struct vcpu *v, unsigned long address,
static void vlapic_write(struct vcpu *v, unsigned long address,
unsigned long len, unsigned long val)
{
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
unsigned int offset = address - vlapic->base_address;
if ( offset != 0xb0 )
@@ -741,7 +737,7 @@ static void vlapic_write(struct vcpu *v, unsigned long address,
vlapic_set_reg(vlapic, offset, val);
- if ( !vlapic->vcpu->vcpu_id && (offset == APIC_LVT0) )
+ if ( (vlapic_vcpu(vlapic)->vcpu_id == 0) && (offset == APIC_LVT0) )
{
if ( (val & APIC_MODE_MASK) == APIC_DM_EXTINT )
if ( val & APIC_LVT_MASKED)
@@ -803,7 +799,7 @@ static void vlapic_write(struct vcpu *v, unsigned long address,
static int vlapic_range(struct vcpu *v, unsigned long addr)
{
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
return (vlapic_global_enabled(vlapic) &&
(addr >= vlapic->base_address) &&
@@ -818,12 +814,6 @@ struct hvm_mmio_handler vlapic_mmio_handler = {
void vlapic_msr_set(struct vlapic *vlapic, uint64_t value)
{
- if ( vlapic == NULL )
- return;
-
- if ( vlapic->vcpu->vcpu_id )
- value &= ~MSR_IA32_APICBASE_BSP;
-
vlapic->apic_base_msr = value;
vlapic->base_address = vlapic->apic_base_msr & MSR_IA32_APICBASE_BASE;
@@ -840,7 +830,6 @@ void vlapic_msr_set(struct vlapic *vlapic, uint64_t value)
void vlapic_timer_fn(void *data)
{
struct vlapic *vlapic = data;
- struct vcpu *v;
uint32_t timer_vector;
s_time_t now;
@@ -848,7 +837,6 @@ void vlapic_timer_fn(void *data)
!vlapic_lvt_enabled(vlapic, APIC_LVTT)) )
return;
- v = vlapic->vcpu;
timer_vector = vlapic_lvt_vector(vlapic, APIC_LVTT);
now = NOW();
@@ -882,14 +870,14 @@ void vlapic_timer_fn(void *data)
int vlapic_accept_pic_intr(struct vcpu *v)
{
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
return vlapic ? test_bit(_VLAPIC_BSP_ACCEPT_PIC, &vlapic->status) : 1;
}
int cpu_get_apic_interrupt(struct vcpu *v, int *mode)
{
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
int highest_irr;
if ( !vlapic || !vlapic_enabled(vlapic) )
@@ -923,7 +911,7 @@ int cpu_has_pending_irq(struct vcpu *v)
void vlapic_post_injection(struct vcpu *v, int vector, int deliver_mode)
{
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
if ( unlikely(vlapic == NULL) )
return;
@@ -961,11 +949,9 @@ void vlapic_post_injection(struct vcpu *v, int vector, int deliver_mode)
static int vlapic_reset(struct vlapic *vlapic)
{
- struct vcpu *v = vlapic->vcpu;
+ struct vcpu *v = vlapic_vcpu(vlapic);
int i;
- vlapic->domain = v->domain;
-
vlapic_set_reg(vlapic, APIC_ID, v->vcpu_id << 24);
vlapic_set_reg(vlapic, APIC_LVR, VLAPIC_VERSION);
@@ -981,30 +967,9 @@ static int vlapic_reset(struct vlapic *vlapic)
vlapic->flush_tpr_threshold = 0;
- if ( v->vcpu_id == 0 )
- vlapic->apic_base_msr |= MSR_IA32_APICBASE_BSP;
-
vlapic->base_address = vlapic->apic_base_msr &
MSR_IA32_APICBASE_BASE;
- hvm_vioapic_add_lapic(vlapic, v);
-
- init_timer(&vlapic->vlapic_timer,
- vlapic_timer_fn, vlapic, v->processor);
-
-#ifdef VLAPIC_NO_BIOS
- /*
- * XXX According to mp sepcific, BIOS will enable LVT0/1,
- * remove it after BIOS enabled
- */
- if ( !v->vcpu_id )
- {
- vlapic_set_reg(vlapic, APIC_LVT0, APIC_MODE_EXTINT << 8);
- vlapic_set_reg(vlapic, APIC_LVT1, APIC_MODE_NMI << 8);
- set_bit(_VLAPIC_BSP_ACCEPT_PIC, &vlapic->status);
- }
-#endif
-
HVM_DBG_LOG(DBG_LEVEL_VLAPIC,
"vcpu=%p, id=%d, vlapic_apic_base_msr=0x%016"PRIx64", "
"base_address=0x%0lx.",
@@ -1016,19 +981,10 @@ static int vlapic_reset(struct vlapic *vlapic)
int vlapic_init(struct vcpu *v)
{
- struct vlapic *vlapic;
+ struct vlapic *vlapic = vcpu_vlapic(v);
HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_init %d", v->vcpu_id);
- vlapic = xmalloc_bytes(sizeof(struct vlapic));
- if ( vlapic == NULL )
- {
- printk("malloc vlapic error for vcpu %x\n", v->vcpu_id);
- return -ENOMEM;
- }
-
- memset(vlapic, 0, sizeof(struct vlapic));
-
vlapic->regs_page = alloc_domheap_page(NULL);
if ( vlapic->regs_page == NULL )
{
@@ -1040,22 +996,32 @@ int vlapic_init(struct vcpu *v)
vlapic->regs = map_domain_page_global(page_to_mfn(vlapic->regs_page));
memset(vlapic->regs, 0, PAGE_SIZE);
- VLAPIC(v) = vlapic;
- vlapic->vcpu = v;
-
vlapic_reset(vlapic);
+ if ( v->vcpu_id == 0 )
+ vlapic->apic_base_msr |= MSR_IA32_APICBASE_BSP;
+
+ hvm_vioapic_add_lapic(vlapic, v);
+
+ init_timer(&vlapic->vlapic_timer,
+ vlapic_timer_fn, vlapic, v->processor);
+
+#ifdef VLAPIC_NO_BIOS
+ /* According to mp specification, BIOS will enable LVT0/1. */
+ if ( v->vcpu_id == 0 )
+ {
+ vlapic_set_reg(vlapic, APIC_LVT0, APIC_MODE_EXTINT << 8);
+ vlapic_set_reg(vlapic, APIC_LVT1, APIC_MODE_NMI << 8);
+ set_bit(_VLAPIC_BSP_ACCEPT_PIC, &vlapic->status);
+ }
+#endif
+
return 0;
}
void vlapic_destroy(struct vcpu *v)
{
- struct vlapic *vlapic = VLAPIC(v);
-
- if ( vlapic == NULL )
- return;
-
- VLAPIC(v) = NULL;
+ struct vlapic *vlapic = vcpu_vlapic(v);
kill_timer(&vlapic->vlapic_timer);
unmap_domain_page_global(vlapic->regs);
diff --git a/xen/arch/x86/hvm/vmx/io.c b/xen/arch/x86/hvm/vmx/io.c
index fa250a009c..0c939d73ce 100644
--- a/xen/arch/x86/hvm/vmx/io.c
+++ b/xen/arch/x86/hvm/vmx/io.c
@@ -96,7 +96,7 @@ asmlinkage void vmx_intr_assist(void)
int highest_vector;
unsigned long eflags;
struct vcpu *v = current;
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
struct hvm_domain *plat=&v->domain->arch.hvm_domain;
struct periodic_time *pt = &plat->pl_time.periodic_tm;
struct hvm_virpic *pic= &plat->vpic;
@@ -117,7 +117,7 @@ asmlinkage void vmx_intr_assist(void)
pic_set_xen_irq(pic, callback_irq, local_events_need_delivery());
}
- if ( vlapic && vlapic_enabled(vlapic) && vlapic->flush_tpr_threshold )
+ if ( vlapic_enabled(vlapic) && vlapic->flush_tpr_threshold )
update_tpr_threshold(vlapic);
has_ext_irq = cpu_has_pending_irq(v);
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 06c0ca71b8..84febc6b1a 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -408,7 +408,7 @@ static void stop_vmx(void)
void vmx_migrate_timers(struct vcpu *v)
{
- struct periodic_time *pt = &(v->domain->arch.hvm_domain.pl_time.periodic_tm);
+ struct periodic_time *pt = &v->domain->arch.hvm_domain.pl_time.periodic_tm;
struct RTCState *vrtc = &v->domain->arch.hvm_domain.pl_time.vrtc;
struct PMTState *vpmt = &v->domain->arch.hvm_domain.pl_time.vpmt;
@@ -417,8 +417,7 @@ void vmx_migrate_timers(struct vcpu *v)
migrate_timer(&pt->timer, v->processor);
migrate_timer(&v->arch.hvm_vcpu.hlt_timer, v->processor);
}
- if ( VLAPIC(v) != NULL )
- migrate_timer(&VLAPIC(v)->vlapic_timer, v->processor);
+ migrate_timer(&vcpu_vlapic(v)->vlapic_timer, v->processor);
migrate_timer(&vrtc->second_timer, v->processor);
migrate_timer(&vrtc->second_timer2, v->processor);
migrate_timer(&vpmt->timer, v->processor);
@@ -853,7 +852,7 @@ static void vmx_do_cpuid(struct cpu_user_regs *regs)
/* Mask off reserved bits. */
ecx &= ~VMX_VCPU_CPUID_L1_ECX_RESERVED;
- if ( !vlapic_global_enabled((VLAPIC(v))) )
+ if ( !vlapic_global_enabled(vcpu_vlapic(v)) )
clear_bit(X86_FEATURE_APIC, &edx);
#if CONFIG_PAGING_LEVELS >= 3
@@ -1559,7 +1558,7 @@ static int mov_to_cr(int gp, int cr, struct cpu_user_regs *regs)
unsigned long value;
unsigned long old_cr;
struct vcpu *v = current;
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
switch ( gp ) {
CASE_GET_REG(EAX, eax);
@@ -1705,8 +1704,6 @@ static int mov_to_cr(int gp, int cr, struct cpu_user_regs *regs)
}
case 8:
{
- if ( vlapic == NULL )
- break;
vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
break;
}
@@ -1725,7 +1722,7 @@ static void mov_from_cr(int cr, int gp, struct cpu_user_regs *regs)
{
unsigned long value = 0;
struct vcpu *v = current;
- struct vlapic *vlapic = VLAPIC(v);
+ struct vlapic *vlapic = vcpu_vlapic(v);
switch ( cr )
{
@@ -1733,8 +1730,6 @@ static void mov_from_cr(int cr, int gp, struct cpu_user_regs *regs)
value = (unsigned long)v->arch.hvm_vmx.cpu_cr3;
break;
case 8:
- if ( vlapic == NULL )
- break;
value = (unsigned long)vlapic_get_reg(vlapic, APIC_TASKPRI);
value = (value & 0xF0) >> 4;
break;
@@ -1835,7 +1830,7 @@ static inline void vmx_do_msr_read(struct cpu_user_regs *regs)
__vmread(GUEST_SYSENTER_EIP, &msr_content);
break;
case MSR_IA32_APICBASE:
- msr_content = VLAPIC(v) ? VLAPIC(v)->apic_base_msr : 0;
+ msr_content = vcpu_vlapic(v)->apic_base_msr;
break;
default:
if (long_mode_do_msr_read(regs))
@@ -1892,7 +1887,7 @@ static inline void vmx_do_msr_write(struct cpu_user_regs *regs)
__vmwrite(GUEST_SYSENTER_EIP, msr_content);
break;
case MSR_IA32_APICBASE:
- vlapic_msr_set(VLAPIC(v), msr_content);
+ vlapic_msr_set(vcpu_vlapic(v), msr_content);
break;
default:
if ( !long_mode_do_msr_write(regs) )
@@ -2307,7 +2302,7 @@ asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
break;
case EXIT_REASON_TPR_BELOW_THRESHOLD:
- VLAPIC(v)->flush_tpr_threshold = 1;
+ vcpu_vlapic(v)->flush_tpr_threshold = 1;
break;
default:
diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h
index 8945916d32..990562cd71 100644
--- a/xen/include/asm-x86/hvm/vcpu.h
+++ b/xen/include/asm-x86/hvm/vcpu.h
@@ -32,7 +32,7 @@ struct hvm_vcpu {
unsigned long hw_cr3; /* value we give to HW to use */
unsigned long ioflags;
struct hvm_io_op io_op;
- struct vlapic *vlapic;
+ struct vlapic vlapic;
s64 cache_tsc_offset;
u64 guest_time;
diff --git a/xen/include/asm-x86/hvm/vlapic.h b/xen/include/asm-x86/hvm/vlapic.h
index b53c9e149b..ed23916649 100644
--- a/xen/include/asm-x86/hvm/vlapic.h
+++ b/xen/include/asm-x86/hvm/vlapic.h
@@ -25,7 +25,10 @@
#define MAX_VECTOR 256
-#define VLAPIC(v) (v->arch.hvm_vcpu.vlapic)
+#define vcpu_vlapic(vcpu) (&(vcpu)->arch.hvm_vcpu.vlapic)
+#define vlapic_vcpu(vpic) (container_of((vpic), struct vcpu, \
+ arch.hvm_vcpu.vlapic))
+#define vlapic_domain(vpic) (vlapic_vcpu(vlapic)->domain)
#define VLAPIC_ID(vlapic) \
(GET_APIC_ID(vlapic_get_reg(vlapic, APIC_ID)))
@@ -51,8 +54,6 @@ struct vlapic {
int timer_pending_count;
int flush_tpr_threshold;
s_time_t timer_last_update;
- struct vcpu *vcpu;
- struct domain *domain;
struct page_info *regs_page;
void *regs;
};