RE: [PATCH] x86/efi: Don't unmap EFI boot services code/data regions for EFI_OLD_MEMMAP and EFI_MIXED_MODE

From: Prakhya, Sai Praneeth
Date: Sat Dec 22 2018 - 14:05:48 EST


>
> * Sai Praneeth Prakhya <sai.praneeth.prakhya@xxxxxxxxx> wrote:
>
> > Commit d5052a7130a6 ("x86/efi: Unmap EFI boot services code/data
> > regions from efi_pgd") forgets to take two EFI modes into
> > consideration namely EFI_OLD_MEMMAP and EFI_MIXED_MODE.
>
> So the commit sha1 ended up being this one in tip:efi/core:
>
> 08cfb38f3ef4: x86/efi: Unmap EFI boot services code/data regions from
> efi_pgd

Ya.. sorry! I took the sha1 from efi tree.

>
> > EFI_OLD_MEMMAP is a legacy way of mapping EFI regions into
> > swapper_pg_dir using ioremap() and init_memory_mapping(). This feature
> > can be enabled by passing "efi=old_map" as kernel command line
> > argument. But,
> > efi_unmap_pages() unmaps EFI boot services code/data regions *only*
> > from efi_pgd and hence cannot be used for unmapping EFI boot services
> > code/data regions from swapper_pg_dir.


[.........]


> > + /*
> > + * EFI mixed mode has all RAM mapped to access arguments while
> making
> > + * EFI runtime calls, hence don't unmap EFI boot services code/data
> > + * regions.
> > + */
> > + if (!efi_is_native() && IS_ENABLED(CONFIG_EFI_MIXED))
> > + return;
>
> I suppose old_mmap and mixed mode stopped working altogether after the
> unmapping changes?

Yes.. that's true.

> What are the symptoms, instant reboots, crasher, or some
> more benign behavior like non-working runtime EFI functionality?

I noticed a kernel panic due to page fault.

AFAIK, it happens because efi_pgd is not defined for old_map and mixed mode.
Hence efi_unmap_pages() which calls __change_page_attr() unmaps mappings
from swapper_pg_dir (please note that this my theory but I haven't checked if
this is really true).

>
> If Ard acks this I'll apply it immediately, as these bugs look like show-stoppers for
> merging the EFI tree into v4.21.
>
> Thanks,
>
> Ingo