lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94461b3ac97f13073c8db552f90952aa7edf503a.1755004923.git.maciej.wieczor-retman@intel.com>
Date: Tue, 12 Aug 2025 15:23:47 +0200
From: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
To: nathan@...nel.org,
	arnd@...db.de,
	broonie@...nel.org,
	Liam.Howlett@...cle.com,
	urezki@...il.com,
	will@...nel.org,
	kaleshsingh@...gle.com,
	rppt@...nel.org,
	leitao@...ian.org,
	coxu@...hat.com,
	surenb@...gle.com,
	akpm@...ux-foundation.org,
	luto@...nel.org,
	jpoimboe@...nel.org,
	changyuanl@...gle.com,
	hpa@...or.com,
	dvyukov@...gle.com,
	kas@...nel.org,
	corbet@....net,
	vincenzo.frascino@....com,
	smostafa@...gle.com,
	nick.desaulniers+lkml@...il.com,
	morbo@...gle.com,
	andreyknvl@...il.com,
	alexander.shishkin@...ux.intel.com,
	thiago.bauermann@...aro.org,
	catalin.marinas@....com,
	ryabinin.a.a@...il.com,
	jan.kiszka@...mens.com,
	jbohac@...e.cz,
	dan.j.williams@...el.com,
	joel.granados@...nel.org,
	baohua@...nel.org,
	kevin.brodsky@....com,
	nicolas.schier@...ux.dev,
	pcc@...gle.com,
	andriy.shevchenko@...ux.intel.com,
	wei.liu@...nel.org,
	bp@...en8.de,
	ada.coupriediaz@....com,
	xin@...or.com,
	pankaj.gupta@....com,
	vbabka@...e.cz,
	glider@...gle.com,
	jgross@...e.com,
	kees@...nel.org,
	jhubbard@...dia.com,
	joey.gouly@....com,
	ardb@...nel.org,
	thuth@...hat.com,
	pasha.tatashin@...een.com,
	kristina.martsenko@....com,
	bigeasy@...utronix.de,
	maciej.wieczor-retman@...el.com,
	lorenzo.stoakes@...cle.com,
	jason.andryuk@....com,
	david@...hat.com,
	graf@...zon.com,
	wangkefeng.wang@...wei.com,
	ziy@...dia.com,
	mark.rutland@....com,
	dave.hansen@...ux.intel.com,
	samuel.holland@...ive.com,
	kbingham@...nel.org,
	trintaeoitogc@...il.com,
	scott@...amperecomputing.com,
	justinstitt@...gle.com,
	kuan-ying.lee@...onical.com,
	maz@...nel.org,
	tglx@...utronix.de,
	samitolvanen@...gle.com,
	mhocko@...e.com,
	nunodasneves@...ux.microsoft.com,
	brgerst@...il.com,
	willy@...radead.org,
	ubizjak@...il.com,
	peterz@...radead.org,
	mingo@...hat.com,
	sohil.mehta@...el.com
Cc: linux-mm@...ck.org,
	linux-kbuild@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	x86@...nel.org,
	llvm@...ts.linux.dev,
	kasan-dev@...glegroups.com,
	linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH v4 11/18] x86: LAM initialization

To make use of KASAN's tag based mode on x86, Linear Address Masking
(LAM) needs to be enabled. To do that the 28th bit in CR4 has to be set.

Set the bit in early memory initialization.

When launching secondary CPUs the LAM bit gets lost. To avoid this add
it in a mask in head_64.S. The bitmask permits some bits of CR4 to pass
from the primary CPU to the secondary CPUs without being cleared.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
---
 arch/x86/kernel/head_64.S | 3 +++
 arch/x86/mm/init.c        | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 3e9b3a3bd039..18ca77daa481 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -209,6 +209,9 @@ SYM_INNER_LABEL(common_startup_64, SYM_L_LOCAL)
 	 *  there will be no global TLB entries after the execution."
 	 */
 	movl	$(X86_CR4_PAE | X86_CR4_LA57), %edx
+#ifdef CONFIG_ADDRESS_MASKING
+	orl	$X86_CR4_LAM_SUP, %edx
+#endif
 #ifdef CONFIG_X86_MCE
 	/*
 	 * Preserve CR4.MCE if the kernel will enable #MC support.
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index bb57e93b4caf..756bd96c3b8b 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -763,6 +763,9 @@ void __init init_mem_mapping(void)
 	probe_page_size_mask();
 	setup_pcid();
 
+	if (boot_cpu_has(X86_FEATURE_LAM) && IS_ENABLED(CONFIG_KASAN_SW_TAGS))
+		cr4_set_bits_and_update_boot(X86_CR4_LAM_SUP);
+
 #ifdef CONFIG_X86_64
 	end = max_pfn << PAGE_SHIFT;
 #else
-- 
2.50.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