[PATCH v3 2/8] Add LoongArch definitions

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- include/grub/elf.h | 23 +++ 1 file changed, 23 insertions(+) diff --git a/include/grub/elf.h b/include/grub/elf.h index c478933ee..1c8d4f5d5 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -248,6 +248,7 @@

[PATCH v3 5/8] LoongArch: Add stubs for Linux loading commands

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu --- grub-core/loader/loongarch64/linux.c | 59 include/grub/loongarch64/linux.h | 31 +++ 2 files changed, 90 insertions(+) create mode 100644 grub-core/loader/loongarch64/linux.c create mode 100644 include/grub/loongarch64

[PATCH v3 7/8] LoongArch: Add auxiliary files

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- grub-core/kern/efi/mm.c | 3 +- grub-core/kern/loongarch64/cache.c | 39 + grub-core/kern/loongarch64/cache_flush.S | 33 +++ grub-core/kern/loongarch64/efi/init.c| 77 grub-core/

[PATCH v3 1/8] PE: Add LoongArch definitions

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- include/grub/efi/pe32.h | 36 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index 0ed8781f0..de56edef6 100644 --- a/include/grub/efi/pe

[PATCH v3 4/8] LoongArch: Add early startup code

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- grub-core/kern/loongarch64/efi/startup.S | 34 1 file changed, 34 insertions(+) create mode 100644 grub-core/kern/loongarch64/efi/startup.S diff --git a/grub-core/kern/loongarch64/efi/startup.S b/grub-core/kern/l

[PATCH v3 0/8] Add support for LoongArch

2022-03-27 Thread Xiaotian Wu
LoongArch is a new Loongson 3A5000 CPU instruction set, you can read documents[1] or visit the development community[2] to get more information. [1]: https://loongson.github.io/LoongArch-Documentation/README-EN.html [2]: https://github.com/loongson This patch series will add the basic support for

[PATCH v3 3/8] LoongArch: Add setjmp implementation

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang Signed-off-by: Sun Haiyong --- grub-core/lib/loongarch64/setjmp.S | 69 ++ grub-core/lib/setjmp.S | 2 + include/grub/loongarch64/setjmp.h | 27 3 files changed, 98 insertions(+) create m

[PATCH v3 6/8] LoongArch: Add awareness for LoongArch relocations

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- grub-core/kern/dl.c| 9 +- grub-core/kern/loongarch64/dl.c| 102 + grub-core/kern/loongarch64/dl_helper.c | 198 + include/grub/dl.h | 1 + util/grub-m

[PATCH v3 8/8] LoongArch: Add to build system

2022-03-27 Thread Xiaotian Wu
Signed-off-by: Xiaotian Wu Signed-off-by: Zhou Yang --- Makefile.util.def | 1 + conf/Makefile.common| 3 +++ configure.ac| 7 ++ gentpl.py | 25 ++- grub-core/Makefile.am | 6 + grub-core/Makefile.core.def | 1

[PATCH v2] util/grub.d/linux: Improve initramfs detection

2022-03-27 Thread Oskari Pirhonen
Add detection for initramfs of the form *.img.old. For example, Gentoo's sys-kernel/genkernel installs it as initramfs-*.img and moves any existing one to initramfs-*.img.old. Signed-off-by: Oskari Pirhonen --- v1 -> v2: - don't reorder the checks - include 20_linux_xen.in util/grub.d/10_linux.

[PATCH v2 00/15] Dynamic allocation of memory regions and IBM vTPM v2

2022-03-27 Thread Daniel Axtens
Hi all, This is, at long last, an updated version of my series extending Patrick's dynamic memory regions to ieee1275. Noteworthy changes: - reworked debug prints as grub_dprintfs. Folded the ieee1275 ones into the ieee1275 patches. - reworked the ieee1275 runtime memory claiming to be mor

[PATCH v2 02/15] mm: assert that we preserve header vs region alignment

2022-03-27 Thread Daniel Axtens
grub_mm_region_init() does: h = (grub_mm_header_t) (r + 1); where h is a grub_mm_header_t and r is a grub_mm_region_t. Cells are supposed to be GRUB_MM_ALIGN aligned, but while grub_mm_dump ensures this vs the region header, grub_mm_region_init() does not. It's better to be explicit than impl

[PATCH v2 03/15] mm: when adding a region, merge with region after as well as before

2022-03-27 Thread Daniel Axtens
On x86_64-efi (at least) regions seem to be added from top down. The mm code will merge a new region with an existing region that comes immediately before the new region. This allows larger allocations to be satisfied that would otherwise be the case. On powerpc-ieee1275, however, regions are adde

[PATCH v2 01/15] grub-shell: only pass SeaBIOS fw_opt in for x86 BIOS platforms

