Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7859894rwl; Tue, 10 Jan 2023 06:19:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXvI3zYbjK7SPG0x1b9L1PsSoSnnVad6J05lsT+/lSHcaZ958wzfGOItLgEhDeFE7FJ3ZrR+ X-Received: by 2002:a17:902:ccc5:b0:185:441e:4cfc with SMTP id z5-20020a170902ccc500b00185441e4cfcmr81132320ple.44.1673360340575; Tue, 10 Jan 2023 06:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673360340; cv=none; d=google.com; s=arc-20160816; b=jDD6sPvN0IhcbQauPVJLA7iyzrD2kj/bT2AoK3f8Kz66KsFyelkTAIapo1YpJY6tF6 g9IrKAcs820vU6Wccs3mlbVnlpg+noLTVDXtsKHlMcUQLoChBhmiQkIhMWO0d4fRlnpJ hOKhAsj+lUM8qHYP2T8epWW1+JpQeIQvr7Ojb0Scw9tm1aD7lIeeQ4kp6VXZITwGtry4 kJ0WpLKKIlI4Wqo8PmQ0gb9sI4IXZpbJQm8NRQKL2SM2mcSizQ/PSHC6iWSP+PFVHN6P HIRPdrd4oiGueyZjDlDmq60OTIAenzOj48KOGBES/0E5AOLvdTDVuB5/m5kB81a3Mq9M IQMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=xw3LEy+SZoKsr91Jwdzb7sTvyKPjaagDoUcGF1bAZ0s=; b=rF6k3/41apdZcoixLazC/tGiVWzp0gBSPkM34DMjBvVxD1NsAQhZJ8Re1cwkBlrNPO gT3d1oV0Fl2FH1Mi0MWtj4xUvUrDtV6/QNelhIpQEcYDnBqV97mG5yZN3Kh5bMlSsJyO eMmc0eS3effcDc/CrKFY32z8QiqZklX1Hryk2l55tw9iV8MdxZfrtg0u6I1hGrmufoTi cOhn1phfINL7W0J39BPfWipEP/i+9BYOZc7RF5LRuV9OGHDljc3bZdnJI6yomzShWURk Acj7DuBCtZsNnAo1gvzy0GDkq3VOvnTOUi4Rh9pvhxfhkdIemfWbIqw+eeGzeYHjIayS 3x5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170902834900b0018010c3d7e3si9202179pln.404.2023.01.10.06.18.53; Tue, 10 Jan 2023 06:19:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233175AbjAJNmp (ORCPT + 53 others); Tue, 10 Jan 2023 08:42:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232706AbjAJNmP (ORCPT ); Tue, 10 Jan 2023 08:42:15 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65AEA8FC1 for ; Tue, 10 Jan 2023 05:42:14 -0800 (PST) Received: from kwepemi500024.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NrsLX6g8KzqV3Z; Tue, 10 Jan 2023 21:37:24 +0800 (CST) Received: from [10.174.179.163] (10.174.179.163) by kwepemi500024.china.huawei.com (7.221.188.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 10 Jan 2023 21:42:09 +0800 Message-ID: <8fd825e3-494a-8a06-2b30-91458db2815b@huawei.com> Date: Tue, 10 Jan 2023 21:42:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH -v2] x86/boot/compressed: Register dummy NMI handler in EFI boot loader, to avoid kdump crashes Content-Language: en-US To: Borislav Petkov CC: Ingo Molnar , , , , , , , , , , , , , References: <20230110102745.2514694-1-zengheng4@huawei.com> <684a2472-f388-b2e1-4a7a-7bc9a07650b4@huawei.com> From: Zeng Heng In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.163] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500024.china.huawei.com (7.221.188.100) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/1/10 20:57, Borislav Petkov wrote: > On Tue, Jan 10, 2023 at 08:32:07PM +0800, Zeng Heng wrote: >> mce is registered on NMI handler by inject_init(). > That's a handler for the NMI raised by raise_mce(). That's for the injection > case, which is simulated. If you're fixing the injection case, then surely not > with a bogus boot NMI handler. OK, mce-injection is the simulated one. > >> Yes, exactly. The following procedure is like: >> >> panic() -> relocate_kernel() -> identity_mapped() -> x86 purgatory image -> >> EFI loader -> secondary kernel > I'm doubtful now as you're injecting errors so you're not really in #MC context > but in this contrived context which is actually an NMI one. So we need to think > about how to fix this case. > > Certainly not with an empty NMI handler... > > Regardless, we should do > > diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c > index 7832a69d170e..57fe376ed049 100644 > --- a/arch/x86/kernel/cpu/mce/core.c > +++ b/arch/x86/kernel/cpu/mce/core.c > @@ -286,6 +286,8 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) > if (!fake_panic) { > if (panic_timeout == 0) > panic_timeout = mca_cfg.panic_timeout; > + > + mce_wrmsrl(MSR_IA32_MCG_STATUS, 0); > panic(msg); > } else > pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg); > > so that we not run kexec in #MC context. > > Hmmm. I don't have ready test case for real MCE to verify whether it has exited #MC context before panic() or not. In mce-inject case that based on NMI, it doesn't work as mentioned indeed. B.R., Zeng Heng