[PATCH v3 1/2] mm: Adjust new region size to take management overhead into account

2022-12-22 Thread Zhang Boyang
When grub_memalign() encounters out-of-memory, it will try grub_mm_add_region_fn() to request more memory from system firmware. However, the size passed to it doesn't take region management overhead into account. Adding a memory area of "size" bytes may result in a heap region of less than "size" b

[PATCH v3 2/2] mm: Preallocate some space when adding new regions

2022-12-22 Thread Zhang Boyang
When grub_memalign() encounters out-of-memory, it will try grub_mm_add_region_fn() to request more memory from system firmware. However, it doesn't preallocate memory space for future allocation requests. In extreme cases, it requires one call to grub_mm_add_region_fn() for each memory allocation r

[PATCH v3 0/2] mm: Better handling of adding new regions

2022-12-22 Thread Zhang Boyang
Hi, This is the V3 patchset. V2 is at: https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00164.html V1 is at: https://lists.gnu.org/archive/html/grub-devel/2022-11/msg00147.html For changes in V2->V3, please see my reply at: https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00250.

[PATCH] verifiers: Don't return error for deferred image

2022-12-22 Thread Leo Yan
When boot from menu and the flag GRUB_VERIFY_FLAGS_DEFER_AUTH is set, grub returns error: Booting a command list error: verification requested but nobody cares: (hd0,gpt1)/Image. Press any key to continue... In this case, the image should be deferred for authentication, grub should return th

Re: [PATCH] verifiers: Don't return error for deferred image

2022-12-22 Thread Zhang Boyang
Hi, On 2022/12/22 19:14, Leo Yan wrote: When boot from menu and the flag GRUB_VERIFY_FLAGS_DEFER_AUTH is set, grub returns error: Booting a command list error: verification requested but nobody cares: (hd0,gpt1)/Image. Press any key to continue... In this case, the image should be defe

Re: [PATCH] verifiers: Don't return error for deferred image

2022-12-22 Thread Leo Yan
Hi Boyang, On Thu, Dec 22, 2022 at 07:25:13PM +0800, Zhang Boyang wrote: > Hi, > > On 2022/12/22 19:14, Leo Yan wrote: > > When boot from menu and the flag GRUB_VERIFY_FLAGS_DEFER_AUTH is set, > > grub returns error: > > > > Booting a command list > > > > error: verification requested but n

Re: [PATCH v2 8/8] serial: Add ability to specify MMIO ports via 'serial'

2022-12-22 Thread Daniel Kiper
Thank you for quick turn around! Now patches looks much better but... On Thu, Dec 22, 2022 at 05:12:57PM +1100, Benjamin Herrenschmidt wrote: > From: Benjamin Herrenschmidt > > This adds the ability to explicitely add an MMIO based serial port > via the 'serial' command. The syntax is: > > seria

Re: Handling large allocations (bypassing mm?)

2022-12-22 Thread Ard Biesheuvel
On Fri, 16 Dec 2022 at 18:55, Robbie Harwood wrote: > > Ard Biesheuvel writes: > > > As for supporing kernels from 2012: I don't see why upstream GRUB > > should care about that. If your distro fork supports those today, you > > will simply need to carry those patches out of tree a bit longer. >

Re: [PATCH] verifiers: Don't return error for deferred image

2022-12-22 Thread Zhang Boyang
Hi, On 2022/12/22 20:22, Leo Yan wrote: Hi Boyang, On Thu, Dec 22, 2022 at 07:25:13PM +0800, Zhang Boyang wrote: Hi, On 2022/12/22 19:14, Leo Yan wrote: When boot from menu and the flag GRUB_VERIFY_FLAGS_DEFER_AUTH is set, grub returns error: Booting a command list error: verificatio

[RFC PATCH v3 0/1] kern/dl: Add module version check

2022-12-22 Thread Zhang Boyang
Hi, This is the V3 of my patch. V2 is at: https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00234.html V1 is at: https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00213.html [ TD;LR ] 1) The check is always enforced when GRUB is locked down, i.e. modules will be refused to loa

[RFC PATCH v3 1/1] kern/dl: Add module version check

2022-12-22 Thread Zhang Boyang
This patch add version information to GRUB modules. Specifically, PACKAGE_VERSION is embedded as null-terminated string in .modver section. This string is checked at module loading time. If GRUB is locked down, modules with mismatched version will be rejected. This is necessary for implementing ex

