From nobody Mon Feb 9 09:09:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488453060138882.5295432482413; Thu, 2 Mar 2017 03:11:00 -0800 (PST) Received: from localhost ([::1]:51580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjOdM-0003c2-PV for importer@patchew.org; Thu, 02 Mar 2017 06:10:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjOcN-0003ak-O9 for qemu-devel@nongnu.org; Thu, 02 Mar 2017 06:09:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjOcK-0005PD-FF for qemu-devel@nongnu.org; Thu, 02 Mar 2017 06:09:55 -0500 Received: from smtp.citrix.com ([66.165.176.89]:53406) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjOcK-0005Oc-7e for qemu-devel@nongnu.org; Thu, 02 Mar 2017 06:09:52 -0500 X-IronPort-AV: E=Sophos;i="5.35,230,1484006400"; d="scan'208";a="410838436" From: Paul Durrant To: , Date: Thu, 2 Mar 2017 11:09:44 +0000 Message-ID: <1488452986-24501-4-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1488452986-24501-1-git-send-email-paul.durrant@citrix.com> References: <1488452986-24501-1-git-send-email-paul.durrant@citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Subject: [Qemu-devel] [PATCH v2 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Eduardo Habkost , "Michael S. Tsirkin" , Paul Durrant , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Anthony Perard --- Cc: Stefano Stabellini Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: "Michael S. Tsirkin" --- 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 =3D (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 =3D 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. */ =20 +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 =20 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_n= um) =20 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); } =20 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 &=3D 0xf; if (((address + i) >=3D 0x60) && ((address + i) <=3D 0x63)) { - xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x6= 0, 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) =20 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); } =20 static void xen_suspend_notifier(Notifier *notifier, void *data) @@ -168,7 +168,7 @@ static void xen_suspend_notifier(Notifier *notifier, vo= id *data) =20 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); } =20 qemu_irq *xen_interrupt_controller_init(void) @@ -481,10 +481,10 @@ static void xen_set_memory(struct MemoryListener *lis= tener, section->mr, section->offset_within_region); } else { mem_type =3D 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; } =20 - rc =3D xc_hvm_track_dirty_vram(xen_xc, xen_domid, - start_addr >> TARGET_PAGE_BITS, npages, - bitmap); + rc =3D 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, Memo= ryRegionSection *section, if (old & ~new & (1 << DIRTY_MEMORY_VGA)) { state->log_for_dirtybit =3D 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); } } =20 @@ -1403,7 +1402,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_ad= dr_t length) start_pfn =3D start >> TARGET_PAGE_BITS; nb_pages =3D ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PA= GE_BITS) - start_pfn; - rc =3D xc_hvm_modified_memory(xen_xc, xen_domid, start_pfn, nb_pag= es); + rc =3D 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", --=20 2.1.4