From 85688075ccc22c12bd0fca2a2c269199938e104c Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 21 Feb 2018 18:10:00 +0000 Subject: [PATCH] x86/hvm: Constify the read side of vlapic handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is in preparation to make hvm_x2apic_msr_read() take a const vcpu pointer. One modification is to alter vlapic_get_tmcct() to not use current. This in turn needs an alteration to hvm_get_guest_time_fixed(), which is safe because the only mutable action it makes is to take the domain plt lock. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné Reviewed-by: Jan Beulich --- xen/arch/x86/hvm/vlapic.c | 13 +++++++------ xen/arch/x86/hvm/vpt.c | 2 +- xen/include/asm-x86/hvm/hvm.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 7387f91fe0..e715729f77 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -171,12 +171,12 @@ void vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig) vcpu_kick(target); } -static int vlapic_find_highest_isr(struct vlapic *vlapic) +static int vlapic_find_highest_isr(const struct vlapic *vlapic) { return vlapic_find_highest_vector(&vlapic->regs->data[APIC_ISR]); } -static uint32_t vlapic_get_ppr(struct vlapic *vlapic) +static uint32_t vlapic_get_ppr(const struct vlapic *vlapic) { uint32_t tpr, isrv, ppr; int isr; @@ -550,9 +550,9 @@ void vlapic_ipi( } } -static uint32_t vlapic_get_tmcct(struct vlapic *vlapic) +static uint32_t vlapic_get_tmcct(const struct vlapic *vlapic) { - struct vcpu *v = current; + const struct vcpu *v = const_vlapic_vcpu(vlapic); uint32_t tmcct = 0, tmict = vlapic_get_reg(vlapic, APIC_TMICT); uint64_t counter_passed; @@ -590,7 +590,8 @@ static void vlapic_set_tdcr(struct vlapic *vlapic, unsigned int val) "timer_divisor: %d", vlapic->hw.timer_divisor); } -static uint32_t vlapic_read_aligned(struct vlapic *vlapic, unsigned int offset) +static uint32_t vlapic_read_aligned(const struct vlapic *vlapic, + unsigned int offset) { switch ( offset ) { @@ -680,7 +681,7 @@ int hvm_x2apic_msr_read(struct vcpu *v, unsigned int msr, uint64_t *msr_content) REGBLOCK(ISR) | REGBLOCK(TMR) | REGBLOCK(IRR) #undef REGBLOCK }; - struct vlapic *vlapic = vcpu_vlapic(v); + const struct vlapic *vlapic = vcpu_vlapic(v); uint32_t high = 0, reg = msr - MSR_IA32_APICBASE_MSR, offset = reg << 4; if ( !vlapic_x2apic_mode(vlapic) || diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 181f4cb631..9d27b483b2 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -35,7 +35,7 @@ void hvm_init_guest_time(struct domain *d) pl->last_guest_time = 0; } -u64 hvm_get_guest_time_fixed(struct vcpu *v, u64 at_tsc) +uint64_t hvm_get_guest_time_fixed(const struct vcpu *v, uint64_t at_tsc) { struct pl_time *pl = v->domain->arch.hvm_domain.pl_time; u64 now; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index ca3a3343fd..9aa6c72d9d 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -273,7 +273,7 @@ u64 hvm_get_tsc_scaling_ratio(u32 gtsc_khz); void hvm_init_guest_time(struct domain *d); void hvm_set_guest_time(struct vcpu *v, u64 guest_time); -u64 hvm_get_guest_time_fixed(struct vcpu *v, u64 at_tsc); +uint64_t hvm_get_guest_time_fixed(const struct vcpu *v, uint64_t at_tsc); #define hvm_get_guest_time(v) hvm_get_guest_time_fixed(v, 0) int vmsi_deliver( -- 2.39.5