x86/ioapic: Check 1k alignment for IO-APIC physical addresses
PATCH 1/1 x86/ioapic: Check 1k alignment for IO-APIC physical addresses
The MP spec requires a minimum of 1k alignment. So too does Xen's use of a single fixmap page to map the IO-APIC.
Reject out-of-spec values so we don't end up in a position where a bad firmware value causes Xen to use the wrong mapping.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/io_apic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
xen/arch/x86/io_apic.c +3 -2
@@ -2589,10 +2589,11 @@ static void __init ioapic_init_mappings(void)union IO_APIC_reg_01 reg_01;paddr_t ioapic_phys = mp_ioapics[i].mpc_apicaddr; -if ( !ioapic_phys ) +if ( !ioapic_phys || (ioapic_phys & (KB (1 ) -1 )) ) {printk (KERN_ERR -"WARNING: bogus zero IO-APIC address found in MPTABLE, disabling IO/APIC support!\n" ); +"WARNING: bogus IO-APIC address %08lx found in MPTABLE, disabling IO/APIC support!\n" , + ioapic_phys); smp_found_config = false; skip_ioapic_setup = true;break ;
Signature · 1 line
2.30.2
Quoted 7 lines · Andrew Cooper
The MP spec requires a minimum of 1k alignment. So too does Xen's use of a single fixmap page to map the IO-APIC.
Reject out-of-spec values so we don't end up in a position where a bad firmware value causes Xen to use the wrong mapping.
Signed-off-by Andrew Cooper <[email protected]>
I'm curious though: Was this observed in practice?
Jan
Quoted 11 lines · Jan Beulich
Quoted 7 lines · Andrew Cooper
The MP spec requires a minimum of 1k alignment. So too does Xen's use of a single fixmap page to map the IO-APIC.
Reject out-of-spec values so we don't end up in a position where a bad firmware value causes Xen to use the wrong mapping.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>I'm curious though: Was this observed in practice?
No. I had some prototype cleanup which collided with MISRA, and I realised I hadn't posted this part of the series.
The other part of the cleanup still has work to do, and I don't have time to unpick it right now.
~Andrew
Quoted 20 lines · Andrew Cooper
The MP spec requires a minimum of 1k alignment. So too does Xen's use of a single fixmap page to map the IO-APIC.
Reject out-of-spec values so we don't end up in a position where a bad firmware value causes Xen to use the wrong mapping.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>--- xen/arch/x86/io_apic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)xen/arch/x86/io_apic.c +0
-0
xen/arch/x86/io_apic.c static void __init ioapic_init_mappings(void) · line 2592
Quoted 5 lines
xen/arch/x86/io_apic.c +1
-1@@ -2589,10 +2589,11 @@ static void __init ioapic_init_mappings(void)union IO_APIC_reg_01 reg_01;paddr_t ioapic_phys = mp_ioapics[i].mpc_apicaddr; -if ( !ioapic_phys ) +if ( !ioapic_phys || (ioapic_phys & (KB (1 ) -1 )) )
Might be clearer to use !IS_ALIGNED(), otherwise:
xen/arch/x86/io_apic.c static void __init ioapic_init_mappings(void) · line 2595
Quoted 4 lines
xen/arch/x86/io_apic.c +1
-1{ printk(KERN_ERR -"WARNING: bogus zero IO-APIC address found in MPTABLE, disabling IO/APIC support!\n" ); + "WARNING: bogus IO-APIC address %08lx found in MPTABLE, disabling IO/APIC support!\n",
FWIW, I think the '!' at the end is not useful, and I would adjust the last 'IO/APIC' to 'IO-APIC' if already modifying the line.
Thanks, Roger.
Quoted 24 lines · Roger Pau Monné
Quoted 23 lines · Andrew Cooper
The MP spec requires a minimum of 1k alignment. So too does Xen's use of a single fixmap page to map the IO-APIC.
Reject out-of-spec values so we don't end up in a position where a bad firmware value causes Xen to use the wrong mapping.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>--- xen/arch/x86/io_apic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)xen/arch/x86/io_apic.c +0
-0@@ -2589,10 +2589,11 @@ static void __init ioapic_init_mappings(void)union IO_APIC_reg_01 reg_01;paddr_t ioapic_phys = mp_ioapics[i].mpc_apicaddr;
Quoted 3 lines
xen/arch/x86/io_apic.c static void __init ioapic_init_mappings(void) · line 2592
Quoted 2 lines
xen/arch/x86/io_apic.c +1
-1-if ( !ioapic_phys ) +if ( !ioapic_phys || (ioapic_phys & (KB (1 ) -1 )) )Might be clearer to use !IS_ALIGNED()
Hmm, yeah. Will change.
Quoted 3 lines
, otherwise:
Reviewed-by Roger Pau Monné <[email protected]>
Thanks.
Quoted 7 lines
xen/arch/x86/io_apic.c static void __init ioapic_init_mappings(void) · line 2595
Quoted 5 lines
xen/arch/x86/io_apic.c +1
-1{ printk(KERN_ERR -"WARNING: bogus zero IO-APIC address found in MPTABLE, disabling IO/APIC support!\n" ); + "WARNING: bogus IO-APIC address %08lx found in MPTABLE, disabling IO/APIC support!\n",FWIW, I think the '!' at the end is not useful, and I would adjust the last 'IO/APIC' to 'IO-APIC' if already modifying the line.
Ok. will do.
~Andrew