summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibing Zhou <libing.zhou@nokia-sbell.com>2020-08-20 10:56:41 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-29 09:55:00 +0100
commita0cc22fa1ea248e48dfc354a33c0a34a70e8cfe6 (patch)
treea30f7c0f9854d8b46ddc2b7ee7906f4cf271c84f
parentb2fc0a13f93fad361fa412cfa5a26374ed8c695f (diff)
downloadlinux-stable-a0cc22fa1ea248e48dfc354a33c0a34a70e8cfe6.tar.gz
linux-stable-a0cc22fa1ea248e48dfc354a33c0a34a70e8cfe6.tar.bz2
linux-stable-a0cc22fa1ea248e48dfc354a33c0a34a70e8cfe6.zip
x86/nmi: Fix nmi_handle() duration miscalculation
[ Upstream commit f94c91f7ba3ba7de2bc8aa31be28e1abb22f849e ] When nmi_check_duration() is checking the time an NMI handler took to execute, the whole_msecs value used should be read from the @duration argument, not from the ->max_duration, the latter being used to store the current maximal duration. [ bp: Rewrite commit message. ] Fixes: 248ed51048c4 ("x86/nmi: Remove irq_work from the long duration NMI handler") Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Libing Zhou <libing.zhou@nokia-sbell.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Changbin Du <changbin.du@gmail.com> Link: https://lkml.kernel.org/r/20200820025641.44075-1-libing.zhou@nokia-sbell.com Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--arch/x86/kernel/nmi.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 0f8b9b900b0e..996eb53f8eb7 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -104,7 +104,6 @@ fs_initcall(nmi_warning_debugfs);
static void nmi_check_duration(struct nmiaction *action, u64 duration)
{
- u64 whole_msecs = READ_ONCE(action->max_duration);
int remainder_ns, decimal_msecs;
if (duration < nmi_longest_ns || duration < action->max_duration)
@@ -112,12 +111,12 @@ static void nmi_check_duration(struct nmiaction *action, u64 duration)
action->max_duration = duration;
- remainder_ns = do_div(whole_msecs, (1000 * 1000));
+ remainder_ns = do_div(duration, (1000 * 1000));
decimal_msecs = remainder_ns / 1000;
printk_ratelimited(KERN_INFO
"INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
- action->handler, whole_msecs, decimal_msecs);
+ action->handler, duration, decimal_msecs);
}
static int nmi_handle(unsigned int type, struct pt_regs *regs)