linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke
@ 2021-06-04 14:54 Christophe Leroy
  2021-06-04 14:54 ` [PATCH 2/4] powerpc/32: Interchange r1 and r11 in SYSCALL_ENTRY on booke Christophe Leroy
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Christophe Leroy @ 2021-06-04 14:54 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

To better match booke version of SYSCALL_ENTRY macro, interchange
r10 and r12 in the non booke version.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/kernel/head_32.h | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index a8221ddcbd66..1e55bc054659 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -142,42 +142,42 @@ _ASM_NOKPROBE_SYMBOL(\name\()_virt)
 
 .macro SYSCALL_ENTRY trapno
 	mfspr	r9, SPRN_SRR1
-	mfspr	r10, SPRN_SRR0
+	mfspr	r12, SPRN_SRR0
 	LOAD_REG_IMMEDIATE(r11, MSR_KERNEL)		/* can take exceptions */
-	lis	r12, 1f@h
-	ori	r12, r12, 1f@l
+	lis	r10, 1f@h
+	ori	r10, r10, 1f@l
 	mtspr	SPRN_SRR1, r11
-	mtspr	SPRN_SRR0, r12
-	mfspr	r12,SPRN_SPRG_THREAD
+	mtspr	SPRN_SRR0, r10
+	mfspr	r10,SPRN_SPRG_THREAD
 	mr	r11, r1
-	lwz	r1,TASK_STACK-THREAD(r12)
-	tovirt(r12, r12)
+	lwz	r1,TASK_STACK-THREAD(r10)
+	tovirt(r10, r10)
 	addi	r1, r1, THREAD_SIZE - INT_FRAME_SIZE
 	rfi
 1:
 	stw	r11,GPR1(r1)
 	stw	r11,0(r1)
 	mr	r11, r1
-	stw	r10,_NIP(r11)
-	mflr	r10
-	stw	r10, _LINK(r11)
-	mfcr	r10
-	rlwinm	r10,r10,0,4,2	/* Clear SO bit in CR */
-	stw	r10,_CCR(r11)		/* save registers */
+	stw	r12,_NIP(r11)
+	mflr	r12
+	stw	r12, _LINK(r11)
+	mfcr	r12
+	rlwinm	r12,r12,0,4,2	/* Clear SO bit in CR */
+	stw	r12,_CCR(r11)		/* save registers */
 #ifdef CONFIG_40x
 	rlwinm	r9,r9,0,14,12		/* clear MSR_WE (necessary?) */
 #endif
-	lis	r10,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
+	lis	r12,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
 	stw	r2,GPR2(r11)
-	addi	r10,r10,STACK_FRAME_REGS_MARKER@l
+	addi	r12,r12,STACK_FRAME_REGS_MARKER@l
 	stw	r9,_MSR(r11)
 	li	r2, \trapno
-	stw	r10,8(r11)
+	stw	r12,8(r11)
 	stw	r2,_TRAP(r11)
 	SAVE_GPR(0, r11)
 	SAVE_4GPRS(3, r11)
 	SAVE_2GPRS(7, r11)
-	addi	r2,r12,-THREAD
+	addi	r2,r10,-THREAD
 	b	transfer_to_syscall		/* jump to handler */
 .endm
 
-- 
2.25.0


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

* [PATCH 2/4] powerpc/32: Interchange r1 and r11 in SYSCALL_ENTRY on booke
  2021-06-04 14:54 [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Christophe Leroy
@ 2021-06-04 14:54 ` Christophe Leroy
  2021-06-04 14:54 ` [PATCH 3/4] powerpc/32: Reduce code duplication of system call entry Christophe Leroy
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Christophe Leroy @ 2021-06-04 14:54 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

To better match non booke version of SYSCALL_ENTRY macro,
interchange r1 and r11 in the booke version.

While at it, in both versions use r1 instead of r11 to save
_NIP and _CCR.

All other uses of r11 will go away in next patch, so don't
bother changing them for now.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/kernel/head_32.h    |  4 ++--
 arch/powerpc/kernel/head_booke.h | 17 +++++++++--------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index 1e55bc054659..7ca25eb9bc75 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -158,12 +158,12 @@ _ASM_NOKPROBE_SYMBOL(\name\()_virt)
 	stw	r11,GPR1(r1)
 	stw	r11,0(r1)
 	mr	r11, r1
-	stw	r12,_NIP(r11)
+	stw	r12,_NIP(r1)
 	mflr	r12
 	stw	r12, _LINK(r11)
 	mfcr	r12
 	rlwinm	r12,r12,0,4,2	/* Clear SO bit in CR */
-	stw	r12,_CCR(r11)		/* save registers */
+	stw	r12,_CCR(r1)
 #ifdef CONFIG_40x
 	rlwinm	r9,r9,0,14,12		/* clear MSR_WE (necessary?) */
 #endif
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index f82470091697..4a2fad9f225e 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -135,17 +135,18 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
 #endif
 	mfspr	r9, SPRN_SRR1
 	BOOKE_CLEAR_BTB(r11)
-	lwz	r11, TASK_STACK - THREAD(r10)
+	mr	r11, r1
+	lwz	r1, TASK_STACK - THREAD(r10)
 	rlwinm	r12,r12,0,4,2	/* Clear SO bit in CR */
-	ALLOC_STACK_FRAME(r11, THREAD_SIZE - INT_FRAME_SIZE)
-	stw	r12, _CCR(r11)		/* save various registers */
+	ALLOC_STACK_FRAME(r1, THREAD_SIZE - INT_FRAME_SIZE)
+	stw	r12, _CCR(r1)
 	mflr	r12
-	stw	r12,_LINK(r11)
+	stw	r12,_LINK(r1)
 	mfspr	r12,SPRN_SRR0
-	stw	r1, GPR1(r11)
-	stw	r1, 0(r11)
-	mr	r1, r11
-	stw	r12,_NIP(r11)
+	stw	r11, GPR1(r1)
+	stw	r11, 0(r1)
+	mr	r11, r1
+	stw	r12,_NIP(r1)
 	rlwinm	r9,r9,0,14,12		/* clear MSR_WE (necessary?)	   */
 	lis	r12, STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
 	stw	r2,GPR2(r11)
-- 
2.25.0


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

* [PATCH 3/4] powerpc/32: Reduce code duplication of system call entry
  2021-06-04 14:54 [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Christophe Leroy
  2021-06-04 14:54 ` [PATCH 2/4] powerpc/32: Interchange r1 and r11 in SYSCALL_ENTRY on booke Christophe Leroy
@ 2021-06-04 14:54 ` Christophe Leroy
  2021-06-04 14:54 ` [PATCH 4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry Christophe Leroy
  2021-06-26 10:37 ` [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Michael Ellerman
  3 siblings, 0 replies; 7+ messages in thread
From: Christophe Leroy @ 2021-06-04 14:54 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

booke and non booke do pretty similar things in SYSCALL_ENTRY macro
just before calling jumping to transfer_to_syscall().

Do them in transfer_to_syscall() instead.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/kernel/entry_32.S   | 19 +++++++++++++++++++
 arch/powerpc/kernel/head_32.h    | 19 -------------------
 arch/powerpc/kernel/head_booke.h | 18 ------------------
 3 files changed, 19 insertions(+), 37 deletions(-)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 9160285cb2f4..0f53f6d11865 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -32,6 +32,7 @@
 #include <asm/barrier.h>
 #include <asm/kup.h>
 #include <asm/bug.h>
+#include <asm/interrupt.h>
 
 #include "head_32.h"
 
@@ -74,6 +75,24 @@ _ASM_NOKPROBE_SYMBOL(prepare_transfer_to_handler)
 
 	.globl	transfer_to_syscall
 transfer_to_syscall:
+	stw	r11, GPR1(r1)
+	stw	r11, 0(r1)
+	mflr	r12
+	stw	r12, _LINK(r1)
+#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
+	rlwinm	r9,r9,0,14,12		/* clear MSR_WE (necessary?) */
+#endif
+	lis	r12,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
+	SAVE_GPR(2, r1)
+	addi	r12,r12,STACK_FRAME_REGS_MARKER@l
+	stw	r9,_MSR(r1)
+	li	r2, INTERRUPT_SYSCALL
+	stw	r12,8(r1)
+	stw	r2,_TRAP(r1)
+	SAVE_GPR(0, r1)
+	SAVE_4GPRS(3, r1)
+	SAVE_2GPRS(7, r1)
+	addi	r2,r10,-THREAD
 	SAVE_NVGPRS(r1)
 
 	/* Calling convention has r9 = orig r0, r10 = regs */
diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index 7ca25eb9bc75..6b1ec9e3541b 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -155,29 +155,10 @@ _ASM_NOKPROBE_SYMBOL(\name\()_virt)
 	addi	r1, r1, THREAD_SIZE - INT_FRAME_SIZE
 	rfi
 1:
-	stw	r11,GPR1(r1)
-	stw	r11,0(r1)
-	mr	r11, r1
 	stw	r12,_NIP(r1)
-	mflr	r12
-	stw	r12, _LINK(r11)
 	mfcr	r12
 	rlwinm	r12,r12,0,4,2	/* Clear SO bit in CR */
 	stw	r12,_CCR(r1)
-#ifdef CONFIG_40x
-	rlwinm	r9,r9,0,14,12		/* clear MSR_WE (necessary?) */
-#endif
-	lis	r12,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
-	stw	r2,GPR2(r11)
-	addi	r12,r12,STACK_FRAME_REGS_MARKER@l
-	stw	r9,_MSR(r11)
-	li	r2, \trapno
-	stw	r12,8(r11)
-	stw	r2,_TRAP(r11)
-	SAVE_GPR(0, r11)
-	SAVE_4GPRS(3, r11)
-	SAVE_2GPRS(7, r11)
-	addi	r2,r10,-THREAD
 	b	transfer_to_syscall		/* jump to handler */
 .endm
 
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index 4a2fad9f225e..10f31146b472 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -140,26 +140,8 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
 	rlwinm	r12,r12,0,4,2	/* Clear SO bit in CR */
 	ALLOC_STACK_FRAME(r1, THREAD_SIZE - INT_FRAME_SIZE)
 	stw	r12, _CCR(r1)
-	mflr	r12
-	stw	r12,_LINK(r1)
 	mfspr	r12,SPRN_SRR0
-	stw	r11, GPR1(r1)
-	stw	r11, 0(r1)
-	mr	r11, r1
 	stw	r12,_NIP(r1)
-	rlwinm	r9,r9,0,14,12		/* clear MSR_WE (necessary?)	   */
-	lis	r12, STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
-	stw	r2,GPR2(r11)
-	addi	r12, r12, STACK_FRAME_REGS_MARKER@l
-	stw	r9,_MSR(r11)
-	li	r2, \trapno
-	stw	r12, 8(r11)
-	stw	r2,_TRAP(r11)
-	SAVE_GPR(0, r11)
-	SAVE_4GPRS(3, r11)
-	SAVE_2GPRS(7, r11)
-
-	addi	r2,r10,-THREAD
 	b	transfer_to_syscall	/* jump to handler */
 .endm
 
-- 
2.25.0


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

* [PATCH 4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry
  2021-06-04 14:54 [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Christophe Leroy
  2021-06-04 14:54 ` [PATCH 2/4] powerpc/32: Interchange r1 and r11 in SYSCALL_ENTRY on booke Christophe Leroy
  2021-06-04 14:54 ` [PATCH 3/4] powerpc/32: Reduce code duplication of system call entry Christophe Leroy
@ 2021-06-04 14:54 ` Christophe Leroy
  2021-06-04 17:02   ` Andreas Schwab
  2021-06-26 10:37 ` [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Michael Ellerman
  3 siblings, 1 reply; 7+ messages in thread
From: Christophe Leroy @ 2021-06-04 14:54 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

On booke, SYSCALL_ENTRY macro nests an FTR_SECTION with a

Duplicate the single instruction alternative to avoid nesting.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/kernel/head_booke.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index 10f31146b472..87b806e8eded 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -128,10 +128,10 @@ BEGIN_FTR_SECTION
 	mr	r12, r13
 	lwz	r13, THREAD_NORMSAVE(2)(r10)
 FTR_SECTION_ELSE
-#endif
 	mfcr	r12
-#ifdef CONFIG_KVM_BOOKE_HV
 ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
+#else
+	mfcr	r12
 #endif
 	mfspr	r9, SPRN_SRR1
 	BOOKE_CLEAR_BTB(r11)
-- 
2.25.0


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

* Re: [PATCH 4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry
  2021-06-04 14:54 ` [PATCH 4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry Christophe Leroy
@ 2021-06-04 17:02   ` Andreas Schwab
  2021-06-04 18:30     ` Christophe Leroy
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2021-06-04 17:02 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	linux-kernel, linuxppc-dev

On Jun 04 2021, Christophe Leroy wrote:

> On booke, SYSCALL_ENTRY macro nests an FTR_SECTION with a

That sentence lacks an

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: [PATCH 4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry
  2021-06-04 17:02   ` Andreas Schwab
@ 2021-06-04 18:30     ` Christophe Leroy
  0 siblings, 0 replies; 7+ messages in thread
From: Christophe Leroy @ 2021-06-04 18:30 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	linux-kernel, linuxppc-dev



Le 04/06/2021 à 19:02, Andreas Schwab a écrit :
> On Jun 04 2021, Christophe Leroy wrote:
> 
>> On booke, SYSCALL_ENTRY macro nests an FTR_SECTION with a
> 
> That sentence lacks an
> 


Argh !

It was ..... FTR_SECTION with a
#ifdef CONFIG_KVM_BOOKE_HV.

And git discarded the line starting with a #


Christophe

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

* Re: [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke
  2021-06-04 14:54 [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Christophe Leroy
                   ` (2 preceding siblings ...)
  2021-06-04 14:54 ` [PATCH 4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry Christophe Leroy
@ 2021-06-26 10:37 ` Michael Ellerman
  3 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2021-06-26 10:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman, Paul Mackerras,
	Christophe Leroy
  Cc: linuxppc-dev, linux-kernel

On Fri, 4 Jun 2021 14:54:12 +0000 (UTC), Christophe Leroy wrote:
> To better match booke version of SYSCALL_ENTRY macro, interchange
> r10 and r12 in the non booke version.

Applied to powerpc/next.

[1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke
      https://git.kernel.org/powerpc/c/10e9252f043ecda0dad7cde6ef87db5d10dff2c7
[2/4] powerpc/32: Interchange r1 and r11 in SYSCALL_ENTRY on booke
      https://git.kernel.org/powerpc/c/275dcf24e253f4f5b200bc8cca5eac32a23b08c8
[3/4] powerpc/32: Reduce code duplication of system call entry
      https://git.kernel.org/powerpc/c/4bd9e05ac7b8b1f7d0c28702cb684417501a5e39
[4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry
      https://git.kernel.org/powerpc/c/a27755d57e0b8c1109a6b1485e52a5f9d51bd4eb

cheers

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

end of thread, other threads:[~2021-06-26 10:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 14:54 [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Christophe Leroy
2021-06-04 14:54 ` [PATCH 2/4] powerpc/32: Interchange r1 and r11 in SYSCALL_ENTRY on booke Christophe Leroy
2021-06-04 14:54 ` [PATCH 3/4] powerpc/32: Reduce code duplication of system call entry Christophe Leroy
2021-06-04 14:54 ` [PATCH 4/4] powerpc/32: Avoid #ifdef nested with FTR_SECTION on booke syscall entry Christophe Leroy
2021-06-04 17:02   ` Andreas Schwab
2021-06-04 18:30     ` Christophe Leroy
2021-06-26 10:37 ` [PATCH 1/4] powerpc/32: Interchange r10 and r12 in SYSCALL_ENTRY on non booke Michael Ellerman

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