From: Ian Campbell Subject: Re: [PATCH v2] tools: libxc: flush data cache after loading images into guest memory Date: Mon, 16 Dec 2013 11:05:54 +0000 Message-ID: <1387191954.20076.77.camel@kazak.uk.xensource.com> References: <1386850863-16373-1-git-send-email-ian.campbell@citrix.com> <1386858199-18882-1-git-send-email-ian.campbell@citrix.com> <52AA59A8.9090103@linaro.org> <1386923172.20787.65.camel@dagon.hellion.org.uk> <1386939215.20787.87.camel@dagon.hellion.org.uk> <52AE4E1A.6070007@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <52AE4E1A.6070007@linaro.org> 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: Andre Przywara , Stefano Stabellini , Tim Deegan , "xen-devel@lists.xen.org" , Anup Patel , Pranavkumar Sawargaonkar List-Id: xen-devel@lists.xenproject.org On Mon, 2013-12-16 at 00:49 +0000, Julien Grall wrote: > > On 12/13/2013 12:53 PM, Ian Campbell wrote: > >>> > >>>> Unfortunately Linux doesn't provide any syscall to call this function > >>>> for ARMv7 and it's not possible to call cache instruction from > >>>> userspace. What we could do is: > >>>> - Use the "flags" parameters of cacheflush syscall and call a > >>>> function which DCCMVAC (for instance __cpuc_flush_dcache_area) > >>>> - Extend privcmd to have a flush cache ioctl > >>> > >>> Personally I think the first is nicer, but ultimately we need input from > >>> l-a-k on this one and would be happy with either. > >> > >> I agree. Can you try to come up with such a patch? > > There is 2 functions in kernel space to flush cache PoC: > - flush_kern_dcache_area > - dma_flush_range > I'm not sure if one of these are suitable to expose to user space. v7_dma_clean_range is the one which matches the arm64 instruction we are using (dc cvac), I think. Perhaps we need to invalidate the cache too? Probably not since we are going to tear the mapping down rather than use it further. At the least whichever variant is selected needs to be updated to use the USER() mechanism to protect against userspace faults, since they assume kernel addresses right now. Rather than using any of these directly I'd be tempted to create a new wrapper (not new code necessarily) and call it foo_user_range (it's a bit odd that the current function is called coherent when it only does unification -- oh well!) > > > I think Julien was going to investigate, but if says not I'll take a > > stab at it. > > I will try to do and send a patch tomorrow. Thanks.