Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2246629rdd; Fri, 12 Jan 2024 04:06:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGN9YyMC6p7KzuMyfw2rC5BNgLubrvlFYW2txORBzoxgKGr/jYXgyjWY7RXHeCsMSsW/wZ7 X-Received: by 2002:a17:906:552:b0:a28:c16a:f18a with SMTP id k18-20020a170906055200b00a28c16af18amr638340eja.5.1705061205880; Fri, 12 Jan 2024 04:06:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705061205; cv=none; d=google.com; s=arc-20160816; b=XXFHrtogtgt3j0EvrupFrLERE3DiSIzGH0s3QRjBvzSdYsqdCkkfG+VVLS5YP1UroJ Aa6g9R670vGzS4aveFpCSqpEcmBgX4JWDP6OIVg+JVAXvGAtCeYw93LsmkH9njGI46U9 MMwGSEk8XHI029P7ca9EH6NFY9IchV8wx1zbgEqlgoJgKLqdNpUxL3WjF2pBtsJICyzl wUj9O286SC5KMHcKfd+ist7TCcK/9YcdDOyaBwmAO4oHwHDrul9rQumAS2FX5odfQc14 GNdZrSpN4m7WLcjRE6ZLEVDEFo6uxqyNW6QdfnLTWcAtp51qd/2mebG6jNG8eobYMFFB T1Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=g5DaLt0u1AHtgkeAgmRSoWPNaEMNAS4HqAU9SCImVXY=; fh=X27bPM68lSKKHhHgXiC4ZuaEIzpEELI5utyIkp/IrIg=; b=eoCIB8wQ9czqQ5pYz73nEk3TVxbEz3/0wGNADu5Sb197eBcFyETQweBHv0vWsQNEUO 2ZAimnMj8Hj0MjfrcHJcaWeNFHf19Cg2IKR2JpG83u64VGI7QN7g7hNC63Buy8lwedkC 5MwcYmJkrESfMmSz6jpsIolfy3k2h18eY3Fw2fO7hAajCZ0rHg/zuqaCnrwBedzPM8rE 9rgkbQstvWjcqzXBkA4SulDj8UaU8uLdP3PGvWb8pn6Hi/RJEp79ErXKp9DR4Ejpu1WI u9JSe88eZfPP9WxZF28pR7k0GTTLSdhR12vghA9XSopCOZtbMtlGwRbD5OTTNTSWkjsd C3fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hyM//Fnf"; spf=pass (google.com: domain of linux-kernel+bounces-24638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x9-20020a1709060a4900b00a2a3f0411fasi1322337ejf.310.2024.01.12.04.06.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 04:06:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hyM//Fnf"; spf=pass (google.com: domain of linux-kernel+bounces-24638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 714F51F23684 for ; Fri, 12 Jan 2024 12:06:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 871026A323; Fri, 12 Jan 2024 12:06:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hyM//Fnf" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) (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 526026A032 for ; Fri, 12 Jan 2024 12:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705061188; x=1736597188; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=qZO5o8gloP88hNEdbyf9gooCX6/C7fxpb8IKA6kIC/U=; b=hyM//FnfKYE1n2o5ZnHZAR1919Dre9R4uNLe9OsDqzuTw24JQkF6BvV/ HWWEa41oWu77lU6VN8uRXOTAyRt4YHpv+5M4z2APrTTCLarTXbFCWJ9cq pfXhQdhR39DV/O87Y+QoDutx3lpd2/JohfRccufoN/pElEsZalVzbogT5 QQWdEq4j8LB6KUulyArRWdl7WedkRZiTAFYnW2Tg5VVO4DSTeRb9eN9et +tHsSXMF/IftuW809i26bRGWQzo0Eh+jXZkZp5hPbXJC7rkMruMiXLfe8 zVqxWybOzmq+sBCXhFEkhebFMdbybdwwuZQN8TAJVw/0s/asSUabYDwWE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="463441909" X-IronPort-AV: E=Sophos;i="6.04,189,1695711600"; d="scan'208";a="463441909" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2024 04:06:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,189,1695711600"; d="scan'208";a="24689196" Received: from kschuele-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.213.195]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2024 04:06:19 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id B843210A557; Fri, 12 Jan 2024 15:06:16 +0300 (+03) Date: Fri, 12 Jan 2024 15:06:16 +0300 From: "kirill.shutemov@linux.intel.com" To: NOMURA =?utf-8?B?SlVOSUNISSjph47mnZHjgIDmt7PkuIAp?= Cc: "mingo@redhat.com" , "tglx@linutronix.de" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "ardb@kernel.org" , "david@redhat.com" , "nikunj@amd.com" , "thomas.lendacky@amd.com" , "debarbos@redhat.com" , "jlelli@redhat.com" , "lgoncalv@redhat.com" , "dzickus@redhat.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH repost] x86/boot: Add a message about ignored early NMIs Message-ID: <20240112120616.5zjojjmjeqg5egb7@box> References: 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Jan 12, 2024 at 11:13:53AM +0000, NOMURA JUNICHI(野村 淳一) wrote: > Commit 78a509fba9c9 ("x86/boot: Ignore NMIs during very early boot") added > empty handler in early boot stage to avoid boot failure by spurious NMIs. > > Add a diagnostic message in case we need to know whether early NMIs have > occurred and/or what happened to them. > > Signed-off-by: Jun'ichi Nomura > Suggested-by: Borislav Petkov > Suggested-by: H. Peter Anvin > Link: https://lore.kernel.org/lkml/20231130103339.GCZWhlA196uRklTMNF@fat_crate.local/ > > diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c > --- a/arch/x86/boot/compressed/ident_map_64.c > +++ b/arch/x86/boot/compressed/ident_map_64.c > @@ -387,7 +387,10 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code) > kernel_add_identity_map(address, end); > } > > +extern int spurious_nmi_count; > + It has to be in a header file. > void do_boot_nmi_trap(struct pt_regs *regs, unsigned long error_code) > { > /* Empty handler to ignore NMI during early boot */ > + spurious_nmi_count++; > } > diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c > --- a/arch/x86/boot/compressed/misc.c > +++ b/arch/x86/boot/compressed/misc.c > @@ -357,6 +357,8 @@ unsigned long decompress_kernel(unsigned char *outbuf, unsigned long virt_addr, > return entry; > } > > +int spurious_nmi_count; > + It is not a right place to define a variable. Do it next to rest of variables at the beginning of the file. > /* > * The compressed kernel image (ZO), has been moved so that its position > * is against the end of the buffer used to hold the uncompressed kernel > @@ -493,6 +495,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output) > /* Disable exception handling before booting the kernel */ > cleanup_exception_handling(); > > + if (spurious_nmi_count) { > + error_putstr("Spurious early NMI ignored. Number of NMIs: 0x"); > + error_puthex(spurious_nmi_count); > + error_putstr("\n"); > + } > + > return output + entry_offset; > } > -- Kiryl Shutsemau / Kirill A. Shutemov