diff mbox series

[v2,1/3] MIPS: Remove noreturn attribute for die()

Message ID 1691985181-28363-2-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State Superseded
Headers show
Series Modify die() for MIPS | expand

Commit Message

Tiezhu Yang Aug. 14, 2023, 3:52 a.m. UTC
If notify_die() returns NOTIFY_STOP, honor the return value from the
handler chain invocation in die() as, through a debugger, the fault
may have been fixed. It makes sense even if ignoring the event will
make the system unstable, by allowing access through a debugger it
has been compromised already anyway. So we can remove the noreturn
attribute for die() to make our port consistent with x86, arm64,
riscv and csky.

Commit 20c0d2d44029 ("[PATCH] i386: pass proper trap numbers to die
chain handlers") may be the earliest of similar changes.

Link: https://lore.kernel.org/all/alpine.DEB.2.21.2308132148500.8596@angie.orcam.me.uk/
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/mips/kernel/traps.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

kernel test robot Aug. 14, 2023, 5:24 a.m. UTC | #1
Hi Tiezhu,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.5-rc6 next-20230809]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tiezhu-Yang/MIPS-Remove-noreturn-attribute-for-die/20230814-115513
base:   linus/master
patch link:    https://lore.kernel.org/r/1691985181-28363-2-git-send-email-yangtiezhu%40loongson.cn
patch subject: [PATCH v2 1/3] MIPS: Remove noreturn attribute for die()
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20230814/202308141322.sZl3fv7u-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230814/202308141322.sZl3fv7u-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308141322.sZl3fv7u-lkp@intel.com/

