RE: [tip:efi/core] x86/efi: Unmap EFI boot services code/data regions from efi_pgd

From: Prakhya, Sai Praneeth
Date: Mon Dec 17 2018 - 13:42:28 EST


> > Hi Thomas and Ingo,
> >
> > I recently noticed that the below commits [1] and [2] are broken when
> > kernel command line argument "efi=old_map" is passed. Sorry! I missed
> > to test this condition prior to sending these patches to mailing list.
> > I am working on a fix and will send it to mailing list as soon as it's ready.
> >
>
> Could you elaborate on the problem please?

Sure! My bad..

Little bit of history here:
Boris with this patch set [1] introduced statically mapping EFI Runtime Services at -4G
and also introduced "efi=old_map" to return to previous EFI functionality which used
ioremap and __va(pa).

[3] and [4] are links to old_map_region()

The commit 08cfb38f3ef4 ("x86/efi: Unmap EFI boot services code/data regions from efi_pgd"),
unmaps EFI boot services code/data regions *only* from efi_pgd but efi=old_map maps
EFI boot services code/data regions into swapper_pgd. Also, efi=old_map uses either
ioremap() or __va(md->phys_addr) to map EFI runtime/boot time services and doesn't use kernel_map_pages_in_pgd().

So, we need a different unmapping routine to unmap EFI boot services code/data
regions from swapper_pgd if they were mapped using efi=old_map.

[1] https://lkml.org/lkml/2013/9/19/235 - Cover letter for EFI runtime services virtual mapping
[2] https://lkml.org/lkml/2013/10/8/777 - Talks about efi=old_map
[3] https://elixir.bootlin.com/linux/v4.20-rc7/source/arch/x86/platform/efi/efi_64.c#L429
[4] https://elixir.bootlin.com/linux/v4.20-rc7/source/arch/x86/platform/efi/efi.c#L584

>
> > Meanwhile, could you please drop these patches before sending pull request
> to Linus?
> >
> > [1] Commit 08cfb38f3ef4 ("x86/efi: Unmap EFI boot services code/data
> > regions from efi_pgd") [2] Commit 7e0dabd3010d ("x86/mm/pageattr:
> > Introduce helper function to unmap EFI boot services")
> >
>
> I'd like to understand what the issue is before we drop anything.

Regards,
Sai