Re: [PATCH v5 1/5] kern/misc: Implement grub_strtok()

2025-07-28 Thread Frediano Ziglio via Grub-devel
On Sun, Jul 27, 2025 at 2:57 AM Alec Brown via Grub-devel wrote: > > Add the functions grub_strtok() and grub_strtok_r() to help parse strings into > tokens separated by characters in the 'delim' parameter. These functions are > present in gnulib but calling them directly from the gnulib code is q

Re: [PATCH] arm64/xen: Set correctly bootargs property for modules

2025-07-25 Thread Frediano Ziglio via Grub-devel
On Fri, Jul 25, 2025 at 1:56 PM Daniel Kiper wrote: > > Next time when you post Xen patches please CC Xen-devel too. > > On Mon, Jul 21, 2025 at 05:25:57PM +0100, Frediano Ziglio via Grub-devel > wrote: > > "cmdline_size" already account for NUL terminator, you

[PATCH] arm64/xen: Set correctly bootargs property for modules

2025-07-21 Thread Frediano Ziglio via Grub-devel
"cmdline_size" already account for NUL terminator, you can see this in "xen_boot_binary_load". The same property is set correctly for Xen command line. Signed-off-by: Frediano Ziglio --- grub-core/loader/arm64/xen_boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-co

[PATCH v4] loader/efi/linux: Return correct size from LoadFile

2025-07-16 Thread Frediano Ziglio via Grub-devel
From UEFI specifications 2.10, section 13.2.2, "EFI_LOAD_FILE2_PROTOCOL.LoadFile" (see https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html), for BufferSize: On input the size of Buffer in bytes. On output with a return code of EFI_SUCCESS, the amount of data transferred to Buff

Re: [PATCH v3] loader/efi/linux: Return correct size from LoadFile

