]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
live update: add kimage_add_live_update_data()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 15 Jan 2020 17:46:54 +0000 (18:46 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 18 Mar 2020 23:42:36 +0000 (23:42 +0000)
This appends the IND_WRITE64 directives to the kimage, to write the
breadcrumb which leads the next Xen to the live update data stream.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
xen/common/kimage.c
xen/include/xen/kimage.h
xen/include/xen/lu.h

index 8d55d3e8252dc5a04482bb5a2c08fbd59135676f..faaea8abf955e9b8b23dfaa8844377fcda91d53a 100644 (file)
@@ -20,6 +20,7 @@
 #include <xen/mm.h>
 #include <xen/kexec.h>
 #include <xen/kimage.h>
+#include <xen/lu.h>
 
 #include <asm/page.h>
 
@@ -941,6 +942,42 @@ done:
     return ret;
 }
 
+#ifdef CONFIG_LIVE_UPDATE
+int kimage_add_live_update_data(struct kexec_image *image, mfn_t data, int nr_mfns)
+{
+    int ret;
+
+    /*
+     * For live update, we place the physical location of 'data'
+     * into the first 64 bits of the reserved live update bootmem
+     * region. At 'data' is an MFN list of pages containing the
+     * actual live update stream, which the new Xen can vmap().
+     *
+     * Append IND_WRITE64 operations to the end of the kimage stream
+     * to store the live update magic and the address of 'data' for
+     * the new Xen to see.
+     */
+    if (!lu_bootmem_start || kimage_dst_used(image, lu_bootmem_start))
+        return -EINVAL;
+
+    ret = machine_kexec_add_page(image, lu_bootmem_start, lu_bootmem_start);
+    if ( ret < 0 )
+        return ret;
+
+    ret = kimage_set_destination(image, lu_bootmem_start);
+    if (!ret)
+        ret = kimage_add_entry(image, LIVE_UPDATE_MAGIC | IND_WRITE64);
+    if (!ret)
+        ret = kimage_add_entry(image, mfn_to_maddr(data) | IND_WRITE64);
+    if (!ret)
+        ret = kimage_add_entry(image, (nr_mfns << PAGE_SHIFT) | IND_WRITE64);
+
+    kimage_terminate(image);
+
+    return ret;
+}
+#endif /* CONFIG_LIVE_UPDATE */
+
 /*
  * Local variables:
  * mode: C
index e94839d7c3d993f0f297b4763af5425e36162d53..1e0e378afd5b83c688f8703b24f7f3fc36089914 100644 (file)
@@ -54,6 +54,9 @@ unsigned long kimage_entry_ind(kimage_entry_t *entry, bool_t compat);
 int kimage_build_ind(struct kexec_image *image, mfn_t ind_mfn,
                      bool_t compat);
 
+int kimage_add_live_update_data(struct kexec_image *image, mfn_t data,
+                                int nr_mfns);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __XEN_KIMAGE_H__ */
index abb30545fe8256e9ddd35b0809c190a6b420e25c..21ee1825d35c2eee9c2fbd1880af30ff8ced4e5f 100644 (file)
@@ -1,9 +1,12 @@
 #ifndef __XEN_LU_H__
 #define __XEN_LU_H__
 
+
 #include <xen/types.h>
 #include <xen/mm.h>
 
+#define LIVE_UPDATE_MAGIC        (0x4c69766555706461UL & PAGE_MASK)
+
 struct lu_stream {
     mfn_t *pagelist;
     size_t len;