All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] kexec-tools: add support for Xen 4.3
@ 2013-02-21 17:57 David Vrabel
  2013-02-21 17:57 ` [PATCH 1/4] purgatory: put variables altered by kexec in .data not .bss David Vrabel
                   ` (13 more replies)
  0 siblings, 14 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

The series adds support for the new hypercall ABI which should be
provided by Xen 4.3.  Images are loaded into Xen directly with no
kernel involvement.

Do not apply until the hypervisor side patches are applied to Xen.

Patch 1 is unrelated but kexec wouldn't work for me without it. Not
sure why I had problems, perhaps a toolstack specific issue?

Patch 2 makes libxc 4.3 mandatory for Xen support.

Patch 3 removes a use of /proc/iomem in favour of libxc.

Patch 4 adds the support for loading an image into Xen.

This series explicitly drops support for older version of libxc/Xen as
supporting kexec on these hypervisors requires kernel support that
will never be available upstream.

David


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/4] purgatory: put variables altered by kexec in .data not .bss
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-02-21 17:57 ` David Vrabel
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

elf_rel_set_symbol() fails if the symbol is in the .bss section.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 purgatory/arch/i386/console-x86.c        |    6 +++---
 purgatory/arch/i386/crashdump_backup.c   |    8 +++++---
 purgatory/arch/x86_64/purgatory-x86_64.c |    6 +++---
 purgatory/include/purgatory.h            |    4 ++++
 purgatory/purgatory.c                    |    4 ++--
 5 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/purgatory/arch/i386/console-x86.c b/purgatory/arch/i386/console-x86.c
index 9773573..40a734b 100644
--- a/purgatory/arch/i386/console-x86.c
+++ b/purgatory/arch/i386/console-x86.c
@@ -55,9 +55,9 @@ static void putchar_vga(int ch)
  */
 
 /* Base Address */
-uint8_t console_serial = 0;
-uint16_t serial_base = 0x3f8; /* TTYS0 */
-uint32_t serial_baud = 0;
+uint8_t console_serial __data = 0;
+uint16_t serial_base __data = 0x3f8; /* TTYS0 */
+uint32_t serial_baud __data = 0;
 
 #define XMTRDY          0x20
 
diff --git a/purgatory/arch/i386/crashdump_backup.c b/purgatory/arch/i386/crashdump_backup.c
index 365eb5d..0438a75 100644
--- a/purgatory/arch/i386/crashdump_backup.c
+++ b/purgatory/arch/i386/crashdump_backup.c
@@ -21,13 +21,15 @@
 #include <stdint.h>
 #include <string.h>
 
+#include <purgatory.h>
+
 /* Backup region start gets set after /proc/iomem has been parsed. */
 /* We reuse the same code for x86_64 also so changing backup_start to
    unsigned long */
-unsigned long  backup_start = 0;
+unsigned long  backup_start __data = 0;
 
-unsigned long backup_src_start = 0;
-unsigned long backup_src_size = 0;
+unsigned long backup_src_start __data = 0;
+unsigned long backup_src_size __data = 0;
 
 /* Backup first 640K of memory to backup region as reserved by kexec.
  * Assuming first 640K has to be present on i386 machines and no address
diff --git a/purgatory/arch/x86_64/purgatory-x86_64.c b/purgatory/arch/x86_64/purgatory-x86_64.c
index c25a9c2..8a3e24d 100644
--- a/purgatory/arch/x86_64/purgatory-x86_64.c
+++ b/purgatory/arch/x86_64/purgatory-x86_64.c
@@ -3,11 +3,11 @@
 #include <purgatory.h>
 #include "purgatory-x86_64.h"
 
-uint8_t reset_vga = 0;
+uint8_t reset_vga __data = 0;
 uint8_t legacy_pic = 0;
-uint8_t panic_kernel = 0;
+uint8_t panic_kernel __data = 0;
 unsigned long jump_back_entry = 0;
-char *cmdline_end = NULL;
+char *cmdline_end __data = NULL;
 
 void setup_arch(void)
 {
diff --git a/purgatory/include/purgatory.h b/purgatory/include/purgatory.h
index ed50dc4..e2b061a 100644
--- a/purgatory/include/purgatory.h
+++ b/purgatory/include/purgatory.h
@@ -1,6 +1,10 @@
 #ifndef PURGATORY_H
 #define PURGATORY_H
 
+/* Force variables that are adjusted by kexec to be in .data not
+   .bss. */
+#define __data __attribute__((section("data")))
+
 void putchar(int ch);
 void sprintf(char *buffer, const char *fmt, ...);
 void printf(const char *fmt, ...);
diff --git a/purgatory/purgatory.c b/purgatory/purgatory.c
index 3bbcc09..05f3b48 100644
--- a/purgatory/purgatory.c
+++ b/purgatory/purgatory.c
@@ -6,8 +6,8 @@
 #include <string.h>
 #include "../kexec/kexec-sha256.h"
 
-struct sha256_region sha256_regions[SHA256_REGIONS] = {};
-sha256_digest_t sha256_digest = { };
+struct sha256_region sha256_regions[SHA256_REGIONS] __data = {};
+sha256_digest_t sha256_digest __data = { };
 
 int verify_sha256_digest(void)
 {
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 1/4] purgatory: put variables altered by kexec in .data not .bss
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
  2013-02-21 17:57 ` [PATCH 1/4] purgatory: put variables altered by kexec in .data not .bss David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-02-21 17:57 ` [PATCH 2/4] kexec/xen: require libxc from Xen 4.3 David Vrabel
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

elf_rel_set_symbol() fails if the symbol is in the .bss section.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 purgatory/arch/i386/console-x86.c        |    6 +++---
 purgatory/arch/i386/crashdump_backup.c   |    8 +++++---
 purgatory/arch/x86_64/purgatory-x86_64.c |    6 +++---
 purgatory/include/purgatory.h            |    4 ++++
 purgatory/purgatory.c                    |    4 ++--
 5 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/purgatory/arch/i386/console-x86.c b/purgatory/arch/i386/console-x86.c
index 9773573..40a734b 100644
--- a/purgatory/arch/i386/console-x86.c
+++ b/purgatory/arch/i386/console-x86.c
@@ -55,9 +55,9 @@ static void putchar_vga(int ch)
  */
 
 /* Base Address */
-uint8_t console_serial = 0;
-uint16_t serial_base = 0x3f8; /* TTYS0 */
-uint32_t serial_baud = 0;
+uint8_t console_serial __data = 0;
+uint16_t serial_base __data = 0x3f8; /* TTYS0 */
+uint32_t serial_baud __data = 0;
 
 #define XMTRDY          0x20
 
diff --git a/purgatory/arch/i386/crashdump_backup.c b/purgatory/arch/i386/crashdump_backup.c
index 365eb5d..0438a75 100644
--- a/purgatory/arch/i386/crashdump_backup.c
+++ b/purgatory/arch/i386/crashdump_backup.c
@@ -21,13 +21,15 @@
 #include <stdint.h>
 #include <string.h>
 
+#include <purgatory.h>
+
 /* Backup region start gets set after /proc/iomem has been parsed. */
 /* We reuse the same code for x86_64 also so changing backup_start to
    unsigned long */
-unsigned long  backup_start = 0;
+unsigned long  backup_start __data = 0;
 
-unsigned long backup_src_start = 0;
-unsigned long backup_src_size = 0;
+unsigned long backup_src_start __data = 0;
+unsigned long backup_src_size __data = 0;
 
 /* Backup first 640K of memory to backup region as reserved by kexec.
  * Assuming first 640K has to be present on i386 machines and no address
diff --git a/purgatory/arch/x86_64/purgatory-x86_64.c b/purgatory/arch/x86_64/purgatory-x86_64.c
index c25a9c2..8a3e24d 100644
--- a/purgatory/arch/x86_64/purgatory-x86_64.c
+++ b/purgatory/arch/x86_64/purgatory-x86_64.c
@@ -3,11 +3,11 @@
 #include <purgatory.h>
 #include "purgatory-x86_64.h"
 
-uint8_t reset_vga = 0;
+uint8_t reset_vga __data = 0;
 uint8_t legacy_pic = 0;
-uint8_t panic_kernel = 0;
+uint8_t panic_kernel __data = 0;
 unsigned long jump_back_entry = 0;
-char *cmdline_end = NULL;
+char *cmdline_end __data = NULL;
 
 void setup_arch(void)
 {
diff --git a/purgatory/include/purgatory.h b/purgatory/include/purgatory.h
index ed50dc4..e2b061a 100644
--- a/purgatory/include/purgatory.h
+++ b/purgatory/include/purgatory.h
@@ -1,6 +1,10 @@
 #ifndef PURGATORY_H
 #define PURGATORY_H
 
+/* Force variables that are adjusted by kexec to be in .data not
+   .bss. */
+#define __data __attribute__((section("data")))
+
 void putchar(int ch);
 void sprintf(char *buffer, const char *fmt, ...);
 void printf(const char *fmt, ...);
diff --git a/purgatory/purgatory.c b/purgatory/purgatory.c
index 3bbcc09..05f3b48 100644
--- a/purgatory/purgatory.c
+++ b/purgatory/purgatory.c
@@ -6,8 +6,8 @@
 #include <string.h>
 #include "../kexec/kexec-sha256.h"
 
-struct sha256_region sha256_regions[SHA256_REGIONS] = {};
-sha256_digest_t sha256_digest = { };
+struct sha256_region sha256_regions[SHA256_REGIONS] __data = {};
+sha256_digest_t sha256_digest __data = { };
 
 int verify_sha256_digest(void)
 {
-- 
1.7.2.5


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/4] kexec/xen: require libxc from Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
  2013-02-21 17:57 ` [PATCH 1/4] purgatory: put variables altered by kexec in .data not .bss David Vrabel
  2013-02-21 17:57 ` David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-02-21 17:57 ` David Vrabel
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

libxc from Xen 4.3 added xc_kexec_load() which will be required to
load images into Xen in the future.

Remove all the #ifdef'ery for older versions of libxc.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 configure.ac                       |    5 +-
 kexec/arch/i386/crashdump-x86.c    |  109 ------------------------------------
 kexec/arch/i386/kexec-x86-common.c |  103 ----------------------------------
 kexec/crashdump-xen.c              |   12 ----
 4 files changed, 1 insertions(+), 228 deletions(-)

