peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0003-xen-create-wrappers-for-all-other-uses-of-xc_hvm_XXX.patch

Daniel P. Berrange 1e96c6
From 8a69b7e617ce170295aaff4616713c11ef2d998c Mon Sep 17 00:00:00 2001
Daniel P. Berrange 1e96c6
From: Paul Durrant <paul.durrant@citrix.com>
Daniel P. Berrange 1e96c6
Date: Tue, 7 Mar 2017 10:55:32 +0000
Daniel P. Berrange 1e96c6
Subject: [PATCH 3/6] xen: create wrappers for all other uses of xc_hvm_XXX()
Daniel P. Berrange 1e96c6
 functions
Daniel P. Berrange 1e96c6
Daniel P. Berrange 1e96c6
This patch creates inline wrapper functions in xen_common.h for all open
Daniel P. Berrange 1e96c6
coded calls to xc_hvm_XXX() functions outside of xen_common.h so that use
Daniel P. Berrange 1e96c6
of xen_xc can be made implicit. This again is in preparation for the move
Daniel P. Berrange 1e96c6
to using libxendevicemodel.
Daniel P. Berrange 1e96c6
Daniel P. Berrange 1e96c6
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Daniel P. Berrange 1e96c6
Reviewed-by: Anthony Perard <anthony.perard@citrix.com>
Daniel P. Berrange 1e96c6
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Daniel P. Berrange 1e96c6
(cherry picked from commit 8f25e7544150abd4bfd4ef35fe152c049b5ea5e7)
Daniel P. Berrange 1e96c6
---
Daniel P. Berrange 1e96c6
 hw/i386/xen/xen_platform.c  |  2 +-
Daniel P. Berrange 1e96c6
 include/hw/xen/xen_common.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
Daniel P. Berrange 1e96c6
 xen-hvm.c                   | 27 +++++++++++++--------------
Daniel P. Berrange 1e96c6
 3 files changed, 58 insertions(+), 15 deletions(-)
Daniel P. Berrange 1e96c6
Daniel P. Berrange 1e96c6
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
Daniel P. Berrange 1e96c6
index 6010f35266..1419fc96d2 100644
Daniel P. Berrange 1e96c6
--- a/hw/i386/xen/xen_platform.c
Daniel P. Berrange 1e96c6
+++ b/hw/i386/xen/xen_platform.c
Daniel P. Berrange 1e96c6
@@ -195,7 +195,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
Daniel P. Berrange 1e96c6
     case 0: /* Platform flags */ {
Daniel P. Berrange 1e96c6
         hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
Daniel P. Berrange 1e96c6
             HVMMEM_ram_ro : HVMMEM_ram_rw;
Daniel P. Berrange 1e96c6
-        if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, 0xc0, 0x40)) {
Daniel P. Berrange 1e96c6
+        if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
Daniel P. Berrange 1e96c6
             DPRINTF("unable to change ro/rw state of ROM memory area!\n");
Daniel P. Berrange 1e96c6
         } else {
Daniel P. Berrange 1e96c6
             s->flags = val & PFFLAG_ROM_LOCK;
Daniel P. Berrange 1e96c6
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
Daniel P. Berrange 1e96c6
index 1e08b98617..31cf25f846 100644
Daniel P. Berrange 1e96c6
--- a/include/hw/xen/xen_common.h
Daniel P. Berrange 1e96c6
+++ b/include/hw/xen/xen_common.h
Daniel P. Berrange 1e96c6
@@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
Daniel P. Berrange 1e96c6
  * We don't support Xen prior to 4.2.0.
Daniel P. Berrange 1e96c6
  */
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
+static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
Daniel P. Berrange 1e96c6
+                                   uint64_t first_pfn, uint32_t nr)
Daniel P. Berrange 1e96c6
+{
Daniel P. Berrange 1e96c6
+    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
Daniel P. Berrange 1e96c6
+}
Daniel P. Berrange 1e96c6
+
Daniel P. Berrange 1e96c6
+static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
Daniel P. Berrange 1e96c6
+                                         uint8_t bus, uint8_t device,
Daniel P. Berrange 1e96c6
+                                         uint8_t intx, unsigned int level)
Daniel P. Berrange 1e96c6
+{
Daniel P. Berrange 1e96c6
+    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
Daniel P. Berrange 1e96c6
+                                     intx, level);
Daniel P. Berrange 1e96c6
+}
Daniel P. Berrange 1e96c6
+
Daniel P. Berrange 1e96c6
+static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
Daniel P. Berrange 1e96c6
+                                         uint8_t irq)
Daniel P. Berrange 1e96c6
+{
Daniel P. Berrange 1e96c6
+    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
Daniel P. Berrange 1e96c6
+}
Daniel P. Berrange 1e96c6
+
Daniel P. Berrange 1e96c6
+static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
Daniel P. Berrange 1e96c6
+                                 uint32_t msi_data)
Daniel P. Berrange 1e96c6
+{
Daniel P. Berrange 1e96c6
+    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
Daniel P. Berrange 1e96c6
+}
Daniel P. Berrange 1e96c6
+
Daniel P. Berrange 1e96c6
+static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
Daniel P. Berrange 1e96c6
+                                        unsigned int level)
Daniel P. Berrange 1e96c6
+{
Daniel P. Berrange 1e96c6
+    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
Daniel P. Berrange 1e96c6
+}
Daniel P. Berrange 1e96c6
+
Daniel P. Berrange 1e96c6
+static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
Daniel P. Berrange 1e96c6
+                                       uint32_t nr, unsigned long *bitmap)
Daniel P. Berrange 1e96c6
+{
Daniel P. Berrange 1e96c6
+    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
Daniel P. Berrange 1e96c6
+}
Daniel P. Berrange 1e96c6
+
Daniel P. Berrange 1e96c6
+static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
Daniel P. Berrange 1e96c6
+                                      uint32_t nr)
Daniel P. Berrange 1e96c6
+{
Daniel P. Berrange 1e96c6
+    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
Daniel P. Berrange 1e96c6
+}
Daniel P. Berrange 1e96c6
+
Daniel P. Berrange 1e96c6
 /* Xen 4.2 through 4.6 */
