From nobody Mon Feb 9 07:00:14 2026 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=1753835903; cv=none; d=zohomail.com; s=zohoarc; b=iDYNAiwvQbgdSM3SLzLJn3n7WmlESktNjcgFj+Oh6apL2lVlYstv2VGtbDzVaTphkAHhD3ceN1FoPAEKq/rgITgSd1dQfx1eZ8Ka0Vpsmn3u8N6pkbhNsOfU4GRGgdCO4CDIZ/iurK1GoLpWFOk4hREjeOoH8VT+o+bRvzyjCFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753835903; h=Content-Transfer-Encoding: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:Cc; bh=vwXX72bT0hdUpN/EvIn1LJHfScPNRgxUHXGHlv+hV9I=; b=ZCd0rdp1RbvzWAiJiBkwXAZ61lWsg0lVq5UWLni7T12ko5wUBUMRvkD3VMkKiKKY9nm5nk7NbiQEQ57Wu5HRJFcPtj90AHZaD9kcBvuyJEi0CVLm3Desf05QVkj8v2/L42VNdK15rDAyQ6pNvLkTdSnV8hWyfdjklNJBpoRfjkE= 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 1753835903256720.185041870729; Tue, 29 Jul 2025 17:38:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uguV3-0000XG-V7; Tue, 29 Jul 2025 20:16:54 -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 1uguFg-000251-Pt for qemu-devel@nongnu.org; Tue, 29 Jul 2025 20:01:10 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uguFa-00046E-Ng for qemu-devel@nongnu.org; Tue, 29 Jul 2025 20:00:58 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-b3507b63c6fso6542273a12.2 for ; Tue, 29 Jul 2025 17:00:52 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-764090e178bsm9026087b3a.62.2025.07.29.17.00.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 17:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753833651; x=1754438451; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vwXX72bT0hdUpN/EvIn1LJHfScPNRgxUHXGHlv+hV9I=; b=cRrDNtXXnbv96WHrebHetvV7Yb4Qedp24tQG+PPqoq7vBUCLJCYfMTw5lUXjtSmXaK URNV1rMTQSiQtLkxAd6egH3RUBlCXGLLtt2dldR9eMpr6nYbbMjcBZYcd4xEEaSCQ4be 0J8xoEspNLwoRfk3kgPX679bmCx7ENyLcynTbIQUuYpcvoPV1udbMXUKMi28KuqZOzDb sBbylDcXF8lCY+Vg6oTl4M+4UGsPBGi7r4fzPVGz9Jolfnwkg6dTsdrWP9pdGZQoVV6L Ed5lI8QDRdYUW5RBkXhFimr5y3zSf1E7iJkrgPCHdW+LwWsiGVrayMDys24gMe5OVpPa gbWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753833651; x=1754438451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vwXX72bT0hdUpN/EvIn1LJHfScPNRgxUHXGHlv+hV9I=; b=P4rFVFEZbgUL/i7wRuCSsKrRobpL9TEvfFXCPUm/kCA1HVgkOJf46F0YcHGkmqeP8c D+od0Xx0tkO9db5hMr/6vfx8WVLdPEgmu+Th2ZuMbGXFto+sQuiyUiX4JyIKYoiCMK68 JAIqG6yN3Gij5eyR8EvynLqRY7zGcV0Y2Hw73V167XfkNtomJFJ4wvyMbZgyiE+n1KJG H4wflTi9QTLigtJUVNWhA5Dcx47w2K6Hck9LG3DYt1ol3mP0aY729SjGxki8OLkGUUGb g+ES8tEklzBIjDSp2blje3HZmVpFKjVyoKycmCridQ9ixtSrAb0/f9y0N+vSJAjPN//R h1RQ== X-Gm-Message-State: AOJu0YzUMmzGN6mHtcraiJINLJa+3mHSSCLsyGGu0XqzQgAsfG1D0I6D JPOg9OuBpmEGh2oJ17WdcfwVxUP/H/0fawMBBrWV6XoAwECwmUcCFMgb6oG4aiZfV/VArbh3Nva NoZrZ X-Gm-Gg: ASbGncvColyVFVc0h0TfqIpi783hFe4gXC+rF0alWT5bZVf55wYgr8xM4dbJZCy5N1Z QueQRxOJueBVi0pDYlk4cj+/1cZzi6Kc1qNvDKMA8TmWLtEwPk/EZG7CzGrgDfERuSPuUDcF+41 69CmaNNjMwQeldLFE97BULQGFJBmO6I3KwF2VhghQj5W/LWrRv/JdRZzm4PRDvLx0XuffdmU957 2ACm9UQISTfu5BlFukpknYukYYYmo7bCHbDgjvZ+Z5sPMrzrNKi4XkRSBFZ9GCVuaPAW0nOnnot D1Cl98Cg0PVQE0WUBObm/CXBRE6tdhinhs+RmDXjT5DMKpWncnPHHRo86HXrx9/VvBmxJc04VB6 xQjzcdTGoFfCG8vqXZBsDGGb+vAkoatakcGgxz1TEeegMDR5lGtkTAP4L2K84xPb07lIPU9Lkdv N0iCD/tqRc8Q== X-Google-Smtp-Source: AGHT+IGq8conUtnzTc7UGSClQChBXByB5QXZUy31IGY1GGXNvO1Q72BMk/gfRIIQCgDsaMgEhuJ5sQ== X-Received: by 2002:a05:6a20:94cb:b0:215:ead1:b867 with SMTP id adf61e73a8af0-23dc0d4820cmr1987438637.14.1753833650862; Tue, 29 Jul 2025 17:00:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 29/89] linux-user/mips: Create init_main_thread Date: Tue, 29 Jul 2025 13:59:02 -1000 Message-ID: <20250730000003.599084-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250730000003.599084-1-richard.henderson@linaro.org> References: <20250730000003.599084-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::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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: 1753835905219116600 Content-Type: text/plain; charset="utf-8" Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Note that init_thread had set cp0_status in target_pt_regs, but target_cpu_copy_regs did not copy to env. This turns out to be ok because mips_cpu_reset_hold initializes CP0_Status properly. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/elfload.c | 8 +------- linux-user/mips/cpu_loop.c | 16 ++++++---------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 4095f7615d..e295dda0bd 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -587,13 +587,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *r= egs, #define elf_check_abi(x) (!((x) & EF_MIPS_ABI2)) #endif =20 -static inline void init_thread(struct target_pt_regs *regs, - struct image_info *infop) -{ - regs->cp0_status =3D 2 << CP0St_KSU; - regs->cp0_epc =3D infop->entry; - regs->regs[29] =3D infop->start_stack; -} +#define HAVE_INIT_MAIN_THREAD =20 /* See linux kernel: arch/mips/include/asm/elf.h. */ #define ELF_NREG 45 diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 6405806eb0..e67b8a2e46 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -211,12 +211,9 @@ done_syscall: } } =20 -void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs) +void init_main_thread(CPUState *cs, struct image_info *info) { - CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D get_task_state(cpu); - struct image_info *info =3D ts->info; - int i; + CPUArchState *env =3D cpu_env(cs); =20 struct mode_req { bool single; @@ -245,12 +242,11 @@ void target_cpu_copy_regs(CPUArchState *env, target_p= t_regs *regs) =20 struct mode_req prog_req; struct mode_req interp_req; + target_ulong entry =3D info->entry; =20 - for(i =3D 0; i < 32; i++) { - env->active_tc.gpr[i] =3D regs->regs[i]; - } - env->active_tc.PC =3D regs->cp0_epc & ~(target_ulong)1; - if (regs->cp0_epc & 1) { + env->active_tc.gpr[29] =3D info->start_stack; + env->active_tc.PC =3D entry & ~(target_ulong)1; + if (entry & 1) { env->hflags |=3D MIPS_HFLAG_M16; } =20 --=20 2.43.0