From patchwork Wed Jan 31 07:21:26 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: 194555 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1723646dyb; Tue, 30 Jan 2024 23:27:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAvaEy4+tjGPcq+Q9/7/x8Tp8sOXVTNwbyJE6pLDAEDcHP777h+TtzmcejNU26JGhos7i7 X-Received: by 2002:a50:ed91:0:b0:55f:4ce3:5988 with SMTP id h17-20020a50ed91000000b0055f4ce35988mr451670edr.8.1706686036103; Tue, 30 Jan 2024 23:27:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706686036; cv=pass; d=google.com; s=arc-20160816; b=G438kBv3UAms8ywbgvQwr71GkopMNNd5tDUi7BDeghmkxdMv8MrO5wtscDzLOdkRbm UNaa0dAr4qErLl9No67N167uPuZxEIFqlAKfo7z8xDiq0yi4onJbNfr5aIAVpDsxTG0R aEGRcZ9WkU8sEbwIizqMOvgIneBa5GLhj9Q2R280xQfesq1RNKZpWixlclWvfuwxUbHB vgkGQ4cjggORkJcWXBOHICruwurywD+IwGBijpys9xyTm9JUN5iab9LBMEvti1ElI5ZI S7F/X1DOqX/NcbTq8voMeCOuf4roQoa5q/y8ShXbfKFMYcr6m05XKjdawd1h8yPAEQrK sMXw== 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=pbELyu7iGlzy7e/Az06OBENSg8wuqlswZAyHLgGayv0=; fh=Bk9kjDW0J81MQsWw7v1b3xyYugA7sYdBK4rNmVCmjU4=; b=LDRqnOyuOGHyKwsk0oEXxr91e/Ir6FMU7un0u7Vq8LEPRx2PoY6glzyBL/ehEluG2s f95q1Y6JyqxKQzJgCETEtflfW0cGqaKBQinP4U3v9n4Rc0k54w5I9+hQ+nqIE3H2uDlC b5JbPTdHq1s37cP9ObRdX6QkxO7YQDRQ1k5ZBW3gPG/PqtUglEy1qIYi69QUDp0Ppl2w Diri0/TvCO+BCeOfzlyRXwDRcEywwesqKYwCy4BXHJ1/4f6MMhVq9kkA0C5TwZb/yoaK yU1vSwHQ1uqpoEawwKKT15C3W9bdi40WjcW8zuvOAqdun4R/yHmyfbA63JOsIGJwVMHh 9y7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RBEkMkuh; 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-45914-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45914-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCUQqDsOah31sLUt7rD35D+qUQwBWkA/8XyKlTnrsG1cicEz0a1dYb/feM0A7CPhCMdTL4mdjRJy3/Q/EwIs/yoKMT4aJg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m14-20020a056402050e00b0055f60f94c01si747243edv.644.2024.01.30.23.27.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 23:27:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45914-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RBEkMkuh; 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-45914-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45914-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B77471F251A3 for ; Wed, 31 Jan 2024 07:27:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 65F048288F; Wed, 31 Jan 2024 07:21:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RBEkMkuh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KqqPmk6V" 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 21AD97D40C; Wed, 31 Jan 2024 07:21:28 +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=1706685690; cv=none; b=ON/UMlg43hmGph77Si3CdhoQmXRCT/ZRwc6C8LOgo4t+uQ0MZckM52YDDUPHuTy0rbo6+YhMRJ72ko0tvGPdMPTxIpRbu3x7kq+uJwd0msnBdAJRmwaWW7QPT0+iEFwiK8d8hKq5JGA1iy8GzIT2mLevwC+eyboPon1PtXIg5us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706685690; c=relaxed/simple; bh=daqUiW0YHFLh2qHv1GFQCdF1Sr4HYvygqC7fBUCgMXg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=WlEAt1HbzWMGLiy5QdM+N2sSom1zCc8fVbeGrDYPpBJxjdf5JD7xhJxJnwCC/8ymo9r8jwRjCoXGPErkOVZePfvWh9KMkz7/YfciksnMfEwoN6/OPGTZ2yd6WPtIg1BlqZOJSWpQWFVZeFsFm9wusnEXZhs62OS6iPa7QKajuqA= 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=RBEkMkuh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KqqPmk6V; 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:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706685687; 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=pbELyu7iGlzy7e/Az06OBENSg8wuqlswZAyHLgGayv0=; b=RBEkMkuhvc2w7mSwRKQ7Ak30RmBcg9dF1lERdSTWD7xCh8bv+KMiosdiadZRe+HbAKtPmC 75X6hxNQJNEFqMwAuPYn80/tBSZoFmisa+MbP8KxYtQtHBNquIQgyD+AqH/at5/ki3G2Wq ahMcsvbUlXGaUCYS96yFNbgWRvv/YKSekWt1psgELjoHbCzMPmzcAjPF6Sqw/1RoKEsuYl AJ9wEAH5b4vUqgWifLIRtXrSyBjR9sSczc/O+iVTXN5NMgk8+cL2tufRqGje938MenowKU FYNNUPR90sBRtW2K9ksATVoZoyXx25bKXxM8nv3ePefSs6rlzXHbPnHFSoNorQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706685687; 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=pbELyu7iGlzy7e/Az06OBENSg8wuqlswZAyHLgGayv0=; b=KqqPmk6VSA4ipe/M4OyQFtrCMJIcAhaBLQiooKI1R5vyj3ij3M7s2yIAnraihBkAaj5ylm dSET9ffArzRbOlDA== From: "tip-bot2 for H. Peter Anvin (Intel)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fred] x86/cpu: Add X86_CR4_FRED macro Cc: "H. Peter Anvin (Intel)" , Xin Li , Thomas Gleixner , Shan Kang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231205105030.8698-12-xin3.li@intel.com> References: <20231205105030.8698-12-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: <170668568667.398.15869925252024046678.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: 1784440835177456283 X-GMAIL-MSGID: 1789590017035807131 The following commit has been merged into the x86/fred branch of tip: Commit-ID: 95d34efac1a0aff6da00ad177168d99c60a3b7cd Gitweb: https://git.kernel.org/tip/95d34efac1a0aff6da00ad177168d99c60a3b7cd Author: H. Peter Anvin (Intel) AuthorDate: Tue, 05 Dec 2023 02:50:00 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 30 Jan 2024 18:20:34 +01:00 x86/cpu: Add X86_CR4_FRED macro Add X86_CR4_FRED macro for the FRED bit in %cr4. This bit must not be changed after initialization, so add it to the pinned CR4 bits. Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li Signed-off-by: Thomas Gleixner Tested-by: Shan Kang Link: https://lore.kernel.org/r/20231205105030.8698-12-xin3.li@intel.com --- arch/x86/include/uapi/asm/processor-flags.h | 7 +++++++ arch/x86/kernel/cpu/common.c | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/uapi/asm/processor-flags.h b/arch/x86/include/uapi/asm/processor-flags.h index d898432..f1a4adc 100644 --- a/arch/x86/include/uapi/asm/processor-flags.h +++ b/arch/x86/include/uapi/asm/processor-flags.h @@ -139,6 +139,13 @@ #define X86_CR4_LAM_SUP_BIT 28 /* LAM for supervisor pointers */ #define X86_CR4_LAM_SUP _BITUL(X86_CR4_LAM_SUP_BIT) +#ifdef __x86_64__ +#define X86_CR4_FRED_BIT 32 /* enable FRED kernel entry */ +#define X86_CR4_FRED _BITUL(X86_CR4_FRED_BIT) +#else +#define X86_CR4_FRED (0) +#endif + /* * x86-64 Task Priority Register, CR8 */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 0b97bcd..c3a1757 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -382,9 +382,8 @@ out: } /* These bits should not change their value after CPU init is finished. */ -static const unsigned long cr4_pinned_mask = - X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP | - X86_CR4_FSGSBASE | X86_CR4_CET; +static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP | + X86_CR4_FSGSBASE | X86_CR4_CET | X86_CR4_FRED; static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning); static unsigned long cr4_pinned_bits __ro_after_init;