[PATCH v2] configure: Fix default -O2 being added when CFLAGS not set

2022-03-28 Thread Glenn Washburn
Autoconf will set a default CFLAGS of "-g -O2" if CFLAGS is not set. CFLAGS was defaulted to "" early in configure to prevent this. A recent commit ad9ccf660013c208077b1e983d6c824df25ed1cf ("configure: Fix various new autotools warnings") added AC_USE_SYSTEM_EXTENSIONS, which pulls in the autoconf

Re: [PATCH] configure: Fix default -O2 being added when CFLAGS not set

2022-03-28 Thread Glenn Washburn
Hi Paul, On Fri, 25 Mar 2022 07:53:29 +0100 Paul Menzel wrote: > Dear Glenn, > > > Thank you for your tireless awesome work on GRUB. Sincerely, thank you. It seems to me that you're also deserving of this compliment and probably more so. > Am 24.03.22 um 23:31 schrieb Glenn Washburn: > >

Re: [PATCH] configure: Fix default -O2 being added when CFLAGS not set

2022-03-28 Thread Glenn Washburn
On Fri, 25 Mar 2022 11:54:59 -0400 Robbie Harwood wrote: > Glenn Washburn writes: > > > Autoconf will set a default CFLAGS of "-g -O2" if CFLAGS is not set. CFLAGS > > was defaulted to "" early in configure to prevent this. Apparently something > > changed in autoconf and now

[PATCH v2 2/3] Fix -Werror=array-bounds array subscript 0 is outside array bounds

2022-03-28 Thread Michael Chang via Grub-devel
The grub is failing to build with gcc-12 in many places like this: In function 'init_cbfsdisk', inlined from 'grub_mod_init' at ../../grub-core/fs/cbfs.c:391:3: ../../grub-core/fs/cbfs.c:345:7: error: array subscript 0 is outside array bounds of 'grub_uint32_t[0]' {aka 'unsigned int[]'}

[PATCH v2 0/3] Fix GCC 12 build error

2022-03-28 Thread Michael Chang via Grub-devel
The tested gcc version is: abuild@mazu:~> gcc --version gcc (SUSE Linux) 12.0.1 20220307 (experimental) [revision 40c1d4a07e5798c01e4364336c9617550744861d] Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty;

[PATCH v2 3/3] reed_solomon: Fix array subscript 0 is outside array bounds

2022-03-28 Thread Michael Chang via Grub-devel
The grub_absolute_pointer() is a compound expression that can only work within a function. We are out of luck here when the pointer variables require global definition due to ATTRIBUTE_TEXT that have to use fully initialized global definition because of the way linkers work. static gf_single_t *

[PATCH v2 1/3] mkimage: Fix dangling pointer may be used error

2022-03-28 Thread Michael Chang via Grub-devel
The warning is real as long as dangling pointer to 'tmp_' may be used if o32 and o64 are both null. However that is not going to happen and can be ignored safely because the PE_OHDR is being used in a context that either o32 or o64 must have been properly initialized. Sadly compiler seems not to

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

2022-03-28 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

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

2022-03-28 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 ---

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

2022-03-28 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

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

2022-03-28 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 15/15] ibmvtpm: Add support for trusted boot using a vTPM 2.0

2022-03-28 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

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

2022-03-28 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

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

2022-03-28 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)

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

2022-03-28 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

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

2022-03-28 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 ---

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

2022-03-28 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 06/15] mm: Allow dynamically requesting additional memory regions

2022-03-28 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 05/15] mm: Drop unused unloading of modules on OOM

2022-03-28 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

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

2022-03-28 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

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

2022-03-28 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

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

2022-03-28 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

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

2022-03-28 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