[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tools: libxc: flush data cache after loading images into guest memory





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 <ian.campbell@xxxxxxxxxx>
Cc: Andre Przywara <andre.przywara@xxxxxxxxxxx>
Cc: Pranavkumar Sawargaonkar <psawargaonkar@xxxxxxx>
Cc: Anup Patel <apatel@xxxxxxx>
---
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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.