From nobody Sun Sep 28 16:30:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1756383274; cv=none; d=zohomail.com; s=zohoarc; b=Oa1T3fSqsrfJBHXfnuHh94KhAzn5frpDubvPNndI1nPme+NOfWgwaf02WsbDTMAEc4VltwYWI2J7u6vNZjxPWGlHBf/Try6RuceQo7FnlQn/efSa5c/SyDW0ysvjMUKn0J+7ci8hRaxdkamMszoYIOpVH1zwsAH/2X9b/DqgvWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756383274; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wIfXsalfKXZPBG/HfzJiE2bOo32PAgp8HxaWLSOVE5E=; b=lz+WunQ2fvHNPiY+10hX/0xLFsoakSm1Qv7eXkqIk6vB9LxfTXs08ehSaEzlvBgXjkYFywf6MnCDFtAcola9r3Dr6MVNP8IB9J+KUaobv/ieau6m17IcQuTZA7EziaaSgGU4+xEjsjlRz8TlRDhtAld2Uqw1OVIs0kCQEfcU5O8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756383274234907.2138774217026; Thu, 28 Aug 2025 05:14:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1urbTj-0004yy-AP; Thu, 28 Aug 2025 08:11:43 -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 1urbRk-0002lC-33 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 08:09:43 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1urbRg-0007HA-O1 for qemu-devel@nongnu.org; Thu, 28 Aug 2025 08:09:39 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-b4c53892a56so799222a12.2 for ; Thu, 28 Aug 2025 05:09:36 -0700 (PDT) Received: from stoup.. ([144.6.121.55]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b49cb8b4b98sm13933222a12.19.2025.08.28.05.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 05:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756382975; x=1756987775; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wIfXsalfKXZPBG/HfzJiE2bOo32PAgp8HxaWLSOVE5E=; b=l/oRPyTC1lW5/TtAp2zfak62mqSQhEibjmeN1kMPz6PP39C9CdpxZt3xY1/eoPVyKv +dipvXXIhheHmUbRrkfzojnnKkyAnHHPhKwbTu5s1BZgafZWJ/ayraitjpw/xAexNHXz r96N/JkFp7/fVquQst6Z2IgUNVFzsmJAs8XPKJuUhplAW3FEmSVo4Yav7iZwHBWQvrJK Ozr1eOTZrTxPI7p+UwcN262KJAImo99YLFlh7rzJetUyeKNRrAhdz5+1C11TuOBrdK+f 2yfDYtb6OilQt7iMZpnMiwH9klluudFPZdvA1YSudvvKfSiPYsn58Hx0QenkdIisRpwY s4Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756382975; x=1756987775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wIfXsalfKXZPBG/HfzJiE2bOo32PAgp8HxaWLSOVE5E=; b=o2oX89w1b5c/wzMQwVWXgoXW1xvQWW2NalQN5I+ZmCedJhlY/SR2RVsjPTK4kEsCr/ fg7wmHGZy84DALOfZUNu2ucau5+0I4RaH5ckd0IwJ+Qv1OZBSJrSIQhPQkWuV/9gDjxe JVWnRUZbxNah4HCt7rPcuKPv86HlJ3CdpXLfL6ELgjmVoUoKbiswA8RionvdmxgdPyFr Yt3GbB22mSooha72nz93yGytVCA1mP/KjpFNOZDQVU9RNXCrbpDuRnpWyogRMPiK0n9X G2vFsC0qUcmCuSKALATIbiAuSV/7oq0pnC8hBRS8LY+pBPYCSIJXzk88z4qksMfFR7PR 4lsg== X-Gm-Message-State: AOJu0YynjjOWbjvOX8she4z92R2I4glFcja6KFFnWO2/nOI6PJFBmTsw +fj/kfxcJhShjavwCaTaJKy80qsWmKWlVbhmXPMJjOvVtTc7CbcTdOtJWPVNvS2nqKG0N/90RX0 IBRv3tf4= X-Gm-Gg: ASbGncuNG/Fj/jLkRMBH+r5C4JBwq3AhaD4QRWcoKiy80Fl5u6e1ULYDr1zn2+5oQEn 2/iUIHeGxjqulFZeWAxXXocn1FvKAp2HgER8iir5WA5EYLVYRkYqG7HJEOE1z4U6v0EqH619WbM SvX+b3FTzqPrsgeJPQs5Jw0A0+MnaGHzx1NJE2fa1k7PXpzvqrS2cUtAuXu28yDfPp/fYXozYh/ E9H8K4Z+eplNZtNA0cOyx/brqlq72K41fjUl+TrOQGMTNGOR5Qn8UAcoqUtIfWLjGe0q5yl5WJJ 6XjhZeICKEyZoEo4JXRqNgYx+cKniolvCqmHv3AJSGdL6sD3xDaQD0S8htxiVyBPGqJUGK28r3R E4wfmt/zCR192zuZcAZvO4VExr6Injko+H2Y8 X-Google-Smtp-Source: AGHT+IGx4+CAuM4tRH2ljvJ72GUZ66Sug02pWs/psIT3FeavQ9YZJn9bBKvFdJpztgqVs+CZt3vhOw== X-Received: by 2002:a17:90b:3d88:b0:31f:11d6:cea0 with SMTP id 98e67ed59e1d1-32517d1dd5bmr28530334a91.27.1756382974837; Thu, 28 Aug 2025 05:09:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH v3 22/87] linux-user: Move elf_core_copy_regs to mips/elfload.c Date: Thu, 28 Aug 2025 22:07:31 +1000 Message-ID: <20250828120836.195358-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828120836.195358-1-richard.henderson@linaro.org> References: <20250828120836.195358-1-richard.henderson@linaro.org> 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=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1756383276439124100 Content-Type: text/plain; charset="utf-8" Move elf_core_copy_regs to elfload.c. Move HAVE_ELF_CORE_DUMP, ELF_NREGS, target_elf_gregset_t to target_elf.h. For now, duplicate the definitions of target_elf_greg_t and tswapreg. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/mips/target_elf.h | 9 +++++++ linux-user/mips64/target_elf.h | 13 ++++++++++ linux-user/elfload.c | 46 ---------------------------------- linux-user/mips/elfload.c | 46 ++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 46 deletions(-) diff --git a/linux-user/mips/target_elf.h b/linux-user/mips/target_elf.h index 08e699c085..f767767eaa 100644 --- a/linux-user/mips/target_elf.h +++ b/linux-user/mips/target_elf.h @@ -10,5 +10,14 @@ =20 #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_BASE_PLATFORM 1 +#define HAVE_ELF_CORE_DUMP 1 + +typedef abi_ulong target_elf_greg_t; + +/* See linux kernel: arch/mips/include/asm/elf.h. */ +#define ELF_NREG 45 +typedef struct target_elf_gregset_t { + target_elf_greg_t regs[ELF_NREG]; +} target_elf_gregset_t; =20 #endif diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h index 24bb7fcd3f..046a165eef 100644 --- a/linux-user/mips64/target_elf.h +++ b/linux-user/mips64/target_elf.h @@ -10,5 +10,18 @@ =20 #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_BASE_PLATFORM 1 +#define HAVE_ELF_CORE_DUMP 1 + +#ifdef TARGET_ABI_MIPSN32 +typedef abi_ullong target_elf_greg_t; +#else +typedef abi_ulong target_elf_greg_t; +#endif + +/* See linux kernel: arch/mips/include/asm/elf.h. */ +#define ELF_NREG 45 +typedef struct target_elf_gregset_t { + target_elf_greg_t regs[ELF_NREG]; +} target_elf_gregset_t; =20 #endif diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 4acd7b9ffe..5a3a5cfc39 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -403,52 +403,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t e= lf_flags) #define elf_check_abi(x) (!((x) & EF_MIPS_ABI2)) #endif =20 -/* See linux kernel: arch/mips/include/asm/elf.h. */ -#define ELF_NREG 45 -typedef struct target_elf_gregset_t { - target_elf_greg_t regs[ELF_NREG]; -} target_elf_gregset_t; - -/* See linux kernel: arch/mips/include/asm/reg.h. */ -enum { -#ifdef TARGET_MIPS64 - TARGET_EF_R0 =3D 0, -#else - TARGET_EF_R0 =3D 6, -#endif - TARGET_EF_R26 =3D TARGET_EF_R0 + 26, - TARGET_EF_R27 =3D TARGET_EF_R0 + 27, - TARGET_EF_LO =3D TARGET_EF_R0 + 32, - TARGET_EF_HI =3D TARGET_EF_R0 + 33, - TARGET_EF_CP0_EPC =3D TARGET_EF_R0 + 34, - TARGET_EF_CP0_BADVADDR =3D TARGET_EF_R0 + 35, - TARGET_EF_CP0_STATUS =3D TARGET_EF_R0 + 36, - TARGET_EF_CP0_CAUSE =3D TARGET_EF_R0 + 37 -}; - -/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ -void elf_core_copy_regs(target_elf_gregset_t *r, const CPUMIPSState *env) -{ - int i; - - for (i =3D 0; i <=3D TARGET_EF_R0; i++) { - r->regs[i] =3D 0; - } - for (i =3D 1; i < ARRAY_SIZE(env->active_tc.gpr); i++) { - r->regs[TARGET_EF_R0 + i] =3D tswapreg(env->active_tc.gpr[i]); - } - - r->regs[TARGET_EF_R26] =3D 0; - r->regs[TARGET_EF_R27] =3D 0; - r->regs[TARGET_EF_LO] =3D tswapreg(env->active_tc.LO[0]); - r->regs[TARGET_EF_HI] =3D tswapreg(env->active_tc.HI[0]); - r->regs[TARGET_EF_CP0_EPC] =3D tswapreg(env->active_tc.PC); - r->regs[TARGET_EF_CP0_BADVADDR] =3D tswapreg(env->CP0_BadVAddr); - r->regs[TARGET_EF_CP0_STATUS] =3D tswapreg(env->CP0_Status); - r->regs[TARGET_EF_CP0_CAUSE] =3D tswapreg(env->CP0_Cause); -} - -#define HAVE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 =20 #endif /* TARGET_MIPS */ diff --git a/linux-user/mips/elfload.c b/linux-user/mips/elfload.c index c353ccc1ad..6e884911af 100644 --- a/linux-user/mips/elfload.c +++ b/linux-user/mips/elfload.c @@ -4,6 +4,7 @@ #include "qemu.h" #include "loader.h" #include "elf.h" +#include "target_elf.h" =20 =20 const char *get_elf_cpu_model(uint32_t eflags) @@ -122,3 +123,48 @@ const char *get_elf_base_platform(CPUState *cs) } =20 #undef MATCH_PLATFORM_INSN + +#ifdef TARGET_ABI_MIPSN32 +#define tswapreg(ptr) tswap64(ptr) +#else +#define tswapreg(ptr) tswapal(ptr) +#endif + +/* See linux kernel: arch/mips/include/asm/reg.h. */ +enum { +#ifdef TARGET_MIPS64 + TARGET_EF_R0 =3D 0, +#else + TARGET_EF_R0 =3D 6, +#endif + TARGET_EF_R26 =3D TARGET_EF_R0 + 26, + TARGET_EF_R27 =3D TARGET_EF_R0 + 27, + TARGET_EF_LO =3D TARGET_EF_R0 + 32, + TARGET_EF_HI =3D TARGET_EF_R0 + 33, + TARGET_EF_CP0_EPC =3D TARGET_EF_R0 + 34, + TARGET_EF_CP0_BADVADDR =3D TARGET_EF_R0 + 35, + TARGET_EF_CP0_STATUS =3D TARGET_EF_R0 + 36, + TARGET_EF_CP0_CAUSE =3D TARGET_EF_R0 + 37 +}; + +/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ +void elf_core_copy_regs(target_elf_gregset_t *r, const CPUMIPSState *env) +{ + int i; + + for (i =3D 0; i <=3D TARGET_EF_R0; i++) { + r->regs[i] =3D 0; + } + for (i =3D 1; i < ARRAY_SIZE(env->active_tc.gpr); i++) { + r->regs[TARGET_EF_R0 + i] =3D tswapreg(env->active_tc.gpr[i]); + } + + r->regs[TARGET_EF_R26] =3D 0; + r->regs[TARGET_EF_R27] =3D 0; + r->regs[TARGET_EF_LO] =3D tswapreg(env->active_tc.LO[0]); + r->regs[TARGET_EF_HI] =3D tswapreg(env->active_tc.HI[0]); + r->regs[TARGET_EF_CP0_EPC] =3D tswapreg(env->active_tc.PC); + r->regs[TARGET_EF_CP0_BADVADDR] =3D tswapreg(env->CP0_BadVAddr); + r->regs[TARGET_EF_CP0_STATUS] =3D tswapreg(env->CP0_Status); + r->regs[TARGET_EF_CP0_CAUSE] =3D tswapreg(env->CP0_Cause); +} --=20 2.43.0