linux-user/ppc: Create init_main_thread

Merge init_thread and target_cpu_copy_regs.
There's no point going through a target_pt_regs intermediate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2025-07-28 13:09:29 -10:00
parent 7b9efb7aae
commit 88c9adef2b
2 changed files with 19 additions and 24 deletions

View file

@ -485,22 +485,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,
NEW_AUX_ENT(AT_UCACHEBSIZE, 0); \
} while (0)
static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop)
{
_regs->gpr[1] = infop->start_stack;
#if defined(TARGET_PPC64)
if (get_ppc64_abi(infop) < 2) {
uint64_t val;
get_user_u64(val, infop->entry + 8);
_regs->gpr[2] = val + infop->load_bias;
get_user_u64(val, infop->entry);
infop->entry = val + infop->load_bias;
} else {
_regs->gpr[12] = infop->entry; /* r12 set to global entry address */
}
#endif
_regs->nip = infop->entry;
}
#define HAVE_INIT_MAIN_THREAD
/* See linux kernel: arch/powerpc/include/asm/elf.h. */
#define ELF_NREG 48

View file

@ -378,21 +378,31 @@ void cpu_loop(CPUPPCState *env)
}
}
void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
void init_main_thread(CPUState *cs, struct image_info *info)
{
int i;
CPUArchState *env = cpu_env(cs);
abi_ptr entry = info->entry;
env->gpr[1] = info->start_stack;
#ifdef TARGET_PPC64
if (get_ppc64_abi(info) < 2) {
uint64_t val;
get_user_u64(val, entry + 8);
env->gpr[2] = val + info->load_bias;
get_user_u64(val, entry);
entry = val + info->load_bias;
} else {
env->gpr[12] = entry; /* r12 set to global entry address */
}
#if defined(TARGET_PPC64)
int flag = (env->insns_flags2 & PPC2_BOOKE206) ? MSR_CM : MSR_SF;
#if defined(TARGET_ABI32)
ppc_store_msr(env, env->msr & ~((target_ulong)1 << flag));
#else
ppc_store_msr(env, env->msr | (target_ulong)1 << flag);
#endif
#endif
#endif /* TARGET_PPC64 */
env->nip = regs->nip;
for(i = 0; i < 32; i++) {
env->gpr[i] = regs->gpr[i];
}
env->nip = entry;
}