From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v6][PATCH 3/7] tools/libxc: check if mmio BAR is out of reserved device memory maps Date: Thu, 11 Sep 2014 09:14:41 +0800 Message-ID: <5410F781.8030709@intel.com> References: <1410328190-6372-1-git-send-email-tiejun.chen@intel.com> <1410328190-6372-4-git-send-email-tiejun.chen@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "Tian, Kevin" , "JBeulich@suse.com" , "ian.campbell@citrix.com" , "ian.jackson@eu.citrix.com" , "stefano.stabellini@eu.citrix.com" , "Zhang, Yang Z" Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 2014/9/11 5:37, Tian, Kevin wrote: >> From: Chen, Tiejun >> Sent: Tuesday, September 09, 2014 10:50 PM >> >> We need to avoid allocating MMIO BAR conflicting to all reserved device >> memory range. > > besides checking MMIO BAR confliction, you also need check guest memory > confliction with reserved device memory ranges. Kexin, In patch #6, hvmloader: check to reserved device memory maps in e820, we'll lookup the entire e820 table to check if RMRR is overlapping with all recorded ranges in e820, so I think that already cover this case, right? > >> >> Signed-off-by: Tiejun Chen >> >> diff --git a/tools/libxc/xc_hvm_build_x86.c b/tools/libxc/xc_hvm_build_x86.c >> index c81a25b..299e33a 100644 >> --- a/tools/libxc/xc_hvm_build_x86.c >> +++ b/tools/libxc/xc_hvm_build_x86.c >> @@ -239,6 +239,73 @@ static int check_mmio_hole(uint64_t start, uint64_t >> memsize, >> return 1; >> } >> >> +/* >> + * Check whether there exists mmio overplap with the reserved device >> + * memory map >> + */ >> +static int check_rdm_overlap(xc_interface *xch, uint64_t mmio_start, >> + uint64_t mmio_size) >> +{ >> + struct xen_mem_reserved_device_memory *map = NULL; > > If there are multiple callers of this call, better to move the structure out of > this function to avoid multiple calls. Good point. +/* Record reserved device memory. */ +static struct xen_mem_reserved_device_memory *xmrdm = NULL; + > >> + uint64_t rdm_start = 0, rdm_end = 0; >> + unsigned int i = 0; >> + int rc = 0; >> + /* Assume we have one entry if not enough we'll expand.*/ >> + uint32_t nr_entries = 1; [snip] >> } >> >> + rc = check_rdm_overlap(xch, mmio_start, mmio_start); > > mmio_start -> mmio_size. Fixed and thanks a lot. Thanks Tiejun > >> + if ( rc < 0 ) >> + goto error_out; >> + >> for ( i = 0; i < nr_pages; i++ ) >> page_array[i] = i; >> for ( i = mmio_start >> PAGE_SHIFT; i < nr_pages; i++ ) >> -- >> 1.9.1 > >