Subject: Re: ret_from_sys_call and signal

From: Ralf Baechle <[email-masked]>
Date: Wed, 5 Sep 2001 22:03:00 +0200

On Fri, Aug 31, 2001 at 03:23:10PM +0900, Atsushi Nemoto wrote:

> After merging with 2.4.6 kernel, ret_from_sys_call (and
> o32_ret_from_sys_call) does not check whether it returns to kernel
> mode or not.
> 
> syscall may happen in kernel mode, so we should check KU_USER bits (as
>  done in past code).  Is this right?
> 
> At least, currently DO_FAULT() jumps to ret_from_sys_call and it may
> cause problems.  If page fault happened in kernel code when any
> signals pending, do_signal() is called before returning to kernel and
> it fails to setup sigcontext.

The changes in entry.S and scall_o32.S were correct; they match the
changing in the i386 code.  The idea is to avoid the usermode check if
possible.  I just lost the matching changes to other files.  Untested
patch below.  Tell me if it helps.

  Ralf

Index: arch/mips64/kernel/r4k_tlb_glue.S
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips64/kernel/r4k_tlb_glue.S,v
retrieving revision 1.10
diff -u -r1.10 r4k_tlb_glue.S
--- arch/mips64/kernel/r4k_tlb_glue.S 2001/09/05 19:13:24 1.10  
+++ arch/mips64/kernel/r4k_tlb_glue.S 2001/09/05 19:39:18   
@@ -29,7 +29,7 @@
 	sd	a2, PT_BVADDR(sp)
 	move	a0, sp
 	jal	do_page_fault
-	j	ret_from_sys_call
+	j	ret_from_exception
 	END(__\name)
 	.endm
 
Index: arch/mips/kernel/r2300_misc.S
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips/kernel/r2300_misc.S,v
retrieving revision 1.9
diff -u -r1.9 r2300_misc.S
--- arch/mips/kernel/r2300_misc.S 2000/03/07 15:45:28 1.9  
+++ arch/mips/kernel/r2300_misc.S 2001/09/05 19:39:18   
@@ -1,4 +1,4 @@
-/* $Id: r2300_misc.S,v 1.8 1999/12/08 22:05:10 harald Exp $
+/*
  * misc.S: Misc. exception handling code for R3000/R2000.
  *
  * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse
@@ -9,6 +9,8 @@
  * Further modifications to make this work:
  * Copyright (c) 1998 Harald Koerfgen
  * Copyright (c) 1998, 1999 Gleb Raiko & Vladimir Roganov
+ * Copyright (c) 2001 Ralf Baechle
+ * Copyright (c) 2001 MIPS Technologies, Inc.
  */
 #include <asm/asm.h>
 #include <asm/current.h>
@@ -68,7 +70,7 @@
 	move	a0, sp; \
 	jal	do_page_fault; \
 	 li	a1, write; \
-	j	ret_from_sys_call; \
+	j	ret_from_exception; \
 	 nop; \
 	.set	noat; \
 	.set	nomacro;
Index: arch/mips/kernel/r4k_misc.S
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips/kernel/r4k_misc.S,v
retrieving revision 1.11
diff -u -r1.11 r4k_misc.S
--- arch/mips/kernel/r4k_misc.S 2001/03/28 01:35:12 1.11  
+++ arch/mips/kernel/r4k_misc.S 2001/09/05 19:39:18   
@@ -1,5 +1,4 @@
-/* $Id: r4k_misc.S,v 1.8 1999/10/09 00:00:58 ralf Exp $
- *
+/*
  * r4k_misc.S: Misc. exception handling code for r4k.
  *
  * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse
@@ -86,7 +85,7 @@
 	move	a0, sp; \
 	jal	do_page_fault; \
 	 li	a1, write; \
-	j	ret_from_sys_call; \
+	j	ret_from_exception; \
 	 nop; \
 	.set	noat;

---

From: Atsushi Nemoto <[email-masked]>
Date: Thu, 06 Sep 2001 19:16:39 +0900 (JST)

>>>>> On Wed, 5 Sep 2001 22:03:00 +0200, Ralf Baechle <[email-masked]> said:
ralf> The changes in entry.S and scall_o32.S were correct; they match the
ralf> changing in the i386 code.  The idea is to avoid the usermode check if
ralf> possible.  I just lost the matching changes to other files.  Untested
ralf> patch below.  Tell me if it helps.

I tried the patch with r4k CPU.  It works fine for me.  Thanks.

---
Atsushi Nemoto