All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH v2 0/4] x86: enable x2APIC mode regardless of interrupt remapping support
@ 2019-11-29 11:28 Roger Pau Monne
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled Roger Pau Monne
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Roger Pau Monne @ 2019-11-29 11:28 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monne

Hello,

The following series aims to allow enabling x2APIC mode without
interrupt remapping support. The main usage of this would be in
virtualized environments, that usually provide x2APIC support but not
interrupt remapping.

See the last patch for some performance numbers of using x2APIC over
xAPIC when running Xen in pvshim mode.

Thanks, Roger.

Roger Pau Monne (4):
  x86/ioapic: only use dest32 with x2apic and interrupt remapping
    enabled
  x86/apic: force phys mode if interrupt remapping is disabled
  x86/smp: check APIC ID on AP bringup
  x86/apic: allow enabling x2APIC mode regardless of interrupt remapping

 xen/arch/x86/apic.c           | 89 +++++++++++++++++------------------
 xen/arch/x86/genapic/x2apic.c |  8 ++++
 xen/arch/x86/io_apic.c        | 14 +++---
 xen/arch/x86/smpboot.c        |  7 +++
 4 files changed, 64 insertions(+), 54 deletions(-)

-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled
  2019-11-29 11:28 [Xen-devel] [PATCH v2 0/4] x86: enable x2APIC mode regardless of interrupt remapping support Roger Pau Monne
@ 2019-11-29 11:28 ` Roger Pau Monne
  2019-12-03 15:11   ` Jan Beulich
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled Roger Pau Monne
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ messages in thread
From: Roger Pau Monne @ 2019-11-29 11:28 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monne

The IO-APIC code assumes that x2apic being enabled also implies
interrupt remapping being enabled, and hence will use the 32bit
destination field in the IO-APIC entry.

This is safe now, but there's no reason to not enable x2APIC even
without interrupt remapping, and hence the IO-APIC code needs to use
the 32 bit destination field only when both interrupt remapping and
x2APIC are enabled.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - Fix set_ioapic_affinity_irq.
---
 xen/arch/x86/io_apic.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index 97cb2d154a..be0b085513 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -562,7 +562,7 @@ set_ioapic_affinity_irq(struct irq_desc *desc, const cpumask_t *mask)
 
     dest = set_desc_affinity(desc, mask);
     if (dest != BAD_APICID) {
-        if ( !x2apic_enabled )
+        if ( !iommu_intremap )
             dest = SET_APIC_LOGICAL_ID(dest);
         entry = irq_2_pin + irq;
         for (;;) {
@@ -964,7 +964,7 @@ static hw_irq_controller ioapic_edge_type;
 #define IOAPIC_LEVEL	1
 
 #define SET_DEST(ent, mode, val) do { \
-    if (x2apic_enabled) \
+    if (x2apic_enabled && iommu_intremap) \
         (ent).dest.dest32 = (val); \
     else \
         (ent).dest.mode.mode##_dest = (val); \
@@ -1194,14 +1194,14 @@ static void /*__init*/ __print_IO_APIC(bool boot)
 	printk(KERN_DEBUG ".... IRQ redirection table:\n");
 
 	printk(KERN_DEBUG " NR %s Msk Trg IRR Pol Stat DstM DelM Vec\n",
-               x2apic_enabled ? " DestID" : "Dst");
+               (x2apic_enabled && iommu_intremap) ? " DestID" : "Dst");
 
 	for (i = 0; i <= reg_01.bits.entries; i++) {
             struct IO_APIC_route_entry entry;
 
             entry = ioapic_read_entry(apic, i, 0);
 
-            if ( x2apic_enabled )
+            if ( x2apic_enabled && iommu_intremap )
                 printk(KERN_DEBUG " %02x %08x", i, entry.dest.dest32);
             else
                 printk(KERN_DEBUG " %02x  %02x ", i,
@@ -2504,9 +2504,9 @@ void dump_ioapic_irq_info(void)
                    rte.dest_mode ? 'L' : 'P',
                    rte.delivery_status, rte.polarity, rte.irr,
                    rte.trigger ? 'L' : 'E', rte.mask,
-                   x2apic_enabled ? 8 : 2,
-                   x2apic_enabled ? rte.dest.dest32
-                                  : rte.dest.logical.logical_dest);
+                   (x2apic_enabled && iommu_intremap) ? 8 : 2,
+                   (x2apic_enabled && iommu_intremap) ?
+                       rte.dest.dest32 : rte.dest.logical.logical_dest);
 
             if ( entry->next == 0 )
                 break;
-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled
  2019-11-29 11:28 [Xen-devel] [PATCH v2 0/4] x86: enable x2APIC mode regardless of interrupt remapping support Roger Pau Monne
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled Roger Pau Monne
@ 2019-11-29 11:28 ` Roger Pau Monne
  2019-11-29 11:38   ` Roger Pau Monné
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 3/4] x86/smp: check APIC ID on AP bringup Roger Pau Monne
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping Roger Pau Monne
  3 siblings, 1 reply; 16+ messages in thread
