Skip to content

Commit ea961a8

Browse files
antonblanchardozbenh
authored andcommitted
powerpc: Fix endian issues in kexec and crash dump code
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]>
1 parent 04a3411 commit ea961a8

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

arch/powerpc/kernel/machine_kexec.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ int overlaps_crashkernel(unsigned long start, unsigned long size)
196196

197197
/* Values we need to export to the second kernel via the device tree. */
198198
static phys_addr_t kernel_end;
199+
static phys_addr_t crashk_base;
199200
static phys_addr_t crashk_size;
201+
static unsigned long long mem_limit;
200202

201203
static struct property kernel_end_prop = {
202204
.name = "linux,kernel-end",
@@ -207,7 +209,7 @@ static struct property kernel_end_prop = {
207209
static struct property crashk_base_prop = {
208210
.name = "linux,crashkernel-base",
209211
.length = sizeof(phys_addr_t),
210-
.value = &crashk_res.start,
212+
.value = &crashk_base
211213
};
212214

213215
static struct property crashk_size_prop = {
@@ -219,9 +221,11 @@ static struct property crashk_size_prop = {
219221
static struct property memory_limit_prop = {
220222
.name = "linux,memory-limit",
221223
.length = sizeof(unsigned long long),
222-
.value = &memory_limit,
224+
.value = &mem_limit,
223225
};
224226

227+
#define cpu_to_be_ulong __PASTE(cpu_to_be, BITS_PER_LONG)
228+
225229
static void __init export_crashk_values(struct device_node *node)
226230
{
227231
struct property *prop;
@@ -237,15 +241,17 @@ static void __init export_crashk_values(struct device_node *node)
237241
of_remove_property(node, prop);
238242

239243
if (crashk_res.start != 0) {
244+
crashk_base = cpu_to_be_ulong(crashk_res.start),
240245
of_add_property(node, &crashk_base_prop);
241-
crashk_size = resource_size(&crashk_res);
246+
crashk_size = cpu_to_be_ulong(resource_size(&crashk_res));
242247
of_add_property(node, &crashk_size_prop);
243248
}
244249

245250
/*
246251
* memory_limit is required by the kexec-tools to limit the
247252
* crash regions to the actual memory used.
248253
*/
254+
mem_limit = cpu_to_be_ulong(memory_limit);
249255
of_update_property(node, &memory_limit_prop);
250256
}
251257

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

266272
/* information needed by userspace when using default_machine_kexec */
267-
kernel_end = __pa(_end);
273+
kernel_end = cpu_to_be_ulong(__pa(_end));
268274
of_add_property(node, &kernel_end_prop);
269275

270276
export_crashk_values(node);

arch/powerpc/kernel/machine_kexec_64.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ void default_machine_kexec(struct kimage *image)
369369

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

373374
static struct property htab_base_prop = {
374375
.name = "linux,htab-base",
@@ -379,7 +380,7 @@ static struct property htab_base_prop = {
379380
static struct property htab_size_prop = {
380381
.name = "linux,htab-size",
381382
.length = sizeof(unsigned long),
382-
.value = &htab_size_bytes,
383+
.value = &htab_size,
383384
};
384385

385386
static int __init export_htab_values(void)
@@ -403,8 +404,9 @@ static int __init export_htab_values(void)
403404
if (prop)
404405
of_remove_property(node, prop);
405406

406-
htab_base = __pa(htab_address);
407+
htab_base = cpu_to_be64(__pa(htab_address));
407408
of_add_property(node, &htab_base_prop);
409+
htab_size = cpu_to_be64(htab_size_bytes);
408410
of_add_property(node, &htab_size_prop);
409411

410412
of_node_put(node);

0 commit comments

Comments
 (0)