2022-03-27 Thread Daniel Axtens
This breaks the tests on pseries - just restrict it to x86 platforms that don't specify a BIOS. Signed-off-by: Daniel Axtens --- v2: Thanks Daniel K and Glenn for feedback. --- tests/util/grub-shell.in | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/util/grub-shell

[PATCH v2 05/15] mm: Drop unused unloading of modules on OOM

2022-03-27 Thread Daniel Axtens
From: Patrick Steinhardt In `grub_memalign ()`, there's a commented section which would allow for unloading of unneeded modules in case where there is not enough free memory available to satisfy a request. Given that this code is never compiled in, let's remove it together with `grub_dl_unload_un

[PATCH v2 06/15] mm: Allow dynamically requesting additional memory regions

2022-03-27 Thread Daniel Axtens
From: Patrick Steinhardt Currently, all platforms will set up their heap on initialization of the platform code. While this works mostly fine, it poses some limitations on memory management on us. Most notably, allocating big chunks of memory in the gigabyte range would require us to pre-request

[PATCH v2 07/15] efi: mm: Always request a fixed number of pages on init

2022-03-27 Thread Daniel Axtens
From: Patrick Steinhardt When initializing the EFI memory subsytem, we will by default request a quarter of the available memory, bounded by a minimum/maximum value. Given that we're about to extend the EFI memory system to dynamically request additional pages from the firmware as required, this

[PATCH v2 08/15] efi: mm: Extract function to add memory regions

2022-03-27 Thread Daniel Axtens
From: Patrick Steinhardt In preparation of support for runtime-allocating additional memory region, this patch extracts the function to retrieve the EFI memory map and add a subset of it to GRUB's own memory regions. Signed-off-by: Patrick Steinhardt Signed-off-by: Daniel Axtens --- grub-core

[PATCH v2 09/15] efi: mm: Pass up errors from `add_memory_regions ()`

2022-03-27 Thread Daniel Axtens
From: Patrick Steinhardt The function `add_memory_regions ()` is currently only called on system initialization to allocate a fixed amount of pages. As such, it didn't need to return any errors: in case it failed, we cannot proceed anyway. This will change with the upcoming support for requesting

[PATCH v2 12/15] ieee1275: drop len -= 1 quirk in heap_init

2022-03-27 Thread Daniel Axtens
This was apparently 'required by some firmware': commit dc9468500919 ("2007-02-12 Hollis Blanchard "). It's not clear what firmware that was, and what platform from 14 years ago which exhibited the bug then is still both in use and buggy now. It doesn't cause issues on qemu (mac99 or pseries) o

[PATCH v2 11/15] ieee1275: request memory with ibm, client-architecture-support

2022-03-27 Thread Daniel Axtens
On PowerVM, the first time we boot a Linux partition, we may only get 256MB of real memory area, even if the partition has more memory. This isn't really enough. Fortunately, the Power Architecture Platform Reference (PAPR) defines a method we can call to ask for more memory. This is part of the b

[PATCH v2 15/15] ibmvtpm: Add support for trusted boot using a vTPM 2.0

2022-03-27 Thread Daniel Axtens
From: Stefan Berger Add support for trusted boot using a vTPM 2.0 on the IBM IEEE1275 PowerPC platform. With this patch grub now measures text and binary data into the TPM's PCRs 8 and 9 in the same way as the x86_64 platform does. This patch requires Daniel Axtens's patches for claiming more me

[PATCH v2 13/15] ieee1275: support runtime memory claiming

2022-03-27 Thread Daniel Axtens
On powerpc-ieee1275, we are running out of memory trying to verify anything. This is because: - we have to load an entire file into memory to verify it. This is difficult to change with appended signatures. - We only have 32MB of heap. - Distro kernels are now often around 30MB. So we want

[PATCH v2 14/15] [RFC] Add memtool module with memory allocation stress-test

2022-03-27 Thread Daniel Axtens
When working on memory, it's nice to be able to test your work. Add a memtest module. When compiled with --enable-mm-debug, it exposes 3 commands: * lsmem - print all allocations and free space in all regions * lsfreemem - print free space in all regions * stress_big_allocs - stress test larg

[PATCH v2 04/15] mm: debug support for region operations

2022-03-27 Thread Daniel Axtens
This is handy for debugging. Enable with `set debug=regions`. Signed-off-by: Daniel Axtens --- grub-core/kern/mm.c | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index 94e78f9a910d..f36499865632 100644 --- a/grub

[PATCH v2 10/15] efi: mm: Implement runtime addition of pages

2022-03-27 Thread Daniel Axtens
From: Patrick Steinhardt Adjust the interface of `grub_efi_mm_add_regions ()` to take a set of `GRUB_MM_ADD_REGION_*` flags, which most notably is currently only the `CONSECUTVE` flag. This allows us to set the function up as callback for the memory subsystem and have it call out to us in case th