All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Decouple Xen-HVM from PIIX
@ 2022-06-26  9:46 Bernhard Beschow
  2022-06-26  9:46 ` [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route() Bernhard Beschow
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Bernhard Beschow @ 2022-06-26  9:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant,
	Bernhard Beschow

hw/i386/xen/xen-hvm.c contains logic which is PIIX-specific. This makes xen-hvm.c depend on PIIX which can be avoided if PIIX logic was isolated in PIIX itself.

Bernhard Beschow (2):
  hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
  hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and
    remove it

 hw/i386/xen/xen-hvm.c       | 17 ++---------------
 hw/isa/piix3.c              | 15 ++++++++++++++-
 include/hw/xen/xen.h        |  2 +-
 include/hw/xen/xen_common.h |  6 ------
 stubs/xen-hw-stub.c         |  3 ++-
 5 files changed, 19 insertions(+), 24 deletions(-)

-- 
2.36.1



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

* [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
  2022-06-26  9:46 [PATCH 0/2] Decouple Xen-HVM from PIIX Bernhard Beschow
@ 2022-06-26  9:46 ` Bernhard Beschow
  2022-06-27  8:52   ` Durrant, Paul
  2022-06-28 22:24   ` Laurent Vivier
  2022-06-26  9:46 ` [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it Bernhard Beschow
  2022-06-28 20:58 ` [PATCH 0/2] Decouple Xen-HVM from PIIX B
  2 siblings, 2 replies; 10+ messages in thread
From: Bernhard Beschow @ 2022-06-26  9:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant,
	Bernhard Beschow

The only user of xen_set_pci_link_route() is
xen_piix_pci_write_config_client() which implements PIIX-specific logic in
the xen namespace. This makes xen-hvm depend on PIIX which could be
avoided if xen_piix_pci_write_config_client() was implemented in PIIX. In
order to do this, xen_set_pci_link_route() needs to be stubbable which
this patch addresses.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
 hw/i386/xen/xen-hvm.c       | 7 ++++++-
 include/hw/xen/xen.h        | 1 +
 include/hw/xen/xen_common.h | 6 ------
 stubs/xen-hw-stub.c         | 5 +++++
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index 0731f70410..204fda7949 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -161,11 +161,16 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
         }
         v &= 0xf;
         if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
-            xen_set_pci_link_route(xen_domid, address + i - PIIX_PIRQCA, v);
+            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
         }
     }
 }
 
+int xen_set_pci_link_route(uint8_t link, uint8_t irq)
+{
+    return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, irq);
+}
+
 int xen_is_pirq_msi(uint32_t msi_data)
 {
     /* If vector is 0, the msi is remapped into a pirq, passed as
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 0f9962b1c1..13bffaef53 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -21,6 +21,7 @@ extern enum xen_mode xen_mode;
 extern bool xen_domid_restrict;
 
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
+int xen_set_pci_link_route(uint8_t link, uint8_t irq);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 179741ff79..77ce17d8a4 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -316,12 +316,6 @@ static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
                                              device, intx, level);
 }
 
-static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
-                                         uint8_t irq)
-{
-    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link, irq);
-}
-
 static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
                                  uint32_t msi_data)
 {
diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c
index 15f3921a76..743967623f 100644
--- a/stubs/xen-hw-stub.c
+++ b/stubs/xen-hw-stub.c
@@ -23,6 +23,11 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
 {
 }
 
+int xen_set_pci_link_route(uint8_t link, uint8_t irq)
+{
+    return -1;
+}
+
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
 {
 }
-- 
2.36.1



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

* [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it
  2022-06-26  9:46 [PATCH 0/2] Decouple Xen-HVM from PIIX Bernhard Beschow
  2022-06-26  9:46 ` [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route() Bernhard Beschow
@ 2022-06-26  9:46 ` Bernhard Beschow
  2022-06-26 12:59   ` Michael S. Tsirkin
                     ` (2 more replies)
  2022-06-28 20:58 ` [PATCH 0/2] Decouple Xen-HVM from PIIX B
  2 siblings, 3 replies; 10+ messages in thread
From: Bernhard Beschow @ 2022-06-26  9:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant,
	Bernhard Beschow

xen_piix_pci_write_config_client() is implemented in the xen sub tree and
uses PIIX constants internally, thus creating a direct dependency on
PIIX. Now that xen_set_pci_link_route() is stubbable, the logic of
xen_piix_pci_write_config_client() can be moved to PIIX which resolves
the dependency.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
 hw/i386/xen/xen-hvm.c | 18 ------------------
 hw/isa/piix3.c        | 15 ++++++++++++++-
 include/hw/xen/xen.h  |  1 -
 stubs/xen-hw-stub.c   |  4 ----
 4 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index 204fda7949..e4293d6d66 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -15,7 +15,6 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_host.h"
 #include "hw/i386/pc.h"
-#include "hw/southbridge/piix.h"
 #include "hw/irq.h"
 #include "hw/hw.h"
 #include "hw/i386/apic-msidef.h"
@@ -149,23 +148,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int level)
                            irq_num & 3, level);
 }
 
-void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
-{
-    int i;
-
-    /* Scan for updates to PCI link routes (0x60-0x63). */
-    for (i = 0; i < len; i++) {
-        uint8_t v = (val >> (8 * i)) & 0xff;
-        if (v & 0x80) {
-            v = 0;
-        }
-        v &= 0xf;
-        if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
-            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
-        }
-    }
-}
-
 int xen_set_pci_link_route(uint8_t link, uint8_t irq)
 {
     return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, irq);
diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
index 6388558f92..48f9ab1096 100644
--- a/hw/isa/piix3.c
+++ b/hw/isa/piix3.c
@@ -138,7 +138,20 @@ static void piix3_write_config(PCIDevice *dev,
 static void piix3_write_config_xen(PCIDevice *dev,
                                    uint32_t address, uint32_t val, int len)
 {
-    xen_piix_pci_write_config_client(address, val, len);
+    int i;
+
+    /* Scan for updates to PCI link routes (0x60-0x63). */
+    for (i = 0; i < len; i++) {
+        uint8_t v = (val >> (8 * i)) & 0xff;
+        if (v & 0x80) {
+            v = 0;
+        }
+        v &= 0xf;
+        if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
+            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
+        }
+    }
+
     piix3_write_config(dev, address, val, len);
 }
 
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 13bffaef53..afdf9c436a 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -23,7 +23,6 @@ extern bool xen_domid_restrict;
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 int xen_set_pci_link_route(uint8_t link, uint8_t irq);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
-void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
 int xen_is_pirq_msi(uint32_t msi_data);
 
diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c
index 743967623f..34a22f2ad7 100644
--- a/stubs/xen-hw-stub.c
+++ b/stubs/xen-hw-stub.c
@@ -19,10 +19,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int level)
 {
 }
 
