]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/efi: Make efi_enter/leave_mm() use the use_/unuse_temporary_mm() machinery
authorAndy Lutomirski <luto@kernel.org>
Wed, 2 Apr 2025 09:45:39 +0000 (11:45 +0200)
committerIngo Molnar <mingo@kernel.org>
Sat, 12 Apr 2025 08:06:04 +0000 (10:06 +0200)
This should be considerably more robust.  It's also necessary for optimized
for_each_possible_lazymm_cpu() on x86 -- without this patch, EFI calls in
lazy context would remove the lazy mm from mm_cpumask().

[ mingo: Merged it on top of x86/alternatives ]

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lore.kernel.org/r/20250402094540.3586683-7-mingo@kernel.org
arch/x86/platform/efi/efi_64.c

index ac57259a432b8c67f76590ee3050438311084a92..a5d3496d32a517785169a1a09c0c6eaa04309801 100644 (file)
@@ -434,15 +434,12 @@ void __init efi_dump_pagetable(void)
  */
 static void efi_enter_mm(void)
 {
-       efi_prev_mm = current->active_mm;
-       current->active_mm = &efi_mm;
-       switch_mm(efi_prev_mm, &efi_mm, NULL);
+       efi_prev_mm = use_temporary_mm(&efi_mm);
 }
 
 static void efi_leave_mm(void)
 {
-       current->active_mm = efi_prev_mm;
-       switch_mm(&efi_mm, efi_prev_mm, NULL);
+       unuse_temporary_mm(efi_prev_mm);
 }
 
 void arch_efi_call_virt_setup(void)