drivers: ioapic: fix the cast for the offset

The cast for the offset variable will make incorrect register
access when it is over 0x80. Change the char cast to unsigned
char to fix it.

Fixes #49803.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
This commit is contained in:
Enjia Mai 2022-09-19 13:27:01 +08:00 committed by Carles Cufí
commit 24f989cd90

View file

@ -438,7 +438,7 @@ static uint32_t __IoApicGet(int32_t offset)
key = irq_lock();
*((volatile uint32_t *) (IOAPIC_REG + IOAPIC_IND)) = (char)offset;
*((volatile uint32_t *) (IOAPIC_REG + IOAPIC_IND)) = (unsigned char)offset;
value = *((volatile uint32_t *)(IOAPIC_REG + IOAPIC_DATA));
irq_unlock(key);
@ -463,7 +463,7 @@ static void __IoApicSet(int32_t offset, uint32_t value)
key = irq_lock();
*(volatile uint32_t *)(IOAPIC_REG + IOAPIC_IND) = (char)offset;
*(volatile uint32_t *)(IOAPIC_REG + IOAPIC_IND) = (unsigned char)offset;
*((volatile uint32_t *)(IOAPIC_REG + IOAPIC_DATA)) = value;
irq_unlock(key);