From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v4][PATCH 3/9] tools:libxc: introduce hypercall for xc_reserved_device_memory_map Date: Mon, 25 Aug 2014 19:11:43 +0800 Message-ID: <53FB19EF.9090303@intel.com> References: <1408702186-24432-1-git-send-email-tiejun.chen@intel.com> <1408702186-24432-4-git-send-email-tiejun.chen@intel.com> <53F721AD.8010300@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53F721AD.8010300@citrix.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: Andrew Cooper , JBeulich@suse.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, yang.z.zhang@intel.com, kevin.tian@intel.com Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 2014/8/22 18:55, Andrew Cooper wrote: > On 22/08/14 11:09, Tiejun Chen wrote: >> We will introduce that hypercall xc_reserved_device_memory_map >> to libxc. >> >> Signed-off-by: Tiejun Chen >> --- >> tools/libxc/xc_domain.c | 29 +++++++++++++++++++++++++++++ >> tools/libxc/xenctrl.h | 4 ++++ >> 2 files changed, 33 insertions(+) >> >> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c >> index c67ac9a..08dc16f 100644 >> --- a/tools/libxc/xc_domain.c >> +++ b/tools/libxc/xc_domain.c >> @@ -649,6 +649,35 @@ int xc_domain_set_memory_map(xc_interface *xch, >> >> return rc; >> } >> + >> +int xc_reserved_device_memory_map(xc_interface *xch, >> + struct xen_reserved_device_memory entries[], >> + uint32_t max_entries) >> +{ >> + int rc; >> + struct xen_reserved_device_memory_map memmap = { >> + .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(memmap.buffer, entries); >> + >> + rc = do_memory_op(xch, XENMEM_reserved_device_memory_map, >> + &memmap, sizeof(memmap)); >> + >> + xc_hypercall_bounce_post(xch, entries); >> + >> + if ( errno == ENOBUFS ) >> + return memmap.nr_entries; >> + >> + return rc ? -errno : memmap.nr_entries; > > So how does the caller distinguish between "xen filled in N entries" and > "xen said you need N entries for all the information" ? Thanks for your reminder, I will add something to check this point. I think the caller can compare that number of entries as that input parameter with the return value. If equal, this should be in case of "xen filled in N entries". If not, this is in case of "xen said you need N entries for all the information". Thanks Tiejun > > ~Andrew > >> +} >> + >> int xc_get_machine_memory_map(xc_interface *xch, >> struct e820entry entries[], >> uint32_t max_entries) >> diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h >> index 1c5d0db..1cc7852 100644 >> --- a/tools/libxc/xenctrl.h >> +++ b/tools/libxc/xenctrl.h >> @@ -1270,6 +1270,10 @@ 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, >> + struct xen_reserved_device_memory entries[], >> + uint32_t max_entries); >> #endif >> int xc_domain_set_time_offset(xc_interface *xch, >> uint32_t domid, > >