linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Fleming <matt@console-pimps.org>
To: Borislav Petkov <bp@alien8.de>
Cc: X86 ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	Borislav Petkov <bp@suse.de>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Vivek Goyal <vgoyal@redhat.com>, Dave Young <dyoung@redhat.com>,
	linux-efi@vger.kernel.org, fwts-devel@lists.ubuntu.com
Subject: Re: [PATCH 12/12] EFI: Runtime services virtual mapping
Date: Mon, 28 Oct 2013 11:22:46 +0000	[thread overview]
Message-ID: <20131028112246.GK1982@console-pimps.org> (raw)
In-Reply-To: <20131008164831.GD16793@pd.tnic>

On Tue, 08 Oct, at 06:48:31PM, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> We map the EFI regions needed for runtime services contiguously on
> virtual addresses starting from -4G down for a total max space of 64G.
> This way, we provide for stable runtime services addresses across
> kernels so that a kexec'd kernel can still use them.
> 
> This way, they're mapped in a separate pagetable so that we don't
> pollute the kernel namespace (you can see how the whole ioremapping and
> saving and restoring of PGDs is gone now).
> 
> Also, add a chicken bit called "efi=old_map" which can be used as a
> fallback to the old runtime services mapping method in case there's some
> b0rkage with a particular EFI implementation (haha, it is hard to hold
> up the sarcasm here...).
> 
> Add UEFI RT VA space to Documentation/x86/x86_64/mm.txt, while at it.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> ---
>  Documentation/x86/x86_64/mm.txt      |  7 +++
>  arch/x86/include/asm/efi.h           | 47 ++++++++++++-------
>  arch/x86/include/asm/pgtable_types.h |  3 +-
>  arch/x86/platform/efi/efi.c          | 91 ++++++++++++++++++++++++++----------
>  arch/x86/platform/efi/efi_32.c       |  8 +++-
>  arch/x86/platform/efi/efi_64.c       | 83 ++++++++++++++++++++++++++++++++
>  arch/x86/platform/efi/efi_stub_64.S  | 54 +++++++++++++++++++++
>  include/linux/efi.h                  |  1 +
>  8 files changed, 251 insertions(+), 43 deletions(-)

[...]

> @@ -949,8 +978,17 @@ void __init efi_enter_virtual_mode(void)
>  		count++;
>  	}
>  
> +#ifdef CONFIG_X86_64
> +	efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
> +
> +	if (!test_bit(EFI_OLD_MEMMAP, &x86_efi_facility))
> +		efi_scratch.use_pgd = true;
> +#endif
> +
>  	BUG_ON(!efi.systab);

Could you use the efi_enabled() function to test for EFI_OLD_MEMMAP
instead of test_bit()?

[...]

> diff --git a/include/linux/efi.h b/include/linux/efi.h
> index fa47d80ab4b5..beff433aa8c0 100644
> --- a/include/linux/efi.h
> +++ b/include/linux/efi.h
> @@ -632,6 +632,7 @@ extern int __init efi_setup_pcdp_console(char *);
>  #define EFI_RUNTIME_SERVICES	3	/* Can we use runtime services? */
>  #define EFI_MEMMAP		4	/* Can we use EFI memory map? */
>  #define EFI_64BIT		5	/* Is the firmware 64-bit? */
> +#define EFI_OLD_MEMMAP		6	/* Use old mapping method */

Hmm... I'm wondering whether this should actually be,

#define EFI_ARCH_1		6	/* Architecture-specific option */

and in arch/x86/include/ we could then do,

/*
 * Lots of info about why we need to switch to a new mapping scheme, but
 * also why the old scheme might be desirable....
 */
#define EFI_OLD_MEMMAP		EFI_ARCH_1

This way we won't exhaust the bitspace quite so soon (since ARM/ARM64
can reuse EFI_ARCH_1 if they need it), plus this memory mapping method
is a very architecture-specific thing and so makes sense to hide it in
the bowels of arch/x86. If it turns out that ARM/ARM64 need the exact
same config option we can delete EFI_ARCH_1 and move EFI_OLD_MEMMAP to
include/linux/efi.h just like in your original patch. 

What do you think?