diff --git a/configure.ac b/configure.ac
index 438b3c9..120a5ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,11 +161,8 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then
 	AC_CHECK_HEADER(xenctrl.h,
-		AC_CHECK_LIB(xenctrl, xc_version, ,
+		AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
 		AC_MSG_NOTICE([Xen support disabled])))
-	if test "$ac_cv_lib_xenctrl_xc_version" = yes ; then
-		AC_CHECK_FUNCS(xc_get_machine_memory_map)
-	fi
 fi
 
 dnl ---Sanity checks
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 245402c..f9709fe 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -43,14 +43,7 @@
 #include "crashdump-x86.h"
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 #include <xenctrl.h>
-#else
-#define __XEN_TOOLS__	1
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xen/sys/privcmd.h>
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
 #endif /* HAVE_LIBXENCTRL */
 
 #include <x86/x86-linux.h>
@@ -294,34 +287,20 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 }
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 static int get_crash_memory_ranges_xen(struct memory_range **range,
 					int *ranges, unsigned long lowmem_limit)
 {
 	int j, rc, ret = -1;
 	struct e820entry e820entries[CRASH_MAX_MEMORY_RANGES];
 	unsigned int i;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 
 	if (!xc) {
 		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
 		goto err;
 	}
-#else
-	xc = xc_interface_open();
-
-	if (xc == -1) {
-		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
-		goto err;
-	}
-#endif
 
 	rc = xc_get_machine_memory_map(xc, e820entries, CRASH_MAX_MEMORY_RANGES);
 
@@ -357,94 +336,6 @@ err:
 static int get_crash_memory_ranges_xen(struct memory_range **range,
 					int *ranges, unsigned long lowmem_limit)
 {
-	int fd, j, rc, ret = -1;
-	privcmd_hypercall_t hypercall;
-	struct e820entry *e820entries = NULL;
-	struct xen_memory_map *xen_memory_map = NULL;
-	unsigned int i;
-
-	fd = open("/proc/xen/privcmd", O_RDWR);
-
-	if (fd == -1) {
-		fprintf(stderr, "%s: open(/proc/xen/privcmd): %m\n", __func__);
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&e820entries, getpagesize(),
-			    sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES);
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(e820entries): %s\n", __func__, strerror(rc));
-		e820entries = NULL;
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&xen_memory_map, getpagesize(),
-			    sizeof(struct xen_memory_map));
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(xen_memory_map): %s\n", __func__, strerror(rc));
-		xen_memory_map = NULL;
-		goto err;
-	}
-
-	if (mlock(e820entries, sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES) == -1) {
-		fprintf(stderr, "%s: mlock(e820entries): %m\n", __func__);
-		goto err;
-	}
-
-	if (mlock(xen_memory_map, sizeof(struct xen_memory_map)) == -1) {
-		fprintf(stderr, "%s: mlock(xen_memory_map): %m\n", __func__);
-		goto err;
-	}
-
-	xen_memory_map->nr_entries = CRASH_MAX_MEMORY_RANGES;
-	set_xen_guest_handle(xen_memory_map->buffer, e820entries);
-
-	hypercall.op = __HYPERVISOR_memory_op;
-	hypercall.arg[0] = XENMEM_machine_memory_map;
-	hypercall.arg[1] = (__u64)xen_memory_map;
-
-	rc = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
-
-	if (rc == -1) {
-		fprintf(stderr, "%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n", __func__);
-		goto err;
-	}
-
-	for (i = 0, j = 0; i < xen_memory_map->nr_entries &&
-				j < CRASH_MAX_MEMORY_RANGES; ++i, ++j) {
-		crash_memory_range[j].start = e820entries[i].addr;
-		crash_memory_range[j].end = e820entries[i].addr + e820entries[i].size - 1;
-		crash_memory_range[j].type = xen_e820_to_kexec_type(e820entries[i].type);
-		segregate_lowmem_region(&j, lowmem_limit);
-	}
-
-	*range = crash_memory_range;
-	*ranges = j;
-
-	qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges);
-
-	if (exclude_region(ranges, crash_reserved_mem.start,
-						crash_reserved_mem.end) < 0)
-		goto err;
-
-	ret = 0;
-
-err:
-	munlock(xen_memory_map, sizeof(struct xen_memory_map));
-	munlock(e820entries, sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES);
-	free(xen_memory_map);
-	free(e820entries);
-	close(fd);
-
-	return ret;
-}
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
-#else
-static int get_crash_memory_ranges_xen(struct memory_range **range,
-					int *ranges, unsigned long lowmem_limit)
-{
 	return 0;
 }
 #endif /* HAVE_LIBXENCTRL */
diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
index 02471a8..dba89f2 100644
--- a/kexec/arch/i386/kexec-x86-common.c
+++ b/kexec/arch/i386/kexec-x86-common.c
@@ -40,15 +40,7 @@
 #include "kexec-x86.h"
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 #include <xenctrl.h>
-#else
-#define __XEN_TOOLS__	1
-#include <x86/x86-linux.h>
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xen/sys/privcmd.h>
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
 #endif /* HAVE_LIBXENCTRL */
 
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
@@ -175,33 +167,19 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
  *
  * @return 0 on success, any other value on failure.
  */
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
 {
 	int rc, ret = -1;
 	struct e820entry e820entries[MAX_MEMORY_RANGES];
 	unsigned int i;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 
 	if (!xc) {
 		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
 		goto err;
 	}
-#else
-	xc = xc_interface_open();
-
-	if (xc == -1) {
-		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
-		goto err;
-	}
-#endif
 
 	rc = xc_get_machine_memory_map(xc, e820entries, MAX_MEMORY_RANGES);
 
@@ -231,87 +209,6 @@ err:
 #else
 static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
 {
-	int fd, rc, ret = -1;
-	privcmd_hypercall_t hypercall;
-	struct e820entry *e820entries = NULL;
-	struct xen_memory_map *xen_memory_map = NULL;
-	unsigned int i;
-
-	fd = open("/proc/xen/privcmd", O_RDWR);
-
-	if (fd == -1) {
-		fprintf(stderr, "%s: open(/proc/xen/privcmd): %m\n", __func__);
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&e820entries, sysconf(_SC_PAGESIZE),
-			    sizeof(struct e820entry) * MAX_MEMORY_RANGES);
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(e820entries): %s\n", __func__, strerror(rc));
-		e820entries = NULL;
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&xen_memory_map, sysconf(_SC_PAGESIZE),
-			    sizeof(struct xen_memory_map));
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(xen_memory_map): %s\n", __func__, strerror(rc));
-		xen_memory_map = NULL;
-		goto err;
-	}
-
-	if (mlock(e820entries, sizeof(struct e820entry) * MAX_MEMORY_RANGES) == -1) {
-		fprintf(stderr, "%s: mlock(e820entries): %m\n", __func__);
-		goto err;
-	}
-
-	if (mlock(xen_memory_map, sizeof(struct xen_memory_map)) == -1) {
-		fprintf(stderr, "%s: mlock(xen_memory_map): %m\n", __func__);
-		goto err;
-	}
-
-	xen_memory_map->nr_entries = MAX_MEMORY_RANGES;
-	set_xen_guest_handle(xen_memory_map->buffer, e820entries);
-
-	hypercall.op = __HYPERVISOR_memory_op;
-	hypercall.arg[0] = XENMEM_machine_memory_map;
-	hypercall.arg[1] = (__u64)xen_memory_map;
-
-	rc = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
-
-	if (rc == -1) {
-		fprintf(stderr, "%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n", __func__);
-		goto err;
-	}
-
-	for (i = 0; i < xen_memory_map->nr_entries; ++i) {
-		memory_range[i].start = e820entries[i].addr;
-		memory_range[i].end = e820entries[i].addr + e820entries[i].size;
-		memory_range[i].type = xen_e820_to_kexec_type(e820entries[i].type);
-	}
-
-	qsort(memory_range, xen_memory_map->nr_entries, sizeof(struct memory_range), compare_ranges);
-
-	*range = memory_range;
-	*ranges = xen_memory_map->nr_entries;
-
-	ret = 0;
-
-err:
-	munlock(xen_memory_map, sizeof(struct xen_memory_map));
-	munlock(e820entries, sizeof(struct e820entry) * MAX_MEMORY_RANGES);
-	free(xen_memory_map);
-	free(e820entries);
-	close(fd);
-
-	return ret;
-}
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
-#else
-static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
-{
 	return 0;
 }
 #endif /* HAVE_LIBXENCTRL */
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index d8bd0f4..ff4706c 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -131,30 +131,18 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
 #ifdef HAVE_LIBXENCTRL
 	int rc;
 	xen_capabilities_info_t capabilities;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
 	if (!xen_present())
 		goto out;
 
 	memset(capabilities, '0', XEN_CAPABILITIES_INFO_LEN);
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 	if ( !xc ) {
 		fprintf(stderr, "failed to open xen control interface.\n");
 		goto out;
 	}
-#else
-	xc = xc_interface_open();
-	if ( xc == -1 ) {
-		fprintf(stderr, "failed to open xen control interface.\n");
-		goto out;
-	}
-#endif
 
 	rc = xc_version(xc, XENVER_capabilities, &capabilities[0]);
 	if ( rc == -1 ) {
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/4] kexec/xen: require libxc from Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (2 preceding siblings ...)
  2013-02-21 17:57 ` [PATCH 2/4] kexec/xen: require libxc from Xen 4.3 David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-02-21 17:57 ` [PATCH 3/4] kexec/xen: use libxc to get location of crash notes David Vrabel
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

libxc from Xen 4.3 added xc_kexec_load() which will be required to
load images into Xen in the future.

Remove all the #ifdef'ery for older versions of libxc.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 configure.ac                       |    5 +-
 kexec/arch/i386/crashdump-x86.c    |  109 ------------------------------------
 kexec/arch/i386/kexec-x86-common.c |  103 ----------------------------------
 kexec/crashdump-xen.c              |   12 ----
 4 files changed, 1 insertions(+), 228 deletions(-)

diff --git a/configure.ac b/configure.ac
index 438b3c9..120a5ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,11 +161,8 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then
 	AC_CHECK_HEADER(xenctrl.h,
-		AC_CHECK_LIB(xenctrl, xc_version, ,
+		AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
 		AC_MSG_NOTICE([Xen support disabled])))
