improve recoverability of OPAL calls
Nicholas Piggin
reviewercover improve recoverability of OPAL calls
Here's a few patches to improve recoverability for FIXUP_ENDIAN on powernv. We should try to minimise SRR[01] (and MSR[RI]=0) usage as much as possible. Whether that's by using HSRR or mtmsrd, it usually results in faster and smaller code too.
There's a few other places we can improve, but I've had these patches around for a while.
Thanks,
Nick
Nicholas Piggin (3):
powerpc/book3s: use label for FIXUP_ENDIAN macro branch powerpc/book3s: Add an HV variant of FIXUP_ENDIAN that is recoverable powerpc/powernv: Use FIXUP_ENDIAN_HV in OPAL return
arch/powerpc/include/asm/ppc_asm.h | 27 ++++++++++++++++++++++++-- arch/powerpc/platforms/powernv/opal-wrappers.S | 4 ++-- 2 files changed, 27 insertions(+), 4 deletions(-)
Signature · 1 line
2.13.3
Nicholas Piggin
reviewerPATCH 1/3 powerpc/book3s: use label for FIXUP_ENDIAN macro branch
--- arch/powerpc/include/asm/ppc_asm.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/ppc_asm.h +3 -2
@@ -776,7 +776,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)#else #define FIXUP_ENDIAN \ tdi 0,0,0x48; /* Reverse endian of b . + 8 */ \ - b $+44; /* Skip trampoline if endian is good */ \ + b 191f; /* Skip trampoline if endian is good */ \ .long 0xa600607d; /* mfmsr r11 */ \ .long 0x01006b69; /* xori r11,r11,1 */ \ .long 0x00004039; /* li r10,0 */ \
@@ -786,7 +786,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601) .long 0x14004a39; /* addi r10,r10,20 */ \ .long 0xa6035a7d; /* mtsrr0 r10 */ \ .long 0xa6037b7d; /* mtsrr1 r11 */ \ - .long 0x2400004c /* rfid */ + .long 0x2400004c; /* rfid */ \ +191:#endif /* !CONFIG_PPC_BOOK3E */
Signature · 1 line
2.13.3
Re: [1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch
Quoted 1 line · Nicholas Piggin
Signed-off-by Nicholas Piggin <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/f848ea7f5960ec2684c3bd1c0692e6
cheers
Nicholas Piggin
reviewerPATCH 2/3 powerpc/book3s: Add an HV variant of FIXUP_ENDIAN that is recoverable
In reply to Nicholas PigginAdd an HV variant of FIXUP_ENDIAN which uses HSRR[01] and does not clear MSR[RI], which improves recoverability.
--- arch/powerpc/include/asm/ppc_asm.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/powerpc/include/asm/ppc_asm.h +22 -0
@@ -774,6 +774,10 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)#ifdef CONFIG_PPC_BOOK3E #define FIXUP_ENDIAN #else +/* +* This version may be used in in HV or non-HV context. +* MSR[EE] must be disabled. +*/ #define FIXUP_ENDIAN \ tdi 0,0,0x48; /* Reverse endian of b . + 8 */ \ b 191f; /* Skip trampoline if endian is good */ \
@@ -789,6 +793,24 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601) .long 0x2400004c; /* rfid */ \ 191: +/* +* This version that may only be used with MSR[HV]=1 +* - Does not clear MSR[RI], so more robust. +* - Slightly smaller and faster. +*/ +#define FIXUP_ENDIAN_HV \ + tdi 0,0,0x48; /* Reverse endian of b . + 8 */ \ + b 191f; /* Skip trampoline if endian is good */ \ + .long 0xa600607d; /* mfmsr r11 */ \ + .long 0x01006b69; /* xori r11,r11,1 */ \ + .long 0x05009f42; /* bcl 20,31,$+4 */ \ + .long 0xa602487d; /* mflr r10 */ \ + .long 0x14004a39; /* addi r10,r10,20 */ \ + .long 0xa64b5a7d; /* mthsrr0 r10 */ \ + .long 0xa64b7b7d; /* mthsrr1 r11 */ \ + .long 0x2402004c; /* hrfid */ \ +191: +#endif /* !CONFIG_PPC_BOOK3E */ #endif /* __ASSEMBLY__ */
Signature · 1 line
2.13.3
Nicholas Piggin
reviewerPATCH 3/3 powerpc/powernv: Use FIXUP_ENDIAN_HV in OPAL return
In reply to Nicholas PigginClose the recoverability gap for OPAL calls by using FIXUP_ENDIAN_HV in the return path.
--- arch/powerpc/platforms/powernv/opal-wrappers.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/powernv/opal-wrappers.S +2 -2
@@ -94,7 +94,7 @@ opal_return: * bytes (always BE) since MSR:LE will end up fixed up as a side * effect of the rfid. */ - FIXUP_ENDIAN + FIXUP_ENDIAN_HV ld r2,PACATOC(r13); lwz r4,8(r1); ld r5,PPC_LR_STKOFF(r1);
@@ -120,7 +120,7 @@ opal_real_call: hrfid opal_return_realmode: - FIXUP_ENDIAN + FIXUP_ENDIAN_HV ld r2,PACATOC(r13); lwz r11,8(r1); ld r12,PPC_LR_STKOFF(r1)
Signature · 1 line
2.13.3