Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp251871pxx; Wed, 28 Oct 2020 04:08:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHDM0hhChPX7oUSRyFs5h4n+Bv99uk7TpGEQ9uvlKuhZU+WFmTopL8emTl98+rteIV7hSk X-Received: by 2002:aa7:d28a:: with SMTP id w10mr7166201edq.192.1603883305336; Wed, 28 Oct 2020 04:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603883305; cv=none; d=google.com; s=arc-20160816; b=wwYrZCGd0jotG/jzUP5UU9W6dVNql7776qrFc+aUVQ+/hABG9IotIQ32Iqnm9YHqaI OwYhnNqhjBv4i9z/jQHqmOWhtB7eYgywKWMu5yTzdjkCri+AsuPVe4O4hAttrxoy2awx pcnmnPyHy+0FplLde/vRLd8Q5odBuRnR/gFU893VcvT+6bwER7QdTmYlm26fvitoFY+J sVnAA7964XbmzpmNWSRbHVTZsThFgUhbMK6EsD4JgQTHpjRj8fXhhqGwUtaT72YhN8Qj Zlq/H8Ab2yDwc3TmIgdHWaPNFMUjphd8dHw2DDsFl+qyhpHKPUYAl6+Z4fHlcQoIn2fJ NqBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=77lrX++PY4ouWorNRL9oKk8vVRQatJIwY2oEi/l9Ppo=; b=lLUUdodldqGCz9Enjr9Cyiuhyr5IhlQPWLoyAc+eZoLyJaI9NfpI080zrXPXT3Jfvd fo/7rYoTlijF01AwvNqKbRDrf7KafmvUAse4yslIl+D/LWPWmOiBu53xnMzFNST2pSn0 pciGeq2nSsn9GFVW514D8hcpctgPIsY+kdWLByYCJ3oZWGixJviZ3DOlcE/K+7VzHFWB +Kci8elM4Rh+XQinZxCrIzCLhPGMnUVykzhFEMCszKaaT3ObVuyGt/bUshiCIRTu65lC HUxrVmPA71SGcytOKx6XeYlwFwREEC1C2ORUWZNBz4vSrlTeTi31h8Js17B7lgw7nVp5 oXPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BuWwPrSe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si3663191edn.100.2020.10.28.04.08.03; Wed, 28 Oct 2020 04:08:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BuWwPrSe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1786331AbgJ0O7u (ORCPT + 99 others); Tue, 27 Oct 2020 10:59:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:51264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773334AbgJ0Ov5 (ORCPT ); Tue, 27 Oct 2020 10:51:57 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA4DF20773; Tue, 27 Oct 2020 14:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810316; bh=8xO6donlWuaYx3A3j8ilplaJ2DqNwh8NLzOUZ7XGuyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BuWwPrSe9fS0fOlUeCjJTK6RTq3j7z/xQIp+RdAtHUv3kO5QGqkE+6nDBWROxKD6r I3WOlaJulwsA7gIaLjYUfD/ePoM+E6rPL6pwc7SYlqoj1R1L1QuVbsAlHtb6eurcR6 OyWxitUVwdjxi7GB/7gQlktD6RqIBss7bL6kHxb4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Libing Zhou , Borislav Petkov , Changbin Du , Sasha Levin Subject: [PATCH 5.8 096/633] x86/nmi: Fix nmi_handle() duration miscalculation Date: Tue, 27 Oct 2020 14:47:19 +0100 Message-Id: <20201027135527.204805198@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Libing Zhou [ 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) Signed-off-by: Libing Zhou Signed-off-by: Borislav Petkov Cc: Changbin Du Link: https://lkml.kernel.org/r/20200820025641.44075-1-libing.zhou@nokia-sbell.com Signed-off-by: Sasha Levin --- arch/x86/kernel/nmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index d7c5e44b26f73..091752c3a19e2 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -102,7 +102,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) @@ -110,12 +109,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) -- 2.25.1