Skip to contentSkip to conversation

x86: Add a new physdev_op PHYSDEVOP_nr_irqs_gsi

RFC PATCH In review Lin Ming 6 participants 9 messages Apr 10, 2012 – Apr 11, 2012

lore
Share & tools
lore

Lin Ming

author
#0 lore raw

RFC PATCH 1/1 x86: Add a new physdev_op PHYSDEVOP_nr_irqs_gsi

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

See below Linux kernel patch for detail explanation.

[RFC PATCH] xen: get correct nr_irqs_gsi value from hypervisor
http://marc.info/?l=xen-devel&m=133407004503365&w=2

---
 xen/arch/x86/physdev.c       |    8 ++++++++
 xen/include/public/physdev.h |    6 ++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
xen/arch/x86/physdev.c +8 -0
index 05fff9e..0912db0 100644
@@ -688,6 +688,14 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
                               setup_gsi.polarity);
         break; 
     }
+    case PHYSDEVOP_nr_irqs_gsi: {
+        struct physdev_nr_irqs_gsi out;
+
+        out.nr_irqs_gsi = nr_irqs_gsi;
+        ret = copy_to_guest(arg, &out, 1) ? -EFAULT : 0;
+
+        break;
+    }
     case PHYSDEVOP_get_free_pirq: {
         struct physdev_get_free_pirq out;
         struct domain *d;
xen/include/public/physdev.h +6 -0
index b78eeba..7856fc2 100644
@@ -312,6 +312,12 @@ struct physdev_pci_device {
 typedef struct physdev_pci_device physdev_pci_device_t;
 DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t);
 
+#define PHYSDEVOP_nr_irqs_gsi           29
+struct physdev_nr_irqs_gsi {
+    /* OUT */
+    uint32_t nr_irqs_gsi;
+};
+
 /*
  * Notify that some PIRQ-bound event channels have been unmasked.
  * ** This command is obsolete since interface version 0x00030202 and is **
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

Jan

Quoted 57 lines

See below Linux kernel patch for detail explanation.

[RFC PATCH] xen: get correct nr_irqs_gsi value from hypervisor
http://marc.info/?l=xen-devel&m=133407004503365&w=2

---
 xen/arch/x86/physdev.c       |    8 ++++++++
 xen/include/public/physdev.h |    6 ++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
xen/arch/x86/physdev.c +8 -0
index 05fff9e..0912db0 100644
@@ -688,6 +688,14 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
                               setup_gsi.polarity);
         break; 
     }
+    case PHYSDEVOP_nr_irqs_gsi: {
+        struct physdev_nr_irqs_gsi out;
+
+        out.nr_irqs_gsi = nr_irqs_gsi;
+        ret = copy_to_guest(arg, &out, 1) ? -EFAULT : 0;
+
+        break;
+    }
     case PHYSDEVOP_get_free_pirq: {
         struct physdev_get_free_pirq out;
         struct domain *d;
xen/include/public/physdev.h +6 -0
index b78eeba..7856fc2 100644
@@ -312,6 +312,12 @@ struct physdev_pci_device {
 typedef struct physdev_pci_device physdev_pci_device_t;
 DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t);
 
+#define PHYSDEVOP_nr_irqs_gsi           29
+struct physdev_nr_irqs_gsi {
+    /* OUT */
+    uint32_t nr_irqs_gsi;
+};
+
 /*
  * Notify that some PIRQ-bound event channels have been unmasked.
  * ** This command is obsolete since interface version 0x00030202 and is **
Signature · 9 lines
1.7.2.5




_______________________________________________
Xen-devel mailing list
[email protected] 
http://lists.xen.org/xen-devel 
author
#2 lore raw
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

In Linux kernel:

mp_register_ioapic(...):

        entries = io_apic_get_redir_entries(idx);
        gsi_cfg = mp_ioapic_gsi_routing(idx);
        gsi_cfg->gsi_base = gsi_base;
        gsi_cfg->gsi_end = gsi_base + entries - 1;

        /*
         * The number of IO-APIC IRQ registers (== #pins):
         */
        ioapics[idx].nr_registers = entries;

        if (gsi_cfg->gsi_end >= gsi_top)
                gsi_top = gsi_cfg->gsi_end + 1;

io_apic_get_redir_entries calls io_apic_read(), which returns wrong value(0xFFFFFFFF) on Xen Dom0 kernel.

How can we get the correct gsi_top value, which is used to set nr_irqs_gsi, without hypercall?

The problem here is we don't have a Xen version of io_apic_read in Linux kernel.

Thanks,
Lin Ming

Quoted 2 lines

Jan

#3 lore raw
Quoted 26 lines
Quoted 1 line
Quoted 1 line · Lin Ming
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

In Linux kernel:

