From nobody Tue Feb 10 12:42:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681457805266195.78246264464394; Fri, 14 Apr 2023 00:36:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnDyJ-0007FH-Bf; Fri, 14 Apr 2023 03:35:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnDyH-0007F0-6I; Fri, 14 Apr 2023 03:35:49 -0400 Received: from mail-out-4.itc.rwth-aachen.de ([2a00:8a60:1:e501::5:49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnDyD-0005sL-D6; Fri, 14 Apr 2023 03:35:48 -0400 Received: from rwthex-s1-a.rwth-ad.de ([134.130.26.152]) by mail-in-4.itc.rwth-aachen.de with ESMTP; 14 Apr 2023 09:35:37 +0200 Received: from Tartaros.fritz.box (2a0a:a540:ee49:0:4dac:dbd1:97f4:c51) by rwthex-s1-a.rwth-ad.de (2a00:8a60:1:e500::26:152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 14 Apr 2023 09:35:35 +0200 X-IPAS-Result: =?us-ascii?q?A2DIAgAJAjlk/5gagoZaHAEBAQEBAQcBARIBAQQEAQGCD?= =?us-ascii?q?4R9tV8PAQEBAQEBAQEBCAFEBAEBhQYChTwnOBMBAgQBAQEBAwIDAQEBAQEBA?= =?us-ascii?q?wEBBgE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gbQdU4O/Q37RzIw7DRywCeAGcCU3hGctNOiSMtbSY1y l+Ej5byXHlm9qeKVXLY/7vSoT7a1TUpEFLurBQsFWMti+QPaqlp5v4TZr6PyJKIs+A= IronPort-HdrOrdr: A9a23:Ta4mSK2LYH5WDQD++YgMVAqjBIMkLtp133Aq2lEZdPRUGvb1qy nIpoV+6faUskd3ZJhOo7690cW7K080sKQFgrX5Xo3SOTUO2lHIEGgK1+KLqAEIWReOlNK1vZ 0QFZSWY+eeMbEVt6vHCF7SKadZ/DD+ysCVbLDlvg5QcT0= X-Talos-CUID: 9a23:+LbNx2F8p9owJy91qmJl1EAMBMo9U0HMkluNOWizNnpJR4+aHAo= X-Talos-MUID: 9a23:ijtkdAY4IwzJd+BTmTjivDpuJMFU05+hI0svzJlZpcqtKnkl X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="5.99,195,1677538800"; d="scan'208";a="177084577" From: Stefan Lankes To: CC: , , Stefan Lankes Subject: [RFC 1/1] add support of `--initrd` for ELF-ARM kernels Date: Fri, 14 Apr 2023 09:34:32 +0200 Message-ID: <20230414073432.36000-2-slankes@eonerc.rwth-aachen.de> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20230414073432.36000-1-slankes@eonerc.rwth-aachen.de> References: <20230414073432.36000-1-slankes@eonerc.rwth-aachen.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [2a0a:a540:ee49:0:4dac:dbd1:97f4:c51] X-ClientProxiedBy: rwthex-w1-a.rwth-ad.de (2a00:8a60:1:e500::26:156) To rwthex-s1-a.rwth-ad.de (2a00:8a60:1:e500::26:152) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:8a60:1:e501::5:49; envelope-from=slankes@eonerc.rwth-aachen.de; helo=mail-out-4.itc.rwth-aachen.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1681457811782100005 Content-Type: text/plain; charset="utf-8" Currently, the flag `--initrd` is only support for Linux ARM kernels. However, also other ELF kernels could depend on an initial ramdisk. This PR loads also the initrd for ELF kernels and announce the location by the nodes "/chosen/initrd-start" and "/chosen/initrd-end" within the device tree. Signed-off-by: Stefan Lankes --- hw/arm/boot.c | 106 +++++++++++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 54f6a3e0b3..f767a4809e 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -657,20 +657,38 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_i= nfo *binfo, } =20 if (binfo->initrd_size) { - rc =3D qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,initrd-= start", + if (binfo->is_linux) { + rc =3D qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,ini= trd-start", acells, binfo->initrd_start); - if (rc < 0) { - fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); - goto fail; - } + if (rc < 0) { + fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n= "); + goto fail; + } =20 - rc =3D qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,initrd-= end", - acells, - binfo->initrd_start + - binfo->initrd_size); - if (rc < 0) { - fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); - goto fail; + rc =3D qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,ini= trd-end", + acells, + binfo->initrd_start + + binfo->initrd_size); + if (rc < 0) { + fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); + goto fail; + } + } else { + rc =3D qemu_fdt_setprop_sized_cells(fdt, "/chosen", "initrd-st= art", + acells, binfo->initrd_start); + if (rc < 0) { + fprintf(stderr, "couldn't set /chosen/initrd-start\n"); + goto fail; + } + + rc =3D qemu_fdt_setprop_sized_cells(fdt, "/chosen", "initrd-en= d", + acells, + binfo->initrd_start + + binfo->initrd_size); + if (rc < 0) { + fprintf(stderr, "couldn't set /chosen/initrd-end\n"); + goto fail; + } } } =20 @@ -1099,41 +1117,41 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cp= u, } info->initrd_start =3D TARGET_PAGE_ALIGN(info->initrd_start); =20 - if (is_linux) { - uint32_t fixupcontext[FIXUP_MAX]; - - if (info->initrd_filename) { + if (info->initrd_filename) { =20 - if (info->initrd_start >=3D ram_end) { - error_report("not enough space after kernel to load initrd= "); - exit(1); - } + if (info->initrd_start >=3D ram_end) { + error_report("not enough space after kernel to load initrd"); + exit(1); + } =20 - initrd_size =3D load_ramdisk_as(info->initrd_filename, - info->initrd_start, - ram_end - info->initrd_start, as= ); - if (initrd_size < 0) { - initrd_size =3D load_image_targphys_as(info->initrd_filena= me, - info->initrd_start, - ram_end - - info->initrd_start, - as); - } - if (initrd_size < 0) { - error_report("could not load initrd '%s'", - info->initrd_filename); - exit(1); - } - if (info->initrd_start + initrd_size > ram_end) { - error_report("could not load initrd '%s': " - "too big to fit into RAM after the kernel", - info->initrd_filename); - exit(1); - } - } else { - initrd_size =3D 0; + initrd_size =3D load_ramdisk_as(info->initrd_filename, + info->initrd_start, + ram_end - info->initrd_start, as); + if (initrd_size < 0) { + initrd_size =3D load_image_targphys_as(info->initrd_filename, + info->initrd_start, + ram_end - + info->initrd_start, + as); + } + if (initrd_size < 0) { + error_report("could not load initrd '%s'", + info->initrd_filename); + exit(1); + } + if (info->initrd_start + initrd_size > ram_end) { + error_report("could not load initrd '%s': " + "too big to fit into RAM after the kernel", + info->initrd_filename); + exit(1); } - info->initrd_size =3D initrd_size; + } else { + initrd_size =3D 0; + } + info->initrd_size =3D initrd_size; + + if (is_linux) { + uint32_t fixupcontext[FIXUP_MAX]; =20 fixupcontext[FIXUP_BOARDID] =3D info->board_id; fixupcontext[FIXUP_BOARD_SETUP] =3D info->board_setup_addr; --=20 2.39.2 (Apple Git-143)