linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] improve recoverability of OPAL calls
@ 2017-10-23  7:08 Nicholas Piggin
  2017-10-23  7:08 ` [PATCH 1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch Nicholas Piggin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nicholas Piggin @ 2017-10-23  7:08 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

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(-)

-- 
2.13.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch
  2017-10-23  7:08 [PATCH 0/3] improve recoverability of OPAL calls Nicholas Piggin
@ 2017-10-23  7:08 ` Nicholas Piggin
  2017-11-07 23:30   ` [1/3] " Michael Ellerman
  2017-10-23  7:08 ` [PATCH 2/3] powerpc/book3s: Add an HV variant of FIXUP_ENDIAN that is recoverable Nicholas Piggin
  2017-10-23  7:08 ` [PATCH 3/3] powerpc/powernv: Use FIXUP_ENDIAN_HV in OPAL return Nicholas Piggin
  2 siblings, 1 reply; 5+ messages in thread
From: Nicholas Piggin @ 2017-10-23  7:08 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/include/asm/ppc_asm.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 36f3e41c9fbe..d6b56aebe602 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -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 */
 
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] powerpc/book3s: Add an HV variant of FIXUP_ENDIAN that is recoverable
  2017-10-23  7:08 [PATCH 0/3] improve recoverability of OPAL calls Nicholas Piggin
  2017-10-23  7:08 ` [PATCH 1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch Nicholas Piggin
@ 2017-10-23  7:08 ` Nicholas Piggin
  2017-10-23  7:08 ` [PATCH 3/3] powerpc/powernv: Use FIXUP_ENDIAN_HV in OPAL return Nicholas Piggin
  2 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2017-10-23  7:08 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Add an HV variant of FIXUP_ENDIAN which uses HSRR[01] and does not
clear MSR[RI], which improves recoverability.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/include/asm/ppc_asm.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index d6b56aebe602..ae94b3626b6c 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -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__ */
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] powerpc/powernv: Use FIXUP_ENDIAN_HV in OPAL return
  2017-10-23  7:08 [PATCH 0/3] improve recoverability of OPAL calls Nicholas Piggin
  2017-10-23  7:08 ` [PATCH 1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch Nicholas Piggin
  2017-10-23  7:08 ` [PATCH 2/3] powerpc/book3s: Add an HV variant of FIXUP_ENDIAN that is recoverable Nicholas Piggin
@ 2017-10-23  7:08 ` Nicholas Piggin
  2 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2017-10-23  7:08 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Close the recoverability gap for OPAL calls by using FIXUP_ENDIAN_HV
in the return path.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/platforms/powernv/opal-wrappers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 37cd170201a2..6f4b00a2ac46 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -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)
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch
  2017-10-23  7:08 ` [PATCH 1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch Nicholas Piggin
@ 2017-11-07 23:30   ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-11-07 23:30 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin

On Mon, 2017-10-23 at 07:08:13 UTC, Nicholas Piggin wrote:
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f848ea7f5960ec2684c3bd1c0692e6

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-11-07 23:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-23  7:08 [PATCH 0/3] improve recoverability of OPAL calls Nicholas Piggin
2017-10-23  7:08 ` [PATCH 1/3] powerpc/book3s: use label for FIXUP_ENDIAN macro branch Nicholas Piggin
2017-11-07 23:30   ` [1/3] " Michael Ellerman
2017-10-23  7:08 ` [PATCH 2/3] powerpc/book3s: Add an HV variant of FIXUP_ENDIAN that is recoverable Nicholas Piggin
2017-10-23  7:08 ` [PATCH 3/3] powerpc/powernv: Use FIXUP_ENDIAN_HV in OPAL return Nicholas Piggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).