Re: [RFC PATCH v3 0/1] kern/dl: Add module version check

2022-12-22 Thread Pete Batard via Grub-devel
I'm sorry but that's NO_GO for me. This is a major step back from v2, where the check was never applicable for BIOS and I believe I explained why a module check that can be enforced for BIOS is going to create a major headache for end-users. It seems pretty obvious that, if distro maintainers

Re: [PATCH v4 08/15] gdb: If enabled, print line used to load EFI kernel symbols when using gdb_grub script

2022-12-22 Thread Daniel Kiper
On Wed, Dec 21, 2022 at 11:57:33AM -0600, Glenn Washburn wrote: > On Wed, 21 Dec 2022 16:20:17 +0100 > Daniel Kiper wrote: > > > Adding Robbie... > > > > Please CC him next time when you post these patches. I would want to > > hear his opinion too. Or at least he is aware what is happening > > her

Re: [PATCH v4 12/15] gdb: Allow running user-defined commands at GRUB start

2022-12-22 Thread Daniel Kiper
On Thu, Dec 22, 2022 at 12:08:17AM -0600, Glenn Washburn wrote: > On Wed, 21 Dec 2022 12:19:16 -0600 > Glenn Washburn wrote: > > > On Wed, 21 Dec 2022 16:27:40 +0100 > > Daniel Kiper wrote: > > > > > On Thu, Dec 15, 2022 at 11:29:35PM -0600, Glenn Washburn wrote: > > > > A new command, run_on_sta

Re: [PATCH v4 13/15] gdb: Add extra early initialization symbols for i386-pc

2022-12-22 Thread Daniel Kiper
On Wed, Dec 21, 2022 at 12:21:26PM -0600, Glenn Washburn wrote: > On Wed, 21 Dec 2022 16:28:35 +0100 > Daniel Kiper wrote: > > > On Thu, Dec 15, 2022 at 11:29:36PM -0600, Glenn Washburn wrote: > > > Add symbols for boot.image, disk.image, and lzma_decompress.image > > > if the target is i386-pc. >

Re: GRUB 2.12 release - update

2022-12-22 Thread Daniel Kiper
Hi, Quick update below... On Wed, Oct 26, 2022 at 04:52:09PM +0200, Daniel Kiper wrote: > Hi, > > We are getting closer to the 2.12 release. Sadly we still do not have > many of important patch sets in the tree. So, I am going to spend more > time on reviews in the following weeks. Below you can

Re: [PATCH v2 8/8] serial: Add ability to specify MMIO ports via 'serial'

2022-12-22 Thread Benjamin Herrenschmidt
On Thu, 2022-12-22 at 13:54 +0100, Daniel Kiper wrote: > Thank you for quick turn around! > > Now patches looks much better but... Hehe :-) > > > >  #if (defined(__mips__) || defined (__i386__) || defined (__x86_64__)) && > > !defined(GRUB_MACHINE_EMU) && !defined(GRUB_MACHINE_ARC) > > -  if (

[PATCH v3 5/8] ns8250: Add configuration parameter when adding ports

2022-12-22 Thread Benjamin Herrenschmidt
From: Benjamin Herrenschmidt This will allow ports to be added with a pre-set configuration Signed-off-by: Benjamin Herrenschmidt --- grub-core/term/ns8250.c | 27 --- grub-core/term/serial.c | 2 +- include/grub/serial.h | 4 ++-- 3 files changed, 23 insertions(+),

[PATCH v3 7/8] ns8250: Support more MMIO access sizes

2022-12-22 Thread Benjamin Herrenschmidt
From: Benjamin Herrenschmidt It is common for PCI based UARTs to use larger than one byte access sizes. This adds support for this and uses the information present in SPCR accordingly. Signed-off-by: Benjamin Herrenschmidt --- grub-core/term/ns8250-spcr.c | 3 +- grub-core/term/ns8250.c

[PATCH v2 0/8] serial: Add MMIO & SPCR support

2022-12-22 Thread Benjamin Herrenschmidt
This series adds support for MMIO serial ports and auto-configuration via ACPI SPCR. This is necessary for the serial port to work on AWS EC2 "metal" x86 systems. An MMIO serial port can be specified explicitely using the "mmio," prefix for the --port argument to the 'serial' command, the registe

