mbox series

[0/7] efi: improved correctness, arm unification, and cleanup

Message ID 20170228223537.9685-1-leif.lindholm@linaro.org
Headers show
Series efi: improved correctness, arm unification, and cleanup | expand

Message

Leif Lindholm Feb. 28, 2017, 10:35 p.m. UTC
This patch series is really three different ones, but they unite around
the need for (and the implementation) of more flexible control of memory
allocation on UEFI systems.

1: Adding new interfaces
- A function for detecting the start address of RAM
  Since ARM platforms have no standardised memory map, implement a
  function that picks the lowest-address region supporting the
  write-back cache atribute from the UEFI memory map.
- Implement and expose a new memory allocation function giving access to
  the allocation type and memory type arguments to the AllocatePages
  boot service.

2: ARM unificatios
- The fdt helper library for arm64/efi is really an efi/fdt function.
  So move it to neutral ground in loader/efi.
- The arm64 efi linux loader was written for arm64 only, so clean it up a
  bit with regards to 32/64-bit portability, and abstract out some
  definitions and function prototypes.
- Move the arm efi port to use the arm64 linux loader instead of the one
  shared with the u-boot port. Clean up the u-boot loder by deleting the
  efi-specific bits and other code only used by that.

3: Correctness improvements
- There are some restrictions on the placement of initrd images in
  relation to the runtime kernel images, for both arm and arm64 - but the
  arm64 one did not use to be explicitly documented (and only triggerable
  on systems with > 40GB of RAM), and the u-boot loader always placed the
  images nearly adjacent. Use the new interfaces to place the initrd as
  approrpiate for each architecture.
- The allocation of memory for the grub heap is done of memory type
  GRUB_EFI_LOADER_DATA. Since UEFI can return memory with non-executable
  mappings for this request, and modules are loaded onto the heap, change
  this allocation GRUB_EFI_LOADER_CODE instead.

Leif Lindholm (7):
  efi: add grub_efi_get_dram_base() function for arm*
  efi: refactor grub_efi_allocate_pages
  efi: move fdt helper library
  arm64: make efi linux loader more generic
  arm: reuse arm64 linux loader on efi systems
  efi: restrict arm/arm64 linux loader initrd placement
  efi: change heap allocation type to GRUB_EFI_LOADER_CODE

 grub-core/Makefile.am                 |   1 -
 grub-core/Makefile.core.def           |   6 +-
 grub-core/kern/arm/efi/misc.c         | 202 ----------------------------------
 grub-core/kern/efi/mm.c               |  92 ++++++++++++----
 grub-core/loader/arm/linux.c          |  48 +-------
 grub-core/loader/arm64/linux.c        |  73 ++++++++----
 grub-core/loader/arm64/xen_boot.c     |  15 +--
 grub-core/loader/{arm64 => efi}/fdt.c |  11 +-
 include/grub/arm/efi/loader.h         |  26 -----
 include/grub/arm/efi/memory.h         |   3 +
 include/grub/arm/linux.h              |  30 ++---
 include/grub/arm64/efi/memory.h       |   3 +
 include/grub/arm64/linux.h            |  13 +--
 include/grub/efi/efi.h                |  10 ++
 include/grub/{arm64 => efi}/fdtload.h |   3 -
 include/grub/efi/pe32.h               |   2 +
 16 files changed, 176 insertions(+), 362 deletions(-)
 delete mode 100644 grub-core/kern/arm/efi/misc.c
 rename grub-core/loader/{arm64 => efi}/fdt.c (93%)
 delete mode 100644 include/grub/arm/efi/loader.h
 rename include/grub/{arm64 => efi}/fdtload.h (89%)

-- 
2.11.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Comments

Vladimir 'phcoder' Serbinenko Feb. 28, 2017, 10:51 p.m. UTC | #1
I will review your patches later. There might be some overlap with my "arm"
branch. Can you have a look whether it diverges a lot?

On Tue, Feb 28, 2017, 14:48 Leif Lindholm <leif.lindholm@linaro.org> wrote:

> This patch series is really three different ones, but they unite around

> the need for (and the implementation) of more flexible control of memory

> allocation on UEFI systems.

>

> 1: Adding new interfaces

> - A function for detecting the start address of RAM

>   Since ARM platforms have no standardised memory map, implement a

>   function that picks the lowest-address region supporting the

>   write-back cache atribute from the UEFI memory map.

> - Implement and expose a new memory allocation function giving access to

>   the allocation type and memory type arguments to the AllocatePages

>   boot service.

>

> 2: ARM unificatios

> - The fdt helper library for arm64/efi is really an efi/fdt function.

