From patchwork Wed Aug 22 12:31:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 179384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6057F2C0084 for ; Thu, 23 Aug 2012 05:31:48 +1000 (EST) Received: from localhost ([::1]:42968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4G62-0003yD-Is for incoming@patchwork.ozlabs.org; Wed, 22 Aug 2012 14:56:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4G5H-0002rF-FP for qemu-devel@nongnu.org; Wed, 22 Aug 2012 14:55:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4G5F-0007ba-Oi for qemu-devel@nongnu.org; Wed, 22 Aug 2012 14:55:19 -0400 Received: from smtp.citrix.com ([66.165.176.89]:13432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4G5F-0007FA-G8 for qemu-devel@nongnu.org; Wed, 22 Aug 2012 14:55:17 -0400 X-IronPort-AV: E=Sophos;i="4.80,809,1344225600"; d="scan'208";a="35484799" Received: from ftlpmailmx01.citrite.net ([10.13.107.65]) by FTLPIPO01.CITRIX.COM with ESMTP/TLS/RC4-MD5; 22 Aug 2012 14:55:16 -0400 Received: from meteora.cam.xci-test.com (10.80.248.22) by smtprelay.citrix.com (10.13.107.65) with Microsoft SMTP Server id 8.3.213.0; Wed, 22 Aug 2012 14:55:16 -0400 From: Julien Grall To: qemu-devel@nongnu.org Date: Wed, 22 Aug 2012 13:31:55 +0100 Message-ID: <8747cb48d50a10784df56904db29ca8b6e8c5d80.1345552068.git.julien.grall@citrix.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: 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 Cc: Julien Grall , christian.limpach@gmail.com, Stefano.Stabellini@eu.citrix.com, xen-devel@lists.xen.org Subject: [Qemu-devel] [XEN][RFC PATCH V2 09/17] xc: Add the hypercall for multiple servers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch add 5 hypercalls to register server, io range and PCI. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- tools/libxc/xc_domain.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++ tools/libxc/xenctrl.h | 21 ++++++ 2 files changed, 176 insertions(+), 0 deletions(-) diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index d98e68b..cb186c1 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -1514,6 +1514,161 @@ int xc_domain_set_virq_handler(xc_interface *xch, uint32_t domid, int virq) return do_domctl(xch, &domctl); } +ioservid_or_error_t xc_hvm_register_ioreq_server(xc_interface *xch, + domid_t dom) +{ + DECLARE_HYPERCALL; + DECLARE_HYPERCALL_BUFFER(xen_hvm_register_ioreq_server_t, arg); + ioservid_or_error_t rc = -1; + + arg = xc_hypercall_buffer_alloc(xch, arg, sizeof (*arg)); + if ( !arg ) + { + PERROR("Could not allocate memory for xc_hvm_register_ioreq_server hypercall"); + goto out; + } + + hypercall.op = __HYPERVISOR_hvm_op; + hypercall.arg[0] = HVMOP_register_ioreq_server; + hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg); + + arg->domid = dom; + rc = do_xen_hypercall(xch, &hypercall); + if ( !rc ) + rc = arg->id; + + xc_hypercall_buffer_free(xch, arg); +out: + return rc; +} + +evtchn_port_or_error_t xc_hvm_get_ioreq_server_buf_channel(xc_interface *xch, + domid_t dom, + ioservid_t id) +{ + DECLARE_HYPERCALL; + DECLARE_HYPERCALL_BUFFER(xen_hvm_get_ioreq_server_buf_channel_t, arg); + evtchn_port_or_error_t rc = -1; + + arg = xc_hypercall_buffer_alloc(xch, arg, sizeof (*arg)); + if ( !arg ) + { + PERROR("Could not allocate memory for xc_hvm_get_ioreq_servr_buf_channel"); + goto out; + } + + hypercall.op = __HYPERVISOR_hvm_op; + hypercall.arg[0] = HVMOP_get_ioreq_server_buf_channel; + hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg); + + arg->domid = dom; + arg->id = id; + rc = do_xen_hypercall(xch, &hypercall); + + if ( !rc ) + rc = arg->channel; + + xc_hypercall_buffer_free(xch, arg); + +out: + return rc; +} + +int xc_hvm_map_io_range_to_ioreq_server(xc_interface *xch, domid_t dom, + ioservid_t id, int is_mmio, + uint64_t start, uint64_t end) +{ + DECLARE_HYPERCALL; + DECLARE_HYPERCALL_BUFFER(xen_hvm_map_io_range_to_ioreq_server_t, arg); + int rc = -1; + + arg = xc_hypercall_buffer_alloc(xch, arg, sizeof (*arg)); + if ( !arg ) + { + PERROR("Could not allocate memory for xc_hvm_map_io_range_to_ioreq_server hypercall"); + goto out; + } + + hypercall.op = __HYPERVISOR_hvm_op; + hypercall.arg[0] = HVMOP_map_io_range_to_ioreq_server; + hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg); + + arg->domid = dom; + arg->id = id; + arg->is_mmio = is_mmio; + arg->s = start; + arg->e = end; + + rc = do_xen_hypercall(xch, &hypercall); + + xc_hypercall_buffer_free(xch, arg); +out: + return rc; +} + +int xc_hvm_unmap_io_range_from_ioreq_server(xc_interface *xch, domid_t dom, + ioservid_t id, int is_mmio, + uint64_t addr) +{ + DECLARE_HYPERCALL; + DECLARE_HYPERCALL_BUFFER(xen_hvm_unmap_io_range_from_ioreq_server_t, arg); + int rc = -1; + + arg = xc_hypercall_buffer_alloc(xch, arg, sizeof (*arg)); + if ( !arg ) + { + PERROR("Could not allocate memory for xc_hvm_unmap_io_range_from_ioreq_server hypercall"); + goto out; + } + + hypercall.op = __HYPERVISOR_hvm_op; + hypercall.arg[0] = HVMOP_unmap_io_range_from_ioreq_server; + hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg); + + arg->domid = dom; + arg->id = id; + arg->is_mmio = is_mmio; + arg->addr = addr; + rc = do_xen_hypercall(xch, &hypercall); + + xc_hypercall_buffer_free(xch, arg); +out: + return rc; +} + +int xc_hvm_register_pcidev(xc_interface *xch, domid_t dom, ioservid_t id, + uint8_t domain, uint8_t bus, uint8_t device, + uint8_t function) +{ + DECLARE_HYPERCALL; + DECLARE_HYPERCALL_BUFFER(xen_hvm_register_pcidev_t, arg); + int rc = -1; + + arg = xc_hypercall_buffer_alloc(xch, arg, sizeof (*arg)); + if ( !arg ) + { + PERROR("Could not allocate memory for xc_hvm_create_pci hypercall"); + goto out; + } + + hypercall.op = __HYPERVISOR_hvm_op; + hypercall.arg[0] = HVMOP_register_pcidev; + hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg); + + arg->domid = dom; + arg->id = id; + arg->domain = domain; + arg->bus = bus; + arg->device = device; + arg->function = function; + rc = do_xen_hypercall(xch, &hypercall); + + xc_hypercall_buffer_free(xch, arg); +out: + return rc; +} + + /* * Local variables: * mode: C diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index b7741ca..65a950e 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -1659,6 +1659,27 @@ void xc_clear_last_error(xc_interface *xch); int xc_set_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned long value); int xc_get_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned long *value); +/* A IO server identifier is guaranteed to fit in 31 bits. */ +typedef int ioservid_or_error_t; + +ioservid_or_error_t xc_hvm_register_ioreq_server(xc_interface *xch, + domid_t dom); +evtchn_port_or_error_t xc_hvm_get_ioreq_server_buf_channel(xc_interface *xch, + domid_t dom, + ioservid_t id); +int xc_hvm_map_io_range_to_ioreq_server(xc_interface *xch, domid_t dom, + ioservid_t id, int is_mmio, + uint64_t start, uint64_t end); +int xc_hvm_unmap_io_range_from_ioreq_server(xc_interface *xch, domid_t dom, + ioservid_t id, int is_mmio, + uint64_t addr); +/* + * Register a PCI device + */ +int xc_hvm_register_pcidev(xc_interface *xch, domid_t dom, unsigned int id, + uint8_t domain, uint8_t bus, uint8_t device, + uint8_t function); + /* IA64 specific, nvram save */ int xc_ia64_save_to_nvram(xc_interface *xch, uint32_t dom);