Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cfe19577 authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Ingo Molnar
Browse files

x86/efi: Fix efi_call_phys_epilog() with CONFIG_X86_5LEVEL=y



Open-coded page table entry checks don't work correctly when we fold the
page table level at runtime.

pgd_present() on 4-level paging machine always returns true, but
open-coded version of the check may return false-negative result and
we silently skip the rest of the loop body in efi_call_phys_epilog().

Replace open-coded checks with proper helpers.

Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org # v4.12+
Fixes: 94133e46 ("x86/efi: Correct EFI identity mapping under 'efi=old_map' when KASLR is enabled")
Link: http://lkml.kernel.org/r/20180625120852.18300-1-kirill.shutemov@linux.intel.com


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e8a445de
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -166,14 +166,14 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
		pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE);
		pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE);
		set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]);
		set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]);


		if (!(pgd_val(*pgd) & _PAGE_PRESENT))
		if (!pgd_present(*pgd))
			continue;
			continue;


		for (i = 0; i < PTRS_PER_P4D; i++) {
		for (i = 0; i < PTRS_PER_P4D; i++) {
			p4d = p4d_offset(pgd,
			p4d = p4d_offset(pgd,
					 pgd_idx * PGDIR_SIZE + i * P4D_SIZE);
					 pgd_idx * PGDIR_SIZE + i * P4D_SIZE);


			if (!(p4d_val(*p4d) & _PAGE_PRESENT))
			if (!p4d_present(*p4d))
				continue;
				continue;


			pud = (pud_t *)p4d_page_vaddr(*p4d);
			pud = (pud_t *)p4d_page_vaddr(*p4d);