Skip to content

Commit 162ee5a

Browse files
Sai PraneethIngo Molnar
authored andcommitted
x86/mm: Fix bogus warning during EFI bootup, use boot_cpu_has() instead of this_cpu_has() in build_cr3_noflush()
Linus reported the following boot warning: WARNING: CPU: 0 PID: 0 at arch/x86/include/asm/tlbflush.h:134 load_new_mm_cr3+0x114/0x170 [...] Call Trace: switch_mm_irqs_off+0x267/0x590 switch_mm+0xe/0x20 efi_switch_mm+0x3e/0x50 efi_enter_virtual_mode+0x43f/0x4da start_kernel+0x3bf/0x458 secondary_startup_64+0xa5/0xb0 ... after merging: 03781e4: x86/efi: Use efi_switch_mm() rather than manually twiddling with %cr3 When the platform supports PCID and if CONFIG_DEBUG_VM=y is enabled, build_cr3_noflush() (called via switch_mm()) does a sanity check to see if X86_FEATURE_PCID is set. Presently, build_cr3_noflush() uses "this_cpu_has(X86_FEATURE_PCID)" to perform the check but this_cpu_has() works only after SMP is initialized (i.e. per cpu cpu_info's should be populated) and this happens to be very late in the boot process (during rest_init()). As efi_runtime_services() are called during (early) kernel boot time and run time, modify build_cr3_noflush() to use boot_cpu_has() all the time. As suggested by Dave Hansen, this should be OK because all CPU's have same capabilities on x86. With this change the warning is fixed. ( Dave also suggested that we put a warning in this_cpu_has() if it's used early in the boot process. This is still work in progress as it affects MCE. ) Reported-by: Linus Torvalds <[email protected]> Signed-off-by: Sai Praneeth Prakhya <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Lee Chun-Yi <[email protected]> Cc: Matt Fleming <[email protected]> Cc: Michael S. Tsirkin <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Shankar <[email protected]> Cc: Ricardo Neri <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tony Luck <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 642e7fd commit 162ee5a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/x86/include/asm/tlbflush.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ static inline unsigned long build_cr3(pgd_t *pgd, u16 asid)
131131
static inline unsigned long build_cr3_noflush(pgd_t *pgd, u16 asid)
132132
{
133133
VM_WARN_ON_ONCE(asid > MAX_ASID_AVAILABLE);
134-
VM_WARN_ON_ONCE(!this_cpu_has(X86_FEATURE_PCID));
134+
/*
135+
* Use boot_cpu_has() instead of this_cpu_has() as this function
136+
* might be called during early boot. This should work even after
137+
* boot because all CPU's the have same capabilities:
138+
*/
139+
VM_WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_PCID));
135140
return __sme_pa(pgd) | kern_pcid(asid) | CR3_NOFLUSH;
136141
}
137142

0 commit comments

Comments
 (0)