From patchwork Thu Mar 2 05:24:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 63215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4063199wrd; Wed, 1 Mar 2023 21:52:25 -0800 (PST) X-Google-Smtp-Source: AK7set8vQr02k0Axw7lG3RgGNZ58r4s0H/435pamx0DnYeCdeu9T/L3pdwXSVE/luWSlF2tyqfca X-Received: by 2002:a17:907:80cd:b0:8ae:fa9f:d58e with SMTP id io13-20020a17090780cd00b008aefa9fd58emr15523887ejc.53.1677736345758; Wed, 01 Mar 2023 21:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677736345; cv=none; d=google.com; s=arc-20160816; b=whGhp+NEdCwsYQFs9iuEIvj7mvKdi1y1L2yBAcrLeOiBKeDANfplDXG4aTahKXBOJi /Ayue00jGmogmMnoT0TsfOwsKPvy/I6t+vSTr0rjdu3D9Lha53ciZTiPzHqXoNcGSJ04 keiV7kvdcz0v8CQ5RSJ17jNcl+msUO8h+wnUBThISHEdq3uxHx0BhKvVb4PQ/NxdOjak yNuJzarKZooVoWQebq75RbW8fIbGtWMbuaMcx2+uNTeSsVMji2iQDmCYgffrU0Ogf6sk sKhP9Nd7ggFw9zZWjvrt/9u/XmkSrwHwOrCHDqk4U140gDs46IQl/0wX8SURoVKBkqKP U0mg== 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=PJ6Xt3dKM+ctvjLuOs5bs1mcolBoe5WroUL0J4IZfftZIaYbZvVjcG92KktJJERKPa F1PXq0AhloTi7A4xLLQDkjU2RdSzTaxo4LkrFucMdh2CCTXqBRgjI6fzA64actWscx8W 3FmFj/lKJTcHNZSIdClnCXai8q1S/JP9OOFfgDhWdRjmn5+ivRddpfop+PRGvrKs2kJF k+v7Niq5WJzWe9JtO7g2ZLKOpvaQEOOHPkWxIXMG+8o6OKFwKvyQwXeTVx0+8EhFGWGU G8ws9renVyuBNuK8PagwjBzz9JEM9pOS4hBeuSsdnAHxfFPGKW7DIdvAbXVqEWpEUdLA ZmXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lf3UTBua; 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 re23-20020a170906d8d700b008de4a641ff4si6407849ejb.412.2023.03.01.21.52.01; Wed, 01 Mar 2023 21:52:25 -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=lf3UTBua; 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 S229916AbjCBFvH (ORCPT + 99 others); Thu, 2 Mar 2023 00:51:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjCBFux (ORCPT ); Thu, 2 Mar 2023 00:50:53 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B13A4AFE7; Wed, 1 Mar 2023 21:50:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677736252; x=1709272252; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y8+C0nkNS1GRT0vpQmI78TLcU0TSh7ChvDXpWBoU34k=; b=lf3UTBuaNQ4UC3hRSL9g25i0HubuI79ZeLF5Jxg3IHb6NLGLiX7u36Mz zv3RyJUI9lYHCy00Hh8BAjwDfd3x+GihEU/TvCOpiU9LsQoC441K1Lav+ ncjdIqmG/Tu7pK1L/ybnMVi/eFSh0+PJRAIjoxwCzlh31QN91g7vDUp6s vcrCTDLhl0Ojp2WRBlvUEoaTPqnkvWhBabtiBlwD8ZWIx2K0ravnPlhgp ioaQwg9gxRX+Q5WsgMc1x/GIWU2Bs50DaYDX9bxtYtC2WiKWtq6+TGERK 1pnp6T15LqAqbQ7VmNRPTGXYaYWGXDz4MTBzrh0BBDk7P3vrkJkW8mE9n Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="420887080" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="420887080" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 21:50:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="920530944" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="920530944" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 01 Mar 2023 21:50:49 -0800 From: Xin Li 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 v4 20/34] x86/fred: add a machine check entry stub for FRED Date: Wed, 1 Mar 2023 21:24:57 -0800 Message-Id: <20230302052511.1918-21-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302052511.1918-1-xin3.li@intel.com> References: <20230302052511.1918-1-xin3.li@intel.com> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759234066359577219?= X-GMAIL-MSGID: =?utf-8?q?1759234066359577219?= 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 Signed-off-by: Xin Li --- arch/x86/include/asm/fred.h | 1 + arch/x86/kernel/cpu/mce/core.c | 11 +++++++++++ 2 files changed, 12 insertions(+) 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 #include #include +#include #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)