diff mbox series

[v2,1/4] x86/ioapic: only use dest32 with x2apic and interrupt remapping enabled

Message ID 20191129112851.19273-2-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
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(-)

Comments

Jan Beulich Dec. 3, 2019, 3:11 p.m. UTC | #1
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
Roger Pau Monné Dec. 4, 2019, 10:47 a.m. UTC | #2
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.
diff mbox series

Patch

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;