diff mbox series

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

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

Commit Message

Roger Pau Monné Nov. 29, 2019, 11:28 a.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>
---
 xen/arch/x86/smpboot.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jan Beulich Dec. 3, 2019, 3:23 p.m. UTC | #1
On 29.11.2019 12:28, Roger Pau Monne wrote:
> --- 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("Processor with APIC ID %u cannot be onlined in xAPIC mode "
> +               "or without interrupt remapping\n", apicid);

Please log the APIC ID in hex, to match how it gets logged e.g.
by the ACPI table parsing code. I'd also prefer if the message
could be shortened a little: I don't think the "or" is needed,
"Processor" could become "CPU", and slight re-wording could
save even a little more: "Cannot online CPU with APIC ID %#x in
xAPIC mode w/o interrupt remapping".

Then again this isn't fully correct: We could bring such a
CPU online in x2APIC mode but without interrupt remapping.
There would be a restriction on which CPUs physical interrupts
could be delivered to. So perhaps "Unsupported: APIC ID %#x in
xAPIC mode w/o interrupt remapping" or some such?

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index fa691b6ba0..484d344c44 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("Processor with APIC ID %u cannot be onlined in xAPIC mode "
+               "or without interrupt remapping\n", apicid);
+        return -EINVAL;
+    }
+
     if ( (ret = do_boot_cpu(apicid, cpu)) != 0 )
         return ret;