From 07789defcdf8b42ded9c39ad78f65c2a91830315 Mon Sep 17 00:00:00 2001 From: Xiongfeng Wang Date: Wed, 27 Feb 2019 11:06:14 +0800 Subject: [PATCH] sdei_watchdog: do not disable sdei_watchdog event when failed to initialise SDEI euler inclusion category: feature Bugzilla: 5515 CVE: N/A ---------------------------------------- When we modify '/proc/sys/kernel/watchdog_thresh', kernel will call 'watchdog_nmi_disable' before change 'watchdog_thresh'. If firmware does not support SDEI, we will get 'SDEI NMI Watchdog: Disable NMI Watchdog failed on cpuX'. It is because we failed to disable sdei_watchdog event. It has no bad effect. This patch add a flag to record whether we have registered sdei_watchdog successfully and do not disable sdei_watchdog event if we failed to register sdei_watchdog event. Signed-off-by: Xiongfeng Wang Reviewed-by: Hanjun Guo Signed-off-by: Yang Yingliang --- arch/arm64/kernel/watchdog_sdei.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/watchdog_sdei.c b/arch/arm64/kernel/watchdog_sdei.c index 4fd1419729c2..e36c4d398893 100644 --- a/arch/arm64/kernel/watchdog_sdei.c +++ b/arch/arm64/kernel/watchdog_sdei.c @@ -21,11 +21,15 @@ static int sdei_watchdog_event_num; static bool disable_sdei_nmi_watchdog; +static bool sdei_watchdog_registered; int watchdog_nmi_enable(unsigned int cpu) { int ret; + if (!sdei_watchdog_registered) + return -EINVAL; + refresh_hld_last_timestamp(); ret = sdei_api_event_enable(sdei_watchdog_event_num); @@ -42,6 +46,9 @@ void watchdog_nmi_disable(unsigned int cpu) { int ret; + if (!sdei_watchdog_registered) + return; + ret = sdei_api_event_disable(sdei_watchdog_event_num); if (ret) pr_err("Disable NMI Watchdog failed on cpu%d\n", @@ -87,7 +94,7 @@ int __init watchdog_nmi_probe(void) sdei_watchdog_event_num = sdei_api_event_interrupt_bind(SDEI_NMI_WATCHDOG_HWIRQ); if (sdei_watchdog_event_num < 0) { - pr_err("bind interrupt failed !\n"); + pr_err("Bind interrupt failed. Firmware may not support SDEI !\n"); return sdei_watchdog_event_num; } @@ -100,6 +107,7 @@ int __init watchdog_nmi_probe(void) return ret; } + sdei_watchdog_registered = true; pr_info("SDEI Watchdog registered successfully\n"); return 0; -- GitLab