From: Stefano Stabellini <sstabellini@kernel.org>
To: peter.maydell@linaro.org
Cc: stefanha@gmail.com, sstabellini@kernel.org, stefanha@redhat.com,
anthony.perard@citrix.com, xen-devel@lists.xenproject.org,
qemu-devel@nongnu.org, Paul Durrant <paul.durrant@citrix.com>
Subject: [Qemu-devel] [PATCH 03/21] xen: create wrappers for all other uses of xc_hvm_XXX() functions
Date: Tue, 25 Apr 2017 11:34:55 -0700 [thread overview]
Message-ID: <1493145313-31311-3-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <1493145313-31311-1-git-send-email-sstabellini@kernel.org>
From: Paul Durrant <paul.durrant@citrix.com>
This patch creates inline wrapper functions in xen_common.h for all open
coded calls to xc_hvm_XXX() functions outside of xen_common.h so that use
of xen_xc can be made implicit. This again is in preparation for the move
to using libxendevicemodel.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Anthony Perard <anthony.perard@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
hw/i386/xen/xen_platform.c | 2 +-
include/hw/xen/xen_common.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
xen-hvm.c | 27 +++++++++++++--------------
3 files changed, 58 insertions(+), 15 deletions(-)
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 6010f35..1419fc9 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -195,7 +195,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
case 0: /* Platform flags */ {
hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
HVMMEM_ram_ro : HVMMEM_ram_rw;
- if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, 0xc0, 0x40)) {
+ if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
DPRINTF("unable to change ro/rw state of ROM memory area!\n");
} else {
s->flags = val & PFFLAG_ROM_LOCK;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 1e08b98..31cf25f 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
* We don't support Xen prior to 4.2.0.
*/
+static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
+ uint64_t first_pfn, uint32_t nr)
+{
+ return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
+}
+
+static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
+ uint8_t bus, uint8_t device,
+ uint8_t intx, unsigned int level)
+{
+ return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
+ intx, level);
+}
+
+static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
+ uint8_t irq)
+{
+ return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
+}
+
+static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
+ uint32_t msi_data)
+{
+ return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
+}
+
+static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
+ unsigned int level)
+{
+ return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
+}
+
+static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
+ uint32_t nr, unsigned long *bitmap)
+{
+ return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
+}
+
+static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
+ uint32_t nr)
+{
+ return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
+}
+
/* Xen 4.2 through 4.6 */
#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
diff --git a/xen-hvm.c b/xen-hvm.c
index edf4983..4b928cf 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -125,8 +125,8 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
void xen_piix3_set_irq(void *opaque, int irq_num, int level)
{
- xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2,
- irq_num & 3, level);
+ xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2,
+ irq_num & 3, level);
}
void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
@@ -141,7 +141,7 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
}
v &= 0xf;
if (((address + i) >= 0x60) && ((address + i) <= 0x63)) {
- xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v);
+ xen_set_pci_link_route(xen_domid, address + i - 0x60, v);
}
}
}
@@ -156,7 +156,7 @@ int xen_is_pirq_msi(uint32_t msi_data)
void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
{
- xc_hvm_inject_msi(xen_xc, xen_domid, addr, data);
+ xen_inject_msi(xen_domid, addr, data);
}
static void xen_suspend_notifier(Notifier *notifier, void *data)
@@ -168,7 +168,7 @@ static void xen_suspend_notifier(Notifier *notifier, void *data)
static void xen_set_irq(void *opaque, int irq, int level)
{
- xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
+ xen_set_isa_irq_level(xen_domid, irq, level);
}
qemu_irq *xen_interrupt_controller_init(void)
@@ -481,10 +481,10 @@ static void xen_set_memory(struct MemoryListener *listener,
section->mr, section->offset_within_region);
} else {
mem_type = HVMMEM_ram_ro;
- if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type,
- start_addr >> TARGET_PAGE_BITS,
- size >> TARGET_PAGE_BITS)) {
- DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n",
+ if (xen_set_mem_type(xen_domid, mem_type,
+ start_addr >> TARGET_PAGE_BITS,
+ size >> TARGET_PAGE_BITS)) {
+ DPRINTF("xen_set_mem_type error, addr: "TARGET_FMT_plx"\n",
start_addr);
}
}
@@ -586,9 +586,8 @@ static void xen_sync_dirty_bitmap(XenIOState *state,
return;
}
- rc = xc_hvm_track_dirty_vram(xen_xc, xen_domid,
- start_addr >> TARGET_PAGE_BITS, npages,
- bitmap);
+ rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS,
+ npages, bitmap);
if (rc < 0) {
#ifndef ENODATA
#define ENODATA ENOENT
@@ -634,7 +633,7 @@ static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section,
if (old & ~new & (1 << DIRTY_MEMORY_VGA)) {
state->log_for_dirtybit = NULL;
/* Disable dirty bit tracking */
- xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL);
+ xen_track_dirty_vram(xen_domid, 0, 0, NULL);
}
}
@@ -1403,7 +1402,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
start_pfn = start >> TARGET_PAGE_BITS;
nb_pages = ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
- start_pfn;
- rc = xc_hvm_modified_memory(xen_xc, xen_domid, start_pfn, nb_pages);
+ rc = xen_modified_memory(xen_domid, start_pfn, nb_pages);
if (rc) {
fprintf(stderr,
"%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
--
1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: Stefano Stabellini <sstabellini@kernel.org>
To: peter.maydell@linaro.org
Cc: sstabellini@kernel.org, stefanha@gmail.com,
qemu-devel@nongnu.org, Paul Durrant <paul.durrant@citrix.com>,
stefanha@redhat.com, anthony.perard@citrix.com,
xen-devel@lists.xenproject.org
Subject: [PATCH 03/21] xen: create wrappers for all other uses of xc_hvm_XXX() functions
Date: Tue, 25 Apr 2017 11:34:55 -0700 [thread overview]
Message-ID: <1493145313-31311-3-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <1493145313-31311-1-git-send-email-sstabellini@kernel.org>
From: Paul Durrant <paul.durrant@citrix.com>
This patch creates inline wrapper functions in xen_common.h for all open
coded calls to xc_hvm_XXX() functions outside of xen_common.h so that use
of xen_xc can be made implicit. This again is in preparation for the move
to using libxendevicemodel.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Anthony Perard <anthony.perard@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
hw/i386/xen/xen_platform.c | 2 +-
include/hw/xen/xen_common.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
xen-hvm.c | 27 +++++++++++++--------------
3 files changed, 58 insertions(+), 15 deletions(-)
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 6010f35..1419fc9 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -195,7 +195,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
case 0: /* Platform flags */ {
hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
HVMMEM_ram_ro : HVMMEM_ram_rw;
- if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, 0xc0, 0x40)) {
+ if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
DPRINTF("unable to change ro/rw state of ROM memory area!\n");
} else {
s->flags = val & PFFLAG_ROM_LOCK;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 1e08b98..31cf25f 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
* We don't support Xen prior to 4.2.0.
*/
+static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
+ uint64_t first_pfn, uint32_t nr)
+{
+ return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
+}
+
+static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
+ uint8_t bus, uint8_t device,
+ uint8_t intx, unsigned int level)
+{
+ return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
+ intx, level);
+}
+
+static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
+ uint8_t irq)
+{
+ return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
+}
+
+static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
+ uint32_t msi_data)
+{
+ return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
+}
+
+static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
+ unsigned int level)
+{
+ return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
+}
+
+static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
+ uint32_t nr, unsigned long *bitmap)
+{
+ return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
+}
+
+static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
+ uint32_t nr)
+{
+ return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
+}
+
/* Xen 4.2 through 4.6 */
#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
diff --git a/xen-hvm.c b/xen-hvm.c
index edf4983..4b928cf 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -125,8 +125,8 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
void xen_piix3_set_irq(void *opaque, int irq_num, int level)
{
- xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2,
- irq_num & 3, level);
+ xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2,
+ irq_num & 3, level);
}
void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
@@ -141,7 +141,7 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
}
v &= 0xf;
if (((address + i) >= 0x60) && ((address + i) <= 0x63)) {
- xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v);
+ xen_set_pci_link_route(xen_domid, address + i - 0x60, v);
}
}
}
@@ -156,7 +156,7 @@ int xen_is_pirq_msi(uint32_t msi_data)
void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
{
- xc_hvm_inject_msi(xen_xc, xen_domid, addr, data);
+ xen_inject_msi(xen_domid, addr, data);
}
static void xen_suspend_notifier(Notifier *notifier, void *data)
@@ -168,7 +168,7 @@ static void xen_suspend_notifier(Notifier *notifier, void *data)
static void xen_set_irq(void *opaque, int irq, int level)
{
- xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
+ xen_set_isa_irq_level(xen_domid, irq, level);
}
qemu_irq *xen_interrupt_controller_init(void)
@@ -481,10 +481,10 @@ static void xen_set_memory(struct MemoryListener *listener,
section->mr, section->offset_within_region);
} else {
mem_type = HVMMEM_ram_ro;
- if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type,
- start_addr >> TARGET_PAGE_BITS,
- size >> TARGET_PAGE_BITS)) {
- DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n",
+ if (xen_set_mem_type(xen_domid, mem_type,
+ start_addr >> TARGET_PAGE_BITS,
+ size >> TARGET_PAGE_BITS)) {
+ DPRINTF("xen_set_mem_type error, addr: "TARGET_FMT_plx"\n",
start_addr);
}
}
@@ -586,9 +586,8 @@ static void xen_sync_dirty_bitmap(XenIOState *state,
return;
}
- rc = xc_hvm_track_dirty_vram(xen_xc, xen_domid,
- start_addr >> TARGET_PAGE_BITS, npages,
- bitmap);
+ rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS,
+ npages, bitmap);
if (rc < 0) {
#ifndef ENODATA
#define ENODATA ENOENT
@@ -634,7 +633,7 @@ static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section,
if (old & ~new & (1 << DIRTY_MEMORY_VGA)) {
state->log_for_dirtybit = NULL;
/* Disable dirty bit tracking */
- xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL);
+ xen_track_dirty_vram(xen_domid, 0, 0, NULL);
}
}
@@ -1403,7 +1402,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
start_pfn = start >> TARGET_PAGE_BITS;
nb_pages = ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
- start_pfn;
- rc = xc_hvm_modified_memory(xen_xc, xen_domid, start_pfn, nb_pages);
+ rc = xen_modified_memory(xen_domid, start_pfn, nb_pages);
if (rc) {
fprintf(stderr,
"%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-04-25 18:35 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 18:34 [Qemu-devel] [PULL 0/21] Please pull xen-20170421-v2-tag for 2.10 Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini
2017-04-25 18:34 ` [Qemu-devel] [PATCH 01/21] xen: make use of xen_xc implicit in xen_common.h inlines Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini
2017-04-25 18:34 ` [Qemu-devel] [PATCH 02/21] xen: rename xen_modified_memory() to xen_hvm_modified_memory() Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini [this message]
2017-04-25 18:34 ` [PATCH 03/21] xen: create wrappers for all other uses of xc_hvm_XXX() functions Stefano Stabellini
2017-04-25 18:34 ` [Qemu-devel] [PATCH 04/21] configure: detect presence of libxendevicemodel Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini
2017-04-25 18:34 ` [Qemu-devel] [PATCH 05/21] xen: use libxendevicemodel when available Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini
2017-04-25 18:34 ` [Qemu-devel] [PATCH 06/21] xen: use 5 digit xen versions Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini
2017-04-25 18:34 ` [Qemu-devel] [PATCH 07/21] xen: use libxendevice model to restrict operations Stefano Stabellini
2017-04-25 18:34 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 08/21] xen: additionally restrict xenforeignmemory operations Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 09/21] configure: use pkg-config for obtaining xen version Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2018-12-11 10:34 ` Peter Maydell
2018-12-11 10:34 ` [Qemu-devel] " Peter Maydell
2018-12-11 10:43 ` Daniel P. Berrangé
2018-12-11 10:43 ` Daniel P. Berrangé
2019-01-02 21:21 ` Stefano Stabellini
2019-01-02 21:21 ` [Qemu-devel] " Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 10/21] xen: import ring.h from xen Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-26 1:52 ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-04-26 1:52 ` Philippe Mathieu-Daudé
2017-04-25 18:35 ` [Qemu-devel] [PATCH 11/21] 9p: introduce a type for the 9p header Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 12/21] xen/9pfs: introduce Xen 9pfs backend Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 13/21] xen/9pfs: connect to the frontend Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 14/21] xen/9pfs: receive requests from " Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 15/21] xen/9pfs: implement in/out_iov_from_pdu and vmarshal/vunmarshal Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 16/21] xen/9pfs: send responses back to the frontend Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 17/21] xen/9pfs: build and register Xen 9pfs backend Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 18/21] add xen-9p-backend to MAINTAINERS under Xen Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 19/21] move xen-common.c to hw/xen/ Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 20/21] move xen-hvm.c to hw/i386/xen/ Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-25 18:35 ` [Qemu-devel] [PATCH 21/21] move xen-mapcache.c " Stefano Stabellini
2017-04-25 18:35 ` Stefano Stabellini
2017-04-26 10:39 ` [Qemu-devel] [PULL 0/21] Please pull xen-20170421-v2-tag for 2.10 Peter Maydell
2017-04-26 10:39 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493145313-31311-3-git-send-email-sstabellini@kernel.org \
--to=sstabellini@kernel.org \
--cc=anthony.perard@citrix.com \
--cc=paul.durrant@citrix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.