-	if test "$ac_cv_lib_xenctrl_xc_version" = yes ; then
-		AC_CHECK_FUNCS(xc_get_machine_memory_map)
-	fi
 fi
 
 dnl ---Sanity checks
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 245402c..f9709fe 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -43,14 +43,7 @@
 #include "crashdump-x86.h"
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 #include <xenctrl.h>
-#else
-#define __XEN_TOOLS__	1
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xen/sys/privcmd.h>
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
 #endif /* HAVE_LIBXENCTRL */
 
 #include <x86/x86-linux.h>
@@ -294,34 +287,20 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 }
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 static int get_crash_memory_ranges_xen(struct memory_range **range,
 					int *ranges, unsigned long lowmem_limit)
 {
 	int j, rc, ret = -1;
 	struct e820entry e820entries[CRASH_MAX_MEMORY_RANGES];
 	unsigned int i;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 
 	if (!xc) {
 		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
 		goto err;
 	}
-#else
-	xc = xc_interface_open();
-
-	if (xc == -1) {
-		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
-		goto err;
-	}
-#endif
 
 	rc = xc_get_machine_memory_map(xc, e820entries, CRASH_MAX_MEMORY_RANGES);
 
@@ -357,94 +336,6 @@ err:
 static int get_crash_memory_ranges_xen(struct memory_range **range,
 					int *ranges, unsigned long lowmem_limit)
 {
-	int fd, j, rc, ret = -1;
-	privcmd_hypercall_t hypercall;
-	struct e820entry *e820entries = NULL;
-	struct xen_memory_map *xen_memory_map = NULL;
-	unsigned int i;
-
-	fd = open("/proc/xen/privcmd", O_RDWR);
-
-	if (fd == -1) {
-		fprintf(stderr, "%s: open(/proc/xen/privcmd): %m\n", __func__);
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&e820entries, getpagesize(),
-			    sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES);
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(e820entries): %s\n", __func__, strerror(rc));
-		e820entries = NULL;
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&xen_memory_map, getpagesize(),
-			    sizeof(struct xen_memory_map));
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(xen_memory_map): %s\n", __func__, strerror(rc));
-		xen_memory_map = NULL;
-		goto err;
-	}
-
-	if (mlock(e820entries, sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES) == -1) {
-		fprintf(stderr, "%s: mlock(e820entries): %m\n", __func__);
-		goto err;
-	}
-
-	if (mlock(xen_memory_map, sizeof(struct xen_memory_map)) == -1) {
-		fprintf(stderr, "%s: mlock(xen_memory_map): %m\n", __func__);
-		goto err;
-	}
-
-	xen_memory_map->nr_entries = CRASH_MAX_MEMORY_RANGES;
-	set_xen_guest_handle(xen_memory_map->buffer, e820entries);
-
-	hypercall.op = __HYPERVISOR_memory_op;
-	hypercall.arg[0] = XENMEM_machine_memory_map;
-	hypercall.arg[1] = (__u64)xen_memory_map;
-
-	rc = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
-
-	if (rc == -1) {
-		fprintf(stderr, "%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n", __func__);
-		goto err;
-	}
-
-	for (i = 0, j = 0; i < xen_memory_map->nr_entries &&
-				j < CRASH_MAX_MEMORY_RANGES; ++i, ++j) {
-		crash_memory_range[j].start = e820entries[i].addr;
-		crash_memory_range[j].end = e820entries[i].addr + e820entries[i].size - 1;
-		crash_memory_range[j].type = xen_e820_to_kexec_type(e820entries[i].type);
-		segregate_lowmem_region(&j, lowmem_limit);
-	}
-
-	*range = crash_memory_range;
-	*ranges = j;
-
-	qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges);
-
-	if (exclude_region(ranges, crash_reserved_mem.start,
-						crash_reserved_mem.end) < 0)
-		goto err;
-
-	ret = 0;
-
-err:
-	munlock(xen_memory_map, sizeof(struct xen_memory_map));
-	munlock(e820entries, sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES);
-	free(xen_memory_map);
-	free(e820entries);
-	close(fd);
-
-	return ret;
-}
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
-#else
-static int get_crash_memory_ranges_xen(struct memory_range **range,
-					int *ranges, unsigned long lowmem_limit)
-{
 	return 0;
 }
 #endif /* HAVE_LIBXENCTRL */
diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
index 02471a8..dba89f2 100644
--- a/kexec/arch/i386/kexec-x86-common.c
+++ b/kexec/arch/i386/kexec-x86-common.c
@@ -40,15 +40,7 @@
 #include "kexec-x86.h"
 
 #ifdef HAVE_LIBXENCTRL
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 #include <xenctrl.h>
-#else
-#define __XEN_TOOLS__	1
-#include <x86/x86-linux.h>
-#include <xen/xen.h>
-#include <xen/memory.h>
-#include <xen/sys/privcmd.h>
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
 #endif /* HAVE_LIBXENCTRL */
 
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
@@ -175,33 +167,19 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
  *
  * @return 0 on success, any other value on failure.
  */
-#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
 static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
 {
 	int rc, ret = -1;
 	struct e820entry e820entries[MAX_MEMORY_RANGES];
 	unsigned int i;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 
 	if (!xc) {
 		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
 		goto err;
 	}
-#else
-	xc = xc_interface_open();
-
-	if (xc == -1) {
-		fprintf(stderr, "%s: Failed to open Xen control interface\n", __func__);
-		goto err;
-	}
-#endif
 
 	rc = xc_get_machine_memory_map(xc, e820entries, MAX_MEMORY_RANGES);
 
@@ -231,87 +209,6 @@ err:
 #else
 static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
 {
-	int fd, rc, ret = -1;
-	privcmd_hypercall_t hypercall;
-	struct e820entry *e820entries = NULL;
-	struct xen_memory_map *xen_memory_map = NULL;
-	unsigned int i;
-
-	fd = open("/proc/xen/privcmd", O_RDWR);
-
-	if (fd == -1) {
-		fprintf(stderr, "%s: open(/proc/xen/privcmd): %m\n", __func__);
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&e820entries, sysconf(_SC_PAGESIZE),
-			    sizeof(struct e820entry) * MAX_MEMORY_RANGES);
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(e820entries): %s\n", __func__, strerror(rc));
-		e820entries = NULL;
-		goto err;
-	}
-
-	rc = posix_memalign((void **)&xen_memory_map, sysconf(_SC_PAGESIZE),
-			    sizeof(struct xen_memory_map));
-
-	if (rc) {
-		fprintf(stderr, "%s: posix_memalign(xen_memory_map): %s\n", __func__, strerror(rc));
-		xen_memory_map = NULL;
-		goto err;
-	}
-
-	if (mlock(e820entries, sizeof(struct e820entry) * MAX_MEMORY_RANGES) == -1) {
-		fprintf(stderr, "%s: mlock(e820entries): %m\n", __func__);
-		goto err;
-	}
-
-	if (mlock(xen_memory_map, sizeof(struct xen_memory_map)) == -1) {
-		fprintf(stderr, "%s: mlock(xen_memory_map): %m\n", __func__);
-		goto err;
-	}
-
-	xen_memory_map->nr_entries = MAX_MEMORY_RANGES;
-	set_xen_guest_handle(xen_memory_map->buffer, e820entries);
-
-	hypercall.op = __HYPERVISOR_memory_op;
-	hypercall.arg[0] = XENMEM_machine_memory_map;
-	hypercall.arg[1] = (__u64)xen_memory_map;
-
-	rc = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
-
-	if (rc == -1) {
-		fprintf(stderr, "%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n", __func__);
-		goto err;
-	}
-
-	for (i = 0; i < xen_memory_map->nr_entries; ++i) {
-		memory_range[i].start = e820entries[i].addr;
-		memory_range[i].end = e820entries[i].addr + e820entries[i].size;
-		memory_range[i].type = xen_e820_to_kexec_type(e820entries[i].type);
-	}
-
-	qsort(memory_range, xen_memory_map->nr_entries, sizeof(struct memory_range), compare_ranges);
-
-	*range = memory_range;
-	*ranges = xen_memory_map->nr_entries;
-
-	ret = 0;
-
-err:
-	munlock(xen_memory_map, sizeof(struct xen_memory_map));
-	munlock(e820entries, sizeof(struct e820entry) * MAX_MEMORY_RANGES);
-	free(xen_memory_map);
-	free(e820entries);
-	close(fd);
-
-	return ret;
-}
-#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
-#else
-static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
-{
 	return 0;
 }
 #endif /* HAVE_LIBXENCTRL */
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index d8bd0f4..ff4706c 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -131,30 +131,18 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
 #ifdef HAVE_LIBXENCTRL
 	int rc;
 	xen_capabilities_info_t capabilities;
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc_interface *xc;
-#else
-	int xc;
-#endif
 
 	if (!xen_present())
 		goto out;
 
 	memset(capabilities, '0', XEN_CAPABILITIES_INFO_LEN);
 
-#ifdef XENCTRL_HAS_XC_INTERFACE
 	xc = xc_interface_open(NULL, NULL, 0);
 	if ( !xc ) {
 		fprintf(stderr, "failed to open xen control interface.\n");
 		goto out;
 	}
-#else
-	xc = xc_interface_open();
-	if ( xc == -1 ) {
-		fprintf(stderr, "failed to open xen control interface.\n");
-		goto out;
-	}
-#endif
 
 	rc = xc_version(xc, XENVER_capabilities, &capabilities[0]);
 	if ( rc == -1 ) {
-- 
1.7.2.5


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/4] kexec/xen: use libxc to get location of crash notes
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (4 preceding siblings ...)
  2013-02-21 17:57 ` [PATCH 3/4] kexec/xen: use libxc to get location of crash notes David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-02-21 17:57 ` [PATCH 4/4] kexec/xen: directly load images images into Xen David Vrabel
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

Use xc_kexec_get_range(KEXEC_RANGE_MA_CPU) instead of parsing
/proc/iomem (which is only populated by non-upstream ("classic") Xen
kernels).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 kexec/crashdump-xen.c |   61 ++++++++++++++++++++++++++++---------------------
 1 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index ff4706c..13335a5 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -163,42 +163,51 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
 	return machine;
 }
 
