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: <01104816cdd0d430ac843847a8056d07b8770be0.1738686764.git.maciej.wieczor-retman@intel.com>
Date: Tue,  4 Feb 2025 18:33:52 +0100
From: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
To: luto@...nel.org,
	xin@...or.com,
	kirill.shutemov@...ux.intel.com,
	palmer@...belt.com,
	tj@...nel.org,
	andreyknvl@...il.com,
	brgerst@...il.com,
	ardb@...nel.org,
	dave.hansen@...ux.intel.com,
	jgross@...e.com,
	will@...nel.org,
	akpm@...ux-foundation.org,
	arnd@...db.de,
	corbet@....net,
	maciej.wieczor-retman@...el.com,
	dvyukov@...gle.com,
	richard.weiyang@...il.com,
	ytcoode@...il.com,
	tglx@...utronix.de,
	hpa@...or.com,
	seanjc@...gle.com,
	paul.walmsley@...ive.com,
	aou@...s.berkeley.edu,
	justinstitt@...gle.com,
	jason.andryuk@....com,
	glider@...gle.com,
	ubizjak@...il.com,
	jannh@...gle.com,
	bhe@...hat.com,
	vincenzo.frascino@....com,
	rafael.j.wysocki@...el.com,
	ndesaulniers@...gle.com,
	mingo@...hat.com,
	catalin.marinas@....com,
	junichi.nomura@....com,
	nathan@...nel.org,
	ryabinin.a.a@...il.com,
	dennis@...nel.org,
	bp@...en8.de,
	kevinloughlin@...gle.com,
	morbo@...gle.com,
	dan.j.williams@...el.com,
	julian.stecklina@...erus-technology.de,
	peterz@...radead.org,
	cl@...ux.com,
	kees@...nel.org
Cc: kasan-dev@...glegroups.com,
	x86@...nel.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-riscv@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	linux-mm@...ck.org,
	llvm@...ts.linux.dev,
	linux-doc@...r.kernel.org
Subject: [PATCH 11/15] 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 needs to be
set.

Set the bit in early memory initialization.

When launching secondary CPUs the LAM bit gets lost. To avoid this it
needs to get added in a mask in head_64.S. The bit mask 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 16752b8dfa89..7cdafcedbc70 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -199,6 +199,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 eb503f53c319..4dc3679fedd1 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -756,6 +756,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.47.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