From: Matt Fleming <matt@codeblueprint.co.uk>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>,
Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
"Ravi V. Shankar" <ravi.v.shankar@intel.com>,
Toshi Kani <toshi.kani@hp.com>, Brian Gerst <brgerst@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Luis Rodriguez <mcgrof@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
ricardo.neri@intel.com, Hugh Dickins <hughd@google.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [tip:efi/core] x86/mm/pat: Use _PAGE_GLOBAL bit for EFI page table mappings
Date: Thu, 25 Feb 2016 15:27:34 +0000 [thread overview]
Message-ID: <20160225152734.GA2772@codeblueprint.co.uk> (raw)
In-Reply-To: <CALCETrX5NPHM=a_C7FmDA_j4kBNU=fx5Zu5mBGsgLZrth3KUVw@mail.gmail.com>
On Wed, 24 Feb, at 11:49:23AM, Andy Lutomirski wrote:
> On Wed, Feb 24, 2016 at 11:33 AM, Matt Fleming <matt@codeblueprint.co.uk> wrote:
> > On Wed, 24 Feb, at 08:36:33AM, Andy Lutomirski wrote:
> >> On Wed, Feb 24, 2016 at 8:20 AM, Borislav Petkov <bp@alien8.de> wrote:
> >> > On Wed, Feb 24, 2016 at 02:10:46PM +0000, Matt Fleming wrote:
> >> >> > Normally, the only pages with are _PAGE_GLOBAL are those that are in
> >> >> > the normal kernel mappings (swapper_pg_dir and normal mm_struct pgds).
> >> >> > By allowing _PAGE_GLOBAL to be set in EFI mappings, you're breaking
> >> >> > that convention, which forces you to use extra-expensive
> >> >> > __flush_tlb_all calls in efi_call_virt.
> >> >
> >> > Hold on, do you mean the __flush_tlb_all() in the CONFIG_EFI_MIXED code?
> >> >
> >> > That's mixed mode. I think you mean the FLUSH_TLB_ALL in efi_call.
> >> > That's EFI on 64-bit but that is mandated by the spec, AFAIR.
> >>
> >> I mean the one in efi_call_virt. Why would the spec mandate a TLB
> >> flush at all? EFI runtime services have no business touching the
> >> paging structures directly. Heck, the 32-bit ones don't even know the
> >> *format* of the paging structures.
> >
> > Right, and it would necessitate copying out arguments because the
> > firmware won't understand where/how the kernel has mapped things.
> >
> > No firmware is going to be doing that.
>
> Just so I understand correctly: could we get away with putting the EFI
> virtual runtime mappings at positive (user) addresses for 64-bit UEFI,
> or is there some reason that we need the high bit set?
Good question. There are multiple parts to this answer:
1) Some firmware is known to break when entered via the identity
addresses (VA==PA)
2) Kexec cares the most about where we map things because the region
has to be static across Kexec reboots. We do pass the kernel's EFI
memory map regions between Kexec kernels but that region clearly
needs to be available across kernel versions
It shouldn't be possible to conflict with userspace mappings or
anything like that because we should never be accessing userspace
addresses during EFI runtime services calls - all relevant data is
copied to a kernel buffer or such. Userspace isn't even mapped now
we've got completely separate EFI page tables.
I don't think there's anything else that would stop us clearing the
high bit and moving the EFI virtual mapping region somewhere else.
Boris?
> If we could use positive addresses, then we could use the existing
> use_mm infrastructure directly with no funny business at all except to
> the extent that we might need to use unusual APIs to set up the VMAs
> (if we use real VMAs) in the first place. (We could cheat and
> allocate a single monstrous VM_MIXEDMAP or VM_PFNMAP vma with a .fault
> handler that always fails.) If we have to use negative addresses,
> then we'll always be stuck with a funny pgd, but we could still
> probably use use_mm instead of manually fiddling with cr3.
We don't use VMAs at the moment.
Having a custom .fault handler could be a very interesting idea
because we've talked about wanting to do EFI-specific things in the
past if we fault while executing firmware, e.g. printing warnings in
the kernel log indicating the firmware is known to be buggy because it
performed an access not compliant with the spec. See 1) above.
> Some day I want to experiment with calling runtime services at CPL 3,
> too :) We'd want to add some infrastructure to permit kernel threads
> to run through the entry/exit code as if they were user processes, but
> there's nothing conceptually wrong with that. We already allow kernel
> threads to call execve and "return" to real user mode, so it's not
> much of a stretch. The main issue would be dealing with signal
> handling and such -- we'd want to report faults back to the kernel
> thread's CPL3-invocation thunks rather than delivering a signal at CPL
> 3.
Right, more isolation is better. I'm not sure we could get all the way
to CPL 3 but I wouldn't begrudge anyone trying.
next prev parent reply other threads:[~2016-02-25 15:27 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 12:35 [GIT PULL 00/13] EFI changes for v4.6 part 2 Matt Fleming
2016-02-17 12:35 ` Matt Fleming
2016-02-17 12:35 ` [PATCH 03/13] x86/mm/pageattr: Use _PAGE_GLOBAL bit for EFI page table mappings Matt Fleming
2016-02-22 12:13 ` [tip:efi/core] x86/mm/pat: " =?UTF-8?B?dGlwLWJvdCBmb3IgU2FpIFByYW5lZXRoIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-23 17:47 ` Andy Lutomirski
2016-02-23 18:08 ` Linus Torvalds
2016-02-23 18:12 ` Borislav Petkov
2016-02-24 2:09 ` H. Peter Anvin
2016-02-24 2:13 ` H. Peter Anvin
2016-02-25 8:59 ` Ingo Molnar
2016-02-24 0:50 ` Sai Praneeth Prakhya
2016-02-24 2:43 ` Andy Lutomirski
2016-02-24 14:10 ` Matt Fleming
2016-02-24 16:20 ` Borislav Petkov
2016-02-24 16:36 ` Andy Lutomirski
2016-02-24 18:56 ` Linus Torvalds
2016-02-24 19:45 ` Matt Fleming
2016-02-24 19:50 ` Andy Lutomirski
2016-02-29 10:56 ` Sylvain Chouleur
2016-03-02 11:20 ` Matt Fleming
2016-02-24 19:33 ` Matt Fleming
2016-02-24 19:49 ` Andy Lutomirski
2016-02-25 9:06 ` Ingo Molnar
2016-02-25 15:27 ` Matt Fleming [this message]
2016-02-24 16:41 ` Borislav Petkov
2016-02-24 16:47 ` Andy Lutomirski
2016-02-24 16:39 ` Andy Lutomirski
2016-02-25 16:00 ` Matt Fleming
2016-02-17 12:35 ` [PATCH 04/13] efi/arm64: Drop __init annotation from handle_kernel_image() Matt Fleming
2016-02-22 12:14 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
[not found] ` <1455712566-16727-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-02-17 12:35 ` [PATCH 01/13] efi: Reformat GUID tables to follow the format in UEFI spec Matt Fleming
2016-02-17 12:35 ` Matt Fleming
2016-02-22 12:12 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgUGV0ZXIgSm9uZXMgPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-17 12:35 ` [PATCH 02/13] efi/runtime-wrappers: Run UEFI Runtime Services with interrupts enabled Matt Fleming
2016-02-17 12:35 ` Matt Fleming
2016-02-22 12:13 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-17 12:35 ` [PATCH 05/13] arm64: vmlinux.lds.S: Handle .init.rodata.xxx and .init.bss sections Matt Fleming
2016-02-17 12:35 ` Matt Fleming
2016-02-22 12:14 ` [tip:efi/core] arm64/vmlinux.lds.S: " =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-17 12:36 ` [PATCH 13/13] x86/efi: Only map kernel text for EFI mixed mode Matt Fleming
2016-02-17 12:36 ` Matt Fleming
2016-02-22 12:17 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgU2FpIFByYW5lZXRoIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-17 12:35 ` [PATCH 06/13] efi/efistub: Prevent __init annotations from being used Matt Fleming
2016-02-22 12:14 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-17 12:36 ` [PATCH 07/13] efi/arm-init: Use read-only early mappings Matt Fleming
2016-02-22 12:15 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-17 12:36 ` [PATCH 08/13] efi/arm: Check for LPAE support before booting a LPAE kernel Matt Fleming
2016-02-22 12:15 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-17 12:36 ` [PATCH 09/13] efi/arm64: Check for h/w support before booting a >4 KB granule kernel Matt Fleming
2016-02-22 12:16 ` [tip:efi/core] efi/arm64: Check for h/w support before booting a >4 KB granular kernel =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
[not found] ` <1455712566-16727-10-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-03-06 3:35 ` [PATCH 09/13] efi/arm64: Check for h/w support before booting a >4 KB granule kernel Ard Biesheuvel
2016-03-06 3:35 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-ZHz9Z6YyusLZdKJA4QPJ8fkxVWaA=EQvTM5iSLM7c1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-07 11:02 ` Matt Fleming
2016-03-07 11:02 ` Matt Fleming
[not found] ` <20160307110243.GB27675-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-03-07 11:05 ` Ard Biesheuvel
2016-03-07 11:05 ` Ard Biesheuvel
2016-02-17 12:36 ` [PATCH 10/13] efi/arm*: Perform hardware compatibility check Matt Fleming
2016-02-22 12:16 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgQXJkIEJpZXNoZXV2ZWwgPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-17 12:36 ` [PATCH 11/13] x86/mm/pageattr: Don't implicitly allow _PAGE_RW in kernel_map_pages_in_pgd() Matt Fleming
2016-02-22 12:16 ` [tip:efi/core] x86/mm/pat: " =?UTF-8?B?dGlwLWJvdCBmb3IgU2FpIFByYW5lZXRoIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-17 12:36 ` [PATCH 12/13] x86/efi: Map EFI_MEMORY_{XP,RO} memory region bits to EFI page tables Matt Fleming
2016-02-22 12:17 ` [tip:efi/core] " =?UTF-8?B?dGlwLWJvdCBmb3IgU2FpIFByYW5lZXRoIDx0aXBib3RAenl0b3IuY29tPg==?=
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=20160225152734.GA2772@codeblueprint.co.uk \
--to=matt@codeblueprint.co.uk \
--cc=akpm@linux-foundation.org \
--cc=ard.biesheuvel@linaro.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mcgrof@suse.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.v.shankar@intel.com \
--cc=ricardo.neri@intel.com \
--cc=sai.praneeth.prakhya@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=toshi.kani@hp.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: link
Be 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.