-- 
Matt Fleming, Intel Open Source Technology Center

  parent reply	other threads:[~2013-10-28 11:22 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-19 14:54 [PATCH 00/11] EFI runtime services virtual mapping Borislav Petkov
2013-09-19 14:54 ` [PATCH 01/11] efi: Simplify EFI_DEBUG Borislav Petkov
2013-09-19 14:54 ` [PATCH 02/11] efi: Remove EFI_PAGE_SHIFT and EFI_PAGE_SIZE Borislav Petkov
2013-09-20 10:42   ` Matt Fleming
2013-09-21 15:21     ` Leif Lindholm
2013-09-21 15:41       ` Borislav Petkov
2013-09-21 15:50         ` Borislav Petkov
2013-09-21 16:01           ` Leif Lindholm
2013-09-21 16:03             ` Borislav Petkov
2013-09-21 15:59         ` Leif Lindholm
2013-09-19 14:54 ` [PATCH 03/11] x86, pageattr: Lookup address in an arbitrary PGD Borislav Petkov
2013-09-19 14:54 ` [PATCH 04/11] x86, pageattr: Add a PGD pagetable populating function Borislav Petkov
2013-09-19 14:54 ` [PATCH 05/11] x86, pageattr: Add a PUD " Borislav Petkov
2013-09-19 14:54 ` [PATCH 06/11] x86, pageattr: Add a PMD " Borislav Petkov
2013-09-19 14:54 ` [PATCH 07/11] x86, pageattr: Add a PTE " Borislav Petkov
2013-09-19 14:54 ` [PATCH 08/11] x86, pageattr: Add a PUD error unwinding path Borislav Petkov
2013-09-19 14:54 ` [PATCH 09/11] x86, pageattr: Add last levels of error path Borislav Petkov
2013-09-19 14:54 ` [PATCH 10/11] x86, cpa: Map in an arbitrary pgd Borislav Petkov
2013-09-19 14:54 ` [PATCH 11/11] EFI: Runtime services virtual mapping Borislav Petkov
2013-09-21 11:39   ` [PATCH -v2] " Borislav Petkov
2013-09-22 12:35     ` Dave Young
2013-09-22 13:37       ` Borislav Petkov
2013-09-22 14:00         ` Dave Young
2013-09-22 14:31           ` Dave Young
2013-09-22 15:27         ` H. Peter Anvin
2013-09-22 16:38           ` Borislav Petkov
2013-09-23  5:45           ` Dave Young
2013-09-24  2:52           ` Dave Young
2013-09-24  3:06             ` H. Peter Anvin
2013-09-24  4:57               ` Dave Young
2013-09-24  4:58                 ` Dave Young
2013-09-24  5:23                   ` Dave Young
2013-09-24  8:57                     ` Dave Young
2013-09-24  9:43                 ` Borislav Petkov
2013-09-24 10:01                   ` Dave Young
2013-09-24 12:45                   ` Dave Young
2013-10-02 10:04               ` Borislav Petkov
2013-10-02 15:43                 ` H. Peter Anvin
2013-10-02 17:05                   ` Borislav Petkov
2013-10-02 17:32                     ` H. Peter Anvin
2013-10-02 18:42                       ` Borislav Petkov
2013-10-02 18:46                         ` H. Peter Anvin
2013-10-04  9:42                           ` Borislav Petkov
2013-10-04 14:43                             ` H. Peter Anvin
2013-10-04 14:50                               ` Borislav Petkov
2013-09-23  5:47     ` Dave Young
2013-09-23  6:29       ` Borislav Petkov
2013-09-23  7:08         ` Dave Young
2013-09-23  8:45     ` Borislav Petkov
2013-09-25  9:24     ` Borislav Petkov
2013-09-20  7:29 ` [PATCH 00/11] EFI runtime " Dave Young
2013-09-20  8:19   ` Dave Young
2013-09-20  9:33     ` Borislav Petkov
2013-09-20 10:07       ` Dave Young
2013-09-20  9:05   ` Borislav Petkov
2013-09-20  9:44     ` Matt Fleming
2013-09-20  9:49     ` Matt Fleming
2013-09-20 10:02       ` Borislav Petkov
2013-09-20 11:51     ` Dave Young
2013-09-20 12:29     ` Matt Fleming
2013-09-20 14:04       ` Dave Young
2013-10-08 16:45 ` Borislav Petkov
2013-10-08 16:47   ` [PATCH 11/12] efi: Add an efi= kernel command line parameter Borislav Petkov
2013-10-28 11:02     ` Matt Fleming
2013-10-28 11:10       ` Borislav Petkov
2013-10-08 16:48   ` [PATCH 12/12] EFI: Runtime services virtual mapping Borislav Petkov
2013-10-10  8:06     ` Dave Young
2013-10-10  8:14       ` Dave Young
2013-10-10  8:58         ` Borislav Petkov
2013-10-10 12:34           ` Matt Fleming
2013-10-11  6:24             ` Dave Young
2013-10-11  7:41               ` Borislav Petkov
2013-10-12  7:54                 ` Dave Young
2013-10-12 10:13                   ` Matt Fleming
2013-10-12 10:30                     ` Borislav Petkov
2013-10-13  3:11                       ` Dave Young
2013-10-13  9:25                         ` Borislav Petkov
2013-10-14 15:58                           ` Borislav Petkov
2013-10-21 12:47                             ` Dave Young
2013-10-21 13:37                               ` Borislav Petkov
2013-10-21 15:04                                 ` Dave Young
2013-10-22 11:18                                   ` Borislav Petkov
2013-10-23  2:17                                     ` Dave Young
2013-10-23 12:25                                       ` Borislav Petkov
2013-10-23 12:37                                         ` Matthew Garrett
2013-10-23 12:51                                         ` Dave Young
2013-10-23 13:11                                           ` Borislav Petkov
2013-10-26 15:50                                 ` Matt Fleming
2013-10-13  3:06                     ` Dave Young
2013-10-11 10:27               ` Matt Fleming
2013-10-11 13:42                 ` Dave Young
2013-10-12  2:14                   ` Dave Young
2013-10-14 15:57                     ` Peter Jones
2013-10-16  6:27                       ` Dave Young
2013-10-28 11:22     ` Matt Fleming [this message]
2013-10-28 16:00       ` Borislav Petkov
2013-10-29  6:47     ` Dave Young
2013-10-29  9:40       ` Borislav Petkov
2013-10-30  9:32         ` Dave Young
2013-10-30 10:45           ` Borislav Petkov
2013-10-31  7:07             ` Dave Young
2013-10-14 13:04   ` [PATCH 00/11] EFI runtime " Matt Fleming

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=20131028112246.GK1982@console-pimps.org \
    --to=matt@console-pimps.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=dyoung@redhat.com \
    --cc=fwts-devel@lists.ubuntu.com \
    --cc=hpa@zytor.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).