qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] x86: ioapic: upgrade emulated IOAPIC to ver 0x20
@ 2016-07-25 11:36 Peter Xu
  2016-07-26  2:15 ` Michael S. Tsirkin
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Xu @ 2016-07-25 11:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, pbonzini, peter.maydell, peterx

IOMMU IR and IOAPIC legacy devices (e.g., e1000) cannot work well
together with some old Linux kernels (upstream before v4.0, or any
released RHEL kernels). This patch fixes it.

The problem is that: some old linux kernels (with IR enabled) only
support IOAPIC chips with version 0x20. New kernels after commit d32932d
("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces")
fixed this problem. To make sure we can work with even old kernels,
let's upgrade our IOAPIC to version 0x20.

This patch is only useful when vIOMMU IR is enabled (which still do not
support kernel IOAPIC). So here we are only upgrading QEMU IOAPIC chip
to version 0x20. For kernel based IOAPIC, the version will still be
0x11.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hw/intc/ioapic.c                  | 6 ++++++
 include/hw/i386/ioapic_internal.h | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
index 2d3282a..361c37c 100644
--- a/hw/intc/ioapic.c
+++ b/hw/intc/ioapic.c
@@ -354,6 +354,12 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t val,
             }
         }
         break;
+    case IOAPIC_EOI:
+        if (size != 4) {
+            break;
+        }
+        ioapic_eoi_broadcast(val);
+        break;
     }
 
     ioapic_update_kvm_routes(s);
diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_internal.h
index d89ea1b..9654a93 100644
--- a/include/hw/i386/ioapic_internal.h
+++ b/include/hw/i386/ioapic_internal.h
@@ -29,7 +29,7 @@
 
 #define MAX_IOAPICS                     1
 
-#define IOAPIC_VERSION                  0x11
+#define IOAPIC_VERSION                  0x20
 
 #define IOAPIC_LVT_DEST_SHIFT           56
 #define IOAPIC_LVT_DEST_IDX_SHIFT       48
@@ -71,6 +71,7 @@
 
 #define IOAPIC_IOREGSEL                 0x00
 #define IOAPIC_IOWIN                    0x10
+#define IOAPIC_EOI                      0x40
 
 #define IOAPIC_REG_ID                   0x00
 #define IOAPIC_REG_VER                  0x01
-- 
2.4.11

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

* Re: [Qemu-devel] [PATCH] x86: ioapic: upgrade emulated IOAPIC to ver 0x20
  2016-07-25 11:36 [Qemu-devel] [PATCH] x86: ioapic: upgrade emulated IOAPIC to ver 0x20 Peter Xu
@ 2016-07-26  2:15 ` Michael S. Tsirkin
  2016-07-26  2:56   ` Peter Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2016-07-26  2:15 UTC (permalink / raw)
  To: Peter Xu; +Cc: qemu-devel, peter.maydell, pbonzini

On Mon, Jul 25, 2016 at 07:36:24PM +0800, Peter Xu wrote:
> IOMMU IR and IOAPIC legacy devices (e.g., e1000) cannot work well
> together with some old Linux kernels (upstream before v4.0, or any
> released RHEL kernels). This patch fixes it.
> 
> The problem is that: some old linux kernels (with IR enabled) only
> support IOAPIC chips with version 0x20. New kernels after commit d32932d
> ("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces")
> fixed this problem. To make sure we can work with even old kernels,
> let's upgrade our IOAPIC to version 0x20.
> 
> This patch is only useful when vIOMMU IR is enabled (which still do not
> support kernel IOAPIC). So here we are only upgrading QEMU IOAPIC chip
> to version 0x20. For kernel based IOAPIC, the version will still be
> 0x11.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>

As a minimum, we need to make sure not to change this for
old machine types.

Given the timing, limiting this for when IR is enabled
would be a good idea I think.

> ---
>  hw/intc/ioapic.c                  | 6 ++++++
>  include/hw/i386/ioapic_internal.h | 3 ++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
> index 2d3282a..361c37c 100644
> --- a/hw/intc/ioapic.c
> +++ b/hw/intc/ioapic.c
> @@ -354,6 +354,12 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t val,
>              }
>          }
>          break;
> +    case IOAPIC_EOI:
> +        if (size != 4) {
> +            break;
> +        }
> +        ioapic_eoi_broadcast(val);
> +        break;
>      }
>  
>      ioapic_update_kvm_routes(s);


I'd add a code comment saying this is for 0x20 only.

> diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_internal.h
> index d89ea1b..9654a93 100644
> --- a/include/hw/i386/ioapic_internal.h
> +++ b/include/hw/i386/ioapic_internal.h
> @@ -29,7 +29,7 @@
>  
>  #define MAX_IOAPICS                     1
>  
> -#define IOAPIC_VERSION                  0x11
> +#define IOAPIC_VERSION                  0x20
>  
>  #define IOAPIC_LVT_DEST_SHIFT           56
>  #define IOAPIC_LVT_DEST_IDX_SHIFT       48
> @@ -71,6 +71,7 @@
>  
>  #define IOAPIC_IOREGSEL                 0x00
>  #define IOAPIC_IOWIN                    0x10
> +#define IOAPIC_EOI                      0x40
>  
>  #define IOAPIC_REG_ID                   0x00
>  #define IOAPIC_REG_VER                  0x01
> -- 
> 2.4.11
> 

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

* Re: [Qemu-devel] [PATCH] x86: ioapic: upgrade emulated IOAPIC to ver 0x20
  2016-07-26  2:15 ` Michael S. Tsirkin
@ 2016-07-26  2:56   ` Peter Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Xu @ 2016-07-26  2:56 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel, peter.maydell, pbonzini

On Tue, Jul 26, 2016 at 05:15:58AM +0300, Michael S. Tsirkin wrote:
> On Mon, Jul 25, 2016 at 07:36:24PM +0800, Peter Xu wrote:
> > IOMMU IR and IOAPIC legacy devices (e.g., e1000) cannot work well
> > together with some old Linux kernels (upstream before v4.0, or any
> > released RHEL kernels). This patch fixes it.
> > 
> > The problem is that: some old linux kernels (with IR enabled) only
> > support IOAPIC chips with version 0x20. New kernels after commit d32932d
> > ("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces")
> > fixed this problem. To make sure we can work with even old kernels,
> > let's upgrade our IOAPIC to version 0x20.
> > 
> > This patch is only useful when vIOMMU IR is enabled (which still do not
> > support kernel IOAPIC). So here we are only upgrading QEMU IOAPIC chip
> > to version 0x20. For kernel based IOAPIC, the version will still be
> > 0x11.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> 
> As a minimum, we need to make sure not to change this for
> old machine types.
> 
> Given the timing, limiting this for when IR is enabled
> would be a good idea I think.

Thanks Michael. Then let me cook another patch specified to IR, and
then we can choose either one we want.

-- peterx

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

end of thread, other threads:[~2016-07-26  2:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-25 11:36 [Qemu-devel] [PATCH] x86: ioapic: upgrade emulated IOAPIC to ver 0x20 Peter Xu
2016-07-26  2:15 ` Michael S. Tsirkin
2016-07-26  2:56   ` Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).