[PATCH v3 4/8] ns8250: Move base clock definition to a header

2022-12-22 Thread Benjamin Herrenschmidt
And while at it, unify it as clock frequency in HZ, to match the value in "struct grub_serial_config" and do the division by 16 in one common place. This will simplify adding SPCR support. Signed-off-by: Benjamin Herrenschmidt --- grub-core/term/ns8250.c | 15 --- include/grub/ns825

[PATCH v3 6/8] ns8250: Use ACPI SPCR table when available to configure serial

2022-12-22 Thread Benjamin Herrenschmidt
From: Benjamin Herrenschmidt "serial auto" is now equivalent to just "serial" and will use the SPCR to discover the port if present, otherwise defaults to "com0" as before. This allows to support MMIO ports specified by ACPI which is needed on AWS EC2 "metal" instances, and will enable GRUB to p

[PATCH 2/3] serial: Avoid double lookup of serial ports

2022-12-22 Thread Benjamin Herrenschmidt
The various functions to add a port used to return port->name, and the callers would immediately iterate all registered ports to "find" the one just created by comparing that return value with ... port->name. This is a waste of cycles and code. Instead, have those functions return "port" directly.

[PATCH v3 8/8] serial: Add ability to specify MMIO ports via 'serial'

2022-12-22 Thread Benjamin Herrenschmidt
This adds the ability to explicitely add an MMIO based serial port via the 'serial' command. The syntax is: serial --port=mmio,{.b,.w,.l,.q} Signed-off-by: Benjamin Herrenschmidt # Conflicts: # grub-core/term/serial.c --- docs/grub.texi | 26 +-- grub-core/term/seria

[PATCH 3/3] serial: Improve detection of duplicate serial ports

2022-12-22 Thread Benjamin Herrenschmidt
We currently rely on some pretty fragile comparison by name to identify wether a serial port being configured is identical --- grub-core/term/arc/serial.c | 4 +++ grub-core/term/ieee1275/serial.c | 4 +++ grub-core/term/ns8250.c | 16 + grub-core/term/serial.c | 5

[PATCH 1/3] serial: Replace usage of memcmp with strncmp

2022-12-22 Thread Benjamin Herrenschmidt
We are comparing strings after all Signed-off-by: Benjamin Herrenschmidt --- grub-core/term/serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index d161e1d36..88bcd4032 100644 --- a/grub-core/term/serial.c +++ b/gru

[PATCH v3 1/8] acpi: Export a generic grub_acpi_find_table

2022-12-22 Thread Benjamin Herrenschmidt
And convert grub_acpi_find_fadt to use it Signed-off-by: Benjamin Herrenschmidt --- grub-core/kern/acpi.c | 43 +-- include/grub/acpi.h | 3 +++ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/grub-core/kern/acpi.c b/grub-core/kern/acpi

[PATCH v3 3/8] ns8250: Add base support for MMIO UARTs

2022-12-22 Thread Benjamin Herrenschmidt
From: Benjamin Herrenschmidt This adds the ability for the driver to access UARTs via MMIO instead of PIO selectively at runtime, and exposes a new function to add an MMIO port. In an ideal world, MMIO accessors would be generic and have architecture specific memory barriers. However, existing d

[PATCH 0/3] serial: Cleanup & fix port discovery

2022-12-22 Thread Benjamin Herrenschmidt
This series cleans up a few things in serial port discovery and fixes detection of duplicates in some cases: - Existing usage of memcmp to compare strings is replaces with strncmp - Don't lookup ports by name right after creating them, just return the pointer instead. - Move the detecti

[PATCH v3 2/8] acpi: Add SPCR and generic address definitions

2022-12-22 Thread Benjamin Herrenschmidt
This adds the definition of the two ACPI tables according to the spec. Signed-off-by: Benjamin Herrenschmidt --- include/grub/acpi.h | 51 + 1 file changed, 51 insertions(+) diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 8c126b2b9..17aad

Re: [RFC PATCH v3 0/1] kern/dl: Add module version check

2022-12-22 Thread Zhang Boyang
Hi, I think there are some misunderstandings. This feature is implemented in kern/dl.c in core.img, which is UNDER YOUR CONTROL. Let me analyze the worst case from your perspective: 1) Every distro is enforcing version check, even in BIOS mode. 2) Because this check is in kern/dl.c, there i