From: Roger Pau Monne @ 2019-11-29 11:28 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monne

Cluster mode can only be used with interrupt remapping support, since
the top 16bits of the APIC ID are filled with the cluster ID, and
hence on systems where the physical ID is still smaller than 255 the
cluster ID is not. Force x2APIC to use physical mode if there's no
interrupt remapping support.

Note that this requires a further patch in order to enable x2APIC
without interrupt remapping support.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - New in this version.
---
 xen/arch/x86/genapic/x2apic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/arch/x86/genapic/x2apic.c b/xen/arch/x86/genapic/x2apic.c
index d5a17f10d5..7e32ee22ff 100644
--- a/xen/arch/x86/genapic/x2apic.c
+++ b/xen/arch/x86/genapic/x2apic.c
@@ -228,6 +228,14 @@ const struct genapic *__init apic_x2apic_probe(void)
     if ( x2apic_phys < 0 )
         x2apic_phys = !!(acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL);
 
+    if ( !x2apic_phys && !iommu_intremap )
+        /*
+         * Force physical mode if there's no interrupt remapping support: the
+         * ID in clustered mode requires a 32 bit destination field due to the
+         * usage of the high 16 bits to store the cluster ID.
+         */
+        x2apic_phys = true;
+
     if ( x2apic_phys )
         return &apic_x2apic_phys;
 
-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Xen-devel] [PATCH v2 3/4] x86/smp: check APIC ID on AP bringup
  2019-11-29 11:28 [Xen-devel] [PATCH v2 0/4] x86: enable x2APIC mode regardless of interrupt remapping support Roger Pau Monne
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled Roger Pau Monne
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled Roger Pau Monne
@ 2019-11-29 11:28 ` Roger Pau Monne
  2019-12-03 15:23   ` Jan Beulich
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping Roger Pau Monne
  3 siblings, 1 reply; 16+ messages in thread
From: Roger Pau Monne @ 2019-11-29 11:28 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monne

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(+)

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;
 
