[PATCH v6 3/3] mkimage: Clarify file alignment in efi case

2019-01-28 Thread Alexander Graf
There are a few spots in the PE generation code for EFI binaries that uses the section alignment rather than file alignment, even though the alignment is really only file bound. Replace those cases with the file alignment constant instead. Reported-by: Daniel Kiper Signed-off-by: Alexander Graf

[PATCH v6 1/3] mkimage: Use EFI32_HEADER_SIZE define in arm-efi case

2019-01-28 Thread Alexander Graf
The efi-arm case was defining its own header size calculation, even though it's 100% identical to the common EFI32_HEADER_SIZE definition. So let's clean it up to use the common define. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper --- util/mkimage.c | 7 +-- 1 file changed, 1 in

[PATCH v6 0/3] arm64: Support HP Envy X2

2019-01-28 Thread Alexander Graf
I got a new toy recently: An HP Envy X2 system. This is one of those shiny new Qualcomm Snapdragon based Windows tablet/notebook hybrid things. While running Windows on those is actually not a terribly bad experience now that WSL is out, I would like to see Linux run on those as well in the future

[PATCH v6 2/3] mkimage: Align efi sections on 4k boundary

2019-01-28 Thread Alexander Graf
There is UEFI firmware popping up in the wild now that implements stricter permission checks using NX and write protect page table entry bits. This means that firmware now may fail to load binaries if its individual sections are not page aligned, as otherwise it can not ensure permission boundarie

Re: [PATCH v5 3/3] mkimage: Clarify file alignment in efi case

2019-01-28 Thread Daniel Kiper
On Mon, Jan 28, 2019 at 01:34:20PM +0100, Alexander Graf wrote: > On 28.01.19 13:27, Daniel Kiper wrote: > > On Fri, Jan 25, 2019 at 12:45:16PM +0100, Alexander Graf wrote: > >> There are a few spots in the PE generation code for EFI binaries that uses > >> the section alignment rather than file al

Re: [PATCH v5 2/3] mkimage: Align efi sections on 4k boundary

2019-01-28 Thread Daniel Kiper
On Mon, Jan 28, 2019 at 01:33:33PM +0100, Alexander Graf wrote: > On 28.01.19 13:22, Daniel Kiper wrote: > > On Fri, Jan 25, 2019 at 12:45:15PM +0100, Alexander Graf wrote: > >> There is UEFI firmware popping up in the wild now that implements stricter > >> permission checks using NX and write prot

[PATCH v5 05/11] RISC-V: Add early startup code

2019-01-28 Thread Alexander Graf
On entry, we need to save the system table pointer as well as our image handle. Add an early startup file that saves them and then brings us into our main function. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper

[PATCH v5 08/11] RISC-V: Add auxiliary files

2019-01-28 Thread Alexander Graf
To support a new architecture we need to provide a few helper functions for memory, cache, timer, etc support. This patch adds the remainders of those. Some bits are still disabled, as I couldn't guarantee that we're always running on models / in modes where the respective hardware is available.

[PATCH v5 06/11] RISC-V: Add Linux load logic

2019-01-28 Thread Alexander Graf
We currently only support to run grub on RISC-V as UEFI payload. Ideally, we also only want to support running Linux underneath as UEFI payload. Prepare that with a Linux boot case that is not enabled in Linux yet. At least it will give people something to test against when they enable the Linux U

[PATCH v5 09/11] RISC-V: Add libgcc helpers for clz

2019-01-28 Thread Alexander Graf
Gcc may decide it wants to call helper functions to execute clz. Provide them in our own copy of libgcc. Signed-off-by: Alexander Graf --- grub-core/kern/compiler-rt.c | 42 ++ include/grub/compiler-rt.h | 7 +++ 2 files changed, 49 insertions(+) d

[PATCH v5 04/11] RISC-V: Add setjmp implementation

2019-01-28 Thread Alexander Graf
This patch adds a 32/64 capable setjmp implementation for RISC-V. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper --- v3 -> v4: - Change copyright from 2013 to 2018 v4 -> v5: - Add blank lines before and

[PATCH v5 10/11] RISC-V: Add to build system

2019-01-28 Thread Alexander Graf
This patch adds support for RISC-V to the grub build system. With this patch, I can successfully build grub on RISC-V as a UEFI application. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng --- v2 -> v3: - Fix riscv32 target --- config