-static int xen_crash_note_callback(void *UNUSED(data), int nr,
-				   char *UNUSED(str),
-				   unsigned long base,
-				   unsigned long length)
-{
-	struct crash_note_info *note = xen_phys_notes + nr;
-
-	note->base = base;
-	note->length = length;
-
-	return 0;
-}
-
+#ifdef HAVE_LIBXENCTRL
 int xen_get_nr_phys_cpus(void)
 {
-	char *match = "Crash note\n";
-	int cpus, n;
+	xc_interface *xc;
+	int cpu;
 
 	if (xen_phys_cpus)
 		return xen_phys_cpus;
 
-	if ((cpus = kexec_iomem_for_each_line(match, NULL, NULL))) {
-		n = sizeof(struct crash_note_info) * cpus;
-		xen_phys_notes = malloc(n);
-		if (!xen_phys_notes) {
-			fprintf(stderr, "failed to allocate xen_phys_notes.\n");
+	xc = xc_interface_open(NULL, NULL, 0);
+	if ( !xc ) {
+		fprintf(stderr, "failed to open xen control interface.\n");
+		return -1;
+	}
+
+	for (cpu = 0;; cpu++) {
+		uint64_t size, start;
+		int ret;
+
+		ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_CPU, cpu, &size, &start);
+		if (ret < 0)
+			break;
+
+		xen_phys_notes = realloc(xen_phys_notes,
+					 sizeof(*xen_phys_notes) * (cpu + 1));
+		if (xen_phys_notes == NULL)
 			return -1;
-		}
-		memset(xen_phys_notes, 0, n);
-		kexec_iomem_for_each_line(match,
-					  xen_crash_note_callback, NULL);
-		xen_phys_cpus = cpus;
+
+		xen_phys_notes[cpu].base = start;
+		xen_phys_notes[cpu].length = size;
 	}
 
-	return cpus;
+	xc_interface_close(xc);
+
+	xen_phys_cpus = cpu;
+
+	return cpu;
 }
+#else
+int xen_get_nr_phys_cpus(void)
+{
+	return -1;
+}
+#endif
+
 
 int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
 {
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/4] kexec/xen: use libxc to get location of crash notes
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (3 preceding siblings ...)
  2013-02-21 17:57 ` David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-02-26 13:53   ` [Xen-devel] " Don Slutz
  2013-02-26 13:53   ` Don Slutz
  2013-02-21 17:57 ` David Vrabel
                   ` (8 subsequent siblings)
  13 siblings, 2 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

Use xc_kexec_get_range(KEXEC_RANGE_MA_CPU) instead of parsing
/proc/iomem (which is only populated by non-upstream ("classic") Xen
kernels).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 kexec/crashdump-xen.c |   61 ++++++++++++++++++++++++++++---------------------
 1 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index ff4706c..13335a5 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -163,42 +163,51 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
 	return machine;
 }
 
-static int xen_crash_note_callback(void *UNUSED(data), int nr,
-				   char *UNUSED(str),
-				   unsigned long base,
-				   unsigned long length)
-{
-	struct crash_note_info *note = xen_phys_notes + nr;
-
-	note->base = base;
-	note->length = length;
-
-	return 0;
-}
-
+#ifdef HAVE_LIBXENCTRL
 int xen_get_nr_phys_cpus(void)
 {
-	char *match = "Crash note\n";
-	int cpus, n;
+	xc_interface *xc;
+	int cpu;
 
 	if (xen_phys_cpus)
 		return xen_phys_cpus;
 
-	if ((cpus = kexec_iomem_for_each_line(match, NULL, NULL))) {
-		n = sizeof(struct crash_note_info) * cpus;
-		xen_phys_notes = malloc(n);
-		if (!xen_phys_notes) {
-			fprintf(stderr, "failed to allocate xen_phys_notes.\n");
+	xc = xc_interface_open(NULL, NULL, 0);
+	if ( !xc ) {
+		fprintf(stderr, "failed to open xen control interface.\n");
+		return -1;
+	}
+
+	for (cpu = 0;; cpu++) {
+		uint64_t size, start;
+		int ret;
+
+		ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_CPU, cpu, &size, &start);
+		if (ret < 0)
+			break;
+
+		xen_phys_notes = realloc(xen_phys_notes,
+					 sizeof(*xen_phys_notes) * (cpu + 1));
+		if (xen_phys_notes == NULL)
 			return -1;
-		}
-		memset(xen_phys_notes, 0, n);
-		kexec_iomem_for_each_line(match,
-					  xen_crash_note_callback, NULL);
-		xen_phys_cpus = cpus;
+
+		xen_phys_notes[cpu].base = start;
+		xen_phys_notes[cpu].length = size;
 	}
 
-	return cpus;
+	xc_interface_close(xc);
+
+	xen_phys_cpus = cpu;
+
+	return cpu;
 }
+#else
+int xen_get_nr_phys_cpus(void)
+{
+	return -1;
+}
+#endif
+
 
 int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
 {
-- 
1.7.2.5


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/4] kexec/xen: directly load images images into Xen
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (6 preceding siblings ...)
  2013-02-21 17:57 ` [PATCH 4/4] kexec/xen: directly load images images into Xen David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-02-22  8:14 ` [PATCH 0/4] kexec-tools: add support for Xen 4.3 Jan Beulich
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

Xen 4.3 has an improvided kexec hypercall ABI that allows images to be
loaded and executed without any kernel involvement.  Use the API
provided by libxc to load images when running in a Xen guest.

Support for loading images via the kexec_load syscall in non-upstream
("classic") Xen kernels is no longer supported.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 kexec/Makefile                     |    1 +
 kexec/arch/i386/crashdump-x86.c    |   19 ++++++++-
 kexec/arch/i386/kexec-x86-common.c |    6 +-
 kexec/crashdump-xen.c              |   34 ++++++++++++++++
 kexec/crashdump.h                  |    3 +-
 kexec/kexec-xen.c                  |   76 ++++++++++++++++++++++++++++++++++++
 kexec/kexec.c                      |   10 ++++-
 kexec/kexec.h                      |    5 ++
 8 files changed, 147 insertions(+), 7 deletions(-)
 create mode 100644 kexec/kexec-xen.c

diff --git a/kexec/Makefile b/kexec/Makefile
index 8a6138d..dc9dab1 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -25,6 +25,7 @@ KEXEC_SRCS_base += kexec/phys_arch.c
 KEXEC_SRCS_base += kexec/kernel_version.c
 KEXEC_SRCS_base += kexec/lzma.c
 KEXEC_SRCS_base += kexec/zlib.c
+KEXEC_SRCS_base += kexec/kexec-xen.c
 
 KEXEC_GENERATED_SRCS += $(PURGATORY_HEX_C)
 
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index f9709fe..46a76f9 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -939,11 +939,28 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	return 0;
 }
 
+int get_crashkernel_region(uint64_t *start, uint64_t *end)
+{
+	int ret;
+
+	if (xen_present())
+		ret = xen_get_crashkernel_region(start, end);
+	else
+		ret = parse_iomem_single("Crash kernel\n", start, end);
+	if (ret < 0)
+		return ret;
+	if (start == end)
+		return -1;
+	return 0;
+}
+
 int is_crashkernel_mem_reserved(void)
 {
 	uint64_t start, end;
+	int rc;
 
-	if (parse_iomem_single("Crash kernel\n", &start, &end) || start == end)
+	rc = get_crashkernel_region(&start, &end);
+	if (rc < 0)
 		return 0;
 
 	crash_reserved_mem.start = start;
diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
index dba89f2..2477dee 100644
--- a/kexec/arch/i386/kexec-x86-common.c
+++ b/kexec/arch/i386/kexec-x86-common.c
@@ -364,9 +364,9 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 	    !(kexec_flags & KEXEC_PRESERVE_CONTEXT)) {
 		uint64_t start, end;
 
-		ret = parse_iomem_single("Crash kernel\n", &start, &end);
-		if (ret != 0) {
-			fprintf(stderr, "parse_iomem_single failed.\n");
+		ret = get_crashkernel_region(&start, &end);
+		if (ret < 0) {
+			fprintf(stderr, "No crash region available.\n");
 			return -1;
 		}
 
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index 13335a5..434fe66 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -223,3 +223,37 @@ int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
 
 	return 0;
 }
+
+#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;
+}
+#else
+int xen_get_crashkernel_region(uint64_t *start, uint64_t *end)
+{
+	return -1;
+}
+#endif
diff --git a/kexec/crashdump.h b/kexec/crashdump.h
index 0f7c2ea..95f1f0c 100644
--- a/kexec/crashdump.h
+++ b/kexec/crashdump.h
@@ -1,6 +1,7 @@
 #ifndef CRASHDUMP_H
 #define CRASHDUMP_H
 
+int get_crashkernel_region(uint64_t *start, uint64_t *end);
 extern int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len);
 extern int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len);
 extern int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len);
@@ -56,9 +57,9 @@ unsigned long crash_architecture(struct crash_elf_info *elf_info);
 unsigned long phys_to_virt(struct crash_elf_info *elf_info,
 			   unsigned long paddr);
 
-int xen_present(void);
 unsigned long xen_architecture(struct crash_elf_info *elf_info);
 int xen_get_nr_phys_cpus(void);
 int xen_get_note(int cpu, uint64_t *addr, uint64_t *len);
+int xen_get_crashkernel_region(uint64_t *start, uint64_t *end);
 
 #endif /* CRASHDUMP_H */
diff --git a/kexec/kexec-xen.c b/kexec/kexec-xen.c
new file mode 100644
index 0000000..8bc16aa
--- /dev/null
+++ b/kexec/kexec-xen.c
@@ -0,0 +1,76 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "kexec.h"
+#include "crashdump.h"
+
+#include "config.h"
+
+#ifdef HAVE_LIBXENCTRL
+#include <xenctrl.h>
+
+#include "crashdump.h"
+
+int xen_kexec_load(uint64_t entry,
+		   uint32_t nr_segments, struct kexec_segment *segments,
+		   uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	xc_hypercall_buffer_array_t *array = NULL;
+	uint8_t type;
+	uint8_t arch;
+	xen_kexec_segment_t *xen_segs;
+	int s;
+	int ret = -1;
+
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	xen_segs = calloc(nr_segments, sizeof(*xen_segs));
+	if (!xen_segs)
+		goto out;
+
+	array = xc_hypercall_buffer_array_create(xch, nr_segments);
+	if (array == NULL)
+		goto out;
+
+	for (s = 0; s < nr_segments; s++) {
+		DECLARE_HYPERCALL_BUFFER(void, seg_buf);
+
+		seg_buf = xc_hypercall_buffer_array_alloc(xch, array, s,
+							  seg_buf, segments[s].bufsz);
+		if (seg_buf == NULL)
+			goto out;
+		memcpy(seg_buf, segments[s].buf, segments[s].bufsz);
+
+		set_xen_guest_handle(xen_segs[s].buf, seg_buf);
+		xen_segs[s].buf_size = segments[s].bufsz;
+		xen_segs[s].dest_maddr = (uint64_t)segments[s].mem;
+		xen_segs[s].dest_size = segments[s].memsz;
+	}
+
+	type = kexec_flags & KEXEC_TYPE_CRASH;
+	arch = (kexec_flags >> 16) & 0xffff;
+
+	ret = xc_kexec_load(xch, type, arch, entry, nr_segments, xen_segs);
+
+out:
+	xc_hypercall_buffer_array_destroy(xch, array);
+	free(xen_segs);
+	xc_interface_close(xch);
+
+	return ret;
+}
+
+#else /* ! HAVE_LIBXENCTRL */
+
+int xen_kexec_load(uint64_t entry,
+		   uint32_t nr_segments, struct kexec_segment *segments,
+		   uint64_t kexec_flags)
+{
+	return -1;
+}
+
+#endif
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 16c6308..3eab839 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -764,8 +764,14 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 		info.entry, info.kexec_flags);
 	print_segments(stderr, &info);
 #endif
-	result = kexec_load(
-		info.entry, info.nr_segments, info.segment, info.kexec_flags);
+	if (xen_present())
+		result = xen_kexec_load((uint64_t)info.entry,
+					info.nr_segments, info.segment,
+					info.kexec_flags);
+	else
+		result = kexec_load(info.entry,
+				    info.nr_segments, info.segment,
+				    info.kexec_flags);
 	if (result != 0) {
 		/* The load failed, print some debugging information */
 		fprintf(stderr, "kexec_load failed: %s\n", 
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 94c62c1..4ef8906 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -280,4 +280,9 @@ extern int add_backup_segments(struct kexec_info *info,
 
 char *concat_cmdline(const char *base, const char *append);
 
+int xen_present(void);
+int xen_kexec_load(uint64_t entry,
+		   uint32_t nr_segments, struct kexec_segment *segments,
+		   uint64_t kexec_flags);
+
 #endif /* KEXEC_H */
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/4] kexec/xen: directly load images images into Xen
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (5 preceding siblings ...)
  2013-02-21 17:57 ` David Vrabel
