diff --git a/hypervisor/arch/x86/guest/vlapic.c b/hypervisor/arch/x86/guest/vlapic.c index 567270f78..6cc16174a 100644 --- a/hypervisor/arch/x86/guest/vlapic.c +++ b/hypervisor/arch/x86/guest/vlapic.c @@ -169,19 +169,21 @@ static inline uint32_t vlapic_build_id(struct acrn_vlapic *vlapic) { struct vcpu *vcpu = vlapic->vcpu; - uint16_t id; + uint8_t vlapic_id; + uint32_t lapic_regs_id; if (is_vm0(vcpu->vm)) { /* Get APIC ID sequence format from cpu_storage */ - id = per_cpu(lapic_id, vcpu->vcpu_id); + vlapic_id = per_cpu(lapic_id, vcpu->vcpu_id); } else { - id = vcpu->vcpu_id; + vlapic_id = (uint8_t)vcpu->vcpu_id; } - dev_dbg(ACRN_DBG_LAPIC, "vlapic APIC PAGE ID : 0x%08x", - (id << APIC_ID_SHIFT)); + lapic_regs_id = vlapic_id << APIC_ID_SHIFT; - return (id << APIC_ID_SHIFT); + dev_dbg(ACRN_DBG_LAPIC, "vlapic APIC PAGE ID : 0x%08x", lapic_regs_id); + + return lapic_regs_id; } static void diff --git a/hypervisor/arch/x86/lapic.c b/hypervisor/arch/x86/lapic.c index aa35e0ae4..6c7752c91 100644 --- a/hypervisor/arch/x86/lapic.c +++ b/hypervisor/arch/x86/lapic.c @@ -209,6 +209,9 @@ void early_init_lapic(void) } } +/** + * @pre pcpu_id < 8U + */ void init_lapic(uint16_t pcpu_id) { /* Set the Logical Destination Register */