diff options
| author | Gavin Shan <gwshan@linux.vnet.ibm.com> | 2015-01-08 00:40:51 -0500 |
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-01-22 22:02:52 -0500 |
| commit | 6f20e7f2e930211613a66d0603fa4abaaf3ce662 (patch) | |
| tree | 2d92f779d0d1e675b5289c176b1cda023fbebc9b | |
| parent | 53a448c3d5d721cd85e3ad3e38c222a4dbb17f13 (diff) | |
powerpc/kernel: Avoid memory corruption at early stage
When calling to early_setup(), we pick "boot_paca" up for the master CPU
and initialize that with initialise_paca(). At that point, the SLB
shadow buffer isn't populated yet. Updating the SLB shadow buffer should
corrupt what we had in physical address 0 where the trap instruction is
usually stored.
This hasn't been observed to cause any trouble in practice, but is
obviously fishy.
Fixes: 6f4441ef7009 ("powerpc: Dynamically allocate slb_shadow from memblock")
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
| -rw-r--r-- | arch/powerpc/kernel/paca.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index d6e195e8cd4c..5a23b69f8129 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c | |||
| @@ -115,6 +115,14 @@ static struct slb_shadow * __init init_slb_shadow(int cpu) | |||
| 115 | { | 115 | { |
| 116 | struct slb_shadow *s = &slb_shadow[cpu]; | 116 | struct slb_shadow *s = &slb_shadow[cpu]; |
| 117 | 117 | ||
| 118 | /* | ||
| 119 | * When we come through here to initialise boot_paca, the slb_shadow | ||
| 120 | * buffers are not allocated yet. That's OK, we'll get one later in | ||
| 121 | * boot, but make sure we don't corrupt memory at 0. | ||
| 122 | */ | ||
| 123 | if (!slb_shadow) | ||
| 124 | return NULL; | ||
| 125 | |||
| 118 | s->persistent = cpu_to_be32(SLB_NUM_BOLTED); | 126 | s->persistent = cpu_to_be32(SLB_NUM_BOLTED); |
| 119 | s->buffer_length = cpu_to_be32(sizeof(*s)); | 127 | s->buffer_length = cpu_to_be32(sizeof(*s)); |
| 120 | 128 | ||