@ 2013-02-21 17:57 ` David Vrabel
  2013-03-12 11:29   ` Daniel Kiper
  2013-03-12 11:29   ` Daniel Kiper
  2013-02-21 17:57 ` David Vrabel
                   ` (6 subsequent siblings)
  13 siblings, 2 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-21 17:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Daniel Kiper, kexec, David Vrabel

From: David Vrabel <david.vrabel@citrix.com>

Xen 4.3 has an improvided kexec hypercall ABI that allows images to be
loaded and executed without any kernel involvement.  Use the API
provided by libxc to load images when running in a Xen guest.

Support for loading images via the kexec_load syscall in non-upstream
("classic") Xen kernels is no longer supported.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 kexec/Makefile                     |    1 +
 kexec/arch/i386/crashdump-x86.c    |   19 ++++++++-
 kexec/arch/i386/kexec-x86-common.c |    6 +-
 kexec/crashdump-xen.c              |   34 ++++++++++++++++
 kexec/crashdump.h                  |    3 +-
 kexec/kexec-xen.c                  |   76 ++++++++++++++++++++++++++++++++++++
 kexec/kexec.c                      |   10 ++++-
 kexec/kexec.h                      |    5 ++
 8 files changed, 147 insertions(+), 7 deletions(-)
 create mode 100644 kexec/kexec-xen.c

diff --git a/kexec/Makefile b/kexec/Makefile
index 8a6138d..dc9dab1 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -25,6 +25,7 @@ KEXEC_SRCS_base += kexec/phys_arch.c
 KEXEC_SRCS_base += kexec/kernel_version.c
 KEXEC_SRCS_base += kexec/lzma.c
 KEXEC_SRCS_base += kexec/zlib.c
+KEXEC_SRCS_base += kexec/kexec-xen.c
 
 KEXEC_GENERATED_SRCS += $(PURGATORY_HEX_C)
 
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index f9709fe..46a76f9 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -939,11 +939,28 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	return 0;
 }
 
+int get_crashkernel_region(uint64_t *start, uint64_t *end)
+{
+	int ret;
+
+	if (xen_present())
+		ret = xen_get_crashkernel_region(start, end);
+	else
+		ret = parse_iomem_single("Crash kernel\n", start, end);
+	if (ret < 0)
+		return ret;
+	if (start == end)
+		return -1;
+	return 0;
+}
+
 int is_crashkernel_mem_reserved(void)
 {
 	uint64_t start, end;
+	int rc;
 
-	if (parse_iomem_single("Crash kernel\n", &start, &end) || start == end)
+	rc = get_crashkernel_region(&start, &end);
+	if (rc < 0)
 		return 0;
 
 	crash_reserved_mem.start = start;
diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
index dba89f2..2477dee 100644
--- a/kexec/arch/i386/kexec-x86-common.c
+++ b/kexec/arch/i386/kexec-x86-common.c
@@ -364,9 +364,9 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 	    !(kexec_flags & KEXEC_PRESERVE_CONTEXT)) {
 		uint64_t start, end;
 
-		ret = parse_iomem_single("Crash kernel\n", &start, &end);
-		if (ret != 0) {
-			fprintf(stderr, "parse_iomem_single failed.\n");
+		ret = get_crashkernel_region(&start, &end);
+		if (ret < 0) {
+			fprintf(stderr, "No crash region available.\n");
 			return -1;
 		}
 
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index 13335a5..434fe66 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -223,3 +223,37 @@ int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
 
 	return 0;
 }
+
+#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;
+}
+#else
+int xen_get_crashkernel_region(uint64_t *start, uint64_t *end)
+{
+	return -1;
+}
+#endif
diff --git a/kexec/crashdump.h b/kexec/crashdump.h
index 0f7c2ea..95f1f0c 100644
--- a/kexec/crashdump.h
+++ b/kexec/crashdump.h
@@ -1,6 +1,7 @@
 #ifndef CRASHDUMP_H
 #define CRASHDUMP_H
 
+int get_crashkernel_region(uint64_t *start, uint64_t *end);
 extern int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len);
 extern int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len);
 extern int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len);
@@ -56,9 +57,9 @@ unsigned long crash_architecture(struct crash_elf_info *elf_info);
 unsigned long phys_to_virt(struct crash_elf_info *elf_info,
 			   unsigned long paddr);
 
-int xen_present(void);
 unsigned long xen_architecture(struct crash_elf_info *elf_info);
 int xen_get_nr_phys_cpus(void);
 int xen_get_note(int cpu, uint64_t *addr, uint64_t *len);
+int xen_get_crashkernel_region(uint64_t *start, uint64_t *end);
 
 #endif /* CRASHDUMP_H */
diff --git a/kexec/kexec-xen.c b/kexec/kexec-xen.c
new file mode 100644
index 0000000..8bc16aa
--- /dev/null
+++ b/kexec/kexec-xen.c
@@ -0,0 +1,76 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "kexec.h"
+#include "crashdump.h"
+
+#include "config.h"
+
+#ifdef HAVE_LIBXENCTRL
+#include <xenctrl.h>
+
+#include "crashdump.h"
+
+int xen_kexec_load(uint64_t entry,
+		   uint32_t nr_segments, struct kexec_segment *segments,
+		   uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	xc_hypercall_buffer_array_t *array = NULL;
+	uint8_t type;
+	uint8_t arch;
+	xen_kexec_segment_t *xen_segs;
+	int s;
+	int ret = -1;
+
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	xen_segs = calloc(nr_segments, sizeof(*xen_segs));
+	if (!xen_segs)
+		goto out;
+
+	array = xc_hypercall_buffer_array_create(xch, nr_segments);
+	if (array == NULL)
+		goto out;
+
+	for (s = 0; s < nr_segments; s++) {
+		DECLARE_HYPERCALL_BUFFER(void, seg_buf);
+
+		seg_buf = xc_hypercall_buffer_array_alloc(xch, array, s,
+							  seg_buf, segments[s].bufsz);
+		if (seg_buf == NULL)
+			goto out;
+		memcpy(seg_buf, segments[s].buf, segments[s].bufsz);
+
+		set_xen_guest_handle(xen_segs[s].buf, seg_buf);
+		xen_segs[s].buf_size = segments[s].bufsz;
+		xen_segs[s].dest_maddr = (uint64_t)segments[s].mem;
+		xen_segs[s].dest_size = segments[s].memsz;
+	}
+
+	type = kexec_flags & KEXEC_TYPE_CRASH;
+	arch = (kexec_flags >> 16) & 0xffff;
+
+	ret = xc_kexec_load(xch, type, arch, entry, nr_segments, xen_segs);
+
+out:
+	xc_hypercall_buffer_array_destroy(xch, array);
+	free(xen_segs);
+	xc_interface_close(xch);
+
+	return ret;
+}
+
+#else /* ! HAVE_LIBXENCTRL */
+
+int xen_kexec_load(uint64_t entry,
+		   uint32_t nr_segments, struct kexec_segment *segments,
+		   uint64_t kexec_flags)
+{
+	return -1;
+}
+
+#endif
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 16c6308..3eab839 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -764,8 +764,14 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 		info.entry, info.kexec_flags);
 	print_segments(stderr, &info);
 #endif
-	result = kexec_load(
-		info.entry, info.nr_segments, info.segment, info.kexec_flags);
+	if (xen_present())
+		result = xen_kexec_load((uint64_t)info.entry,
+					info.nr_segments, info.segment,
+					info.kexec_flags);
+	else
+		result = kexec_load(info.entry,
+				    info.nr_segments, info.segment,
+				    info.kexec_flags);
 	if (result != 0) {
 		/* The load failed, print some debugging information */
 		fprintf(stderr, "kexec_load failed: %s\n", 
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 94c62c1..4ef8906 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -280,4 +280,9 @@ extern int add_backup_segments(struct kexec_info *info,
 
 char *concat_cmdline(const char *base, const char *append);
 
+int xen_present(void);
+int xen_kexec_load(uint64_t entry,
+		   uint32_t nr_segments, struct kexec_segment *segments,
+		   uint64_t kexec_flags);
+
 #endif /* KEXEC_H */
-- 
1.7.2.5


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (7 preceding siblings ...)
  2013-02-21 17:57 ` David Vrabel