Daniel P. Berrange 1e96c6
 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
diff --git a/xen-hvm.c b/xen-hvm.c
Daniel P. Berrange 1e96c6
index edf4983702..4b928cfb30 100644
Daniel P. Berrange 1e96c6
--- a/xen-hvm.c
Daniel P. Berrange 1e96c6
+++ b/xen-hvm.c
Daniel P. Berrange 1e96c6
@@ -125,8 +125,8 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
Daniel P. Berrange 1e96c6
 {
Daniel P. Berrange 1e96c6
-    xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2,
Daniel P. Berrange 1e96c6
-                              irq_num & 3, level);
Daniel P. Berrange 1e96c6
+    xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2,
Daniel P. Berrange 1e96c6
+                           irq_num & 3, level);
Daniel P. Berrange 1e96c6
 }
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
Daniel P. Berrange 1e96c6
@@ -141,7 +141,7 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
Daniel P. Berrange 1e96c6
         }
Daniel P. Berrange 1e96c6
         v &= 0xf;
Daniel P. Berrange 1e96c6
         if (((address + i) >= 0x60) && ((address + i) <= 0x63)) {
Daniel P. Berrange 1e96c6
-            xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v);
Daniel P. Berrange 1e96c6
+            xen_set_pci_link_route(xen_domid, address + i - 0x60, v);
Daniel P. Berrange 1e96c6
         }
Daniel P. Berrange 1e96c6
     }
Daniel P. Berrange 1e96c6
 }
Daniel P. Berrange 1e96c6
@@ -156,7 +156,7 @@ int xen_is_pirq_msi(uint32_t msi_data)
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
Daniel P. Berrange 1e96c6
 {
Daniel P. Berrange 1e96c6
-    xc_hvm_inject_msi(xen_xc, xen_domid, addr, data);
Daniel P. Berrange 1e96c6
+    xen_inject_msi(xen_domid, addr, data);
Daniel P. Berrange 1e96c6
 }
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
 static void xen_suspend_notifier(Notifier *notifier, void *data)
Daniel P. Berrange 1e96c6
@@ -168,7 +168,7 @@ static void xen_suspend_notifier(Notifier *notifier, void *data)
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
 static void xen_set_irq(void *opaque, int irq, int level)
