diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2024-04-08 13:07:54 -1000 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2024-05-26 12:51:50 -0700 |
commit | c536f9b77ccb771fc480ec8d3c1cefac243eac73 (patch) | |
tree | 1ed01b55f1b9e8e8831c00ac63124527f48b6262 | |
parent | bae0455ce3ded1df80dee4e844194568063ad093 (diff) |
linux-user/i386: Return boolean success from restore_sigcontext
Invert the sense of the return value and use bool.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r-- | linux-user/i386/signal.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 6763b4bda8..9e6d883ea1 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -564,12 +564,12 @@ static int xrstor_sigcontext(CPUX86State *env, X86LegacyXSaveArea *fxsave, return 0; } -static int -restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) +static bool restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) { - int err = 1; abi_ulong fpstate_addr; unsigned int tmpflags; + struct target_fpstate *fpstate; + bool ok; #ifndef TARGET_X86_64 cpu_x86_load_seg(env, R_GS, tswap16(sc->gs)); @@ -617,29 +617,27 @@ restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc) // regs->orig_eax = -1; /* disable syscall checks */ fpstate_addr = tswapl(sc->fpstate); - if (fpstate_addr != 0) { - struct target_fpstate *fpstate; - if (!lock_user_struct(VERIFY_READ, fpstate, fpstate_addr, - sizeof(struct target_fpstate))) { - return err; - } + if (fpstate_addr == 0) { + return true; + } + if (!lock_user_struct(VERIFY_READ, fpstate, fpstate_addr, + sizeof(struct target_fpstate))) { + return false; + } #ifndef TARGET_X86_64 - if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { - cpu_x86_frstor(env, fpstate_addr, 1); - err = 0; - } else { - err = xrstor_sigcontext(env, &fpstate->fxstate, - fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFSET); - } -#else - err = xrstor_sigcontext(env, fpstate, fpstate_addr); -#endif - unlock_user_struct(fpstate, fpstate_addr, 0); + if (!(env->features[FEAT_1_EDX] & CPUID_FXSR)) { + cpu_x86_frstor(env, fpstate_addr, 1); + ok = true; } else { - err = 0; + ok = !xrstor_sigcontext(env, &fpstate->fxstate, + fpstate_addr + TARGET_FPSTATE_FXSAVE_OFFSET); } +#else + ok = !xrstor_sigcontext(env, fpstate, fpstate_addr); +#endif + unlock_user_struct(fpstate, fpstate_addr, 0); - return err; + return ok; } /* Note: there is no sigreturn on x86_64, there is only rt_sigreturn */ @@ -665,8 +663,9 @@ long do_sigreturn(CPUX86State *env) set_sigmask(&set); /* restore registers */ - if (restore_sigcontext(env, &frame->sc)) + if (!restore_sigcontext(env, &frame->sc)) { goto badframe; + } unlock_user_struct(frame, frame_addr, 0); return -QEMU_ESIGRETURN; @@ -690,7 +689,7 @@ long do_rt_sigreturn(CPUX86State *env) target_to_host_sigset(&set, &frame->uc.tuc_sigmask); set_sigmask(&set); - if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) { + if (!restore_sigcontext(env, &frame->uc.tuc_mcontext)) { goto badframe; } |