Skip to content

Commit

Permalink
powerpc: Fix endian issues in kexec and crash dump code
Browse files Browse the repository at this point in the history
We expose a number of OF properties in the kexec and crash dump code
and these need to be big endian.

Cc: [email protected] # v3.13
Signed-off-by: Anton Blanchard <[email protected]>
Signed-off-by: Benjamin Herrenschmidt <[email protected]>
  • Loading branch information
antonblanchard authored and ozbenh committed Feb 11, 2014
1 parent 04a3411 commit ea961a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 10 additions & 4 deletions arch/powerpc/kernel/machine_kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ int overlaps_crashkernel(unsigned long start, unsigned long size)

/* Values we need to export to the second kernel via the device tree. */
static phys_addr_t kernel_end;
static phys_addr_t crashk_base;
static phys_addr_t crashk_size;
static unsigned long long mem_limit;

static struct property kernel_end_prop = {
.name = "linux,kernel-end",
Expand All @@ -207,7 +209,7 @@ static struct property kernel_end_prop = {
static struct property crashk_base_prop = {
.name = "linux,crashkernel-base",
.length = sizeof(phys_addr_t),
.value = &crashk_res.start,
.value = &crashk_base
};

static struct property crashk_size_prop = {
Expand All @@ -219,9 +221,11 @@ static struct property crashk_size_prop = {
static struct property memory_limit_prop = {
.name = "linux,memory-limit",
.length = sizeof(unsigned long long),
.value = &memory_limit,
.value = &mem_limit,
};

#define cpu_to_be_ulong __PASTE(cpu_to_be, BITS_PER_LONG)

static void __init export_crashk_values(struct device_node *node)
{
struct property *prop;
Expand All @@ -237,15 +241,17 @@ static void __init export_crashk_values(struct device_node *node)
of_remove_property(node, prop);

if (crashk_res.start != 0) {
crashk_base = cpu_to_be_ulong(crashk_res.start),
of_add_property(node, &crashk_base_prop);
crashk_size = resource_size(&crashk_res);
crashk_size = cpu_to_be_ulong(resource_size(&crashk_res));
of_add_property(node, &crashk_size_prop);
}

/*
* memory_limit is required by the kexec-tools to limit the
* crash regions to the actual memory used.
*/
mem_limit = cpu_to_be_ulong(memory_limit);
of_update_property(node, &memory_limit_prop);
}

Expand All @@ -264,7 +270,7 @@ static int __init kexec_setup(void)
of_remove_property(node, prop);

/* information needed by userspace when using default_machine_kexec */
kernel_end = __pa(_end);
kernel_end = cpu_to_be_ulong(__pa(_end));
of_add_property(node, &kernel_end_prop);

export_crashk_values(node);
Expand Down
6 changes: 4 additions & 2 deletions arch/powerpc/kernel/machine_kexec_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ void default_machine_kexec(struct kimage *image)

/* Values we need to export to the second kernel via the device tree. */
static unsigned long htab_base;
static unsigned long htab_size;

static struct property htab_base_prop = {
.name = "linux,htab-base",
Expand All @@ -379,7 +380,7 @@ static struct property htab_base_prop = {
static struct property htab_size_prop = {
.name = "linux,htab-size",
.length = sizeof(unsigned long),
.value = &htab_size_bytes,
.value = &htab_size,
};

static int __init export_htab_values(void)
Expand All @@ -403,8 +404,9 @@ static int __init export_htab_values(void)
if (prop)
of_remove_property(node, prop);

htab_base = __pa(htab_address);
htab_base = cpu_to_be64(__pa(htab_address));
of_add_property(node, &htab_base_prop);
htab_size = cpu_to_be64(htab_size_bytes);
of_add_property(node, &htab_size_prop);

of_node_put(node);
Expand Down

0 comments on commit ea961a8

Please sign in to comment.