>   So move it to neutral ground in loader/efi.

> - The arm64 efi linux loader was written for arm64 only, so clean it up a

>   bit with regards to 32/64-bit portability, and abstract out some

>   definitions and function prototypes.

> - Move the arm efi port to use the arm64 linux loader instead of the one

>   shared with the u-boot port. Clean up the u-boot loder by deleting the

>   efi-specific bits and other code only used by that.

>

> 3: Correctness improvements

> - There are some restrictions on the placement of initrd images in

>   relation to the runtime kernel images, for both arm and arm64 - but the

>   arm64 one did not use to be explicitly documented (and only triggerable

>   on systems with > 40GB of RAM), and the u-boot loader always placed the

>   images nearly adjacent. Use the new interfaces to place the initrd as

>   approrpiate for each architecture.

> - The allocation of memory for the grub heap is done of memory type

>   GRUB_EFI_LOADER_DATA. Since UEFI can return memory with non-executable

>   mappings for this request, and modules are loaded onto the heap, change

>   this allocation GRUB_EFI_LOADER_CODE instead.

>

> Leif Lindholm (7):

>   efi: add grub_efi_get_dram_base() function for arm*

>   efi: refactor grub_efi_allocate_pages

>   efi: move fdt helper library

>   arm64: make efi linux loader more generic

>   arm: reuse arm64 linux loader on efi systems

>   efi: restrict arm/arm64 linux loader initrd placement

>   efi: change heap allocation type to GRUB_EFI_LOADER_CODE

>

>  grub-core/Makefile.am                 |   1 -

>  grub-core/Makefile.core.def           |   6 +-

>  grub-core/kern/arm/efi/misc.c         | 202

> ----------------------------------

>  grub-core/kern/efi/mm.c               |  92 ++++++++++++----

>  grub-core/loader/arm/linux.c          |  48 +-------

>  grub-core/loader/arm64/linux.c        |  73 ++++++++----

>  grub-core/loader/arm64/xen_boot.c     |  15 +--

>  grub-core/loader/{arm64 => efi}/fdt.c |  11 +-

>  include/grub/arm/efi/loader.h         |  26 -----

>  include/grub/arm/efi/memory.h         |   3 +

>  include/grub/arm/linux.h              |  30 ++---

>  include/grub/arm64/efi/memory.h       |   3 +

>  include/grub/arm64/linux.h            |  13 +--

>  include/grub/efi/efi.h                |  10 ++

>  include/grub/{arm64 => efi}/fdtload.h |   3 -

>  include/grub/efi/pe32.h               |   2 +

>  16 files changed, 176 insertions(+), 362 deletions(-)

>  delete mode 100644 grub-core/kern/arm/efi/misc.c

>  rename grub-core/loader/{arm64 => efi}/fdt.c (93%)

>  delete mode 100644 include/grub/arm/efi/loader.h

>  rename include/grub/{arm64 => efi}/fdtload.h (89%)

>

> --

> 2.11.0

>

>

> _______________________________________________

> Grub-devel mailing list

> Grub-devel@gnu.org

> https://lists.gnu.org/mailman/listinfo/grub-devel

>
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
Leif Lindholm March 1, 2017, 10:31 a.m. UTC | #2
On Tue, Feb 28, 2017 at 10:51:51PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> I will review your patches later. There might be some overlap with my "arm"

> branch. Can you have a look whether it diverges a lot?


Not a lot.
2, 4, 6 and 7 apply cleanly if I merge the others manually.

1 fails on efi.h because 0d23457 isn't in your branch, and I think
that's the reason 3 fails too.

5 fails partly due to some of your fdt changes, but again not a hard
manual fix.

There is effectively no functional overlap.

/
    Leif

> On Tue, Feb 28, 2017, 14:48 Leif Lindholm <leif.lindholm@linaro.org> wrote:

> 

> > This patch series is really three different ones, but they unite around

> > the need for (and the implementation) of more flexible control of memory

> > allocation on UEFI systems.

> >

> > 1: Adding new interfaces

> > - A function for detecting the start address of RAM

> >   Since ARM platforms have no standardised memory map, implement a

> >   function that picks the lowest-address region supporting the

> >   write-back cache atribute from the UEFI memory map.

> > - Implement and expose a new memory allocation function giving access to

> >   the allocation type and memory type arguments to the AllocatePages

> >   boot service.

> >

> > 2: ARM unificatios

> > - The fdt helper library for arm64/efi is really an efi/fdt function.

> >   So move it to neutral ground in loader/efi.

> > - The arm64 efi linux loader was written for arm64 only, so clean it up a

