* [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses
@ 2023-11-20 15:10 Andrew Cooper
2023-11-20 16:06 ` Jan Beulich
2023-11-20 17:36 ` Roger Pau Monné
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Cooper @ 2023-11-20 15:10 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Jan Beulich, Wei Liu, Roger Pau Monné
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 <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
xen/arch/x86/io_apic.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index 0ef61fb2f167..db1ea6e2f2ca 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses
2023-11-20 15:10 [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses Andrew Cooper
@ 2023-11-20 16:06 ` Jan Beulich
2023-11-20 16:09 ` Andrew Cooper
2023-11-20 17:36 ` Roger Pau Monné
1 sibling, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2023-11-20 16:06 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Wei Liu, Roger Pau Monné, Xen-devel
On 20.11.2023 16:10, Andrew Cooper wrote:
> 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 <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
I'm curious though: Was this observed in practice?
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses
2023-11-20 16:06 ` Jan Beulich
@ 2023-11-20 16:09 ` Andrew Cooper
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cooper @ 2023-11-20 16:09 UTC (permalink / raw)
To: Jan Beulich; +Cc: Wei Liu, Roger Pau Monné, Xen-devel
On 20/11/2023 4:06 pm, Jan Beulich wrote:
> On 20.11.2023 16:10, Andrew Cooper wrote:
>> 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 <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses
2023-11-20 15:10 [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses Andrew Cooper
2023-11-20 16:06 ` Jan Beulich
@ 2023-11-20 17:36 ` Roger Pau Monné
2023-11-20 17:38 ` Andrew Cooper
1 sibling, 1 reply; 5+ messages in thread
From: Roger Pau Monné @ 2023-11-20 17:36 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Xen-devel, Jan Beulich, Wei Liu
On Mon, Nov 20, 2023 at 03:10:06PM +0000, Andrew Cooper wrote:
> 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 <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wl@xen.org>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> ---
> xen/arch/x86/io_apic.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
> index 0ef61fb2f167..db1ea6e2f2ca 100644
> --- a/xen/arch/x86/io_apic.c
> +++ b/xen/arch/x86/io_apic.c
> @@ -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:
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> {
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses
2023-11-20 17:36 ` Roger Pau Monné
@ 2023-11-20 17:38 ` Andrew Cooper
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cooper @ 2023-11-20 17:38 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: Xen-devel, Jan Beulich, Wei Liu
On 20/11/2023 5:36 pm, Roger Pau Monné wrote:
> On Mon, Nov 20, 2023 at 03:10:06PM +0000, Andrew Cooper wrote:
>> 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 <andrew.cooper3@citrix.com>
>> ---
>> CC: Jan Beulich <JBeulich@suse.com>
>> CC: Wei Liu <wl@xen.org>
>> CC: Roger Pau Monné <roger.pau@citrix.com>
>> ---
>> xen/arch/x86/io_apic.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
>> index 0ef61fb2f167..db1ea6e2f2ca 100644
>> --- a/xen/arch/x86/io_apic.c
>> +++ b/xen/arch/x86/io_apic.c
>> @@ -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()
Hmm, yeah. Will change.
> , otherwise:
>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks.
>
>> {
>> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-20 17:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-20 15:10 [PATCH] x86/ioapic: Check 1k alignment for IO-APIC physical addresses Andrew Cooper
2023-11-20 16:06 ` Jan Beulich
2023-11-20 16:09 ` Andrew Cooper
2023-11-20 17:36 ` Roger Pau Monné
2023-11-20 17:38 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.