diff mbox series

[19/23] x86/efi: Make efi_enter/leave_mm use the temporary_mm machinery

Message ID 3efc4cfd1d7c45a32752ced389d6666be15cde56.1641659630.git.luto@kernel.org (mailing list archive)
State New
Headers show
Series mm, sched: Rework lazy mm handling | expand

Commit Message

Andy Lutomirski Jan. 8, 2022, 4:44 p.m. UTC
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().

Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/platform/efi/efi_64.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Ard Biesheuvel Jan. 10, 2022, 1:13 p.m. UTC | #1
On Sat, 8 Jan 2022 at 17:44, Andy Lutomirski <luto@kernel.org> wrote:
>
> 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().
>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Andy Lutomirski <luto@kernel.org>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  arch/x86/platform/efi/efi_64.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
> index 7515e78ef898..b9a571904363 100644
> --- a/arch/x86/platform/efi/efi_64.c
> +++ b/arch/x86/platform/efi/efi_64.c
> @@ -54,7 +54,7 @@
>   * 0xffff_ffff_0000_0000 and limit EFI VA mapping space to 64G.
>   */
>  static u64 efi_va = EFI_VA_START;
> -static struct mm_struct *efi_prev_mm;
> +static temp_mm_state_t efi_temp_mm_state;
>
>  /*
>   * We need our own copy of the higher levels of the page tables
> @@ -461,15 +461,12 @@ void __init efi_dump_pagetable(void)
>   */
>  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_temp_mm_state = use_temporary_mm(&efi_mm);
>  }
>
>  void efi_leave_mm(void)
>  {
> -       current->active_mm = efi_prev_mm;
> -       switch_mm(&efi_mm, efi_prev_mm, NULL);
> +       unuse_temporary_mm(efi_temp_mm_state);
>  }
>
>  static DEFINE_SPINLOCK(efi_runtime_lock);
> --
> 2.33.1
>
diff mbox series

Patch

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 7515e78ef898..b9a571904363 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -54,7 +54,7 @@ 
  * 0xffff_ffff_0000_0000 and limit EFI VA mapping space to 64G.
  */
 static u64 efi_va = EFI_VA_START;
-static struct mm_struct *efi_prev_mm;
+static temp_mm_state_t efi_temp_mm_state;
 
 /*
  * We need our own copy of the higher levels of the page tables
@@ -461,15 +461,12 @@  void __init efi_dump_pagetable(void)
  */
 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_temp_mm_state = use_temporary_mm(&efi_mm);
 }
 
 void efi_leave_mm(void)
 {
-	current->active_mm = efi_prev_mm;
-	switch_mm(&efi_mm, efi_prev_mm, NULL);
+	unuse_temporary_mm(efi_temp_mm_state);
 }
 
 static DEFINE_SPINLOCK(efi_runtime_lock);