From nobody Sat Nov 15 09:10:27 2025 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=git.sr.ht Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752704568309366.4015176558336; Wed, 16 Jul 2025 15:22:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ucAW4-00087v-TO; Wed, 16 Jul 2025 18:22:20 -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 1ucA8O-00084v-ST; Wed, 16 Jul 2025 17:57:53 -0400 Received: from mail-a.sr.ht ([46.23.81.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ucA8M-0002ET-5E; Wed, 16 Jul 2025 17:57:52 -0400 Received: from git.sr.ht (unknown [46.23.81.155]) by mail-a.sr.ht (Postfix) with ESMTPSA id 51CA822663; Wed, 16 Jul 2025 21:57:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Zf4dPYfRzBQpH7+u8KHYEm6a6uMIHYYozbV511IKdSk=; c=simple/simple; d=git.sr.ht; h=From:Date:Subject:Reply-to:In-Reply-To:To:Cc; q=dns/txt; s=20240113; t=1752703065; v=1; b=XhX36YzGbMRiwBEqNxcB3NFQYDRBv4nKoRoVQzdElzAE4Mc998shCmEoxiKNYTxmvHbdsAwv Zp5uSn62rM+Zf/M2Ajp1tcKVWrIMY9GfUGQrixcy57utFhuhe0yLgxIYo7mRJpS8nChS4xOlaG3 WyPNVn7JBPNvq2+SClT80P1ugGZii6aqGe55C203GfRzU6U/rVbYobfy9fDBDFGjlNYKnReLCkC iZKzM1ReiuLgMYBRjHR4t6PiOUWTA02+ssdMBXHVvFNJr9AzapJgA9Ksv+2J0ZnUKHl/K0CpKbl mfFrMStNcTC0rpZmMqM4qSa6GQUt0HQI75ZwIPdZevLOA== From: ~wojtekka Date: Wed, 16 Jul 2025 21:24:54 +0200 Subject: [PATCH qemu 1/2] Don't reverse bFLT endianess when not needed Message-ID: <175270306503.19369.144677794735042916-1@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <175270306503.19369.144677794735042916-0@git.sr.ht> To: qemu-devel@nongnu.org Cc: Laurent Vivier , qemu-trivial@nongnu.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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=46.23.81.152; envelope-from=outgoing@sr.ht; helo=mail-a.sr.ht X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 16 Jul 2025 18:20:18 -0400 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: , Reply-To: ~wojtekka Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1752704572172116600 From: Wojtek Kaniewski bFLT format is big-endian. get_user_ual() returns host value so for little-endian target and little-endian host it's necessary to reverse words using ntohl(). For big-endian targets we end up with incorrect endianess: $ qemu-m68k-static ./test BINFMT_FLAT: reloc outside program 0x801f0000 (0 - 0x41f0/0x1e40) Aborted (core dumped) For comparison the output of `flthdr` follows: $ m68k-elf-flthdr -P ./test ./test Magic: bFLT Rev: 4 Build Date: Tue Jul 15 23:02:00 2025 Entry: 0x44 Data Start: 0x1e80 Data End: 0x205c BSS End: 0x40a0 Stack Size: 0x1000 Reloc Start: 0x205c Reloc Count: 0x17 Flags: 0x2 ( Has-PIC-GOT ) Relocs: # reloc ( address ) data 0 0x00001f80 (0x00001f80) 3c200000 ^^^^^^^^ 1 0x00001f84 (0x00001f84) 3c300000 2 0x00001f88 (0x00001f88) 3c200000 ... Signed-off-by: Wojtek Kaniewski --- linux-user/flatload.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 4beb3ed1b9..afaff4ac44 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -413,7 +413,9 @@ static int load_flat_file(struct linux_binprm * bprm, relocated first). */ if (get_user_ual(relval, reloc + i * sizeof(abi_ulong))) return -EFAULT; +#if !TARGET_BIG_ENDIAN relval =3D ntohl(relval); +#endif if (flat_set_persistent(relval, &persistent)) continue; addr =3D flat_get_relocate_addr(relval); --=20 2.45.3 From nobody Sat Nov 15 09:10:27 2025 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=git.sr.ht Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752704579339926.7947001772388; Wed, 16 Jul 2025 15:22:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ucAW6-0008An-2n; Wed, 16 Jul 2025 18:22:22 -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 1ucA8Q-00087O-4G; Wed, 16 Jul 2025 17:57:54 -0400 Received: from mail-a.sr.ht ([46.23.81.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ucA8M-0002EU-JJ; Wed, 16 Jul 2025 17:57:53 -0400 Received: from git.sr.ht (unknown [46.23.81.155]) by mail-a.sr.ht (Postfix) with ESMTPSA id 90D8F22777; Wed, 16 Jul 2025 21:57:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zzonJQxswZ84hXBpj0LR6s25Asu+hIu08m80f3+4oeY=; c=simple/simple; d=git.sr.ht; h=From:Date:Subject:Reply-to:In-Reply-To:To:Cc; q=dns/txt; s=20240113; t=1752703065; v=1; b=X0Gm50u8nLQ8nosC+CGm0uGd4gy0co4TKA34tII78ndA7O0HH8Od8w1Tb2vOiZg70eqRaTe6 hWA5VhuFP+16l2SnUWAjDWPuMFj362SeIxAVJDEOJ6hnJRx8Bb0J58zb48fn7gnMni3R0LfYkDl TGTwEp4QcLD+ml8vChoIb4S7Q0i241SdGO41V1psj51tYSvn2DEv2zur04t/WeigMfKj8dPR8nb 58lilqWQ0qo7KfHNb4IstlROSIhZRnhQwPa7RLwHm30ot+ul5JvaSQShZCV9/jo4OxAaDq1DGMm GmuiEFHiuJTjDkPNJ9/loXEKVfZuB19140EwEBoQrlhUg== From: ~wojtekka Date: Wed, 16 Jul 2025 22:03:42 +0200 Subject: [PATCH qemu 2/2] Fill out m68k PIC register Message-ID: <175270306503.19369.144677794735042916-2@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <175270306503.19369.144677794735042916-0@git.sr.ht> To: qemu-devel@nongnu.org Cc: Laurent Vivier , qemu-trivial@nongnu.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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=46.23.81.152; envelope-from=outgoing@sr.ht; helo=mail-a.sr.ht X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 16 Jul 2025 18:20:18 -0400 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: , Reply-To: ~wojtekka Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1752704581286116600 From: Wojtek Kaniewski D5 is expected to be set to data address on m68k without MMU. See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arc= h/m68k/include/asm/flat.h for reference. Signed-off-by: Wojtek Kaniewski --- linux-user/elfload.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ea214105ff..b151ebcba2 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1756,6 +1756,7 @@ static uint32_t get_elf_hwcap(void) static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) { + regs->d5 =3D infop->start_data; /* For uClinux PIC binaries. */ regs->usp =3D infop->start_stack; regs->sr =3D 0; regs->pc =3D infop->entry; --=20 2.45.3