mirror of
				https://gitlab.com/qemu-project/qemu.git
				synced 2025-10-30 07:57:14 +08:00 
			
		
		
		
	linux-user: Create do_init_main_thread
Provide a unified function to initialize the main thread. Keep target_pt_regs isolated to this function. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
		| @ -3619,7 +3619,10 @@ static int elf_core_dump(int signr, const CPUArchState *env) | ||||
| } | ||||
| #endif /* USE_ELF_CORE_DUMP */ | ||||
|  | ||||
| void do_init_thread(struct target_pt_regs *regs, struct image_info *infop) | ||||
| void do_init_main_thread(CPUState *cs, struct image_info *infop) | ||||
| { | ||||
|     init_thread(regs, infop); | ||||
|     target_pt_regs regs = { }; | ||||
|  | ||||
|     init_thread(®s, infop); | ||||
|     target_cpu_copy_regs(cpu_env(cs), ®s); | ||||
| } | ||||
|  | ||||
| @ -139,8 +139,7 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, | ||||
| } | ||||
|  | ||||
| int loader_exec(int fdexec, const char *filename, char **argv, char **envp, | ||||
|                 struct target_pt_regs *regs, struct image_info *infop, | ||||
|                 struct linux_binprm *bprm) | ||||
|                 struct image_info *infop, struct linux_binprm *bprm) | ||||
| { | ||||
|     int retval; | ||||
|  | ||||
| @ -175,8 +174,7 @@ int loader_exec(int fdexec, const char *filename, char **argv, char **envp, | ||||
|         return retval; | ||||
|     } | ||||
|  | ||||
|     /* Success.  Initialize important registers. */ | ||||
|     do_init_thread(regs, infop); | ||||
|     /* Success. */ | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -82,12 +82,11 @@ struct linux_binprm { | ||||
|     int (*core_dump)(int, const CPUArchState *); /* coredump routine */ | ||||
| }; | ||||
|  | ||||
| void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); | ||||
| void do_init_main_thread(CPUState *cs, struct image_info *infop); | ||||
| abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, | ||||
|                               abi_ulong stringp, int push_ptr); | ||||
| int loader_exec(int fdexec, const char *filename, char **argv, char **envp, | ||||
|              struct target_pt_regs *regs, struct image_info *infop, | ||||
|              struct linux_binprm *); | ||||
|                 struct image_info *infop, struct linux_binprm *); | ||||
|  | ||||
| uint32_t get_elf_eflags(int fd); | ||||
| int load_elf_binary(struct linux_binprm *bprm, struct image_info *info); | ||||
|  | ||||
| @ -696,7 +696,6 @@ static int parse_args(int argc, char **argv) | ||||
|  | ||||
| int main(int argc, char **argv, char **envp) | ||||
| { | ||||
|     struct target_pt_regs regs1, *regs = ®s1; | ||||
|     struct image_info info1, *info = &info1; | ||||
|     struct linux_binprm bprm; | ||||
|     TaskState *ts; | ||||
| @ -762,9 +761,6 @@ int main(int argc, char **argv, char **envp) | ||||
|     trace_init_file(); | ||||
|     qemu_plugin_load_list(&plugins, &error_fatal); | ||||
|  | ||||
|     /* Zero out regs */ | ||||
|     memset(regs, 0, sizeof(struct target_pt_regs)); | ||||
|  | ||||
|     /* Zero out image_info */ | ||||
|     memset(info, 0, sizeof(struct image_info)); | ||||
|  | ||||
| @ -988,8 +984,8 @@ int main(int argc, char **argv, char **envp) | ||||
|  | ||||
|     fd_trans_init(); | ||||
|  | ||||
|     ret = loader_exec(execfd, exec_path, target_argv, target_environ, regs, | ||||
|         info, &bprm); | ||||
|     ret = loader_exec(execfd, exec_path, target_argv, target_environ, | ||||
|                       info, &bprm); | ||||
|     if (ret != 0) { | ||||
|         printf("Error while loading %s: %s\n", exec_path, strerror(-ret)); | ||||
|         _exit(EXIT_FAILURE); | ||||
| @ -1041,7 +1037,7 @@ int main(int argc, char **argv, char **envp) | ||||
|        the real value of GUEST_BASE into account.  */ | ||||
|     tcg_prologue_init(); | ||||
|  | ||||
|     target_cpu_copy_regs(env, regs); | ||||
|     do_init_main_thread(cpu, info); | ||||
|  | ||||
|     if (gdbstub) { | ||||
|         gdbserver_start(gdbstub, &error_fatal); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Richard Henderson
					Richard Henderson