1 Star 0 Fork 0

lcy/os-patch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-sdei_watchdog-avoid-possible-false-hardlockup.patch 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
lcy 提交于 2024-10-29 10:09 . commit-OpenCloudOS-kernel
From e4df2fa274e839e69f394040f56c7bde60266831 Mon Sep 17 00:00:00 2001
From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Date: Sat, 20 Feb 2021 11:01:03 +0800
Subject: [PATCH] sdei_watchdog: avoid possible false hardlockup
Firmware may not trigger SDEI event as required frequency. SDEI event
may be triggered too soon, which cause false hardlockup in kernel. Check
the time stamp in sdei_watchdog_callbak and skip the hardlockup check if
it is invoked too soon.
Signed-off-by: huwentao <huwentao19@h-partners.com>
---
arch/arm64/kernel/watchdog_sdei.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/arch/arm64/kernel/watchdog_sdei.c b/arch/arm64/kernel/watchdog_sdei.c
index 6352b589e02a..a499a14b23c1 100644
--- a/arch/arm64/kernel/watchdog_sdei.c
+++ b/arch/arm64/kernel/watchdog_sdei.c
@@ -23,6 +23,7 @@
static int sdei_watchdog_event_num;
static bool disable_sdei_nmi_watchdog;
static bool sdei_watchdog_registered;
+static DEFINE_PER_CPU(ktime_t, last_check_time);
int watchdog_nmi_enable(unsigned int cpu)
{
@@ -35,6 +36,7 @@ int watchdog_nmi_enable(unsigned int cpu)
refresh_hld_last_timestamp();
#endif
+ __this_cpu_write(last_check_time, ktime_get_mono_fast_ns());
sdei_api_set_secure_timer_period(watchdog_thresh);
ret = sdei_api_event_enable(sdei_watchdog_event_num);
@@ -63,6 +65,23 @@ void watchdog_nmi_disable(unsigned int cpu)
static int sdei_watchdog_callback(u32 event,
struct pt_regs *regs, void *arg)
{
+ ktime_t delta, now = ktime_get_mono_fast_ns();
+
+ delta = now - __this_cpu_read(last_check_time);
+ __this_cpu_write(last_check_time, now);
+
+ /*
+ * Set delta to 4/5 of the actual watchdog threshold period so the
+ * hrtimer is guaranteed to fire at least once within the real
+ * watchdog threshold.
+ */
+ if (delta < watchdog_thresh * (u64)NSEC_PER_SEC * 4 / 5) {
+ pr_err(FW_BUG "SDEI Watchdog event triggered too soon, "
+ "time to last check:%lld ns\n", delta);
+ WARN_ON(1);
+ return 0;
+ }
+
watchdog_hardlockup_check(regs);
return 0;
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lcy48/os-patch.git
git@gitee.com:lcy48/os-patch.git
lcy48
os-patch
os-patch
master

搜索帮助