[PATCH v5 11/11] fdt: Treat device tree file type like ACPI

2019-01-28 Thread Alexander Graf
We now have signature check logic in grub which allows us to treat files differently depending on their file type. Treat a loaded device tree like an overlayed ACPI table. Both describe hardware, so I suppose their threat level is the same. Signed-off-by: Alexander Graf Reviewed-by: Daniel Kiper

[PATCH v5 01/11] efi: Rename armxx to arch

2019-01-28 Thread Alexander Graf
Some architectures want to boot Linux as plain UEFI binary. Today that really only encompasses ARM and AArch64, but going forward more architectures may adopt that model. So rename our internal API accordingly. Signed-off-by: Alexander Graf Acked-by: Leif Lindholm Reviewed-by: Alistair Francis

[PATCH v5 07/11] RISC-V: Add awareness for RISC-V reloations

2019-01-28 Thread Alexander Graf
This patch adds awareness of RISC-V relocations throughout the grub tools as well as dynamic linkage and elf->PE relocation conversion support. Signed-off-by: Alexander Graf --- v2 -> v3: - Fix riscv32 target v3 -> v4: - Change copyright from 2013 to 2018 - Add spec reference v4 -> v5

[PATCH v5 00/11] Add RISC-V support

2019-01-28 Thread Alexander Graf
As part of the plan for total world domination, we would like to make sure that booting on RISC-V is in a sane state before anyone goes and does quick hacks "just because". For that reason, U-Boot supports UEFI booting on RISC-V for a while now. This patch set is the second part of the puzzle, wit

[PATCH v5 03/11] elf.h: Add RISC-V definitions

2019-01-28 Thread Alexander Graf
The RISC-V ABI document outlines ELF header structure and relocation information. Pull the respective magic numbers into our elf header so we can make use of them. Signed-off-by: Alexander Graf Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kiper -

[PATCH v5 02/11] PE: Add RISC-V definitions

2019-01-28 Thread Alexander Graf
The PE format defines magic numbers as well as relocation identifiers for RISC-V. Add them to our include file, so we can make use of them. Signed-off-by: Alexander Graf Reviewed-by: Leif Lindholm Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Daniel Kipe

Re: [PATCH v5 3/3] mkimage: Clarify file alignment in efi case

2019-01-28 Thread Alexander Graf
On 28.01.19 13:27, Daniel Kiper wrote: > On Fri, Jan 25, 2019 at 12:45:16PM +0100, Alexander Graf wrote: >> There are a few spots in the PE generation code for EFI binaries that uses >> the section alignment rather than file alignment, even though the alignment >> is really only file bound. >> >

Re: [PATCH v5 2/3] mkimage: Align efi sections on 4k boundary

2019-01-28 Thread Alexander Graf
On 28.01.19 13:22, Daniel Kiper wrote: > On Fri, Jan 25, 2019 at 12:45:15PM +0100, Alexander Graf wrote: >> There is UEFI firmware popping up in the wild now that implements stricter >> permission checks using NX and write protect page table entry bits. >> >> This means that firmware now may fai

Re: [PATCH v5 3/3] mkimage: Clarify file alignment in efi case

2019-01-28 Thread Daniel Kiper
On Fri, Jan 25, 2019 at 12:45:16PM +0100, Alexander Graf wrote: > There are a few spots in the PE generation code for EFI binaries that uses > the section alignment rather than file alignment, even though the alignment > is really only file bound. > > Replace those cases with the file alignment con

Re: [PATCH v5 2/3] mkimage: Align efi sections on 4k boundary

2019-01-28 Thread Daniel Kiper
On Fri, Jan 25, 2019 at 12:45:15PM +0100, Alexander Graf wrote: > There is UEFI firmware popping up in the wild now that implements stricter > permission checks using NX and write protect page table entry bits. > > This means that firmware now may fail to load binaries if its individual > sections

Re: [PATCH v5 1/3] mkimage: Use EFI32_HEADER_SIZE define in arm-efi case

2019-01-28 Thread Daniel Kiper
On Fri, Jan 25, 2019 at 12:45:14PM +0100, Alexander Graf wrote: > The efi-arm case was defining its own header size calculation, even though > it's > 100% identical to the common EFI32_HEADER_SIZE definition. > > So let's clean it up to use the common define. > > Signed-off-by: Alexander Graf Re