From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [v4][PATCH 4/9] tools:libxc: check if mmio BAR is out of RMRR mappings Date: Tue, 26 Aug 2014 21:36:14 +0100 Message-ID: <1409085374.28009.37.camel@citrix.com> References: <1408702186-24432-1-git-send-email-tiejun.chen@intel.com> <1408702186-24432-5-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: <1408702186-24432-5-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: Tiejun Chen Cc: kevin.tian@intel.com, stefano.stabellini@eu.citrix.com, 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 Fri, 2014-08-22 at 18:09 +0800, Tiejun Chen wrote: > + /* We should check if mmio range is out of RMRR mapping. > + * > + * Assume we have one entry if not enough we'll expand. > + */ The usual approach with such hypervisor interfaces (which I suppose xc_reserved_device_memory_map turns into) is to first call it with NULL to get the required size and then allocate a suitable buffer and call a second time. > + for ( i = 0; i < rc; i++ ) > + { > + rmrr_start = map[i].pfn << PAGE_SHIFT; > + rmrr_end = rmrr_start + map[i].count * PAGE_SIZE; > + if ( check_mmio_hole(rmrr_start, map[i].count * PAGE_SIZE, Adding rmrr_size = map... & PAGE_SIZE could be used twice here. Ian.