diff mbox series

[v3,3/4] x86/smp: check APIC ID on AP bringup

Message ID 20191204162025.37510-4-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series x86: enable x2APIC mode regardless of interrupt remapping support | expand

Commit Message

Roger Pau Monné Dec. 4, 2019, 4:20 p.m. UTC
Check that the processor to be woken up APIC ID is addressable in the
current APIC mode.

Note that in practice systems with APIC IDs > 255 should already have
x2APIC enabled by the firmware, and hence this is mostly a safety
belt.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v2:
 - Reword error message.
---
 xen/arch/x86/smpboot.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jan Beulich Dec. 5, 2019, 9:33 a.m. UTC | #1
On 04.12.2019 17:20, Roger Pau Monne wrote:
> Check that the processor to be woken up APIC ID is addressable in the
> current APIC mode.
> 
> Note that in practice systems with APIC IDs > 255 should already have
> x2APIC enabled by the firmware, and hence this is mostly a safety
> belt.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with ...

> --- a/xen/arch/x86/smpboot.c
> +++ b/xen/arch/x86/smpboot.c
> @@ -1317,6 +1317,13 @@ int __cpu_up(unsigned int cpu)
>      if ( (apicid = x86_cpu_to_apicid[cpu]) == BAD_APICID )
>          return -ENODEV;
>  
> +    if ( (!x2apic_enabled || !iommu_intremap) && (apicid >> 8) )
> +    {
> +        printk("Unsupported: APIC ID %#x in xAPIC mode w/o interrupt remapping",
> +               apicid);

... the lost newline added back (can be done while commiting).

Jan
Roger Pau Monné Dec. 9, 2019, 10:27 a.m. UTC | #2
On Thu, Dec 05, 2019 at 10:33:44AM +0100, Jan Beulich wrote:
> On 04.12.2019 17:20, Roger Pau Monne wrote:
> > Check that the processor to be woken up APIC ID is addressable in the
> > current APIC mode.
> > 
> > Note that in practice systems with APIC IDs > 255 should already have
> > x2APIC enabled by the firmware, and hence this is mostly a safety
> > belt.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> with ...
> 
> > --- a/xen/arch/x86/smpboot.c
> > +++ b/xen/arch/x86/smpboot.c
> > @@ -1317,6 +1317,13 @@ int __cpu_up(unsigned int cpu)
> >      if ( (apicid = x86_cpu_to_apicid[cpu]) == BAD_APICID )
> >          return -ENODEV;
> >  
> > +    if ( (!x2apic_enabled || !iommu_intremap) && (apicid >> 8) )
> > +    {
> > +        printk("Unsupported: APIC ID %#x in xAPIC mode w/o interrupt remapping",
> > +               apicid);
> 
> ... the lost newline added back (can be done while commiting).

Sorry for dropping it, please add it at commit.

Thanks, Roger.
Jan Beulich Dec. 20, 2019, 3:17 p.m. UTC | #3
On 04.12.2019 17:20, Roger Pau Monne wrote:
> Check that the processor to be woken up APIC ID is addressable in the
> current APIC mode.
> 
> Note that in practice systems with APIC IDs > 255 should already have
> x2APIC enabled by the firmware, and hence this is mostly a safety
> belt.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Changes since v2:
>  - Reword error message.
> ---
>  xen/arch/x86/smpboot.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
> index fa691b6ba0..8cbb7173a4 100644
> --- a/xen/arch/x86/smpboot.c
> +++ b/xen/arch/x86/smpboot.c
> @@ -1317,6 +1317,13 @@ int __cpu_up(unsigned int cpu)
>      if ( (apicid = x86_cpu_to_apicid[cpu]) == BAD_APICID )
>          return -ENODEV;
>  
> +    if ( (!x2apic_enabled || !iommu_intremap) && (apicid >> 8) )

Btw, I'll change the right side to "apicid >= 0xff", as that ID is
special. Or perhaps this should really be

    if ( (!x2apic_enabled && apicid >= APIC_ALL_CPUS) ||
         (!iommu_intremap && (apicid >> 8)) )

Thoughts?

Jan
Andrew Cooper Dec. 20, 2019, 3:23 p.m. UTC | #4
On 20/12/2019 15:17, Jan Beulich wrote:
> On 04.12.2019 17:20, Roger Pau Monne wrote:
>> Check that the processor to be woken up APIC ID is addressable in the
>> current APIC mode.
>>
>> Note that in practice systems with APIC IDs > 255 should already have
>> x2APIC enabled by the firmware, and hence this is mostly a safety
>> belt.
>>
>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>> ---
>> Changes since v2:
>>  - Reword error message.
>> ---
>>  xen/arch/x86/smpboot.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
>> index fa691b6ba0..8cbb7173a4 100644
>> --- a/xen/arch/x86/smpboot.c
>> +++ b/xen/arch/x86/smpboot.c
>> @@ -1317,6 +1317,13 @@ int __cpu_up(unsigned int cpu)
>>      if ( (apicid = x86_cpu_to_apicid[cpu]) == BAD_APICID )
>>          return -ENODEV;
>>  
>> +    if ( (!x2apic_enabled || !iommu_intremap) && (apicid >> 8) )
> Btw, I'll change the right side to "apicid >= 0xff", as that ID is
> special. Or perhaps this should really be
>
>     if ( (!x2apic_enabled && apicid >= APIC_ALL_CPUS) ||
>          (!iommu_intremap && (apicid >> 8)) )
>
> Thoughts?

LGTM.

~Andrew
diff mbox series

Patch

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index fa691b6ba0..8cbb7173a4 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -1317,6 +1317,13 @@  int __cpu_up(unsigned int cpu)
     if ( (apicid = x86_cpu_to_apicid[cpu]) == BAD_APICID )
         return -ENODEV;
 
+    if ( (!x2apic_enabled || !iommu_intremap) && (apicid >> 8) )
+    {
+        printk("Unsupported: APIC ID %#x in xAPIC mode w/o interrupt remapping",
+               apicid);
+        return -EINVAL;
+    }
+
     if ( (ret = do_boot_cpu(apicid, cpu)) != 0 )
         return ret;