Skip to content

Commit 861efb8

Browse files
chleroymaddy-kerneldev
authored andcommitted
powerpc/kexec: fix physical address calculation in clear_utlb_entry()
In relocate_32.S, function clear_utlb_entry() goes into real mode. To do so, it has to calculate the physical address based on the virtual address. To get the virtual address it uses 'bl' which is problematic (see commit c974809 ("powerpc/vdso: Avoid link stack corruption in __get_datapage()")). In addition, the calculation is done on a wrong address because 'bl' loads LR with the address of the following instruction, not the address of the target. So when the target is not the instruction following the 'bl' instruction, it may lead to unexpected behaviour. Fix it by re-writing the code so that is goes via another path which is based 'bcl 20,31,.+4' which is the right instruction to use for that. Fixes: 6834302 ("powerpc/47x: Kernel support for KEXEC") Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/dc4f9616fba9c05c5dbf9b4b5480eb1c362adc17.1741256651.git.christophe.leroy@csgroup.eu
1 parent 1e4d73d commit 861efb8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

arch/powerpc/kexec/relocate_32.S

+2-5
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,13 @@ write_utlb:
348348
rlwinm r10, r24, 0, 22, 27
349349

350350
cmpwi r10, PPC47x_TLB0_4K
351-
bne 0f
352351
li r10, 0x1000 /* r10 = 4k */
353-
ANNOTATE_INTRA_FUNCTION_CALL
354-
bl 1f
352+
beq 0f
355353

356-
0:
357354
/* Defaults to 256M */
358355
lis r10, 0x1000
359356

360-
bcl 20,31,$+4
357+
0: bcl 20,31,$+4
361358
1: mflr r4
362359
addi r4, r4, (2f-1b) /* virtual address of 2f */
363360

0 commit comments

Comments
 (0)