From nobody Sat May 4 14:38:45 2024 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; dmarc=fail(p=none dis=none) header.from=flygoat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660408271722170.16199807397845; Sat, 13 Aug 2022 09:31:11 -0700 (PDT) Received: from localhost ([::1]:40348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMu2X-0002X1-N4 for importer@patchew.org; Sat, 13 Aug 2022 12:31:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMtz4-00087V-0j for qemu-devel@nongnu.org; Sat, 13 Aug 2022 12:27:34 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:41047) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMtz2-0005TN-Ic for qemu-devel@nongnu.org; Sat, 13 Aug 2022 12:27:33 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E5A9F5C00D3; Sat, 13 Aug 2022 12:27:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 13 Aug 2022 12:27:30 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 13 Aug 2022 12:27:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1660408050; x=1660494450; bh=RQ FP/Pb0CXD9g4rjGrPFNExo8/7xaOwQ2mU2NCkA/fo=; b=JKFLeUGa1UhUVBypwO KxqD4jkLIE+yYqvteNWC0Jt/s0X30tzM9QJKcye+68WS4T5Gl7hL/1sZxgZhk4iS 8fNa1EqlVr/LESoEdO1iegf/XyOsMZmt9oOiQKUO/KrJE4myu2zI3onHBJ6Rekl1 sNXffHnSjpUG5fVYdfjUnOsPjDW8vFnERP2E72igj2f+vKNGlUsUcXOXccTrwM/Q SdjRjHeouVv2sHFEtnRVWoZ9aYvETK1xs3AerkxITM1OVIE+ODopa9BO1nzaefEx tHpzNiQP0x9chLaDzMWV8VJwfZfE/jhi1DT6UPlyeN2KwDBsd3aQZDqMSlhg1/Yy QugA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1660408050; x=1660494450; bh=RQFP/Pb0CXD9g 4rjGrPFNExo8/7xaOwQ2mU2NCkA/fo=; b=c6ftuq+++3EZEiMvHlfezMJmmwx22 owxitqDtt0edN5Tjk39R0uasYR8CY4PKUlC2QzVpa64x83UX/E/13iHE1SOuOHQM wzakZdJ/+cPabzawkL+2aoV3+l5EfjrBScEL9uLaQiosMom0ly7vIucAFBvVnV/p HfMdr2D7Fu+McC40Yszz/AkXh+DWkXiapfjDElBLGlGe0fjVrn+6j9RW30qFyXM4 6AB6/FJyhn6XAcPmmPBvOkwgrTjn1qtCj6HhSpyKR6igSUQWQALMNe45E5LZ2/TJ dmn2bHBcv5jhXQGEq6CCUohbOEV3+hWq6HLksfQQgcw81sfxCkF2+IR1g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegkedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestd ekredtredttdenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigr nhhgsehflhihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpeefledufeehgedvue dvvdegkefgvddttedtleeiiefhgeetudegkefhvdfhjeeftdenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflh ihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail From: Jiaxun Yang To: f4bug@amsat.org Cc: qemu-devel@nongnu.org, Jiaxun Yang Subject: [PATCH 1/2] hw/mips/boston: Support initrd for ELF kernel Date: Sat, 13 Aug 2022 17:27:19 +0100 Message-Id: <20220813162720.60008-2-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220813162720.60008-1-jiaxun.yang@flygoat.com> References: <20220813162720.60008-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=66.111.4.29; envelope-from=jiaxun.yang@flygoat.com; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZM-MESSAGEID: 1660408272901100005 Content-Type: text/plain; charset="utf-8" When loading ELF kernel we can just load out initrd after DTB and append initrd information to DeviceTree's chosen node. Signed-off-by: Jiaxun Yang --- hw/mips/boston.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index d2ab9da1a0..5145179951 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -73,6 +73,8 @@ struct BostonState { =20 hwaddr kernel_entry; hwaddr fdt_base; + hwaddr initrd_base; + hwaddr initrd_end; }; =20 enum { @@ -383,6 +385,14 @@ static const void *boston_fdt_filter(void *opaque, con= st void *fdt_orig, return NULL; } =20 + if (s->initrd_base) { + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", + s->initrd_base); + + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", + s->initrd_end); + } + ram_low_sz =3D MIN(256 * MiB, machine->ram_size); ram_high_sz =3D machine->ram_size - ram_low_sz; qemu_fdt_setprop_sized_cells(fdt, "/memory@0", "reg", @@ -804,6 +814,35 @@ static void boston_mach_init(MachineState *machine) dtb_file_data =3D create_fdt(s, boston_memmap, &dt_size); } =20 + if (machine->initrd_filename) { + /* We want to leave low 128 MiB memory for kernelrelocatio= n */ + hwaddr initrd_paddr =3D MAX(128 * MiB, + QEMU_ALIGN_UP(dtb_paddr + dt_size, + 64 * KiB)); + int maxsz =3D boston_memmap[BOSTON_LOWDDR].size - initrd_p= addr; + + if (maxsz <=3D 0) { + error_report("no space left for ramdisk '%s'", + machine->initrd_filename); + exit(1); + } + + int size =3D load_ramdisk(machine->initrd_filename, + initrd_paddr, maxsz); + if (size < 0) { + size =3D load_image_targphys(machine->initrd_filename, + initrd_paddr, maxsz); + if (size < 0) { + error_report("could not load ramdisk '%s'", + machine->initrd_filename); + exit(1); + } + } + + s->initrd_base =3D initrd_paddr; + s->initrd_end =3D s->initrd_base + size; + } + dtb_load_data =3D boston_fdt_filter(s, dtb_file_data, NULL, &dtb_vaddr); =20 --=20 2.32.1 (Apple Git-133) From nobody Sat May 4 14:38:45 2024 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; dmarc=fail(p=none dis=none) header.from=flygoat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660408267884506.28921130468484; Sat, 13 Aug 2022 09:31:07 -0700 (PDT) Received: from localhost ([::1]:40272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMu2U-0002Ty-PY for importer@patchew.org; Sat, 13 Aug 2022 12:31:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMtz4-000894-Tl for qemu-devel@nongnu.org; Sat, 13 Aug 2022 12:27:34 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:41479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMtz3-0005Tc-78 for qemu-devel@nongnu.org; Sat, 13 Aug 2022 12:27:34 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B7B4B5C00DA; Sat, 13 Aug 2022 12:27:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 13 Aug 2022 12:27:31 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 13 Aug 2022 12:27:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1660408051; x=1660494451; bh=Zk jXCaOWL58K7ZMeAQFjuuRpamyHM5rJ95oAggQodcA=; b=IH0fgTpXw5ISl4F4Tw eKTZqB/lkkCjsBdiHX8ZKR+0l7ZnMuJnmBGym7EGJtgpnPHunThxdKaKwf/ltwOi 8yH0F4NVQwpIB+zsYijcgF2ni8fHI/BRiTfm8e2ddVJ8Lk3rG6kbGZPF7zVMaoBf iqYDDBeh6T/uIY6zeWZZAo4m8bEVhezlHlNPuDZfaaYiOMnuGbiRwd9EDm8lHz3y bEpbAqbiDm/Kw9GeUI0dHwTQJ1vfv0Oae4D1GHEEufvRLSQMMfe+OZl7PIDxEhEf MltiJ6g5OvYeaxi3tALl+A5SHCy7Gyx/AGF1wn9KomiksCROg1tbWmrsOSyhgskL Wflw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1660408051; x=1660494451; bh=ZkjXCaOWL58K7 ZMeAQFjuuRpamyHM5rJ95oAggQodcA=; b=BGtO/sg9AHSB7UKisE2oATYgwc1Te 4lqtizG61bJ4NR1dgzRzFLXj+VtkD7ujbTguogiPrJjuwHMuMcq70GuW5DGCbvIu VwJsdE95tMtAuj0FGB8AMp+MZlRGv6P+JDMSySbMPLL8cJQ7v8EX4nm2ygWYeriF ZDYFlJqJGfhs4ai9NzNak7lyNSPK/3qXxYQqnlkPfA8LVEskTGjhhxCcCkdotV6x aqT0WXyLkYDApiJF8ulNyW6lehbYgkpQa5l9ANzmwu0spObC0oSftF16mySFUozO c1M+kSIjb6QkYlj31jRCSfsDFPn0RHCVTbJKgbnSiTJ7TQgB+hEM9ghvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegkedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestd ekredtredttdenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigr nhhgsehflhihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpeefledufeehgedvue dvvdegkefgvddttedtleeiiefhgeetudegkefhvdfhjeeftdenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflh ihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail From: Jiaxun Yang To: f4bug@amsat.org Cc: qemu-devel@nongnu.org, Jiaxun Yang Subject: [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter Date: Sat, 13 Aug 2022 17:27:20 +0100 Message-Id: <20220813162720.60008-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220813162720.60008-1-jiaxun.yang@flygoat.com> References: <20220813162720.60008-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=66.111.4.29; envelope-from=jiaxun.yang@flygoat.com; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZM-MESSAGEID: 1660408268844100001 Content-Type: text/plain; charset="utf-8" FDT can be awfully fat after series of modifications in fdt filter. Just pack it up before add to ram. Signed-off-by: Jiaxun Yang --- hw/mips/boston.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 5145179951..a40f193f78 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -400,6 +400,7 @@ static const void *boston_fdt_filter(void *opaque, cons= t void *fdt_orig, 1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz, 1, ram_high_sz); =20 + fdt_pack(fdt); fdt =3D g_realloc(fdt, fdt_totalsize(fdt)); qemu_fdt_dumpdtb(fdt, fdt_sz); =20 --=20 2.32.1 (Apple Git-133)