All warnings (new ones prefixed by >>):

   arch/mips/kernel/traps.c:370:6: warning: no previous prototype for 'show_registers' [-Wmissing-prototypes]
     370 | void show_registers(struct pt_regs *regs)
         |      ^~~~~~~~~~~~~~
   arch/mips/kernel/traps.c:447:17: warning: no previous prototype for 'do_be' [-Wmissing-prototypes]
     447 | asmlinkage void do_be(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:752:17: warning: no previous prototype for 'do_ov' [-Wmissing-prototypes]
     752 | asmlinkage void do_ov(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:874:17: warning: no previous prototype for 'do_fpe' [-Wmissing-prototypes]
     874 | asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1027:17: warning: no previous prototype for 'do_bp' [-Wmissing-prototypes]
    1027 | asmlinkage void do_bp(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1114:17: warning: no previous prototype for 'do_tr' [-Wmissing-prototypes]
    1114 | asmlinkage void do_tr(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1151:17: warning: no previous prototype for 'do_ri' [-Wmissing-prototypes]
    1151 | asmlinkage void do_ri(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1402:17: warning: no previous prototype for 'do_cpu' [-Wmissing-prototypes]
    1402 | asmlinkage void do_cpu(struct pt_regs *regs)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1507:17: warning: no previous prototype for 'do_msa_fpe' [-Wmissing-prototypes]
    1507 | asmlinkage void do_msa_fpe(struct pt_regs *regs, unsigned int msacsr)
         |                 ^~~~~~~~~~
   arch/mips/kernel/traps.c:1527:17: warning: no previous prototype for 'do_msa' [-Wmissing-prototypes]
    1527 | asmlinkage void do_msa(struct pt_regs *regs)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1548:17: warning: no previous prototype for 'do_mdmx' [-Wmissing-prototypes]
    1548 | asmlinkage void do_mdmx(struct pt_regs *regs)
         |                 ^~~~~~~
   arch/mips/kernel/traps.c:1560:17: warning: no previous prototype for 'do_watch' [-Wmissing-prototypes]
    1560 | asmlinkage void do_watch(struct pt_regs *regs)
         |                 ^~~~~~~~
   arch/mips/kernel/traps.c:1587:17: warning: no previous prototype for 'do_mcheck' [-Wmissing-prototypes]
    1587 | asmlinkage void do_mcheck(struct pt_regs *regs)
         |                 ^~~~~~~~~
   arch/mips/kernel/traps.c: In function 'do_mcheck':
   arch/mips/kernel/traps.c:1590:24: warning: variable 'prev_state' set but not used [-Wunused-but-set-variable]
    1590 |         enum ctx_state prev_state;
         |                        ^~~~~~~~~~
   arch/mips/kernel/traps.c: At top level:
   arch/mips/kernel/traps.c:1612:17: warning: no previous prototype for 'do_mt' [-Wmissing-prototypes]
    1612 | asmlinkage void do_mt(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1648:17: warning: no previous prototype for 'do_dsp' [-Wmissing-prototypes]
    1648 | asmlinkage void do_dsp(struct pt_regs *regs)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1656:17: warning: no previous prototype for 'do_reserved' [-Wmissing-prototypes]
    1656 | asmlinkage void do_reserved(struct pt_regs *regs)
         |                 ^~~~~~~~~~~
   arch/mips/kernel/traps.c:1832:17: warning: no previous prototype for 'cache_parity_error' [-Wmissing-prototypes]
    1832 | asmlinkage void cache_parity_error(void)
         |                 ^~~~~~~~~~~~~~~~~~
   arch/mips/kernel/traps.c:1880:17: warning: no previous prototype for 'do_ftlb' [-Wmissing-prototypes]
    1880 | asmlinkage void do_ftlb(void)
         |                 ^~~~~~~
   arch/mips/kernel/traps.c:1909:17: warning: no previous prototype for 'do_gsexc' [-Wmissing-prototypes]
    1909 | asmlinkage void do_gsexc(struct pt_regs *regs, u32 diag1)
         |                 ^~~~~~~~
   arch/mips/kernel/traps.c:1944:6: warning: no previous prototype for 'ejtag_exception_handler' [-Wmissing-prototypes]
    1944 | void ejtag_exception_handler(struct pt_regs *regs)
         |      ^~~~~~~~~~~~~~~~~~~~~~~
   arch/mips/kernel/traps.c:1989:17: warning: no previous prototype for 'nmi_exception_handler' [-Wmissing-prototypes]
    1989 | void __noreturn nmi_exception_handler(struct pt_regs *regs)
         |                 ^~~~~~~~~~~~~~~~~~~~~
   arch/mips/kernel/traps.c: In function 'die':
>> arch/mips/kernel/traps.c:426:1: warning: 'noreturn' function does return
     426 | }
         | ^


vim +/noreturn +426 arch/mips/kernel/traps.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  393  
84d992b55d603d Tiezhu Yang     2023-08-14  394  void die(const char *str, struct pt_regs *regs)
^1da177e4c3f41 Linus Torvalds  2005-04-16  395  {
^1da177e4c3f41 Linus Torvalds  2005-04-16  396  	static int die_counter;
84d992b55d603d Tiezhu Yang     2023-08-14  397  	int ret;
^1da177e4c3f41 Linus Torvalds  2005-04-16  398  
8742cd23471635 Nathan Lynch    2011-09-30  399  	oops_enter();
8742cd23471635 Nathan Lynch    2011-09-30  400  
84d992b55d603d Tiezhu Yang     2023-08-14  401  	ret = notify_die(DIE_OOPS, str, regs, 0,
84d992b55d603d Tiezhu Yang     2023-08-14  402  			 current->thread.trap_nr, SIGSEGV);
5dd11d5d47d248 Jason Wessel    2010-05-20  403  
^1da177e4c3f41 Linus Torvalds  2005-04-16  404  	console_verbose();
4d85f6afa43d36 Wu Zhangjin     2011-07-23  405  	raw_spin_lock_irq(&die_lock);
41c594ab65fc89 Ralf Baechle    2006-04-05  406  	bust_spinlocks(1);
ce384d83d00ee4 Yury Polyanskiy 2010-04-26  407  
178086c86ac973 Ralf Baechle    2005-10-13  408  	printk("%s[#%d]:\n", str, ++die_counter);
^1da177e4c3f41 Linus Torvalds  2005-04-16  409  	show_registers(regs);
373d4d099761cb Rusty Russell   2013-01-21  410  	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
4d85f6afa43d36 Wu Zhangjin     2011-07-23  411  	raw_spin_unlock_irq(&die_lock);
d4fd1989ea142b Maxime Bizon    2006-07-20  412  
8742cd23471635 Nathan Lynch    2011-09-30  413  	oops_exit();
8742cd23471635 Nathan Lynch    2011-09-30  414  
d4fd1989ea142b Maxime Bizon    2006-07-20  415  	if (in_interrupt())
d4fd1989ea142b Maxime Bizon    2006-07-20  416  		panic("Fatal exception in interrupt");
d4fd1989ea142b Maxime Bizon    2006-07-20  417  
99a7a234c89017 Aaro Koskinen   2016-03-09  418  	if (panic_on_oops)
d4fd1989ea142b Maxime Bizon    2006-07-20  419  		panic("Fatal exception");
d4fd1989ea142b Maxime Bizon    2006-07-20  420  
7aa1c8f47e7e79 Ralf Baechle    2012-10-11  421  	if (regs && kexec_should_crash(current))
7aa1c8f47e7e79 Ralf Baechle    2012-10-11  422  		crash_kexec(regs);
7aa1c8f47e7e79 Ralf Baechle    2012-10-11  423  
84d992b55d603d Tiezhu Yang     2023-08-14  424  	if (ret != NOTIFY_STOP)
84d992b55d603d Tiezhu Yang     2023-08-14  425  		make_task_dead(SIGSEGV);
^1da177e4c3f41 Linus Torvalds  2005-04-16 @426  }
^1da177e4c3f41 Linus Torvalds  2005-04-16  427
Tiezhu Yang Aug. 14, 2023, 6:24 a.m. UTC | #2
On 08/14/2023 01:24 PM, kernel test robot wrote:
> Hi Tiezhu,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on linus/master]
> [also build test WARNING on v6.5-rc6 next-20230809]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Tiezhu-Yang/MIPS-Remove-noreturn-attribute-for-die/20230814-115513
> base:   linus/master
> patch link:    https://lore.kernel.org/r/1691985181-28363-2-git-send-email-yangtiezhu%40loongson.cn
> patch subject: [PATCH v2 1/3] MIPS: Remove noreturn attribute for die()
> config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20230814/202308141322.sZl3fv7u-lkp@intel.com/config)
> compiler: mips-linux-gcc (GCC) 12.3.0
> reproduce: (https://download.01.org/0day-ci/archive/20230814/202308141322.sZl3fv7u-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202308141322.sZl3fv7u-lkp@intel.com/
>

...

>    arch/mips/kernel/traps.c: In function 'die':
>>> arch/mips/kernel/traps.c:426:1: warning: 'noreturn' function does return
>      426 | }
>          | ^

Thanks for your report, the follow up patch #2 of this patch series
can silence the above warning.

[PATCH v2 2/3] MIPS: Modify the declaration for die()
https://lore.kernel.org/all/1691985181-28363-3-git-send-email-yangtiezhu@loongson.cn/

Thanks,
Tiezhu
diff mbox series

Patch

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 246c6a6..62d6c4e 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -391,16 +391,15 @@  void show_registers(struct pt_regs *regs)
 
 static DEFINE_RAW_SPINLOCK(die_lock);
 
-void __noreturn die(const char *str, struct pt_regs *regs)
+void die(const char *str, struct pt_regs *regs)
 {
 	static int die_counter;
-	int sig = SIGSEGV;
+	int ret;
 
 	oops_enter();
 
-	if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_nr,
-		       SIGSEGV) == NOTIFY_STOP)
-		sig = 0;
+	ret = notify_die(DIE_OOPS, str, regs, 0,
+			 current->thread.trap_nr, SIGSEGV);
 
 	console_verbose();
 	raw_spin_lock_irq(&die_lock);
@@ -422,7 +421,8 @@  void __noreturn die(const char *str, struct pt_regs *regs)
 	if (regs && kexec_should_crash(current))
 		crash_kexec(regs);
 
-	make_task_dead(sig);
+	if (ret != NOTIFY_STOP)
+		make_task_dead(SIGSEGV);
 }
 
 extern struct exception_table_entry __start___dbe_table[];