mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PTI: unbreak EFI old_memmap
@ 2018-01-05 21:35 Jiri Kosina
  2018-01-06 11:52 ` [tip:x86/pti] x86/pti: Unbreak " tip-bot for Jiri Kosina
  2018-01-06 21:03 ` tip-bot for Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Jiri Kosina @ 2018-01-05 21:35 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86
  Cc: Ard Biesheuvel, linux-efi, linux-kernel, Andrea Arcangeli,
	Dave Hansen, Dimitri Sivanich

From: Jiri Kosina <jkosina@suse.cz>

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@suse.cz>
Tested-by: Dimitri Sivanich <sivanich@hpe.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
--- 
 arch/x86/platform/efi/efi_64.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index d87ac96e37ed..2dd15e967c3f 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -135,7 +135,9 @@ pgd_t * __init efi_call_phys_prolog(void)
 				pud[j] = *pud_offset(p4d_k, vaddr);
 			}
 		}
+		pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX;
 	}
+
 out:
 	__flush_tlb_all();
 

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/pti] x86/pti: Unbreak EFI old_memmap
  2018-01-05 21:35 [PATCH] PTI: unbreak EFI old_memmap Jiri Kosina
@ 2018-01-06 11:52 ` tip-bot for Jiri Kosina
  2018-01-06 21:03 ` tip-bot for Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jiri Kosina @ 2018-01-06 11:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: aarcange, peterz, torvalds, tglx, matt, dave.hansen, sivanich,
	jkosina, ard.biesheuvel, hpa, mingo, linux-kernel

Commit-ID:  5ad9a697fa957e61d50ef969179c18348968cd9f
Gitweb:     https://git.kernel.org/tip/5ad9a697fa957e61d50ef969179c18348968cd9f
Author:     Jiri Kosina <jkosina@suse.cz>
AuthorDate: Fri, 5 Jan 2018 22:35:41 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 6 Jan 2018 11:43:44 +0100

x86/pti: Unbreak EFI old_memmap

EFI_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.

Tested-by: Dimitri Sivanich <sivanich@hpe.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
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: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/nycvar.YFH.7.76.1801052215460.11852@cbobk.fhfr.pm
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/efi/efi_64.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 39c4b35..61975b6 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -134,7 +134,9 @@ pgd_t * __init efi_call_phys_prolog(void)
 				pud[j] = *pud_offset(p4d_k, vaddr);
 			}
 		}
+		pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX;
 	}
+
 out:
 	__flush_tlb_all();
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/pti] x86/pti: Unbreak EFI old_memmap
  2018-01-05 21:35 [PATCH] PTI: unbreak EFI old_memmap Jiri Kosina
  2018-01-06 11:52 ` [tip:x86/pti] x86/pti: Unbreak " tip-bot for Jiri Kosina
@ 2018-01-06 21:03 ` tip-bot for Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jiri Kosina @ 2018-01-06 21:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: aarcange, linux-kernel, torvalds, ard.biesheuvel, sivanich, hpa,
	dave.hansen, jkosina, mingo, matt, peterz, tglx

Commit-ID:  de53c3786a3ce162a1c815d0c04c766c23ec9c0a
Gitweb:     https://git.kernel.org/tip/de53c3786a3ce162a1c815d0c04c766c23ec9c0a
Author:     Jiri Kosina <jkosina@suse.cz>
AuthorDate: Fri, 5 Jan 2018 22:35:41 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 6 Jan 2018 21:38:16 +0100

x86/pti: Unbreak EFI old_memmap

EFI_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.

Tested-by: Dimitri Sivanich <sivanich@hpe.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
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: linux-efi@vger.kernel.org
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/nycvar.YFH.7.76.1801052215460.11852@cbobk.fhfr.pm
---
 arch/x86/platform/efi/efi_64.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 39c4b35..61975b6 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -134,7 +134,9 @@ pgd_t * __init efi_call_phys_prolog(void)
 				pud[j] = *pud_offset(p4d_k, vaddr);
 			}
 		}
+		pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX;
 	}
+
 out:
 	__flush_tlb_all();
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-06 21:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-05 21:35 [PATCH] PTI: unbreak EFI old_memmap Jiri Kosina
2018-01-06 11:52 ` [tip:x86/pti] x86/pti: Unbreak " tip-bot for Jiri Kosina
2018-01-06 21:03 ` tip-bot for Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome