From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v4][PATCH 14/19] tools/libxl: detect and avoid conflicts with RDM Date: Fri, 26 Jun 2015 13:45:02 +0800 Message-ID: <558CE6DE.8010204@intel.com> References: <1435053450-25131-1-git-send-email-tiejun.chen@intel.com> <1435053450-25131-15-git-send-email-tiejun.chen@intel.com> <20150625112352.GJ6545@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150625112352.GJ6545@zion.uk.xensource.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: Wei Liu Cc: Stefano Stabellini , Ian Jackson , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 2015/6/25 19:23, Wei Liu wrote: > On Tue, Jun 23, 2015 at 05:57:25PM +0800, Tiejun Chen wrote: >> While building a VM, HVM domain builder provides struct hvm_info_table{} >> to help hvmloader. Currently it includes two fields to construct guest >> e820 table by hvmloader, low_mem_pgend and high_mem_pgend. So we should >> check them to fix any conflict with RAM. >> > > RAM -> RDM? Fixed. > >> RMRR can reside in address space beyond 4G theoretically, but we never [snip] >> +static struct xen_reserved_device_memory >> +*xc_device_get_rdm(libxl__gc *gc, >> + uint32_t flag, >> + uint16_t seg, >> + uint8_t bus, >> + uint8_t devfn, >> + unsigned int *nr_entries) > > I just notice this function lives in libxl_dm.c. The function should be > renamed to libxl__xc_device_get_rdm. > > This function should return proper libxl error code (ERROR_FAIL or > something more appropriate). The allocated RDM entries should be ERROR_FAIL is better. So refactor this function after address your all comments, static int libxl__xc_device_get_rdm(libxl__gc *gc, uint32_t flag, uint16_t seg, uint8_t bus, uint8_t devfn, unsigned int *nr_entries, struct xen_reserved_device_memory *xrdm) { int rc; /* * We really can't presume how many entries we can get in advance. */ *nr_entries = 0; rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn, NULL, nr_entries); assert(rc <= 0); /* "0" means we have no any rdm entry. */ if (!rc) 94,22 3% /* "0" means we have no any rdm entry. */ if (!rc) goto out; if (errno == ENOBUFS) { xrdm = libxl__malloc(gc, *nr_entries * sizeof(xen_reserved_device_memory_t)); rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn, xrdm, nr_entries); if (rc) { LOG(ERROR, "Could not get reserved device memory maps.\n"); rc = ERROR_FAIL; } } else { LOG(ERROR, "Could not get reserved device memory maps.\n"); rc = ERROR_FAIL; } out: if (rc) { *nr_entries = 0; xrdm = NULL; } return rc; } Thanks Tiejun