> >   bit with regards to 32/64-bit portability, and abstract out some

> >   definitions and function prototypes.

> > - Move the arm efi port to use the arm64 linux loader instead of the one

> >   shared with the u-boot port. Clean up the u-boot loder by deleting the

> >   efi-specific bits and other code only used by that.

> >

> > 3: Correctness improvements

> > - There are some restrictions on the placement of initrd images in

> >   relation to the runtime kernel images, for both arm and arm64 - but the

> >   arm64 one did not use to be explicitly documented (and only triggerable

> >   on systems with > 40GB of RAM), and the u-boot loader always placed the

> >   images nearly adjacent. Use the new interfaces to place the initrd as

> >   approrpiate for each architecture.

> > - The allocation of memory for the grub heap is done of memory type

> >   GRUB_EFI_LOADER_DATA. Since UEFI can return memory with non-executable

> >   mappings for this request, and modules are loaded onto the heap, change

> >   this allocation GRUB_EFI_LOADER_CODE instead.

> >

> > Leif Lindholm (7):

> >   efi: add grub_efi_get_dram_base() function for arm*

> >   efi: refactor grub_efi_allocate_pages

> >   efi: move fdt helper library

> >   arm64: make efi linux loader more generic

> >   arm: reuse arm64 linux loader on efi systems

> >   efi: restrict arm/arm64 linux loader initrd placement

> >   efi: change heap allocation type to GRUB_EFI_LOADER_CODE

> >

> >  grub-core/Makefile.am                 |   1 -

> >  grub-core/Makefile.core.def           |   6 +-

> >  grub-core/kern/arm/efi/misc.c         | 202

> > ----------------------------------

> >  grub-core/kern/efi/mm.c               |  92 ++++++++++++----

> >  grub-core/loader/arm/linux.c          |  48 +-------

> >  grub-core/loader/arm64/linux.c        |  73 ++++++++----

> >  grub-core/loader/arm64/xen_boot.c     |  15 +--

> >  grub-core/loader/{arm64 => efi}/fdt.c |  11 +-

> >  include/grub/arm/efi/loader.h         |  26 -----

> >  include/grub/arm/efi/memory.h         |   3 +

> >  include/grub/arm/linux.h              |  30 ++---

> >  include/grub/arm64/efi/memory.h       |   3 +

> >  include/grub/arm64/linux.h            |  13 +--

> >  include/grub/efi/efi.h                |  10 ++

> >  include/grub/{arm64 => efi}/fdtload.h |   3 -

> >  include/grub/efi/pe32.h               |   2 +

> >  16 files changed, 176 insertions(+), 362 deletions(-)

> >  delete mode 100644 grub-core/kern/arm/efi/misc.c

> >  rename grub-core/loader/{arm64 => efi}/fdt.c (93%)

> >  delete mode 100644 include/grub/arm/efi/loader.h

> >  rename include/grub/{arm64 => efi}/fdtload.h (89%)

> >

> > --

> > 2.11.0

> >

> >

> > _______________________________________________

> > Grub-devel mailing list

> > Grub-devel@gnu.org

> > https://lists.gnu.org/mailman/listinfo/grub-devel

> >


> _______________________________________________

> Grub-devel mailing list

> Grub-devel@gnu.org

> https://lists.gnu.org/mailman/listinfo/grub-devel



_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
Gerd Hoffmann March 8, 2017, 7:57 a.m. UTC | #3
On Di, 2017-02-28 at 22:35 +0000, Leif Lindholm wrote:
> This patch series is really three different ones, but they unite around

> the need for (and the implementation) of more flexible control of memory

> allocation on UEFI systems.


Works fine in my testing, grub loads kernel, initrd, device tree just
fine, kernel successfully unpacks initramfs.

Then the kernel crashes when trying to access the efi variables.  But
that is a kernel bug, not a grub issue (Ard already submitted a fix for
this one).

cheers,
  Gerd


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
Ard Biesheuvel March 8, 2017, 8 a.m. UTC | #4
On 8 March 2017 at 08:57, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On Di, 2017-02-28 at 22:35 +0000, Leif Lindholm wrote:

>> This patch series is really three different ones, but they unite around

>> the need for (and the implementation) of more flexible control of memory

>> allocation on UEFI systems.

>

> Works fine in my testing, grub loads kernel, initrd, device tree just

> fine, kernel successfully unpacks initramfs.

>

> Then the kernel crashes when trying to access the efi variables.  But

> that is a kernel bug, not a grub issue (Ard already submitted a fix for

> this one).

>


... and it was pulled yesterday into mainline (with cc stable) so I
suppose this will make its way into the Fedora kernels as well.

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel