From: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
To: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
Leif Lindholm
<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"Baicar, Tyler" <tbaicar-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Matthew Garrett <mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
Subject: Re: [PATCH v2 1/2] efi: esrt: use memremap not ioremap to access ESRT table in memory
Date: Thu, 18 Feb 2016 14:15:44 +0000 [thread overview]
Message-ID: <20160218141544.GH2651@codeblueprint.co.uk> (raw)
In-Reply-To: <CAKv+Gu875r9RkDC723kNsG4XC0eSE9RPPmSFZrD0sx0QxS+V4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Thu, 18 Feb, at 02:44:02PM, Ard Biesheuvel wrote:
> On 18 February 2016 at 14:43, Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org> wrote:
> > On Thu, 18 Feb, at 02:29:32PM, Ard Biesheuvel wrote:
> >> On 18 February 2016 at 14:28, Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org> wrote:
> >> > On Thu, 18 Feb, at 01:16:05PM, Ard Biesheuvel wrote:
> >> >> On 18 February 2016 at 11:44, Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org> wrote:
> >> >> > On Mon, 15 Feb, at 12:32:32PM, Ard Biesheuvel wrote:
> >> >> >> On ARM and arm64, ioremap() and memremap() are not interchangeable like
> >> >> >> on x86, and the use of ioremap() on ordinary RAM is typically flagged
> >> >> >> as an error if the memory region being mapped is also covered by the
> >> >> >> linear mapping, since that would lead to aliases with conflicting
> >> >> >> cacheability attributes.
> >> >> >>
> >> >> >> Since what we are dealing with is not an I/O region with side effects,
> >> >> >> using ioremap() here is arguably incorrect anyway, so let's replace
> >> >> >> it with memremap instead. Also add a missing unmap on the success path,
> >> >> >> and drop a memblock_remove() call which does not belong here, this far
> >> >> >> into the boot sequence.
> >> >> >>
> >> >> >> Cc: Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> >> >> >> Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> >> >> >> ---
> >> >> >> drivers/firmware/efi/esrt.c | 16 ++++++++--------
> >> >> >> 1 file changed, 8 insertions(+), 8 deletions(-)
> >> >> >>
> >> >> >
> >> >> > [...]
> >> >> >
> >> >> >> @@ -432,8 +434,6 @@ static int __init esrt_sysfs_init(void)
> >> >> >> if (error)
> >> >> >> goto err_cleanup_list;
> >> >> >>
> >> >> >> - memblock_remove(esrt_data, esrt_data_size);
> >> >> >> -
> >> >> >> pr_debug("esrt-sysfs: loaded.\n");
> >> >> >>
> >> >> >> return 0;
> >> >> >
> >> >> > Shouldn't we be replacing memblock_remove() with free_bootmem_late()?
> >> >> > The original ESRT region is still reserved at this point, so we should
> >> >> > do our best to release it to the page allocator.
> >> >>
> >> >> I'd rather we keep it reserved. That way, the config table entry still
> >> >> points to something valid, which could be useful for kexec(), I think?
> >> >> At least, that is how I intended to handle config tables on ARM ...
> >> >
> >> > If we're going to reserve it why do we need to copy the data out at
> >> > all in esrt_sysfs_init()?
> >>
> >> Excellent question. I don't think there is any point to doing that.
> >
> > ... Unless the data is contained in an EFI Boot Services region ;-)
> >
> > Peter?
>
> Yes, it usually is. Is that a problem?
Yes, we free the Boot Services regions before hitting userspace on
x86, see efi_free_boot_services(). We do this map/copy/unmap trick in
the ACPI BGRT driver for that reason.
The Boot Services regions can be many gigabytes in size, which makes
leaving them alone impractical.
For kexec on x86 we simply discard the BGRT table, which isn't the end
of the world because who really needs access to the BGRT image on
kexec reboot? However, I can see the value of preserving the ESRT.
I guess we've got two options, 1) copy out the chunks of Boot Services
regions we're interested in and rewrite the EFI tables to point at
these new allocations and free/discard all of the original Boot
Services regions or 2) only selectively free the Boot Services
regions.
I've always stayed clear of 2) in case there exists cross-region
references in the data that isn't obvious. I'd like to think that
would never happen, but, you know, dragons lurk here, etc.
Though actually, now I think about it, cross-region references can't
possibly exist because they'd cause issues with the current code.
So maybe the best solution is actually 2), where we preserve the Boot
Services regions if any of the drivers (ESRT, BGRT) request them but
free all the others?
What are the lifetime rules for Boot Services regions on arm*?
next prev parent reply other threads:[~2016-02-18 14:15 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 11:32 [PATCH v2 0/2] efi: ARM/arm64: wire up ESRT table Ard Biesheuvel
[not found] ` <1455535953-5056-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-02-15 11:32 ` [PATCH v2 1/2] efi: esrt: use memremap not ioremap to access ESRT table in memory Ard Biesheuvel
[not found] ` <1455535953-5056-2-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-02-15 15:45 ` Peter Jones
2016-02-16 19:19 ` Baicar, Tyler
2016-02-18 10:44 ` Matt Fleming
[not found] ` <20160218104407.GC2651-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-02-18 12:16 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_AW7PKJJOd2mbEu3LKJe+gNaPHnH=sgO=YXM_KWFyKxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-18 13:28 ` Matt Fleming
[not found] ` <20160218132824.GE2651-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-02-18 13:29 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-s1pzYBzuDG-Z7s3gyo8dPOfeidZQ+rim-uAWZCBcKQQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-18 13:43 ` Matt Fleming
[not found] ` <20160218134324.GG2651-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-02-18 13:44 ` Ard Biesheuvel
[not found] ` <CAKv+Gu875r9RkDC723kNsG4XC0eSE9RPPmSFZrD0sx0QxS+V4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-18 14:15 ` Matt Fleming [this message]
[not found] ` <20160218141544.GH2651-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-02-18 14:21 ` Ard Biesheuvel
[not found] ` <CAKv+Gu8RP21vw1Ht7UtkHsen2GMUNx8DikH-hLaezV+uZvWO-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-18 14:38 ` Matt Fleming
2016-02-19 9:27 ` Dave Young
2016-02-18 19:16 ` Peter Jones
[not found] ` <20160218191624.GA1515-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-02-26 14:41 ` Matt Fleming
[not found] ` <20160226144114.GA7475-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-03-01 23:30 ` Matt Fleming
[not found] ` <20160301233040.GA31476-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-03-01 23:31 ` Matt Fleming
2016-03-02 1:16 ` Dave Young
[not found] ` <20160302011619.GA3192-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2016-03-02 10:23 ` Matt Fleming
2016-03-04 6:25 ` Dave Young
[not found] ` <20160304062524.GA19010-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2016-05-18 8:36 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_ekP+44FJjR7BY_MFqx2jQgc6Tk9W4SBL__ttdvQ55VQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-05-18 8:53 ` Matt Fleming
[not found] ` <20160518085348.GG21993-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-06-16 13:47 ` Ard Biesheuvel
2016-06-20 11:49 ` Matt Fleming
2016-02-15 11:32 ` [PATCH v2 2/2] arm64/efi: esrt: add missing call to efi_esrt_init() Ard Biesheuvel
[not found] ` <1455535953-5056-3-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-02-15 15:46 ` Peter Jones
2016-02-16 20:25 ` Baicar, Tyler
[not found] ` <56C385D3.3090308-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-02-17 8:32 ` Ard Biesheuvel
2016-05-17 20:36 ` Christopher Covington
-- strict thread matches above, loose matches on Subject: below --
2016-07-11 19:00 [PATCH v2 0/2] efi/arm*: wire up ESRT table Ard Biesheuvel
[not found] ` <1468263646-28184-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-07-11 19:00 ` [PATCH v2 1/2] efi: esrt: use memremap not ioremap to access ESRT table in memory Ard Biesheuvel
[not found] ` <1468263646-28184-2-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-07-15 15:05 ` 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=20160218141544.GH2651@codeblueprint.co.uk \
--to=matt-mf/unelci9gs6ibeejttw/xrex20p6io@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=leif.lindholm-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=mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org \
--cc=pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=tbaicar-sgV2jX0FEOL9JmXXK+q4OQ@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;
as well as URLs for NNTP newsgroup(s).