[RHEL7.5 PATCH 1/1] x86/kaiser/efi: unbreak EFI old_memmap

From: Jiri Kosina
Date: Fri Jan 05 2018 - 14:00:25 EST


old_memmap's efi_call_phys_prolog() calls set_pgd() with swapper PGD that
has PAGE_USER set, which makes PTI set NX on it, and therefore EFI can't
execute it's code.

Fix that by forcefully clearing _PAGE_NX from the PGD (this can't be done
by the pgprot API).

_PAGE_NX will be automatically reintroduced in efi_call_phys_epilog(), as
_set_pgd() will again notice that this is _PAGE_USER, and set _PAGE_NX on
it.

Signed-off-by: Jiri Kosina <jkosina@xxxxxxx>
Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx>
---
arch/x86/platform/efi/efi_64.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index f951026ea2d2..395079128d98 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -110,6 +110,7 @@ void __init efi_call_phys_prelog(void)
vaddr = (unsigned long)__va(pgd * PGDIR_SIZE);
pgd_efi = pgd_offset_k(addr_pgd);
save_pgd[pgd] = *pgd_efi;
+ pgd_efi->pgd &= ~_PAGE_NX;

pud = pud_alloc(&init_mm, pgd_efi, addr_pgd);
if (!pud) {