On Tue, Jul 8, 2025 at 8:26 PM Frediano Ziglio via Grub-devel
<grub-devel@gnu.org> wrote:
>
> 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 have options for both Xen (xen_hypervisor) and kernel
> (first xen_module) compose the command lines.
>
> Signed-off-by: Frediano Ziglio <frediano.zig...@cloud.com>
> ---
>  grub-core/loader/arm64/xen_boot.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/grub-core/loader/arm64/xen_boot.c 
> b/grub-core/loader/arm64/xen_boot.c
> index 64f685de6..bf66db3eb 100644
> --- a/grub-core/loader/arm64/xen_boot.c
> +++ b/grub-core/loader/arm64/xen_boot.c
> @@ -302,6 +302,29 @@ fail:
>
>    return grub_error (GRUB_ERR_IO, "failed to install/update FDT");
>  #else
> +  const char *xen_cmdline, *start = "placeholder -- ";
> +  char *new_cmdline;
> +
> +  /* Concatenate Xen command line with kernel command line */
> +  if (!module_head || !module_head->cmdline || !module_head->cmdline_size)
> +    return GRUB_ERR_NONE;
> +
> +  xen_cmdline = xen_hypervisor->cmdline ? xen_hypervisor->cmdline : "";
> +  if (grub_strncmp(xen_cmdline, "-- ", 3) == 0 ||
> +      grub_strstr(xen_cmdline, " -- ") != NULL)
> +    start = "";
> +  new_cmdline =
> +    grub_xasprintf ("%s%s -- %s", start, xen_cmdline, module_head->cmdline);
> +  if (!new_cmdline)
> +    return grub_errno;
> +
> +  grub_free (xen_hypervisor->cmdline);
> +  grub_free (module_head->cmdline);
> +  xen_hypervisor->cmdline = new_cmdline;
> +  xen_hypervisor->cmdline_size = grub_strlen (new_cmdline);

I think this is supposed to include the NUL terminator.

Ross

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to