mp_register_ioapic(...):

        entries = io_apic_get_redir_entries(idx);
        gsi_cfg = mp_ioapic_gsi_routing(idx);
        gsi_cfg->gsi_base = gsi_base;
        gsi_cfg->gsi_end = gsi_base + entries - 1;

        /*
         * The number of IO-APIC IRQ registers (== #pins):
         */
        ioapics[idx].nr_registers = entries;

        if (gsi_cfg->gsi_end >= gsi_top)
                gsi_top = gsi_cfg->gsi_end + 1;
Quoted 2 lines

io_apic_get_redir_entries calls io_apic_read(), which returns wrong value(0xFFFFFFFF) on Xen Dom0 kernel.

I understand all of the above.

Quoted 5 lines

How can we get the correct gsi_top value, which is used to set nr_irqs_gsi, without hypercall?

The problem here is we don't have a Xen version of io_apic_read in Linux kernel.

Meaning you need to craft one if you need one, the more that struct io_apic_ops already exists. The traditional kernel was able to do so quite fine, and hence didn't need any hypercall.

Jan

#4 lore raw
In reply to Lin Ming
Quoted 25 lines · Lin Ming
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

In Linux kernel:

mp_register_ioapic(...):

        entries = io_apic_get_redir_entries(idx);
        gsi_cfg = mp_ioapic_gsi_routing(idx);
        gsi_cfg->gsi_base = gsi_base;
        gsi_cfg->gsi_end = gsi_base + entries - 1;

        /*
         * The number of IO-APIC IRQ registers (== #pins):
         */
        ioapics[idx].nr_registers = entries;

        if (gsi_cfg->gsi_end >= gsi_top)
                gsi_top = gsi_cfg->gsi_end + 1;
Quoted 8 lines

io_apic_get_redir_entries calls io_apic_read(), which returns wrong value(0xFFFFFFFF) on Xen Dom0 kernel.

How can we get the correct gsi_top value, which is used to set nr_irqs_gsi, without hypercall?

The problem here is we don't have a Xen version of io_apic_read in Linux kernel.

Actually we do: http://marc.info/?l=linux-kernel&m=133295662314519

#5 lore raw
Quoted 39 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Wednesday, April 11, 2012 12:21 AM
To: Lin Ming
Cc: Jan Beulich; Konrad Rzeszutek Wilk; Zhang, Xiantao; xen-devel
Subject: Re: [Xen-devel] [RFC PATCH] x86: Add a new physdev_op PHYSDEVOP_nr_irqs_gsi

Quoted 28 lines · Lin Ming
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

In Linux kernel:

mp_register_ioapic(...):

        entries = io_apic_get_redir_entries(idx);
        gsi_cfg = mp_ioapic_gsi_routing(idx);
        gsi_cfg->gsi_base = gsi_base;
        gsi_cfg->gsi_end = gsi_base + entries - 1;

        /*
         * The number of IO-APIC IRQ registers (== #pins):
         */
        ioapics[idx].nr_registers = entries;

        if (gsi_cfg->gsi_end >= gsi_top)
                gsi_top = gsi_cfg->gsi_end + 1;

io_apic_get_redir_entries calls io_apic_read(), which returns wrong value(0xFFFFFFFF) on Xen Dom0 kernel.

Quoted 7 lines
Quoted 5 lines

How can we get the correct gsi_top value, which is used to set nr_irqs_gsi, without hypercall?

The problem here is we don't have a Xen version of io_apic_read in Linux kernel.

Actually we do: http://marc.info/?l=linux-kernel&m=133295662314519

This is not enough, seems fixed value are returned for each read ? Xiantao

#6 lore raw
Quoted 40 lines · Xiantao
Quoted 40 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Wednesday, April 11, 2012 12:21 AM
To: Lin Ming
Cc: Jan Beulich; Konrad Rzeszutek Wilk; Zhang, Xiantao; xen-devel
Subject: Re: [Xen-devel] [RFC PATCH] x86: Add a new physdev_op PHYSDEVOP_nr_irqs_gsi

Quoted 31 lines · Lin Ming
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

In Linux kernel:

mp_register_ioapic(...):

        entries = io_apic_get_redir_entries(idx);
        gsi_cfg = mp_ioapic_gsi_routing(idx);
        gsi_cfg->gsi_base = gsi_base;
        gsi_cfg->gsi_end = gsi_base + entries - 1;

        /*
         * The number of IO-APIC IRQ registers (== #pins):
         */
        ioapics[idx].nr_registers = entries;

        if (gsi_cfg->gsi_end >= gsi_top)
                gsi_top = gsi_cfg->gsi_end + 1;

io_apic_get_redir_entries calls io_apic_read(), which returns wrong value(0xFFFFFFFF) on Xen Dom0 kernel.

How can we get the correct gsi_top value, which is used to set nr_irqs_gsi, without hypercall?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The problem here is we don't have a Xen version of io_apic_read in Linux kernel.

