Skip to content

Commit 3e32552

Browse files
hansendcIngo Molnar
authored and
Ingo Molnar
committed
x86/boot: Move x86_cache_alignment initialization to correct spot
c->x86_cache_alignment is initialized from c->x86_clflush_size. However, commit fbf6449 moved c->x86_clflush_size initialization to later in boot without moving the c->x86_cache_alignment assignment: fbf6449 ("x86/sev-es: Set x86_virt_bits to the correct value straight away, instead of a two-phase approach") This presumably left c->x86_cache_alignment set to zero for longer than it should be. The result was an oops on 32-bit kernels while accessing a pointer at 0x20. The 0x20 came from accessing a structure member at offset 0x10 (buffer->cpumask) from a ZERO_SIZE_PTR=0x10. kmalloc() can evidently return ZERO_SIZE_PTR when it's given 0 as its alignment requirement. Move the c->x86_cache_alignment initialization to be after c->x86_clflush_size has an actual value. Fixes: fbf6449 ("x86/sev-es: Set x86_virt_bits to the correct value straight away, instead of a two-phase approach") Signed-off-by: Dave Hansen <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fbf6449 commit 3e32552

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/x86/kernel/cpu/common.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ void get_cpu_address_sizes(struct cpuinfo_x86 *c)
11411141
}
11421142
}
11431143
c->x86_cache_bits = c->x86_phys_bits;
1144+
c->x86_cache_alignment = c->x86_clflush_size;
11441145
}
11451146

11461147
static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
@@ -1594,8 +1595,6 @@ static void __init cpu_parse_early_param(void)
15941595
*/
15951596
static void __init early_identify_cpu(struct cpuinfo_x86 *c)
15961597
{
1597-
c->x86_cache_alignment = c->x86_clflush_size;
1598-
15991598
memset(&c->x86_capability, 0, sizeof(c->x86_capability));
16001599
c->extended_cpuid_level = 0;
16011600

0 commit comments

Comments
 (0)