diff mbox series

[1/2] xen/arm: Fix initrd placeholders generation in make_chosen_node()

Message ID 20230810112544.17365-2-michal.orzel@amd.com (mailing list archive)
State New, archived
Headers show
Series xen/arm: fixes around device tree generation | expand

Commit Message

Michal Orzel Aug. 10, 2023, 11:25 a.m. UTC
When booting a dom0less domU without initial ramdisk, it was observed
that Xen still creates empty linux,initrd-{start,end} properties under
/chosen node. This is because in make_chosen_node(), generation of initrd
placeholders (later on filled with the real values) is protected with
a check for presence of kernel bootmodule (always present) instead of
initrd bootmodule. Fix it along with renaming the variable from "mod" to
"initrd" to prevent similar mistakes in the future.

Fixes: 48f4bf6bdeb4 ("arm/acpi: Create min DT stub for Dom0")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/domain_build.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Luca Fancellu Aug. 10, 2023, 1:31 p.m. UTC | #1
> On 10 Aug 2023, at 12:25, Michal Orzel <michal.orzel@amd.com> wrote:
> 
> When booting a dom0less domU without initial ramdisk, it was observed
> that Xen still creates empty linux,initrd-{start,end} properties under
> /chosen node. This is because in make_chosen_node(), generation of initrd
> placeholders (later on filled with the real values) is protected with
> a check for presence of kernel bootmodule (always present) instead of
> initrd bootmodule. Fix it along with renaming the variable from "mod" to
> "initrd" to prevent similar mistakes in the future.
> 
> Fixes: 48f4bf6bdeb4 ("arm/acpi: Create min DT stub for Dom0")
> Signed-off-by: Michal Orzel <michal.orzel@amd.com>

Hi Michal, good catch!

Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>

Cheers,
Luca
Stefano Stabellini Aug. 11, 2023, 1:55 a.m. UTC | #2
On Thu, 10 Aug 2023, Luca Fancellu wrote:
> > On 10 Aug 2023, at 12:25, Michal Orzel <michal.orzel@amd.com> wrote:
> > 
> > When booting a dom0less domU without initial ramdisk, it was observed
> > that Xen still creates empty linux,initrd-{start,end} properties under
> > /chosen node. This is because in make_chosen_node(), generation of initrd
> > placeholders (later on filled with the real values) is protected with
> > a check for presence of kernel bootmodule (always present) instead of
> > initrd bootmodule. Fix it along with renaming the variable from "mod" to
> > "initrd" to prevent similar mistakes in the future.
> > 
> > Fixes: 48f4bf6bdeb4 ("arm/acpi: Create min DT stub for Dom0")
> > Signed-off-by: Michal Orzel <michal.orzel@amd.com>
> 
> Hi Michal, good catch!
> 
> Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Julien Grall Aug. 11, 2023, 6:24 p.m. UTC | #3
Hi Michal,

On 10/08/2023 12:25, Michal Orzel wrote:
> When booting a dom0less domU without initial ramdisk, it was observed
> that Xen still creates empty linux,initrd-{start,end} properties under
> /chosen node. This is because in make_chosen_node(), generation of initrd
> placeholders (later on filled with the real values) is protected with
> a check for presence of kernel bootmodule (always present) instead of
> initrd bootmodule. Fix it along with renaming the variable from "mod" to
> "initrd" to prevent similar mistakes in the future.
> 
> Fixes: 48f4bf6bdeb4 ("arm/acpi: Create min DT stub for Dom0")

(No change required, just a remark about the tag)

Someone wanting to backport this would need to be cautious. The fix 
would not apply as-is for Xen older than ~4.11 because 'mod' is used to 
fetch the command line as well.

This also means that it would not be correct to simply replace 'mod' 
with 'initrd'. Anyway, for upstream, this would only be backported up to 
4.17 as the other release are either only security supported or not 
supported at all. So this is not a concern for us.

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 39b4ee03a505..c6881de8bd85 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2256,7 +2256,7 @@  int __init make_chosen_node(const struct kernel_info *kinfo)
 {
     int res;
     const char *bootargs = NULL;
-    const struct bootmodule *mod = kinfo->kernel_bootmodule;
+    const struct bootmodule *initrd = kinfo->initrd_bootmodule;
     void *fdt = kinfo->fdt;
 
     dt_dprintk("Create chosen node\n");
@@ -2276,7 +2276,7 @@  int __init make_chosen_node(const struct kernel_info *kinfo)
      * If the bootloader provides an initrd, we must create a placeholder
      * for the initrd properties. The values will be replaced later.
      */
-    if ( mod && mod->size )
+    if ( initrd && initrd->size )
     {
         u64 a = 0;
         res = fdt_property(kinfo->fdt, "linux,initrd-start", &a, sizeof(a));