Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1920384rdb; Wed, 31 Jan 2024 13:16:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBXD4+oh+dC+PjFAt/63I4wHv9GW5eob1o8KxrY5NENJdmYN1cyqm4OWy4QjAS2kb5tKv5 X-Received: by 2002:a05:622a:1b0b:b0:42a:30c6:4c4b with SMTP id bb11-20020a05622a1b0b00b0042a30c64c4bmr449674qtb.54.1706735815176; Wed, 31 Jan 2024 13:16:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706735815; cv=pass; d=google.com; s=arc-20160816; b=pc4AJFO7cU46ecJya/LnUng1HKn03TBtYkdzpwlEB2fTpHhKY4vSGgHpUsaUJOwBCv N611ix2wP0fmtUkownTttGs7L1Ehm3yqDjgfMBIQxrswNtd4I/7IgJZvqEjJCj9gSu+4 Khd6LJNe5B/8ZacETgRTQf4ELaBKVqv59MJD7sVyx45iK7DJaH7gTFeiwVsPfUHRpEK2 WMqwq4mp5HxFEvqf+Wt2C4/efVDAH3g0yIAra7hRmVYOhsOpc0a7AbBv0aWzVY89+YU/ ezf5wBBkzzWJE735O665Q2FjZcvkl4OtlqZuZjcoOEdeg8L14siydC08K+M6ppe/QIrZ JpiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=cAsKqSZQiMmyEBIxsOBVerb+//M+p5CBe7734Eoe210=; fh=81fq3MUhHtvTM9HOFF7FgmWnQ92rbEfPbJp7rjOPyWI=; b=SfjtyQfQ19JHaMQEUMl+rHFhdvCd5iyAwzQr9LP9qsq/jn86SEsKqaL/4h3hiWYNNR +Y2NA3IYEp5glCjWBFhHQfySFJx89LNo6FUdCVSo4FsHHuHPnyPeymebf88jiwAVTjBQ Cc9ZJFbYc08vGu7TyGJN8kVwcRsg8oqWXRbecjLNLWoWxtZlWhKmth1iOMnPLfXDRsWW oGmQuzS0ks7RcNbasD+52HWQig2y5zAFIej0ksMnNJaHiJrBERZ9rD2DZsT6tAXXHmE1 BdWJXlJwEIV+X4xcuEQAytW++vJcU66T/+BvLHO+EdyQ9KkyCYBog8PGpKUBIVSAherC +HMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wEGEXbMQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-47126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCWjH7p0j5wAJYoUixMV9jx6SN9Evr9CO1Gyjyp2YWS6qdGRdHnQH24z8tRdvEkU7orYR1y+x7KTUIyRPT2/ye914ewoRsZR5x4Opmp12w== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h17-20020a05622a171100b0042be5cbccdasi2279851qtk.308.2024.01.31.13.16.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 13:16:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wEGEXbMQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-47126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E4FEB1C2284E for ; Wed, 31 Jan 2024 21:16:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6ED423AC01; Wed, 31 Jan 2024 21:14:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wEGEXbMQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/XYa1Cmz" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 818A13A1AF; Wed, 31 Jan 2024 21:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706735689; cv=none; b=D6VZwhCjbcWx3+b09QBjEYwhR/NaG9fODaXj9dDS1S+io8csYL7mQIg4xKM3jVZmzwmeCalnLcjxKKinrnYgl71kkfC4nOdGOCGUVSmCKR5DDlZKOSpe+azvV+v64/ykmm9VZF3Fm3ZfzZVdCm09l8B0vF2nV2n9T7TW+k74OP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706735689; c=relaxed/simple; bh=Ypu/2eUmvIVBmgoTBS3XLAy0cqa61KOQCiNVBJZFIxs=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=UlQeoxoNVQwWYWYp+X9gP5gk+km6mNsOyaIoX0ncP+UQSoz2eJQJJuYtDdvVtx8QAvLEstN3iPeUJHnEaV0Eq6D6WBYUWbczL0bPxU9rncf2CZIMVGUT35Vr0cGr3ne7Hoz2EOLVAWpYS7QTsT/m91bd6dNaVZHxJRSf9fa00ng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wEGEXbMQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/XYa1Cmz; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Wed, 31 Jan 2024 21:14:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706735685; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cAsKqSZQiMmyEBIxsOBVerb+//M+p5CBe7734Eoe210=; b=wEGEXbMQYDxbekMpNs6dTsmUjvG1TqZau2jrNx1UqK6N34Cl7bVaJCCl3V2QutKw7KZ1Xb WuV0/KwpAiRnmwWUFu0++rRy10SG6XwkEAPA9JtakpxshNPuqbVD8ju4IBAZSpr1+EyYkP FzqUcsyWeyZbeu8fdoQuaRU9tjKjVzX2LJxFC45B2BjRdz6yTWKY/oLF+8D2SQEDQ5YGZX TWokSZGHf1IFPoYiDBAZEPFS7unPeoHOUVXZNMuFnP2zqsKXpGpR9ywEir2z/TDSixHZFw L3goHyfKxHa8JIHGSrQwov5wUtq4cj8nDlELK4qZK642qcqJXdTFfoqaNGnmDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706735685; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cAsKqSZQiMmyEBIxsOBVerb+//M+p5CBe7734Eoe210=; b=/XYa1CmzO1/5C3NmtPPb48AUIct7ap6vGEFSKKQYdNtYerKlMvwld84BBcqLzkrxQHmeLk z2nFSyK5GQ7JJJAA== From: "tip-bot2 for Xin Li" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fred] x86/fred: Add a machine check entry stub for FRED Cc: Xin Li , Thomas Gleixner , "Borislav Petkov (AMD)" , Shan Kang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231205105030.8698-26-xin3.li@intel.com> References: <20231205105030.8698-26-xin3.li@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170673568505.398.17054166707598114339.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/fred branch of tip: Commit-ID: ffa4901f0e004e1a0a4e18a2452a1fcc27277cc0 Gitweb: https://git.kernel.org/tip/ffa4901f0e004e1a0a4e18a2452a1fcc27277cc0 Author: Xin Li AuthorDate: Tue, 05 Dec 2023 02:50:14 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 31 Jan 2024 22:02:25 +01:00 x86/fred: Add a machine check entry stub for FRED 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 the FRED machine check entry stub doesn't do stack switch. Signed-off-by: Xin Li Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Tested-by: Shan Kang Link: https://lore.kernel.org/r/20231205105030.8698-26-xin3.li@intel.com --- 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 bc39252..04acdc3 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -2166,6 +2167,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)