From: Andrea Arcangeli <aarcange@redhat.com> To: Jiri Kosina <jikos@kernel.org> Cc: Dave Hansen <dave.hansen@linux.intel.com>, Yisheng Xie <xieyisheng1@huawei.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, richard.fellner@student.tugraz.at, moritz.lipp@iaik.tugraz.at, daniel.gruss@iaik.tugraz.at, michael.schwarz@iaik.tugraz.at, luto@kernel.org, Linus Torvalds <torvalds@linux-foundation.org>, keescook@google.com, hughd@google.com, x86@kernel.org Subject: Re: [PATCH 05/23] x86, kaiser: unmap kernel from userspace page tables (core patch) Date: Fri, 5 Jan 2018 20:55:35 +0100 [thread overview] Message-ID: <20180105195535.GZ26807@redhat.com> (raw) In-Reply-To: <nycvar.YFH.7.76.1801052014050.11852@cbobk.fhfr.pm> On Fri, Jan 05, 2018 at 08:17:17PM +0100, Jiri Kosina wrote: > On Fri, 5 Jan 2018, Dave Hansen wrote: > > > > --- a/arch/x86/platform/efi/efi_64.c > > > +++ b/arch/x86/platform/efi/efi_64.c > > > @@ -95,6 +95,12 @@ pgd_t * __init efi_call_phys_prolog(void > > > save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE); > > > vaddress = (unsigned long)__va(pgd * PGDIR_SIZE); > > > set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress)); > > > + /* > > > + * pgprot API doesn't clear it for PGD > > > + * > > > + * Will be brought back automatically in _epilog() > > > + */ > > > + pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX; > > > } > > > __flush_tlb_all(); Upstream & downstream looks different, how the above looks completely different I don't know, but I got it and updating is easy. Great catch. > > > > Wait a sec... Where does the _PAGE_USER come from? Shouldn't we see > > the &init_mm in there and *not* set _PAGE_USER? > > That's because pgd_populate() uses _PAGE_TABLE and not _KERNPG_TABLE for > reasons that are behind me. For vsyscalls? I also had to single out warnings out of init_mm.pgd for the same reasons. How does the below (untested) look? >From ab949b80124588c4791568429cf8a234dda16340 Mon Sep 17 00:00:00 2001 From: Jiri Kosina <jikos@kernel.org> Date: Fri, 5 Jan 2018 20:00:25 +0100 Subject: [RHEL7.5 PATCH 1/1] x86/kaiser/efi: unbreak EFI old_memmap 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> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> --- 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) {
WARNING: multiple messages have this Message-ID (diff)
From: Andrea Arcangeli <aarcange@redhat.com> To: Jiri Kosina <jikos@kernel.org> Cc: Dave Hansen <dave.hansen@linux.intel.com>, Yisheng Xie <xieyisheng1@huawei.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, richard.fellner@student.tugraz.at, moritz.lipp@iaik.tugraz.at, daniel.gruss@iaik.tugraz.at, michael.schwarz@iaik.tugraz.at, luto@kernel.org, Linus Torvalds <torvalds@linux-foundation.org>, keescook@google.com, hughd@google.com, x86@kernel.org Subject: Re: [PATCH 05/23] x86, kaiser: unmap kernel from userspace page tables (core patch) Date: Fri, 5 Jan 2018 20:55:35 +0100 [thread overview] Message-ID: <20180105195535.GZ26807@redhat.com> (raw) In-Reply-To: <nycvar.YFH.7.76.1801052014050.11852@cbobk.fhfr.pm> On Fri, Jan 05, 2018 at 08:17:17PM +0100, Jiri Kosina wrote: > On Fri, 5 Jan 2018, Dave Hansen wrote: > > > > --- a/arch/x86/platform/efi/efi_64.c > > > +++ b/arch/x86/platform/efi/efi_64.c > > > @@ -95,6 +95,12 @@ pgd_t * __init efi_call_phys_prolog(void > > > save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE); > > > vaddress = (unsigned long)__va(pgd * PGDIR_SIZE); > > > set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress)); > > > + /* > > > + * pgprot API doesn't clear it for PGD > > > + * > > > + * Will be brought back automatically in _epilog() > > > + */ > > > + pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX; > > > } > > > __flush_tlb_all(); Upstream & downstream looks different, how the above looks completely different I don't know, but I got it and updating is easy. Great catch. > > > > Wait a sec... Where does the _PAGE_USER come from? Shouldn't we see > > the &init_mm in there and *not* set _PAGE_USER? > > That's because pgd_populate() uses _PAGE_TABLE and not _KERNPG_TABLE for > reasons that are behind me. For vsyscalls? I also had to single out warnings out of init_mm.pgd for the same reasons. How does the below (untested) look?
next prev parent reply other threads:[~2018-01-05 19:55 UTC|newest] Thread overview: 131+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-11-23 0:34 [PATCH 00/23] [v4] KAISER: unmap most of the kernel from userspace page tables Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 01/23] x86, kaiser: disable global pages by default with KAISER Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 02/23] x86, kaiser: prepare assembly for entry/exit CR3 switching Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 03/23] x86, kaiser: introduce user-mapped per-cpu areas Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 04/23] x86, kaiser: mark per-cpu data structures required for entry/exit Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 05/23] x86, kaiser: unmap kernel from userspace page tables (core patch) Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 4:07 ` Andy Lutomirski 2017-11-23 4:07 ` Andy Lutomirski 2017-11-26 16:10 ` Andy Lutomirski 2017-11-26 16:10 ` Andy Lutomirski 2017-11-26 16:24 ` Dave Hansen 2017-11-26 16:24 ` Dave Hansen 2017-11-26 16:29 ` Andy Lutomirski 2017-11-26 16:29 ` Andy Lutomirski 2018-01-05 4:16 ` Yisheng Xie 2018-01-05 4:16 ` Yisheng Xie 2018-01-05 5:18 ` Dave Hansen 2018-01-05 5:18 ` Dave Hansen 2018-01-05 6:16 ` Yisheng Xie 2018-01-05 6:16 ` Yisheng Xie 2018-01-05 6:29 ` Dave Hansen 2018-01-05 6:29 ` Dave Hansen 2018-01-05 11:49 ` Andrea Arcangeli 2018-01-05 11:49 ` Andrea Arcangeli 2018-01-05 18:19 ` Jiri Kosina 2018-01-05 18:19 ` Jiri Kosina 2018-01-05 19:00 ` Jiri Kosina 2018-01-05 19:00 ` Jiri Kosina 2018-01-05 19:03 ` Dave Hansen 2018-01-05 19:03 ` Dave Hansen 2018-01-05 19:17 ` Jiri Kosina 2018-01-05 19:17 ` Jiri Kosina 2018-01-05 19:18 ` Jiri Kosina 2018-01-05 19:18 ` Jiri Kosina 2018-01-05 19:55 ` Andrea Arcangeli [this message] 2018-01-05 19:55 ` Andrea Arcangeli 2018-01-05 21:07 ` Dave Hansen 2018-01-05 21:07 ` Dave Hansen 2018-01-05 21:14 ` Jiri Kosina 2018-01-05 21:14 ` Jiri Kosina 2018-01-05 21:29 ` Andy Lutomirski 2018-01-05 21:29 ` Andy Lutomirski 2018-01-05 22:48 ` Hugh Dickins 2018-01-05 22:48 ` Hugh Dickins 2018-01-06 4:54 ` Hanjun Guo 2018-01-06 4:54 ` Hanjun Guo 2018-01-06 6:06 ` Dave Hansen 2018-01-06 6:28 ` Hanjun Guo 2018-01-06 6:28 ` Hanjun Guo 2018-01-06 6:53 ` Hanjun Guo 2018-01-06 6:53 ` Hanjun Guo 2018-01-06 7:55 ` Dave Hansen 2018-01-06 7:55 ` Dave Hansen 2018-01-06 8:42 ` Hanjun Guo 2018-01-06 8:42 ` Hanjun Guo 2018-01-06 7:51 ` Dave Hansen 2018-01-06 7:51 ` Dave Hansen 2018-01-06 17:22 ` Andrea Arcangeli 2018-01-06 17:22 ` Andrea Arcangeli 2017-11-23 0:34 ` [PATCH 06/23] x86, kaiser: allow NX poison to be set in p4d/pgd Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 07/23] x86, kaiser: make sure static PGDs are 8k in size Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 08/23] x86, kaiser: map cpu entry area Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 09/23] x86, kaiser: map dynamically-allocated LDTs Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 19:42 ` Eric Biggers 2017-11-23 19:42 ` Eric Biggers 2017-11-23 20:12 ` Andy Lutomirski 2017-11-23 20:12 ` Andy Lutomirski 2017-11-23 0:34 ` [PATCH 10/23] x86, kaiser: map espfix structures Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 0:34 ` [PATCH 11/23] x86, kaiser: map entry stack variables Dave Hansen 2017-11-23 0:34 ` Dave Hansen 2017-11-23 3:31 ` Andy Lutomirski 2017-11-23 3:31 ` Andy Lutomirski 2017-11-23 15:37 ` Dave Hansen 2017-11-23 15:37 ` Dave Hansen 2017-11-23 15:55 ` Andy Lutomirski 2017-11-23 15:55 ` Andy Lutomirski 2017-11-23 0:35 ` [PATCH 12/23] x86, kaiser: map virtually-addressed performance monitoring buffers Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 13/23] x86, mm: Move CR3 construction functions Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 14/23] x86, mm: remove hard-coded ASID limit checks Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 15/23] x86, mm: put mmu-to-h/w ASID translation in one place Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 16/23] x86, pcid, kaiser: allow flushing for future ASID switches Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 17/23] x86, kaiser: use PCID feature to make user and kernel switches faster Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 18/23] x86, kaiser: disable native VSYSCALL Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 19/23] x86, kaiser: add debugfs file to turn KAISER on/off at runtime Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 20/23] x86, kaiser: add a function to check for KAISER being enabled Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-25 1:23 ` Eduardo Valentin 2017-11-25 1:23 ` Eduardo Valentin 2017-11-23 0:35 ` [PATCH 21/23] x86, kaiser: un-poison PGDs at runtime Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-25 1:17 ` Eduardo Valentin 2017-11-25 1:17 ` Eduardo Valentin 2017-11-23 0:35 ` [PATCH 22/23] x86, kaiser: allow KAISER to be enabled/disabled " Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 0:35 ` [PATCH 23/23] x86, kaiser: add Kconfig Dave Hansen 2017-11-23 0:35 ` Dave Hansen 2017-11-23 7:23 ` [PATCH 00/23] [v4] KAISER: unmap most of the kernel from userspace page tables Ingo Molnar 2017-11-23 7:23 ` Ingo Molnar 2017-11-23 7:27 ` Ingo Molnar 2017-11-23 7:27 ` Ingo Molnar 2017-11-23 7:32 ` Ingo Molnar 2017-11-23 7:32 ` Ingo Molnar 2017-11-23 15:02 ` Dave Hansen 2017-11-23 15:02 ` Dave Hansen 2017-11-23 16:20 ` Dave Hansen 2017-11-23 16:20 ` Dave Hansen 2017-11-24 6:35 ` Ingo Molnar 2017-11-24 6:35 ` Ingo Molnar 2017-11-24 6:41 ` Dave Hansen 2017-11-24 6:41 ` Dave Hansen 2017-11-24 7:33 ` Ingo Molnar 2017-11-24 7:33 ` Ingo Molnar
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180105195535.GZ26807@redhat.com \ --to=aarcange@redhat.com \ --cc=daniel.gruss@iaik.tugraz.at \ --cc=dave.hansen@linux.intel.com \ --cc=hughd@google.com \ --cc=jikos@kernel.org \ --cc=keescook@google.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=luto@kernel.org \ --cc=michael.schwarz@iaik.tugraz.at \ --cc=moritz.lipp@iaik.tugraz.at \ --cc=richard.fellner@student.tugraz.at \ --cc=torvalds@linux-foundation.org \ --cc=x86@kernel.org \ --cc=xieyisheng1@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.