From: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Ard Biesheuvel
<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Catalin Marinas <Catalin.Marinas-5wv7dgnIgG8@public.gmane.org>,
Will Deacon <Will.Deacon-5wv7dgnIgG8@public.gmane.org>,
"matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org"
<bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>,
"dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
<dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"geoff.levand-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<geoff.levand-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
<msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v4 6/8] arm64/efi: move SetVirtualAddressMap() to UEFI stub
Date: Tue, 6 Jan 2015 17:13:59 +0000 [thread overview]
Message-ID: <20150106171359.GE3827@bivouac.eciton.net> (raw)
In-Reply-To: <20150105162016.GD26699@leverpostej>
On Mon, Jan 05, 2015 at 04:20:16PM +0000, Mark Rutland wrote:
> Hi Ard,
>
> I have a few (minor) comments below.
>
> On Mon, Dec 22, 2014 at 10:59:02AM +0000, Ard Biesheuvel wrote:
> > In order to support kexec, the kernel needs to be able to deal with the
> > state of the UEFI firmware after SetVirtualAddressMap() has been called.
> > To avoid having separate code paths for non-kexec and kexec, let's move
> > the call to SetVirtualAddressMap() to the stub: this will guarantee us
> > that it will only be called once (since the stub is not executed during
> > kexec), and ensures that the UEFI state is identical between kexec and
> > normal boot.
> >
> > This implies that the layout of the virtual mapping needs to be created
> > by the stub as well. All regions are rounded up to a naturally aligned
> > multiple of 64 KB (for compatibility with 64k pages kernels) and recorded
> > in the UEFI memory map. The kernel proper reads those values and installs
> > the mappings in a dedicated set of page tables that are swapped in during
> > UEFI Runtime Services calls.
> >
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > ---
> > arch/arm64/include/asm/efi.h | 20 +++-
> > arch/arm64/kernel/efi.c | 223 ++++++++++++++++++++-----------------
> > arch/arm64/kernel/setup.c | 1 +
> > drivers/firmware/efi/libstub/fdt.c | 137 ++++++++++++++++++++++-
> > 4 files changed, 270 insertions(+), 111 deletions(-)
>
> [...]
>
> > +static void efi_set_pgd(struct mm_struct *mm)
> > +{
> > + cpu_switch_mm(mm->pgd, mm);
> > + flush_tlb_all();
> > + if (icache_is_aivivt())
> > + __flush_icache_all();
> > +}
>
> Do we have any idea how often we call runtime services?
Very rarely.
> I assume not all that often (read the RTC at boot, set/get variables).
And in future possibly:
- adding capsules
- getwakeuptime/setwakeuptime
- saving time to RTC on shutdown
- reboot
All of which are uid0-invoked manual operations.
The only exception I can think of is if we're using the efivarfs
backend for pstore.
> If we're nuking the TLBs and I-cache a lot we'll probably need to
> reserve an asid for the EFI virtmap.
> > @@ -248,12 +337,52 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
> > }
> > }
> >
> > + /*
> > + * Update the memory map with virtual addresses. The function will also
> > + * populate the spare second half of the memory_map allocation with
> > + * copies of just the EFI_MEMORY_RUNTIME entries so that we can pass it
> > + * straight into SetVirtualAddressMap()
> > + */
> > + update_memory_map(memory_map, map_size, desc_size,
> > + &runtime_entry_count);
> > +
> > + pr_efi(sys_table,
> > + "Exiting boot services and installing virtual address map...\n");
>
> I believe that the memory map is allowed to change as a result of this
> call, so I think this needs to be moved before update_memory_map.
You are absolutely correct - but update_memory_map() only modifies the
copy of the memory map. The message needs to move all the way to
before the calll to get_memory_map(), and for practical reasons
perhaps before the while(1) loop.
/
Leif
next prev parent reply other threads:[~2015-01-06 17:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-22 10:58 [PATCH v4 0/8] stable UEFI virtual mappings for kexec Ard Biesheuvel
[not found] ` <1419245944-2424-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-12-22 10:58 ` [PATCH v4 1/8] arm64/mm: add explicit struct_mm argument to __create_mapping() Ard Biesheuvel
2014-12-22 10:58 ` [PATCH v4 2/8] arm64/mm: add create_pgd_mapping() to create private page tables Ard Biesheuvel
2014-12-22 10:58 ` [PATCH v4 3/8] efi: split off remapping code from efi_config_init() Ard Biesheuvel
[not found] ` <1419245944-2424-4-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-05 14:55 ` Matt Fleming
2015-01-05 21:56 ` Borislav Petkov
2014-12-22 10:59 ` [PATCH v4 4/8] efi: efistub: allow allocation alignment larger than EFI_PAGE_SIZE Ard Biesheuvel
[not found] ` <1419245944-2424-5-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-12-23 16:45 ` Borislav Petkov
[not found] ` <20141223164549.GB3810-fF5Pk5pvG8Y@public.gmane.org>
2014-12-29 9:25 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_+scCHYuXccgsvn9THsbP24OfyjvjN9XtEVe4nMdQtig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-29 9:47 ` Borislav Petkov
[not found] ` <20141229094732.GA16051-K5JNixvcfoxupOikMc4+xw@public.gmane.org>
2015-01-05 11:24 ` Ard Biesheuvel
2014-12-22 10:59 ` [PATCH v4 5/8] arm64/efi: set EFI_ALLOC_ALIGN to 64 KB Ard Biesheuvel
2015-01-06 16:37 ` Leif Lindholm
2014-12-22 10:59 ` [PATCH v4 6/8] arm64/efi: move SetVirtualAddressMap() to UEFI stub Ard Biesheuvel
[not found] ` <1419245944-2424-7-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-05 16:20 ` Mark Rutland
2015-01-06 17:13 ` Leif Lindholm [this message]
2015-01-07 18:05 ` Ard Biesheuvel
2015-01-05 16:54 ` Matt Fleming
[not found] ` <20150105165402.GE3163-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2015-01-06 18:01 ` Leif Lindholm
[not found] ` <20150106180120.GF3827-t77nlHhSwNqAroYi2ySoxKxOck334EZe@public.gmane.org>
2015-01-12 10:43 ` Matt Fleming
2015-01-07 18:15 ` Ard Biesheuvel
2015-01-07 12:06 ` Leif Lindholm
[not found] ` <20150107120608.GJ3827-t77nlHhSwNqAroYi2ySoxKxOck334EZe@public.gmane.org>
2015-01-07 12:16 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_k0_anqvm24P8J4WaMrFLMxOhQETAfUb6xmzaJ+Z2vBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-07 12:25 ` Leif Lindholm
[not found] ` <20150107122515.GK3827-t77nlHhSwNqAroYi2ySoxKxOck334EZe@public.gmane.org>
2015-01-07 12:30 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-aRkoRj5zVXrsBc0APCehZ9W926J6fxH380K9EURXe_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-07 12:56 ` Leif Lindholm
2014-12-22 10:59 ` [PATCH v4 7/8] arm64/efi: remove free_boot_services() and friends Ard Biesheuvel
[not found] ` <1419245944-2424-8-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-06 18:06 ` Leif Lindholm
2014-12-22 10:59 ` [PATCH v4 8/8] arm64/efi: remove idmap manipulations from UEFI code Ard Biesheuvel
[not found] ` <1419245944-2424-9-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-06 18:17 ` Leif Lindholm
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=20150106171359.GE3827@bivouac.eciton.net \
--to=leif.lindholm-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=Catalin.Marinas-5wv7dgnIgG8@public.gmane.org \
--cc=Will.Deacon-5wv7dgnIgG8@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org \
--cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=geoff.levand-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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