-void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
-{
-}
-
 int xen_set_pci_link_route(uint8_t link, uint8_t irq)
 {
     return -1;
-- 
2.36.1



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

* Re: [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it
  2022-06-26  9:46 ` [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it Bernhard Beschow
@ 2022-06-26 12:59   ` Michael S. Tsirkin
  2022-06-27  8:52   ` Durrant, Paul
  2022-06-28 22:25   ` Laurent Vivier
  2 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2022-06-26 12:59 UTC (permalink / raw)
  To: Bernhard Beschow
  Cc: qemu-devel, Richard Henderson, xen-devel, qemu-trivial,
	Eduardo Habkost, Marcel Apfelbaum, Stefano Stabellini,
	Paolo Bonzini, Anthony Perard, Paul Durrant

On Sun, Jun 26, 2022 at 11:46:56AM +0200, Bernhard Beschow wrote:
> xen_piix_pci_write_config_client() is implemented in the xen sub tree and
> uses PIIX constants internally, thus creating a direct dependency on
> PIIX. Now that xen_set_pci_link_route() is stubbable, the logic of
> xen_piix_pci_write_config_client() can be moved to PIIX which resolves
> the dependency.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>

Fine by me

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/i386/xen/xen-hvm.c | 18 ------------------
>  hw/isa/piix3.c        | 15 ++++++++++++++-
>  include/hw/xen/xen.h  |  1 -
>  stubs/xen-hw-stub.c   |  4 ----
>  4 files changed, 14 insertions(+), 24 deletions(-)
> 
> diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
> index 204fda7949..e4293d6d66 100644
> --- a/hw/i386/xen/xen-hvm.c
> +++ b/hw/i386/xen/xen-hvm.c
> @@ -15,7 +15,6 @@
>  #include "hw/pci/pci.h"
>  #include "hw/pci/pci_host.h"
>  #include "hw/i386/pc.h"
> -#include "hw/southbridge/piix.h"
>  #include "hw/irq.h"
>  #include "hw/hw.h"
>  #include "hw/i386/apic-msidef.h"
> @@ -149,23 +148,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int level)
>                             irq_num & 3, level);
>  }
>  
> -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
> -{
> -    int i;
> -
> -    /* Scan for updates to PCI link routes (0x60-0x63). */
> -    for (i = 0; i < len; i++) {
> -        uint8_t v = (val >> (8 * i)) & 0xff;
> -        if (v & 0x80) {
> -            v = 0;
> -        }
> -        v &= 0xf;
> -        if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
> -            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
> -        }
> -    }
> -}
> -
>  int xen_set_pci_link_route(uint8_t link, uint8_t irq)
>  {
>      return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, irq);
> diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
> index 6388558f92..48f9ab1096 100644
> --- a/hw/isa/piix3.c
> +++ b/hw/isa/piix3.c
> @@ -138,7 +138,20 @@ static void piix3_write_config(PCIDevice *dev,
>  static void piix3_write_config_xen(PCIDevice *dev,
>                                     uint32_t address, uint32_t val, int len)
>  {
> -    xen_piix_pci_write_config_client(address, val, len);
> +    int i;
> +
> +    /* Scan for updates to PCI link routes (0x60-0x63). */
> +    for (i = 0; i < len; i++) {
> +        uint8_t v = (val >> (8 * i)) & 0xff;
> +        if (v & 0x80) {
> +            v = 0;
> +        }
> +        v &= 0xf;
> +        if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
> +            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
> +        }
> +    }
> +
>      piix3_write_config(dev, address, val, len);
>  }
>  
> diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
> index 13bffaef53..afdf9c436a 100644
> --- a/include/hw/xen/xen.h
> +++ b/include/hw/xen/xen.h
> @@ -23,7 +23,6 @@ extern bool xen_domid_restrict;
>  int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
>  int xen_set_pci_link_route(uint8_t link, uint8_t irq);
>  void xen_piix3_set_irq(void *opaque, int irq_num, int level);
> -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
>  void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
>  int xen_is_pirq_msi(uint32_t msi_data);
>  
> diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c
> index 743967623f..34a22f2ad7 100644
> --- a/stubs/xen-hw-stub.c
> +++ b/stubs/xen-hw-stub.c
> @@ -19,10 +19,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int level)
>  {
>  }
>  
> -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
> -{
> -}
> -
>  int xen_set_pci_link_route(uint8_t link, uint8_t irq)
>  {
>      return -1;
> -- 
> 2.36.1



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

* Re: [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
  2022-06-26  9:46 ` [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route() Bernhard Beschow
@ 2022-06-27  8:52   ` Durrant, Paul
  2022-06-28 22:24   ` Laurent Vivier
  1 sibling, 0 replies; 10+ messages in thread
From: Durrant, Paul @ 2022-06-27  8:52 UTC (permalink / raw)
  To: Bernhard Beschow, qemu-devel
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant

On 26/06/2022 10:46, Bernhard Beschow wrote:
> The only user of xen_set_pci_link_route() is
> xen_piix_pci_write_config_client() which implements PIIX-specific logic in
> the xen namespace. This makes xen-hvm depend on PIIX which could be
> avoided if xen_piix_pci_write_config_client() was implemented in PIIX. In
> order to do this, xen_set_pci_link_route() needs to be stubbable which
> this patch addresses.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>

Reviewed-by: Paul Durrant <paul@xen.org>


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

* Re: [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it
  2022-06-26  9:46 ` [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it Bernhard Beschow
  2022-06-26 12:59   ` Michael S. Tsirkin
@ 2022-06-27  8:52   ` Durrant, Paul
  2022-06-28 22:25   ` Laurent Vivier
  2 siblings, 0 replies; 10+ messages in thread
From: Durrant, Paul @ 2022-06-27  8:52 UTC (permalink / raw)
  To: Bernhard Beschow, qemu-devel
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant

On 26/06/2022 10:46, Bernhard Beschow wrote:
> xen_piix_pci_write_config_client() is implemented in the xen sub tree and
> uses PIIX constants internally, thus creating a direct dependency on
> PIIX. Now that xen_set_pci_link_route() is stubbable, the logic of
> xen_piix_pci_write_config_client() can be moved to PIIX which resolves
> the dependency.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>

Reviewed-by: Paul Durrant <paul@xen.org>


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

* Re: [PATCH 0/2] Decouple Xen-HVM from PIIX
  2022-06-26  9:46 [PATCH 0/2] Decouple Xen-HVM from PIIX Bernhard Beschow
  2022-06-26  9:46 ` [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route() Bernhard Beschow
  2022-06-26  9:46 ` [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it Bernhard Beschow
@ 2022-06-28 20:58 ` B
  2022-06-28 21:09   ` Stefano Stabellini
  2 siblings, 1 reply; 10+ messages in thread
From: B @ 2022-06-28 20:58 UTC (permalink / raw)
  To: qemu-devel, Laurent Vivier
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant



Am 26. Juni 2022 09:46:54 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>hw/i386/xen/xen-hvm.c contains logic which is PIIX-specific. This makes xen-hvm.c depend on PIIX which can be avoided if PIIX logic was isolated in PIIX itself.
>
>
>
>Bernhard Beschow (2):
>
>  hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
>
>  hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and
>
>    remove it
>
>
>
> hw/i386/xen/xen-hvm.c       | 17 ++---------------
>
> hw/isa/piix3.c              | 15 ++++++++++++++-
>
> include/hw/xen/xen.h        |  2 +-
>
> include/hw/xen/xen_common.h |  6 ------
>
> stubs/xen-hw-stub.c         |  3 ++-
>
> 5 files changed, 19 insertions(+), 24 deletions(-)
>
>
>
>-- >
>2.36.1
>
>
>

Hi Laurent,

would you like to queue this as well? Both patches have been reviewed at least once, piix twice. Or would you rather keep the review period open for longer?

Best regards,
Bernhard


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

* Re: [PATCH 0/2] Decouple Xen-HVM from PIIX
  2022-06-28 20:58 ` [PATCH 0/2] Decouple Xen-HVM from PIIX B
@ 2022-06-28 21:09   ` Stefano Stabellini
  0 siblings, 0 replies; 10+ messages in thread
From: Stefano Stabellini @ 2022-06-28 21:09 UTC (permalink / raw)
  To: B
  Cc: qemu-devel, Laurent Vivier, Richard Henderson, xen-devel,
	qemu-trivial, Eduardo Habkost, Marcel Apfelbaum,
	Stefano Stabellini, Paolo Bonzini, Michael S. Tsirkin,
	Anthony Perard, Paul Durrant

On Tue, 28 Jun 2022, B wrote:
> Am 26. Juni 2022 09:46:54 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
> >hw/i386/xen/xen-hvm.c contains logic which is PIIX-specific. This makes xen-hvm.c depend on PIIX which can be avoided if PIIX logic was isolated in PIIX itself.
> >
> >
> >
> >Bernhard Beschow (2):
> >
> >  hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
> >
> >  hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and
> >
> >    remove it
> >
> >
> >
> > hw/i386/xen/xen-hvm.c       | 17 ++---------------
> >
> > hw/isa/piix3.c              | 15 ++++++++++++++-
> >
> > include/hw/xen/xen.h        |  2 +-
> >
> > include/hw/xen/xen_common.h |  6 ------
> >
> > stubs/xen-hw-stub.c         |  3 ++-
> >
> > 5 files changed, 19 insertions(+), 24 deletions(-)
> >
> >
> >
> >-- >
> >2.36.1
> >
> >
> >
> 
> Hi Laurent,
> 
> would you like to queue this as well? Both patches have been reviewed at least once, piix twice. Or would you rather keep the review period open for longer?
 
Paul reviewed them both -- I don't think we need further reviews.
Laurent could just take them.


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

* Re: [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
  2022-06-26  9:46 ` [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route() Bernhard Beschow
  2022-06-27  8:52   ` Durrant, Paul
@ 2022-06-28 22:24   ` Laurent Vivier
  1 sibling, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2022-06-28 22:24 UTC (permalink / raw)
  To: Bernhard Beschow, qemu-devel
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant

Le 26/06/2022 à 11:46, Bernhard Beschow a écrit :
> The only user of xen_set_pci_link_route() is
> xen_piix_pci_write_config_client() which implements PIIX-specific logic in
> the xen namespace. This makes xen-hvm depend on PIIX which could be
> avoided if xen_piix_pci_write_config_client() was implemented in PIIX. In
> order to do this, xen_set_pci_link_route() needs to be stubbable which
> this patch addresses.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
>   hw/i386/xen/xen-hvm.c       | 7 ++++++-
>   include/hw/xen/xen.h        | 1 +
>   include/hw/xen/xen_common.h | 6 ------
>   stubs/xen-hw-stub.c         | 5 +++++
>   4 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
> index 0731f70410..204fda7949 100644
> --- a/hw/i386/xen/xen-hvm.c
> +++ b/hw/i386/xen/xen-hvm.c
> @@ -161,11 +161,16 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
>           }
>           v &= 0xf;
>           if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
> -            xen_set_pci_link_route(xen_domid, address + i - PIIX_PIRQCA, v);
> +            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
>           }
>       }
>   }
>   
> +int xen_set_pci_link_route(uint8_t link, uint8_t irq)
> +{
> +    return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, irq);
> +}
> +
>   int xen_is_pirq_msi(uint32_t msi_data)
>   {
>       /* If vector is 0, the msi is remapped into a pirq, passed as
> diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
> index 0f9962b1c1..13bffaef53 100644
> --- a/include/hw/xen/xen.h
> +++ b/include/hw/xen/xen.h
> @@ -21,6 +21,7 @@ extern enum xen_mode xen_mode;
>   extern bool xen_domid_restrict;
>   
>   int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
> +int xen_set_pci_link_route(uint8_t link, uint8_t irq);
>   void xen_piix3_set_irq(void *opaque, int irq_num, int level);
>   void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
>   void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 179741ff79..77ce17d8a4 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -316,12 +316,6 @@ static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
>                                                device, intx, level);
>   }
>   
> -static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
> -                                         uint8_t irq)
> -{
> -    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link, irq);
> -}
> -
>   static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
>                                    uint32_t msi_data)
>   {
> diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c
> index 15f3921a76..743967623f 100644
> --- a/stubs/xen-hw-stub.c
> +++ b/stubs/xen-hw-stub.c
> @@ -23,6 +23,11 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
>   {
>   }
>   
> +int xen_set_pci_link_route(uint8_t link, uint8_t irq)
> +{
> +    return -1;
> +}
> +
>   void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
>   {
>   }

Applied to my trivial-patches branch.

Thanks,
Laurent


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

* Re: [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it
  2022-06-26  9:46 ` [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it Bernhard Beschow
  2022-06-26 12:59   ` Michael S. Tsirkin
  2022-06-27  8:52   ` Durrant, Paul
@ 2022-06-28 22:25   ` Laurent Vivier
  2 siblings, 0 replies; 10+ messages in thread
From: Laurent Vivier @ 2022-06-28 22:25 UTC (permalink / raw)
  To: Bernhard Beschow, qemu-devel
  Cc: Richard Henderson, xen-devel, qemu-trivial, Eduardo Habkost,
	Marcel Apfelbaum, Stefano Stabellini, Paolo Bonzini,
	Michael S. Tsirkin, Anthony Perard, Paul Durrant

Le 26/06/2022 à 11:46, Bernhard Beschow a écrit :
> xen_piix_pci_write_config_client() is implemented in the xen sub tree and
> uses PIIX constants internally, thus creating a direct dependency on
> PIIX. Now that xen_set_pci_link_route() is stubbable, the logic of
> xen_piix_pci_write_config_client() can be moved to PIIX which resolves
> the dependency.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
>   hw/i386/xen/xen-hvm.c | 18 ------------------
>   hw/isa/piix3.c        | 15 ++++++++++++++-
>   include/hw/xen/xen.h  |  1 -
>   stubs/xen-hw-stub.c   |  4 ----
>   4 files changed, 14 insertions(+), 24 deletions(-)
> 
> diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
> index 204fda7949..e4293d6d66 100644
> --- a/hw/i386/xen/xen-hvm.c
> +++ b/hw/i386/xen/xen-hvm.c
> @@ -15,7 +15,6 @@
>   #include "hw/pci/pci.h"
>   #include "hw/pci/pci_host.h"
>   #include "hw/i386/pc.h"
> -#include "hw/southbridge/piix.h"
>   #include "hw/irq.h"
>   #include "hw/hw.h"
>   #include "hw/i386/apic-msidef.h"
> @@ -149,23 +148,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int level)
>                              irq_num & 3, level);
>   }
>   
> -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
> -{
> -    int i;
> -
> -    /* Scan for updates to PCI link routes (0x60-0x63). */
> -    for (i = 0; i < len; i++) {
> -        uint8_t v = (val >> (8 * i)) & 0xff;
> -        if (v & 0x80) {
> -            v = 0;
> -        }
> -        v &= 0xf;
> -        if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
> -            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
> -        }
> -    }
> -}
> -
>   int xen_set_pci_link_route(uint8_t link, uint8_t irq)
>   {
>       return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, irq);
> diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
> index 6388558f92..48f9ab1096 100644
> --- a/hw/isa/piix3.c
> +++ b/hw/isa/piix3.c
> @@ -138,7 +138,20 @@ static void piix3_write_config(PCIDevice *dev,
>   static void piix3_write_config_xen(PCIDevice *dev,
>                                      uint32_t address, uint32_t val, int len)
>   {
> -    xen_piix_pci_write_config_client(address, val, len);
> +    int i;
> +
> +    /* Scan for updates to PCI link routes (0x60-0x63). */
> +    for (i = 0; i < len; i++) {
> +        uint8_t v = (val >> (8 * i)) & 0xff;
> +        if (v & 0x80) {
> +            v = 0;
> +        }
> +        v &= 0xf;
> +        if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) {
> +            xen_set_pci_link_route(address + i - PIIX_PIRQCA, v);
> +        }
> +    }
> +
>       piix3_write_config(dev, address, val, len);
>   }
>   
> diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
> index 13bffaef53..afdf9c436a 100644
> --- a/include/hw/xen/xen.h
> +++ b/include/hw/xen/xen.h
> @@ -23,7 +23,6 @@ extern bool xen_domid_restrict;
>   int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
>   int xen_set_pci_link_route(uint8_t link, uint8_t irq);
>   void xen_piix3_set_irq(void *opaque, int irq_num, int level);
> -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
>   void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
>   int xen_is_pirq_msi(uint32_t msi_data);
>   
> diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c
> index 743967623f..34a22f2ad7 100644
> --- a/stubs/xen-hw-stub.c
> +++ b/stubs/xen-hw-stub.c
> @@ -19,10 +19,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int level)
>   {
>   }
>   
> -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
> -{
> -}
> -
>   int xen_set_pci_link_route(uint8_t link, uint8_t irq)
>   {
>       return -1;

Applied to my trivial-patches branch.

Thanks,
Laurent



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

end of thread, other threads:[~2022-06-28 22:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-26  9:46 [PATCH 0/2] Decouple Xen-HVM from PIIX Bernhard Beschow
2022-06-26  9:46 ` [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route() Bernhard Beschow
2022-06-27  8:52   ` Durrant, Paul
2022-06-28 22:24   ` Laurent Vivier
2022-06-26  9:46 ` [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it Bernhard Beschow
2022-06-26 12:59   ` Michael S. Tsirkin
2022-06-27  8:52   ` Durrant, Paul
2022-06-28 22:25   ` Laurent Vivier
2022-06-28 20:58 ` [PATCH 0/2] Decouple Xen-HVM from PIIX B
2022-06-28 21:09   ` Stefano Stabellini

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.