]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
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, 29 Jan 2020 14:34:25 +0000 (14:34 +0000)
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
xen/common/kimage.c
xen/include/xen/kimage.h
xen/include/xen/lu.h

index 210241dfb76c3bbd1dbc2e54f4293d429edd5d99..86d2797cbcfed655e46d18c573ff2c1e656c13eb 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>
 
@@ -938,6 +939,39 @@ done:
     return ret;
 }
 
+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;
+}
 /*
  * 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;