On Wed, 30 Jul 2025 at 01:48, Richard Henderson <richard.hender...@linaro.org> wrote: > > Initialize all 3 fields in main(), rather than in 4 different > target-specific functions. Adjust the ifdef to be function > rather than target specific. Include stack_base in the ifdef. > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > linux-user/qemu.h | 4 ++-- > linux-user/aarch64/cpu_loop.c | 8 -------- > linux-user/arm/cpu_loop.c | 37 +++++++++++++++-------------------- > linux-user/m68k/cpu_loop.c | 9 --------- > linux-user/main.c | 5 +++++ > linux-user/riscv/cpu_loop.c | 5 ----- > 6 files changed, 23 insertions(+), 45 deletions(-) > > diff --git a/linux-user/qemu.h b/linux-user/qemu.h > index 6c97ab221f..dff7767bc8 100644 > --- a/linux-user/qemu.h > +++ b/linux-user/qemu.h > @@ -122,12 +122,12 @@ struct TaskState { > #ifdef TARGET_M68K > abi_ulong tp_value; > #endif > -#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_RISCV) > +#ifdef CONFIG_SEMIHOSTING > /* Extra fields for semihosted binaries. */ > abi_ulong heap_base; > abi_ulong heap_limit; > -#endif > abi_ulong stack_base; > +#endif > int used; /* non zero if used */ > struct image_info *info; > struct linux_binprm *bprm;
> diff --git a/linux-user/main.c b/linux-user/main.c > index 68972f00a1..4def4be1c1 100644 > --- a/linux-user/main.c > +++ b/linux-user/main.c > @@ -1050,6 +1050,11 @@ int main(int argc, char **argv, char **envp) > > #ifdef CONFIG_SEMIHOSTING > qemu_semihosting_guestfd_init(); > + > + ts->stack_base = info->start_stack; > + ts->heap_base = info->brk; > + /* This will be filled in on the first SYS_HEAPINFO call. */ > + ts->heap_limit = 0; > #endif Do we need to hide the struct fields and their initialization behind an ifdef at all? We allocate our TaskState structs on the heap so we don't care too much about their size, and the init code here is trivial. Otherwise Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> thanks -- PMM