powerpc/mce: Avoid using irq_work_queue() in realmode
PATCH v4 1/1 powerpc/mce: Avoid using irq_work_queue() in realmode
In realmode mce handler we use irq_work_queue() to defer the processing of mce events, irq_work_queue() can only be called when translation is enabled because it touches memory outside RMA, hence we enable translation before calling irq_work_queue and disable on return, though it is not safe to do in realmode.
To avoid this, program the decrementer and call the event processing functions from timer handler.
---
V2:
* Use arch_irq_work_raise to raise decrementer interrupt.
* Avoid having atomic variable.
V3:
* Fix build error.
Reported by kernel test bot.
V4:
* Rename some functions and variables
* Remove mces_to_process counter and add a flag to indicate there is a mce info to process.
--- arch/powerpc/include/asm/machdep.h | 2 + arch/powerpc/include/asm/mce.h | 13 +++++ arch/powerpc/include/asm/paca.h | 1 + arch/powerpc/kernel/mce.c | 60 +++++++++++++----------- arch/powerpc/kernel/time.c | 2 + arch/powerpc/platforms/pseries/pseries.h | 1 + arch/powerpc/platforms/pseries/ras.c | 31 +----------- arch/powerpc/platforms/pseries/setup.c | 1 + 8 files changed, 53 insertions(+), 58 deletions(-)
arch/powerpc/include/asm/machdep.h +2 -0
@@ -99,6 +99,8 @@ struct machdep_calls {/* Called during machine check exception to retrive fixup address. */ bool (*mce_check_early_recovery)(struct pt_regs *regs); +void (*machine_check_log_err)(void ); +/* Motherboard/chipset features. This is a kind of general purpose * hook used to control some machine specific features (like reset * lines, chip power control, etc...).
arch/powerpc/include/asm/mce.h +13 -0
@@ -235,8 +235,21 @@ extern void machine_check_print_event_info(struct machine_check_event *evt,unsigned long addr_to_pfn (struct pt_regs *regs,unsigned long addr);extern void mce_common_process_ue (struct pt_regs *regs,struct mce_error_info *mce_err); +void mce_irq_work_queue (void );int mce_register_notifier (struct notifier_block *nb);int mce_unregister_notifier (struct notifier_block *nb); + +#ifdef CONFIG_PPC_BOOK3S_64 +void mce_run_irq_context_handlers (void ); +#else +static inline void mce_run_irq_context_handlers (void ) { }; +#endif /* CONFIG_PPC_BOOK3S_64 */ + +#ifdef CONFIG_PPC_BOOK3S_64 +void set_mce_pending_irq_work (void ); +void clear_mce_pending_irq_work (void ); +#endif /* CONFIG_PPC_BOOK3S_64 */ +#ifdef CONFIG_PPC_BOOK3S_64 void flush_and_reload_slb (void );void flush_erat (void );
arch/powerpc/include/asm/paca.h +1 -0
@@ -280,6 +280,7 @@ struct paca_struct {#endif #ifdef CONFIG_PPC_BOOK3S_64 struct mce_info *mce_info; +u8 mce_pending_irq_work;#endif /* CONFIG_PPC_BOOK3S_64 */ }____cacheline_aligned ;
arch/powerpc/kernel/mce.c +32 -28
111 lines not on this page · raw message
arch/powerpc/kernel/time.c +2 -0
@@ -70,6 +70,7 @@#include <asm/vdso_datapage.h> #include <asm/firmware.h> #include <asm/asm-prototypes.h> +#include <asm/mce.h> /* powerpc clocksource/clockevent code */
@@ -594,6 +595,7 @@ DEFINE_INTERRUPT_HANDLER_ASYNC(timer_interrupt)if (test_irq_work_pending ()) {clear_irq_work_pending (); +mce_run_irq_context_handlers ();irq_work_run (); }
arch/powerpc/platforms/pseries/pseries.h +1 -0
@@ -21,6 +21,7 @@ struct pt_regs;extern int pSeries_system_reset_exception (struct pt_regs *regs);extern int pSeries_machine_check_exception (struct pt_regs *regs);extern long pseries_machine_check_realmode (struct pt_regs *regs); +void pSeries_machine_check_log_err (void );#ifdef CONFIG_SMP extern void smp_init_pseries (void );
arch/powerpc/platforms/pseries/ras.c +1 -30
@@ -23,11 +23,6 @@ static DEFINE_SPINLOCK(ras_log_buf_lock);static int ras_check_exception_token; -static void mce_process_errlog_event (struct irq_work *work); -static struct irq_work mce_errlog_process_work = { - .func = mce_process_errlog_event, -}; -#define EPOW_SENSOR_TOKEN 9#define EPOW_SENSOR_INDEX 0
@@ -729,40 +724,16 @@ static int mce_handle_error(struct pt_regs *regs, struct rtas_error_log *errp) error_type = mce_log->error_type; disposition =mce_handle_err_realmode (disposition, error_type); - -/* -* Enable translation as we will be accessing per-cpu variables -* in save_mce_event() which may fall outside RMO region, also -* leave it enabled because subsequently we will be queuing work -* to workqueues where again per-cpu variables accessed, besides -* fwnmi_release_errinfo() crashes when called in realmode on -* pseries. -* Note: All the realmode handling like flushing SLB entries for -* SLB multihit is done by now. -*/ out: - msr =mfmsr (); -mtmsr (msr |MSR_IR |MSR_DR ); - disposition =mce_handle_err_virtmode (regs, errp, mce_log, disposition); - -/* -* Queue irq work to log this rtas event later. -* irq_work_queue uses per-cpu variables, so do this in virt -* mode as well. -*/ -irq_work_queue (&mce_errlog_process_work); - -mtmsr (msr); -return disposition; }/* * Process MCE rtas errlog event. */ -static void mce_process_errlog_event (struct irq_work *work) +void pSeries_machine_check_log_err (void ) {struct rtas_error_log *err;
arch/powerpc/platforms/pseries/setup.c +1 -0
@@ -1084,6 +1084,7 @@ define_machine(pseries) { .system_reset_exception = pSeries_system_reset_exception, .machine_check_early = pseries_machine_check_realmode, .machine_check_exception = pSeries_machine_check_exception, + .machine_check_log_err = pSeries_machine_check_log_err, #ifdef CONFIG_KEXEC_CORE .machine_kexec = pSeries_machine_kexec, .kexec_cpu_down = pseries_kexec_cpu_down,
Signature · 1 line
2.31.1
kernel test robot
build botThank 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.16 next-20220118]
[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-Avoid-using-irq_work_queue-in-realmode/20220117-163425 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc64-randconfig-c024-20220116 (https://download.01.org/0day-ci/archive/20220118/202201181831.VB3r6wzz-lkp(a)intel.com/config) compiler: powerpc64-linux-gcc (GCC) 11.2.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
# https://github.com/0day-ci/linux/commit/bb8f4e786eb9c838daad7a6187dcd59040ff2771
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Ganesh-Goudar/powerpc-mce-Avoid-using-irq_work_queue-in-realmode/20220117-163425 git checkout bb8f4e786eb9c838daad7a6187dcd59040ff2771
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash arch/powerpc/platforms/pseries/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
arch/powerpc/platforms/pseries/ras.c: In function 'mce_handle_error':
>> arch/powerpc/platforms/pseries/ras.c:715:23: error: unused variable 'msr' [-Werror=unused-variable]
715 | unsigned long msr;
| ^~~cc1: all warnings being treated as errors
vim +/msr +715 arch/powerpc/platforms/pseries/ras.c
a43c1590426c44 Mahesh Salgaonkar 2018-09-11 709
4ff753feab0212 Ganesh Goudar 2020-07-24 710 static int mce_handle_error(struct pt_regs *regs, struct rtas_error_log *errp)
4ff753feab0212 Ganesh Goudar 2020-07-24 711 {
4ff753feab0212 Ganesh Goudar 2020-07-24 712 struct pseries_errorlog *pseries_log;
4ff753feab0212 Ganesh Goudar 2020-07-24 713 struct pseries_mc_errorlog *mce_log = NULL;
4ff753feab0212 Ganesh Goudar 2020-07-24 714 int disposition = rtas_error_disposition(errp);
74c3354bc1d89d Nicholas Piggin 2021-02-07 @715 unsigned long msr;
4ff753feab0212 Ganesh Goudar 2020-07-24 716 u8 error_type;
4ff753feab0212 Ganesh Goudar 2020-07-24 717
4ff753feab0212 Ganesh Goudar 2020-07-24 718 if (!rtas_error_extended(errp))
4ff753feab0212 Ganesh Goudar 2020-07-24 719 goto out;
4ff753feab0212 Ganesh Goudar 2020-07-24 720
4ff753feab0212 Ganesh Goudar 2020-07-24 721 pseries_log = get_pseries_errorlog(errp, PSERIES_ELOG_SECT_ID_MCE);
4ff753feab0212 Ganesh Goudar 2020-07-24 722 if (!pseries_log)
4ff753feab0212 Ganesh Goudar 2020-07-24 723 goto out;
4ff753feab0212 Ganesh Goudar 2020-07-24 724
4ff753feab0212 Ganesh Goudar 2020-07-24 725 mce_log = (struct pseries_mc_errorlog *)pseries_log->data;
4ff753feab0212 Ganesh Goudar 2020-07-24 726 error_type = mce_log->error_type;
4ff753feab0212 Ganesh Goudar 2020-07-24 727
4ff753feab0212 Ganesh Goudar 2020-07-24 728 disposition = mce_handle_err_realmode(disposition, error_type);
4ff753feab0212 Ganesh Goudar 2020-07-24 729 out:
4ff753feab0212 Ganesh Goudar 2020-07-24 730 disposition = mce_handle_err_virtmode(regs, errp, mce_log,
4ff753feab0212 Ganesh Goudar 2020-07-24 731 disposition);
9ca766f9891d23 Nicholas Piggin 2019-08-02 732 return disposition;
7f177f9810ada8 Ganesh Goudar 2019-04-15 733 }
7f177f9810ada8 Ganesh Goudar 2019-04-15 734 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org