summaryrefslogtreecommitdiff
path: root/kexec/crashdump-xen.c
diff options
context:
space:
mode:
authorMagnus Damm <magnus@valinux.co.jp>2006-11-22 00:02:47 +0900
committerSimon Horman <horms@verge.net.au>2006-11-27 12:25:13 +0900
commitf7d547f412f0f0b363240c2261ed3ec89b828689 (patch)
tree814175da6d5e4332f772b11d8fb42b711ac0a785 /kexec/crashdump-xen.c
parent5ce4f874087d0981479e841e9c366cf55e67d985 (diff)
downloadkexec-tools-f7d547f412f0f0b363240c2261ed3ec89b828689.tar.gz
kexec-tools: Introduce crashdump-xen.c and Xen support V2
kexec-tools: Introduce crashdump-xen.c and Xen support V2 This patch adds the new file crashdump-xen.c that implements Xen support. The Xen support is not complete yet in the sense that a special program header for the hypervisor isn't created. Crash notes for physical cpus are created so basic support is at least provided by this patch. Version 2 of this patch includes a cleaner implementation for crashdump-elf.c together with a bugfix for xen_get_nr_phys_cpus(). Signed-off-by: Magnus Damm <magnus@valinux.co.jp> Removed trailing whitespace Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/crashdump-xen.c')
-rw-r--r--kexec/crashdump-xen.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
new file mode 100644
index 0000000..aa096e6
--- /dev/null
+++ b/kexec/crashdump-xen.c
@@ -0,0 +1,80 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "kexec.h"
+#include "crashdump.h"
+
+struct crash_note_info {
+ unsigned long base;
+ unsigned long length;
+};
+
+int xen_phys_cpus = 0;
+struct crash_note_info *xen_phys_notes;
+
+int xen_present(void)
+{
+ struct stat buf;
+
+ return stat("/proc/xen", &buf) == 0;
+}
+
+static int xen_crash_note_callback(void *data, int nr,
+ char *str,
+ unsigned long base,
+ unsigned long length)
+{
+ struct crash_note_info *note = xen_phys_notes + nr;
+
+ note->base = base;
+ note->length = length;
+
+ return 0;
+}
+
+int xen_get_nr_phys_cpus(void)
+{
+ char *match = "Crash note\n";
+ int cpus, n;
+
+ 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) {
+ memset(xen_phys_notes, 0, n);
+ kexec_iomem_for_each_line(match,
+ xen_crash_note_callback,
+ NULL);
+ }
+
+ xen_phys_cpus = cpus;
+ }
+
+ return cpus;
+}
+
+int xen_get_note(int cpu, uint64_t *addr, uint64_t *len)
+{
+ struct crash_note_info *note;
+
+ if (xen_phys_cpus <= 0)
+ return -1;
+
+ note = xen_phys_notes + cpu;
+
+ *addr = note->base;
+ *len = note->length;
+
+ return 0;
+}