Skip to content

Commit df5b035

Browse files
committed
x86/cacheinfo: Add a cpu_llc_shared_mask() UP variant
On a CONFIG_SMP=n kernel, the LLC shared mask is 0, which prevents __cache_amd_cpumap_setup() from doing the L3 masks setup, and more specifically from setting up the shared_cpu_map and shared_cpu_list files in sysfs, leading to lscpu from util-linux getting confused and segfaulting. Add a cpu_llc_shared_mask() UP variant which returns a mask with a single bit set, i.e., for CPU0. Fixes: 2b83809 ("x86/cpu/amd: Derive L3 shared_cpu_map from cpu_llc_shared_mask") Reported-by: Saurabh Sengar <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent efd608f commit df5b035

File tree

1 file changed

+15
-10
lines changed
  • arch/x86/include/asm

1 file changed

+15
-10
lines changed

arch/x86/include/asm/smp.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
2121
DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_l2c_id);
2222
DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
2323

24-
static inline struct cpumask *cpu_llc_shared_mask(int cpu)
25-
{
26-
return per_cpu(cpu_llc_shared_map, cpu);
27-
}
28-
29-
static inline struct cpumask *cpu_l2c_shared_mask(int cpu)
30-
{
31-
return per_cpu(cpu_l2c_shared_map, cpu);
32-
}
33-
3424
DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid);
3525
DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid);
3626
DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid);
@@ -172,13 +162,28 @@ extern int safe_smp_processor_id(void);
172162
# define safe_smp_processor_id() smp_processor_id()
173163
#endif
174164

165+
static inline struct cpumask *cpu_llc_shared_mask(int cpu)
166+
{
167+
return per_cpu(cpu_llc_shared_map, cpu);
168+
}
169+
170+
static inline struct cpumask *cpu_l2c_shared_mask(int cpu)
171+
{
172+
return per_cpu(cpu_l2c_shared_map, cpu);
173+
}
174+
175175
#else /* !CONFIG_SMP */
176176
#define wbinvd_on_cpu(cpu) wbinvd()
177177
static inline int wbinvd_on_all_cpus(void)
178178
{
179179
wbinvd();
180180
return 0;
181181
}
182+
183+
static inline struct cpumask *cpu_llc_shared_mask(int cpu)
184+
{
185+
return (struct cpumask *)cpumask_of(0);
186+
}
182187
#endif /* CONFIG_SMP */
183188

184189
extern unsigned disabled_cpus;

0 commit comments

Comments
 (0)