From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [RFC PATCH 1/2] xen: introduce arch_iommu_grant_(un)map_page Date: Wed, 16 Jul 2014 19:19:46 +0100 Message-ID: <53C6C242.8030007@linaro.org> References: <1404834794-16055-1-git-send-email-stefano.stabellini@eu.citrix.com> <1405526198.1087.45.camel@kazak.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: <1405526198.1087.45.camel@kazak.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: Ian Campbell , Stefano Stabellini Cc: julien.grall@citrix.com, xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi Ian, On 16/07/14 16:56, Ian Campbell wrote: > On Tue, 2014-07-08 at 16:53 +0100, Stefano Stabellini wrote: >> +int arch_iommu_grant_map_page(struct domain *d, unsigned long frame, >> + unsigned flags) >> +{ >> + p2m_type_t t; >> + >> + /* Grant mappings can be used for DMA requests. The dev_bus_addr returned by >> + * the hypercall is the MFN (not the IPA). For device protected by >> + * an IOMMU, Xen needs to add a 1:1 mapping in the domain p2m to >> + * allow DMA request to work. >> + * This is only valid when the domain is directed mapped. >> + */ >> + BUG_ON(!is_domain_direct_mapped(d)); > > What stops a non-1:1 guest from trying to map a grant reference and > ending up here? The function is protected by gnttab_need_iommu_mapping which check if the domain use direct mapping for the memory. Regards, -- Julien Grall