From patchwork Fri Jan 6 08:56:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 40032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp728824wrt; Fri, 6 Jan 2023 01:24:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXupD1gnbDiFAXG+G+MFfUdemh8BtOticT3tYNEuYdttfmJSSNHc+MYtRO0l1tU7/u3DBVED X-Received: by 2002:a17:906:7188:b0:7c0:f117:6990 with SMTP id h8-20020a170906718800b007c0f1176990mr47222492ejk.41.1672997050400; Fri, 06 Jan 2023 01:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672997050; cv=none; d=google.com; s=arc-20160816; b=We1kt1fAgG5+3OKrt5ftL4yY2IdSbqrkrnM/R5kiI2ROeWofcnjigEhZleGFMxZ/7s 2vsD9zxBl1uXH3DbirqV3GbsiU4v6zqrsytHUaMGBxkxN1/pWfG12z8Hxh5MQgXNkuk5 TaAWvQXkq/vkQWjI7cHjovMajG/siuY/+VHS7Z7l01O9eYGNndanUGCrD5hSr9N7chkx XfBIO+0G5GdJDuCq+BbfCV/JzG5rzru1lrRhh0sHBN30uF8zZWPYjqYlXQVuW1AWk7op 8RDWTyFpBGqdbXHLRhj4gjltHus3AcFZ9etfCFFgt8cfVdqDT13T585rsRMzuGCDLH5W K2Dg== 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=et2RSemdnbIlYf9lPENu5I3i36nGWT3zJbSVW/vMVZQ=; b=lt5auaejMcPZ09/FX4P0CCd1j3sjK0thi+9ZSsxXrjFK9VtVq8yajzASj7iJD3bdG+ Cl3wo7SE0T8lEGRezRI5vnNre+BeE37qdphSqvOA/UpayeUTmAfV5S9z7K9WX3XO8FgN EJ1kq0+Nh3WPVpAU6JnkPAgtfvqDnuKOioXato3X3Q+2tqUmkAWtlApzyNi47iyrjlx3 eAQpcMCO8nu6H/xpQ+jPS+ffwnjxzD1e0zkXFHxIq1db4uNqZEqAoXoTI6pxQCMFKPLE ywzvlMIJ1iX3eDP1cKQY8uYQJbaNf1Lf73roRuA7B/5Cbd3juQhDz62omQqK1Nsv+9UN LwwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k9RwTEr0; 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 g14-20020a1709065d0e00b0080a15fe49a5si1018740ejt.571.2023.01.06.01.23.46; Fri, 06 Jan 2023 01:24:10 -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=k9RwTEr0; 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 S234106AbjAFJW0 (ORCPT + 99 others); Fri, 6 Jan 2023 04:22:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233050AbjAFJUX (ORCPT ); Fri, 6 Jan 2023 04:20:23 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7574E6B5DD; Fri, 6 Jan 2023 01:20:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672996822; x=1704532822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E/FeNV+3qBVGEK0P7SnzT+Yj1OApYKW6UTscZQGZuUQ=; b=k9RwTEr0bAXzRJ0h4zkmA7lOtjRHHTD67oBGcmCxFwm3hKvW+mfSK+eD dOAwBXXzDR16p/42EKdaMmVLatVVcs+G5PZ2760gTOuacUHjyFM3BrzvF 5Rv2zqsjbC06rPeXUoGhzHNrP5fCxsAMeVotMh+4x2Eyt+1NlbL7O7ukb zgG3ykyr3gEl/AKsundJpaTWcNZEYL9Y0YhKrrmmp5c67D3PgROBU7Tra 2+V0aa/PkUcxaQHjKIK1PV1ZMcNBiBOXOGJ/F+cKVu9/7CVjiFPxY7AJ0 RYY+VmgMwb9iSdx734LoQI9fxhfM923pUyuX6u9xlw5AuajRARcCKK4j9 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="322511558" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="322511558" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 01:20:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="719139417" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="719139417" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga008.fm.intel.com with ESMTP; 06 Jan 2023 01:20:15 -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: [RFC PATCH v2 20/32] x86/fred: add a machine check entry stub for FRED Date: Fri, 6 Jan 2023 00:56:05 -0800 Message-Id: <20230106085617.17248-21-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230106085617.17248-1-xin3.li@intel.com> References: <20230106085617.17248-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?1754264555262763130?= X-GMAIL-MSGID: =?utf-8?q?1754264555262763130?= Add a machine check entry stub for FRED. Unlike IDT, no need to save/restore dr7 in FRED machine check handler. 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 753ae2adf422..3d6c5c063eef 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 2c8ec5c71712..0186c9b39f5f 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" @@ -2121,6 +2122,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)