All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric DeVolder <eric.devolder@oracle.com>
To: xen-devel@lists.xen.org
Cc: daniel.kiper@oracle.com, eric.devolder@oracle.com,
	kexec@lists.infradead.org, boris.ostrovsky@oracle.com
Subject: [RFC v1 1/8] kexec: add kexec_file_load to libxenctrl
Date: Mon, 14 Jan 2019 13:47:58 -0600	[thread overview]
Message-ID: <1547495285-28907-2-git-send-email-eric.devolder__18519.8075291284$1547495346$gmane$org@oracle.com> (raw)
In-Reply-To: <1547495285-28907-1-git-send-email-eric.devolder@oracle.com>

This change adds a new entry point in libxenctrl for the
kexec_file_load() operation. The code for kexec_file_load() is nearly
identical to kexec_load() other than the use of hypercall op
KEXEC_CMD_kexec_file_load rather than KEXEC_CMD_kexec_load.

Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 tools/libxc/xc_kexec.c     | 41 +++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xenctrl.h      |  4 ++++
 xen/include/public/kexec.h |  4 +++-
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/xc_kexec.c b/tools/libxc/xc_kexec.c
index 5003556..10762af 100644
--- a/tools/libxc/xc_kexec.c
+++ b/tools/libxc/xc_kexec.c
@@ -112,6 +112,47 @@ out:
     return ret;
 }
 
+int xc_kexec_file_load(xc_interface *xch, uint8_t type, uint16_t arch,
+                  uint64_t entry_maddr,
+                  uint32_t nr_segments, xen_kexec_segment_t *segments)
+{
+    int ret = -1;
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BOUNCE(segments, sizeof(*segments) * nr_segments,
+                             XC_HYPERCALL_BUFFER_BOUNCE_IN);
+    DECLARE_HYPERCALL_BUFFER(xen_kexec_load_t, load);
+
+    if ( xc_hypercall_bounce_pre(xch, segments) )
+    {
+        PERROR("Could not allocate bounce buffer for kexec load hypercall");
+        goto out;
+    }
+    load = xc_hypercall_buffer_alloc(xch, load, sizeof(*load));
+    if ( load == NULL )
+    {
+        PERROR("Could not allocate buffer for kexec load hypercall");
+        goto out;
+    }
+
+    load->type = type;
+    load->arch = arch;
+    load->entry_maddr = entry_maddr;
+    load->nr_segments = nr_segments;
+    set_xen_guest_handle(load->segments.h, segments);
+
+    hypercall.op = __HYPERVISOR_kexec_op;
+    hypercall.arg[0] = KEXEC_CMD_kexec_file_load; // only difference with xc_kexec_load()
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(load);
+
+    ret = do_xen_hypercall(xch, &hypercall);
+
+out:
+    xc_hypercall_buffer_free(xch, load);
+    xc_hypercall_bounce_post(xch, segments);
+
+    return ret;
+}
+
 int xc_kexec_unload(xc_interface *xch, int type)
 {
     DECLARE_HYPERCALL;
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index f61a61c..6243e5a 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -2488,6 +2488,10 @@ int xc_kexec_load(xc_interface *xch, uint8_t type, uint16_t arch,
                   uint64_t entry_maddr,
                   uint32_t nr_segments, xen_kexec_segment_t *segments);
 
+int xc_kexec_file_load(xc_interface *xch, uint8_t type, uint16_t arch,
+                  uint64_t entry_maddr,
+                  uint32_t nr_segments, xen_kexec_segment_t *segments);
+
 /*
  * Unload a kexec image.
  *
diff --git a/xen/include/public/kexec.h b/xen/include/public/kexec.h
index 022e160..eae98d4 100644
--- a/xen/include/public/kexec.h
+++ b/xen/include/public/kexec.h
@@ -203,6 +203,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_kexec_segment_t);
  */
 
 #define KEXEC_CMD_kexec_load 4
+#define KEXEC_CMD_kexec_file_load 7
 typedef struct xen_kexec_load {
     uint8_t  type;        /* One of KEXEC_TYPE_* */
     uint8_t  _pad;
@@ -213,8 +214,9 @@ typedef struct xen_kexec_load {
         uint64_t _pad;
     } segments;
     uint64_t entry_maddr; /* image entry point machine address. */
-} xen_kexec_load_t;
+} xen_kexec_load_t, xen_kexec_file_load_t;
 DEFINE_XEN_GUEST_HANDLE(xen_kexec_load_t);
+DEFINE_XEN_GUEST_HANDLE(xen_kexec_file_load_t);
 
 /*
  * Unload a kexec image.
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-01-14 19:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 19:47 [RFC v1 0/8] Prototype for kexec signature verification within Xen Eric DeVolder
2019-01-14 19:47 ` [RFC v1 1/8] kexec: add kexec_file_load to libxenctrl Eric DeVolder
2019-01-29 10:51   ` Jan Beulich
2019-01-29 10:51   ` [Xen-devel] " Jan Beulich
2019-01-14 19:47 ` Eric DeVolder [this message]
2019-01-14 19:47 ` [RFC v1 2/8] kexec: implement kexec_file_load() for PECOFF+Authenticode files Eric DeVolder
2019-01-14 19:47 ` Eric DeVolder
2019-01-14 19:48 ` [RFC v1 3/8] kexec: new file openssl-1.1.0i.patch Eric DeVolder
2019-01-14 19:48 ` Eric DeVolder
2019-01-14 19:48 ` [RFC v1 4/8] kexec: xen/common/Makefile: include building of OpenSSL Eric DeVolder
2019-01-14 19:48 ` Eric DeVolder
2019-01-14 19:48 ` [RFC v1 5/8] kexec: changes to facilitate compiling OpenSSL within Xen Eric DeVolder
2019-01-14 19:48 ` Eric DeVolder
2019-01-14 19:48 ` [RFC v1 6/8] kexec: support files for PECOFF Authenticode signature verification Eric DeVolder
2019-01-14 19:48   ` Eric DeVolder
2019-01-14 19:48 ` [RFC v1 7/8] kexec: Xen compatible makefile for OpenSSL Eric DeVolder
2019-01-14 19:48 ` Eric DeVolder
2019-01-14 19:48 ` [RFC v1 8/8] kexec: include OpenSSL build in xen.spec Eric DeVolder
2019-01-14 19:48 ` Eric DeVolder
2019-01-29 11:04 ` [Xen-devel] [RFC v1 0/8] Prototype for kexec signature verification within Xen Jan Beulich
2019-01-29 11:04 ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='1547495285-28907-2-git-send-email-eric.devolder__18519.8075291284$1547495346$gmane$org@oracle.com' \
    --to=eric.devolder@oracle.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=daniel.kiper@oracle.com \
    --cc=kexec@lists.infradead.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.