Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Don't flush/invalidate the d/icache for an unknown relocation type

For an unknown relocation type since the value of r4 is just the 8bit
relocation type, the sum of r4 and r7 may yield an invalid memory
address. For example:
In normal case:
r4 = c00xxxxx
r7 = 40000000
r4 + r7 = 000xxxxx

For an unknown relocation type:
r4 = 000000xx
r7 = 40000000
r4 + r7 = 400000xx
400000xx is an invalid memory address for a board which has just
512M memory.

And for operations such as dcbst or icbi may cause bus error for an
invalid memory address on some platforms and then cause the board
reset. So we should skip the flush/invalidate the d/icache for
an unknown relocation type.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Suzuki K. Poulose <suzuki@in.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Kevin Hao and committed by
Benjamin Herrenschmidt
348c2298 4bb29711

+2 -1
+2 -1
arch/powerpc/kernel/reloc_32.S
··· 166 166 /* R_PPC_ADDR16_LO */ 167 167 lo16: 168 168 cmpwi r4, R_PPC_ADDR16_LO 169 - bne nxtrela 169 + bne unknown_type 170 170 lwz r4, 0(r9) /* r_offset */ 171 171 lwz r0, 8(r9) /* r_addend */ 172 172 add r0, r0, r3 ··· 191 191 dcbst r4,r7 192 192 sync /* Ensure the data is flushed before icbi */ 193 193 icbi r4,r7 194 + unknown_type: 194 195 cmpwi r8, 0 /* relasz = 0 ? */ 195 196 ble done 196 197 add r9, r9, r6 /* move to next entry in the .rela table */