[PATCH] x86/efi: Don't unmap EFI boot services code/data regions for EFI_OLD_MEMMAP and EFI_MIXED_MODE
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. 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. Introduce a temporary fix to not unmap EFI boot services code/data regions when EFI_OLD_MEMMAP is enabled while working on a real fix. EFI_MIXED_MODE is another feature where a 64-bit kernel runs on a 64-bit platform crippled by a 32-bit firmware. To support EFI_MIXED_MODE, all RAM (i.e. namely EFI regions like EFI_CONVENTIONAL_MEMORY, EFI_LOADER_, EFI_BOOT_SERVICES_ and EFI_RUNTIME_CODE/DATA regions) is mapped into efi_pgd all the time to facilitate EFI runtime calls access it's arguments in 1:1 mode. Hence, don't unmap EFI boot services code/data regions when booted in mixed mode. Signed-off-by: Sai Praneeth Prakhya Cc: Borislav Petkov Cc: Ingo Molnar Cc: Andy Lutomirski Cc: Dave Hansen Cc: Bhupesh Sharma Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ard Biesheuvel --- arch/x86/platform/efi/quirks.c | 16 1 file changed, 16 insertions(+) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 09e811b9da26..9c34230aaeae 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -380,6 +380,22 @@ static void __init efi_unmap_pages(efi_memory_desc_t *md) u64 pa = md->phys_addr; u64 va = md->virt_addr; + /* +* To Do: Remove this check after adding functionality to unmap EFI boot +* services code/data regions from direct mapping area because +* "efi=old_map" maps EFI regions in swapper_pg_dir. +*/ + if (efi_enabled(EFI_OLD_MEMMAP)) + return; + + /* +* 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; + if (kernel_unmap_pages_in_pgd(pgd, pa, md->num_pages)) pr_err("Failed to unmap 1:1 mapping for 0x%llx\n", pa); -- 2.19.1
Re: [PATCH] pstore: Convert buf_lock to semaphore
On Tue, 4 Dec 2018 at 19:06, Sebastian Andrzej Siewior wrote: > > On 2018-12-04 09:23:13 [-0800], Kees Cook wrote: > > Okay, so, if kmsg_dump() uses rcu_read_lock(), that means efi-pstore > > can _never_ sleep, and it's nothing to do with pstore internals. :( I > > guess we just hard-code it, then? And efi-pstore should probably only > > attach to pstore if it has a nonblock implementation (and warn if one > > isn't available). > > I was about to suggest that. I am not aware if anything else could use > efi_pstore_write() use that but otherwise you could hardcode it. > efivar_entry_set_safe() will only use the default backend if no non-blocking variant is provided, in which case it assumes that the default one is non-blocking. Perhaps we should just assign both function pointers to the same function in this case.
Re: [PATCH efi-urgent] Revert "efi: Align 'efi_guid_t' to 64 bits"
On Fri, 21 Dec 2018 at 13:13, Borislav Petkov wrote: > > On Fri, Dec 21, 2018 at 12:54:46PM +0100, Ard Biesheuvel wrote: > > This reverts commit 793423cf07e51e3185b8680167115813589c057d. > > > > The 64-bit alignment affects the size of efi_config_table_32_t, > > which is used as an array type. On the other hand, the former > > byte alignment could trigger alignment faults during firmware > > calls on 32-bit ARM, since UEFI defines efi_guid_t as a struct > > of UINT32 + UINT16 + UINT16 + UINT8[8], and so it may use load/ > > store multiple instructions [requiring 32-bit alignment], e.g., > > on GUID pointers passed as function arguments since UEFI's view > > of the type has implicit 32-bit alignment. > > > > Let's sort this out for the next release, and revert the change > > for now. > > > > Fixes: 793423cf07e5 ("efi: Align 'efi_guid_t' to 64 bits") > > Reported-by: Heinrich Schuchardt > > Cc: Ingo Molnar > > Cc: Andy Lutomirski > > Cc: Borislav Petkov > > Cc: Dave Hansen > > Cc: H. Peter Anvin > > Cc: Linus Torvalds > > Cc: Peter Zijlstra > > Cc: Qian Cai > > Cc: Rik van Riel > > Cc: Thomas Gleixner > > Signed-off-by: Ard Biesheuvel > > --- > > include/linux/efi.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/include/linux/efi.h b/include/linux/efi.h > > index e6480c805932..100ce4a4aff6 100644 > > --- a/include/linux/efi.h > > +++ b/include/linux/efi.h > > @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character > > */ > > typedef u64 efi_physical_addr_t; > > typedef void *efi_handle_t; > > > > -typedef guid_t efi_guid_t __aligned(8); > > +typedef guid_t efi_guid_t; > > > > #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ > > GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) > > -- > > It was the top commit on tip:efi/urgent so I've zapped it. > Even better! Thanks a lot
Re: [PATCH efi-urgent] Revert "efi: Align 'efi_guid_t' to 64 bits"
On Fri, Dec 21, 2018 at 12:54:46PM +0100, Ard Biesheuvel wrote: > This reverts commit 793423cf07e51e3185b8680167115813589c057d. > > The 64-bit alignment affects the size of efi_config_table_32_t, > which is used as an array type. On the other hand, the former > byte alignment could trigger alignment faults during firmware > calls on 32-bit ARM, since UEFI defines efi_guid_t as a struct > of UINT32 + UINT16 + UINT16 + UINT8[8], and so it may use load/ > store multiple instructions [requiring 32-bit alignment], e.g., > on GUID pointers passed as function arguments since UEFI's view > of the type has implicit 32-bit alignment. > > Let's sort this out for the next release, and revert the change > for now. > > Fixes: 793423cf07e5 ("efi: Align 'efi_guid_t' to 64 bits") > Reported-by: Heinrich Schuchardt > Cc: Ingo Molnar > Cc: Andy Lutomirski > Cc: Borislav Petkov > Cc: Dave Hansen > Cc: H. Peter Anvin > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Qian Cai > Cc: Rik van Riel > Cc: Thomas Gleixner > Signed-off-by: Ard Biesheuvel > --- > include/linux/efi.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/efi.h b/include/linux/efi.h > index e6480c805932..100ce4a4aff6 100644 > --- a/include/linux/efi.h > +++ b/include/linux/efi.h > @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ > typedef u64 efi_physical_addr_t; > typedef void *efi_handle_t; > > -typedef guid_t efi_guid_t __aligned(8); > +typedef guid_t efi_guid_t; > > #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ > GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) > -- It was the top commit on tip:efi/urgent so I've zapped it. HTH. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
[PATCH efi-urgent] Revert "efi: Align 'efi_guid_t' to 64 bits"
This reverts commit 793423cf07e51e3185b8680167115813589c057d. The 64-bit alignment affects the size of efi_config_table_32_t, which is used as an array type. On the other hand, the former byte alignment could trigger alignment faults during firmware calls on 32-bit ARM, since UEFI defines efi_guid_t as a struct of UINT32 + UINT16 + UINT16 + UINT8[8], and so it may use load/ store multiple instructions [requiring 32-bit alignment], e.g., on GUID pointers passed as function arguments since UEFI's view of the type has implicit 32-bit alignment. Let's sort this out for the next release, and revert the change for now. Fixes: 793423cf07e5 ("efi: Align 'efi_guid_t' to 64 bits") Reported-by: Heinrich Schuchardt Cc: Ingo Molnar Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Qian Cai Cc: Rik van Riel Cc: Thomas Gleixner Signed-off-by: Ard Biesheuvel --- include/linux/efi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/efi.h b/include/linux/efi.h index e6480c805932..100ce4a4aff6 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ typedef u64 efi_physical_addr_t; typedef void *efi_handle_t; -typedef guid_t efi_guid_t __aligned(8); +typedef guid_t efi_guid_t; #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) -- 2.19.2