Daniel P. Berrange 1e96c6
 {
Daniel P. Berrange 1e96c6
-    xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
Daniel P. Berrange 1e96c6
+    xen_set_isa_irq_level(xen_domid, irq, level);
Daniel P. Berrange 1e96c6
 }
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
 qemu_irq *xen_interrupt_controller_init(void)
Daniel P. Berrange 1e96c6
@@ -481,10 +481,10 @@ static void xen_set_memory(struct MemoryListener *listener,
Daniel P. Berrange 1e96c6
                                section->mr, section->offset_within_region);
Daniel P. Berrange 1e96c6
         } else {
Daniel P. Berrange 1e96c6
             mem_type = HVMMEM_ram_ro;
Daniel P. Berrange 1e96c6
-            if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type,
Daniel P. Berrange 1e96c6
-                                    start_addr >> TARGET_PAGE_BITS,
Daniel P. Berrange 1e96c6
-                                    size >> TARGET_PAGE_BITS)) {
Daniel P. Berrange 1e96c6
-                DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n",
Daniel P. Berrange 1e96c6
+            if (xen_set_mem_type(xen_domid, mem_type,
Daniel P. Berrange 1e96c6
+                                 start_addr >> TARGET_PAGE_BITS,
Daniel P. Berrange 1e96c6
+                                 size >> TARGET_PAGE_BITS)) {
Daniel P. Berrange 1e96c6
+                DPRINTF("xen_set_mem_type error, addr: "TARGET_FMT_plx"\n",
Daniel P. Berrange 1e96c6
                         start_addr);
Daniel P. Berrange 1e96c6
             }
Daniel P. Berrange 1e96c6
         }
Daniel P. Berrange 1e96c6
@@ -586,9 +586,8 @@ static void xen_sync_dirty_bitmap(XenIOState *state,
Daniel P. Berrange 1e96c6
         return;
Daniel P. Berrange 1e96c6
     }
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
-    rc = xc_hvm_track_dirty_vram(xen_xc, xen_domid,
Daniel P. Berrange 1e96c6
-                                 start_addr >> TARGET_PAGE_BITS, npages,
Daniel P. Berrange 1e96c6
-                                 bitmap);
Daniel P. Berrange 1e96c6
+    rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS,
Daniel P. Berrange 1e96c6
+                              npages, bitmap);
Daniel P. Berrange 1e96c6
     if (rc < 0) {
Daniel P. Berrange 1e96c6
 #ifndef ENODATA
Daniel P. Berrange 1e96c6
 #define ENODATA  ENOENT
Daniel P. Berrange 1e96c6
@@ -634,7 +633,7 @@ static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section,
Daniel P. Berrange 1e96c6
     if (old & ~new & (1 << DIRTY_MEMORY_VGA)) {
Daniel P. Berrange 1e96c6
         state->log_for_dirtybit = NULL;
Daniel P. Berrange 1e96c6
         /* Disable dirty bit tracking */
Daniel P. Berrange 1e96c6
-        xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL);
Daniel P. Berrange 1e96c6
+        xen_track_dirty_vram(xen_domid, 0, 0, NULL);
Daniel P. Berrange 1e96c6
     }
Daniel P. Berrange 1e96c6
 }
Daniel P. Berrange 1e96c6
 
Daniel P. Berrange 1e96c6
@@ -1403,7 +1402,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
Daniel P. Berrange 1e96c6
         start_pfn = start >> TARGET_PAGE_BITS;
Daniel P. Berrange 1e96c6
         nb_pages = ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
Daniel P. Berrange 1e96c6
             - start_pfn;
Daniel P. Berrange 1e96c6
-        rc = xc_hvm_modified_memory(xen_xc, xen_domid, start_pfn, nb_pages);
Daniel P. Berrange 1e96c6
+        rc = xen_modified_memory(xen_domid, start_pfn, nb_pages);
Daniel P. Berrange 1e96c6
         if (rc) {
Daniel P. Berrange 1e96c6
             fprintf(stderr,
Daniel P. Berrange 1e96c6
                     "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
Daniel P. Berrange 1e96c6
-- 
Daniel P. Berrange 1e96c6
2.13.0
Daniel P. Berrange 1e96c6