From patchwork Mon Jul 31 06:33:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 128432 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1867193vqg; Mon, 31 Jul 2023 01:14:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlFCib+VF0plxHb7Zhw6e+b+XESX0JIHVI2QN3kg2lfWr6+NA+OyWglaFUnt+Y65fhVPHt0a X-Received: by 2002:a05:6a00:3a27:b0:671:4b06:4ea7 with SMTP id fj39-20020a056a003a2700b006714b064ea7mr10475597pfb.15.1690791247101; Mon, 31 Jul 2023 01:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690791247; cv=none; d=google.com; s=arc-20160816; b=rtOfIbOzP89uTzVfQmVM8RlbPofeCwfg/dEfcanT7OqoLaGACh0WaMv7DuSow4ZXlR fqJ5BPlsSID/TQtiFokbidDRgAG8FYtn3YpefxWRsGQe25WMiRlk303TzaKH4DYD6f4Q J8znqD4gBxn6drcdF15LbSdhYnaFxBkmJvCregS8/XkTKr7gXr2q0QkkQY0GbHUGXDzs yCh/8PJN+xn/kz6sUyHHcRUobG16eNyI7js1mI0+r2ocef23j7d92ukRl3EYHkbrSZET sKIAAqTxqQU4ysufoiE31/2y7NFFeG17N/vVF4Url7UrwH7vgG90hc/6KME5Aci3oBVv ustg== 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=EPPzUq6b5YB4Tkg967rF0WqUxHdV7LKbVYRBw3eSgDk=; fh=runz8kYc7mvoALl4f6YJmLswtUHBUyF5+hFgjyimmLU=; b=aGv/vJ6U+0w3If59Dg93V3f9jZSaDhD2lde/5FY58FPwVx8hgcUCZ2CzsgnLUurI/B hobJK0+Bdx6gjFWYpATgqh45rWeGBE+45nBCuMApd6BR6Jm57RigJacd6EOqRgdZQO53 o9F2GjSkYA3TDWayGXbIkOHWpYYPjEjm66PeSba1B84gKLlFiB+YiSs2F+KycAXVdc1Y MFd7urRqos+QGFQnYDBRQYslbE8bEUv+VSYI/4o0M+WoMz4DX1w8ZH3MEvUdDWyuS4c5 ldp3OKUHMFyVhgso8RSWds/ScXunYr0w5QDpCQYEyCzQD6548HFKnIaHcXT2gVhgbD6A KK3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Lw2pc903; 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 cp20-20020a056a00349400b00666ad95e625si2355236pfb.337.2023.07.31.01.13.54; Mon, 31 Jul 2023 01:14:07 -0700 (PDT) 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=Lw2pc903; 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 S231282AbjGaHE6 (ORCPT + 99 others); Mon, 31 Jul 2023 03:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbjGaHEW (ORCPT ); Mon, 31 Jul 2023 03:04:22 -0400 Received: from mgamail.intel.com (unknown [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA3762121; Mon, 31 Jul 2023 00:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690786975; x=1722322975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dQPbDjEqQWsCazdenr4wm1/cp/YJX7zOnAx3X5niG4Q=; b=Lw2pc903eR3UGc6g01tROhrFb+5GwhmXEOuvGxEvrHRuYXMIEFsUq8WA jg1EOxSF3Ifo0r0yvk29eHO6TH8RecOVlSA1BJGtlYxGh2EOs0ocKHCPn Z5FcCH/kk7OUZbs3+9lPyFjDzQ5/d24AylkpyQbi9L/7dgF5on7qxPAFX h8mORaX57azrlYcnd299iImF5JjlNT4n8n8zBxfsmByEo2Bh8LF9C80ox yF1Kj4aWmcJHdu4t1J8Luyg4mLebj7/stiHFZYROURlTtVaenbddzsmJQ WO05eyx/DLaP2iNgaJm1FwwAFFax4+Tv6WMCQaaU+phJtDK16x1aKQ+FF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10787"; a="371649313" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="371649313" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 00:02:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="871543470" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga001.fm.intel.com with ESMTP; 31 Jul 2023 00:02:12 -0700 From: Xin Li 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: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Andy Lutomirski , Oleg Nesterov , Tony Luck , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Sean Christopherson , Peter Zijlstra , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Josh Poimboeuf , "Paul E . McKenney" , Catalin Marinas , Randy Dunlap , Steven Rostedt , Kim Phillips , Xin Li , Hyeonggon Yoo <42.hyeyoo@gmail.com>, "Liam R . Howlett" , Sebastian Reichel , "Kirill A . Shutemov" , Suren Baghdasaryan , Pawan Gupta , Jiaxi Chen , Babu Moger , Jim Mattson , Sandipan Das , Lai Jiangshan , Hans de Goede , Reinette Chatre , Daniel Sneddon , Breno Leitao , Nikunj A Dadhania , Brian Gerst , Sami Tolvanen , Alexander Potapenko , Andrew Morton , Arnd Bergmann , "Eric W . Biederman" , Kees Cook , Masami Hiramatsu , Masahiro Yamada , Ze Gao , Fei Li , Conghui , Ashok Raj , "Jason A . Donenfeld" , Mark Rutland , Jacob Pan , Jiapeng Chong , Jane Malalane , David Woodhouse , Boris Ostrovsky , Arnaldo Carvalho de Melo , Yantengsi , Christophe Leroy , Sathvika Vasireddy Subject: [PATCH v9 21/36] x86/fred: Add a machine check entry stub for FRED Date: Sun, 30 Jul 2023 23:33:02 -0700 Message-Id: <20230731063317.3720-22-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230731063317.3720-1-xin3.li@intel.com> References: <20230731063317.3720-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1772923122878736273 X-GMAIL-MSGID: 1772923122878736273 Add a machine check entry stub for FRED. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v5: * Disallow #DB inside #MCE for robustness sake (Peter Zijlstra). --- arch/x86/include/asm/fred.h | 1 + arch/x86/kernel/cpu/mce/core.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/x86/include/asm/fred.h b/arch/x86/include/asm/fred.h index 2a7c47dfd733..f559dd9dc4f2 100644 --- a/arch/x86/include/asm/fred.h +++ b/arch/x86/include/asm/fred.h @@ -115,6 +115,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 b8ad5a5b4026..98456e20f155 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" @@ -2118,6 +2119,20 @@ 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) +{ + 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)