Message ID | 20230923094212.26520-28-xin3.li@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp262835vqu; Sat, 23 Sep 2023 09:17:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1SixE+rWKGahcvebZln9nN++oCf20yl4E0YCk2f0+fN3X6VAXBuNkDbgFejJ9iyZ6UNcp X-Received: by 2002:a05:6a20:2583:b0:155:1710:664a with SMTP id k3-20020a056a20258300b001551710664amr4063553pzd.18.1695485845993; Sat, 23 Sep 2023 09:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695485845; cv=none; d=google.com; s=arc-20160816; b=uNFTGEGwXdPA0o28j7Byvq6elrKWr1iWOU9OKM28AV0UynmI+6NW2gldB7DmmL0RsO FKAS6RIBSv3zYCYmJ8gPSg8Jq9EJelV3WKhC40DaCK3YdSA4d2MeIVcEWVYfUsxGnGBy /3s798Lnx5+6ikz3W5kH3svOxNjNLeyeykLSq5+C0T5aca1Wa3uc0lyLxnT3NEo7ER9p rfdQqJ4goWU4ypqbV1MbvbVD5/B6M3sww0JHXQWt+ohJ5M2WzmAAttdFb5kw64nFn4Jr O8lQQS3xRxNsVTs/+58bh0gzdsFfOcCn4zqexuCkEPcBLBQ3onOqhHVJQP6hSwtV0oBZ phfA== 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=RYtazmEiUZouwK5sDJ9DS0fjOpmsfVVL+4zG0pg0LkE=; fh=Tb1p8S3iOxe/kX/WSNC3xEJzSVgGJ5DaxSrKb+pzH+4=; b=rp+cZDoIcpDrel8BzCJ27sI+z2W2KG28QXIXpDZUqqsKMQYS8aV0fOlC+Nc/SKULUC l0n3QMg3NOxQdvZMzA15Qri2ZRIkyzeIcBbvkJ2ii3hicm6zySGHgduBoAEd5+LmtFVD hxTZbVJNC26ibbaqWSX05/ZAzmtOWRFrJDKyoJ2V3dO/G0qRilvm6eJgYEmarTM6oNA3 oZQJtj/6z2OLxeVh9GqgD2jP0W9Z6ycOA+AHxTu3DPrY/NvaoEjsNGASglf6qSNpCeTs oGMW4NaTlxxhTo3KcEOu0St0oJheVRkSFgrLvPWtZmj4I0VwwfS3jwIjyAaagudEQr07 cI2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LZ2QO50Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ei16-20020a056a0080d000b00690c1e51cdfsi5853988pfb.188.2023.09.23.09.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 09:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LZ2QO50Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A4D6C867FEB0; Sat, 23 Sep 2023 03:13:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbjIWKNY (ORCPT <rfc822;chrisfriedt@gmail.com> + 29 others); Sat, 23 Sep 2023 06:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbjIWKMD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 23 Sep 2023 06:12:03 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 455E5CDF; Sat, 23 Sep 2023 03:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695463912; x=1726999912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bNtEfhEic2/4eI6U3F6LZD3GtdQN7TZ08d/4AOd+L9I=; b=LZ2QO50YfqdDo8MkxH7jn0cK9EzSuhuOH0Liq8Ra7laGgJV7BFrLvuWl 5ck1IsGyzIYRExmfyAhQ+Np1MkhaCqbwV5hCpRg/4RmtJcKhzewsFR+BQ HvsQMGqpdeutNBdeoLotc22LW+zOBTxNbIdzWRYKUK+sAthn8iil/M8wo oRa4ZMrcRqwnx1/3B5UqTIm73vkbGSDY/FkC7V2rfXftOAf4ukNvTZTDT L+aUA9o3YbVNQ8XlAS/HTEgWI9y1H+H/errtdLfVo5TYuAj1ncCgOxifO SfJ23tBhmkeVnFxQbrAqWqAaQfrtTGCTS7DfVmlIymV9JpAtEHLl3iZFI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="447492399" X-IronPort-AV: E=Sophos;i="6.03,171,1694761200"; d="scan'208";a="447492399" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2023 03:11:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="813388196" X-IronPort-AV: E=Sophos;i="6.03,171,1694761200"; d="scan'208";a="813388196" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga008.fm.intel.com with ESMTP; 23 Sep 2023 03:11:49 -0700 From: Xin Li <xin3.li@intel.com> To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, pbonzini@redhat.com, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com, nik.borisov@suse.com Subject: [PATCH v11 27/37] x86/fred: Add a machine check entry stub for FRED Date: Sat, 23 Sep 2023 02:42:02 -0700 Message-Id: <20230923094212.26520-28-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923094212.26520-1-xin3.li@intel.com> References: <20230923094212.26520-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 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 23 Sep 2023 03:13:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777845766019966261 X-GMAIL-MSGID: 1777845766019966261 |
Series |
x86: enable FRED for x86-64
|
|
Commit Message
Li, Xin3
Sept. 23, 2023, 9:42 a.m. UTC
Like #DB, when occurred on different ring level, i.e., from user or kernel context, #MCE needs to be handled on different stack: User #MCE on current task stack, while kernel #MCE on a dedicated stack. This is exactly how FRED event delivery invokes an exception handler: ring 3 event on level 0 stack, i.e., current task stack; ring 0 event on the #MCE dedicated stack specified in the IA32_FRED_STKLVLS MSR. So unlike IDT, the FRED machine check entry stub doesn't do stack switch. Tested-by: Shan Kang <shan.kang@intel.com> Signed-off-by: Xin Li <xin3.li@intel.com> --- Changes since v5: * Disallow #DB inside #MCE for robustness sake (Peter Zijlstra). --- arch/x86/kernel/cpu/mce/core.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 6f35f724cc14..da0a4a102afe 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" @@ -2144,6 +2145,31 @@ DEFINE_IDTENTRY_MCE_USER(exc_machine_check) exc_machine_check_user(regs); local_db_restore(dr7); } + +#ifdef CONFIG_X86_FRED +/* + * When occurred on different ring level, i.e., from user or kernel + * context, #MCE needs to be handled on different stack: User #MCE + * on current task stack, while kernel #MCE on a dedicated stack. + * + * This is exactly how FRED event delivery invokes an exception + * handler: ring 3 event on level 0 stack, i.e., current task stack; + * ring 0 event on the #MCE dedicated stack specified in the + * IA32_FRED_STKLVLS MSR. So unlike IDT, the FRED machine check entry + * stub doesn't do stack switch. + */ +DEFINE_FREDENTRY_MCE(exc_machine_check) +{ + unsigned long dr7; + + dr7 = local_db_save(); + if (user_mode(regs)) + exc_machine_check_user(regs); + else + exc_machine_check_kernel(regs); + local_db_restore(dr7); +} +#endif #else /* 32bit unified entry point */ DEFINE_IDTENTRY_RAW(exc_machine_check)