@ 2013-02-22  8:14 ` Jan Beulich
  2013-02-22  8:14 ` [Xen-devel] " Jan Beulich
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Jan Beulich @ 2013-02-22  8:14 UTC (permalink / raw)
  To: David Vrabel; +Cc: Daniel Kiper, kexec, xen-devel

>>> On 21.02.13 at 18:57, David Vrabel <david.vrabel@citrix.com> wrote:
> The series adds support for the new hypercall ABI which should be
> provided by Xen 4.3.  Images are loaded into Xen directly with no
> kernel involvement.
> 
> Do not apply until the hypervisor side patches are applied to Xen.
> 
> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
> sure why I had problems, perhaps a toolstack specific issue?
> 
> Patch 2 makes libxc 4.3 mandatory for Xen support.

That doesn't sound right. How do you envision this to be
incorporated into existing distros that don't right away switch
to Xen 4.3?

Jan

> Patch 3 removes a use of /proc/iomem in favour of libxc.
> 
> Patch 4 adds the support for loading an image into Xen.
> 
> This series explicitly drops support for older version of libxc/Xen as
> supporting kexec on these hypervisors requires kernel support that
> will never be available upstream.
> 
> David
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org 
> http://lists.xen.org/xen-devel 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (8 preceding siblings ...)
  2013-02-22  8:14 ` [PATCH 0/4] kexec-tools: add support for Xen 4.3 Jan Beulich
@ 2013-02-22  8:14 ` Jan Beulich
  2013-02-22 11:39   ` David Vrabel
  2013-02-22 11:39   ` David Vrabel
  2013-02-25 18:34 ` Don Slutz
                   ` (3 subsequent siblings)
  13 siblings, 2 replies; 23+ messages in thread
From: Jan Beulich @ 2013-02-22  8:14 UTC (permalink / raw)
  To: David Vrabel; +Cc: Daniel Kiper, kexec, xen-devel

>>> On 21.02.13 at 18:57, David Vrabel <david.vrabel@citrix.com> wrote:
> The series adds support for the new hypercall ABI which should be
> provided by Xen 4.3.  Images are loaded into Xen directly with no
> kernel involvement.
> 
> Do not apply until the hypervisor side patches are applied to Xen.
> 
> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
> sure why I had problems, perhaps a toolstack specific issue?
> 
> Patch 2 makes libxc 4.3 mandatory for Xen support.

That doesn't sound right. How do you envision this to be
incorporated into existing distros that don't right away switch
to Xen 4.3?

Jan

> Patch 3 removes a use of /proc/iomem in favour of libxc.
> 
> Patch 4 adds the support for loading an image into Xen.
> 
> This series explicitly drops support for older version of libxc/Xen as
> supporting kexec on these hypervisors requires kernel support that
> will never be available upstream.
> 
> David
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org 
> http://lists.xen.org/xen-devel 




_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-22  8:14 ` [Xen-devel] " Jan Beulich
  2013-02-22 11:39   ` David Vrabel
@ 2013-02-22 11:39   ` David Vrabel
  1 sibling, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-22 11:39 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Daniel Kiper, kexec, Eric W. Biederman, xen-devel

On 22/02/13 08:14, Jan Beulich wrote:
>>>> On 21.02.13 at 18:57, David Vrabel <david.vrabel@citrix.com> wrote:
>> The series adds support for the new hypercall ABI which should be
>> provided by Xen 4.3.  Images are loaded into Xen directly with no
>> kernel involvement.
>>
>> Do not apply until the hypervisor side patches are applied to Xen.
>>
>> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
>> sure why I had problems, perhaps a toolstack specific issue?
>>
>> Patch 2 makes libxc 4.3 mandatory for Xen support.
> 
> That doesn't sound right. How do you envision this to be
> incorporated into existing distros that don't right away switch
> to Xen 4.3?

Eric Bierderman said in an earlier thread[1]:

"Certainly /sbin/kexec will only support the new hypercall once the
support has merged."

David

[1] http://lists.xen.org/archives/html/xen-devel/2013-01/msg00754.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-22  8:14 ` [Xen-devel] " Jan Beulich
@ 2013-02-22 11:39   ` David Vrabel
  2013-02-22 11:39   ` David Vrabel
  1 sibling, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-22 11:39 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Daniel Kiper, kexec, Eric W. Biederman, xen-devel

On 22/02/13 08:14, Jan Beulich wrote:
>>>> On 21.02.13 at 18:57, David Vrabel <david.vrabel@citrix.com> wrote:
>> The series adds support for the new hypercall ABI which should be
>> provided by Xen 4.3.  Images are loaded into Xen directly with no
>> kernel involvement.
>>
>> Do not apply until the hypervisor side patches are applied to Xen.
>>
>> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
>> sure why I had problems, perhaps a toolstack specific issue?
>>
>> Patch 2 makes libxc 4.3 mandatory for Xen support.
> 
> That doesn't sound right. How do you envision this to be
> incorporated into existing distros that don't right away switch
> to Xen 4.3?

Eric Bierderman said in an earlier thread[1]:

"Certainly /sbin/kexec will only support the new hypercall once the
support has merged."

David

[1] http://lists.xen.org/archives/html/xen-devel/2013-01/msg00754.html

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (9 preceding siblings ...)
  2013-02-22  8:14 ` [Xen-devel] " Jan Beulich
@ 2013-02-25 18:34 ` Don Slutz
  2013-02-25 18:34 ` [Xen-devel] " Don Slutz
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Don Slutz @ 2013-02-25 18:34 UTC (permalink / raw)
  To: David Vrabel; +Cc: Daniel Kiper, kexec, xen-devel

On 02/21/13 12:57, David Vrabel wrote:
> The series adds support for the new hypercall ABI which should be
> provided by Xen 4.3.  Images are loaded into Xen directly with no
> kernel involvement.
>
> Do not apply until the hypervisor side patches are applied to Xen.
>
> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
> sure why I had problems, perhaps a toolstack specific issue?
>
> Patch 2 makes libxc 4.3 mandatory for Xen support.
>
> Patch 3 removes a use of /proc/iomem in favour of libxc.
>
> Patch 4 adds the support for loading an image into Xen.
>
> This series explicitly drops support for older version of libxc/Xen as
> supporting kexec on these hypervisors requires kernel support that
> will never be available upstream.
>
> David
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
I did not find a fix/change to get_xen_vmcoreinfo() to call on 
xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, ...

I found the following to work.
    -Don Slutz

 From 2cabc018d7613b0d2ac487cbf2a2e9438a441a8d Mon Sep 17 00:00:00 2001
From: Don Slutz <Don@CloudSwitch.com>
Date: Fri, 22 Feb 2013 22:27:03 -0500
Subject: [PATCH 1/2] Switch to use xc_kexec_get_range for 
get_xen_vmcoreinfo.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
  kexec/crashdump-xen.c |   20 ++++++++++++++++++++
  kexec/crashdump.c     |    2 ++
  2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index 56b0653..8179b72 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -161,6 +161,26 @@ 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;
+        int ret = 0;
+
+       xc = xc_interface_open(NULL, NULL, 0);
+       if ( !xc ) {
+               fprintf(stderr, "failed to open xen control interface.\n");
+               return -1;
+       }
+
+        ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, 0, len, 
addr);
+
+       xc_interface_close(xc);
+
+        if (ret < 0)
+            return -1;
+        return 0;
+}
+
  int xen_get_nr_phys_cpus(void)
  {
         xc_interface *xc;
diff --git a/kexec/crashdump.c b/kexec/crashdump.c
index 847d080..3d2c1b9 100644
--- a/kexec/crashdump.c
+++ b/kexec/crashdump.c
@@ -142,7 +142,9 @@ int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len)
         return get_vmcoreinfo("/sys/kernel/vmcoreinfo", addr, len);
  }

+#ifndef HAVE_LIBXENCTRL
  int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len)
  {
         return get_vmcoreinfo("/sys/hypervisor/vmcoreinfo", addr, len);
  }
+#endif
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (10 preceding siblings ...)
  2013-02-25 18:34 ` Don Slutz
@ 2013-02-25 18:34 ` Don Slutz
  2013-02-25 19:34   ` David Vrabel
  2013-02-25 19:34   ` David Vrabel
  2013-03-08 10:30 ` Daniel Kiper
  2013-03-08 10:30 ` Daniel Kiper
  13 siblings, 2 replies; 23+ messages in thread
From: Don Slutz @ 2013-02-25 18:34 UTC (permalink / raw)
  To: David Vrabel; +Cc: Daniel Kiper, kexec, xen-devel

On 02/21/13 12:57, David Vrabel wrote:
> The series adds support for the new hypercall ABI which should be
> provided by Xen 4.3.  Images are loaded into Xen directly with no
> kernel involvement.
>
> Do not apply until the hypervisor side patches are applied to Xen.
>
> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
> sure why I had problems, perhaps a toolstack specific issue?
>
> Patch 2 makes libxc 4.3 mandatory for Xen support.
>
> Patch 3 removes a use of /proc/iomem in favour of libxc.
>
> Patch 4 adds the support for loading an image into Xen.
>
> This series explicitly drops support for older version of libxc/Xen as
> supporting kexec on these hypervisors requires kernel support that
> will never be available upstream.
>
> David
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
I did not find a fix/change to get_xen_vmcoreinfo() to call on 
xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, ...

I found the following to work.
    -Don Slutz

 From 2cabc018d7613b0d2ac487cbf2a2e9438a441a8d Mon Sep 17 00:00:00 2001
From: Don Slutz <Don@CloudSwitch.com>
Date: Fri, 22 Feb 2013 22:27:03 -0500
Subject: [PATCH 1/2] Switch to use xc_kexec_get_range for 
get_xen_vmcoreinfo.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
  kexec/crashdump-xen.c |   20 ++++++++++++++++++++
  kexec/crashdump.c     |    2 ++
  2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index 56b0653..8179b72 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -161,6 +161,26 @@ 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;
+        int ret = 0;
+
+       xc = xc_interface_open(NULL, NULL, 0);
+       if ( !xc ) {
+               fprintf(stderr, "failed to open xen control interface.\n");
+               return -1;
+       }
+
+        ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, 0, len, 
addr);
+
+       xc_interface_close(xc);
+
+        if (ret < 0)
+            return -1;
+        return 0;
+}
+
  int xen_get_nr_phys_cpus(void)
  {
         xc_interface *xc;
diff --git a/kexec/crashdump.c b/kexec/crashdump.c
index 847d080..3d2c1b9 100644
--- a/kexec/crashdump.c
+++ b/kexec/crashdump.c
@@ -142,7 +142,9 @@ int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len)
         return get_vmcoreinfo("/sys/kernel/vmcoreinfo", addr, len);
  }

+#ifndef HAVE_LIBXENCTRL
  int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len)
  {
         return get_vmcoreinfo("/sys/hypervisor/vmcoreinfo", addr, len);
  }
+#endif
-- 
1.7.1

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-25 18:34 ` [Xen-devel] " Don Slutz
  2013-02-25 19:34   ` David Vrabel
@ 2013-02-25 19:34   ` David Vrabel
  1 sibling, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-25 19:34 UTC (permalink / raw)
  To: Don Slutz; +Cc: Daniel Kiper, kexec, xen-devel

