From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
Anup Patel <apatel@ventanamicro.com>
Subject: Re: [kvmtool PATCH] riscv: Fix no params with nodefault segfault
Date: Tue, 11 Feb 2025 15:16:18 +0000 [thread overview]
Message-ID: <Z6tpwskaTCfS2mjR@arm.com> (raw)
In-Reply-To: <20250123151339.185908-2-ajones@ventanamicro.com>
Hi Drew,
On Thu, Jan 23, 2025 at 04:13:40PM +0100, Andrew Jones wrote:
> Fix segfault received when using --nodefault without --params.
>
> Fixes: 7c9aac003925 ("riscv: Generate FDT at runtime for Guest/VM")
> Suggested-by: Alexandru Elisei <alexandru.elisei@arm.com>
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> ---
> riscv/fdt.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/riscv/fdt.c b/riscv/fdt.c
> index 85c8f95604f6..f6a702533258 100644
> --- a/riscv/fdt.c
> +++ b/riscv/fdt.c
> @@ -256,9 +256,10 @@ static int setup_fdt(struct kvm *kvm)
> if (kvm->cfg.kernel_cmdline)
> _FDT(fdt_property_string(fdt, "bootargs",
> kvm->cfg.kernel_cmdline));
> - } else
> + } else if (kvm->cfg.real_cmdline) {
Looks good to me, matches how arm/fdt.c handles real_cmdline:
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Some context here. Before the patch that introduced --nodefaults, in commit
5613ae26b998 ("Add --nodefaults command line argument"), kvmtool would
always fiddle with the kernel command line to make it more likely that a
kernel boots - kvm_cmd_run_init() called kvm_run_set_real_cmdline()
unconditionally, which made it that kvm->cfg.real_cmdline was always
pointing to a valid string. Hence no check was needed here.
After --nodefaults was introduced, if the user specifies --nodefaults and
doesn't set the kernel command line (via -p/--params), real_cmdline ends up
being NULL and the fdt generator segfaults below.
The riscv port was developed in parallel to the series that introduced
--nodefaults, so I guess this check was missed during integration.
Thanks,
Alex
> _FDT(fdt_property_string(fdt, "bootargs",
> kvm->cfg.real_cmdline));
> + }
>
> _FDT(fdt_property_string(fdt, "stdout-path", "serial0"));
>
> --
> 2.48.1
>
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
Anup Patel <apatel@ventanamicro.com>
Subject: Re: [kvmtool PATCH] riscv: Fix no params with nodefault segfault
Date: Tue, 11 Feb 2025 15:16:18 +0000 [thread overview]
Message-ID: <Z6tpwskaTCfS2mjR@arm.com> (raw)
In-Reply-To: <20250123151339.185908-2-ajones@ventanamicro.com>
Hi Drew,
On Thu, Jan 23, 2025 at 04:13:40PM +0100, Andrew Jones wrote:
> Fix segfault received when using --nodefault without --params.
>
> Fixes: 7c9aac003925 ("riscv: Generate FDT at runtime for Guest/VM")
> Suggested-by: Alexandru Elisei <alexandru.elisei@arm.com>
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> ---
> riscv/fdt.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/riscv/fdt.c b/riscv/fdt.c
> index 85c8f95604f6..f6a702533258 100644
> --- a/riscv/fdt.c
> +++ b/riscv/fdt.c
> @@ -256,9 +256,10 @@ static int setup_fdt(struct kvm *kvm)
> if (kvm->cfg.kernel_cmdline)
> _FDT(fdt_property_string(fdt, "bootargs",
> kvm->cfg.kernel_cmdline));
> - } else
> + } else if (kvm->cfg.real_cmdline) {
Looks good to me, matches how arm/fdt.c handles real_cmdline:
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Some context here. Before the patch that introduced --nodefaults, in commit
5613ae26b998 ("Add --nodefaults command line argument"), kvmtool would
always fiddle with the kernel command line to make it more likely that a
kernel boots - kvm_cmd_run_init() called kvm_run_set_real_cmdline()
unconditionally, which made it that kvm->cfg.real_cmdline was always
pointing to a valid string. Hence no check was needed here.
After --nodefaults was introduced, if the user specifies --nodefaults and
doesn't set the kernel command line (via -p/--params), real_cmdline ends up
being NULL and the fdt generator segfaults below.
The riscv port was developed in parallel to the series that introduced
--nodefaults, so I guess this check was missed during integration.
Thanks,
Alex
> _FDT(fdt_property_string(fdt, "bootargs",
> kvm->cfg.real_cmdline));
> + }
>
> _FDT(fdt_property_string(fdt, "stdout-path", "serial0"));
>
> --
> 2.48.1
>
next prev parent reply other threads:[~2025-02-11 15:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 15:13 [kvmtool PATCH] riscv: Fix no params with nodefault segfault Andrew Jones
2025-01-23 15:13 ` Andrew Jones
2025-02-11 15:16 ` Alexandru Elisei [this message]
2025-02-11 15:16 ` Alexandru Elisei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z6tpwskaTCfS2mjR@arm.com \
--to=alexandru.elisei@arm.com \
--cc=ajones@ventanamicro.com \
--cc=apatel@ventanamicro.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.