|
| 1 | +From 0ea7a41c1a88f248206455589d3d1c8a08e8362d Mon Sep 17 00:00:00 2001 |
| 2 | +From: Jeremy Kerr < [email protected]> |
| 3 | +Date: Mon, 2 Feb 2015 22:05:39 +0800 |
| 4 | +Subject: [PATCH] trampoline: Correctly set boot CPU on little-endian |
| 5 | + |
| 6 | +Currently, a little-endian trampoline will store the boot cpu value |
| 7 | +into the device-tree header with a simple stw. However, the fdt is |
| 8 | +defined as big-endian, so we'll be setting an endian-reversed value |
| 9 | +here. |
| 10 | + |
| 11 | +This change uses a stwbrx on little-endian, and a stwx for big-endian. |
| 12 | +Because we only have an x-form instruction for a byte-reversed store, we |
| 13 | +need an extra instruction to add our offset. |
| 14 | + |
| 15 | +Signed-off-by: Jeremy Kerr < [email protected]> |
| 16 | +--- |
| 17 | + kexec_trampoline.S | 11 ++++++++++- |
| 18 | + 1 file changed, 10 insertions(+), 1 deletion(-) |
| 19 | + |
| 20 | +diff --git a/kexec_trampoline.S b/kexec_trampoline.S |
| 21 | +index 954aa63..a3eb314 100644 |
| 22 | +--- a/kexec_trampoline.S |
| 23 | ++++ b/kexec_trampoline.S |
| 24 | +@@ -48,6 +48,14 @@ |
| 25 | + #define LOAD lwz |
| 26 | + #endif |
| 27 | + |
| 28 | ++#if defined(__LITTLE_ENDIAN__) |
| 29 | ++#define STWX_BE stwbrx |
| 30 | ++#elif defined(__BIG_ENDIAN__) |
| 31 | ++#define STWX_BE stwx |
| 32 | ++#else |
| 33 | ++#error no endianness defined! |
| 34 | ++#endif |
| 35 | ++ |
| 36 | + .globl __trampoline_start |
| 37 | + __trampoline_start: |
| 38 | + b start |
| 39 | +@@ -72,7 +80,8 @@ start: |
| 40 | + |
| 41 | + LOAD r7,(device_tree_addr - 1b)(r6) |
| 42 | + /* We save the physical cpu id in the device tree header */ |
| 43 | +- stw r3,DT_CPU_OFFSET(r7) |
| 44 | ++ addi r5,r7,DT_CPU_OFFSET |
| 45 | ++ STWX_BE r3,0,r5 |
| 46 | + mr r3,r7 |
| 47 | + |
| 48 | + LOAD r4,(kernel_addr - 1b)(r6) |
| 49 | +-- |
| 50 | +1.9.1 |
| 51 | + |
0 commit comments