|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 2/2] EFI: free unused boot mem in at least some cases
On Mon, Aug 24, 2020 at 02:08:11PM +0200, Jan Beulich wrote:
> Address at least the primary reason why 52bba67f8b87 ("efi/boot: Don't
> free ebmalloc area at all") was put in place: Make xen_in_range() aware
> of the freed range. This is in particular relevant for EFI-enabled
> builds not actually running on EFI, as the entire range will be unused
> in this case.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Just one comment below.
> ---
> v2: Also adjust the two places where comments point out that they need
> to remain in sync with xen_in_range(). Add assertions to
> xen_in_range().
> ---
> The remaining issue could be addressed too, by making the area 2M in
> size and 2M-aligned.
>
> --- a/xen/arch/x86/efi/stub.c
> +++ b/xen/arch/x86/efi/stub.c
> @@ -52,6 +52,12 @@ bool efi_enabled(unsigned int feature)
>
> void __init efi_init_memory(void) { }
>
> +bool efi_boot_mem_unused(unsigned long *start, unsigned long *end)
> +{
> + *start = *end = (unsigned long)_end;
> + return false;
> +}
> +
> void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t l4e) { }
>
> bool efi_rs_using_pgtables(void)
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -608,7 +608,7 @@ static void __init kexec_reserve_area(st
> #endif
> }
>
> -static inline bool using_2M_mapping(void)
> +bool using_2M_mapping(void)
> {
> return !l1_table_offset((unsigned long)__2M_text_end) &&
> !l1_table_offset((unsigned long)__2M_rodata_start) &&
> @@ -830,6 +830,7 @@ void __init noreturn __start_xen(unsigne
> module_t *mod;
> unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1];
> int i, j, e820_warn = 0, bytes = 0;
> + unsigned long eb_start, eb_end;
> bool acpi_boot_table_init_done = false, relocated = false;
> int ret;
> struct ns16550_defaults ns16550 = {
> @@ -1145,7 +1146,8 @@ void __init noreturn __start_xen(unsigne
>
> /*
> * This needs to remain in sync with xen_in_range() and the
> - * respective reserve_e820_ram() invocation below.
> + * respective reserve_e820_ram() invocation below. No need to
> + * query efi_boot_mem_unused() here, though.
> */
> mod[mbi->mods_count].mod_start = virt_to_mfn(_stext);
> mod[mbi->mods_count].mod_end = __2M_rwdata_end - _stext;
I find this extremely confusing, we reuse mod_start/mod_end to contain
a mfn and a size (in bytes) instead of a start and end address (not
something that should be fixed here, but seeing this I assumed it was
wrong).
> +bool efi_boot_mem_unused(unsigned long *start, unsigned long *end)
> +{
> + *start = (unsigned long)ebmalloc_mem + PAGE_ALIGN(ebmalloc_allocated);
> + *end = (unsigned long)ebmalloc_mem + sizeof(ebmalloc_mem);
> +
> + return *start < *end;
> +}
> +
> void __init free_ebmalloc_unused_mem(void)
> {
> -#if 0 /* FIXME: Putting a hole in the BSS breaks the IOMMU mappings for
> dom0. */
> unsigned long start, end;
>
> - start = (unsigned long)ebmalloc_mem + PAGE_ALIGN(ebmalloc_allocated);
> - end = (unsigned long)ebmalloc_mem + sizeof(ebmalloc_mem);
> +#ifdef CONFIG_X86
> + /* FIXME: Putting a hole in .bss would shatter the large page mapping. */
Could you make the ebmalloc size (EBMALLOC_SIZE) 2MB (and aligned), so
that you would only shatter the malloc'ed pages but not the
surrounding mappings?
That would be a good compromise IMO.
Roger.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |