From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v7] x86/p2m: use large pages for MMIO mappings Date: Tue, 2 Feb 2016 15:27:22 +0000 Message-ID: <56B0CADA.2090405@citrix.com> References: <56B0D61302000078000CD962@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQcrX-0004VR-8y for xen-devel@lists.xenproject.org; Tue, 02 Feb 2016 15:27:27 +0000 In-Reply-To: <56B0D61302000078000CD962@prv-mh.provo.novell.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: Jan Beulich , xen-devel Cc: Kevin Tian , Wei Liu , Ian Campbell , Stefano Stabellini , George Dunlap , Tim Deegan , Ian Jackson , Jun Nakajima , Keir Fraser List-Id: xen-devel@lists.xenproject.org On 02/02/16 15:15, Jan Beulich wrote: > @@ -2095,6 +2131,30 @@ void *map_domain_gfn(struct p2m_domain * > return map_domain_page(*mfn); > } > > +static unsigned int mmio_order(const struct domain *d, > + unsigned long start_fn, unsigned long nr) > +{ > + if ( !need_iommu(d) || !iommu_use_hap_pt(d) || > + (start_fn & ((1UL << PAGE_ORDER_2M) - 1)) || !(nr >> PAGE_ORDER_2M) ) > + return PAGE_ORDER_4K; > + > + if ( 0 /* > + * Don't use 1Gb pages, to limit the iteration count in > + * set_typed_p2m_entry() when it needs to zap M2P entries > + * for a RAM range. > + */ && > + !(start_fn & ((1UL << PAGE_ORDER_1G) - 1)) && (nr >> PAGE_ORDER_1G) && > + hap_has_1gb ) > + return PAGE_ORDER_1G; > + > + if ( hap_has_2mb ) > + return PAGE_ORDER_2M; > + > + return PAGE_ORDER_4K; > +} Apologises again for only just spotting this. PV guests need to be restricted to 4K mappings. Currently, this function can return PAGE_ORDER_2M for PV guests, based on hap_has_2mb. All the callers are presently gated on !paging_mode_translate(d), which will exclude PV guests, but it mmio_order() isn't in principle wrong to call for a PV guest. With either a suitable PV path, or assertion excluding PV guests, Reviewed-by: Andrew Cooper (to avoid another on-list iteration for just this issue)