From patchwork Fri Jun 20 13:53:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 898761 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 EF8E82BD586; Fri, 20 Jun 2025 13:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750427636; cv=none; b=u2aFnTi7EWrgps+xQSFzhVBjMR8jrr7Xmu+68qhCGHD3d2bn89s42uVmPveaa8EboX1fedkjFR1OeiMveoVsunWkLSF7vmHm4cU6i58ZS63LCZCq/4MCqGBTZqolVyow8MR63kfoAg2zGMyT73r3MpZioaeLeDfRkNBRWHKl7ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750427636; c=relaxed/simple; bh=ewcLKkcrMcRFRA0n6aHYClkw5o3cVN33kBYUWBIaM+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nqtO/HExMLiftqnlMfvK64e34BUU0xkA6hSBZa99uAKoVABcMY/aWDioSW6PZ3bF3VABAaJ3+cT50BiSl55dlMMD+6QtuE8P5eNZubkFSz5AW4KOmKD2/AbLMf0tXy7/ez4nMIOxo7EKuY2S0isbCjYeggjWV9oTz4WBlSBdBhc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=k83kiRwR; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mgamail.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="k83kiRwR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1750427635; x=1781963635; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ewcLKkcrMcRFRA0n6aHYClkw5o3cVN33kBYUWBIaM+s=; b=k83kiRwRMqp+8ProDRgcmwkQ46FmpCY5NlgMPqilw2Jl6yMmmoSl1Vx5 9d5Up/xHDbMu0w0T+amoQUr1R4jn41Lie/FzkvN2UAvc1vTkc3KP55ecY xcx8Qohqszmo2s8VBNvkXU3JKk2vRYQ2IwLVDAJ+2wp1x/n+Smikha8Bm Yq8i1M8rtskM0UxvFt0zibinaAjOPDRHl39u+eySUhOMiexV2VAKKItOo +lSR9ouQCr2kQocKdBvlFV8BcHUhOtVNfwnyT32iMFjiK6BdajiLDmltC u7eida4FihoYazJIixWDmFbQNN8dMsvZGEI3Vh0YnQtRTfvrynoH49vXe g==; X-CSE-ConnectionGUID: 2Pcdtk0YSAq7ujQpEoWlJA== X-CSE-MsgGUID: iBUfDDeiSzKb0/BT9CciXg== X-IronPort-AV: E=McAfee;i="6800,10657,11469"; a="51919454" X-IronPort-AV: E=Sophos;i="6.16,251,1744095600"; d="scan'208";a="51919454" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2025 06:53:55 -0700 X-CSE-ConnectionGUID: lWCWiYuVSMeMbf6xPIHWLQ== X-CSE-MsgGUID: gYnYGn3OSSyPczRl/wa2zQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,251,1744095600"; d="scan'208";a="155292165" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa003.jf.intel.com with ESMTP; 20 Jun 2025 06:53:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 3595FA1E; Fri, 20 Jun 2025 16:53:29 +0300 (EEST) From: "Kirill A. Shutemov" To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Ard Biesheuvel , "Paul E. McKenney" , Josh Poimboeuf , Xiongwei Song , Xin Li , "Mike Rapoport (IBM)" , Brijesh Singh , Michael Roth , Tony Luck , Alexey Kardashevskiy , Alexander Shishkin Cc: Jonathan Corbet , Sohil Mehta , Ingo Molnar , Pawan Gupta , Daniel Sneddon , Kai Huang , Sandipan Das , Breno Leitao , Rick Edgecombe , Alexei Starovoitov , Hou Tao , Juergen Gross , Vegard Nossum , Kees Cook , Eric Biggers , Jason Gunthorpe , "Masami Hiramatsu (Google)" , Andrew Morton , Luis Chamberlain , Yuntao Wang , Rasmus Villemoes , Christophe Leroy , Tejun Heo , Changbin Du , Huang Shijie , Geert Uytterhoeven , Namhyung Kim , Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [PATCHv6 15/16] x86/cpu: Enable LASS during CPU initialization Date: Fri, 20 Jun 2025 16:53:23 +0300 Message-ID: <20250620135325.3300848-16-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250620135325.3300848-1-kirill.shutemov@linux.intel.com> References: <20250620135325.3300848-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Sohil Mehta Being a security feature, enable LASS by default if the platform supports it. While at it, get rid of the comment above the SMAP/SMEP/UMIP/LASS setup instead of updating it to mention LASS as well, as the whole sequence is quite self-explanatory. Signed-off-by: Sohil Mehta Signed-off-by: Alexander Shishkin Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/cpu/common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index d12ce36a76f5..edb342214328 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -401,6 +401,12 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c) cr4_clear_bits(X86_CR4_UMIP); } +static __always_inline void setup_lass(struct cpuinfo_x86 *c) +{ + if (cpu_feature_enabled(X86_FEATURE_LASS)) + cr4_set_bits(X86_CR4_LASS); +} + /* 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 | X86_CR4_FRED | @@ -1975,10 +1981,10 @@ static void identify_cpu(struct cpuinfo_x86 *c) /* Disable the PN if appropriate */ squash_the_stupid_serial_number(c); - /* Set up SMEP/SMAP/UMIP */ setup_smep(c); setup_smap(c); setup_umip(c); + setup_lass(c); /* Enable FSGSBASE instructions if available. */ if (cpu_has(c, X86_FEATURE_FSGSBASE)) {