Skip to contentSkip to conversation

x86/speculation/l1tf: Increase l1tf memory limit for Nehalem+

STABLE 4.4 Andi Kleen 2 participants 2 messages Sep 3, 2018 – Sep 17, 2018

Subsystems (3)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

From: Andi Kleen <[email protected]>

[upstream cc51e5428ea54f575d49cfcede1d4cb3a72b4ec4 for 4.4. Note there might be still a trivial conflict with the backport for b0a182f875689647b014bc01d36b340217792852, but should be easy to resolve]

On Nehalem and newer core CPUs the CPU cache internally uses 44 bits physical address space. The L1TF workaround is limited by this internal cache address width, and needs to have one bit free there for the mitigation to work.

Older client systems report only 36bit physical address space so the range check decides that L1TF is not mitigated for a 36bit phys/32GB system with some memory holes.

But since these actually have the larger internal cache width this warning is bogus because it would only really be needed if the system had more than 43bits of memory.

Add a new internal x86_cache_bits field. Normally it is the same as the physical bits field reported by CPUID, but for Nehalem and newerforce it to be at least 44bits.

Change the L1TF memory size warning to use the new cache_bits field to avoid bogus warnings and remove the bogus comment about memory size.

---
 arch/x86/include/asm/processor.h |  4 ++-
 arch/x86/kernel/cpu/bugs.c       | 47 ++++++++++++++++++++++++++++----
 arch/x86/kernel/cpu/common.c     |  2 ++
 3 files changed, 47 insertions(+), 6 deletions(-)
arch/x86/include/asm/processor.h +3 -1
index a3a53955f01c..cb07d3f618ca 100644
@@ -104,6 +104,8 @@ struct cpuinfo_x86 {
 	__u8			x86_phys_bits;
 	/* CPUID returned core id bits: */
 	__u8			x86_coreid_bits;
+
+	__u8			x86_cache_bits;
 	/* Max extended CPUID function supported: */
 	__u32			extended_cpuid_level;
 	/* Maximum supported CPUID level, -1=no CPUID: */
@@ -174,7 +176,7 @@ extern void cpu_detect(struct cpuinfo_x86 *c);
 
 static inline unsigned long l1tf_pfn_limit(void)
 {
-	return BIT(boot_cpu_data.x86_phys_bits - 1 - PAGE_SHIFT) - 1;
+	return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT);
 }
 
 extern void early_cpu_init(void);
arch/x86/kernel/cpu/bugs.c +42 -5

64 lines not on this page · raw message

arch/x86/kernel/cpu/common.c +2 -0
index 4d3fa79c0f09..b12c0287d6cf 100644
@@ -798,6 +798,8 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
 		c->x86_phys_bits = 36;
 #endif
 
+	c->x86_cache_bits = c->x86_phys_bits;
+
 	if (c->extended_cpuid_level >= 0x8000000a)
 		c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 6 lines · Andi Kleen

From: Andi Kleen <[email protected]>

[upstream cc51e5428ea54f575d49cfcede1d4cb3a72b4ec4 for 4.4. Note there might be still a trivial conflict with the backport for b0a182f875689647b014bc01d36b340217792852, but should be easy to resolve]

thanks for this, now queued up.

greg k-h