From patchwork Tue Nov 30 21:17:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 12648075 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 97C52C433F5 for ; Tue, 30 Nov 2021 21:18:50 +0000 (UTC) Received: from localhost ([::1]:40894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1msAWX-0005W8-Pp for qemu-devel@archiver.kernel.org; Tue, 30 Nov 2021 16:18:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msAVN-0003q2-DQ for qemu-devel@nongnu.org; Tue, 30 Nov 2021 16:17:37 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msAVL-0003lC-FX for qemu-devel@nongnu.org; Tue, 30 Nov 2021 16:17:37 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B2DF55C00F4; Tue, 30 Nov 2021 16:17:33 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 30 Nov 2021 16:17:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= fm3; bh=fmtfmTe7flwZ7Dsu10dFozw3xNvOHB49G1+Edt1rdm8=; b=jK9QzWzI Nx6iuCSQfrhYq60P0PF9BOco9mDFqK4AIc23YIjocRTsqehLDKHph/fwAhUXUXB/ A7S7wp/6amY7Xg19HXxjWIAxA8//ZsLRXX7pEQJ6gtebviamEIzVNOkR6CzK4V3q 6q2CJpIXy4L+BwtA8LjJGn+FvI5HlZVzUUejAYAosABxFQ8IKQmVzveyyfBXlX/O lP+3xKFhxDYZjuAB4YJU2M59EUfLqf4ih74cxC3EDJDpUBOs0MtOXmgcJ6EHSr07 Qoijhr9wuxJDVqUqMYBvWiFOyLCAKXtXrKekWGYBnGdPoo9ENMddR6WMVQbCWmLM 3vZSoTvCv4AGDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=fmtfmTe7flwZ7Dsu10dFozw3xNvOH B49G1+Edt1rdm8=; b=Jwkh0f9wdWqcgaXsqKaXXik8okXnVFsz6amYdeqjhXykj oB6MFx7O33uyZvrmJm1yf7wfTFvKvgBBBy3WSO4io+5KDaq1APda3pynXRlFZ+p2 GY4BlapOmhYYYnCe45cWaISzXS1uX9yYGUwUyBttGxPUVvIUSayY+WGAoCFMCBxa pfhICg4vtLVtSHcOuprsbCw76dYsT0uEUUzb9kPyh535rYrlqKk1lAcRPzMOAmwh NOnqMFqgBWmvK8oqGFQFApMpK0xI8QStFtldouQu4D0b+07TTZ23HYN0GdosO/eB YwaO62A7dh+ouAVhWZire9C6o9oHIvdmGf1yYGzXQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddriedugddugeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhestddtredtre dttdenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpeefvdehkeeugeffhfejteduhf duudeltdegtdfgheekudelhedtudfhudfgleevveenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorg htrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Nov 2021 16:17:32 -0500 (EST) From: Jiaxun Yang To: qemu-devel@nongnu.org Subject: [PATCH 1/2] hw/mips: bootloader: Fix write_ulong Date: Tue, 30 Nov 2021 21:17:28 +0000 Message-Id: <20211130211729.7116-2-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211130211729.7116-1-jiaxun.yang@flygoat.com> References: <20211130211729.7116-1-jiaxun.yang@flygoat.com> Received-SPF: pass client-ip=66.111.4.27; envelope-from=jiaxun.yang@flygoat.com; helo=out3-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, RCVD_IN_MSPIKE_H2=-0.001, 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: , Cc: f4bug@amsat.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bl_gen_write_ulong uses sd for both 32 and 64 bit CPU, while sd is illegal on 32 bit CPUs. Replace sd with sw on 32bit CPUs. Fixes: 3ebbf86 ("hw/mips: Add a bootloader helper") Signed-off-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daudé --- Should be backported to 6.0 onwards. --- hw/mips/bootloader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c index 6ec8314490..99991f8b2b 100644 --- a/hw/mips/bootloader.c +++ b/hw/mips/bootloader.c @@ -182,7 +182,11 @@ void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val) { bl_gen_load_ulong(p, BL_REG_K0, val); bl_gen_load_ulong(p, BL_REG_K1, addr); - bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0); + if (bootcpu_supports_isa(ISA_MIPS3)) { + bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0); + } else { + bl_gen_sw(p, BL_REG_K0, BL_REG_K1, 0x0); + } } void bl_gen_write_u32(uint32_t **p, target_ulong addr, uint32_t val) From patchwork Tue Nov 30 21:17:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 12648077 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 1651EC433F5 for ; Tue, 30 Nov 2021 21:20:54 +0000 (UTC) Received: from localhost ([::1]:44808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1msAYW-0008DH-Vg for qemu-devel@archiver.kernel.org; Tue, 30 Nov 2021 16:20:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msAVN-0003pW-4k for qemu-devel@nongnu.org; Tue, 30 Nov 2021 16:17:37 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:50675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msAVL-0003lL-1X for qemu-devel@nongnu.org; Tue, 30 Nov 2021 16:17:36 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9A5995C0183; Tue, 30 Nov 2021 16:17:34 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 30 Nov 2021 16:17:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= fm3; bh=SmJPaERWdMqTuz0UPu68VtWbFnJlanPSbui6sViHGt0=; b=Ah6HfbDC JwIBs8hTHofvWv7gfflwCc5DN6V2Uda4v9QTVjk7Qr5unx4rxmJ+2V/Y1TiWVlGO grxQRaQYz5KnH6TsKi9EbulnVB5lY/E8Cwg9OWYL0i1oOLk5d0/hlbW8KhfLeEab StKeGkWvzgWHvh9t1xGsbYmQTOHS1Bg5xHxCK6plCc1Hrwfk0KwvHQVoZ8ns+X5V dxJq9Rqvus8048CwShEl5YIjnCjD5nzEkv35FqJf6ifK8hT4OuzfH9tX6yi4aFSG a4L28J7wCHQcLUgm7Ec95vRpXTjoi6/sYgiBVBCLeax0AnUOw3cYxRrGDVuGulbN IHPIhox/mwwO2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=SmJPaERWdMqTuz0UPu68VtWbFnJla nPSbui6sViHGt0=; b=cyOUmVewHVTf72aaOIw0gvCwlQ887kZdIyt9TNJkisiDa ShyGPbtI86Ye+f+KC0Jy/p4KA7OI0/iPCFdZst56kyKCiZF1UQHSY6B7gqHDLSQX kew1N5yCBX1cnmxO9/x0b0/UhIDrrPN0CbK0ExX14ABGscvnq9AMw+HvVyznotDI gVN7NNA6kMp0hlUZmYb1GAKRE+xpV0KMQNO1DTWzW0cpSU4tE6Dg8ikJWuAFX0c2 TT+8t9F0rech//0FTBjNzTUC+XppHTs8U64PqKTaP9xtAZS/W1yJDjE+YObyBgUw er0VcdzJcQxZJSexsRfO7jLA0rjnlU4pGcYjZ5IQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddriedugddugeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhestddtredtre dttdenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpeefvdehkeeugeffhfejteduhf duudeltdegtdfgheekudelhedtudfhudfgleevveenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorg htrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Nov 2021 16:17:33 -0500 (EST) From: Jiaxun Yang To: qemu-devel@nongnu.org Subject: [PATCH 2/2] hw/mips/boston: Fix load_elf error detection Date: Tue, 30 Nov 2021 21:17:29 +0000 Message-Id: <20211130211729.7116-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211130211729.7116-1-jiaxun.yang@flygoat.com> References: <20211130211729.7116-1-jiaxun.yang@flygoat.com> Received-SPF: pass client-ip=66.111.4.27; envelope-from=jiaxun.yang@flygoat.com; helo=out3-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, RCVD_IN_MSPIKE_H2=-0.001, 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: , Cc: f4bug@amsat.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" load_elf gives negative return in case of error, not zero. Fixes: 10e3f30 ("hw/mips/boston: Allow loading elf kernel and dtb") Signed-off-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daudé --- For 6.2. --- hw/mips/boston.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 0e3cca5511..296e9fa2ad 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -777,14 +777,15 @@ static void boston_mach_init(MachineState *machine) exit(1); } } else if (machine->kernel_filename) { - uint64_t kernel_entry, kernel_high, kernel_size; + uint64_t kernel_entry, kernel_high; + ssize_t kernel_size; kernel_size = load_elf(machine->kernel_filename, NULL, cpu_mips_kseg0_to_phys, NULL, &kernel_entry, NULL, &kernel_high, NULL, 0, EM_MIPS, 1, 0); - if (kernel_size) { + if (kernel_size > 0) { int dt_size; g_autofree const void *dtb_file_data, *dtb_load_data; hwaddr dtb_paddr = QEMU_ALIGN_UP(kernel_high, 64 * KiB);