From nobody Tue Nov 26 08:53:20 2024 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=1709736284; cv=none; d=zohomail.com; s=zohoarc; b=n50ODO5dyvOR4KoU0KlxB7797vY2nyrHPskoOwD1Go6PUzUEjHl6Kajd4Al1vVk10tP1uyX113BVTW+HYhwm01yOewWndNGzc8SqFwsKviMRUA19BSkstNHUHPa72IUOyA8W5Ak0jU6VEysNm/Vteahxvws8XIF2OvykX8mv1O4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736284; h=Content-Type: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=pBWw39x9Y3CEwJFUzLCHvRqlhcIeKghiDHEbNXeg0I0=; b=TSWqQ/Xb+Y1YEdKxaM1n0PDT2bGb5QInZ55Mn9WQA2c+uINqlp6jLqDxG1uuO27BsFCYsh9qljvqYeaLWvfiowGT5D4kRXipvp4yFcdpq7O26R9HrJ/q8yhjOsAK84JksGA5fsSrwlEMNEj+VIK7ZpplflOjplI18A8M7Lu6BsI= 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 1709736284441813.8134596367407; Wed, 6 Mar 2024 06:44:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS8-0007i5-M3; Wed, 06 Mar 2024 09:41:04 -0500 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 1rhsS7-0007b8-7K for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:03 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001TL-9F for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:02 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-412f988b601so3441075e9.0 for ; Wed, 06 Mar 2024 06:40:44 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id hg5-20020a05600c538500b00412eeb017f0sm4759357wmb.34.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:42 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E84945F950; Wed, 6 Mar 2024 14:40:41 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736043; x=1710340843; 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=pBWw39x9Y3CEwJFUzLCHvRqlhcIeKghiDHEbNXeg0I0=; b=PDgOq6unfyUZfc2fQwWnkzFUH87cDrIbiEO+XD+B8Enjcz+AcSaoA3Xzypf+RtriTN JXb13kSqzdJsIfp/JFrBml53sJpnJ5Y/Rg+voMpp4r5Rdf0URGxi8APWgCC2ryGMbDTt er7Pecg7St8GV/aQXXGwRqU8j0gxe+BXuclcsV4L+b9Ou6jFcf93yvHOxzMTEpgGaFEh yCNi4geCwdnMHfa+xBbUdkoFjDG5uqjeED6cgDqDff2WkMiUq8/fJXbouI/diKchGhjh hUoc1ln7pj+uCybWhzX8BpGKJ4oUorH2Ys6ZHCK+JwF4dGrLmAJV+pHRgNCm9Yv0EI3p DuIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736043; x=1710340843; 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=pBWw39x9Y3CEwJFUzLCHvRqlhcIeKghiDHEbNXeg0I0=; b=rThRo6PVbUI4yIxGk2QdmXS5iX+Numd685JPYd0kx1/7dacYHjymKRg2BPQ9oG8uaz 1qjyFPbxP5b5rP9uCrZ94yTMnL7st0SzVpLGarSxgfx2e8XX527D0+ipJzNMZHh+38iW 9xTk6dN8l8BGSBg/vAfMkpg9c7UpVLQJ591C4yzkNcCTYqCGYzlPBn/bhgkLGFc2wFOX o9Xnd7zn27n1QHQheNWNGyYAvnStceej22cx15PKNaR6WRDO/c87p/TZO6OHnhiuvHXY NSrY2sRl0onoKGreHNMzXwyZHmlG1k1sRB3K3Tlwtim5+ztJQeQXxaoKsQPOh98ZsHdW tksQ== X-Gm-Message-State: AOJu0YysHO6Kybo92rOvkopccWMgh8YkqKebZoLtms1VGvdSxsp4Zfvb 5J4dIbG9TgnXcT2MsXo5oeDS9HHY8iUhln0PoyVaPHmQa6ZVp61SBEjNgQYtq3E= X-Google-Smtp-Source: AGHT+IHefa31uMcVa9KeG8KWrVVbtvn9fp/vpOH4gQE5aZXM0jwpXUe3jLcQFnjWIngPdYQpBE0qjA== X-Received: by 2002:a05:600c:470f:b0:412:900e:84de with SMTP id v15-20020a05600c470f00b00412900e84demr11725288wmo.38.1709736043025; Wed, 06 Mar 2024 06:40:43 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , Richard Henderson , Kyle Evans , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Laurent Vivier , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Subject: [PULL 03/29] {linux,bsd}-user: Introduce get_task_state() Date: Wed, 6 Mar 2024 14:40:15 +0000 Message-Id: <20240306144041.3787188-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1709736286667100001 From: Ilya Leoshkevich A CPU's TaskState is stored in the CPUState's void *opaque field, accessing which is somewhat awkward due to having to use a cast. Introduce a wrapper and use it everywhere. Suggested-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20240219141628.246823-3-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-4-alex.bennee@linaro.org> diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 3c00dc00567..6fa2c30b4de 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -641,7 +641,7 @@ static abi_long do_bsd_readlink(CPUArchState *env, abi_= long arg1, } if (strcmp(p1, "/proc/curproc/file") =3D=3D 0) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D (TaskState *)cpu->opaque; + TaskState *ts =3D get_task_state(cpu); strncpy(p2, ts->bprm->fullpath, arg3); ret =3D MIN((abi_long)strlen(ts->bprm->fullpath), arg3); } else { diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c05c5127676..4adb75d19ff 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -117,6 +117,11 @@ typedef struct TaskState { struct target_sigaltstack sigaltstack_used; } __attribute__((aligned(16))) TaskState; =20 +static inline TaskState *get_task_state(CPUState *cs) +{ + return cs->opaque; +} + void stop_all_tasks(void); extern const char *interp_prefix; extern const char *qemu_uname_release; diff --git a/include/user/safe-syscall.h b/include/user/safe-syscall.h index 27b71cdbd8e..aa075f4d5cd 100644 --- a/include/user/safe-syscall.h +++ b/include/user/safe-syscall.h @@ -134,7 +134,7 @@ extern char safe_syscall_start[]; extern char safe_syscall_end[]; =20 #define safe_syscall(...) \ - safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ + safe_syscall_base(&get_task_state(thread_cpu)->signal_pending, \ __VA_ARGS__) =20 #endif diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h index c3f288dfe83..4b40c09a8d6 100644 --- a/linux-user/m68k/target_cpu.h +++ b/linux-user/m68k/target_cpu.h @@ -37,7 +37,7 @@ static inline void cpu_clone_regs_parent(CPUM68KState *en= v, unsigned flags) static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->tp_value =3D newtls; } diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 4de9ec783f6..32cd43d9eff 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -162,6 +162,11 @@ typedef struct TaskState { uint64_t start_boottime; } TaskState; =20 +static inline TaskState *get_task_state(CPUState *cs) +{ + return cs->opaque; +} + abi_long do_brk(abi_ulong new_brk); int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int flags, mode_t mode, bool safe); diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 3e2dc604c2f..a7df12fc445 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -113,7 +113,7 @@ int process_sigsuspend_mask(sigset_t **pset, target_ulo= ng sigset, static inline void finish_sigsuspend_mask(int ret) { if (ret !=3D -QEMU_ERESTARTSYS) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); ts->in_sigsuspend =3D 1; } } diff --git a/bsd-user/signal.c b/bsd-user/signal.c index f4352e4530f..e9f80a06d32 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -319,7 +319,7 @@ void host_to_target_siginfo(target_siginfo_t *tinfo, co= nst siginfo_t *info) =20 int block_signals(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t set; =20 /* @@ -359,7 +359,7 @@ void dump_core_and_abort(int target_sig) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu_env(cpu); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); int core_dumped =3D 0; int host_sig; struct sigaction act; @@ -421,7 +421,7 @@ void queue_signal(CPUArchState *env, int sig, int si_ty= pe, target_siginfo_t *info) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_queue_signal(env, sig); =20 @@ -476,7 +476,7 @@ void force_sig_fault(int sig, int code, abi_ulong addr) static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) { CPUState *cpu =3D thread_cpu; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); target_siginfo_t tinfo; ucontext_t *uc =3D puc; struct emulated_sigtable *k; @@ -585,7 +585,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) /* compare to kern/kern_sig.c sys_sigaltstack() and kern_sigaltstack() */ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); int ret; target_stack_t oss; =20 @@ -714,7 +714,7 @@ int do_sigaction(int sig, const struct target_sigaction= *act, static inline abi_ulong get_sigframe(struct target_sigaction *ka, CPUArchState *env, size_t frame_size) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); abi_ulong sp; =20 /* Use default user stack */ @@ -789,7 +789,7 @@ static int reset_signal_mask(target_ucontext_t *ucontex= t) int i; sigset_t blocked; target_sigset_t target_set; - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __get_user(target_set.__bits[i], &ucontext->uc_sigmask.__bits[i]); @@ -839,7 +839,7 @@ badframe: =20 void signal_init(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); struct sigaction act; struct sigaction oact; int i; @@ -878,7 +878,7 @@ static void handle_pending_signal(CPUArchState *env, in= t sig, struct emulated_sigtable *k) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct target_sigaction *sa; int code; sigset_t set; @@ -967,7 +967,7 @@ void process_pending_signals(CPUArchState *env) int sig; sigset_t *blocked_set, set; struct emulated_sigtable *k; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 while (qatomic_read(&ts->signal_pending)) { sigfillset(&set); diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index b7d4c37cd81..6646684a4c6 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -204,7 +204,7 @@ int gdb_target_signal_to_gdb(int sig) =20 int gdb_get_cpu_index(CPUState *cpu) { - TaskState *ts =3D (TaskState *) cpu->opaque; + TaskState *ts =3D get_task_state(cpu); return ts ? ts->ts_tid : -1; } =20 @@ -399,7 +399,7 @@ void gdb_handle_query_xfer_exec_file(GArray *params, vo= id *user_ctx) return; } =20 - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); if (!ts || !ts->bprm || !ts->bprm->filename) { gdb_put_packet("E00"); return; diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 8c20dc8a39a..71cdc8be50c 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -189,7 +189,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct tar= get_pt_regs *regs) { ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index b404117ff30..db1a41e27f4 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -263,7 +263,7 @@ static bool insn_is_linux_bkpt(uint32_t opcode, bool is= _thumb) =20 static bool emulate_arm_fpa11(CPUARMState *env, uint32_t opcode) { - TaskState *ts =3D env_cpu(env)->opaque; + TaskState *ts =3D get_task_state(env_cpu(env)); int rc =3D EmulateAll(opcode, &ts->fpa, env); int raise, enabled; =20 @@ -514,7 +514,7 @@ void cpu_loop(CPUARMState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index f77f692c63f..59806335f5b 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -177,7 +177,7 @@ setup_return(CPUARMState *env, struct target_sigaction = *ka, int usig, abi_ulong handler =3D 0; abi_ulong handler_fdpic_GOT =3D 0; abi_ulong retcode; - bool is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->inf= o); + bool is_fdpic =3D info_is_fdpic(get_task_state(thread_cpu)->info); bool is_rt =3D ka->sa_flags & TARGET_SA_SIGINFO; bool thumb; =20 diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c index 01e6ff16fc9..04c9086b6dc 100644 --- a/linux-user/cris/cpu_loop.c +++ b/linux-user/cris/cpu_loop.c @@ -72,7 +72,7 @@ void cpu_loop(CPUCRISState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->regs[0] =3D regs->r0; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0c299a7c15e..4dbca056461 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4404,7 +4404,7 @@ static int wmr_write_region(void *opaque, target_ulon= g start, static int elf_core_dump(int signr, const CPUArchState *env) { const CPUState *cpu =3D env_cpu((CPUArchState *)env); - const TaskState *ts =3D (const TaskState *)cpu->opaque; + const TaskState *ts =3D (const TaskState *)get_task_state((CPUState *)= cpu); struct rlimit dumpsize; CountAndSizeRegions css; off_t offset, note_offset, data_offset; diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c index d08a97dae61..c84557e906a 100644 --- a/linux-user/hppa/signal.c +++ b/linux-user/hppa/signal.c @@ -112,7 +112,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, abi_ulong frame_addr, sp, haddr; struct target_rt_sigframe *frame; int i; - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 sp =3D get_sp_from_cpustate(env); if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) { diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 4a794f8cea1..37f132be4af 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -89,7 +89,7 @@ static int prepare_binprm(struct linux_binprm *bprm) abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, abi_ulong stringp, int push_ptr) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); int n =3D sizeof(abi_ulong); abi_ulong envp; abi_ulong argv; diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index caead1cb741..f79b8e4ab05 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -95,7 +95,7 @@ void cpu_loop(CPUM68KState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->pc =3D regs->pc; diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 990b03e727b..462387a0737 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -214,7 +214,7 @@ done_syscall: void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 7e7302823b0..c232424c1e8 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -486,7 +486,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, int i, err =3D 0; #if defined(TARGET_PPC64) struct target_sigcontext *sc =3D 0; - struct image_info *image =3D ((TaskState *)thread_cpu->opaque)->info; + struct image_info *image =3D get_task_state(thread_cpu)->info; #endif =20 rt_sf_addr =3D get_sigframe(ka, env, sizeof(*rt_sf)); @@ -673,7 +673,7 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uo= ld_ctx, } =20 if (uold_ctx) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if (!lock_user_struct(VERIFY_WRITE, uctx, uold_ctx, 1)) { return -TARGET_EFAULT; diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index bffca7db127..52c49c2e426 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -97,7 +97,7 @@ void cpu_loop(CPURISCVState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->pc =3D regs->sepc; diff --git a/linux-user/signal.c b/linux-user/signal.c index d3e62ab030f..cc7dd78e41f 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -172,7 +172,7 @@ void target_to_host_old_sigset(sigset_t *sigset, =20 int block_signals(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t set; =20 /* It's OK to block everything including SIGSEGV, because we won't @@ -194,7 +194,7 @@ int block_signals(void) */ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if (oldset) { *oldset =3D ts->signal_mask; @@ -237,7 +237,7 @@ int do_sigprocmask(int how, const sigset_t *set, sigset= _t *oldset) */ void set_sigmask(const sigset_t *set) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 ts->signal_mask =3D *set; } @@ -246,7 +246,7 @@ void set_sigmask(const sigset_t *set) =20 int on_sig_stack(unsigned long sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 return (sp - ts->sigaltstack_used.ss_sp < ts->sigaltstack_used.ss_size); @@ -254,7 +254,7 @@ int on_sig_stack(unsigned long sp) =20 int sas_ss_flags(unsigned long sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 return (ts->sigaltstack_used.ss_size =3D=3D 0 ? SS_DISABLE : on_sig_stack(sp) ? SS_ONSTACK : 0); @@ -265,7 +265,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_siga= ction *ka) /* * This is the X/Open sanctioned signal stack switching. */ - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) { return ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size; @@ -275,7 +275,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_siga= ction *ka) =20 void target_save_altstack(target_stack_t *uss, CPUArchState *env) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 __put_user(ts->sigaltstack_used.ss_sp, &uss->ss_sp); __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &uss->ss_flags); @@ -284,7 +284,7 @@ void target_save_altstack(target_stack_t *uss, CPUArchS= tate *env) =20 abi_long target_restore_altstack(target_stack_t *uss, CPUArchState *env) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); size_t minstacksize =3D TARGET_MINSIGSTKSZ; target_stack_t ss; =20 @@ -571,7 +571,7 @@ static void signal_table_init(void) =20 void signal_init(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); struct sigaction act, oact; =20 /* initialize signal conversion tables */ @@ -730,7 +730,7 @@ static G_NORETURN void dump_core_and_abort(CPUArchState *env, int target_sig) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D (TaskState *)cpu->opaque; + TaskState *ts =3D get_task_state(cpu); int host_sig, core_dumped =3D 0; =20 /* On exit, undo the remapping of SIGABRT. */ @@ -769,7 +769,7 @@ void queue_signal(CPUArchState *env, int sig, int si_ty= pe, target_siginfo_t *info) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_queue_signal(env, sig); =20 @@ -954,7 +954,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu_env(cpu); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); target_siginfo_t tinfo; host_sigcontext *uc =3D puc; struct emulated_sigtable *k; @@ -1174,7 +1174,7 @@ static void handle_pending_signal(CPUArchState *cpu_e= nv, int sig, sigset_t set; target_sigset_t target_old_set; struct target_sigaction *sa; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_handle_signal(cpu_env, sig); /* dequeue signal */ @@ -1256,7 +1256,7 @@ void process_pending_signals(CPUArchState *cpu_env) { CPUState *cpu =3D env_cpu(cpu_env); int sig; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); sigset_t set; sigset_t *blocked_set; =20 @@ -1316,7 +1316,7 @@ void process_pending_signals(CPUArchState *cpu_env) int process_sigsuspend_mask(sigset_t **pset, target_ulong sigset, target_ulong sigsize) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t *host_set =3D &ts->sigsuspend_mask; target_sigset_t *target_sigset; =20 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bc8c06522f8..c233d4eb30a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6515,7 +6515,7 @@ static void *clone_func(void *arg) env =3D info->env; cpu =3D env_cpu(env); thread_cpu =3D cpu; - ts =3D (TaskState *)cpu->opaque; + ts =3D get_task_state(cpu); info->tid =3D sys_gettid(); task_settid(ts); if (info->child_tidptr) @@ -6557,7 +6557,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, flags &=3D ~(CLONE_VFORK | CLONE_VM); =20 if (flags & CLONE_VM) { - TaskState *parent_ts =3D (TaskState *)cpu->opaque; + TaskState *parent_ts =3D get_task_state(cpu); new_thread_info info; pthread_attr_t attr; =20 @@ -6680,7 +6680,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, put_user_u32(sys_gettid(), child_tidptr); if (flags & CLONE_PARENT_SETTID) put_user_u32(sys_gettid(), parent_tidptr); - ts =3D (TaskState *)cpu->opaque; + ts =3D get_task_state(cpu); if (flags & CLONE_SETTLS) cpu_set_tls (env, newtls); if (flags & CLONE_CHILD_CLEARTID) @@ -7946,7 +7946,7 @@ int host_to_target_waitstatus(int status) static int open_self_cmdline(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - struct linux_binprm *bprm =3D ((TaskState *)cpu->opaque)->bprm; + struct linux_binprm *bprm =3D get_task_state(cpu)->bprm; int i; =20 for (i =3D 0; i < bprm->argc; i++) { @@ -8146,7 +8146,7 @@ static int open_self_smaps(CPUArchState *cpu_env, int= fd) static int open_self_stat(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); g_autoptr(GString) buf =3D g_string_new(NULL); int i; =20 @@ -8187,7 +8187,7 @@ static int open_self_stat(CPUArchState *cpu_env, int = fd) static int open_self_auxv(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); abi_ulong auxv =3D ts->info->saved_auxv; abi_ulong len =3D ts->info->auxv_len; char *ptr; @@ -9012,7 +9012,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, in= t num, abi_long arg1, pthread_mutex_lock(&clone_lock); =20 if (CPU_NEXT(first_cpu)) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 if (ts->child_tidptr) { put_user_u32(0, ts->child_tidptr); @@ -9439,7 +9439,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, in= t num, abi_long arg1, #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: if (!block_signals()) { - sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + sigsuspend(&get_task_state(cpu)->signal_mask); } return -TARGET_EINTR; #endif @@ -10005,7 +10005,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, sigset_t *set; =20 #if defined(TARGET_ALPHA) - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); /* target_to_host_old_sigset will bswap back */ abi_ulong mask =3D tswapal(arg1); set =3D &ts->sigsuspend_mask; @@ -10406,7 +10406,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, case TARGET_NR_mprotect: arg1 =3D cpu_untagged_addr(cpu, arg1); { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); /* Special hack to detect libc making the stack executable. */ if ((arg3 & PROT_GROWSDOWN) && arg1 >=3D ts->info->stack_limit @@ -12537,7 +12537,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return do_set_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); ts->tp_value =3D arg1; return 0; } @@ -12551,7 +12551,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return do_get_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); return ts->tp_value; } #else @@ -12676,7 +12676,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, #if defined(TARGET_NR_set_tid_address) case TARGET_NR_set_tid_address: { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); ts->child_tidptr =3D arg1; /* do not call host set_tid_address() syscall, instead return tid(= ) */ return get_errno(sys_gettid()); diff --git a/linux-user/vm86.c b/linux-user/vm86.c index c2facf3fc2d..9f512a2242b 100644 --- a/linux-user/vm86.c +++ b/linux-user/vm86.c @@ -74,7 +74,7 @@ static inline unsigned int vm_getl(CPUX86State *env, void save_v86_state(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct target_vm86plus_struct * target_v86; =20 if (!lock_user_struct(VERIFY_WRITE, target_v86, ts->target_v86, 0)) @@ -134,7 +134,7 @@ static inline void return_to_32bit(CPUX86State *env, in= t retval) static inline int set_IF(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->v86flags |=3D VIF_MASK; if (ts->v86flags & VIP_MASK) { @@ -147,7 +147,7 @@ static inline int set_IF(CPUX86State *env) static inline void clear_IF(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->v86flags &=3D ~VIF_MASK; } @@ -165,7 +165,7 @@ static inline void clear_AC(CPUX86State *env) static inline int set_vflags_long(unsigned long eflags, CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 set_flags(ts->v86flags, eflags, ts->v86mask); set_flags(env->eflags, eflags, SAFE_MASK); @@ -179,7 +179,7 @@ static inline int set_vflags_long(unsigned long eflags,= CPUX86State *env) static inline int set_vflags_short(unsigned short flags, CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 set_flags(ts->v86flags, flags, ts->v86mask & 0xffff); set_flags(env->eflags, flags, SAFE_MASK); @@ -193,7 +193,7 @@ static inline int set_vflags_short(unsigned short flags= , CPUX86State *env) static inline unsigned int get_vflags(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); unsigned int flags; =20 flags =3D env->eflags & RETURN_MASK; @@ -210,7 +210,7 @@ static inline unsigned int get_vflags(CPUX86State *env) static void do_int(CPUX86State *env, int intno) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); uint32_t int_addr, segoffs, ssp; unsigned int sp; =20 @@ -269,7 +269,7 @@ void handle_vm86_trap(CPUX86State *env, int trapno) void handle_vm86_fault(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); uint32_t csp, ssp; unsigned int ip, sp, newflags, newip, newcs, opcode, intno; int data32, pref_done; @@ -394,7 +394,7 @@ void handle_vm86_fault(CPUX86State *env) int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct target_vm86plus_struct * target_v86; int ret; =20 diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 32dcfa52291..003208a9161 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -157,7 +157,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, { abi_ulong frame_addr; struct target_rt_sigframe *frame; - int is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->info= ); + int is_fdpic =3D info_is_fdpic(get_task_state(thread_cpu)->info); abi_ulong handler =3D 0; abi_ulong handler_fdpic_GOT =3D 0; uint32_t ra; diff --git a/plugins/api.c b/plugins/api.c index 81f43c9ce8a..e905e995bd6 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -378,7 +378,7 @@ const char *qemu_plugin_path_to_binary(void) { char *path =3D NULL; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); path =3D g_strdup(ts->bprm->filename); #endif return path; @@ -388,7 +388,7 @@ uint64_t qemu_plugin_start_code(void) { uint64_t start =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); start =3D ts->info->start_code; #endif return start; @@ -398,7 +398,7 @@ uint64_t qemu_plugin_end_code(void) { uint64_t end =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); end =3D ts->info->end_code; #endif return end; @@ -408,7 +408,7 @@ uint64_t qemu_plugin_entry_code(void) { uint64_t entry =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); entry =3D ts->info->entry; #endif return entry; diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 329ea112607..d78c6428b90 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -214,7 +214,7 @@ static target_ulong syscall_err; static inline uint32_t get_swi_errno(CPUState *cs) { #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 return ts->swi_errno; #else @@ -226,7 +226,7 @@ static void common_semi_cb(CPUState *cs, uint64_t ret, = int err) { if (err) { #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); ts->swi_errno =3D err; #else syscall_err =3D err; @@ -586,7 +586,7 @@ void do_common_semihosting(CPUState *cs) #if !defined(CONFIG_USER_ONLY) const char *cmdline; #else - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); #endif GET_ARG(0); GET_ARG(1); @@ -664,7 +664,7 @@ void do_common_semihosting(CPUState *cs) target_ulong retvals[4]; int i; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); target_ulong limit; #else LayoutInfo info =3D common_semi_find_bases(cs); --=20 2.39.2