summaryrefslogtreecommitdiff
path: root/kexec
diff options
context:
space:
mode:
Diffstat (limited to 'kexec')
-rw-r--r--kexec/arch/i386/crashdump-x86.c4
-rw-r--r--kexec/arch/i386/kexec-x86.c2
-rw-r--r--kexec/arch/i386/x86-linux-setup.c2
-rw-r--r--kexec/arch/ia64/crashdump-ia64.c9
-rw-r--r--kexec/arch/ia64/kexec-elf-ia64.c2
-rw-r--r--kexec/arch/ia64/kexec-ia64.c5
-rw-r--r--kexec/arch/ppc/kexec-ppc.c2
-rw-r--r--kexec/arch/s390/kexec-s390.c5
-rw-r--r--kexec/arch/x86_64/crashdump-x86_64.c10
-rw-r--r--kexec/arch/x86_64/kexec-x86_64.c2
-rw-r--r--kexec/crashdump-xen.c6
-rw-r--r--kexec/kexec-iomem.c31
-rw-r--r--kexec/kexec.h6
13 files changed, 53 insertions, 33 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index b3e6ede..729ce00 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -59,7 +59,7 @@ static struct memory_range crash_reserved_mem;
*/
static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
{
- const char iomem[]= "/proc/iomem";
+ const char *iomem = proc_iomem(1);
int memory_ranges = 0;
char line[MAX_LINE];
FILE *fp;
@@ -582,6 +582,6 @@ int is_crashkernel_mem_reserved(void)
{
uint64_t start, end;
- return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ?
+ return parse_iomem_single("Crash kernel\n", 1, &start, &end) == 0 ?
(start != end) : 0;
}
diff --git a/kexec/arch/i386/kexec-x86.c b/kexec/arch/i386/kexec-x86.c
index 6d335af..c82b8ba 100644
--- a/kexec/arch/i386/kexec-x86.c
+++ b/kexec/arch/i386/kexec-x86.c
@@ -39,7 +39,7 @@ static struct memory_range memory_range[MAX_MEMORY_RANGES];
int get_memory_ranges(struct memory_range **range, int *ranges,
unsigned long kexec_flags)
{
- const char iomem[]= "/proc/iomem";
+ const char *iomem= proc_iomem(kexec_flags & KEXEC_ON_CRASH);
int memory_ranges = 0;
char line[MAX_LINE];
FILE *fp;
diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index 0bf487b..df2f5c0 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -126,7 +126,7 @@ int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
real_mode->lfb_linelength = fix.line_length;
real_mode->vesapm_seg = 0;
- /* FIXME: better get size from /proc/iomem */
+ /* FIXME: better get size from the file returned by proc_iomem() */
real_mode->lfb_size = (fix.smem_len + 65535) / 65536;
real_mode->pages = (fix.smem_len + 4095) / 4096;
diff --git a/kexec/arch/ia64/crashdump-ia64.c b/kexec/arch/ia64/crashdump-ia64.c
index fbe45c2..e365b3e 100644
--- a/kexec/arch/ia64/crashdump-ia64.c
+++ b/kexec/arch/ia64/crashdump-ia64.c
@@ -43,7 +43,8 @@ static struct crash_elf_info elf_info =
/* Stores a sorted list of RAM memory ranges for which to create elf headers.
* A separate program header is created for backup region.
* The number of entries in memory_range array is always smaller than
- * the number of entries in /proc/iomem, stored in max_memory_ranges. */
+ * the number of entries in the file returned by proc_iomem(),
+ * stored in max_memory_ranges. */
static struct memory_range *crash_memory_range;
/* Memory region reserved for storing panic kernel and other data. */
static struct memory_range crash_reserved_mem;
@@ -142,7 +143,7 @@ static int exclude_crash_reserve_region(int *nr_ranges)
static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
{
- const char iomem[]= "/proc/iomem";
+ const char *iomem = proc_iomem(1);
char line[MAX_LINE];
FILE *fp;
unsigned long start, end;
@@ -261,6 +262,6 @@ int is_crashkernel_mem_reserved(void)
{
uint64_t start, end;
- return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ?
- (start != end) : 0;
+ return parse_iomem_single("Crash kernel\n", 1, &start,
+ &end) == 0 ? (start != end) : 0;
}
diff --git a/kexec/arch/ia64/kexec-elf-ia64.c b/kexec/arch/ia64/kexec-elf-ia64.c
index 48cc6a5..b5eab6c 100644
--- a/kexec/arch/ia64/kexec-elf-ia64.c
+++ b/kexec/arch/ia64/kexec-elf-ia64.c
@@ -195,7 +195,7 @@ int elf_ia64_load(int argc, char **argv, const char *buf, off_t len,
if (info->kexec_flags & KEXEC_ON_CRASH ) {
if ((mem_min == 0x00) && (mem_max == ULONG_MAX)) {
fprintf(stderr, "Failed to find crash kernel region "
- "in /proc/iomem\n");
+ "in %s\n", proc_iomem(1));
free_elf_info(&ehdr);
return -1;
}
diff --git a/kexec/arch/ia64/kexec-ia64.c b/kexec/arch/ia64/kexec-ia64.c
index bb9bdbb..dc0c382 100644
--- a/kexec/arch/ia64/kexec-ia64.c
+++ b/kexec/arch/ia64/kexec-ia64.c
@@ -37,7 +37,8 @@
#include <arch/options.h>
/* The number of entries in memory_range array is always smaller than
- the number of entries in /proc/iomem, stored in max_memory_ranges. */
+ * the number of entries in the file returned by proc_iomem(),
+ * stored in max_memory_ranges. */
static struct memory_range *memory_range;
int max_memory_ranges;
static int memory_ranges;
@@ -79,7 +80,7 @@ static int split_range(int range, unsigned long start, unsigned long end)
int get_memory_ranges(struct memory_range **range, int *ranges,
unsigned long kexec_flags)
{
- const char iomem[]= "/proc/iomem";
+ const char *iomem = proc_iomem(kexec_flags & KEXEC_ON_CRASH);
char line[MAX_LINE];
FILE *fp;
fp = fopen(iomem, "r");
diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c
index e446674..df05212 100644
--- a/kexec/arch/ppc/kexec-ppc.c
+++ b/kexec/arch/ppc/kexec-ppc.c
@@ -34,7 +34,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
memory_ranges++;
#else
#error Please, fix this for your platform
- const char iomem[] = "/proc/iomem";
+ const char *iomem = proc_iomem();
char line[MAX_LINE];
FILE *fp;
unsigned long long start, end;
diff --git a/kexec/arch/s390/kexec-s390.c b/kexec/arch/s390/kexec-s390.c
index 1a1af5d..e303db9 100644
--- a/kexec/arch/s390/kexec-s390.c
+++ b/kexec/arch/s390/kexec-s390.c
@@ -25,7 +25,8 @@ static struct memory_range memory_range[MAX_MEMORY_RANGES];
/*
* get_memory_ranges:
- * Return a list of memory ranges by parsing /proc/iomem
+ * Return a list of memory ranges by parsing the file returned by
+ * proc_iomem()
*
* INPUT:
* - Pointer to an array of memory_range structures.
@@ -39,7 +40,7 @@ static struct memory_range memory_range[MAX_MEMORY_RANGES];
int get_memory_ranges(struct memory_range **range, int *ranges, unsigned long flags)
{
char sys_ram[] = "System RAM\n";
- char iomem[] = "/proc/iomem";
+ char *iomem = proc_iomem(flags & KEXEC_ON_CRASH);
FILE *fp;
char line[80];
int current_range = 0;
diff --git a/kexec/arch/x86_64/crashdump-x86_64.c b/kexec/arch/x86_64/crashdump-x86_64.c
index 4afae7b..0815cf4 100644
--- a/kexec/arch/x86_64/crashdump-x86_64.c
+++ b/kexec/arch/x86_64/crashdump-x86_64.c
@@ -52,8 +52,8 @@ static int exclude_crash_reserve_region(int *nr_ranges);
#define KERN_VADDR_ALIGN 0x100000 /* 1MB */
-/* Read kernel physical load addr from /proc/iomem (Kernel Code) and
- * store in kexec_info */
+/* Read kernel physical load addr from the file returned by proc_iomem()
+ * (Kernel Code) and store in kexec_info */
static int get_kernel_paddr(struct kexec_info *info)
{
uint64_t start;
@@ -61,7 +61,7 @@ static int get_kernel_paddr(struct kexec_info *info)
if (xen_present()) /* Kernel not entity mapped under Xen */
return 0;
- if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
+ if (parse_iomem_single("Kernel code\n", 0, &start, NULL) == 0) {
info->kern_paddr_start = start;
#ifdef DEBUG
printf("kernel load physical addr start = 0x%016Lx\n", start);
@@ -164,7 +164,7 @@ static struct memory_range crash_reserved_mem;
*/
static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
{
- const char iomem[]= "/proc/iomem";
+ const char *iomem= proc_iomem(1);
int memory_ranges = 0;
char line[MAX_LINE];
FILE *fp;
@@ -642,6 +642,6 @@ int is_crashkernel_mem_reserved(void)
{
uint64_t start, end;
- return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ?
+ return parse_iomem_single("Crash kernel\n", 1, &start, &end) == 0 ?
(start != end) : 0;
}
diff --git a/kexec/arch/x86_64/kexec-x86_64.c b/kexec/arch/x86_64/kexec-x86_64.c
index 2df1b34..c4b059e 100644
--- a/kexec/arch/x86_64/kexec-x86_64.c
+++ b/kexec/arch/x86_64/kexec-x86_64.c
@@ -40,7 +40,7 @@ static struct memory_range memory_range[MAX_MEMORY_RANGES];
int get_memory_ranges(struct memory_range **range, int *ranges,
unsigned long kexec_flags)
{
- const char iomem[]= "/proc/iomem";
+ const char *iomem= proc_iomem(kexec_flags & KEXEC_ON_CRASH);
int memory_ranges = 0;
char line[MAX_LINE];
FILE *fp;
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index fcef9db..4d6a25d 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -12,6 +12,7 @@
#include <fcntl.h>
#include "kexec.h"
#include "crashdump.h"
+#include "kexec-syscall.h"
#ifdef HAVE_XENCTRL_H
#include <xenctrl.h>
@@ -90,7 +91,7 @@ int xen_get_nr_phys_cpus(void)
if (xen_phys_cpus)
return xen_phys_cpus;
- if ((cpus = kexec_iomem_for_each_line(match, NULL, NULL))) {
+ if ((cpus = kexec_iomem_for_each_line(match, 1, NULL, NULL))) {
n = sizeof(struct crash_note_info) * cpus;
xen_phys_notes = malloc(n);
if (!xen_phys_notes) {
@@ -98,7 +99,8 @@ int xen_get_nr_phys_cpus(void)
return -1;
}
memset(xen_phys_notes, 0, n);
- kexec_iomem_for_each_line(match, xen_crash_note_callback, NULL);
+ kexec_iomem_for_each_line(match, 1,
+ xen_crash_note_callback, NULL);
xen_phys_cpus = cpus;
}
diff --git a/kexec/kexec-iomem.c b/kexec/kexec-iomem.c
index 6ae4fe4..2497b79 100644
--- a/kexec/kexec-iomem.c
+++ b/kexec/kexec-iomem.c
@@ -15,12 +15,14 @@
/*
* kexec_iomem_for_each_line()
*
- * Iterate over each line in /proc/iomem. If match is NULL or if the line
- * matches with our match-pattern then call the callback if non-NULL.
+ * Iterate over each line in the file returned by proc_iomem(). If match is
+ * NULL or if the line matches with our match-pattern then call the
+ * callback if non-NULL.
+ *
* Return the number of lines matched.
*/
-int kexec_iomem_for_each_line(char *match,
+int kexec_iomem_for_each_line(char *match, int machine,
int (*callback)(void *data,
int nr,
char *str,
@@ -28,7 +30,7 @@ int kexec_iomem_for_each_line(char *match,
unsigned long length),
void *data)
{
- const char iomem[]= "/proc/iomem";
+ const char *iomem = proc_iomem(machine);
char line[MAX_LINE];
FILE *fp;
unsigned long long start, end, size;
@@ -39,7 +41,7 @@ int kexec_iomem_for_each_line(char *match,
fp = fopen(iomem, "r");
if (!fp)
- die("Cannot open /proc/iomem");
+ die("Cannot open %s\n", iomem);
while(fgets(line, sizeof(line), fp) != 0) {
count = sscanf(line, "%Lx-%Lx : %n", &start, &end, &consumed);
@@ -76,15 +78,15 @@ static int kexec_iomem_single_callback(void *data, int nr,
return 0;
}
-int parse_iomem_single(char *str, uint64_t *start, uint64_t *end)
+int parse_iomem_single(char *str, int machine, uint64_t *start, uint64_t *end)
{
struct memory_range range;
int ret;
memset(&range, 0, sizeof(range));
- ret = kexec_iomem_for_each_line(str, kexec_iomem_single_callback,
- &range);
+ ret = kexec_iomem_for_each_line(str, machine,
+ kexec_iomem_single_callback, &range);
if (ret == 1) {
if (start)
@@ -99,3 +101,16 @@ int parse_iomem_single(char *str, uint64_t *start, uint64_t *end)
return ret;
}
+
+static const char proc_iomem_str[]= "/proc/iomem";
+
+/*
+ * Allow an architecture specific implementation of this
+ * function to override the location of a file looking a lot
+ * like /proc/iomem
+ */
+const char * __attribute__((weak)) proc_iomem(int machine)
+{
+ return proc_iomem_str;
+}
+
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 0781898..2ee48c4 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -205,15 +205,15 @@ int arch_compat_trampoline(struct kexec_info *info);
void arch_update_purgatory(struct kexec_info *info);
int is_crashkernel_mem_reserved(void);
-int kexec_iomem_for_each_line(char *match,
+int kexec_iomem_for_each_line(char *match, int machine,
int (*callback)(void *data,
int nr,
char *str,
unsigned long base,
unsigned long length),
void *data);
-int parse_iomem_single(char *str, uint64_t *start, uint64_t *end);
-
+int parse_iomem_single(char *str, int machine, uint64_t *start, uint64_t *end);
+const char * proc_iomem(int machine);
#define MAX_LINE 160