-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping
  2019-11-29 11:28 [Xen-devel] [PATCH v2 0/4] x86: enable x2APIC mode regardless of interrupt remapping support Roger Pau Monne
                   ` (2 preceding siblings ...)
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 3/4] x86/smp: check APIC ID on AP bringup Roger Pau Monne
@ 2019-11-29 11:28 ` Roger Pau Monne
  2019-12-03 15:33   ` Jan Beulich
  3 siblings, 1 reply; 16+ messages in thread
From: Roger Pau Monne @ 2019-11-29 11:28 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monne

x2APIC mode doesn't mandate interrupt remapping, and hence can be
enabled independently. This patch enables x2APIC when available,
regardless of whether there's interrupt remapping support.

This is beneficial specially when running on virtualized environments,
since it reduces the amount of vmexits. For example when sending an
IPI in xAPIC mode Xen performs at least 3 different accesses to the
APIC MMIO region, while when using x2APIC mode a single wrmsr is used.

The following numbers are from a lock profiling of a Xen PV shim
running a Linux PV kernel with 32 vCPUs and xAPIC mode:

(XEN) Global lock flush_lock: addr=ffff82d0804af1c0, lockval=03190319, not locked
(XEN)   lock:656153(892606463454), block:602183(9495067321843)

Average lock time:   1360363ns
Average block time: 15767743ns

While the following are from the same configuration but with the shim
using x2APIC mode:

(XEN) Global lock flush_lock: addr=ffff82d0804b01c0, lockval=1adb1adb, not locked
(XEN)   lock:1841883(1375128998543), block:1658716(10193054890781)

Average lock time:   746588ns
Average block time: 6145147ns

Enabling x2APIC has halved the average lock time, thus reducing
contention.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - Fix error paths of iommu_enable_x2apic call in x2apic_bsp_setup.
---
NB: should enabling x2APIC without interrupt remapping be limited to
running on virtualized environments?

The bigger performance benefit is indeed achieved when using x2APIC on
virt environments, but I also don't see why we wouldn't want to try
using it everywhere where it's supported.
---
 xen/arch/x86/apic.c | 89 +++++++++++++++++++++------------------------
 1 file changed, 42 insertions(+), 47 deletions(-)

diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index a8ee18636f..eaf8924585 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -492,7 +492,8 @@ static void __enable_x2apic(void)
 
 static void resume_x2apic(void)
 {
-    iommu_enable_x2apic();
+    if ( iommu_supports_x2apic() )
+        iommu_enable_x2apic();
     __enable_x2apic();
 }
 
@@ -695,7 +696,8 @@ int lapic_suspend(void)
 
     local_irq_save(flags);
     disable_local_APIC();
-    iommu_disable_x2apic();
+    if ( iommu_supports_x2apic() )
+        iommu_disable_x2apic();
     local_irq_restore(flags);
     return 0;
 }
@@ -875,56 +877,46 @@ void __init x2apic_bsp_setup(void)
         printk("x2APIC: Already enabled by BIOS: Ignoring cmdline disable.\n");
     }
 
-    if ( !iommu_supports_x2apic() )
+    if ( iommu_supports_x2apic() )
     {
-        if ( !x2apic_enabled )
+        if ( (ioapic_entries = alloc_ioapic_entries()) == NULL )
         {
-            printk("Not enabling x2APIC: depends on IOMMU support\n");
-            return;
+            printk("Allocate ioapic_entries failed\n");
+            goto out;
         }
-        panic("x2APIC: already enabled by BIOS, but no IOMMU support\n");
-    }
 
-    if ( (ioapic_entries = alloc_ioapic_entries()) == NULL )
-    {
-        printk("Allocate ioapic_entries failed\n");
-        goto out;
-    }
-
-    if ( save_IO_APIC_setup(ioapic_entries) )
-    {
-        printk("Saving IO-APIC state failed\n");
-        goto out;
-    }
+        if ( save_IO_APIC_setup(ioapic_entries) )
+        {
+            printk("Saving IO-APIC state failed\n");
+            goto out;
+        }
 
-    mask_8259A();
-    mask_IO_APIC_setup(ioapic_entries);
+        mask_8259A();
+        mask_IO_APIC_setup(ioapic_entries);
 
-    switch ( iommu_enable_x2apic() )
-    {
-    case 0:
-        intremap_enabled = true;
-        break;
-    case -ENXIO: /* ACPI_DMAR_X2APIC_OPT_OUT set */
-        if ( !x2apic_enabled )
+        switch ( iommu_enable_x2apic() )
         {
+        case 0:
+            intremap_enabled = true;
+            break;
+
+        case -ENXIO: /* ACPI_DMAR_X2APIC_OPT_OUT set */
+            if ( x2apic_enabled )
+                panic("IOMMU requests xAPIC mode, but x2APIC already enabled by firmware\n");
+
             printk("Not enabling x2APIC (upon firmware request)\n");
             intremap_enabled = false;
             goto restore_out;
+
+        default:
+            printk(XENLOG_ERR "Failed to enable Interrupt Remapping\n");
+            intremap_enabled = false;
+            break;
         }
-        /* fall through */
-    default:
-        if ( x2apic_enabled )
-            panic("Interrupt remapping could not be enabled while "
-                  "x2APIC is already enabled by BIOS\n");
-
-        printk(XENLOG_ERR
-               "Failed to enable Interrupt Remapping: Will not enable x2APIC.\n");
-        intremap_enabled = false;
-        goto restore_out;
-    }
 
-    force_iommu = 1;
+        if ( intremap_enabled )
+            force_iommu = 1;
+    }
 
     if ( !x2apic_enabled )
     {
@@ -938,13 +930,16 @@ void __init x2apic_bsp_setup(void)
         printk("Switched to APIC driver %s\n", genapic.name);
 
 restore_out:
-    /*
-     * NB: do not use raw mode when restoring entries if the iommu has been
-     * enabled during the process, because the entries need to be translated
-     * and added to the remapping table in that case.
-     */
-    restore_IO_APIC_setup(ioapic_entries, !intremap_enabled);
-    unmask_8259A();
+    if ( iommu_supports_x2apic() )
+    {
+        /*
+         * NB: do not use raw mode when restoring entries if the iommu has been
+         * enabled during the process, because the entries need to be translated
+         * and added to the remapping table in that case.
+         */
+        restore_IO_APIC_setup(ioapic_entries, !intremap_enabled);
+        unmask_8259A();
+    }
 
 out:
     if ( ioapic_entries )
-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled Roger Pau Monne
@ 2019-11-29 11:38   ` Roger Pau Monné
  2019-12-03 15:14     ` Jan Beulich
  0 siblings, 1 reply; 16+ messages in thread
From: Roger Pau Monné @ 2019-11-29 11:38 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

On Fri, Nov 29, 2019 at 12:28:49PM +0100, Roger Pau Monne wrote:
> Cluster mode can only be used with interrupt remapping support, since
> the top 16bits of the APIC ID are filled with the cluster ID, and
> hence on systems where the physical ID is still smaller than 255 the
> cluster ID is not. Force x2APIC to use physical mode if there's no
> interrupt remapping support.
> 
> Note that this requires a further patch in order to enable x2APIC
> without interrupt remapping support.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

This is missing a command line doc update and the logic below ignores
a user-set x2apic_phys value. Will wait for comments on other patches
before resending, sorry.

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled Roger Pau Monne
@ 2019-12-03 15:11   ` Jan Beulich
  2019-12-04 10:47     ` Roger Pau Monné
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2019-12-03 15:11 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, Wei Liu, Andrew Cooper

On 29.11.2019 12:28, Roger Pau Monne wrote:
> --- a/xen/arch/x86/io_apic.c
> +++ b/xen/arch/x86/io_apic.c
> @@ -562,7 +562,7 @@ set_ioapic_affinity_irq(struct irq_desc *desc, const cpumask_t *mask)
>  
>      dest = set_desc_affinity(desc, mask);
>      if (dest != BAD_APICID) {
> -        if ( !x2apic_enabled )
> +        if ( !iommu_intremap )

To match description as well as the other changes done, doesn't
this need to be "!x2apic_enabled || !iommu_intremap"?

jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled
  2019-11-29 11:38   ` Roger Pau Monné