2025-07-16 Thread Frediano Ziglio via Grub-devel
On Tue, Jul 15, 2025 at 1:37 PM Daniel Kiper wrote: > > On Mon, Jul 14, 2025 at 09:08:48AM +0100, Frediano Ziglio via Grub-devel > wrote: > > From UEFI specifications 2.10, section 13.2.2, > > "EFI_LOAD_FILE2_PROTOCOL.LoadFile" (see >

[PATCH v3] loader/efi/linux: Return correct size from LoadFile

2025-07-14 Thread Frediano Ziglio via Grub-devel
From UEFI specifications 2.10, section 13.2.2, "EFI_LOAD_FILE2_PROTOCOL.LoadFile" (see https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html), for BufferSize: On input the size of Buffer in bytes. On output with a return code of EFI_SUCCESS, the amount of data transferred to Buff

[PATCH v2] loader/efi/linux: Return correct size from LoadFile

2025-07-11 Thread Frediano Ziglio via Grub-devel
From UEFI specifications 2.10, section 13.2.2, "EFI_LOAD_FILE2_PROTOCOL.LoadFile" (see https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html), for BufferSize: On input the size of Buffer in bytes. On output with a return code of EFI_SUCCESS, the amount of data transferred to Buff

[PATCH] loader/efi/linux: Return correct size from LoadFile

2025-07-10 Thread Frediano Ziglio via Grub-devel
According to specifications, for BufferSize: On output with a return code of EFI_SUCCESS, the amount of data transferred to Buffer. so set *buffer_size correctly. Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-co

Re: [RFC PATCH 4/5] arm64/xen: Use LoadFile2 protocol for Xen boot

2025-07-09 Thread Frediano Ziglio via Grub-devel
On Wed, Jul 9, 2025 at 2:08 PM Ross Lagerwall wrote: > > On Tue, Jul 8, 2025 at 9:02 PM Frediano Ziglio via Grub-devel > wrote: > > > > Allows to load modules using LoadFile2 protocol. > > Add and use a new GUID for kernel media device. > > This will allow Xen to

Re: [RFC PATCH 4/5] arm64/xen: Use LoadFile2 protocol for Xen boot

2025-07-09 Thread Frediano Ziglio via Grub-devel
On Wed, Jul 9, 2025 at 11:30 AM Ross Lagerwall wrote: > > On Tue, Jul 8, 2025 at 9:02 PM Frediano Ziglio via Grub-devel > wrote: > > > > Allows to load modules using LoadFile2 protocol. > > Add and use a new GUID for kernel media device. > > This will allow

Re: [RFC PATCH 3/5] arm64/xen: Allows to use xen_hypervisor and xen_module on x86_64-efi

2025-07-09 Thread Frediano Ziglio via Grub-devel
On Wed, Jul 9, 2025 at 10:54 AM Ross Lagerwall wrote: > > On Wed, Jul 9, 2025 at 10:35 AM Frediano Ziglio via Grub-devel > wrote: > > > > On Tue, Jul 8, 2025 at 11:43 AM Frediano Ziglio > > wrote: > > > > > > Compile for x86_64 EFI architecture. &

Re: [RFC PATCH 5/5] arm64/xen: Allows to use kernel command line from first module

2025-07-09 Thread Frediano Ziglio via Grub-devel
On Wed, Jul 9, 2025 at 11:47 AM Ross Lagerwall wrote: > > On Tue, Jul 8, 2025 at 8:26 PM Frediano Ziglio via Grub-devel > wrote: > > > > For ARM64 command lines are passed using device tree, for > > x86_64 we need to use LoadOptions putting both Xen and kernel >

Re: [RFC PATCH 3/5] arm64/xen: Allows to use xen_hypervisor and xen_module on x86_64-efi

2025-07-09 Thread Frediano Ziglio via Grub-devel
On Tue, Jul 8, 2025 at 11:43 AM Frediano Ziglio wrote: > > Compile for x86_64 EFI architecture. > Do not fill device tree, not present for this architecture. > > Signed-off-by: Frediano Ziglio > --- > grub-core/Makefile.core.def | 2 ++ > grub-core/loader/arm64/xen_boot.c | 13 +++

[RFC PATCH 3/5] arm64/xen: Allows to use xen_hypervisor and xen_module on x86_64-efi

2025-07-08 Thread Frediano Ziglio via Grub-devel
Compile for x86_64 EFI architecture. Do not fill device tree, not present for this architecture. Signed-off-by: Frediano Ziglio --- grub-core/Makefile.core.def | 2 ++ grub-core/loader/arm64/xen_boot.c | 13 + 2 files changed, 15 insertions(+) diff --git a/grub-core/Makefile.

[RFC PATCH 2/5] kern/list: Add a grub_list_append function

2025-07-08 Thread Frediano Ziglio via Grub-devel
Add an element at the end of a list. Signed-off-by: Frediano Ziglio --- grub-core/kern/list.c | 10 ++ include/grub/list.h | 1 + 2 files changed, 11 insertions(+) diff --git a/grub-core/kern/list.c b/grub-core/kern/list.c index 09761b0e5..c5bdaf94b 100644 --- a/grub-core/kern/list.c

[RFC PATCH 1/5] kern/list: Add a grub_list_length function

2025-07-08 Thread Frediano Ziglio via Grub-devel
Counts elements in a list. Signed-off-by: Frediano Ziglio --- grub-core/kern/list.c | 12 include/grub/list.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/grub-core/kern/list.c b/grub-core/kern/list.c index a256bb3f8..09761b0e5 100644 --- a/grub-core/kern/list.c +++ b/

[RFC PATCH 0/5] Allows the usage of xen_hypervisor and xen_module on x86_64

2025-07-08 Thread Frediano Ziglio via Grub-devel
Currently xen_hypervisor and xen_module commands are available only for ARM64 EFI. For x86_64 if the Xen format is portable executable there's no way to pass multiple modules (the feature is available using multiboot2 but only for ELF files). So instead on adding new GRUB commands reuse the already

[RFC PATCH 4/5] arm64/xen: Use LoadFile2 protocol for Xen boot

2025-07-08 Thread Frediano Ziglio via Grub-devel
Allows to load modules using LoadFile2 protocol. Add and use a new GUID for kernel media device. This will allow Xen to pick up additional modules using EFI interface instead of using multiboot2 interface (not available on x86_64). Signed-off-by: Frediano Ziglio --- grub-core/loader/arm64/xen_bo

[RFC PATCH 5/5] arm64/xen: Allows to use kernel command line from first module

2025-07-08 Thread Frediano Ziglio via Grub-devel
For ARM64 command lines are passed using device tree, for x86_64 we need to use LoadOptions putting both Xen and kernel arguments. On x86_64 the LoadOptions is composed by 2 parts, EFI options and Xen options. The Xen options is composed by Xen options and, optionally, kernel options. In order to h

[PATCH v2] arm64/xen: Consider alignment calling grub_arch_efi_linux_boot_image

2025-07-07 Thread Frediano Ziglio via Grub-devel
The Xen image is loaded alignment, not always at "start". Signed-off-by: Frediano Ziglio --- Changes since v1: - indentation changes --- grub-core/loader/arm64/xen_boot.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/lo

Re: [PATCH] arm64/xen: Consider alignment calling grub_arch_efi_linux_boot_image

2025-07-07 Thread Frediano Ziglio via Grub-devel
On Fri, Jul 4, 2025 at 4:20 PM Sudhakar Kuppusamy wrote: > > > > > On 4 Jul 2025, at 7:36 PM, Frediano Ziglio via Grub-devel > > wrote: > > > > The Xen image is loaded alignment, not always at "start". > > > > Signed-off-by: Frediano Zig

Re: [PATCH] arm64/xen: Use bool instead of int

2025-07-04 Thread Frediano Ziglio via Grub-devel
On Fri, Jul 4, 2025 at 4:13 PM Sudhakar Kuppusamy wrote: > > > > > On 4 Jul 2025, at 7:35 PM, Frediano Ziglio via Grub-devel > > wrote: > > > > More readable, could consume less space. > > > > Signed-off-by: Frediano Ziglio >

[PATCH] arm64/xen: Use bool instead of int

2025-07-04 Thread Frediano Ziglio via Grub-devel
More readable, could consume less space. Signed-off-by: Frediano Ziglio --- grub-core/loader/arm64/xen_boot.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 731f1913a..8db1d9db0 10064

[PATCH] arm64/xen: Consider alignment calling grub_arch_efi_linux_boot_image

2025-07-04 Thread Frediano Ziglio via Grub-devel
The Xen image is loaded alignment, not always at "start". Signed-off-by: Frediano Ziglio --- grub-core/loader/arm64/xen_boot.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 8db1d9db0..26

[PATCH] arm64/xen: Delete correctly all modules loaded by xen_module

2025-07-04 Thread Frediano Ziglio via Grub-devel
We need to use FOR_LIST_ELEMENTS_SAFE instead of FOR_LIST_ELEMENTS as single_binary_unload, called during the loop, is changing the list using grub_list_remove. Given the environment probably the old code simply deleted only the first module on the list not freeing all the others. Signed-off-by: F

[PATCH v3 5/6] loader/efi/linux: Use sizeof instead of constant

2025-06-25 Thread Frediano Ziglio via Grub-devel
This is more consistent with the above code using sizeof (grub_efi_char16_t). Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index 3b5c4ed17..9df49

[PATCH v4 1/6] loader/efi/linux: Remove useless assignment

2025-06-25 Thread Frediano Ziglio via Grub-devel
If the following allocation fails this would leave "load_options" NULL while "load_options_size" not valid. If the allocation succeed "load_options_size" is overwritten. Signed-off-by: Frediano Ziglio Reviewed-by: Daniel Kiper --- grub-core/loader/efi/linux.c | 3 +-- 1 file changed, 1 insertio

[PATCH v4 3/6] loader/efi/linux: Do not pass excessive size for source string

2025-06-25 Thread Frediano Ziglio via Grub-devel
The size passed to grub_utf8_to_utf16 for the source string is used as a limit for the string if NUL character is not encountered however len, which is strlen(src)*2+2 is surely greater than strlen(src). Pass the exact correct length. Signed-off-by: Frediano Ziglio --- Changes since v3: - pass ex

[PATCH v4 5/6] loader/efi/linux: Use sizeof instead of constant

2025-06-25 Thread Frediano Ziglio via Grub-devel
This is more consistent with the above code using sizeof (grub_efi_char16_t). Signed-off-by: Frediano Ziglio Reviewed-by: Daniel Kiper --- grub-core/loader/efi/linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/lin

[PATCH v4 0/6] Adjustments for EFI "linux" command and

2025-06-25 Thread Frediano Ziglio via Grub-devel
The series started from the issue that LoadOptions, if providing just command line arguments should be NUL-terminated. But this carried some updates to adjust the code properly. Changes since v3: - use proper length converting args string; - added Reviewed-by comments. Frediano Ziglio (6): load

[PATCH v4 4/6] loader/efi/linux: Use proper type for "len" variable

2025-06-25 Thread Frediano Ziglio via Grub-devel
Although the length should not exceed 2^31 grub_size_t is more suitable for that variable. "len" is used to compute the size of buffers which in C is a size_t, not a int. It is used for GRUB_EFI_BYTES_TO_PAGES which expects unsigned values. It is assigned to load_options_size which is unsigned, not

[PATCH v4 2/6] include/grub/charset.h: Update documentation

2025-06-25 Thread Frediano Ziglio via Grub-devel
(grub_size_t) -1 is never returned, the function always return a not negative values. This is important for overflows considerations. Signed-off-by: Frediano Ziglio Reviewed-by: Daniel Kiper --- include/grub/charset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include

[PATCH v4 6/6] loader/efi/linux: Correctly terminate LoadOptions field

2025-06-25 Thread Frediano Ziglio via Grub-devel
If a simple string for arguments are passed it should be NUL terminated. This is true for other code but not for "linux" command. Signed-off-by: Frediano Ziglio --- Changes since v1 - remove useless assignment. Changes since v2 - split changes; - correct spacing. --- grub-core/loader/efi/linux.

Re: [PATCH v3 6/6] loader/efi/linux: Correctly terminate LoadOptions field

2025-06-25 Thread Frediano Ziglio via Grub-devel
On Wed, Jun 25, 2025 at 1:41 PM Daniel Kiper wrote: > > In general patches #1, #2, #4 and #5 make sense for me. So, you can add > my RB there... > > On Wed, Jun 25, 2025 at 07:42:27AM +0100, Frediano Ziglio via Grub-devel > wrote: > > If a simple string for arguments are

Re: [PATCH v3 3/6] loader/efi/linux: Do not pass excessive size for source string

2025-06-25 Thread Frediano Ziglio via Grub-devel
On Wed, Jun 25, 2025 at 1:27 PM Daniel Kiper wrote: > > On Wed, Jun 25, 2025 at 07:42:24AM +0100, Frediano Ziglio via Grub-devel > wrote: > > The size passed to grub_utf8_to_utf16 for the source string is > > used as a limit for the string if NUL character is not encoun

Re: [PATCH v2] loader/efi/linux: Correctly terminate LoadOptions field

2025-06-25 Thread Frediano Ziglio via Grub-devel
On Tue, Jun 24, 2025 at 4:48 PM Daniel Kiper wrote: > > On Tue, Jun 24, 2025 at 09:01:14AM +0100, Frediano Ziglio via Grub-devel > wrote: > > If a simple string for arguments are passed it should be NUL > > terminated. This is true for other code but not for "linux&qu

[PATCH v3 6/6] loader/efi/linux: Correctly terminate LoadOptions field

2025-06-25 Thread Frediano Ziglio via Grub-devel
If a simple string for arguments are passed it should be NUL terminated. This is true for other code but not for "linux" command. Signed-off-by: Frediano Ziglio --- Changes since v1 - remove useless assignment. Changes since v2 - split changes; - correct spacing. --- grub-core/loader/efi/linux.

[PATCH v3 3/6] loader/efi/linux: Do not pass excessive size for source string

2025-06-24 Thread Frediano Ziglio via Grub-devel
The size passed to grub_utf8_to_utf16 for the source string is used as a limit for the string if NUL character is not encountered however len, which is strlen(src)*2+2 is surely greater than strlen(src). Pass (grub_size_t) -1 to consider only NUL terminator. Signed-off-by: Frediano Ziglio --- gr

[PATCH v3 1/6] loader/efi/linux: Remove useless assignment

2025-06-24 Thread Frediano Ziglio via Grub-devel
If the following allocation fails this would leave "load_options" NULL while "load_options_size" not valid. If the allocation succeed "load_options_size" is overwritten. Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff

[PATCH v3 4/6] loader/efi/linux: Use proper type for "len" variable

2025-06-24 Thread Frediano Ziglio via Grub-devel
Although the length should not exceed 2^31 grub_size_t is more suitable for that variable. "len" is used to compute the size of buffers which in C is a size_t, not a int. It is used for GRUB_EFI_BYTES_TO_PAGES which expects unsigned values. It is assigned to load_options_size which is unsigned, not

[PATCH v3 2/6] include/grub/charset.h: Update documentation

2025-06-24 Thread Frediano Ziglio via Grub-devel
(grub_size_t) -1 is never returned, the function always return a not negative values. This is important for overflows considerations. Signed-off-by: Frediano Ziglio --- include/grub/charset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/grub/charset.h b/include/g

[PATCH v2] loader/efi/linux: Correctly terminate LoadOptions field

2025-06-24 Thread Frediano Ziglio via Grub-devel
If a simple string for arguments are passed it should be NUL terminated. This is true for other code but not for "linux" command. Signed-off-by: Frediano Ziglio --- Changes since v1 - remove useless assignment. --- grub-core/loader/efi/linux.c | 13 +++-- 1 file changed, 7 insertions(+),

Re: [PATCH] loader/efi/linux: Correctly terminate LoadOptions field

2025-06-23 Thread Frediano Ziglio via Grub-devel
On Mon, Jun 23, 2025 at 2:46 PM Ross Lagerwall wrote: > > On Mon, Jun 23, 2025 at 12:33 PM Frediano Ziglio via Grub-devel > wrote: > > > > If a simple string for arguments are passed it should be NUL > > terminated. This is true for other code but not for "linux&

[PATCH] loader/efi/linux: Correctly terminate LoadOptions field

2025-06-23 Thread Frediano Ziglio via Grub-devel
If a simple string for arguments are passed it should be NUL terminated. This is true for other code but not for "linux" command. Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/grub-core/loader/efi/linu

Re: [PATCH v6 10/10] efi: Disallow fallback to legacy Linux loader when shim says NX is required.

2024-09-23 Thread Frediano Ziglio via Grub-devel
On Thu, Sep 19, 2024 at 5:33 PM Mate Kukri wrote: > > Signed-off-by: Mate Kukri > --- > grub-core/kern/efi/sb.c | 28 > grub-core/loader/efi/linux.c | 12 +++- > include/grub/efi/api.h | 2 ++ > include/grub/efi/sb.h| 2 ++ > 4 files chan

Re: [PATCH v2 6/8] i386/memory: Define GRUB_PAGE_MASK constant and GRUB_PAGE_{UP, DOWN} macros

2024-09-20 Thread Frediano Ziglio via Grub-devel
On Thu, Sep 19, 2024 at 11:03 PM Sergii Dmytruk wrote: > > From: Krystian Hebel > > Subsequent patches will use those macros and constant. > Minor, but "Define GRUB_PAGE_MASK constant and GRUB_PAGE_{UP, DOWN} macros" subject sounds a bit confusing to me. I mean, at the end they are all defined a

[PATCH v2 1/2] loader/efi: Reuse len variable

2024-09-03 Thread Frediano Ziglio via Grub-devel
Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- Changes since v1: - split pointer reset. diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index 803d2541d..cbb480b34 100644 --- a/grub-core/loader

[PATCH v2 2/2] loader/efi: Reset freed pointer

2024-09-03 Thread Frediano Ziglio via Grub-devel
Avoid dangling pointer. Code should not be reached but better safe than sorry. Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index cbb480b34..1ffbcf9ce 100644 --- a/g

[PATCH] relocator: Fix comment in code

2024-09-03 Thread Frediano Ziglio via Grub-devel
The instruction uses a 64 bit immediate. Signed-off-by: Frediano Ziglio --- grub-core/lib/x86_64/relocator_asm.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/lib/x86_64/relocator_asm.S b/grub-core/lib/x86_64/relocator_asm.S index 2ab6d8cb7..fd9b2b44e 100644 ---

[PATCH] loader/efi: Reuse len variable

2024-09-03 Thread Frediano Ziglio via Grub-devel
Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index 803d2541d..1ffbcf9ce 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linu

[PATCH] loader/efi: Update comment

2024-09-03 Thread Frediano Ziglio via Grub-devel
The function called is grub_utf8_to_utf16. Signed-off-by: Frediano Ziglio --- grub-core/loader/efi/linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index bfbd95aee..803d2541d 100644 --- a/grub-core/loader/efi/

[PATCH] relocator: Use .quad instead of .long

2024-09-03 Thread Frediano Ziglio via Grub-devel
Used also in other assembly files. They are single 64-bit values. Signed-off-by: Frediano Ziglio --- grub-core/lib/x86_64/relocator_asm.S | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/grub-core/lib/x86_64/relocator_asm.S b/grub-core/lib/x86_64/relocator_asm.S