On 25/02/13 18:34, Don Slutz wrote:
> 
> I did not find a fix/change to get_xen_vmcoreinfo() to call on 
> xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, ...
> 
> I found the following to work.
>     -Don Slutz
> 
>  From 2cabc018d7613b0d2ac487cbf2a2e9438a441a8d Mon Sep 17 00:00:00 2001
> From: Don Slutz <Don@CloudSwitch.com>
> Date: Fri, 22 Feb 2013 22:27:03 -0500
> Subject: [PATCH 1/2] Switch to use xc_kexec_get_range for 
> get_xen_vmcoreinfo.

Thanks.  I'll add this to my series.

David

> Signed-off-by: Don Slutz <Don@CloudSwitch.com>
> ---
>   kexec/crashdump-xen.c |   20 ++++++++++++++++++++
>   kexec/crashdump.c     |    2 ++
>   2 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
> index 56b0653..8179b72 100644
> --- a/kexec/crashdump-xen.c
> +++ b/kexec/crashdump-xen.c
> @@ -161,6 +161,26 @@ 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;
> +        int ret = 0;
> +
> +       xc = xc_interface_open(NULL, NULL, 0);
> +       if ( !xc ) {
> +               fprintf(stderr, "failed to open xen control interface.\n");
> +               return -1;
> +       }
> +
> +        ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, 0, len, 
> addr);
> +
> +       xc_interface_close(xc);
> +
> +        if (ret < 0)
> +            return -1;
> +        return 0;
> +}
> +
>   int xen_get_nr_phys_cpus(void)
>   {
>          xc_interface *xc;
> diff --git a/kexec/crashdump.c b/kexec/crashdump.c
> index 847d080..3d2c1b9 100644
> --- a/kexec/crashdump.c
> +++ b/kexec/crashdump.c
> @@ -142,7 +142,9 @@ int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len)
>          return get_vmcoreinfo("/sys/kernel/vmcoreinfo", addr, len);
>   }
> 
> +#ifndef HAVE_LIBXENCTRL
>   int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len)
>   {
>          return get_vmcoreinfo("/sys/hypervisor/vmcoreinfo", addr, len);
>   }
> +#endif

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-25 18:34 ` [Xen-devel] " Don Slutz
@ 2013-02-25 19:34   ` David Vrabel
  2013-02-25 19:34   ` David Vrabel
  1 sibling, 0 replies; 23+ messages in thread
From: David Vrabel @ 2013-02-25 19:34 UTC (permalink / raw)
  To: Don Slutz; +Cc: Daniel Kiper, kexec, xen-devel

On 25/02/13 18:34, Don Slutz wrote:
> 
> I did not find a fix/change to get_xen_vmcoreinfo() to call on 
> xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, ...
> 
> I found the following to work.
>     -Don Slutz
> 
>  From 2cabc018d7613b0d2ac487cbf2a2e9438a441a8d Mon Sep 17 00:00:00 2001
> From: Don Slutz <Don@CloudSwitch.com>
> Date: Fri, 22 Feb 2013 22:27:03 -0500
> Subject: [PATCH 1/2] Switch to use xc_kexec_get_range for 
> get_xen_vmcoreinfo.

Thanks.  I'll add this to my series.

David

> Signed-off-by: Don Slutz <Don@CloudSwitch.com>
> ---
>   kexec/crashdump-xen.c |   20 ++++++++++++++++++++
>   kexec/crashdump.c     |    2 ++
>   2 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
> index 56b0653..8179b72 100644
> --- a/kexec/crashdump-xen.c
> +++ b/kexec/crashdump-xen.c
> @@ -161,6 +161,26 @@ 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;
> +        int ret = 0;
> +
> +       xc = xc_interface_open(NULL, NULL, 0);
> +       if ( !xc ) {
> +               fprintf(stderr, "failed to open xen control interface.\n");
> +               return -1;
> +       }
> +
> +        ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_VMCOREINFO, 0, len, 
> addr);
> +
> +       xc_interface_close(xc);
> +
> +        if (ret < 0)
> +            return -1;
> +        return 0;
> +}
> +
>   int xen_get_nr_phys_cpus(void)
>   {
>          xc_interface *xc;
> diff --git a/kexec/crashdump.c b/kexec/crashdump.c
> index 847d080..3d2c1b9 100644
> --- a/kexec/crashdump.c
> +++ b/kexec/crashdump.c
> @@ -142,7 +142,9 @@ int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len)
>          return get_vmcoreinfo("/sys/kernel/vmcoreinfo", addr, len);
>   }
> 
> +#ifndef HAVE_LIBXENCTRL
>   int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len)
>   {
>          return get_vmcoreinfo("/sys/hypervisor/vmcoreinfo", addr, len);
>   }
> +#endif


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 3/4] kexec/xen: use libxc to get location of crash notes
  2013-02-21 17:57 ` [PATCH 3/4] kexec/xen: use libxc to get location of crash notes David Vrabel
  2013-02-26 13:53   ` [Xen-devel] " Don Slutz
@ 2013-02-26 13:53   ` Don Slutz
  1 sibling, 0 replies; 23+ messages in thread
From: Don Slutz @ 2013-02-26 13:53 UTC (permalink / raw)
  To: David Vrabel; +Cc: Daniel Kiper, kexec, xen-devel

On 02/21/13 12:57, David Vrabel wrote:
> From: David Vrabel <david.vrabel@citrix.com>
>
> Use xc_kexec_get_range(KEXEC_RANGE_MA_CPU) instead of parsing
> /proc/iomem (which is only populated by non-upstream ("classic") Xen
> kernels).
>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> ---
>   kexec/crashdump-xen.c |   61 ++++++++++++++++++++++++++++---------------------
>   1 files changed, 35 insertions(+), 26 deletions(-)
>
> diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
> index ff4706c..13335a5 100644
> --- a/kexec/crashdump-xen.c
> +++ b/kexec/crashdump-xen.c
> @@ -163,42 +163,51 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
>   	return machine;
>   }
>   
> -static int xen_crash_note_callback(void *UNUSED(data), int nr,
> -				   char *UNUSED(str),
> -				   unsigned long base,
> -				   unsigned long length)
> -{
> -	struct crash_note_info *note = xen_phys_notes + nr;
> -
> -	note->base = base;
> -	note->length = length;
> -
> -	return 0;
> -}
> -
> +#ifdef HAVE_LIBXENCTRL
>   int xen_get_nr_phys_cpus(void)
>   {
> -	char *match = "Crash note\n";
> -	int cpus, n;
> +	xc_interface *xc;
> +	int cpu;
>   
>   	if (xen_phys_cpus)
>   		return xen_phys_cpus;
>   
> -	if ((cpus = kexec_iomem_for_each_line(match, NULL, NULL))) {
> -		n = sizeof(struct crash_note_info) * cpus;
> -		xen_phys_notes = malloc(n);
> -		if (!xen_phys_notes) {
> -			fprintf(stderr, "failed to allocate xen_phys_notes.\n");
> +	xc = xc_interface_open(NULL, NULL, 0);
> +	if ( !xc ) {
> +		fprintf(stderr, "failed to open xen control interface.\n");
> +		return -1;
> +	}
> +
> +	for (cpu = 0;; cpu++) {
This code does work.  Not sure why you did not use xc_physinfo() to get 
the number of cpus that there is data for and remove the need for 
calling realloc.
> +		uint64_t size, start;
> +		int ret;
> +
> +		ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_CPU, cpu, &size, &start);
> +		if (ret < 0)
> +			break;
> +
> +		xen_phys_notes = realloc(xen_phys_notes,
> +					 sizeof(*xen_phys_notes) * (cpu + 1));
> +		if (xen_phys_notes == NULL)
>   			return -1;
> -		}
> -		memset(xen_phys_notes, 0, n);
> -		kexec_iomem_for_each_line(match,
> -					  xen_crash_note_callback, NULL);
> -		xen_phys_cpus = cpus;
> +
> +		xen_phys_notes[cpu].base = start;
> +		xen_phys_notes[cpu].length = size;
>   	}
>   
> -	return cpus;
> +	xc_interface_close(xc);
> +
> +	xen_phys_cpus = cpu;
> +
> +	return cpu;
>   }
> +#else
> +int xen_get_nr_phys_cpus(void)
> +{
> +	return -1;
> +}
> +#endif
> +
>   
>   int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
>   {
    -Don Slutz

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Xen-devel] [PATCH 3/4] kexec/xen: use libxc to get location of crash notes
  2013-02-21 17:57 ` [PATCH 3/4] kexec/xen: use libxc to get location of crash notes David Vrabel
@ 2013-02-26 13:53   ` Don Slutz
  2013-02-26 13:53   ` Don Slutz
  1 sibling, 0 replies; 23+ messages in thread
From: Don Slutz @ 2013-02-26 13:53 UTC (permalink / raw)
  To: David Vrabel; +Cc: Daniel Kiper, kexec, xen-devel

On 02/21/13 12:57, David Vrabel wrote:
> From: David Vrabel <david.vrabel@citrix.com>
>
> Use xc_kexec_get_range(KEXEC_RANGE_MA_CPU) instead of parsing
> /proc/iomem (which is only populated by non-upstream ("classic") Xen
> kernels).
>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> ---
>   kexec/crashdump-xen.c |   61 ++++++++++++++++++++++++++++---------------------
>   1 files changed, 35 insertions(+), 26 deletions(-)
>
> diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
> index ff4706c..13335a5 100644
> --- a/kexec/crashdump-xen.c
> +++ b/kexec/crashdump-xen.c
> @@ -163,42 +163,51 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)
>   	return machine;
>   }
>   
> -static int xen_crash_note_callback(void *UNUSED(data), int nr,
> -				   char *UNUSED(str),
> -				   unsigned long base,
> -				   unsigned long length)
> -{
> -	struct crash_note_info *note = xen_phys_notes + nr;
> -
> -	note->base = base;
> -	note->length = length;
> -
> -	return 0;
> -}
> -
> +#ifdef HAVE_LIBXENCTRL
>   int xen_get_nr_phys_cpus(void)
>   {
> -	char *match = "Crash note\n";
> -	int cpus, n;
> +	xc_interface *xc;
> +	int cpu;
>   
>   	if (xen_phys_cpus)
>   		return xen_phys_cpus;
>   
> -	if ((cpus = kexec_iomem_for_each_line(match, NULL, NULL))) {
> -		n = sizeof(struct crash_note_info) * cpus;
> -		xen_phys_notes = malloc(n);
> -		if (!xen_phys_notes) {
> -			fprintf(stderr, "failed to allocate xen_phys_notes.\n");
> +	xc = xc_interface_open(NULL, NULL, 0);
> +	if ( !xc ) {
> +		fprintf(stderr, "failed to open xen control interface.\n");
> +		return -1;
> +	}
> +
> +	for (cpu = 0;; cpu++) {
This code does work.  Not sure why you did not use xc_physinfo() to get 
the number of cpus that there is data for and remove the need for 
calling realloc.
> +		uint64_t size, start;
> +		int ret;
> +
> +		ret = xc_kexec_get_range(xc, KEXEC_RANGE_MA_CPU, cpu, &size, &start);
> +		if (ret < 0)
> +			break;
> +
> +		xen_phys_notes = realloc(xen_phys_notes,
> +					 sizeof(*xen_phys_notes) * (cpu + 1));
> +		if (xen_phys_notes == NULL)
>   			return -1;
> -		}
> -		memset(xen_phys_notes, 0, n);
> -		kexec_iomem_for_each_line(match,
> -					  xen_crash_note_callback, NULL);
> -		xen_phys_cpus = cpus;
> +
> +		xen_phys_notes[cpu].base = start;
> +		xen_phys_notes[cpu].length = size;
>   	}
>   
> -	return cpus;
> +	xc_interface_close(xc);
> +
> +	xen_phys_cpus = cpu;
> +
> +	return cpu;
>   }
> +#else
> +int xen_get_nr_phys_cpus(void)
> +{
> +	return -1;
> +}
> +#endif
> +
>   
>   int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
>   {
    -Don Slutz

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (11 preceding siblings ...)
  2013-02-25 18:34 ` [Xen-devel] " Don Slutz
