From: Tiejun Chen Subject: [v3][PATCH 09/16] tools/libxc: Expose new hypercall xc_reserved_device_memory_map Date: Thu, 11 Jun 2015 09:15:18 +0800 Message-ID: <1433985325-16676-10-git-send-email-tiejun.chen@intel.com> References: <1433985325-16676-1-git-send-email-tiejun.chen@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1433985325-16676-1-git-send-email-tiejun.chen@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: jbeulich@suse.com, tim@xen.org, andrew.cooper3@citrix.com, kevin.tian@intel.com, yang.z.zhang@intel.com, wei.liu2@citrix.com, ian.campbell@citrix.com, Ian.Jackson@eu.citrix.com, stefano.stabellini@citrix.com Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org We will introduce the hypercall xc_reserved_device_memory_map approach to libxc. This helps us get rdm entry info according to different parameters. If flag == PCI_DEV_RDM_ALL, all entries should be exposed. Or we just expose that rdm entry specific to a SBDF. Signed-off-by: Tiejun Chen --- tools/libxc/include/xenctrl.h | 8 ++++++++ tools/libxc/xc_domain.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 50fa9e7..6c01362 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1326,6 +1326,14 @@ int xc_domain_set_memory_map(xc_interface *xch, int xc_get_machine_memory_map(xc_interface *xch, struct e820entry entries[], uint32_t max_entries); + +int xc_reserved_device_memory_map(xc_interface *xch, + uint32_t flag, + uint16_t seg, + uint8_t bus, + uint8_t devfn, + struct xen_reserved_device_memory entries[], + uint32_t *max_entries); #endif int xc_domain_set_time_offset(xc_interface *xch, uint32_t domid, diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 1ff6d0a..4f96e1b 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -684,6 +684,42 @@ int xc_domain_set_memory_map(xc_interface *xch, return rc; } + +int xc_reserved_device_memory_map(xc_interface *xch, + uint32_t flag, + uint16_t seg, + uint8_t bus, + uint8_t devfn, + struct xen_reserved_device_memory entries[], + uint32_t *max_entries) +{ + int rc; + struct xen_reserved_device_memory_map xrdmmap = { + .flag = flag, + .seg = seg, + .bus = bus, + .devfn = devfn, + .nr_entries = *max_entries + }; + DECLARE_HYPERCALL_BOUNCE(entries, + sizeof(struct xen_reserved_device_memory) * + *max_entries, XC_HYPERCALL_BUFFER_BOUNCE_OUT); + + if ( xc_hypercall_bounce_pre(xch, entries) ) + return -1; + + set_xen_guest_handle(xrdmmap.buffer, entries); + + rc = do_memory_op(xch, XENMEM_reserved_device_memory_map, + &xrdmmap, sizeof(xrdmmap)); + + xc_hypercall_bounce_post(xch, entries); + + *max_entries = xrdmmap.nr_entries; + + return rc; +} + int xc_get_machine_memory_map(xc_interface *xch, struct e820entry entries[], uint32_t max_entries) -- 1.9.1