From: "Jan Beulich" Subject: Re: [v4][PATCH 03/19] xen/vtd: create RMRR mapping Date: Wed, 24 Jun 2015 07:48:19 +0100 Message-ID: <558A6ED30200007800088AD9@mail.emea.novell.com> References: <1435053450-25131-1-git-send-email-tiejun.chen@intel.com> <1435053450-25131-4-git-send-email-tiejun.chen@intel.com> <55894D4902000078000881D3@mail.emea.novell.com> <558A03CD.3090206@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <558A03CD.3090206@intel.com> Content-Disposition: inline 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: Yang Zhang , Kevin Tian , Tim Deegan , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 24.06.15 at 03:11, wrote: > On 2015/6/23 18:12, Jan Beulich wrote: >>>>> On 23.06.15 at 11:57, wrote: >>> --- a/xen/drivers/passthrough/vtd/iommu.c >>> +++ b/xen/drivers/passthrough/vtd/iommu.c >>> @@ -1839,7 +1839,7 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map, >>> >>> while ( base_pfn < end_pfn ) >>> { >>> - if ( intel_iommu_unmap_page(d, base_pfn) ) >>> + if ( guest_physmap_remove_page(d, base_pfn, base_pfn, 0) ) > > Yeah, I also thought this may bring some confusions in this context. > >>> ret = -ENXIO; >>> base_pfn++; >>> } >>> @@ -1855,8 +1855,7 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map, >>> >>> while ( base_pfn < end_pfn ) >>> { >>> - int err = intel_iommu_map_page(d, base_pfn, base_pfn, >>> - IOMMUF_readable|IOMMUF_writable); >>> + int err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw); >> >> Shouldn't the two continue to be the inverse of one another? > > Initially, instead of using guest_physmap_remove_page, I was trying to > introduce a new, clear_identity_p2m_entry, which can wrapper > p2m_remove_page(). > > But Tim just thought we'd better avoid duplicating code, > > http://lists.xenproject.org/archives/html/xen-devel/2015-06/msg02970.html > >> Maybe guest_physmap_remove_page() does what you want, > > Note actually we just need p2m_remove_page() to unmap these mapping on > both ept and vt-d sides, and guest_physmap_remove_page is really a > wrapper of p2m_remove_page(). And I agree with Tim regarding the desire to avoid code duplication. Yet that's no reason to do it asymmetrically: clear_identity_p2m_entry() could still be an inline (or macro) wrapper around guest_physmap_remove_page(). That way, apart from making the code above look nicer, if the latter needs extending in the future for some reason, simply converting the wrapper to a real function is possible without needing to touch the call site(s). This would need to go into patch 2; I wonder whether folding that and this one wouldn't be warranted, avoiding the former adding (at that point) dead code. Jan