From: Ian Campbell Subject: Re: [PATCH RFC] xen: arm: use uncached foreign mappings when building guests Date: Mon, 6 Jan 2014 12:10:29 +0000 Message-ID: <1389010229.31766.14.camel@kazak.uk.xensource.com> References: <1387387710.28680.88.camel@kazak.uk.xensource.com> <52B2758C.70208@linaro.org> <1387463435.9925.86.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1387463435.9925.86.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: Julien Grall Cc: Ian Jackson , Tim Deegan , xen-devel , Julien Grall , Stefano.Stabellini@citrix.com, David Vrabel , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On Thu, 2013-12-19 at 14:30 +0000, Ian Campbell wrote: > Looks like I might have missed a callpath. Not just that, but a cache flush too so even with the uncached mapping the cache is *still* potentially dirty. One place this could be fixed is in dom0 in remap_pte_fn, and I've confirmed that this works: @@ -101,6 +102,8 @@ static int remap_pte_fn(pte_t *ptep, pgtable_t token, unsig if (map_foreign_page(pfn, info->fgmfn, info->domid)) return -EFAULT; set_pte_at(info->vma->vm_mm, addr, ptep, pte); + if (pgprot_val(info->prot) == pgprot_val(pgprot_noncached(info->prot))) + __cpuc_flush_dcache_area((void *)addr, PAGE_SIZE); return 0; } I'm wondering though if it might be more correct to do this on the hypervisor side. In particular I'm thinking that caches should be invalidated when a page is freed. scrub_one_page would have been convenient but is not called for a ballooned down page, so we'd have to add something which maps the page and flushes it on free. An alternative would be to invalidate the cache when we allocate the page to a guest, e.g. in populate physmap. Sadly -- neither of the last two ideas actually work in practice for some reason... I'll poke at it a bit more. Ian.