diff options
author | Ian Campbell <ian.campbell@xensource.com> | 2007-03-16 10:10:24 +0000 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2007-03-19 13:38:50 +0900 |
commit | cdbc9b011fe43407908632d842e3a39e495e48d9 (patch) | |
tree | 99ab9065d606c17bfb838c9155c1a03694f929cc /kexec/crashdump-xen.c | |
parent | efac1da616a211517a4b0eaae098db6ade3bdd26 (diff) |
Set crash dump ELF header e_machine field based on underlying hypervisor architecture.
This is necessary when running Xen with a 64 bit hypervisor and 32 bit
domain 0 since the CPU crash notes will be 64 bit.
Detecting the hypervisor archiecture requires libxenctrl and therefore this
support is optional and disabled by default.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Acked-by: Magnus Damm <magnus@valinux.co.jp>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/crashdump-xen.c')
-rw-r--r-- | kexec/crashdump-xen.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c index aa096e6..30506e2 100644 --- a/kexec/crashdump-xen.c +++ b/kexec/crashdump-xen.c @@ -3,6 +3,7 @@ #include <stdarg.h> #include <string.h> #include <stdlib.h> +#include <elf.h> #include <errno.h> #include <limits.h> #include <sys/types.h> @@ -12,6 +13,10 @@ #include "kexec.h" #include "crashdump.h" +#ifdef HAVE_XENCTRL_H +#include <xenctrl.h> +#endif + struct crash_note_info { unsigned long base; unsigned long length; @@ -27,6 +32,43 @@ int xen_present(void) return stat("/proc/xen", &buf) == 0; } +unsigned long xen_architecture(struct crash_elf_info *elf_info) +{ + unsigned long machine = elf_info->machine; +#ifdef HAVE_XENCTRL_H + int xc, rc; + xen_capabilities_info_t capabilities; + + if (!xen_present()) + goto out; + + memset(capabilities, '0', XEN_CAPABILITIES_INFO_LEN); + + xc = xc_interface_open(); + if ( xc == -1 ) { + fprintf(stderr, "failed to open xen control interface.\n"); + goto out; + } + + rc = xc_version(xc, XENVER_capabilities, &capabilities[0]); + if ( rc == -1 ) { + fprintf(stderr, "failed to make Xen version hypercall.\n"); + goto out_close; + } + + if (strstr(capabilities, "xen-3.0-x86_64")) + machine = EM_X86_64; + else if (strstr(capabilities, "xen-3.0-x86_32")) + machine = EM_386; + + out_close: + xc_interface_close(xc); + + out: +#endif + return machine; +} + static int xen_crash_note_callback(void *data, int nr, char *str, unsigned long base, |