From: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
catalin.marinas-5wv7dgnIgG8@public.gmane.org,
will.deacon-5wv7dgnIgG8@public.gmane.org,
matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org,
dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
geoff.levand-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH v4 7/8] arm64/efi: remove free_boot_services() and friends
Date: Tue, 6 Jan 2015 18:06:04 +0000 [thread overview]
Message-ID: <20150106180604.GG3827@bivouac.eciton.net> (raw)
In-Reply-To: <1419245944-2424-8-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
On Mon, Dec 22, 2014 at 10:59:03AM +0000, Ard Biesheuvel wrote:
> Now that we are calling SetVirtualAddressMap() from the stub, there is no
> need to reserve boot-only memory regions, which implies that there is also
> no reason to free them again later.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> arch/arm64/kernel/efi.c | 123 +-----------------------------------------------
> 1 file changed, 1 insertion(+), 122 deletions(-)
>
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 2ebe67ffb629..e969c5076713 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -198,9 +198,7 @@ static __init void reserve_regions(void)
> if (is_normal_ram(md))
> early_init_dt_add_memory_arch(paddr, size);
>
> - if (is_reserve_region(md) ||
> - md->type == EFI_BOOT_SERVICES_CODE ||
> - md->type == EFI_BOOT_SERVICES_DATA) {
> + if (is_reserve_region(md)) {
> memblock_reserve(paddr, size);
> if (uefi_debug)
> pr_cont("*");
> @@ -213,123 +211,6 @@ static __init void reserve_regions(void)
> set_bit(EFI_MEMMAP, &efi.flags);
> }
>
> -
> -static u64 __init free_one_region(u64 start, u64 end)
> -{
> - u64 size = end - start;
> -
> - if (uefi_debug)
> - pr_info(" EFI freeing: 0x%012llx-0x%012llx\n", start, end - 1);
> -
> - free_bootmem_late(start, size);
> - return size;
> -}
> -
> -static u64 __init free_region(u64 start, u64 end)
> -{
> - u64 map_start, map_end, total = 0;
> -
> - if (end <= start)
> - return total;
> -
> - map_start = (u64)memmap.phys_map;
> - map_end = PAGE_ALIGN(map_start + (memmap.map_end - memmap.map));
> - map_start &= PAGE_MASK;
> -
> - if (start < map_end && end > map_start) {
> - /* region overlaps UEFI memmap */
> - if (start < map_start)
> - total += free_one_region(start, map_start);
> -
> - if (map_end < end)
> - total += free_one_region(map_end, end);
> - } else
> - total += free_one_region(start, end);
> -
> - return total;
> -}
> -
> -static void __init free_boot_services(void)
> -{
> - u64 total_freed = 0;
> - u64 keep_end, free_start, free_end;
> - efi_memory_desc_t *md;
> -
> - /*
> - * If kernel uses larger pages than UEFI, we have to be careful
> - * not to inadvertantly free memory we want to keep if there is
> - * overlap at the kernel page size alignment. We do not want to
> - * free is_reserve_region() memory nor the UEFI memmap itself.
> - *
> - * The memory map is sorted, so we keep track of the end of
> - * any previous region we want to keep, remember any region
> - * we want to free and defer freeing it until we encounter
> - * the next region we want to keep. This way, before freeing
> - * it, we can clip it as needed to avoid freeing memory we
> - * want to keep for UEFI.
> - */
> -
> - keep_end = 0;
> - free_start = 0;
> -
> - for_each_efi_memory_desc(&memmap, md) {
> - u64 paddr, npages, size;
> -
> - if (is_reserve_region(md)) {
> - /*
> - * We don't want to free any memory from this region.
> - */
> - if (free_start) {
> - /* adjust free_end then free region */
> - if (free_end > md->phys_addr)
> - free_end -= PAGE_SIZE;
> - total_freed += free_region(free_start, free_end);
> - free_start = 0;
> - }
> - keep_end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
> - continue;
> - }
> -
> - if (md->type != EFI_BOOT_SERVICES_CODE &&
> - md->type != EFI_BOOT_SERVICES_DATA) {
> - /* no need to free this region */
> - continue;
> - }
> -
> - /*
> - * We want to free memory from this region.
> - */
> - paddr = md->phys_addr;
> - npages = md->num_pages;
> - memrange_efi_to_native(&paddr, &npages);
> - size = npages << PAGE_SHIFT;
> -
> - if (free_start) {
> - if (paddr <= free_end)
> - free_end = paddr + size;
> - else {
> - total_freed += free_region(free_start, free_end);
> - free_start = paddr;
> - free_end = paddr + size;
> - }
> - } else {
> - free_start = paddr;
> - free_end = paddr + size;
> - }
> - if (free_start < keep_end) {
> - free_start += PAGE_SIZE;
> - if (free_start >= free_end)
> - free_start = 0;
> - }
> - }
> - if (free_start)
> - total_freed += free_region(free_start, free_end);
> -
> - if (total_freed)
> - pr_info("Freed 0x%llx bytes of EFI boot services memory",
> - total_freed);
> -}
> -
> void __init efi_init(void)
> {
> struct efi_fdt_params params;
> @@ -396,8 +277,6 @@ static int __init arm64_enter_virtual_mode(void)
> }
> set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>
> - free_boot_services();
> -
> if (!efi_enabled(EFI_VIRTMAP)) {
> pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> return -1;
> --
> 1.8.3.2
Acked-by: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
next prev parent reply other threads:[~2015-01-06 18:06 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
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 [this message]
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=20150106180604.GG3827@bivouac.eciton.net \
--to=leif.lindholm-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org \
--cc=catalin.marinas-5wv7dgnIgG8@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 \
--cc=will.deacon-5wv7dgnIgG8@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