From patchwork Wed Jan 31 07:21:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 194562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1725900dyb; Tue, 30 Jan 2024 23:34:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAo1XmT7A/Eh3cQVoSuRve+nuyvKbpctq6Jg2BBXIL2PlxlA9O08H4hnRfIzpbED92Ir1V X-Received: by 2002:a05:6a20:5498:b0:19c:943e:78f with SMTP id i24-20020a056a20549800b0019c943e078fmr893203pzk.17.1706686442275; Tue, 30 Jan 2024 23:34:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706686442; cv=pass; d=google.com; s=arc-20160816; b=N1SDIgoOZsjYPEnHEr4lgg5ucydjsiaeXXHW5KXGLmpLbwAxdSiIFXeLXAwy6CENsW Ao+J54E4n7LNlZTXD15fyA7/78mXpJao2U4WoQRauEtLoMmGrys8PAObzde+Em1eraoK VAw9BXoAALfyTRuTFsPWmezKsXiS0+oPIdMnSz2rox9Wv6fZ3DRMk5c6jmzB4mrIMy2u mWIu25bRmextMo7qMcCdIz6HG3YBDvsy3RSintIMZ7KGhSkHTM1Vb8owThWyOnbCJpYL v3E4zRldnl5Zf5/gc+RAPIMv81LDAKdhjq5TdjWIgYbXO/fOihjBZivIwzG4YsZcyHHx GMEw== 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=blkPyz8j7UfdQ2JBSA1Upp8rLU7BQRS90Sa9adYoXMU=; fh=mFnOsuHzELM2R/qcKDO7fsSVJNVsXkqjkxldIRPOGAk=; b=FoG3C7iP0O18XkfaJSjgVxK4CbA4SXIuSGrFmQ3HimBDMC9weQG1xNardI0Cd0yj9d HxMREkkoEtiqHyZ2yVUNMUQI7EjuYkRxJWMQC7Rg1Nt58/JPDvtwJ7tAQNhJUKFdXb2o ZZgRIqGLIWOHe7VX7HDput/h3dmp9SkxkJuChAKE/f10zqWy7S/hqdQP5UVXicTFyETu g9DKWKklQDJixVBG5pzFwPwH1Sg6bu225SEj9HlYHgNtT4QTL4ySXOuacAl4TwDHi9Ae lu02le8uPRLOjiJquhKGYbPBIrLsymVHdV9G5p3A49gG+FLbKqQUNB1UF03IE2cjqt1u gkOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fUC2xB4o; 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-45918-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45918-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCWoDqPyfU3H/4+XQuD/uF7AWn1x1NCcGN8E7giolSiNZgSj//2prHWv3/dol7tt22KIt5wv6GA+GnthX2VwlPg7qZidMg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p1-20020a170902e74100b001d8ec338b0bsi4601838plf.37.2024.01.30.23.34.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 23:34:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45918-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fUC2xB4o; 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-45918-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45918-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 89518B21C22 for ; Wed, 31 Jan 2024 07:27:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E91B283CC6; Wed, 31 Jan 2024 07:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fUC2xB4o"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZRvo7zji" 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 0BE2F7F482; Wed, 31 Jan 2024 07:21:30 +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=1706685692; cv=none; b=Q7UVeZefwUtoVxx18s8syfCBpio3dOqmewIKtf68HVEa5HZbKdZAuHkVWLiYLpx1JWYjCkn/83h5OQ87UcByJ0ddqMGCddJVF7DdxrMBSALlSp07X3+uyXUnXksvP2i1V83D1jwXO0mjNiJm6fwPPidMafUgfdBUiQfp57BrLZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706685692; c=relaxed/simple; bh=+pATjSzwErfM3A7JywPE5FqmSPto4bh7XvANozFZDOY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=dMzczrhJn6e7eYH6W4w9T1mPfR6HLjoi4fmoktP6LBk+3cRAY010wC4zytW2DPisyaAlJSDOe8h1rrvIbWhH5rMwaqDmtYBOQ7rEqz9N3/tBb4X0bdqYs2J8u32AtWVeAZyyP9a5KpeHRL47KHCiaTKGsqeYFqQxmQUx/FB/S7U= 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=fUC2xB4o; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ZRvo7zji; 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 07:21:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706685689; 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=blkPyz8j7UfdQ2JBSA1Upp8rLU7BQRS90Sa9adYoXMU=; b=fUC2xB4olV3DabMwxhKlUH1Mimnr9/LpMlXcMTXboNEXUOj0d5g7h7k6tZK6sy76wLWgxJ pReNMgywpYZvTpwuDlrZ7xL1sSsgbN1dVI/osT9E7v0Mc7kpbTiszUSxRt1pfK9O3HV3/A E2hqT5ugpdtQLOa3o+xeyYhB/cY+qZPill0CTPY79iGEVU0hAGOdm3k9j37hswDdRaVmL5 uw/f2k+TULVid2lCI4bdWOfmxJKimD7jf9T2Jz2diGdPt0suItAsVFu+eDE2kIA/NaVsDo UlvpVM944hLtcjlP69kE5M3ed9nQYAguQcTnBzO29sULIKnL9053nESZU98ouw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706685689; 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=blkPyz8j7UfdQ2JBSA1Upp8rLU7BQRS90Sa9adYoXMU=; b=ZRvo7zjiImFVbUanN+NdS761T4FRNh89ht3YJiOAZj1/oavKsJzOku/6jhMnF6Q8t1UGUU fyQru09t92N6esAA== 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 fred= cmdline param Cc: Xin Li , Thomas Gleixner , "Borislav Petkov (AMD)" , Shan Kang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231205105030.8698-9-xin3.li@intel.com> References: <20231205105030.8698-9-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: <170668568846.398.2224540814571562742.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789590442598941426 X-GMAIL-MSGID: 1789590442598941426 The following commit has been merged into the x86/fred branch of tip: Commit-ID: 3810da12710aaa05c6101418675c923642a80c0c Gitweb: https://git.kernel.org/tip/3810da12710aaa05c6101418675c923642a80c0c Author: Xin Li AuthorDate: Tue, 05 Dec 2023 02:49:57 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 30 Jan 2024 18:19:20 +01:00 x86/fred: Add a fred= cmdline param Let command line option "fred" accept multiple options to make it easier to tweak its behavior. Currently, two options 'on' and 'off' are allowed, and the default behavior is to disable FRED. To enable FRED, append "fred=on" to the kernel command line. [ bp: Use cpu_feature_enabled(), touch ups. ] 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-9-xin3.li@intel.com --- Documentation/admin-guide/kernel-parameters.txt | 6 ++++- arch/x86/kernel/traps.c | 26 ++++++++++++++++- 2 files changed, 32 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 31b3a25..d6ea4f4 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1539,6 +1539,12 @@ Warning: use of this parameter will taint the kernel and may cause unknown problems. + fred= [X86-64] + Enable/disable Flexible Return and Event Delivery. + Format: { on | off } + on: enable FRED when it's present. + off: disable FRED, the default setting. + ftrace=[tracer] [FTRACE] will set and start the specified tracer as early as possible in order to facilitate early diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index c3b2f86..3c37489 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -1369,8 +1369,34 @@ DEFINE_IDTENTRY_SW(iret_error) } #endif +/* Do not enable FRED by default yet. */ +static bool enable_fred __ro_after_init = false; + +#ifdef CONFIG_X86_FRED +static int __init fred_setup(char *str) +{ + if (!str) + return -EINVAL; + + if (!cpu_feature_enabled(X86_FEATURE_FRED)) + return 0; + + if (!strcmp(str, "on")) + enable_fred = true; + else if (!strcmp(str, "off")) + enable_fred = false; + else + pr_warn("invalid FRED option: 'fred=%s'\n", str); + return 0; +} +early_param("fred", fred_setup); +#endif + void __init trap_init(void) { + if (cpu_feature_enabled(X86_FEATURE_FRED) && !enable_fred) + setup_clear_cpu_cap(X86_FEATURE_FRED); + /* Init cpu_entry_area before IST entries are set up */ setup_cpu_entry_areas();