From: Varad Gautam <vrd@amazon.de>
To: kexec@lists.infradead.org
Cc: Varad Gautam <vrd@amazon.de>, dwmw@amazon.co.uk
Subject: [PATCH v2 1/3] kexec-xen: Introduce xen_get_kexec_range to wrap xc_kexec_get_range
Date: Wed, 1 Apr 2020 18:57:15 +0200 [thread overview]
Message-ID: <1585760237-26924-1-git-send-email-vrd@amazon.de> (raw)
And convert all callers of xc_kexec_get_range to use this. Allows reusing
sanity checks for other KEXEC_RANGEs
v2: define xen_get_kexec_range outside of HAVE_LIBXENCTRL
Signed-off-by: Varad Gautam <vrd@amazon.de>
---
kexec/crashdump-xen.c | 38 +++++---------------------------------
kexec/kexec-xen.c | 32 ++++++++++++++++++++++++++++++++
kexec/kexec-xen.h | 4 ++++
3 files changed, 41 insertions(+), 33 deletions(-)
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index 2d6b2f9..3f59a0d 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -162,21 +162,15 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
#ifdef HAVE_LIBXENCTRL
int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len)
{
- xc_interface *xc;
+ uint64_t end;
int ret = 0;
- xc = xc_interface_open(NULL, NULL, 0);
- if (!xc) {
- fprintf(stderr, "failed to open xen control interface.\n");
+ ret = xen_get_kexec_range(KEXEC_RANGE_MA_VMCOREINFO, addr, &end);
+ if (ret < 0)
return -1;
- }
-
- ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, 0, len, addr);
- xc_interface_close(xc);
+ *len = end - *addr + 1;
- if (ret < 0)
- return -1;
return 0;
}
@@ -252,29 +246,7 @@ int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
#ifdef HAVE_LIBXENCTRL
int xen_get_crashkernel_region(uint64_t *start, uint64_t *end)
{
- uint64_t size;
- xc_interface *xc;
- int rc = -1;
-
- xc = xc_interface_open(NULL, NULL, 0);
- if (!xc) {
- fprintf(stderr, "failed to open xen control interface.\n");
- goto out;
- }
-
- rc = xc_kexec_get_range(xc, KEXEC_RANGE_MA_CRASH, 0, &size, start);
- if (rc < 0) {
- fprintf(stderr, "failed to get crash region from hypervisor.\n");
- goto out_close;
- }
-
- *end = *start + size - 1;
-
-out_close:
- xc_interface_close(xc);
-
-out:
- return rc;
+ return xen_get_kexec_range(KEXEC_RANGE_MA_CRASH, start, end);
}
#else
int xen_get_crashkernel_region(uint64_t *start, uint64_t *end)
diff --git a/kexec/kexec-xen.c b/kexec/kexec-xen.c
index c326955..afcfc5b 100644
--- a/kexec/kexec-xen.c
+++ b/kexec/kexec-xen.c
@@ -64,6 +64,33 @@ int __xc_interface_close(xc_interface *xch)
}
#endif /* CONFIG_LIBXENCTRL_DL */
+int xen_get_kexec_range(int range, uint64_t *start, uint64_t *end)
+{
+ uint64_t size;
+ xc_interface *xc;
+ int rc = -1;
+
+ xc = xc_interface_open(NULL, NULL, 0);
+ if (!xc) {
+ fprintf(stderr, "failed to open xen control interface.\n");
+ goto out;
+ }
+
+ rc = xc_kexec_get_range(xc, range, 0, &size, start);
+ if (rc < 0) {
+ fprintf(stderr, "failed to get range=%d from hypervisor.\n", range);
+ goto out_close;
+ }
+
+ *end = *start + size - 1;
+
+out_close:
+ xc_interface_close(xc);
+
+out:
+ return rc;
+}
+
#define IDENTMAP_1MiB (1024 * 1024)
int xen_kexec_load(struct kexec_info *info)
@@ -226,6 +253,11 @@ void xen_kexec_exec(void)
#else /* ! HAVE_LIBXENCTRL */
+int xen_get_kexec_range(int range, uint64_t *start, uint64_t *end)
+{
+ return -1;
+}
+
int xen_kexec_load(struct kexec_info *UNUSED(info))
{
return -1;
diff --git a/kexec/kexec-xen.h b/kexec/kexec-xen.h
index ae67393..94d22cd 100644
--- a/kexec/kexec-xen.h
+++ b/kexec/kexec-xen.h
@@ -63,6 +63,10 @@ extern int __xc_interface_close(xc_interface *xch);
__xc_call(void *, xc_hypercall_buffer_array_destroy, args)
#endif /* CONFIG_LIBXENCTRL_DL */
+
+
#endif /* HAVE_LIBXENCTRL */
+int xen_get_kexec_range(int range, uint64_t *start, uint64_t *end);
+
#endif /* KEXEC_XEN_H */
--
2.7.4
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2020-04-01 16:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 16:57 Varad Gautam [this message]
2020-04-01 16:57 ` [PATCH v2 2/3] kexec: Introduce --load-live-update for xen Varad Gautam
2020-04-01 16:57 ` [PATCH v2 3/3] kexec-xen: Introduce --exec-live-update to trigger a live update Varad Gautam
2020-04-07 12:00 ` [PATCH v2 1/3] kexec-xen: Introduce xen_get_kexec_range to wrap xc_kexec_get_range Simon Horman
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=1585760237-26924-1-git-send-email-vrd@amazon.de \
--to=vrd@amazon.de \
--cc=dwmw@amazon.co.uk \
--cc=kexec@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox