From nobody Sun Feb 8 15:42:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D071EB64D9 for ; Thu, 15 Jun 2023 14:50:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345112AbjFOOtu (ORCPT ); Thu, 15 Jun 2023 10:49:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240102AbjFOOts (ORCPT ); Thu, 15 Jun 2023 10:49:48 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA2FE273C for ; Thu, 15 Jun 2023 07:49:46 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A1CA51FDC5; Thu, 15 Jun 2023 14:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1686840585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tWP3X6y1slpOFyHr1sWNQEgiKAMy/X1Ov85nf7gL3Es=; b=VovsHV+u6yMps6Jc8eTq/SihTWxDPyG6vyvN159MCR6KcjJMMU2AqSouxcoQ8GVtuzVGjV z6z5yhvpn/ET/0B8+8GkreLj4Y0O5B8KLeEVQ0Gs1VB34FMEH48FmPKUzme+DbS8NYtnqx m6pi8nYrLF3WZLrBh37kQekKT4WtqIA= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 683FB13A32; Thu, 15 Jun 2023 14:49:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RdHiFgkli2RDAgAAMHmgww (envelope-from ); Thu, 15 Jun 2023 14:49:45 +0000 From: Nikolay Borisov To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Nikolay Borisov Subject: [PATCH] x86/mce: Use lockdep to assert preemption is off in mcheck_cpu_init Date: Thu, 15 Jun 2023 17:49:42 +0300 Message-Id: <20230615144942.1020961-1-nik.borisov@suse.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Instead of relying on a comment, use lockdep_assert_preemption_disabled() as it issue a warning if preemption is on. mcheck_cpu_init is called from: start_kernel check_bugs identify_boot_cpu identify_cpu mcheck_cpu_init Which happens after lockdep_init() call in start_kernel(). Signed-off-by: Nikolay Borisov --- arch/x86/kernel/cpu/mce/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 2eec60f50057..5d945a1690d5 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -2126,12 +2126,12 @@ DEFINE_IDTENTRY_RAW(exc_machine_check) } #endif =20 -/* - * Called for each booted CPU to set up machine checks. - * Must be called with preempt off: - */ +/* Called for each booted CPU to set up machine checks. */ void mcheck_cpu_init(struct cpuinfo_x86 *c) { + + lockdep_assert_preemption_disabled(); + if (mca_cfg.disabled) return; =20 --=20 2.34.1