* [PATCH 2/5 v2] powerpc/boot/fdt: Add little-endian support to libfdt wrappers
2015-02-11 4:55 [PATCH 1/5 v2] powerpc/boot/fdt: Use unsigned long for pointer casts Jeremy Kerr
2015-02-11 4:55 ` [PATCH 5/5 v2] powerpc/boot: don't clobber r6 and r7 in epapr boot Jeremy Kerr
2015-02-11 4:55 ` [PATCH 3/5 v2] powerpc/boot/wrapper: use the pseries wrapper for zImage.epapr Jeremy Kerr
@ 2015-02-11 4:55 ` Jeremy Kerr
2015-02-16 16:53 ` Cedric Le Goater
2015-02-11 4:55 ` [PATCH 4/5 v2] powerpc/boot: Fix stack corruption in epapr entry point Jeremy Kerr
3 siblings, 1 reply; 6+ messages in thread
From: Jeremy Kerr @ 2015-02-11 4:55 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Cédric Le Goater
For epapr-style boot, we may be little-endian. This change implements
the proper conversion for fdt*_to_cpu and cpu_to_fdt*. We also need the
full cpu_to_* and *_to_cpu macros for this.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/boot/libfdt_env.h | 14 ++++++++------
arch/powerpc/boot/of.h | 8 ++++++++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h
index c89fdb1..8dcd744 100644
--- a/arch/powerpc/boot/libfdt_env.h
+++ b/arch/powerpc/boot/libfdt_env.h
@@ -4,15 +4,17 @@
#include <types.h>
#include <string.h>
+#include "of.h"
+
typedef u32 uint32_t;
typedef u64 uint64_t;
typedef unsigned long uintptr_t;
-#define fdt16_to_cpu(x) (x)
-#define cpu_to_fdt16(x) (x)
-#define fdt32_to_cpu(x) (x)
-#define cpu_to_fdt32(x) (x)
-#define fdt64_to_cpu(x) (x)
-#define cpu_to_fdt64(x) (x)
+#define fdt16_to_cpu(x) be16_to_cpu(x)
+#define cpu_to_fdt16(x) cpu_to_be16(x)
+#define fdt32_to_cpu(x) be32_to_cpu(x)
+#define cpu_to_fdt32(x) cpu_to_be32(x)
+#define fdt64_to_cpu(x) be64_to_cpu(x)
+#define cpu_to_fdt64(x) cpu_to_be64(x)
#endif /* _ARCH_POWERPC_BOOT_LIBFDT_ENV_H */
diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h
index c8c1750..5603320 100644
--- a/arch/powerpc/boot/of.h
+++ b/arch/powerpc/boot/of.h
@@ -24,11 +24,19 @@ void of_console_init(void);
typedef u32 __be32;
#ifdef __LITTLE_ENDIAN__
+#define cpu_to_be16(x) swab16(x)
+#define be16_to_cpu(x) swab16(x)
#define cpu_to_be32(x) swab32(x)
#define be32_to_cpu(x) swab32(x)
+#define cpu_to_be64(x) swab64(x)
+#define be64_to_cpu(x) swab64(x)
#else
+#define cpu_to_be16(x) (x)
+#define be16_to_cpu(x) (x)
#define cpu_to_be32(x) (x)
#define be32_to_cpu(x) (x)
+#define cpu_to_be64(x) (x)
+#define be64_to_cpu(x) (x)
#endif
#define PROM_ERROR (-1u)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5 v2] powerpc/boot/wrapper: use the pseries wrapper for zImage.epapr
2015-02-11 4:55 [PATCH 1/5 v2] powerpc/boot/fdt: Use unsigned long for pointer casts Jeremy Kerr
2015-02-11 4:55 ` [PATCH 5/5 v2] powerpc/boot: don't clobber r6 and r7 in epapr boot Jeremy Kerr
@ 2015-02-11 4:55 ` Jeremy Kerr
2015-02-11 4:55 ` [PATCH 2/5 v2] powerpc/boot/fdt: Add little-endian support to libfdt wrappers Jeremy Kerr
2015-02-11 4:55 ` [PATCH 4/5 v2] powerpc/boot: Fix stack corruption in epapr entry point Jeremy Kerr
3 siblings, 0 replies; 6+ messages in thread
From: Jeremy Kerr @ 2015-02-11 4:55 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Cédric Le Goater
We'll likely be entering the zImage.epapr as BE, so include the pseries
implementation of _zimage_start, which adds the endian fixup magic.
Although the endian fixup won't work on Book III-E machines starting LE,
the current entry point doesn't support LE anyway, so we shouldn't be
breaking anything.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
arch/powerpc/boot/wrapper | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index ae0f88e..3f50c27 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -277,7 +277,7 @@ treeboot-iss4xx-mpic)
platformo="$object/treeboot-iss4xx.o"
;;
epapr)
- platformo="$object/epapr.o $object/epapr-wrapper.o"
+ platformo="$object/pseries-head.o $object/epapr.o $object/epapr-wrapper.o"
link_address='0x20000000'
pie=-pie
;;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/5 v2] powerpc/boot/fdt: Use unsigned long for pointer casts
@ 2015-02-11 4:55 Jeremy Kerr
2015-02-11 4:55 ` [PATCH 5/5 v2] powerpc/boot: don't clobber r6 and r7 in epapr boot Jeremy Kerr
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Jeremy Kerr @ 2015-02-11 4:55 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Cédric Le Goater
Now that the wrapper supports 64-bit builds, we see warnings when
attempting to cast pointers to int. Use unsigned long instead.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
arch/powerpc/boot/libfdt-wrapper.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/boot/libfdt-wrapper.c b/arch/powerpc/boot/libfdt-wrapper.c
index bb8b9b3..535e8fd 100644
--- a/arch/powerpc/boot/libfdt-wrapper.c
+++ b/arch/powerpc/boot/libfdt-wrapper.c
@@ -44,12 +44,12 @@
#define offset_devp(off) \
({ \
- int _offset = (off); \
+ unsigned long _offset = (off); \
check_err(_offset) ? NULL : (void *)(_offset+1); \
})
-#define devp_offset_find(devp) (((int)(devp))-1)
-#define devp_offset(devp) (devp ? ((int)(devp))-1 : 0)
+#define devp_offset_find(devp) (((unsigned long)(devp))-1)
+#define devp_offset(devp) (devp ? ((unsigned long)(devp))-1 : 0)
static void *fdt;
static void *buf; /* = NULL */
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5 v2] powerpc/boot: Fix stack corruption in epapr entry point
2015-02-11 4:55 [PATCH 1/5 v2] powerpc/boot/fdt: Use unsigned long for pointer casts Jeremy Kerr
` (2 preceding siblings ...)
2015-02-11 4:55 ` [PATCH 2/5 v2] powerpc/boot/fdt: Add little-endian support to libfdt wrappers Jeremy Kerr
@ 2015-02-11 4:55 ` Jeremy Kerr
3 siblings, 0 replies; 6+ messages in thread
From: Jeremy Kerr @ 2015-02-11 4:55 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Cédric Le Goater
Currently, a 64-bit little-endian zImage.epapr won't boot in epapr mode,
as we never return from platform_init.
Before entering C, we initialise our stack by setting r1 16 bytes below
the end of the _bss_stack:
stwu r0,-16(r1) /* establish a stack frame */
However, the called function will save the caller's lr in the caller's
frame's lr save area, at -16(r1) to -32(r1).
This means that writes to the fdt variable will corrupt the saved link
register:
0000000020c06018 l O .bss 0000000000001000 _bss_stack
0000000020c07018 l O .bss 0000000000000008 fdt
We'll need at least 32 bytes in the initial stack frame, to handle the
LR save area. We bump this to 112 bytes, as that'll be the max required
by ABIv1.
Thanks to Alistair Popple for debugging help.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
arch/powerpc/boot/crt0.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index 14de4f8..e004062 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -218,7 +218,7 @@ p_base: mflr r10 /* r10 now points to runtime addr of p_base */
beq 6f
ld r1,0(r8)
li r0,0
- stdu r0,-16(r1) /* establish a stack frame */
+ stdu r0,-112(r1) /* establish a stack frame */
6:
#endif /* __powerpc64__ */
/* Call platform_init() */
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5 v2] powerpc/boot: don't clobber r6 and r7 in epapr boot
2015-02-11 4:55 [PATCH 1/5 v2] powerpc/boot/fdt: Use unsigned long for pointer casts Jeremy Kerr
@ 2015-02-11 4:55 ` Jeremy Kerr
2015-02-11 4:55 ` [PATCH 3/5 v2] powerpc/boot/wrapper: use the pseries wrapper for zImage.epapr Jeremy Kerr
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Jeremy Kerr @ 2015-02-11 4:55 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Cédric Le Goater
We use r6 and r7 for epapr boot, but the current pre-C init will clobber
both of these.
This change does a simple replacement, of r6 -> r12 and r7 -> r13, so
that we hit platform init with these registers intact.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
arch/powerpc/boot/crt0.S | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index e004062..12866cc 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -155,29 +155,29 @@ p_base: mflr r10 /* r10 now points to runtime addr of p_base */
ld r9,(p_rela-p_base)(r10)
add r9,r9,r10
- li r7,0
+ li r13,0
li r8,0
-9: ld r6,0(r11) /* get tag */
- cmpdi r6,0
+9: ld r12,0(r11) /* get tag */
+ cmpdi r12,0
beq 12f /* end of list */
- cmpdi r6,RELA
+ cmpdi r12,RELA
bne 10f
- ld r7,8(r11) /* get RELA pointer in r7 */
+ ld r13,8(r11) /* get RELA pointer in r13 */
b 11f
-10: addis r6,r6,(-RELACOUNT)@ha
- cmpdi r6,RELACOUNT@l
+10: addis r12,r12,(-RELACOUNT)@ha
+ cmpdi r12,RELACOUNT@l
bne 11f
ld r8,8(r11) /* get RELACOUNT value in r8 */
11: addi r11,r11,16
b 9b
12:
- cmpdi r7,0 /* check we have both RELA and RELACOUNT */
+ cmpdi r13,0 /* check we have both RELA and RELACOUNT */
cmpdi cr1,r8,0
beq 3f
beq cr1,3f
/* Calcuate the runtime offset. */
- subf r7,r7,r9
+ subf r13,r13,r9
/* Run through the list of relocations and process the
* R_PPC64_RELATIVE ones. */
@@ -185,10 +185,10 @@ p_base: mflr r10 /* r10 now points to runtime addr of p_base */
13: ld r0,8(r9) /* ELF64_R_TYPE(reloc->r_info) */
cmpdi r0,22 /* R_PPC64_RELATIVE */
bne 3f
- ld r6,0(r9) /* reloc->r_offset */
+ ld r12,0(r9) /* reloc->r_offset */
ld r0,16(r9) /* reloc->r_addend */
- add r0,r0,r7
- stdx r0,r7,r6
+ add r0,r0,r13
+ stdx r0,r13,r12
addi r9,r9,24
bdnz 13b
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/5 v2] powerpc/boot/fdt: Add little-endian support to libfdt wrappers
2015-02-11 4:55 ` [PATCH 2/5 v2] powerpc/boot/fdt: Add little-endian support to libfdt wrappers Jeremy Kerr
@ 2015-02-16 16:53 ` Cedric Le Goater
0 siblings, 0 replies; 6+ messages in thread
From: Cedric Le Goater @ 2015-02-16 16:53 UTC (permalink / raw)
To: Jeremy Kerr, linuxppc-dev
On 02/11/2015 05:55 AM, Jeremy Kerr wrote:
> For epapr-style boot, we may be little-endian. This change implements
> the proper conversion for fdt*_to_cpu and cpu_to_fdt*. We also need the
> full cpu_to_* and *_to_cpu macros for this.
>
> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
I did not work on the little endian epapr wrapper :/
To test the patchset, I used the 'le' branch of git://github.com/jk-ozlabs/linux
and successfully booted a tuleta and an open-power system using the latest
skiboot and a LE zImage.epapr. Looks good to me.
You might want to add CONFIG_IPMI_WATCHDOG to openpower_defconfig
Thanks.
C.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-02-16 16:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-11 4:55 [PATCH 1/5 v2] powerpc/boot/fdt: Use unsigned long for pointer casts Jeremy Kerr
2015-02-11 4:55 ` [PATCH 5/5 v2] powerpc/boot: don't clobber r6 and r7 in epapr boot Jeremy Kerr
2015-02-11 4:55 ` [PATCH 3/5 v2] powerpc/boot/wrapper: use the pseries wrapper for zImage.epapr Jeremy Kerr
2015-02-11 4:55 ` [PATCH 2/5 v2] powerpc/boot/fdt: Add little-endian support to libfdt wrappers Jeremy Kerr
2015-02-16 16:53 ` Cedric Le Goater
2015-02-11 4:55 ` [PATCH 4/5 v2] powerpc/boot: Fix stack corruption in epapr entry point Jeremy Kerr
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.