From nobody Sat Nov 15 09:08:47 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=1754176337; cv=none; d=zohomail.com; s=zohoarc; b=Z0gzjJmOaUnb3+L+LyF01/TN5m53GA5u79T30uLfZj9T6YmYzD5nzKI6cmLS4U+e7/DoV+jTdbrrc7zwNqGyUU1fF8F57+g7V70DN+HxXAlDykiMrTyBCOUQpGZNygGOu4iu/Jp0upT+qUEOdNHb8GmIDfXjoNCCAxZLrfbD6MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754176337; 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=M5IHWXiuirOhIdHwAX/EQgapibaS75RzzatEhNgb4z0=; b=S07bbxeWDR5HGvYsWxLrcayG4stig2Rg2KrEDa3r3cOuNF1BvbAoF2i+WpkGG+M0oDmnd/eQP3o3g1026puOfHE+39uBLVAkApwjkQv1NNxRnK+GpaggQ/QFjvspmWiwinP1w0ktqktAeECemgZN3ZPTRYA34v3/YVyVg7M8PTk= 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 1754176337773535.9423322896456; Sat, 2 Aug 2025 16:12:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLJo-0005Hq-8z; Sat, 02 Aug 2025 19:07:12 -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 1uiLJk-00054l-Sn for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:07:09 -0400 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLJj-0001DO-A4 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:07:08 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-2eb5cbe41e1so2551534fac.0 for ; Sat, 02 Aug 2025 16:07:06 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-61970693b48sm1093401eaf.19.2025.08.02.16.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754176026; x=1754780826; 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=M5IHWXiuirOhIdHwAX/EQgapibaS75RzzatEhNgb4z0=; b=urt7YnaBUuLBkX1ghhGfjXPHuoWxiph9jBwZhIMy7dUQDusOQvHmNw8OV7YPSzxKBG nchit4VaGyIMC8wdqupUe6nqKgx9sOg8EPHUwYdBxVQDhQMPcaNCMKAVERtnya4+dIlm OBGgkfh/+Q4PWoTQIVVAtV2Am3vgJ9YeVZ02TkerBiAItAlhHB1628Jg6nFaH7J8X6/H naiEAnAIoQ2l5LHsxsTTid68o30omzT56BDIe7qCw6Z9KKAmnO5KSiXRZo3ndxh98b0C 4e+5bQ3egm+5mcpxCkWeXEZh6dZSAXSBqboO9mvbSrWDGTX3o8odSg+dcAorrHA2/R5U aHdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754176026; x=1754780826; 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=M5IHWXiuirOhIdHwAX/EQgapibaS75RzzatEhNgb4z0=; b=dqAWT8XSU4JihuOAhssVGZsJaO96aEEHpUCN1+WcyejSAVJ6toBCxJZckVw3iWfS5R /OJ88qXhLycBTrKkKHbRWsQVrUsWIG4CWYKiXrobJp1jBJJDNDpMrPvjz+ReE22UT3rw dW4ywYojtxpVC+SNojQm6P5eXtVqPze/0uU1E7srIHXjF4eqf/v3qxXOao4p7bL5KOIO 1bTVRBTcqGfxalDuOW6CU+xk7D083zarfb0osqyoTYJk6CjSkCxCJk6Aq8VcOBCxbpMa npvleqQE1fWncnDL807UxVhhvqgxFBdkxwXOAkKCj34S3bIi8Vb1bfy/wj8kzQtj4NPl kd5g== X-Gm-Message-State: AOJu0YyVJncy6PZGF7b8OuWgf5V9Zcoljto+10jTbWCOE75Z+iBx++b+ yAECCX3gEx4P+UdOaAZ22q0RjcegQOdoTBJ/J5s4WuSNPlLblHk7IogAPS9lqb2RNODQVAlmRJj Hjf/Bwqg= X-Gm-Gg: ASbGncvClFdIQUU+zdK7btANISNMygaaJuoUICks/yTRayh3Geb/35HlptiXjNQCgCl Yjtixd/uAHBLX4XudILeJQnUJasvg41IsUpdPTjN8Mm6tJFvW3NnwqYq9eXbCWeSitJX7EZz+G4 aeJAVBMQYFstvYwd7M6P3bHk1vkr9kUiXskPUm1B8La+ih/h/wYKuiKpiiQacBI85TcDALnWTwq P7wvLSpDuPfIf/20vnfKTjFdCSFosM5uyffedx4awz5ICnywF32PgEv5UXe2y0vCCfHiCQdtKK9 L+9WIV4DqdytF5iBdUA31qgbOOJm21SkZmVoC0VwGTvJv8hiUKnoCj76zCZB39xbP84j/B1asxD ZW9NMv1ca3kqlybjfTGhPHhMoKnCzQwem1ioOf5tFvniCicE8UZdeLBV2W7Ep4Cw= X-Google-Smtp-Source: AGHT+IEJ/DA0gszHKLCuVzO1gkrjGhLss/UI0MlHrp3gdnZ7PLQTbXyu9zIREV5u3cOKq9Y9DWPV4g== X-Received: by 2002:a05:6820:992:b0:619:950f:2413 with SMTP id 006d021491bc7-619950f26a5mr1588553eaf.2.1754176025951; Sat, 02 Aug 2025 16:07:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PATCH v2 33/95] linux-user/mips: Create init_main_thread Date: Sun, 3 Aug 2025 09:03:57 +1000 Message-ID: <20250802230459.412251-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802230459.412251-1-richard.henderson@linaro.org> References: <20250802230459.412251-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=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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: 1754176338794124100 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- 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 0feccfbe91..ac96755b06 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -581,13 +581,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