grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/4] efi: Support GRUB_MMAP_MALLOC_LOW in the EFI firmware al


From: Andrey Borzenkov
Subject: Re: [PATCH 3/4] efi: Support GRUB_MMAP_MALLOC_LOW in the EFI firmware allocator
Date: Wed, 13 Nov 2013 07:59:34 +0400

В Tue, 12 Nov 2013 18:26:39 -0800
Josh Triplett <address@hidden> пишет:

> EFI supports allocating memory below a specified address; use that to
> implement GRUB_MMAP_MALLOC_LOW by requesting memory below 1M.

Out of curiosity - why would you need it on EFI? Your patch does not
add any consumer of GRUB_MMAP_MALLOC_LOW and on EFI notion of low
memory should not exist?

> ---
> 
> ChangeLog entry:
> 
> 2013-11-13  Josh Triplett  <address@hidden>
> 
>       * include/grub/efi/memory.h (GRUB_MMAP_MALLOC_LOW): Define.
>       * grub-core/mmap/efi/mmap.c (grub_mmap_malign_and_register): Add
>         support for GRUB_MMAP_MALLOC_LOW, to allocate memory below 1M via the
>         EFI firmware.
> 
>  grub-core/mmap/efi/mmap.c | 15 ++++++++++-----
>  include/grub/efi/memory.h |  2 ++
>  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c
> index e6cd185..64ad05c 100644
> --- a/grub-core/mmap/efi/mmap.c
> +++ b/grub-core/mmap/efi/mmap.c
> @@ -239,9 +239,9 @@ void *
>  grub_mmap_malign_and_register (grub_uint64_t align __attribute__ ((unused)),
>                              grub_uint64_t size,
>                              int *handle, int type,
> -                            int flags __attribute__ ((unused)))
> +                            int flags)
>  {
> -  grub_efi_physical_address_t address;
> +  grub_efi_physical_address_t address, max_address;
>    grub_efi_boot_services_t *b;
>    grub_efi_uintn_t pages;
>    grub_efi_status_t status;
> @@ -254,13 +254,18 @@ grub_mmap_malign_and_register (grub_uint64_t align 
> __attribute__ ((unused)),
>  
>    b = grub_efi_system_table->boot_services;
>  
> -  address = 0xffffffff;
> +  if (flags & GRUB_MMAP_MALLOC_LOW)
> +      max_address = 0xfffff;
> +  else
> +      max_address = 0xffffffff;
> +  address = max_address;
>  
>  #if GRUB_TARGET_SIZEOF_VOID_P < 8
>    /* Limit the memory access to less than 4GB for 32-bit platforms.  */
>    atype = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
>  #else
> -  atype = GRUB_EFI_ALLOCATE_ANY_PAGES;
> +  atype = (flags & GRUB_MMAP_MALLOC_LOW) ? GRUB_EFI_ALLOCATE_MAX_ADDRESS
> +                                         : GRUB_EFI_ALLOCATE_ANY_PAGES;
>  #endif
>  
>    pages = (size + 0xfff) >> 12;
> @@ -276,7 +281,7 @@ grub_mmap_malign_and_register (grub_uint64_t align 
> __attribute__ ((unused)),
>      {
>        /* Uggh, the address 0 was allocated... This is too annoying,
>        so reallocate another one.  */
> -      address = 0xffffffff;
> +      address = max_address;
>        status = efi_call_4 (b->allocate_pages, atype,
>                          make_efi_memtype (type), pages, &address);
>        grub_efi_free_pages (0, pages);
> diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
> index 20526b1..b4940af 100644
> --- a/include/grub/efi/memory.h
> +++ b/include/grub/efi/memory.h
> @@ -24,6 +24,8 @@
>  
>  #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1
>  
> +#define GRUB_MMAP_MALLOC_LOW 1
> +
>  grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t 
> size,
>                                      int type, int handle);
>  grub_err_t grub_machine_mmap_unregister (int handle);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]