[RFC,1/2] opal: Fix OPAL entry path to resue callers stack.

Submitted by Mahesh Salgaonkar on Feb. 21, 2017, 1:46 a.m.

Details

Message ID 148764157624.19040.12352699972619657394.stgit@jupiter.in.ibm.com
State New
Headers show

Commit Message

Mahesh Salgaonkar Feb. 21, 2017, 1:46 a.m.
From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

OPAL uses its own stack for each opal call that are made from linux. This
makes OPAL non reentrant. This patch fixes that by using caller's stack
instead of switching to its own.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 asm/head.S |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/asm/head.S b/asm/head.S
index d7c2821..7efacb7 100644
--- a/asm/head.S
+++ b/asm/head.S
@@ -36,6 +36,9 @@ 
 #define GET_CPU()						\
 	clrrdi	%r13,%r1,STACK_SHIFT
 
+#define GET_CPU_REG(stack_reg)						\
+	clrrdi	%r13,stack_reg,STACK_SHIFT
+
 #define SAVE_GPR(reg,sp)	std %r##reg,STACK_GPR##reg(sp)
 #define REST_GPR(reg,sp)	ld %r##reg,STACK_GPR##reg(sp)
 
@@ -837,9 +840,8 @@  opal_boot_trampoline:
 	.balign	0x10
 .global opal_entry
 opal_entry:
-	/* Get our per CPU stack */
-	mfspr	%r12,SPR_PIR
-	GET_STACK(%r12,%r12)
+	/* Lets stick to caller's stack. */
+	mr	%r12,%r1
 	stdu	%r12,-STACK_FRAMESIZE(%r12)
 
 	/* Save caller r1, establish new r1 */
@@ -864,7 +866,9 @@  opal_entry:
 	std	%r12,STACK_LR(%r1)
 
 	/* Get the CPU thread */
-	GET_CPU()
+	mfspr	%r12,SPR_PIR
+	GET_STACK(%r12,%r12)
+	GET_CPU_REG(%r12)
 
 	/* Store token in CPU thread */
 	std	%r0,CPUTHREAD_CUR_TOKEN(%r13)