[PATCH] MSR_RI not cleared early enough in entry.S

Craig Chaney cchaney at us.ibm.com
Tue Sep 28 02:06:42 EST 2004


oops.  Forgot to attach the patch.

Thanks,
Craig

On Mon, Sep 27, 2004 at 11:18:25AM -0400, Craig Chaney wrote:
> Hi,
> 
> This patch fixes a small hole in entry.S.  In the section of code under the
> label syscall_exit_trace_cont, the kernel is reverting to its previous
> context.  The kernel stack pointer is updated, MSR_RI is cleared, and then the
> rest of the context is restored leading up to the rfid instruction.
> 
> An exception between the update of the kernel stack pointer and the clearing
> of MSR_RI can cause a problem.  If r1 has been updated to point to userspace,
> this will trigger an error condition at the top of EXCEPTION_PROLOG_COMMON,
> and we get the "Bad kernel stack pointer" error.
> 
> If I understand the use of MSR_RI correctly, we should delay the update of the
> kernel stack pointer until after the clearing of MSR_RI.
> 
> I'm new to this, so please let me know if I've made any mistakes (not only in
> the patch itself of course, but also in the conventions of submitting a patch).
> Is submitting the patch here sufficient for it to make it upstream?
> 
> Thanks,
> Craig
> 
> Signed-off-by: Craig Chaney <cchaney at us.ibm.com>
> 
> _______________________________________________
> Linuxppc64-dev mailing list
> Linuxppc64-dev at ozlabs.org
> https://ozlabs.org/cgi-bin/mailman/listinfo/linuxppc64-dev
-------------- next part --------------
diff -Naur clean/arch/ppc64/kernel/entry.S edited/arch/ppc64/kernel/entry.S
--- clean/arch/ppc64/kernel/entry.S	2004-09-26 14:24:27.000000000 +0000
+++ edited/arch/ppc64/kernel/entry.S	2004-09-27 14:36:29.221308744 +0000
@@ -185,10 +185,10 @@
 	beq-	1f			/* only restore r13 if */
 	ld	r13,GPR13(r1)		/* returning to usermode */
 1:	ld	r2,GPR2(r1)
-	ld	r1,GPR1(r1)
 	li	r12,MSR_RI
 	andc	r10,r10,r12
 	mtmsrd	r10,1			/* clear MSR.RI */
+	ld	r1,GPR1(r1)
 	mtlr	r4
 	mtcr	r5
 	mtspr	SRR0,r7


More information about the Linuxppc64-dev mailing list