Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2464027lqb; Mon, 27 May 2024 23:55:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUeEQa9nleyr71Jg4Ehim7qk6gxGW59MRResIyOsYsyGKhaXPG/2lVcad/84dquveJ5WTdEUudVxvhjykpUJk82Ik5qPvymJ4D30MxWw== X-Google-Smtp-Source: AGHT+IG/IshQI3CQKdNDzenkykW0GrpKmU0BreIAC3kYVpG5kXN+A0tJzfn7misoCBpSbIxHFMNe X-Received: by 2002:a05:6a20:6a03:b0:1b0:1ce0:1a2e with SMTP id adf61e73a8af0-1b212dafd87mr12436998637.19.1716879312367; Mon, 27 May 2024 23:55:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716879312; cv=pass; d=google.com; s=arc-20160816; b=Vmrbc+I8Tl7FrcTJkat39WBzgWqXayxhK70zPBmLXqwNv5AY7GUcAcillR6MCOftp0 sKF4O7KRcyJxwQr8ylnasVUICtT7J/OXEJK4cizb1GIUTSVpu8KtruhrBkeMLnIxBt77 EuDzFudUfX8WNHAVjRmaZrYWwLaQHoh13SOZ4N4QWvtBaJ4Px4T3tVNGB/jyfrrTPES+ 5yIDrwuoXUUBc+2aNbWDKJNBXFKYaicMMAF/89gc1jMPzDKF+ue3atcbgHPLnhPgaU/X sCx7b8gB3Spr/+yXOqpC12yLhzKSxWkg4e9x+ljG50rbcDdh/sgWfmfJUshmAdJ7jYYd S0+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=+2Y0MAS+iB79f6GYSCNEPcECpGQM6CXnAvN/A3m9mFU=; fh=mZLR5zYlVcA4WvSnV6opnnPlelUrEV+Qpr35LWbJ1ws=; b=BK4Nbs+JRCtphOV5H+K+UCiSeqp3C/DrHjtpW1ZpuFAUBmfmFne5Nl83TBxP9uXDsZ F//lD1MjIWdgg0hYpf5SGCXyE+9h3nkkdkzaDMpk248/XJp6czyE0uCOGKtsdb1G3Xaa 5TS0oeHKBc6HH5ohkGTNha9+/S10tz7CSkfk04+U3wYWR5ygLZrgQG13nbT1R6tAHw5Y 4+4vFYhkqijKkh3/XQaE24t8abmrDYHrxxFgVoDAwAHJWX1v8EC0Wlpf3WQHYyrCgyMk yXNKYfqS0wfwC6OquTSFI7T2NGU8rSVYOuX5CfkeB1t9a6xEhHcVszb2Dm8/BQUmLBYo esuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zhaoxin.com); spf=pass (google.com: domain of linux-kernel+bounces-191828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191828-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f44ca1e9ddsi71878585ad.651.2024.05.27.23.55.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 23:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zhaoxin.com); spf=pass (google.com: domain of linux-kernel+bounces-191828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191828-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DD391B215D9 for ; Tue, 28 May 2024 06:55:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2168D6F062; Tue, 28 May 2024 06:55:02 +0000 (UTC) Received: from mx2.zhaoxin.com (mx2.zhaoxin.com [203.110.167.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD09D5339B for ; Tue, 28 May 2024 06:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.110.167.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716879301; cv=none; b=UdPdauH209Joii1xCXLb/jUS6gTZp/FW8ky77MacSmhode3eta7R832adZpXKLn6qfYfjsUSDCpA1XhJyKxwWOuA7TuT+I9xrsdrsYoZS3pYPXZtbGdSiPcRBeg1ISsTxxoErlUgsOKQKaRmEFOGD+IaXmCgmLU30PeDNZUvQ1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716879301; c=relaxed/simple; bh=k/kiyNBZ/CQQZm9441hQ2gzjm+HeVypZQxq7MFeGzuU=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ChBeZg8nA7mqRDZ1KvfII0JPwTMs3xRvWb6KF0BxNzGUYnQf8jTdaF2im2CxvuR/GBfTK9NN58moytahw/q1P3gkSUT/H6MMuojApv6RgQM0uHZ+qKkud/KmUJNddryWz/5Lh9xVeHORrV2Jg+7MP07eRvCg+i1M6TgVo7UXIUA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zhaoxin.com; spf=pass smtp.mailfrom=zhaoxin.com; arc=none smtp.client-ip=203.110.167.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zhaoxin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zhaoxin.com X-ASG-Debug-ID: 1716878322-1eb14e15750e370001-xx1T2L Received: from ZXSHMBX3.zhaoxin.com (ZXSHMBX3.zhaoxin.com [10.28.252.165]) by mx2.zhaoxin.com with ESMTP id gd8N2tgmRDCGMwi7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Tue, 28 May 2024 14:38:42 +0800 (CST) X-Barracuda-Envelope-From: TonyWWang-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.165 Received: from ZXBJMBX03.zhaoxin.com (10.29.252.7) by ZXSHMBX3.zhaoxin.com (10.28.252.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 28 May 2024 14:38:41 +0800 Received: from localhost.localdomain (10.32.65.162) by ZXBJMBX03.zhaoxin.com (10.29.252.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 28 May 2024 14:38:37 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.165 From: Tony W Wang-oc X-Barracuda-RBL-Trusted-Forwarder: 10.29.252.7 To: , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH] x86/hpet: Read HPET directly if panic in progress Date: Tue, 28 May 2024 14:38:36 +0800 X-ASG-Orig-Subj: [PATCH] x86/hpet: Read HPET directly if panic in progress Message-ID: <20240528063836.5248-1-TonyWWang-oc@zhaoxin.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To ZXBJMBX03.zhaoxin.com (10.29.252.7) X-Barracuda-Connect: ZXSHMBX3.zhaoxin.com[10.28.252.165] X-Barracuda-Start-Time: 1716878322 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.36:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 1321 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.125447 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- When the clocksource of the system is HPET,a CPU executing read_hpet might be interrupted by exceptions to executing the panic,this may lead to read_hpet dead loops: CPU x CPU x ---- ---- read_hpet() arch_spin_trylock(&hpet.lock) [CPU x got the hpet.lock] #MCE happened do_machine_check() mce_panic() panic() kmsg_dump() pstore_dump() pstore_record_init() ktime_get_real_fast_ns() read_hpet() [dead loops] To avoid this dead loops, read HPET directly if panic in progress. Signed-off-by: Tony W Wang-oc --- arch/x86/kernel/hpet.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index c96ae8fee95e..ecadd0698d6a 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -804,6 +804,12 @@ static u64 read_hpet(struct clocksource *cs) if (in_nmi()) return (u64)hpet_readl(HPET_COUNTER); + /* + * Read HPET directly if panic in progress. + */ + if (unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID)) + return (u64)hpet_readl(HPET_COUNTER); + /* * Read the current state of the lock and HPET value atomically. */ -- 2.25.1