Actually we do: http://marc.info/?l=linux-kernel&m=133295662314519

This is not enough, seems fixed value are returned for each read ?

Yes, it looks like we are always returning 0x00170020, that means 24 entries that I guess is correct for the vast majority of io_apics.

We could limit ourselves to adding a comment saying "we assume the io_apic has 24 redir entries".

Or we could use PHYSDEVOP_apic_read to do an actual io_apic read for reg 0x1.

#7 lore raw
Quoted 38 lines · Stefano Stabellini
Quoted 37 lines · Xiantao
Quoted 37 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Wednesday, April 11, 2012 12:21 AM
To: Lin Ming
Cc: Jan Beulich; Konrad Rzeszutek Wilk; Zhang, Xiantao; xen-devel
Subject: Re: [Xen-devel] [RFC PATCH] x86: Add a new physdev_op PHYSDEVOP_nr_irqs_gsi

Quoted 28 lines · Lin Ming
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

In Linux kernel:

mp_register_ioapic(...):

        entries = io_apic_get_redir_entries(idx);
        gsi_cfg = mp_ioapic_gsi_routing(idx);
        gsi_cfg->gsi_base = gsi_base;
        gsi_cfg->gsi_end = gsi_base + entries - 1;

        /*
         * The number of IO-APIC IRQ registers (== #pins):
         */
        ioapics[idx].nr_registers = entries;

        if (gsi_cfg->gsi_end >= gsi_top)
                gsi_top = gsi_cfg->gsi_end + 1;

io_apic_get_redir_entries calls io_apic_read(), which returns wrong value(0xFFFFFFFF) on Xen Dom0 kernel.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

How can we get the correct gsi_top value, which is used to set nr_irqs_gsi, without hypercall?

The problem here is we don't have a Xen version of io_apic_read in Linux kernel.

Actually we do: http://marc.info/?l=linux-kernel&m=133295662314519

Why was this patch never seen on xen-devel?

Quoted 10 lines
Quoted 1 line

This is not enough, seems fixed value are returned for each read ?

Yes, it looks like we are always returning 0x00170020, that means 24 entries that I guess is correct for the vast majority of io_apics.

We could limit ourselves to adding a comment saying "we assume the io_apic has 24 redir entries".

Or we could use PHYSDEVOP_apic_read to do an actual io_apic read for reg 0x1.

This seems like the obviously right thing to do, compared with hardcoding 24...

Ian.

#8 lore raw
Quoted 33 lines · Ian Campbell
Quoted 32 lines · Stefano Stabellini
Quoted 31 lines · Xiantao
Quoted 31 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Wednesday, April 11, 2012 12:21 AM
To: Lin Ming
Cc: Jan Beulich; Konrad Rzeszutek Wilk; Zhang, Xiantao; xen-devel
Subject: Re: [Xen-devel] [RFC PATCH] x86: Add a new physdev_op PHYSDEVOP_nr_irqs_gsi

Quoted 22 lines · Lin Ming
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lin Ming

This new physdev_op is added for Linux guest kernel to get the correct nr_irqs_gsi value.

I'm not convinced this is really needed - the kernel can work out the right number without any hypercall afaict.

In Linux kernel:

mp_register_ioapic(...):

        entries = io_apic_get_redir_entries(idx);
        gsi_cfg = mp_ioapic_gsi_routing(idx);
        gsi_cfg->gsi_base = gsi_base;
        gsi_cfg->gsi_end = gsi_base + entries - 1;

        /*
         * The number of IO-APIC IRQ registers (== #pins):
         */
        ioapics[idx].nr_registers = entries;
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
        if (gsi_cfg->gsi_end >= gsi_top)
                gsi_top = gsi_cfg->gsi_end + 1;

io_apic_get_redir_entries calls io_apic_read(), which returns wrong value(0xFFFFFFFF) on Xen Dom0 kernel.$

It is actually now 0xfd.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

How can we get the correct gsi_top value, which is used to set nr_irqs_gsi, without hypercall?

So, why is this important?

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

The problem here is we don't have a Xen version of io_apic_read in Linux kernel.

Actually we do: http://marc.info/?l=linux-kernel&m=133295662314519

Why was this patch never seen on xen-devel?

Probably b/c I forgot to put the CC on it. Either way it first has to go through Ingo's tree for 3.5.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

This is not enough, seems fixed value are returned for each read ?

Yes, it looks like we are always returning 0x00170020, that means 24 entries that I guess is correct for the vast majority of io_apics.

Quoted 8 lines
Quoted 5 lines

We could limit ourselves to adding a comment saying "we assume the io_apic has 24 redir entries".

Or we could use PHYSDEVOP_apic_read to do an actual io_apic read for reg 0x1.

This seems like the obviously right thing to do, compared with hardcoding 24...

Could do as well.

Quoted 9 lines

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel