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 <redacted>
---
arch/powerpc/kernel/mce.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
@@ -591,10 +591,15 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info);longnotracemachine_check_early(structpt_regs*regs){longhandled=0;-boolnested=in_nmi();+boolnested;+boolis_pseries_hpt_guest;u8ftrace_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();
From: kernel test robot <hidden> Date: 2020-09-17 08:27:28
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
Reported-by: kernel test robot <redacted>
All errors (new ones prefixed by >>):
arch/powerpc/sysdev/mce_error_inject.c: In function 'get_slb_index':
quoted
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;
| ^~~~~~~~
quoted
arch/powerpc/sysdev/mce_error_inject.c:17:20: error: invalid type argument of '->' (have 'int')
17 | index = get_paca()->stab_rr;
| ^~
quoted
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
quoted
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':
quoted
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'?
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();
| ^
quoted
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':
quoted
arch/powerpc/sysdev/mce_error_inject.c:83:22: error: 'MMU_SEGSIZE_1T' undeclared (first use in this function)
From: kernel test robot <hidden> Date: 2020-09-17 08:38:56
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
Reported-by: kernel test robot <redacted>
All warnings (new ones prefixed by >>):
arch/powerpc/sysdev/mce_error_inject.c: In function 'insert_slb_entry':
quoted
arch/powerpc/sysdev/mce_error_inject.c:52:22: warning: variable 'paca' set but not used [-Wunused-but-set-variable]
From: Michal Suchánek <hidden> Date: 2020-09-17 12:44:14
Hello,
On Wed, Sep 16, 2020 at 10:52:26PM +0530, Ganesh Goudar wrote:
quoted hunk
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 <redacted>
---
arch/powerpc/kernel/mce.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
@@ -591,10 +591,15 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info);longnotracemachine_check_early(structpt_regs*regs){longhandled=0;-boolnested=in_nmi();+boolnested;+boolis_pseries_hpt_guest;u8ftrace_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
From: Michal Suchánek <hidden> Date: 2020-09-17 12:59:19
Hello,
On Wed, Sep 16, 2020 at 10:52:25PM +0530, Ganesh Goudar wrote:
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
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2020-09-18 06:44:47
Hi Ganesh,
Ganesh Goudar [off-list ref] writes:
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
Hello,
On Wed, Sep 16, 2020 at 10:52:25PM +0530, Ganesh Goudar wrote:
quoted
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
Looks like Nick Piggin has the Justification for it, Ill leave Nick to
answer this.
Hello,
On Wed, Sep 16, 2020 at 10:52:26PM +0530, Ganesh Goudar wrote:
quoted
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 <redacted>
---
arch/powerpc/kernel/mce.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
@@ -591,10 +591,15 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info);longnotracemachine_check_early(structpt_regs*regs){longhandled=0;-boolnested=in_nmi();+boolnested;+boolis_pseries_hpt_guest;u8ftrace_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.
ok
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?
Not sure why nmi_enter/exit is needed here, Again, Nick may have a reason.
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.