From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH] tools: libxc: flush data cache after loading images into guest memory Date: Thu, 12 Dec 2013 14:11:49 +0000 Message-ID: <52A9C425.7030109@linaro.org> References: <1386850863-16373-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1386850863-16373-1-git-send-email-ian.campbell@citrix.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 , xen-devel@lists.xen.org Cc: Anup Patel , Andre Przywara , tim@xen.org, Pranavkumar Sawargaonkar , stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On 12/12/2013 12:21 PM, Ian Campbell wrote: > On ARM guest OSes are started with MMU and Caches disables (as they are on > native) however caching is enabled in the domain running the builder and > therefore we must flush the cache as we load the blobs, otherwise when the > guest starts running it may not see them. The dom0 build in the hypervisor has > the same requirements and already does the right thing. > > The mechanism for performing a cache flush from userspace is OS specific, so > implement this as a new osdep hook: > > - On 32-bit ARM Linux provides a system call to flush the cache. > - On 64-bit ARM Linux the processor is configured to allow cache flushes > directly from userspace. > - Non-Linux platforms will need to provide their own implementation. If > similar mechanisms are not available then a new privcmd ioctl should be a > suitable alternative. > > No cache maintenance is required on x86, so provide a stub for all non-Linux > platforms which returns success on x86 only and log an error otherwise. > > This fixes guest building on Xgene which has a very large L3 cache and so is > particularly susceptible to this problem. It has also been observed > sporadically on midway. > > Signed-off-by: Ian Campbell > Cc: Andre Przywara > Cc: Pranavkumar Sawargaonkar > Cc: Anup Patel > --- > Freeze: Bugfix. > --- > tools/libxc/xc_dom_armzimageloader.c | 1 + > tools/libxc/xc_dom_binloader.c | 1 + > tools/libxc/xc_dom_core.c | 2 ++ > tools/libxc/xc_linux_osdep.c | 39 ++++++++++++++++++++++++++++++++++ > tools/libxc/xc_minios.c | 11 ++++++++++ > tools/libxc/xc_netbsd.c | 12 +++++++++++ > tools/libxc/xc_private.c | 5 +++++ > tools/libxc/xc_private.h | 3 +++ > tools/libxc/xc_solaris.c | 12 +++++++++++ > tools/libxc/xenctrl_osdep_ENOSYS.c | 6 ++++++ > tools/libxc/xenctrlosdep.h | 1 + > 11 files changed, 93 insertions(+) > [..] > diff --git a/tools/libxc/xenctrl_osdep_ENOSYS.c b/tools/libxc/xenctrl_osdep_ENOSYS.c > index 4821342..c6fceff 100644 > --- a/tools/libxc/xenctrl_osdep_ENOSYS.c > +++ b/tools/libxc/xenctrl_osdep_ENOSYS.c > @@ -63,6 +63,10 @@ static void *ENOSYS_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handl > return MAP_FAILED; > } > > +static void ENOSYS_privcmd_cache_flush(xc_interface *xch, const void *p, size_t n) > +{ > +} > + Missing IPRINTF for this function. > static struct xc_osdep_ops ENOSYS_privcmd_ops = > { > .open = &ENOSYS_privcmd_open, > @@ -74,6 +78,8 @@ static struct xc_osdep_ops ENOSYS_privcmd_ops = > .map_foreign_bulk = &ENOSYS_privcmd_map_foreign_bulk, > .map_foreign_range = &ENOSYS_privcmd_map_foreign_range, > .map_foreign_ranges = &ENOSYS_privcmd_map_foreign_ranges, > + > + .cache_flush = &ENOSYS_privcmd_cache_flush, > } > }; > > diff --git a/tools/libxc/xenctrlosdep.h b/tools/libxc/xenctrlosdep.h > index e610a24..6c9a005 100644 > --- a/tools/libxc/xenctrlosdep.h > +++ b/tools/libxc/xenctrlosdep.h > @@ -89,6 +89,7 @@ struct xc_osdep_ops > void *(*map_foreign_ranges)(xc_interface *xch, xc_osdep_handle h, uint32_t dom, size_t size, int prot, > size_t chunksize, privcmd_mmap_entry_t entries[], > int nentries); > + void (*cache_flush)(xc_interface *xch, const void *p, size_t n); > } privcmd; > struct { > int (*fd)(xc_evtchn *xce, xc_osdep_handle h); > -- Julien Grall