From patchwork Sat Aug 13 16:27:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 12942797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B146DC25B0F for ; Sat, 13 Aug 2022 16:31:05 +0000 (UTC) Received: from localhost ([::1]:40348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMu2S-0002X1-HO for qemu-devel@archiver.kernel.org; Sat, 13 Aug 2022 12:31:04 -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 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 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 13 Aug 2022 12:27:30 -0400 (EDT) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 { hwaddr kernel_entry; hwaddr fdt_base; + hwaddr initrd_base; + hwaddr initrd_end; }; enum { @@ -383,6 +385,14 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig, return NULL; } + 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 = MIN(256 * MiB, machine->ram_size); ram_high_sz = 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 = create_fdt(s, boston_memmap, &dt_size); } + if (machine->initrd_filename) { + /* We want to leave low 128 MiB memory for kernelrelocation */ + hwaddr initrd_paddr = MAX(128 * MiB, + QEMU_ALIGN_UP(dtb_paddr + dt_size, + 64 * KiB)); + int maxsz = boston_memmap[BOSTON_LOWDDR].size - initrd_paddr; + + if (maxsz <= 0) { + error_report("no space left for ramdisk '%s'", + machine->initrd_filename); + exit(1); + } + + int size = load_ramdisk(machine->initrd_filename, + initrd_paddr, maxsz); + if (size < 0) { + size = 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 = initrd_paddr; + s->initrd_end = s->initrd_base + size; + } + dtb_load_data = boston_fdt_filter(s, dtb_file_data, NULL, &dtb_vaddr); From patchwork Sat Aug 13 16:27:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 12942795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20376C19F2D for ; Sat, 13 Aug 2022 16:30:51 +0000 (UTC) Received: from localhost ([::1]:40272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMu2D-0002Ty-NT for qemu-devel@archiver.kernel.org; Sat, 13 Aug 2022 12:30:49 -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 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 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 13 Aug 2022 12:27:31 -0400 (EDT) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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, const void *fdt_orig, 1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz, 1, ram_high_sz); + fdt_pack(fdt); fdt = g_realloc(fdt, fdt_totalsize(fdt)); qemu_fdt_dumpdtb(fdt, fdt_sz);