powerpc/mce: Fix mce handler and add selftest
cover powerpc/mce: Fix mce handler and add selftest
This patch series fixes mce handling for pseries, provides debugfs interface for mce injection and adds selftest to test mce handling on pseries/powernv machines running in hash mmu mode. debugfs interface and sleftest are added only for slb multihit injection, We can add other tests in future if possible.
Ganesh Goudar (3):
powerpc/mce: remove nmi_enter/exit from real mode handler powerpc/mce: Add debugfs interface to inject MCE selftest/powerpc: Add slb multihit selftest
arch/powerpc/Kconfig.debug | 9 ++ arch/powerpc/kernel/mce.c | 7 +- arch/powerpc/sysdev/Makefile | 2 + arch/powerpc/sysdev/mce_error_inject.c | 149 ++++++++++++++++++ tools/testing/selftests/powerpc/Makefile | 3 +- tools/testing/selftests/powerpc/mces/Makefile | 6 + .../selftests/powerpc/mces/slb_multihit.sh | 9 ++ 7 files changed, 183 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/sysdev/mce_error_inject.c create mode 100644 tools/testing/selftests/powerpc/mces/Makefile create mode 100755 tools/testing/selftests/powerpc/mces/slb_multihit.sh
Signature · 1 line
2.26.2
PATCH 1/3 powerpc/mce: remove nmi_enter/exit from real mode handler
Use of nmi_enter/exit in real mode handler causes the kernel to panic and reboot on injecting slb mutihit on pseries machine running in hash mmu mode, As these calls try to accesses memory outside RMO region in real mode handler where translation is disabled.
Add check to not to use these calls on pseries machine running in hash mmu mode.
--- arch/powerpc/kernel/mce.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/powerpc/kernel/mce.c +6 -1
@@ -591,10 +591,15 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info);long notrace machine_check_early (struct pt_regs *regs) {long handled =0 ; -bool nested =in_nmi (); +bool nested; +bool is_pseries_hpt_guest;u8 ftrace_enabled =this_cpu_get_ftrace_enabled ();this_cpu_set_ftrace_enabled (0 ); + is_pseries_hpt_guest =machine_is (pseries) && +mmu_has_feature (MMU_FTR_HPTE_TABLE ); +/* Do not use nmi_enter/exit for pseries hpte guest */ + nested = is_pseries_hpt_guest ? true :in_nmi ();if (!nested)nmi_enter ();
Signature · 1 line
2.26.2
Re: [PATCH 1/3] powerpc/mce: remove nmi_enter/exit from real mode handler
Hello,
Quoted 22 lines · Ganesh Goudar
Use of nmi_enter/exit in real mode handler causes the kernel to panic and reboot on injecting slb mutihit on pseries machine running in hash mmu mode, As these calls try to accesses memory outside RMO region in real mode handler where translation is disabled.
Add check to not to use these calls on pseries machine running in hash mmu mode.
Fixes 116ac378bb3f ("powerpc/64s: machine check interrupt update NMI accounting")Signed-off-by Ganesh Goudar <[email protected]>--- arch/powerpc/kernel/mce.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/powerpc/kernel/mce.c +0
-0@@ -591,10 +591,15 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info);long notrace machine_check_early (struct pt_regs *regs) {long handled =0 ;
arch/powerpc/kernel/mce.c EXPORT_SYMBOL_GPL(machine_check_print_event_info); · line 602
Quoted 10 lines
arch/powerpc/kernel/mce.c +6
-1-bool nested =in_nmi (); +bool nested; +bool is_pseries_hpt_guest;u8 ftrace_enabled =this_cpu_get_ftrace_enabled ();this_cpu_set_ftrace_enabled (0 ); + is_pseries_hpt_guest =machine_is (pseries) && +mmu_has_feature (MMU_FTR_HPTE_TABLE ); +/* Do not use nmi_enter/exit for pseries hpte guest */ + nested = is_pseries_hpt_guest ? true :in_nmi ();
As pointed out already in another comment nesting is supported natively since 69ea03b56ed2c7189ccd0b5910ad39f3cad1df21. You can simply do nmi_enter and nmi_exit unconditionally - or only based on is_pseries_hpt_guest.
The other question is what is the value of calling nmi_enter here at all. It crashes in one case, we simply skip it for that case, and we are good. Maybe we could skip it altogether?
Thanks
Michal
Re: [PATCH 1/3] powerpc/mce: remove nmi_enter/exit from real mode handler
Quoted 30 lines · Michal Suchánek
Hello,
Quoted 27 lines · Ganesh Goudar
Use of nmi_enter/exit in real mode handler causes the kernel to panic and reboot on injecting slb mutihit on pseries machine running in hash mmu mode, As these calls try to accesses memory outside RMO region in real mode handler where translation is disabled.
Add check to not to use these calls on pseries machine running in hash mmu mode.
Fixes 116ac378bb3f ("powerpc/64s: machine check interrupt update NMI accounting")Signed-off-by Ganesh Goudar <[email protected]>--- arch/powerpc/kernel/mce.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/powerpc/kernel/mce.c +2
-1@@ -591,10 +591,15 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info);long notrace machine_check_early (struct pt_regs *regs) {long handled =0 ; -bool nested =in_nmi (); +bool nested; +bool is_pseries_hpt_guest;u8 ftrace_enabled =this_cpu_get_ftrace_enabled ();
Quoted 9 lines
arch/powerpc/kernel/mce.c EXPORT_SYMBOL_GPL(machine_check_print_event_info); · line 602
Quoted 5 lines
arch/powerpc/kernel/mce.c +4
-0this_cpu_set_ftrace_enabled (0 ); + is_pseries_hpt_guest =machine_is (pseries) && +mmu_has_feature (MMU_FTR_HPTE_TABLE ); +/* Do not use nmi_enter/exit for pseries hpte guest */ + nested = is_pseries_hpt_guest ? true :in_nmi ();As pointed out already in another comment nesting is supported natively since
69ea03b56ed2c7189ccd0b5910ad39f3cad1df21. You can simply donmi_enterandnmi_exitunconditionally - or only based onis_pseries_hpt_guest.
ok
Quoted 3 lines
The other question is what is the value of calling
nmi_enterhere at all. It crashes in one case, we simply skip it for that case, and we are good. Maybe we could skip it altogether?
Not sure why nmi_enter/exit is needed here, Again, Nick may have a reason.
Quoted 3 lines
Thanks
Michal
PATCH 2/3 powerpc/mce: Add debugfs interface to inject MCE
In reply to Ganesh GoudarTo test machine check handling, add debugfs interface to inject slb multihit errors.
To inject slb multihit:
#echo 1 > /sys/kernel/debug/powerpc/mce_error_inject/inject_slb_multihit
--- arch/powerpc/Kconfig.debug | 9 ++ arch/powerpc/sysdev/Makefile | 2 + arch/powerpc/sysdev/mce_error_inject.c | 148 +++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 arch/powerpc/sysdev/mce_error_inject.c
arch/powerpc/Kconfig.debug +9 -0
@@ -398,3 +398,12 @@ config KASAN_SHADOW_OFFSET hex depends on KASAN default 0xe0000000 + +config MCE_ERROR_INJECT + bool "Enable MCE error injection through debugfs" + depends on DEBUG_FS + default y + help + This option creates an mce_error_inject directory in the + powerpc debugfs directory that allows limited injection of + Machine Check Errors (MCEs).
arch/powerpc/sysdev/Makefile +2 -0
@@ -52,3 +52,5 @@ obj-$(CONFIG_PPC_XICS) += xics/ obj-$(CONFIG_PPC_XIVE) += xive/ obj-$(CONFIG_GE_FPGA) += ge/ + +obj-$(CONFIG_MCE_ERROR_INJECT) += mce_error_inject.o
arch/powerpc/sysdev/mce_error_inject.c new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
2.26.2
kernel test robot
build botRe: [PATCH 2/3] powerpc/mce: Add debugfs interface to inject MCE
Thank you for the patch! Yet something to improve:
Hi Ganesh,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.9-rc5 next-20200916]
[cannot apply to scottwood/next mpe/next]
[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]
url: https://github.com/0day-ci/linux/commits/Ganesh-Goudar/powerpc-mce-Fix-mce-handler-and-add-selftest/20200917-092355 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-randconfig-r021-20200917 (attached as .config) compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
arch/powerpc/sysdev/mce_error_inject.c: In function 'get_slb_index':
>> arch/powerpc/sysdev/mce_error_inject.c:17:10: error: implicit declaration of function 'get_paca' [-Werror=implicit-function-declaration]
17 | index = get_paca()->stab_rr;
| ^~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:17:20: error: invalid type argument of '->' (have 'int')
17 | index = get_paca()->stab_rr;
| ^~
>> arch/powerpc/sysdev/mce_error_inject.c:22:15: error: 'mmu_slb_size' undeclared (first use in this function)
22 | if (index < (mmu_slb_size - 1))
| ^~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:22:15: note: each undeclared identifier is reported only once for each function it appears in
>> arch/powerpc/sysdev/mce_error_inject.c:25:11: error: 'SLB_NUM_BOLTED' undeclared (first use in this function)
25 | index = SLB_NUM_BOLTED;
| ^~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:26:12: error: invalid type argument of '->' (have 'int')
26 | get_paca()->stab_rr = index;
| ^~
arch/powerpc/sysdev/mce_error_inject.c: In function 'mk_esid_data':
>> arch/powerpc/sysdev/mce_error_inject.c:31:15: error: 'MMU_SEGSIZE_256M' undeclared (first use in this function); did you mean 'MMU_PAGE_256M'?
31 | (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T)
| ^~~~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:36:15: note: in expansion of macro 'slb_esid_mask'
36 | return (ea & slb_esid_mask(ssize)) | SLB_ESID_V | slot;
| ^~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:31:35: error: 'ESID_MASK' undeclared (first use in this function); did you mean 'NMI_MASK'?
31 | (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T)
| ^~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:36:15: note: in expansion of macro 'slb_esid_mask'
36 | return (ea & slb_esid_mask(ssize)) | SLB_ESID_V | slot;
| ^~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:31:47: error: 'ESID_MASK_1T' undeclared (first use in this function)
31 | (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T)
| ^~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:36:15: note: in expansion of macro 'slb_esid_mask'
36 | return (ea & slb_esid_mask(ssize)) | SLB_ESID_V | slot;
| ^~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:36:39: error: 'SLB_ESID_V' undeclared (first use in this function)
36 | return (ea & slb_esid_mask(ssize)) | SLB_ESID_V | slot;
| ^~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c: In function 'mk_vsid_data':
>> arch/powerpc/sysdev/mce_error_inject.c:45:10: error: implicit declaration of function 'get_kernel_vsid' [-Werror=implicit-function-declaration]
45 | return (get_kernel_vsid(ea, ssize) << slb_vsid_shift(ssize)) | flags |
| ^~~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:40:14: error: 'MMU_SEGSIZE_256M' undeclared (first use in this function); did you mean 'MMU_PAGE_256M'?
40 | ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T)
| ^~~~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:45:40: note: in expansion of macro 'slb_vsid_shift'
45 | return (get_kernel_vsid(ea, ssize) << slb_vsid_shift(ssize)) | flags |
| ^~~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:40:33: error: 'SLB_VSID_SHIFT' undeclared (first use in this function)
40 | ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T)
| ^~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:45:40: note: in expansion of macro 'slb_vsid_shift'
45 | return (get_kernel_vsid(ea, ssize) << slb_vsid_shift(ssize)) | flags |
| ^~~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:40:50: error: 'SLB_VSID_SHIFT_1T' undeclared (first use in this function)
40 | ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T)
| ^~~~~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c:45:40: note: in expansion of macro 'slb_vsid_shift'
45 | return (get_kernel_vsid(ea, ssize) << slb_vsid_shift(ssize)) | flags |
| ^~~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:46:28: error: 'SLB_VSID_SSIZE_SHIFT' undeclared (first use in this function)
46 | ((unsigned long)ssize << SLB_VSID_SSIZE_SHIFT);
| ^~~~~~~~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c: In function 'insert_slb_entry':
>> arch/powerpc/sysdev/mce_error_inject.c:54:10: error: 'SLB_VSID_KERNEL' undeclared (first use in this function)
54 | flags = SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K].sllp;
| ^~~~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:54:28: error: 'mmu_psize_defs' undeclared (first use in this function)
54 | flags = SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K].sllp;
| ^~~~~~~~~~~~~~
>> arch/powerpc/sysdev/mce_error_inject.c:58:7: error: assignment to 'struct paca_struct *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
58 | paca = get_paca();
| ^
>> arch/powerpc/sysdev/mce_error_inject.c:52:22: error: variable 'paca' set but not used [-Werror=unused-but-set-variable]
52 | struct paca_struct *paca;
| ^~~~
arch/powerpc/sysdev/mce_error_inject.c: In function 'inject_vmalloc_slb_multihit':
>> arch/powerpc/sysdev/mce_error_inject.c:83:22: error: 'MMU_SEGSIZE_1T' undeclared (first use in this function)
83 | insert_slb_entry(p, MMU_SEGSIZE_1T);
| ^~~~~~~~~~~~~~
arch/powerpc/sysdev/mce_error_inject.c: In function 'inject_kmalloc_slb_multihit':
arch/powerpc/sysdev/mce_error_inject.c:95:22: error: 'MMU_SEGSIZE_1T' undeclared (first use in this function)
95 | insert_slb_entry(p, MMU_SEGSIZE_1T);
| ^~~~~~~~~~~~~~cc1: all warnings being treated as errors
# https://github.com/0day-ci/linux/commit/4ab1196e8e542fdf0e7cda8638dfb0e5771fd98e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Ganesh-Goudar/powerpc-mce-Fix-mce-handler-and-add-selftest/20200917-092355 git checkout 4ab1196e8e542fdf0e7cda8638dfb0e5771fd98e
vim +/get_paca +17 arch/powerpc/sysdev/mce_error_inject.c
12
13 static inline unsigned long get_slb_index(void)
14 {
15 unsigned long index;
16
> 17 index = get_paca()->stab_rr;
18
19 /*
20 * simple round-robin replacement of slb starting at SLB_NUM_BOLTED.
21 */
> 22 if (index < (mmu_slb_size - 1))
23 index++;
24 else
> 25 index = SLB_NUM_BOLTED;
26 get_paca()->stab_rr = index;
27 return index;
28 }
29
30 #define slb_esid_mask(ssize) \
> 31 (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T)
32
33 static inline unsigned long mk_esid_data(unsigned long ea, int ssize,
34 unsigned long slot)
35 {
> 36 return (ea & slb_esid_mask(ssize)) | SLB_ESID_V | slot;
37 }
38
39 #define slb_vsid_shift(ssize) \
> 40 ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T)
41
42 static inline unsigned long mk_vsid_data(unsigned long ea, int ssize,
43 unsigned long flags)
44 {
> 45 return (get_kernel_vsid(ea, ssize) << slb_vsid_shift(ssize)) | flags |
> 46 ((unsigned long)ssize << SLB_VSID_SSIZE_SHIFT);
47 }
48
49 static void insert_slb_entry(char *p, int ssize)
50 {
51 unsigned long flags, entry;
> 52 struct paca_struct *paca;
53
> 54 flags = SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K].sllp;
55
56 preempt_disable();
57
> 58 paca = get_paca();
59
60 entry = get_slb_index();
61 asm volatile("slbmte %0,%1" :
62 : "r" (mk_vsid_data((unsigned long)p, ssize, flags)),
63 "r" (mk_esid_data((unsigned long)p, ssize, entry))
64 : "memory");
65
66 entry = get_slb_index();
67 asm volatile("slbmte %0,%1" :
68 : "r" (mk_vsid_data((unsigned long)p, ssize, flags)),
69 "r" (mk_esid_data((unsigned long)p, ssize, entry))
70 : "memory");
71 preempt_enable();
72 p[0] = '!';
73 }
74
75 static void inject_vmalloc_slb_multihit(void)
76 {
77 char *p;
78
79 p = vmalloc(2048);
80 if (!p)
81 return;
82
> 83 insert_slb_entry(p, MMU_SEGSIZE_1T);
84 vfree(p);
85 }
86 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH 2/3] powerpc/mce: Add debugfs interface to inject MCE
In reply to Ganesh GoudarThank you for the patch! Perhaps something to improve:
Hi Ganesh,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on powerpc/next]
[also build test WARNING on v5.9-rc5 next-20200916]
[cannot apply to scottwood/next mpe/next]
[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]
url: https://github.com/0day-ci/linux/commits/Ganesh-Goudar/powerpc-mce-Fix-mce-handler-and-add-selftest/20200917-092355 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-allyesconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
arch/powerpc/sysdev/mce_error_inject.c: In function 'insert_slb_entry':
>> arch/powerpc/sysdev/mce_error_inject.c:52:22: warning: variable 'paca' set but not used [-Wunused-but-set-variable]
52 | struct paca_struct *paca;
| ^~~~# https://github.com/0day-ci/linux/commit/4ab1196e8e542fdf0e7cda8638dfb0e5771fd98e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Ganesh-Goudar/powerpc-mce-Fix-mce-handler-and-add-selftest/20200917-092355 git checkout 4ab1196e8e542fdf0e7cda8638dfb0e5771fd98e
vim +/paca +52 arch/powerpc/sysdev/mce_error_inject.c
48
49 static void insert_slb_entry(char *p, int ssize)
50 {
51 unsigned long flags, entry;
> 52 struct paca_struct *paca;
53
54 flags = SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K].sllp;
55
56 preempt_disable();
57
58 paca = get_paca();
59
60 entry = get_slb_index();
61 asm volatile("slbmte %0,%1" :
62 : "r" (mk_vsid_data((unsigned long)p, ssize, flags)),
63 "r" (mk_esid_data((unsigned long)p, ssize, entry))
64 : "memory");
65
66 entry = get_slb_index();
67 asm volatile("slbmte %0,%1" :
68 : "r" (mk_vsid_data((unsigned long)p, ssize, flags)),
69 "r" (mk_esid_data((unsigned long)p, ssize, entry))
70 : "memory");
71 preempt_enable();
72 p[0] = '!';
73 }
74 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 2/3] powerpc/mce: Add debugfs interface to inject MCE
In reply to Ganesh GoudarHello,
Quoted 96 lines · Ganesh Goudar
To test machine check handling, add debugfs interface to inject slb multihit errors.
To inject slb multihit:
#echo 1 >/sys/kernel/debug/powerpc/mce_error_inject/inject_slb_multihitSigned-off-by Ganesh Goudar <[email protected]>Signed-off-by Mahesh Salgaonkar <[email protected]>--- arch/powerpc/Kconfig.debug | 9 ++ arch/powerpc/sysdev/Makefile | 2 + arch/powerpc/sysdev/mce_error_inject.c | 148 +++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 arch/powerpc/sysdev/mce_error_inject.carch/powerpc/Kconfig.debug +9
-0@@ -398,3 +398,12 @@ config KASAN_SHADOW_OFFSET hex depends on KASAN default 0xe0000000 + +config MCE_ERROR_INJECT + bool "Enable MCE error injection through debugfs" + depends on DEBUG_FS + default y + help + This option creates an mce_error_inject directory in the + powerpc debugfs directory that allows limited injection of + Machine Check Errors (MCEs).arch/powerpc/sysdev/Makefile +2
-0@@ -52,3 +52,5 @@ obj-$(CONFIG_PPC_XICS) += xics/ obj-$(CONFIG_PPC_XIVE) += xive/ obj-$(CONFIG_GE_FPGA) += ge/ + +obj-$(CONFIG_MCE_ERROR_INJECT) += mce_error_inject.oarch/powerpc/sysdev/mce_error_inject.c new file +48
-0@@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Machine Check Exception injection code +*/ + +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/vmalloc.h> +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <asm/debugfs.h> + +static inline unsigned long get_slb_index (void ) +{ +unsigned long index; + + index =get_paca ()->stab_rr; + +/* +* simple round-robin replacement of slb starting at SLB_NUM_BOLTED. +*/ +if (index < (mmu_slb_size -1 )) + index++; +else + index =SLB_NUM_BOLTED ; +get_paca ()->stab_rr = index; +return index; +} + +#define slb_esid_mask (ssize) \ + (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T) + +static inline unsigned long mk_esid_data (unsigned long ea,int ssize, +unsigned long slot) +{ +return (ea &slb_esid_mask (ssize)) |SLB_ESID_V | slot; +} + +#define slb_vsid_shift (ssize) \ + ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T) + +static inline unsigned long mk_vsid_data (unsigned long ea,int ssize, +unsigned long flags) +{ +return (get_kernel_vsid (ea, ssize) <<slb_vsid_shift (ssize)) | flags | + ((unsigned long )ssize <<SLB_VSID_SSIZE_SHIFT ); +} +
arch/powerpc/sysdev/mce_error_inject.c line 58
Quoted 10 lines
arch/powerpc/sysdev/mce_error_inject.c new file +10
-0+static void insert_slb_entry (char *p,int ssize) +{ +unsigned long flags, entry; +struct paca_struct *paca; + + flags =SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K ].sllp; + +preempt_disable (); + + paca =get_paca ();
This seems unused?
Quoted 45 lines
arch/powerpc/sysdev/mce_error_inject.c new file +45
-0+ + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); + + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); +preempt_enable (); + p[0 ] ='!' ; +} + +static void inject_vmalloc_slb_multihit (void ) +{ +char *p; + + p =vmalloc (2048 ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +vfree (p); +} + +static void inject_kmalloc_slb_multihit (void ) +{ +char *p; + + p =kmalloc (2048 ,GFP_KERNEL ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +kfree (p); +} + +static ssize_t inject_slb_multihit (const char __user *u_buf,size_t count) +{ +char buf[32 ]; +size_t buf_size; +
arch/powerpc/sysdev/mce_error_inject.c line 113
Quoted 10 lines
arch/powerpc/sysdev/mce_error_inject.c new file +10
-0+ buf_size =min (count, (sizeof (buf) -1 )); +if (copy_from_user (buf, u_buf, buf_size)) +return -EFAULT ; + buf[buf_size] ='\0' ; + +if (buf[0 ] !='1' ) +return -EINVAL ; + +inject_vmalloc_slb_multihit (); +inject_kmalloc_slb_multihit ();
This is missing the test of multihit in paca which is for some reason special.
Thanks
Michal
Quoted 38 lines
arch/powerpc/sysdev/mce_error_inject.c new file +35
-0+return count; +} + +static ssize_t inject_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +static ssize_t (*func)(const char __user *,size_t ); + + func = file->f_inode->i_private; +return func (buf, count); +} + +static const struct file_operations inject_fops = { + .write = inject_write, + .llseek = default_llseek, +}; + +static int mce_error_inject_setup (void ) +{ +struct dentry *mce_error_inject_dir; + + mce_error_inject_dir =debugfs_create_dir ("mce_error_inject" , + powerpc_debugfs_root); + +if (mmu_has_feature (MMU_FTR_HPTE_TABLE )) { + (void )debugfs_create_file ("inject_slb_multihit" ,0200 , + mce_error_inject_dir, + &inject_slb_multihit, + &inject_fops); + } + +return 0 ; +} + +device_initcall (mce_error_inject_setup);Signature · 1 line
2.26.2
Re: [PATCH 2/3] powerpc/mce: Add debugfs interface to inject MCE
Quoted 102 lines · Michal Suchánek
Hello,
Quoted 99 lines · Ganesh Goudar
To test machine check handling, add debugfs interface to inject slb multihit errors.
To inject slb multihit:
#echo 1 >/sys/kernel/debug/powerpc/mce_error_inject/inject_slb_multihitSigned-off-by Ganesh Goudar <[email protected]>Signed-off-by Mahesh Salgaonkar <[email protected]>--- arch/powerpc/Kconfig.debug | 9 ++ arch/powerpc/sysdev/Makefile | 2 + arch/powerpc/sysdev/mce_error_inject.c | 148 +++++++++++++++++++++++++ 3 files changed, 159 insertions(+)create mode 100644
arch/powerpc/sysdev/mce_error_inject.carch/powerpc/Kconfig.debug +9
-0@@ -398,3 +398,12 @@ config KASAN_SHADOW_OFFSET hex depends on KASAN default 0xe0000000 + +config MCE_ERROR_INJECT + bool "Enable MCE error injection through debugfs" + depends on DEBUG_FS + default y + help + This option creates an mce_error_inject directory in the + powerpc debugfs directory that allows limited injection of + Machine Check Errors (MCEs).arch/powerpc/sysdev/Makefile +2
-0@@ -52,3 +52,5 @@ obj-$(CONFIG_PPC_XICS) += xics/ obj-$(CONFIG_PPC_XIVE) += xive/ obj-$(CONFIG_GE_FPGA) += ge/ + +obj-$(CONFIG_MCE_ERROR_INJECT) += mce_error_inject.oarch/powerpc/sysdev/mce_error_inject.c new file +51
-0@@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Machine Check Exception injection code +*/ + +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/vmalloc.h> +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <asm/debugfs.h> + +static inline unsigned long get_slb_index (void ) +{ +unsigned long index; + + index =get_paca ()->stab_rr; + +/* +* simple round-robin replacement of slb starting at SLB_NUM_BOLTED. +*/ +if (index < (mmu_slb_size -1 )) + index++; +else + index =SLB_NUM_BOLTED ; +get_paca ()->stab_rr = index; +return index; +} + +#define slb_esid_mask (ssize) \ + (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T) + +static inline unsigned long mk_esid_data (unsigned long ea,int ssize, +unsigned long slot) +{ +return (ea &slb_esid_mask (ssize)) |SLB_ESID_V | slot; +} + +#define slb_vsid_shift (ssize) \ + ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T) + +static inline unsigned long mk_vsid_data (unsigned long ea,int ssize, +unsigned long flags) +{ +return (get_kernel_vsid (ea, ssize) <<slb_vsid_shift (ssize)) | flags | + ((unsigned long )ssize <<SLB_VSID_SSIZE_SHIFT ); +} + +static void insert_slb_entry (char *p,int ssize) +{ +unsigned long flags, entry;
Quoted 8 lines
arch/powerpc/sysdev/mce_error_inject.c line 58
Quoted 7 lines
arch/powerpc/sysdev/mce_error_inject.c new file +7
-0+struct paca_struct *paca; + + flags =SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K ].sllp; + +preempt_disable (); + + paca =get_paca ();This seems unused?
Thanks, ill remove it.
Quoted 49 lines
Quoted 49 lines
arch/powerpc/sysdev/mce_error_inject.c new file +49
-0+ + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); + + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); +preempt_enable (); + p[0 ] ='!' ; +} + +static void inject_vmalloc_slb_multihit (void ) +{ +char *p; + + p =vmalloc (2048 ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +vfree (p); +} + +static void inject_kmalloc_slb_multihit (void ) +{ +char *p; + + p =kmalloc (2048 ,GFP_KERNEL ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +kfree (p); +} + +static ssize_t inject_slb_multihit (const char __user *u_buf,size_t count) +{ +char buf[32 ]; +size_t buf_size; + + buf_size =min (count, (sizeof (buf) -1 )); +if (copy_from_user (buf, u_buf, buf_size)) +return -EFAULT ; + buf[buf_size] ='\0' ;
Quoted 8 lines
arch/powerpc/sysdev/mce_error_inject.c line 113
Quoted 6 lines
arch/powerpc/sysdev/mce_error_inject.c new file +6
-0+ +if (buf[0 ] !='1' ) +return -EINVAL ; + +inject_vmalloc_slb_multihit (); +inject_kmalloc_slb_multihit ();This is missing the test of multihit in paca which is for some reason special.
I will add it, Thanks
Quoted 41 lines
Thanks
Michal
Quoted 38 lines
arch/powerpc/sysdev/mce_error_inject.c new file +35
-0+return count; +} + +static ssize_t inject_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +static ssize_t (*func)(const char __user *,size_t ); + + func = file->f_inode->i_private; +return func (buf, count); +} + +static const struct file_operations inject_fops = { + .write = inject_write, + .llseek = default_llseek, +}; + +static int mce_error_inject_setup (void ) +{ +struct dentry *mce_error_inject_dir; + + mce_error_inject_dir =debugfs_create_dir ("mce_error_inject" , + powerpc_debugfs_root); + +if (mmu_has_feature (MMU_FTR_HPTE_TABLE )) { + (void )debugfs_create_file ("inject_slb_multihit" ,0200 , + mce_error_inject_dir, + &inject_slb_multihit, + &inject_fops); + } + +return 0 ; +} + +device_initcall (mce_error_inject_setup);Signature · 1 line
2.26.2
Michael Ellerman
reviewerRe: [PATCH 2/3] powerpc/mce: Add debugfs interface to inject MCE
In reply to Ganesh GoudarHi Ganesh,
Quoted 5 lines · Ganesh Goudar
To test machine check handling, add debugfs interface to inject slb multihit errors.
To inject slb multihit:
#echo 1 >/sys/kernel/debug/powerpc/mce_error_inject/inject_slb_multihit
Rather than creating a new ad-hoc way to trigger this, can you please integrate it into drivers/misc/lkdtm.
There's enough code here that I think you should create drivers/misc/lkdtm/powerpc.c and put the code in there. Then add an LKDTM entry point for this, maybe called PPC_SLB_MULTIHIT.
Please Cc Kees when you repost.
cheers
Quoted 189 lines
arch/powerpc/Kconfig.debug | 9 ++ arch/powerpc/sysdev/Makefile | 2 + arch/powerpc/sysdev/mce_error_inject.c | 148 +++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 arch/powerpc/sysdev/mce_error_inject.carch/powerpc/Kconfig.debug +9
-0@@ -398,3 +398,12 @@ config KASAN_SHADOW_OFFSET hex depends on KASAN default 0xe0000000 + +config MCE_ERROR_INJECT + bool "Enable MCE error injection through debugfs" + depends on DEBUG_FS + default y + help + This option creates an mce_error_inject directory in the + powerpc debugfs directory that allows limited injection of + Machine Check Errors (MCEs).arch/powerpc/sysdev/Makefile +2
-0@@ -52,3 +52,5 @@ obj-$(CONFIG_PPC_XICS) += xics/ obj-$(CONFIG_PPC_XIVE) += xive/ obj-$(CONFIG_GE_FPGA) += ge/ + +obj-$(CONFIG_MCE_ERROR_INJECT) += mce_error_inject.oarch/powerpc/sysdev/mce_error_inject.c new file +148
-0@@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Machine Check Exception injection code +*/ + +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/vmalloc.h> +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <asm/debugfs.h> + +static inline unsigned long get_slb_index (void ) +{ +unsigned long index; + + index =get_paca ()->stab_rr; + +/* +* simple round-robin replacement of slb starting at SLB_NUM_BOLTED. +*/ +if (index < (mmu_slb_size -1 )) + index++; +else + index =SLB_NUM_BOLTED ; +get_paca ()->stab_rr = index; +return index; +} + +#define slb_esid_mask (ssize) \ + (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T) + +static inline unsigned long mk_esid_data (unsigned long ea,int ssize, +unsigned long slot) +{ +return (ea &slb_esid_mask (ssize)) |SLB_ESID_V | slot; +} + +#define slb_vsid_shift (ssize) \ + ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T) + +static inline unsigned long mk_vsid_data (unsigned long ea,int ssize, +unsigned long flags) +{ +return (get_kernel_vsid (ea, ssize) <<slb_vsid_shift (ssize)) | flags | + ((unsigned long )ssize <<SLB_VSID_SSIZE_SHIFT ); +} + +static void insert_slb_entry (char *p,int ssize) +{ +unsigned long flags, entry; +struct paca_struct *paca; + + flags =SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K ].sllp; + +preempt_disable (); + + paca =get_paca (); + + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); + + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); +preempt_enable (); + p[0 ] ='!' ; +} + +static void inject_vmalloc_slb_multihit (void ) +{ +char *p; + + p =vmalloc (2048 ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +vfree (p); +} + +static void inject_kmalloc_slb_multihit (void ) +{ +char *p; + + p =kmalloc (2048 ,GFP_KERNEL ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +kfree (p); +} + +static ssize_t inject_slb_multihit (const char __user *u_buf,size_t count) +{ +char buf[32 ]; +size_t buf_size; + + buf_size =min (count, (sizeof (buf) -1 )); +if (copy_from_user (buf, u_buf, buf_size)) +return -EFAULT ; + buf[buf_size] ='\0' ; + +if (buf[0 ] !='1' ) +return -EINVAL ; + +inject_vmalloc_slb_multihit (); +inject_kmalloc_slb_multihit (); +return count; +} + +static ssize_t inject_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +static ssize_t (*func)(const char __user *,size_t ); + + func = file->f_inode->i_private; +return func (buf, count); +} + +static const struct file_operations inject_fops = { + .write = inject_write, + .llseek = default_llseek, +}; + +static int mce_error_inject_setup (void ) +{ +struct dentry *mce_error_inject_dir; + + mce_error_inject_dir =debugfs_create_dir ("mce_error_inject" , + powerpc_debugfs_root); + +if (mmu_has_feature (MMU_FTR_HPTE_TABLE )) { + (void )debugfs_create_file ("inject_slb_multihit" ,0200 , + mce_error_inject_dir, + &inject_slb_multihit, + &inject_fops); + } + +return 0 ; +} + +device_initcall (mce_error_inject_setup);Signature · 1 line
2.26.2
Re: [PATCH 2/3] powerpc/mce: Add debugfs interface to inject MCE
Quoted 8 lines · Michael Ellerman
Hi Ganesh,
Quoted 5 lines · Ganesh Goudar
To test machine check handling, add debugfs interface to inject slb multihit errors.
To inject slb multihit:
#echo 1 >/sys/kernel/debug/powerpc/mce_error_inject/inject_slb_multihit
Quoted 8 lines
Rather than creating a new ad-hoc way to trigger this, can you please integrate it into
drivers/misc/lkdtm.There's enough code here that I think you should create
drivers/misc/lkdtm/powerpc.cand put the code in there. Then add an LKDTM entry point for this, maybe calledPPC_SLB_MULTIHIT.Please Cc Kees when you repost.
Sure, Thanks
Quoted 192 lines
cheers
Quoted 189 lines
arch/powerpc/Kconfig.debug | 9 ++ arch/powerpc/sysdev/Makefile | 2 + arch/powerpc/sysdev/mce_error_inject.c | 148 +++++++++++++++++++++++++ 3 files changed, 159 insertions(+)create mode 100644
arch/powerpc/sysdev/mce_error_inject.carch/powerpc/Kconfig.debug +9
-0@@ -398,3 +398,12 @@ config KASAN_SHADOW_OFFSET hex depends on KASAN default 0xe0000000 + +config MCE_ERROR_INJECT + bool "Enable MCE error injection through debugfs" + depends on DEBUG_FS + default y + help + This option creates an mce_error_inject directory in the + powerpc debugfs directory that allows limited injection of + Machine Check Errors (MCEs).arch/powerpc/sysdev/Makefile +2
-0@@ -52,3 +52,5 @@ obj-$(CONFIG_PPC_XICS) += xics/ obj-$(CONFIG_PPC_XIVE) += xive/ obj-$(CONFIG_GE_FPGA) += ge/ + +obj-$(CONFIG_MCE_ERROR_INJECT) += mce_error_inject.oarch/powerpc/sysdev/mce_error_inject.c new file +148
-0@@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Machine Check Exception injection code +*/ + +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/vmalloc.h> +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <asm/debugfs.h> + +static inline unsigned long get_slb_index (void ) +{ +unsigned long index; + + index =get_paca ()->stab_rr; + +/* +* simple round-robin replacement of slb starting at SLB_NUM_BOLTED. +*/ +if (index < (mmu_slb_size -1 )) + index++; +else + index =SLB_NUM_BOLTED ; +get_paca ()->stab_rr = index; +return index; +} + +#define slb_esid_mask (ssize) \ + (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T) + +static inline unsigned long mk_esid_data (unsigned long ea,int ssize, +unsigned long slot) +{ +return (ea &slb_esid_mask (ssize)) |SLB_ESID_V | slot; +} + +#define slb_vsid_shift (ssize) \ + ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T) + +static inline unsigned long mk_vsid_data (unsigned long ea,int ssize, +unsigned long flags) +{ +return (get_kernel_vsid (ea, ssize) <<slb_vsid_shift (ssize)) | flags | + ((unsigned long )ssize <<SLB_VSID_SSIZE_SHIFT ); +} + +static void insert_slb_entry (char *p,int ssize) +{ +unsigned long flags, entry; +struct paca_struct *paca; + + flags =SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K ].sllp; + +preempt_disable (); + + paca =get_paca (); + + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); + + entry =get_slb_index (); + asmvolatile ("slbmte %0,%1" : + :"r" (mk_vsid_data ((unsigned long )p, ssize, flags)), +"r" (mk_esid_data ((unsigned long )p, ssize, entry)) + :"memory" ); +preempt_enable (); + p[0 ] ='!' ; +} + +static void inject_vmalloc_slb_multihit (void ) +{ +char *p; + + p =vmalloc (2048 ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +vfree (p); +} + +static void inject_kmalloc_slb_multihit (void ) +{ +char *p; + + p =kmalloc (2048 ,GFP_KERNEL ); +if (!p) +return ; + +insert_slb_entry (p,MMU_SEGSIZE_1T ); +kfree (p); +} + +static ssize_t inject_slb_multihit (const char __user *u_buf,size_t count) +{ +char buf[32 ]; +size_t buf_size; + + buf_size =min (count, (sizeof (buf) -1 )); +if (copy_from_user (buf, u_buf, buf_size)) +return -EFAULT ; + buf[buf_size] ='\0' ; + +if (buf[0 ] !='1' ) +return -EINVAL ; + +inject_vmalloc_slb_multihit (); +inject_kmalloc_slb_multihit (); +return count; +} + +static ssize_t inject_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +static ssize_t (*func)(const char __user *,size_t ); + + func = file->f_inode->i_private; +return func (buf, count); +} + +static const struct file_operations inject_fops = { + .write = inject_write, + .llseek = default_llseek, +}; + +static int mce_error_inject_setup (void ) +{ +struct dentry *mce_error_inject_dir; + + mce_error_inject_dir =debugfs_create_dir ("mce_error_inject" , + powerpc_debugfs_root); + +if (mmu_has_feature (MMU_FTR_HPTE_TABLE )) { + (void )debugfs_create_file ("inject_slb_multihit" ,0200 , + mce_error_inject_dir, + &inject_slb_multihit, + &inject_fops); + } + +return 0 ; +} + +device_initcall (mce_error_inject_setup);Signature · 1 line
2.26.2
PATCH 3/3 selftest/powerpc: Add slb multihit selftest
In reply to Ganesh GoudarAdd selftest to check if the system recovers from slb multihit errors.
--- tools/testing/selftests/powerpc/Makefile | 3 ++- tools/testing/selftests/powerpc/mces/Makefile | 6 ++++++ tools/testing/selftests/powerpc/mces/slb_multihit.sh | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/mces/Makefile create mode 100755 tools/testing/selftests/powerpc/mces/slb_multihit.sh
tools/testing/selftests/powerpc/Makefile +2 -1
@@ -31,7 +31,8 @@ SUB_DIRS = alignment \ vphn \ math \ ptrace \ - security + security \ + mces endif
tools/testing/selftests/powerpc/mces/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for machine check exceptions selftests + +TEST_PROGS := slb_multihit.sh + +include ../../lib.mk
tools/testing/selftests/powerpc/mces/slb_multihit.sh new file +9 -0
@@ -0,0 +1,9 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +if [ ! -e "/sys/kernel/debug/powerpc/mce_error_inject/inject_slb_multihit" ] ; then + exit 0; +fi + +echo 1 > /sys/kernel/debug/powerpc/mce_error_inject/inject_slb_multihit +exit 0
Signature · 1 line
2.26.2
Hello,
Quoted 10 lines · Ganesh Goudar
This patch series fixes mce handling for pseries, provides debugfs interface for mce injection and adds selftest to test mce handling on pseries/powernv machines running in hash mmu mode. debugfs interface and sleftest are added only for slb multihit injection, We can add other tests in future if possible.
Ganesh Goudar (3):
powerpc/mce: remove nmi_enter/exit from real mode handler powerpc/mce: Add debugfs interface to inject MCE selftest/powerpc: Add slb multihit selftest
Is the below logic sound? It does not agree with what is added here:
void machine_check_exception(struct pt_regs *regs) {
int recover = 0;
/*
* BOOK3S_64 does not call this handler as a non-maskable interrupt
* (it uses its own early real-mode handler to handle the MCE proper
* and then raises irq_work to call this handler when interrupts are
* enabled).
*
* This is silly. The BOOK3S_64 should just call a different function
* rather than expecting semantics to magically change. Something
* like 'non_nmi_machine_check_exception()', perhaps?
*/
const bool nmi = !IS_ENABLED(CONFIG_PPC_BOOK3S_64);
if (nmi) nmi_enter();
Thanks
Michal
Quoted 31 lines · Michal Suchánek
Hello,
Quoted 10 lines · Ganesh Goudar
This patch series fixes mce handling for pseries, provides debugfs interface for mce injection and adds selftest to test mce handling on pseries/powernv machines running in hash mmu mode. debugfs interface and sleftest are added only for slb multihit injection, We can add other tests in future if possible.
Ganesh Goudar (3):
powerpc/mce: remove nmi_enter/exit from real mode handler powerpc/mce: Add debugfs interface to inject MCE selftest/powerpc: Add slb multihit selftestIs the below logic sound? It does not agree with what is added here:
void
machine_check_exception(struct pt_regs *regs){
int recover = 0;/*
*BOOK3S_64does not call this handler as a non-maskable interrupt
* (it uses its own early real-mode handler to handle the MCE proper
* and then raisesirq_workto call this handler when interrupts are
* enabled).
*
* This is silly. TheBOOK3S_64should just call a different function
* rather than expecting semantics to magically change. Something
* like 'non_nmi_machine_check_exception()', perhaps?
*/
const bool nmi = !IS_ENABLED(CONFIG_PPC_BOOK3S_64);
Quoted 5 lines
if (nmi)
nmi_enter();Thanks
Michal
Looks like Nick Piggin has the Justification for it, Ill leave Nick to answer this.