[v2,13/21] MIPS: traps: Give more explanations if ebase doesn't belong to KSEG0

Message ID 20231123152639.561231-14-gregory.clement@bootlin.com
State New
Headers
Series Add support for the Mobileye EyeQ5 SoC |

Commit Message

Gregory CLEMENT Nov. 23, 2023, 3:26 p.m. UTC
  Now that we support having the kernel in XPHYS and not only in KSEG0,
the case where ebase doesn't belong to KSEG0 is more likely to
occur. However, in this scenariowe encounter a significant and
intimidating stack dump without any explanation. To address this, we
should eliminate the uninformative stack dump and replace it with a
warning that provides a clear explanation of the issue.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 arch/mips/kernel/traps.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

kernel test robot Nov. 26, 2023, 11:31 a.m. UTC | #1
Hi Gregory,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on lee-mfd/for-mfd-next linus/master v6.7-rc2 next-20231124]
[cannot apply to lee-mfd/for-mfd-fixes]
[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/Gregory-CLEMENT/MIPS-Export-higher-highest-relocation-functions-in-uasm/20231124-002644
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20231123152639.561231-14-gregory.clement%40bootlin.com
patch subject: [PATCH v2 13/21] MIPS: traps: Give more explanations if ebase doesn't belong to KSEG0
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20231126/202311261838.wgZG2yvS-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231126/202311261838.wgZG2yvS-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/202311261838.wgZG2yvS-lkp@intel.com/

All warnings (new ones prefixed by >>):

   arch/mips/kernel/traps.c:371:6: warning: no previous prototype for 'show_registers' [-Wmissing-prototypes]
     371 | void show_registers(struct pt_regs *regs)
         |      ^~~~~~~~~~~~~~
   arch/mips/kernel/traps.c:448:17: warning: no previous prototype for 'do_be' [-Wmissing-prototypes]
     448 | asmlinkage void do_be(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:753:17: warning: no previous prototype for 'do_ov' [-Wmissing-prototypes]
     753 | asmlinkage void do_ov(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:875:17: warning: no previous prototype for 'do_fpe' [-Wmissing-prototypes]
     875 | asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1028:17: warning: no previous prototype for 'do_bp' [-Wmissing-prototypes]
    1028 | asmlinkage void do_bp(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1115:17: warning: no previous prototype for 'do_tr' [-Wmissing-prototypes]
    1115 | asmlinkage void do_tr(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1152:17: warning: no previous prototype for 'do_ri' [-Wmissing-prototypes]
    1152 | asmlinkage void do_ri(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1403:17: warning: no previous prototype for 'do_cpu' [-Wmissing-prototypes]
    1403 | asmlinkage void do_cpu(struct pt_regs *regs)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1508:17: warning: no previous prototype for 'do_msa_fpe' [-Wmissing-prototypes]
    1508 | asmlinkage void do_msa_fpe(struct pt_regs *regs, unsigned int msacsr)
         |                 ^~~~~~~~~~
   arch/mips/kernel/traps.c:1528:17: warning: no previous prototype for 'do_msa' [-Wmissing-prototypes]
    1528 | asmlinkage void do_msa(struct pt_regs *regs)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1549:17: warning: no previous prototype for 'do_mdmx' [-Wmissing-prototypes]
    1549 | asmlinkage void do_mdmx(struct pt_regs *regs)
         |                 ^~~~~~~
   arch/mips/kernel/traps.c:1561:17: warning: no previous prototype for 'do_watch' [-Wmissing-prototypes]
    1561 | asmlinkage void do_watch(struct pt_regs *regs)
         |                 ^~~~~~~~
   arch/mips/kernel/traps.c:1588:17: warning: no previous prototype for 'do_mcheck' [-Wmissing-prototypes]
    1588 | asmlinkage void do_mcheck(struct pt_regs *regs)
         |                 ^~~~~~~~~
   arch/mips/kernel/traps.c: In function 'do_mcheck':
   arch/mips/kernel/traps.c:1591:24: warning: variable 'prev_state' set but not used [-Wunused-but-set-variable]
    1591 |         enum ctx_state prev_state;
         |                        ^~~~~~~~~~
   arch/mips/kernel/traps.c: At top level:
   arch/mips/kernel/traps.c:1613:17: warning: no previous prototype for 'do_mt' [-Wmissing-prototypes]
    1613 | asmlinkage void do_mt(struct pt_regs *regs)
         |                 ^~~~~
   arch/mips/kernel/traps.c:1649:17: warning: no previous prototype for 'do_dsp' [-Wmissing-prototypes]
    1649 | asmlinkage void do_dsp(struct pt_regs *regs)
         |                 ^~~~~~
   arch/mips/kernel/traps.c:1657:17: warning: no previous prototype for 'do_reserved' [-Wmissing-prototypes]
    1657 | asmlinkage void do_reserved(struct pt_regs *regs)
         |                 ^~~~~~~~~~~
   arch/mips/kernel/traps.c:1833:17: warning: no previous prototype for 'cache_parity_error' [-Wmissing-prototypes]
    1833 | asmlinkage void cache_parity_error(void)
         |                 ^~~~~~~~~~~~~~~~~~
   arch/mips/kernel/traps.c:1881:17: warning: no previous prototype for 'do_ftlb' [-Wmissing-prototypes]
    1881 | asmlinkage void do_ftlb(void)
         |                 ^~~~~~~
   arch/mips/kernel/traps.c:1910:17: warning: no previous prototype for 'do_gsexc' [-Wmissing-prototypes]
    1910 | asmlinkage void do_gsexc(struct pt_regs *regs, u32 diag1)
         |                 ^~~~~~~~
   arch/mips/kernel/traps.c:1945:6: warning: no previous prototype for 'ejtag_exception_handler' [-Wmissing-prototypes]
    1945 | void ejtag_exception_handler(struct pt_regs *regs)
         |      ^~~~~~~~~~~~~~~~~~~~~~~
   arch/mips/kernel/traps.c:1990:17: warning: no previous prototype for 'nmi_exception_handler' [-Wmissing-prototypes]
    1990 | void __noreturn nmi_exception_handler(struct pt_regs *regs)
         |                 ^~~~~~~~~~~~~~~~~~~~~
   In file included from include/asm-generic/bug.h:22,
                    from arch/mips/include/asm/bug.h:42,
                    from include/linux/bug.h:5,
                    from arch/mips/kernel/traps.c:16:
   arch/mips/kernel/traps.c: In function 'trap_init':
>> include/linux/kern_levels.h:5:25: warning: format '%llX' expects argument of type 'long long unsigned int', but argument 2 has type 'phys_addr_t' {aka 'unsigned int'} [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/printk.h:427:25: note: in definition of macro 'printk_index_wrap'
     427 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ^~~~
   include/linux/printk.h:508:9: note: in expansion of macro 'printk'
     508 |         printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~
   include/linux/kern_levels.h:12:25: note: in expansion of macro 'KERN_SOH'
      12 | #define KERN_WARNING    KERN_SOH "4"    /* warning conditions */
         |                         ^~~~~~~~
   include/linux/printk.h:508:16: note: in expansion of macro 'KERN_WARNING'
     508 |         printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |                ^~~~~~~~~~~~
   arch/mips/kernel/traps.c:2428:25: note: in expansion of macro 'pr_warn'
    2428 |                         pr_warn("ebase(0x%llX) should better be in KSeg0",
         |                         ^~~~~~~


vim +5 include/linux/kern_levels.h

314ba3520e513a Joe Perches 2012-07-30  4  
04d2c8c83d0e3a Joe Perches 2012-07-30 @5  #define KERN_SOH	"\001"		/* ASCII Start Of Header */
04d2c8c83d0e3a Joe Perches 2012-07-30  6  #define KERN_SOH_ASCII	'\001'
04d2c8c83d0e3a Joe Perches 2012-07-30  7
  

Patch

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 68f1dd54cde1c..3af2aa82b4408 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -2420,10 +2420,13 @@  void __init trap_init(void)
 		 * EVA is special though as it allows segments to be rearranged
 		 * and to become uncached during cache error handling.
 		 */
-		if (!IS_ENABLED(CONFIG_EVA) && !WARN_ON(ebase_pa >= 0x20000000))
+		if (!IS_ENABLED(CONFIG_EVA) && ebase_pa < 0x20000000)
 			ebase = CKSEG0ADDR(ebase_pa);
 		else
 			ebase = (unsigned long)phys_to_virt(ebase_pa);
+		if (ebase_pa >= 0x20000000)
+			pr_warn("ebase(0x%llX) should better be in KSeg0",
+				ebase_pa);
 	}
 
 	if (cpu_has_mmips) {