From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v8][PATCH 07/17] hvmloader/util: get reserved device memory maps Date: Mon, 08 Dec 2014 16:45:36 +0800 Message-ID: <54856530.7050206@intel.com> References: <1417425875-9634-1-git-send-email-tiejun.chen@intel.com> <1417425875-9634-8-git-send-email-tiejun.chen@intel.com> <20141202200100.GG357@laptop.dumpdata.com> <54855CB8.7010009@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <54855CB8.7010009@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: Konrad Rzeszutek Wilk Cc: kevin.tian@intel.com, wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, tim@xen.org, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org, jbeulich@suse.com, yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org On 2014/12/8 16:09, Chen, Tiejun wrote: > On 2014/12/3 4:01, Konrad Rzeszutek Wilk wrote: >> On Mon, Dec 01, 2014 at 05:24:25PM +0800, Tiejun Chen wrote: >>> We need to use reserved device memory maps with multiple times, so >>> provide just one common function should be friend. >> >> We need to call reserved device memory maps hypercall >> (XENMEM_reserved_device_memory_map) many times, hence provide one >> common function. > > Rephrased and thanks. > >> >>> >>> Signed-off-by: Tiejun Chen >>> --- >>> tools/firmware/hvmloader/util.c | 59 >>> +++++++++++++++++++++++++++++++++++++++++ >>> tools/firmware/hvmloader/util.h | 2 ++ >>> 2 files changed, 61 insertions(+) >>> >>> diff --git a/tools/firmware/hvmloader/util.c >>> b/tools/firmware/hvmloader/util.c >>> index 80d822f..dd81fb6 100644 >>> --- a/tools/firmware/hvmloader/util.c >>> +++ b/tools/firmware/hvmloader/util.c >>> @@ -22,11 +22,14 @@ >>> #include "config.h" >>> #include "hypercall.h" >>> #include "ctype.h" >>> +#include "errno.h" >>> #include >>> #include >>> #include >>> #include >>> >>> +struct xen_reserved_device_memory *rdm_map; >>> + >>> void wrmsr(uint32_t idx, uint64_t v) >>> { >>> asm volatile ( >>> @@ -828,6 +831,62 @@ int hpet_exists(unsigned long hpet_base) >>> return ((hpet_id >> 16) == 0x8086); >>> } >>> >>> +static int >>> +get_reserved_device_memory_map(struct xen_reserved_device_memory >>> entries[], >>> + uint32_t *max_entries) >>> +{ >>> + int rc; >>> + struct xen_reserved_device_memory_map xrdmmap = { >>> + .domid = DOMID_SELF, >>> + .nr_entries = *max_entries >>> + }; >>> + >>> + set_xen_guest_handle(xrdmmap.buffer, entries); >>> + >>> + rc = hypercall_memory_op(XENMEM_reserved_device_memory_map, >>> &xrdmmap); >>> + *max_entries = xrdmmap.nr_entries; >> >> Don't you want to check rc first before altering 'max_entries' ? > > - *max_entries = xrdmmap.nr_entries; > + if ( rc == -ENOBUFS ) > + *max_entries = xrdmmap.nr_entries; > Something remind me. That is, in all case we should set max_entries since now we don't count all RMRR ranges again. Instead, we may count those RMRR ranges associated to a assigned device but obviously, it may have no any RMRR. So we always should update max_entries as well. Thanks Tiejun Thanks Tiejun