Message ID | 20230307023946.14516-21-xin3.li@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2215311wrd; Mon, 6 Mar 2023 19:23:38 -0800 (PST) X-Google-Smtp-Source: AK7set+JMyVyKTGkuz/8sLawqBac2eJs7BqEFmzJwvXljKP4N7Ze6qqnRUElo13F0Oq/WR9r/QZw X-Received: by 2002:a05:6a20:8f08:b0:c7:6a98:5bdc with SMTP id b8-20020a056a208f0800b000c76a985bdcmr18758598pzk.16.1678159418286; Mon, 06 Mar 2023 19:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678159418; cv=none; d=google.com; s=arc-20160816; b=FlEMQYrUMF4P6QyQ+fgY98+8KDB9cxu6Dagb9WG6mmQwYki3eWwA+4lSYuz2olAD82 arKWN45J7lJt4yKgqVM7iETDIa5CpRbZOhD0wcmMMVxKdH1VGMDxyqsStiu3DBDqKz4K 91vUp8uWlFlaNIaB9DB9gEfzTyM1AqNqHtECwexi+0PktQGVLNRsoADKuWx25VOnLYiN Wv3+gA61BABvq0o0JBjnfZGO6ejH1To120hW7esx3ruCDWMPqz5EsXC+vV8YRvb62Z3O xH2h7uKMl+q5yCaWvB686/SsLcan9Ozr/mSFoogEEqtd8iEZbkXR8coMgl0nfZ1AXN3r 8LUA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=62cabqeBtlyHMtRghTLfhd1jpTyyJqzc9Z9q/A5AdvQ=; b=FfvEDcxj/Qm+kX5JkcdNH2JlNU5pypSZo9j4WooOjXNea9dGMsN1JSOfT1mWuj4KbP P8wSjftMiT5A2N0MmxskYRTWEJcxtUPt+fuUyVxQAl4dJhFxF2J2G7twwon7eweSUnwa I9Fwh3xGo+ByWaw/bxDpZ2HfYg5J6Ur99aDHxEmPOKdoe8E4kZhho605+htdpM+/p4Qw 6oGBJfltgKkqaawz1BuDA+oWXXNEOsxe1KmNTInXCJNhCUYsG6KcZtGnZITODf3cMJRO TQUp/C6rX8k0OvCKxKDNDpEVNMEOuIKfsb5ecsgYt4NR22FHL/gtcyN0//afG82rIeQq nMEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cSNwpb6h; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d144-20020a621d96000000b005a8da0b042bsi10781095pfd.378.2023.03.06.19.23.25; Mon, 06 Mar 2023 19:23:38 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=cSNwpb6h; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjCGDGx (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 22:06:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbjCGDGA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 22:06:00 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCC5A80E16; Mon, 6 Mar 2023 19:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678158331; x=1709694331; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y8+C0nkNS1GRT0vpQmI78TLcU0TSh7ChvDXpWBoU34k=; b=cSNwpb6hv1Tte6ZVpw8etzk4/PBVO4fSKejgAwXHs9RyM3FVlijrUP2n lX+cpFZblSEE8At0il4LV52gb5TslkquqExGrvWYWhP22jy+APNVpbp/i eEIADWxfMl8uI3YjSf1j9C/Liv6hGr0kQ35Fef7/N/NINNDoaRydooxqf yqwne5awFi3DTNBYJH7yKh56HyUmMxNBMLDHcqCNbIKo+Z9aMa6WJDasi iYNEMd+x1QCA46ewJ+z0L9TfTUfq/VQbgl9b3GkQPDBy99xHQJ9BVGAoF h9jWErd5LRYQjL9fe7rIw5A6qXmZERXrD8mtfKzxg9KUtwn0k7N6cXKCt w==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="338072497" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="338072497" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 19:05:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="676409852" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="676409852" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga002.jf.intel.com with ESMTP; 06 Mar 2023 19:05:18 -0800 From: Xin Li <xin3.li@intel.com> To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, peterz@infradead.org, andrew.cooper3@citrix.com, seanjc@google.com, pbonzini@redhat.com, ravi.v.shankar@intel.com Subject: [PATCH v5 20/34] x86/fred: add a machine check entry stub for FRED Date: Mon, 6 Mar 2023 18:39:32 -0800 Message-Id: <20230307023946.14516-21-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307023946.14516-1-xin3.li@intel.com> References: <20230307023946.14516-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759677690047734715?= X-GMAIL-MSGID: =?utf-8?q?1759677690047734715?= |
Series |
x86: enable FRED for x86-64
|
|
Commit Message
Li, Xin3
March 7, 2023, 2:39 a.m. UTC
Add a machine check entry stub for FRED. Unlike IDT, no need to save/restore dr7 in FRED machine check handler. Tested-by: Shan Kang <shan.kang@intel.com> Signed-off-by: Xin Li <xin3.li@intel.com> --- arch/x86/include/asm/fred.h | 1 + arch/x86/kernel/cpu/mce/core.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
Comments
On Mon, Mar 06, 2023 at 06:39:32PM -0800, Xin Li wrote: > Add a machine check entry stub for FRED. > > Unlike IDT, no need to save/restore dr7 in FRED machine check handler. Given how fragile MCE is, the question should be, do we ever want hw breakpoints to happen while it is running? If the hw-breakpoint handler trips on the same memory fail that got us into the mce the first time, we're dead.
> > Unlike IDT, no need to save/restore dr7 in FRED machine check handler. > > Given how fragile MCE is, the question should be, do we ever want hw > breakpoints to happen while it is running? HW breakpoints still work if they are properly configured. > If the hw-breakpoint handler trips on the same memory fail that got us into the > mce the first time, we're dead. Right. Unless the MCIP bit is turned off any subsequent #MC goes to shutdown ("machine is screwed"). It's the kernel debugger's responsibility to decide how to proceed in such cases. But if the kernel debugger itself is in a screwed memory region, we are soooooo dead. Thanks! Xin
On Tue, Mar 21, 2023 at 12:04:47AM +0000, Li, Xin3 wrote: > > > Unlike IDT, no need to save/restore dr7 in FRED machine check handler. > > > > Given how fragile MCE is, the question should be, do we ever want hw > > breakpoints to happen while it is running? > > HW breakpoints still work if they are properly configured. > > > If the hw-breakpoint handler trips on the same memory fail that got us into the > > mce the first time, we're dead. > > Right. > > Unless the MCIP bit is turned off any subsequent #MC goes to shutdown > ("machine is screwed"). > > It's the kernel debugger's responsibility to decide how to proceed in such > cases. But if the kernel debugger itself is in a screwed memory region, we > are soooooo dead. Yeah, so I would much prefer, for robustness sake, to start out with not allowing #DB in MCE -- much like today.
> On Tue, Mar 21, 2023 at 12:04:47AM +0000, Li, Xin3 wrote: > > > > Unlike IDT, no need to save/restore dr7 in FRED machine check handler. > > > > > > Given how fragile MCE is, the question should be, do we ever want hw > > > breakpoints to happen while it is running? > > > > HW breakpoints still work if they are properly configured. > > > > > If the hw-breakpoint handler trips on the same memory fail that got > > > us into the mce the first time, we're dead. > > > > Right. > > > > Unless the MCIP bit is turned off any subsequent #MC goes to shutdown > > ("machine is screwed"). > > > > It's the kernel debugger's responsibility to decide how to proceed in > > such cases. But if the kernel debugger itself is in a screwed memory > > region, we are soooooo dead. > > Yeah, so I would much prefer, for robustness sake, to start out with not allowing > #DB in MCE -- much like today. Will disable #DB inside #MCE then.
diff --git a/arch/x86/include/asm/fred.h b/arch/x86/include/asm/fred.h index f928a03082af..54746e8c0a17 100644 --- a/arch/x86/include/asm/fred.h +++ b/arch/x86/include/asm/fred.h @@ -97,6 +97,7 @@ typedef DECLARE_FRED_HANDLER((*fred_handler)); DECLARE_FRED_HANDLER(fred_exc_nmi); DECLARE_FRED_HANDLER(fred_exc_debug); DECLARE_FRED_HANDLER(fred_exc_page_fault); +DECLARE_FRED_HANDLER(fred_exc_machine_check); #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 7832a69d170e..26fa7fa44f30 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -52,6 +52,7 @@ #include <asm/mce.h> #include <asm/msr.h> #include <asm/reboot.h> +#include <asm/fred.h> #include "internal.h" @@ -2111,6 +2112,16 @@ DEFINE_IDTENTRY_MCE_USER(exc_machine_check) exc_machine_check_user(regs); local_db_restore(dr7); } + +#ifdef CONFIG_X86_FRED +DEFINE_FRED_HANDLER(fred_exc_machine_check) +{ + if (user_mode(regs)) + exc_machine_check_user(regs); + else + exc_machine_check_kernel(regs); +} +#endif #else /* 32bit unified entry point */ DEFINE_IDTENTRY_RAW(exc_machine_check)