@ 2019-12-03 15:14     ` Jan Beulich
  2019-12-04  9:17       ` Roger Pau Monné
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2019-12-03 15:14 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: xen-devel, Wei Liu, Andrew Cooper

On 29.11.2019 12:38, Roger Pau Monné  wrote:
> On Fri, Nov 29, 2019 at 12:28:49PM +0100, Roger Pau Monne wrote:
>> Cluster mode can only be used with interrupt remapping support, since
>> the top 16bits of the APIC ID are filled with the cluster ID, and
>> hence on systems where the physical ID is still smaller than 255 the
>> cluster ID is not. Force x2APIC to use physical mode if there's no
>> interrupt remapping support.
>>
>> Note that this requires a further patch in order to enable x2APIC
>> without interrupt remapping support.
>>
>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> This is missing a command line doc update and the logic below ignores
> a user-set x2apic_phys value.

So what would the behavior be in your opinion when the user
has requested cluster mode? I can't see you do much other
than panic()-ing, perhaps it's better to override the request
(as you already do)?

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 3/4] x86/smp: check APIC ID on AP bringup
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 3/4] x86/smp: check APIC ID on AP bringup Roger Pau Monne
@ 2019-12-03 15:23   ` Jan Beulich
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Beulich @ 2019-12-03 15:23 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, Wei Liu, Andrew Cooper

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping
  2019-11-29 11:28 ` [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping Roger Pau Monne
@ 2019-12-03 15:33   ` Jan Beulich
  2019-12-04 13:51     ` Roger Pau Monné
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2019-12-03 15:33 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, Wei Liu, Andrew Cooper

On 29.11.2019 12:28, Roger Pau Monne wrote:
> --- a/xen/arch/x86/apic.c
> +++ b/xen/arch/x86/apic.c
> @@ -492,7 +492,8 @@ static void __enable_x2apic(void)
>  
>  static void resume_x2apic(void)
>  {
> -    iommu_enable_x2apic();
> +    if ( iommu_supports_x2apic() )
> +        iommu_enable_x2apic();

The hooks called by this function are __init, and at least the AMD
one also isn't (I think) prepared to be called more than once.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled
  2019-12-03 15:14     ` Jan Beulich
@ 2019-12-04  9:17       ` Roger Pau Monné
  2019-12-04  9:34         ` Jan Beulich
  0 siblings, 1 reply; 16+ messages in thread
From: Roger Pau Monné @ 2019-12-04  9:17 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Wei Liu, Andrew Cooper

On Tue, Dec 03, 2019 at 04:14:46PM +0100, Jan Beulich wrote:
> On 29.11.2019 12:38, Roger Pau Monné  wrote:
> > On Fri, Nov 29, 2019 at 12:28:49PM +0100, Roger Pau Monne wrote:
> >> Cluster mode can only be used with interrupt remapping support, since
> >> the top 16bits of the APIC ID are filled with the cluster ID, and
> >> hence on systems where the physical ID is still smaller than 255 the
> >> cluster ID is not. Force x2APIC to use physical mode if there's no
> >> interrupt remapping support.
> >>
> >> Note that this requires a further patch in order to enable x2APIC
> >> without interrupt remapping support.
> >>
> >> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > 
> > This is missing a command line doc update and the logic below ignores
> > a user-set x2apic_phys value.
> 
> So what would the behavior be in your opinion when the user
> has requested cluster mode? I can't see you do much other
> than panic()-ing, perhaps it's better to override the request
> (as you already do)?

I think panic'ing is fine, a user shouldn't be setting x2apic_phys
unless they know what are doing, and then Xen changing it on the back
of the user also doesn't seem fine.

A panic explaining that x2apic_phys=false is not supported and that
the box can only be booted with x2apic phys mode should be fine IMO.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled
  2019-12-04  9:17       ` Roger Pau Monné
@ 2019-12-04  9:34         ` Jan Beulich
  2019-12-04 10:50           ` Roger Pau Monné
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2019-12-04  9:34 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: xen-devel, Wei Liu, Andrew Cooper

On 04.12.2019 10:17, Roger Pau Monné wrote:
> On Tue, Dec 03, 2019 at 04:14:46PM +0100, Jan Beulich wrote:
>> On 29.11.2019 12:38, Roger Pau Monné  wrote:
>>> On Fri, Nov 29, 2019 at 12:28:49PM +0100, Roger Pau Monne wrote:
>>>> Cluster mode can only be used with interrupt remapping support, since
>>>> the top 16bits of the APIC ID are filled with the cluster ID, and
>>>> hence on systems where the physical ID is still smaller than 255 the
>>>> cluster ID is not. Force x2APIC to use physical mode if there's no
>>>> interrupt remapping support.
>>>>
>>>> Note that this requires a further patch in order to enable x2APIC
>>>> without interrupt remapping support.
>>>>
>>>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>>>
>>> This is missing a command line doc update and the logic below ignores
>>> a user-set x2apic_phys value.
>>
>> So what would the behavior be in your opinion when the user
>> has requested cluster mode? I can't see you do much other
>> than panic()-ing, perhaps it's better to override the request
>> (as you already do)?
> 
> I think panic'ing is fine, a user shouldn't be setting x2apic_phys
> unless they know what are doing, and then Xen changing it on the back
> of the user also doesn't seem fine.
> 
> A panic explaining that x2apic_phys=false is not supported and that
> the box can only be booted with x2apic phys mode should be fine IMO.

I can see this as a valid position to take. Personally, however, I
do think we should avoid failing to boot if we easily can. (Yes, we
should log the fact that we ignore a command line option in such a
case.)

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled
  2019-12-03 15:11   ` Jan Beulich
@ 2019-12-04 10:47     ` Roger Pau Monné
  0 siblings, 0 replies; 16+ messages in thread
From: Roger Pau Monné @ 2019-12-04 10:47 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Wei Liu, Andrew Cooper

On Tue, Dec 03, 2019 at 04:11:07PM +0100, Jan Beulich wrote:
> On 29.11.2019 12:28, Roger Pau Monne wrote:
> > --- a/xen/arch/x86/io_apic.c
> > +++ b/xen/arch/x86/io_apic.c
> > @@ -562,7 +562,7 @@ set_ioapic_affinity_irq(struct irq_desc *desc, const cpumask_t *mask)
> >  
> >      dest = set_desc_affinity(desc, mask);
> >      if (dest != BAD_APICID) {
> > -        if ( !x2apic_enabled )
> > +        if ( !iommu_intremap )
> 
> To match description as well as the other changes done, doesn't
> this need to be "!x2apic_enabled || !iommu_intremap"?

Yes, in fact I already had this change on my local branch, not sure
why it didn't end up in the patch I sent.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled
  2019-12-04  9:34         ` Jan Beulich
@ 2019-12-04 10:50           ` Roger Pau Monné
  0 siblings, 0 replies; 16+ messages in thread
From: Roger Pau Monné @ 2019-12-04 10:50 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Wei Liu, Andrew Cooper

On Wed, Dec 04, 2019 at 10:34:14AM +0100, Jan Beulich wrote:
> On 04.12.2019 10:17, Roger Pau Monné wrote:
> > On Tue, Dec 03, 2019 at 04:14:46PM +0100, Jan Beulich wrote:
> >> On 29.11.2019 12:38, Roger Pau Monné  wrote:
> >>> On Fri, Nov 29, 2019 at 12:28:49PM +0100, Roger Pau Monne wrote:
> >>>> Cluster mode can only be used with interrupt remapping support, since
> >>>> the top 16bits of the APIC ID are filled with the cluster ID, and
> >>>> hence on systems where the physical ID is still smaller than 255 the
> >>>> cluster ID is not. Force x2APIC to use physical mode if there's no
> >>>> interrupt remapping support.
> >>>>
> >>>> Note that this requires a further patch in order to enable x2APIC
> >>>> without interrupt remapping support.
> >>>>
> >>>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> >>>
> >>> This is missing a command line doc update and the logic below ignores
> >>> a user-set x2apic_phys value.
> >>
> >> So what would the behavior be in your opinion when the user
> >> has requested cluster mode? I can't see you do much other
> >> than panic()-ing, perhaps it's better to override the request
> >> (as you already do)?
> > 
> > I think panic'ing is fine, a user shouldn't be setting x2apic_phys
> > unless they know what are doing, and then Xen changing it on the back
> > of the user also doesn't seem fine.
> > 
> > A panic explaining that x2apic_phys=false is not supported and that
> > the box can only be booted with x2apic phys mode should be fine IMO.
> 
> I can see this as a valid position to take. Personally, however, I
> do think we should avoid failing to boot if we easily can. (Yes, we
> should log the fact that we ignore a command line option in such a
> case.)

Ack, I don't have a strong opinion, so I would go this route.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping
  2019-12-03 15:33   ` Jan Beulich
@ 2019-12-04 13:51     ` Roger Pau Monné
  2019-12-04 14:28       ` Jan Beulich
  0 siblings, 1 reply; 16+ messages in thread
From: Roger Pau Monné @ 2019-12-04 13:51 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Wei Liu, Andrew Cooper

On Tue, Dec 03, 2019 at 04:33:09PM +0100, Jan Beulich wrote:
> On 29.11.2019 12:28, Roger Pau Monne wrote:
> > --- a/xen/arch/x86/apic.c
> > +++ b/xen/arch/x86/apic.c
> > @@ -492,7 +492,8 @@ static void __enable_x2apic(void)
> >  
> >  static void resume_x2apic(void)
> >  {
> > -    iommu_enable_x2apic();
> > +    if ( iommu_supports_x2apic() )
> > +        iommu_enable_x2apic();
> 
> The hooks called by this function are __init, and at least the AMD
> one also isn't (I think) prepared to be called more than once.

It's already called twice, there's one call to iommu_supports_x2apic
in x2apic_bsp_setup and another one in iommu_enable_x2apic, so I think
calling iommu_supports_x2apic multiple times is fine (or we would
already have issues).

I will cache the value of iommu_enable_x2apic to be used in the
suspend/resume paths of the local apic, so there's no need to call
iommu_supports_x2apic after init.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping
  2019-12-04 13:51     ` Roger Pau Monné
@ 2019-12-04 14:28       ` Jan Beulich
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Beulich @ 2019-12-04 14:28 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: xen-devel, Wei Liu, Andrew Cooper

On 04.12.2019 14:51, Roger Pau Monné wrote:
> On Tue, Dec 03, 2019 at 04:33:09PM +0100, Jan Beulich wrote:
>> On 29.11.2019 12:28, Roger Pau Monne wrote:
>>> --- a/xen/arch/x86/apic.c
>>> +++ b/xen/arch/x86/apic.c
>>> @@ -492,7 +492,8 @@ static void __enable_x2apic(void)
>>>  
>>>  static void resume_x2apic(void)
>>>  {
>>> -    iommu_enable_x2apic();
>>> +    if ( iommu_supports_x2apic() )
>>> +        iommu_enable_x2apic();
>>
>> The hooks called by this function are __init, and at least the AMD
>> one also isn't (I think) prepared to be called more than once.
> 
> It's already called twice, there's one call to iommu_supports_x2apic
> in x2apic_bsp_setup and another one in iommu_enable_x2apic, so I think
> calling iommu_supports_x2apic multiple times is fine (or we would
> already have issues).

Ah, right - amd_iommu_prepare() bails (relatively) early when
noticing it had been called before.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-12-04 14:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 11:28 [Xen-devel] [PATCH v2 0/4] x86: enable x2APIC mode regardless of interrupt remapping support Roger Pau Monne
2019-11-29 11:28 ` [Xen-devel] [PATCH v2 1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled Roger Pau Monne
2019-12-03 15:11   ` Jan Beulich
2019-12-04 10:47     ` Roger Pau Monné
2019-11-29 11:28 ` [Xen-devel] [PATCH v2 2/4] x86/apic: force phys mode if interrupt remapping is disabled Roger Pau Monne
2019-11-29 11:38   ` Roger Pau Monné
2019-12-03 15:14     ` Jan Beulich
2019-12-04  9:17       ` Roger Pau Monné
2019-12-04  9:34         ` Jan Beulich
2019-12-04 10:50           ` Roger Pau Monné
2019-11-29 11:28 ` [Xen-devel] [PATCH v2 3/4] x86/smp: check APIC ID on AP bringup Roger Pau Monne
2019-12-03 15:23   ` Jan Beulich
2019-11-29 11:28 ` [Xen-devel] [PATCH v2 4/4] x86/apic: allow enabling x2APIC mode regardless of interrupt remapping Roger Pau Monne
2019-12-03 15:33   ` Jan Beulich
2019-12-04 13:51     ` Roger Pau Monné
2019-12-04 14:28       ` Jan Beulich

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.