@ 2013-03-08 10:30 ` Daniel Kiper
  2013-03-08 10:30 ` Daniel Kiper
  13 siblings, 0 replies; 23+ messages in thread
From: Daniel Kiper @ 2013-03-08 10:30 UTC (permalink / raw)
  To: David Vrabel; +Cc: kexec, xen-devel

David,

I have done some tests. I will send my thoughts
and comments as reply to relevant emails.

On Thu, Feb 21, 2013 at 05:57:36PM +0000, David Vrabel wrote:
> The series adds support for the new hypercall ABI which should be
> provided by Xen 4.3.  Images are loaded into Xen directly with no
> kernel involvement.
>
> Do not apply until the hypervisor side patches are applied to Xen.
>
> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
> sure why I had problems, perhaps a toolstack specific issue?
>
> Patch 2 makes libxc 4.3 mandatory for Xen support.
>
> Patch 3 removes a use of /proc/iomem in favour of libxc.
>
> Patch 4 adds the support for loading an image into Xen.
>
> This series explicitly drops support for older version of libxc/Xen as
> supporting kexec on these hypervisors requires kernel support that
> will never be available upstream.

Please do not do that. I agree with Jan that there are many
distros in the wild which uses old interface (and they will
be doing that long time) and we should not make their life
more difficult.

I have found that simple kexec does not work. It means that
if you call kexec -e (after kexec -l) it displays:

Nothing has been loaded!

Linux on baremetal works without any issue.

Daniel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/4] kexec-tools: add support for Xen 4.3
  2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
                   ` (12 preceding siblings ...)
  2013-03-08 10:30 ` Daniel Kiper
@ 2013-03-08 10:30 ` Daniel Kiper
  13 siblings, 0 replies; 23+ messages in thread
From: Daniel Kiper @ 2013-03-08 10:30 UTC (permalink / raw)
  To: David Vrabel; +Cc: kexec, xen-devel

David,

I have done some tests. I will send my thoughts
and comments as reply to relevant emails.

On Thu, Feb 21, 2013 at 05:57:36PM +0000, David Vrabel wrote:
> The series adds support for the new hypercall ABI which should be
> provided by Xen 4.3.  Images are loaded into Xen directly with no
> kernel involvement.
>
> Do not apply until the hypervisor side patches are applied to Xen.
>
> Patch 1 is unrelated but kexec wouldn't work for me without it. Not
> sure why I had problems, perhaps a toolstack specific issue?
>
> Patch 2 makes libxc 4.3 mandatory for Xen support.
>
> Patch 3 removes a use of /proc/iomem in favour of libxc.
>
> Patch 4 adds the support for loading an image into Xen.
>
> This series explicitly drops support for older version of libxc/Xen as
> supporting kexec on these hypervisors requires kernel support that
> will never be available upstream.

Please do not do that. I agree with Jan that there are many
distros in the wild which uses old interface (and they will
be doing that long time) and we should not make their life
more difficult.

I have found that simple kexec does not work. It means that
if you call kexec -e (after kexec -l) it displays:

Nothing has been loaded!

Linux on baremetal works without any issue.

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/4] kexec/xen: directly load images images into Xen
  2013-02-21 17:57 ` [PATCH 4/4] kexec/xen: directly load images images into Xen David Vrabel
  2013-03-12 11:29   ` Daniel Kiper
@ 2013-03-12 11:29   ` Daniel Kiper
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel Kiper @ 2013-03-12 11:29 UTC (permalink / raw)
  To: David Vrabel; +Cc: kexec, xen-devel

On Thu, Feb 21, 2013 at 05:57:40PM +0000, David Vrabel wrote:
> From: David Vrabel <david.vrabel@citrix.com>
>
> Xen 4.3 has an improvided kexec hypercall ABI that allows images to be
> loaded and executed without any kernel involvement.  Use the API
> provided by libxc to load images when running in a Xen guest.
>
> Support for loading images via the kexec_load syscall in non-upstream
> ("classic") Xen kernels is no longer supported.
>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>

[...]

> diff --git a/kexec/kexec-xen.c b/kexec/kexec-xen.c

[...]

> +	type = kexec_flags & KEXEC_TYPE_CRASH;
> +	arch = (kexec_flags >> 16) & 0xffff;

arch = (kexec_flags & KEXEC_ARCH_MASK) >> 16;

Daniel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/4] kexec/xen: directly load images images into Xen
  2013-02-21 17:57 ` [PATCH 4/4] kexec/xen: directly load images images into Xen David Vrabel
@ 2013-03-12 11:29   ` Daniel Kiper
  2013-03-12 11:29   ` Daniel Kiper
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel Kiper @ 2013-03-12 11:29 UTC (permalink / raw)
  To: David Vrabel; +Cc: kexec, xen-devel

On Thu, Feb 21, 2013 at 05:57:40PM +0000, David Vrabel wrote:
> From: David Vrabel <david.vrabel@citrix.com>
>
> Xen 4.3 has an improvided kexec hypercall ABI that allows images to be
> loaded and executed without any kernel involvement.  Use the API
> provided by libxc to load images when running in a Xen guest.
>
> Support for loading images via the kexec_load syscall in non-upstream
> ("classic") Xen kernels is no longer supported.
>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>

[...]

> diff --git a/kexec/kexec-xen.c b/kexec/kexec-xen.c

[...]

> +	type = kexec_flags & KEXEC_TYPE_CRASH;
> +	arch = (kexec_flags >> 16) & 0xffff;

arch = (kexec_flags & KEXEC_ARCH_MASK) >> 16;

Daniel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-03-12 11:29 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-21 17:57 [PATCH 0/4] kexec-tools: add support for Xen 4.3 David Vrabel
2013-02-21 17:57 ` [PATCH 1/4] purgatory: put variables altered by kexec in .data not .bss David Vrabel
2013-02-21 17:57 ` David Vrabel
2013-02-21 17:57 ` [PATCH 2/4] kexec/xen: require libxc from Xen 4.3 David Vrabel
2013-02-21 17:57 ` David Vrabel
2013-02-21 17:57 ` [PATCH 3/4] kexec/xen: use libxc to get location of crash notes David Vrabel
2013-02-26 13:53   ` [Xen-devel] " Don Slutz
2013-02-26 13:53   ` Don Slutz
2013-02-21 17:57 ` David Vrabel
2013-02-21 17:57 ` [PATCH 4/4] kexec/xen: directly load images images into Xen David Vrabel
2013-03-12 11:29   ` Daniel Kiper
2013-03-12 11:29   ` Daniel Kiper
2013-02-21 17:57 ` David Vrabel
2013-02-22  8:14 ` [PATCH 0/4] kexec-tools: add support for Xen 4.3 Jan Beulich
2013-02-22  8:14 ` [Xen-devel] " Jan Beulich
2013-02-22 11:39   ` David Vrabel
2013-02-22 11:39   ` David Vrabel
2013-02-25 18:34 ` Don Slutz
2013-02-25 18:34 ` [Xen-devel] " Don Slutz
2013-02-25 19:34   ` David Vrabel
2013-02-25 19:34   ` David Vrabel
2013-03-08 10:30 ` Daniel Kiper
2013-03-08 10:30 ` Daniel Kiper

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.