powerpc: Use LOAD_REG_IMMEDIATE only for constants on 64-bit
Using LOAD_REG_IMMEDIATE to get the address of kernel symbols generates 5 instructions where LOAD_REG_ADDR can do it in one, and will generate R_PPC64_ADDR16_* relocations in the output when we get to making the kernel as a position-independent executable, which we'd rather not have to handle. This changes various bits of assembly code to use LOAD_REG_ADDR when we need to get the address of a symbol, or to use suitable position-independent code for cases where we can't access the TOC for various reasons, or if we're not running at the address we were linked at. It also cleans up a few minor things; there's no reason to save and restore SRR0/1 around RTAS calls, __mmu_off can get the return address from LR more conveniently than the caller can supply it in R4 (and we already assume elsewhere that EA == RA if the MMU is on in early boot), and enable_64b_mode was using 5 instructions where 2 would do. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
@ -690,10 +690,6 @@ _GLOBAL(enter_rtas)
|
||||
std r7,_DAR(r1)
|
||||
mfdsisr r8
|
||||
std r8,_DSISR(r1)
|
||||
mfsrr0 r9
|
||||
std r9,_SRR0(r1)
|
||||
mfsrr1 r10
|
||||
std r10,_SRR1(r1)
|
||||
|
||||
/* Temporary workaround to clear CR until RTAS can be modified to
|
||||
* ignore all bits.
|
||||
@ -754,6 +750,10 @@ _STATIC(rtas_return_loc)
|
||||
mfspr r4,SPRN_SPRG3 /* Get PACA */
|
||||
clrldi r4,r4,2 /* convert to realmode address */
|
||||
|
||||
bcl 20,31,$+4
|
||||
0: mflr r3
|
||||
ld r3,(1f-0b)(r3) /* get &.rtas_restore_regs */
|
||||
|
||||
mfmsr r6
|
||||
li r0,MSR_RI
|
||||
andc r6,r6,r0
|
||||
@ -761,7 +761,6 @@ _STATIC(rtas_return_loc)
|
||||
mtmsrd r6
|
||||
|
||||
ld r1,PACAR1(r4) /* Restore our SP */
|
||||
LOAD_REG_IMMEDIATE(r3,.rtas_restore_regs)
|
||||
ld r4,PACASAVEDMSR(r4) /* Restore our MSR */
|
||||
|
||||
mtspr SPRN_SRR0,r3
|
||||
@ -769,6 +768,9 @@ _STATIC(rtas_return_loc)
|
||||
rfid
|
||||
b . /* prevent speculative execution */
|
||||
|
||||
.align 3
|
||||
1: .llong .rtas_restore_regs
|
||||
|
||||
_STATIC(rtas_restore_regs)
|
||||
/* relocation is on at this point */
|
||||
REST_GPR(2, r1) /* Restore the TOC */
|
||||
@ -788,10 +790,6 @@ _STATIC(rtas_restore_regs)
|
||||
mtdar r7
|
||||
ld r8,_DSISR(r1)
|
||||
mtdsisr r8
|
||||
ld r9,_SRR0(r1)
|
||||
mtsrr0 r9
|
||||
ld r10,_SRR1(r1)
|
||||
mtsrr1 r10
|
||||
|
||||
addi r1,r1,RTAS_FRAME_SIZE /* Unstack our frame */
|
||||
ld r0,16(r1) /* get return address */
|
||||
|
Reference in New Issue
Block a user