Le 26/08/2019 à 21:58, Max Filippov a écrit : > Xtensa binaries built for call0 ABI don't rotate register window on > function calls and returns. Invocation of signal handlers from the > kernel is therefore different in windowed and call0 ABIs. > There's currently no way to determine xtensa ELF binary ABI from the > binary itself. Add handler for the -xtensa-abi-call0 command line > parameter/QEMU_XTENSA_ABI_CALL0 envitonment variable to the qemu-user > and record ABI choice. Use it to initialize PS.WOE in xtensa_cpu_reset. > Check PS.WOE in setup_rt_frame to determine how a signal should be > delivered. > > Signed-off-by: Max Filippov <jcmvb...@gmail.com> > --- > Changes v2->v3: > > - revert to checking PS.WOE in the setup_rt_frame > > Changes v1->v2: > > - move handling of QEMU_XTENSA_ABI_CALL0 to linux-user/main.c > - check xtensa_abi_call0 instead of PS.WOE in the setup_rt_frame > > linux-user/main.c | 17 +++++++++++++++++ > linux-user/xtensa/signal.c | 25 +++++++++++++++++-------- > target/xtensa/cpu.c | 24 ++++++++++++++++++++---- > target/xtensa/cpu.h | 3 +++ > 4 files changed, 57 insertions(+), 12 deletions(-) > > diff --git a/linux-user/main.c b/linux-user/main.c > index 47917bbb20fc..9e50b2d2a92f 100644 > --- a/linux-user/main.c > +++ b/linux-user/main.c > @@ -393,6 +393,13 @@ static void handle_arg_trace(const char *arg) > trace_file = trace_opt_parse(arg); > } > > +#if defined(TARGET_XTENSA) > +static void handle_arg_abi_call0(const char *arg) > +{ > + xtensa_set_abi_call0(); > +} > +#endif > + > struct qemu_argument { > const char *argv; > const char *env; > @@ -446,6 +453,10 @@ static const struct qemu_argument arg_table[] = { > "", "[[enable=]<pattern>][,events=<file>][,file=<file>]"}, > {"version", "QEMU_VERSION", false, handle_arg_version, > "", "display version information and exit"}, > +#if defined(TARGET_XTENSA) > + {"xtensa-abi-call0", "QEMU_XTENSA_ABI_CALL0", false, > handle_arg_abi_call0, > + "", "assume CALL0 Xtensa ABI"}, > +#endif > {NULL, NULL, false, NULL, NULL, NULL} > }; > > @@ -710,6 +721,12 @@ int main(int argc, char **argv, char **envp) > } > } > > +#if defined(TARGET_XTENSA) > + if (getenv("QEMU_XTENSA_ABI_CALL0")) { > + xtensa_set_abi_call0(); > + }
Not needed, this is done by parse_args() that checks getenv(arginfo->env) and calls arginfo->handle_opt() (handle_arg_abi_call0()). Except that, it looks good. Reviewed-by: Laurent Vivier <laur...@vivier.eu>