2018-04-24 22:26:16 +03:00
|
|
|
/*
|
|
|
|
* Emulation of Linux signals
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 Fabrice Bellard
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2018-04-24 22:26:32 +03:00
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "qemu.h"
|
2021-09-08 18:44:03 +03:00
|
|
|
#include "user-internals.h"
|
2018-04-24 22:26:32 +03:00
|
|
|
#include "signal-common.h"
|
|
|
|
#include "linux-user/trace.h"
|
|
|
|
|
2021-04-26 05:53:23 +03:00
|
|
|
/* A Sparc register window */
|
|
|
|
struct target_reg_window {
|
2018-04-24 22:26:32 +03:00
|
|
|
abi_ulong locals[8];
|
|
|
|
abi_ulong ins[8];
|
2021-04-26 05:53:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* A Sparc stack frame. */
|
|
|
|
struct target_stackf {
|
|
|
|
/*
|
|
|
|
* Since qemu does not reference fp or callers_pc directly,
|
|
|
|
* it's simpler to treat fp and callers_pc as elements of ins[],
|
|
|
|
* and then bundle locals[] and ins[] into reg_window.
|
|
|
|
*/
|
|
|
|
struct target_reg_window win;
|
|
|
|
/*
|
|
|
|
* Similarly, bundle structptr and xxargs into xargs[].
|
|
|
|
* This portion of the struct is part of the function call abi,
|
|
|
|
* and belongs to the callee for spilling argument registers.
|
|
|
|
*/
|
|
|
|
abi_ulong xargs[8];
|
2018-04-24 22:26:32 +03:00
|
|
|
};
|
|
|
|
|
2021-04-26 05:53:27 +03:00
|
|
|
struct target_siginfo_fpu {
|
2021-04-26 05:53:31 +03:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
uint64_t si_double_regs[32];
|
|
|
|
uint64_t si_fsr;
|
|
|
|
uint64_t si_gsr;
|
|
|
|
uint64_t si_fprs;
|
|
|
|
#else
|
2021-04-26 05:53:27 +03:00
|
|
|
/* It is more convenient for qemu to move doubles, not singles. */
|
|
|
|
uint64_t si_double_regs[16];
|
|
|
|
uint32_t si_fsr;
|
|
|
|
uint32_t si_fpqdepth;
|
2018-04-24 22:26:32 +03:00
|
|
|
struct {
|
2021-04-26 05:53:27 +03:00
|
|
|
uint32_t insn_addr;
|
|
|
|
uint32_t insn;
|
2018-04-24 22:26:32 +03:00
|
|
|
} si_fpqueue [16];
|
2021-04-26 05:53:31 +03:00
|
|
|
#endif
|
2021-04-26 05:53:27 +03:00
|
|
|
};
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:33 +03:00
|
|
|
#ifdef TARGET_ARCH_HAS_SETUP_FRAME
|
2018-04-24 22:26:32 +03:00
|
|
|
struct target_signal_frame {
|
2021-04-26 05:53:23 +03:00
|
|
|
struct target_stackf ss;
|
2021-04-26 05:53:24 +03:00
|
|
|
struct target_pt_regs regs;
|
2021-04-26 05:53:27 +03:00
|
|
|
uint32_t si_mask;
|
|
|
|
abi_ulong fpu_save;
|
|
|
|
uint32_t insns[2] QEMU_ALIGNED(8);
|
|
|
|
abi_ulong extramask[TARGET_NSIG_WORDS - 1];
|
|
|
|
abi_ulong extra_size; /* Should be 0 */
|
2021-04-26 05:53:28 +03:00
|
|
|
abi_ulong rwin_save;
|
2018-04-24 22:26:32 +03:00
|
|
|
};
|
2021-04-26 05:53:33 +03:00
|
|
|
#endif
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:32 +03:00
|
|
|
struct target_rt_signal_frame {
|
|
|
|
struct target_stackf ss;
|
|
|
|
target_siginfo_t info;
|
|
|
|
struct target_pt_regs regs;
|
2021-04-26 05:53:33 +03:00
|
|
|
#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
|
|
|
|
abi_ulong fpu_save;
|
|
|
|
target_stack_t stack;
|
|
|
|
target_sigset_t mask;
|
|
|
|
#else
|
2021-04-26 05:53:32 +03:00
|
|
|
target_sigset_t mask;
|
|
|
|
abi_ulong fpu_save;
|
|
|
|
uint32_t insns[2];
|
|
|
|
target_stack_t stack;
|
|
|
|
abi_ulong extra_size; /* Should be 0 */
|
2021-04-26 05:53:33 +03:00
|
|
|
#endif
|
2021-04-26 05:53:32 +03:00
|
|
|
abi_ulong rwin_save;
|
|
|
|
};
|
|
|
|
|
2021-04-26 05:53:26 +03:00
|
|
|
static abi_ulong get_sigframe(struct target_sigaction *sa,
|
|
|
|
CPUSPARCState *env,
|
|
|
|
size_t framesize)
|
2018-04-24 22:26:32 +03:00
|
|
|
{
|
2018-04-11 22:23:47 +03:00
|
|
|
abi_ulong sp = get_sp_from_cpustate(env);
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2018-04-11 22:23:47 +03:00
|
|
|
/*
|
|
|
|
* If we are on the alternate signal stack and would overflow it, don't.
|
|
|
|
* Return an always-bogus address instead so we will die with SIGSEGV.
|
2021-04-26 05:53:26 +03:00
|
|
|
*/
|
2018-04-11 22:23:47 +03:00
|
|
|
if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize))) {
|
2021-04-26 05:53:26 +03:00
|
|
|
return -1;
|
2018-04-11 22:23:47 +03:00
|
|
|
}
|
2018-04-24 22:26:32 +03:00
|
|
|
|
|
|
|
/* This is the X/Open sanctioned signal stack switching. */
|
2018-04-11 22:23:47 +03:00
|
|
|
sp = target_sigsp(sp, sa) - framesize;
|
|
|
|
|
2021-04-26 05:53:26 +03:00
|
|
|
/*
|
|
|
|
* Always align the stack frame. This handles two cases. First,
|
2018-04-11 22:23:47 +03:00
|
|
|
* sigaltstack need not be mindful of platform specific stack
|
|
|
|
* alignment. Second, if we took this signal because the stack
|
|
|
|
* is not aligned properly, we'd like to take the signal cleanly
|
|
|
|
* and report that.
|
|
|
|
*/
|
|
|
|
sp &= ~15UL;
|
|
|
|
|
|
|
|
return sp;
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
|
|
|
|
2021-04-26 05:53:24 +03:00
|
|
|
static void save_pt_regs(struct target_pt_regs *regs, CPUSPARCState *env)
|
2018-04-24 22:26:32 +03:00
|
|
|
{
|
2021-04-26 05:53:24 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
|
|
|
|
__put_user(sparc64_tstate(env), ®s->tstate);
|
|
|
|
/* TODO: magic should contain PT_REG_MAGIC + %tt. */
|
|
|
|
__put_user(0, ®s->magic);
|
|
|
|
#else
|
|
|
|
__put_user(cpu_get_psr(env), ®s->psr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
__put_user(env->pc, ®s->pc);
|
|
|
|
__put_user(env->npc, ®s->npc);
|
|
|
|
__put_user(env->y, ®s->y);
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
__put_user(env->gregs[i], ®s->u_regs[i]);
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
2021-04-26 05:53:24 +03:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
__put_user(env->regwptr[WREG_O0 + i], ®s->u_regs[i + 8]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void restore_pt_regs(struct target_pt_regs *regs, CPUSPARCState *env)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
|
|
|
|
/* User can only change condition codes and %asi in %tstate. */
|
|
|
|
uint64_t tstate;
|
|
|
|
__get_user(tstate, ®s->tstate);
|
|
|
|
cpu_put_ccr(env, tstate >> 32);
|
|
|
|
env->asi = extract64(tstate, 24, 8);
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* User can only change condition codes and FPU enabling in %psr.
|
|
|
|
* But don't bother with FPU enabling, since a real kernel would
|
|
|
|
* just re-enable the FPU upon the next fpu trap.
|
|
|
|
*/
|
|
|
|
uint32_t psr;
|
|
|
|
__get_user(psr, ®s->psr);
|
2023-10-15 00:01:08 +03:00
|
|
|
cpu_put_psr_icc(env, psr);
|
2021-04-26 05:53:24 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Note that pc and npc are handled in the caller. */
|
|
|
|
|
|
|
|
__get_user(env->y, ®s->y);
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
__get_user(env->gregs[i], ®s->u_regs[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
__get_user(env->regwptr[WREG_O0 + i], ®s->u_regs[i + 8]);
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 05:53:25 +03:00
|
|
|
static void save_reg_win(struct target_reg_window *win, CPUSPARCState *env)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
__put_user(env->regwptr[i + WREG_L0], &win->locals[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
__put_user(env->regwptr[i + WREG_I0], &win->ins[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 05:53:27 +03:00
|
|
|
static void save_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-04-26 05:53:31 +03:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
for (i = 0; i < 32; ++i) {
|
|
|
|
__put_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
|
|
|
|
}
|
|
|
|
__put_user(env->fsr, &fpu->si_fsr);
|
|
|
|
__put_user(env->gsr, &fpu->si_gsr);
|
|
|
|
__put_user(env->fprs, &fpu->si_fprs);
|
|
|
|
#else
|
2021-04-26 05:53:27 +03:00
|
|
|
for (i = 0; i < 16; ++i) {
|
|
|
|
__put_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
|
|
|
|
}
|
|
|
|
__put_user(env->fsr, &fpu->si_fsr);
|
|
|
|
__put_user(0, &fpu->si_fpqdepth);
|
2021-04-26 05:53:31 +03:00
|
|
|
#endif
|
2021-04-26 05:53:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-04-26 05:53:31 +03:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
uint64_t fprs;
|
|
|
|
__get_user(fprs, &fpu->si_fprs);
|
|
|
|
|
|
|
|
/* In case the user mucks about with FPRS, restore as directed. */
|
|
|
|
if (fprs & FPRS_DL) {
|
|
|
|
for (i = 0; i < 16; ++i) {
|
|
|
|
__get_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fprs & FPRS_DU) {
|
|
|
|
for (i = 16; i < 32; ++i) {
|
|
|
|
__get_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
__get_user(env->fsr, &fpu->si_fsr);
|
|
|
|
__get_user(env->gsr, &fpu->si_gsr);
|
|
|
|
env->fprs |= fprs;
|
|
|
|
#else
|
2021-04-26 05:53:27 +03:00
|
|
|
for (i = 0; i < 16; ++i) {
|
|
|
|
__get_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
|
|
|
|
}
|
|
|
|
__get_user(env->fsr, &fpu->si_fsr);
|
2021-04-26 05:53:31 +03:00
|
|
|
#endif
|
2021-04-26 05:53:27 +03:00
|
|
|
}
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:33 +03:00
|
|
|
#ifdef TARGET_ARCH_HAS_SETUP_FRAME
|
2021-09-29 16:05:50 +03:00
|
|
|
static void install_sigtramp(uint32_t *tramp, int syscall)
|
|
|
|
{
|
|
|
|
__put_user(0x82102000u + syscall, &tramp[0]); /* mov syscall, %g1 */
|
|
|
|
__put_user(0x91d02010u, &tramp[1]); /* t 0x10 */
|
|
|
|
}
|
|
|
|
|
2018-04-24 22:26:32 +03:00
|
|
|
void setup_frame(int sig, struct target_sigaction *ka,
|
|
|
|
target_sigset_t *set, CPUSPARCState *env)
|
|
|
|
{
|
|
|
|
abi_ulong sf_addr;
|
|
|
|
struct target_signal_frame *sf;
|
2021-04-26 05:53:27 +03:00
|
|
|
size_t sf_size = sizeof(*sf) + sizeof(struct target_siginfo_fpu);
|
|
|
|
int i;
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:27 +03:00
|
|
|
sf_addr = get_sigframe(ka, env, sf_size);
|
2018-04-24 22:26:32 +03:00
|
|
|
trace_user_setup_frame(env, sf_addr);
|
|
|
|
|
2021-04-26 05:53:27 +03:00
|
|
|
sf = lock_user(VERIFY_WRITE, sf_addr, sf_size, 0);
|
2018-04-24 22:26:32 +03:00
|
|
|
if (!sf) {
|
2021-04-26 05:53:29 +03:00
|
|
|
force_sigsegv(sig);
|
|
|
|
return;
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
2021-04-26 05:53:27 +03:00
|
|
|
|
2018-04-24 22:26:32 +03:00
|
|
|
/* 2. Save the current process state */
|
2021-04-26 05:53:24 +03:00
|
|
|
save_pt_regs(&sf->regs, env);
|
2018-04-24 22:26:32 +03:00
|
|
|
__put_user(0, &sf->extra_size);
|
|
|
|
|
2021-04-26 05:53:27 +03:00
|
|
|
save_fpu((struct target_siginfo_fpu *)(sf + 1), env);
|
|
|
|
__put_user(sf_addr + sizeof(*sf), &sf->fpu_save);
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:28 +03:00
|
|
|
__put_user(0, &sf->rwin_save); /* TODO: save_rwin_state */
|
|
|
|
|
2021-04-26 05:53:24 +03:00
|
|
|
__put_user(set->sig[0], &sf->si_mask);
|
2018-04-24 22:26:32 +03:00
|
|
|
for (i = 0; i < TARGET_NSIG_WORDS - 1; i++) {
|
|
|
|
__put_user(set->sig[i + 1], &sf->extramask[i]);
|
|
|
|
}
|
|
|
|
|
2021-04-26 05:53:25 +03:00
|
|
|
save_reg_win(&sf->ss.win, env);
|
2018-04-24 22:26:32 +03:00
|
|
|
|
|
|
|
/* 3. signal handler back-trampoline and parameters */
|
2019-11-06 14:33:12 +03:00
|
|
|
env->regwptr[WREG_SP] = sf_addr;
|
2019-11-06 14:33:11 +03:00
|
|
|
env->regwptr[WREG_O0] = sig;
|
|
|
|
env->regwptr[WREG_O1] = sf_addr +
|
2021-04-26 05:53:24 +03:00
|
|
|
offsetof(struct target_signal_frame, regs);
|
2019-11-06 14:33:11 +03:00
|
|
|
env->regwptr[WREG_O2] = sf_addr +
|
2021-04-26 05:53:24 +03:00
|
|
|
offsetof(struct target_signal_frame, regs);
|
2018-04-24 22:26:32 +03:00
|
|
|
|
|
|
|
/* 4. signal handler */
|
|
|
|
env->pc = ka->_sa_handler;
|
2021-04-26 05:53:29 +03:00
|
|
|
env->npc = env->pc + 4;
|
|
|
|
|
2018-04-24 22:26:32 +03:00
|
|
|
/* 5. return to kernel instructions */
|
|
|
|
if (ka->ka_restorer) {
|
2019-11-06 14:33:11 +03:00
|
|
|
env->regwptr[WREG_O7] = ka->ka_restorer;
|
2018-04-24 22:26:32 +03:00
|
|
|
} else {
|
2021-09-29 16:05:50 +03:00
|
|
|
/* Not used, but retain for ABI compatibility. */
|
|
|
|
install_sigtramp(sf->insns, TARGET_NR_sigreturn);
|
|
|
|
env->regwptr[WREG_O7] = default_sigreturn;
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
2021-04-26 05:53:27 +03:00
|
|
|
unlock_user(sf, sf_addr, sf_size);
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
2021-04-26 05:53:33 +03:00
|
|
|
#endif /* TARGET_ARCH_HAS_SETUP_FRAME */
|
2018-04-24 22:26:32 +03:00
|
|
|
|
|
|
|
void setup_rt_frame(int sig, struct target_sigaction *ka,
|
|
|
|
target_siginfo_t *info,
|
|
|
|
target_sigset_t *set, CPUSPARCState *env)
|
|
|
|
{
|
2021-04-26 05:53:32 +03:00
|
|
|
abi_ulong sf_addr;
|
|
|
|
struct target_rt_signal_frame *sf;
|
|
|
|
size_t sf_size = sizeof(*sf) + sizeof(struct target_siginfo_fpu);
|
|
|
|
|
|
|
|
sf_addr = get_sigframe(ka, env, sf_size);
|
|
|
|
trace_user_setup_rt_frame(env, sf_addr);
|
|
|
|
|
|
|
|
sf = lock_user(VERIFY_WRITE, sf_addr, sf_size, 0);
|
|
|
|
if (!sf) {
|
|
|
|
force_sigsegv(sig);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 2. Save the current process state */
|
|
|
|
save_reg_win(&sf->ss.win, env);
|
|
|
|
save_pt_regs(&sf->regs, env);
|
|
|
|
|
|
|
|
save_fpu((struct target_siginfo_fpu *)(sf + 1), env);
|
|
|
|
__put_user(sf_addr + sizeof(*sf), &sf->fpu_save);
|
|
|
|
|
|
|
|
__put_user(0, &sf->rwin_save); /* TODO: save_rwin_state */
|
|
|
|
|
|
|
|
tswap_siginfo(&sf->info, info);
|
|
|
|
tswap_sigset(&sf->mask, set);
|
|
|
|
target_save_altstack(&sf->stack, env);
|
|
|
|
|
2021-04-26 05:53:33 +03:00
|
|
|
#ifdef TARGET_ABI32
|
2021-04-26 05:53:32 +03:00
|
|
|
__put_user(0, &sf->extra_size);
|
2021-04-26 05:53:33 +03:00
|
|
|
#endif
|
2021-04-26 05:53:32 +03:00
|
|
|
|
|
|
|
/* 3. signal handler back-trampoline and parameters */
|
2021-04-26 05:53:33 +03:00
|
|
|
env->regwptr[WREG_SP] = sf_addr - TARGET_STACK_BIAS;
|
2021-04-26 05:53:32 +03:00
|
|
|
env->regwptr[WREG_O0] = sig;
|
|
|
|
env->regwptr[WREG_O1] =
|
|
|
|
sf_addr + offsetof(struct target_rt_signal_frame, info);
|
2021-04-26 05:53:33 +03:00
|
|
|
#ifdef TARGET_ABI32
|
2021-04-26 05:53:32 +03:00
|
|
|
env->regwptr[WREG_O2] =
|
|
|
|
sf_addr + offsetof(struct target_rt_signal_frame, regs);
|
2021-04-26 05:53:33 +03:00
|
|
|
#else
|
|
|
|
env->regwptr[WREG_O2] = env->regwptr[WREG_O1];
|
|
|
|
#endif
|
2021-04-26 05:53:32 +03:00
|
|
|
|
|
|
|
/* 4. signal handler */
|
|
|
|
env->pc = ka->_sa_handler;
|
|
|
|
env->npc = env->pc + 4;
|
|
|
|
|
|
|
|
/* 5. return to kernel instructions */
|
2021-04-26 05:53:33 +03:00
|
|
|
#ifdef TARGET_ABI32
|
2021-04-26 05:53:32 +03:00
|
|
|
if (ka->ka_restorer) {
|
|
|
|
env->regwptr[WREG_O7] = ka->ka_restorer;
|
|
|
|
} else {
|
2021-09-29 16:05:50 +03:00
|
|
|
/* Not used, but retain for ABI compatibility. */
|
|
|
|
install_sigtramp(sf->insns, TARGET_NR_rt_sigreturn);
|
|
|
|
env->regwptr[WREG_O7] = default_rt_sigreturn;
|
2021-04-26 05:53:32 +03:00
|
|
|
}
|
2021-04-26 05:53:33 +03:00
|
|
|
#else
|
|
|
|
env->regwptr[WREG_O7] = ka->ka_restorer;
|
|
|
|
#endif
|
|
|
|
|
2021-04-26 05:53:32 +03:00
|
|
|
unlock_user(sf, sf_addr, sf_size);
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
long do_sigreturn(CPUSPARCState *env)
|
|
|
|
{
|
2021-04-26 05:53:33 +03:00
|
|
|
#ifdef TARGET_ARCH_HAS_SETUP_FRAME
|
2018-04-24 22:26:32 +03:00
|
|
|
abi_ulong sf_addr;
|
2021-04-26 05:53:30 +03:00
|
|
|
struct target_signal_frame *sf = NULL;
|
2021-04-26 05:53:27 +03:00
|
|
|
abi_ulong pc, npc, ptr;
|
2018-04-24 22:26:32 +03:00
|
|
|
target_sigset_t set;
|
|
|
|
sigset_t host_set;
|
2018-11-15 14:46:16 +03:00
|
|
|
int i;
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2019-11-06 14:33:12 +03:00
|
|
|
sf_addr = env->regwptr[WREG_SP];
|
2018-04-24 22:26:32 +03:00
|
|
|
trace_user_do_sigreturn(env, sf_addr);
|
|
|
|
|
|
|
|
/* 1. Make sure we are not getting garbage from the user */
|
2021-04-26 05:53:30 +03:00
|
|
|
if ((sf_addr & 15) || !lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) {
|
|
|
|
goto segv_and_exit;
|
|
|
|
}
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:30 +03:00
|
|
|
/* Make sure stack pointer is aligned. */
|
|
|
|
__get_user(ptr, &sf->regs.u_regs[14]);
|
|
|
|
if (ptr & 7) {
|
2018-04-24 22:26:32 +03:00
|
|
|
goto segv_and_exit;
|
2021-04-26 05:53:30 +03:00
|
|
|
}
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:30 +03:00
|
|
|
/* Make sure instruction pointers are aligned. */
|
|
|
|
__get_user(pc, &sf->regs.pc);
|
2021-04-26 05:53:24 +03:00
|
|
|
__get_user(npc, &sf->regs.npc);
|
2018-04-24 22:26:32 +03:00
|
|
|
if ((pc | npc) & 3) {
|
|
|
|
goto segv_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 2. Restore the state */
|
2021-04-26 05:53:24 +03:00
|
|
|
restore_pt_regs(&sf->regs, env);
|
2018-04-24 22:26:32 +03:00
|
|
|
env->pc = pc;
|
|
|
|
env->npc = npc;
|
|
|
|
|
2021-04-26 05:53:27 +03:00
|
|
|
__get_user(ptr, &sf->fpu_save);
|
|
|
|
if (ptr) {
|
|
|
|
struct target_siginfo_fpu *fpu;
|
|
|
|
if ((ptr & 3) || !lock_user_struct(VERIFY_READ, fpu, ptr, 1)) {
|
|
|
|
goto segv_and_exit;
|
|
|
|
}
|
|
|
|
restore_fpu(fpu, env);
|
|
|
|
unlock_user_struct(fpu, ptr, 0);
|
|
|
|
}
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:28 +03:00
|
|
|
__get_user(ptr, &sf->rwin_save);
|
|
|
|
if (ptr) {
|
|
|
|
goto segv_and_exit; /* TODO: restore_rwin */
|
|
|
|
}
|
|
|
|
|
2021-04-26 05:53:24 +03:00
|
|
|
__get_user(set.sig[0], &sf->si_mask);
|
|
|
|
for (i = 1; i < TARGET_NSIG_WORDS; i++) {
|
2018-04-24 22:26:32 +03:00
|
|
|
__get_user(set.sig[i], &sf->extramask[i - 1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
target_to_host_sigset_internal(&host_set, &set);
|
|
|
|
set_sigmask(&host_set);
|
|
|
|
|
|
|
|
unlock_user_struct(sf, sf_addr, 0);
|
2021-11-17 16:14:52 +03:00
|
|
|
return -QEMU_ESIGRETURN;
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2021-04-26 05:53:30 +03:00
|
|
|
segv_and_exit:
|
2018-04-24 22:26:32 +03:00
|
|
|
unlock_user_struct(sf, sf_addr, 0);
|
|
|
|
force_sig(TARGET_SIGSEGV);
|
2021-11-17 16:14:52 +03:00
|
|
|
return -QEMU_ESIGRETURN;
|
2021-04-26 05:53:33 +03:00
|
|
|
#else
|
|
|
|
return -TARGET_ENOSYS;
|
|
|
|
#endif
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
long do_rt_sigreturn(CPUSPARCState *env)
|
|
|
|
{
|
2021-04-26 05:53:32 +03:00
|
|
|
abi_ulong sf_addr, tpc, tnpc, ptr;
|
|
|
|
struct target_rt_signal_frame *sf = NULL;
|
|
|
|
sigset_t set;
|
|
|
|
|
|
|
|
sf_addr = get_sp_from_cpustate(env);
|
|
|
|
trace_user_do_rt_sigreturn(env, sf_addr);
|
|
|
|
|
|
|
|
/* 1. Make sure we are not getting garbage from the user */
|
|
|
|
if ((sf_addr & 15) || !lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) {
|
|
|
|
goto segv_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate SP alignment. */
|
|
|
|
__get_user(ptr, &sf->regs.u_regs[8 + WREG_SP]);
|
|
|
|
if ((ptr + TARGET_STACK_BIAS) & 7) {
|
|
|
|
goto segv_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate PC and NPC alignment. */
|
|
|
|
__get_user(tpc, &sf->regs.pc);
|
|
|
|
__get_user(tnpc, &sf->regs.npc);
|
|
|
|
if ((tpc | tnpc) & 3) {
|
|
|
|
goto segv_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 2. Restore the state */
|
|
|
|
restore_pt_regs(&sf->regs, env);
|
|
|
|
|
|
|
|
__get_user(ptr, &sf->fpu_save);
|
|
|
|
if (ptr) {
|
|
|
|
struct target_siginfo_fpu *fpu;
|
|
|
|
if ((ptr & 7) || !lock_user_struct(VERIFY_READ, fpu, ptr, 1)) {
|
|
|
|
goto segv_and_exit;
|
|
|
|
}
|
|
|
|
restore_fpu(fpu, env);
|
|
|
|
unlock_user_struct(fpu, ptr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
__get_user(ptr, &sf->rwin_save);
|
|
|
|
if (ptr) {
|
|
|
|
goto segv_and_exit; /* TODO: restore_rwin_state */
|
|
|
|
}
|
|
|
|
|
|
|
|
target_restore_altstack(&sf->stack, env);
|
|
|
|
target_to_host_sigset(&set, &sf->mask);
|
|
|
|
set_sigmask(&set);
|
|
|
|
|
|
|
|
env->pc = tpc;
|
|
|
|
env->npc = tnpc;
|
|
|
|
|
|
|
|
unlock_user_struct(sf, sf_addr, 0);
|
2021-11-17 16:14:52 +03:00
|
|
|
return -QEMU_ESIGRETURN;
|
2021-04-26 05:53:32 +03:00
|
|
|
|
|
|
|
segv_and_exit:
|
|
|
|
unlock_user_struct(sf, sf_addr, 0);
|
|
|
|
force_sig(TARGET_SIGSEGV);
|
2021-11-17 16:14:52 +03:00
|
|
|
return -QEMU_ESIGRETURN;
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
|
|
|
|
2023-02-16 08:45:07 +03:00
|
|
|
#ifdef TARGET_ABI32
|
|
|
|
void setup_sigtramp(abi_ulong sigtramp_page)
|
|
|
|
{
|
|
|
|
uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0);
|
|
|
|
assert(tramp != NULL);
|
|
|
|
|
|
|
|
default_sigreturn = sigtramp_page;
|
|
|
|
install_sigtramp(tramp, TARGET_NR_sigreturn);
|
|
|
|
|
|
|
|
default_rt_sigreturn = sigtramp_page + 8;
|
|
|
|
install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn);
|
|
|
|
|
|
|
|
unlock_user(tramp, sigtramp_page, 2 * 8);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
2018-04-24 22:26:32 +03:00
|
|
|
#define SPARC_MC_TSTATE 0
|
|
|
|
#define SPARC_MC_PC 1
|
|
|
|
#define SPARC_MC_NPC 2
|
|
|
|
#define SPARC_MC_Y 3
|
|
|
|
#define SPARC_MC_G1 4
|
|
|
|
#define SPARC_MC_G2 5
|
|
|
|
#define SPARC_MC_G3 6
|
|
|
|
#define SPARC_MC_G4 7
|
|
|
|
#define SPARC_MC_G5 8
|
|
|
|
#define SPARC_MC_G6 9
|
|
|
|
#define SPARC_MC_G7 10
|
|
|
|
#define SPARC_MC_O0 11
|
|
|
|
#define SPARC_MC_O1 12
|
|
|
|
#define SPARC_MC_O2 13
|
|
|
|
#define SPARC_MC_O3 14
|
|
|
|
#define SPARC_MC_O4 15
|
|
|
|
#define SPARC_MC_O5 16
|
|
|
|
#define SPARC_MC_O6 17
|
|
|
|
#define SPARC_MC_O7 18
|
|
|
|
#define SPARC_MC_NGREG 19
|
|
|
|
|
|
|
|
typedef abi_ulong target_mc_greg_t;
|
|
|
|
typedef target_mc_greg_t target_mc_gregset_t[SPARC_MC_NGREG];
|
|
|
|
|
|
|
|
struct target_mc_fq {
|
2020-11-06 00:23:12 +03:00
|
|
|
abi_ulong mcfq_addr;
|
2018-04-24 22:26:32 +03:00
|
|
|
uint32_t mcfq_insn;
|
|
|
|
};
|
|
|
|
|
2020-11-06 00:23:12 +03:00
|
|
|
/*
|
|
|
|
* Note the manual 16-alignment; the kernel gets this because it
|
|
|
|
* includes a "long double qregs[16]" in the mcpu_fregs union,
|
|
|
|
* which we can't do.
|
|
|
|
*/
|
2018-04-24 22:26:32 +03:00
|
|
|
struct target_mc_fpu {
|
|
|
|
union {
|
|
|
|
uint32_t sregs[32];
|
|
|
|
uint64_t dregs[32];
|
|
|
|
//uint128_t qregs[16];
|
|
|
|
} mcfpu_fregs;
|
|
|
|
abi_ulong mcfpu_fsr;
|
|
|
|
abi_ulong mcfpu_fprs;
|
|
|
|
abi_ulong mcfpu_gsr;
|
2020-11-06 00:23:12 +03:00
|
|
|
abi_ulong mcfpu_fq;
|
2018-04-24 22:26:32 +03:00
|
|
|
unsigned char mcfpu_qcnt;
|
|
|
|
unsigned char mcfpu_qentsz;
|
|
|
|
unsigned char mcfpu_enab;
|
2020-11-06 00:23:12 +03:00
|
|
|
} __attribute__((aligned(16)));
|
2018-04-24 22:26:32 +03:00
|
|
|
typedef struct target_mc_fpu target_mc_fpu_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
target_mc_gregset_t mc_gregs;
|
|
|
|
target_mc_greg_t mc_fp;
|
|
|
|
target_mc_greg_t mc_i7;
|
|
|
|
target_mc_fpu_t mc_fpregs;
|
|
|
|
} target_mcontext_t;
|
|
|
|
|
|
|
|
struct target_ucontext {
|
2020-11-06 00:23:12 +03:00
|
|
|
abi_ulong tuc_link;
|
2018-04-24 22:26:32 +03:00
|
|
|
abi_ulong tuc_flags;
|
|
|
|
target_sigset_t tuc_sigmask;
|
|
|
|
target_mcontext_t tuc_mcontext;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* {set, get}context() needed for 64-bit SparcLinux userland. */
|
|
|
|
void sparc64_set_context(CPUSPARCState *env)
|
|
|
|
{
|
|
|
|
abi_ulong ucp_addr;
|
|
|
|
struct target_ucontext *ucp;
|
|
|
|
target_mc_gregset_t *grp;
|
2020-11-06 18:27:35 +03:00
|
|
|
target_mc_fpu_t *fpup;
|
2023-02-16 08:45:07 +03:00
|
|
|
target_ulong pc, npc, tstate;
|
2018-04-24 22:26:32 +03:00
|
|
|
unsigned int i;
|
2020-11-06 18:27:35 +03:00
|
|
|
unsigned char fenab;
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2019-11-06 14:33:11 +03:00
|
|
|
ucp_addr = env->regwptr[WREG_O0];
|
2018-04-24 22:26:32 +03:00
|
|
|
if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1)) {
|
|
|
|
goto do_sigsegv;
|
|
|
|
}
|
|
|
|
grp = &ucp->tuc_mcontext.mc_gregs;
|
|
|
|
__get_user(pc, &((*grp)[SPARC_MC_PC]));
|
|
|
|
__get_user(npc, &((*grp)[SPARC_MC_NPC]));
|
|
|
|
if ((pc | npc) & 3) {
|
|
|
|
goto do_sigsegv;
|
|
|
|
}
|
2019-11-06 14:33:11 +03:00
|
|
|
if (env->regwptr[WREG_O1]) {
|
2018-04-24 22:26:32 +03:00
|
|
|
target_sigset_t target_set;
|
|
|
|
sigset_t set;
|
|
|
|
|
|
|
|
if (TARGET_NSIG_WORDS == 1) {
|
|
|
|
__get_user(target_set.sig[0], &ucp->tuc_sigmask.sig[0]);
|
|
|
|
} else {
|
|
|
|
abi_ulong *src, *dst;
|
|
|
|
src = ucp->tuc_sigmask.sig;
|
|
|
|
dst = target_set.sig;
|
|
|
|
for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) {
|
|
|
|
__get_user(*dst, src);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
target_to_host_sigset_internal(&set, &target_set);
|
|
|
|
set_sigmask(&set);
|
|
|
|
}
|
|
|
|
env->pc = pc;
|
|
|
|
env->npc = npc;
|
|
|
|
__get_user(env->y, &((*grp)[SPARC_MC_Y]));
|
|
|
|
__get_user(tstate, &((*grp)[SPARC_MC_TSTATE]));
|
2020-11-06 18:27:38 +03:00
|
|
|
/* Honour TSTATE_ASI, TSTATE_ICC and TSTATE_XCC only */
|
2018-04-24 22:26:32 +03:00
|
|
|
env->asi = (tstate >> 24) & 0xff;
|
2020-11-06 18:27:38 +03:00
|
|
|
cpu_put_ccr(env, (tstate >> 32) & 0xff);
|
2018-04-24 22:26:32 +03:00
|
|
|
__get_user(env->gregs[1], (&(*grp)[SPARC_MC_G1]));
|
|
|
|
__get_user(env->gregs[2], (&(*grp)[SPARC_MC_G2]));
|
|
|
|
__get_user(env->gregs[3], (&(*grp)[SPARC_MC_G3]));
|
|
|
|
__get_user(env->gregs[4], (&(*grp)[SPARC_MC_G4]));
|
|
|
|
__get_user(env->gregs[5], (&(*grp)[SPARC_MC_G5]));
|
|
|
|
__get_user(env->gregs[6], (&(*grp)[SPARC_MC_G6]));
|
2020-11-06 18:27:37 +03:00
|
|
|
/* Skip g7 as that's the thread register in userspace */
|
2020-11-06 00:23:13 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that unlike the kernel, we didn't need to mess with the
|
|
|
|
* guest register window state to save it into a pt_regs to run
|
|
|
|
* the kernel. So for us the guest's O regs are still in WREG_O*
|
|
|
|
* (unlike the kernel which has put them in UREG_I* in a pt_regs)
|
|
|
|
* and the fp and i7 are still in WREG_I6 and WREG_I7 and don't
|
|
|
|
* need to be written back to userspace memory.
|
|
|
|
*/
|
2019-11-06 14:33:11 +03:00
|
|
|
__get_user(env->regwptr[WREG_O0], (&(*grp)[SPARC_MC_O0]));
|
|
|
|
__get_user(env->regwptr[WREG_O1], (&(*grp)[SPARC_MC_O1]));
|
|
|
|
__get_user(env->regwptr[WREG_O2], (&(*grp)[SPARC_MC_O2]));
|
|
|
|
__get_user(env->regwptr[WREG_O3], (&(*grp)[SPARC_MC_O3]));
|
|
|
|
__get_user(env->regwptr[WREG_O4], (&(*grp)[SPARC_MC_O4]));
|
|
|
|
__get_user(env->regwptr[WREG_O5], (&(*grp)[SPARC_MC_O5]));
|
|
|
|
__get_user(env->regwptr[WREG_O6], (&(*grp)[SPARC_MC_O6]));
|
|
|
|
__get_user(env->regwptr[WREG_O7], (&(*grp)[SPARC_MC_O7]));
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2020-11-06 00:23:13 +03:00
|
|
|
__get_user(env->regwptr[WREG_FP], &(ucp->tuc_mcontext.mc_fp));
|
|
|
|
__get_user(env->regwptr[WREG_I7], &(ucp->tuc_mcontext.mc_i7));
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2020-11-06 18:27:35 +03:00
|
|
|
fpup = &ucp->tuc_mcontext.mc_fpregs;
|
|
|
|
|
|
|
|
__get_user(fenab, &(fpup->mcfpu_enab));
|
|
|
|
if (fenab) {
|
|
|
|
abi_ulong fprs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We use the FPRS from the guest only in deciding whether
|
|
|
|
* to restore the upper, lower, or both banks of the FPU regs.
|
|
|
|
* The kernel here writes the FPU register data into the
|
|
|
|
* process's current_thread_info state and unconditionally
|
|
|
|
* clears FPRS and TSTATE_PEF: this disables the FPU so that the
|
|
|
|
* next FPU-disabled trap will copy the data out of
|
|
|
|
* current_thread_info and into the real FPU registers.
|
|
|
|
* QEMU doesn't need to handle lazy-FPU-state-restoring like that,
|
|
|
|
* so we always load the data directly into the FPU registers
|
|
|
|
* and leave FPRS and TSTATE_PEF alone (so the FPU stays enabled).
|
|
|
|
* Note that because we (and the kernel) always write zeroes for
|
|
|
|
* the fenab and fprs in sparc64_get_context() none of this code
|
|
|
|
* will execute unless the guest manually constructed or changed
|
|
|
|
* the context structure.
|
|
|
|
*/
|
|
|
|
__get_user(fprs, &(fpup->mcfpu_fprs));
|
|
|
|
if (fprs & FPRS_DL) {
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
__get_user(env->fpr[i].ll, &(fpup->mcfpu_fregs.dregs[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fprs & FPRS_DU) {
|
|
|
|
for (i = 16; i < 32; i++) {
|
|
|
|
__get_user(env->fpr[i].ll, &(fpup->mcfpu_fregs.dregs[i]));
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
|
|
|
}
|
2020-11-06 18:27:35 +03:00
|
|
|
__get_user(env->fsr, &(fpup->mcfpu_fsr));
|
|
|
|
__get_user(env->gsr, &(fpup->mcfpu_gsr));
|
2018-04-24 22:26:32 +03:00
|
|
|
}
|
|
|
|
unlock_user_struct(ucp, ucp_addr, 0);
|
|
|
|
return;
|
|
|
|
do_sigsegv:
|
|
|
|
unlock_user_struct(ucp, ucp_addr, 0);
|
|
|
|
force_sig(TARGET_SIGSEGV);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sparc64_get_context(CPUSPARCState *env)
|
|
|
|
{
|
|
|
|
abi_ulong ucp_addr;
|
|
|
|
struct target_ucontext *ucp;
|
|
|
|
target_mc_gregset_t *grp;
|
|
|
|
target_mcontext_t *mcp;
|
|
|
|
int err;
|
|
|
|
unsigned int i;
|
|
|
|
target_sigset_t target_set;
|
|
|
|
sigset_t set;
|
|
|
|
|
2019-11-06 14:33:11 +03:00
|
|
|
ucp_addr = env->regwptr[WREG_O0];
|
2018-04-24 22:26:32 +03:00
|
|
|
if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0)) {
|
|
|
|
goto do_sigsegv;
|
|
|
|
}
|
2020-11-06 18:27:35 +03:00
|
|
|
|
|
|
|
memset(ucp, 0, sizeof(*ucp));
|
|
|
|
|
2018-04-24 22:26:32 +03:00
|
|
|
mcp = &ucp->tuc_mcontext;
|
|
|
|
grp = &mcp->mc_gregs;
|
|
|
|
|
|
|
|
/* Skip over the trap instruction, first. */
|
|
|
|
env->pc = env->npc;
|
|
|
|
env->npc += 4;
|
|
|
|
|
|
|
|
/* If we're only reading the signal mask then do_sigprocmask()
|
|
|
|
* is guaranteed not to fail, which is important because we don't
|
|
|
|
* have any way to signal a failure or restart this operation since
|
|
|
|
* this is not a normal syscall.
|
|
|
|
*/
|
|
|
|
err = do_sigprocmask(0, NULL, &set);
|
|
|
|
assert(err == 0);
|
|
|
|
host_to_target_sigset_internal(&target_set, &set);
|
|
|
|
if (TARGET_NSIG_WORDS == 1) {
|
|
|
|
__put_user(target_set.sig[0],
|
|
|
|
(abi_ulong *)&ucp->tuc_sigmask);
|
|
|
|
} else {
|
|
|
|
abi_ulong *src, *dst;
|
|
|
|
src = target_set.sig;
|
|
|
|
dst = ucp->tuc_sigmask.sig;
|
|
|
|
for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) {
|
|
|
|
__put_user(*src, dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-06 18:27:38 +03:00
|
|
|
__put_user(sparc64_tstate(env), &((*grp)[SPARC_MC_TSTATE]));
|
2018-04-24 22:26:32 +03:00
|
|
|
__put_user(env->pc, &((*grp)[SPARC_MC_PC]));
|
|
|
|
__put_user(env->npc, &((*grp)[SPARC_MC_NPC]));
|
|
|
|
__put_user(env->y, &((*grp)[SPARC_MC_Y]));
|
|
|
|
__put_user(env->gregs[1], &((*grp)[SPARC_MC_G1]));
|
|
|
|
__put_user(env->gregs[2], &((*grp)[SPARC_MC_G2]));
|
|
|
|
__put_user(env->gregs[3], &((*grp)[SPARC_MC_G3]));
|
|
|
|
__put_user(env->gregs[4], &((*grp)[SPARC_MC_G4]));
|
|
|
|
__put_user(env->gregs[5], &((*grp)[SPARC_MC_G5]));
|
|
|
|
__put_user(env->gregs[6], &((*grp)[SPARC_MC_G6]));
|
|
|
|
__put_user(env->gregs[7], &((*grp)[SPARC_MC_G7]));
|
2020-11-06 00:23:13 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that unlike the kernel, we didn't need to mess with the
|
|
|
|
* guest register window state to save it into a pt_regs to run
|
|
|
|
* the kernel. So for us the guest's O regs are still in WREG_O*
|
|
|
|
* (unlike the kernel which has put them in UREG_I* in a pt_regs)
|
|
|
|
* and the fp and i7 are still in WREG_I6 and WREG_I7 and don't
|
|
|
|
* need to be fished out of userspace memory.
|
|
|
|
*/
|
2019-11-06 14:33:11 +03:00
|
|
|
__put_user(env->regwptr[WREG_O0], &((*grp)[SPARC_MC_O0]));
|
|
|
|
__put_user(env->regwptr[WREG_O1], &((*grp)[SPARC_MC_O1]));
|
|
|
|
__put_user(env->regwptr[WREG_O2], &((*grp)[SPARC_MC_O2]));
|
|
|
|
__put_user(env->regwptr[WREG_O3], &((*grp)[SPARC_MC_O3]));
|
|
|
|
__put_user(env->regwptr[WREG_O4], &((*grp)[SPARC_MC_O4]));
|
|
|
|
__put_user(env->regwptr[WREG_O5], &((*grp)[SPARC_MC_O5]));
|
|
|
|
__put_user(env->regwptr[WREG_O6], &((*grp)[SPARC_MC_O6]));
|
|
|
|
__put_user(env->regwptr[WREG_O7], &((*grp)[SPARC_MC_O7]));
|
|
|
|
|
2020-11-06 00:23:13 +03:00
|
|
|
__put_user(env->regwptr[WREG_FP], &(mcp->mc_fp));
|
|
|
|
__put_user(env->regwptr[WREG_I7], &(mcp->mc_i7));
|
2018-04-24 22:26:32 +03:00
|
|
|
|
2020-11-06 18:27:35 +03:00
|
|
|
/*
|
|
|
|
* We don't write out the FPU state. This matches the kernel's
|
|
|
|
* implementation (which has the code for doing this but
|
|
|
|
* hidden behind an "if (fenab)" where fenab is always 0).
|
|
|
|
*/
|
2018-04-24 22:26:32 +03:00
|
|
|
|
|
|
|
unlock_user_struct(ucp, ucp_addr, 1);
|
|
|
|
return;
|
|
|
|
do_sigsegv:
|
|
|
|
unlock_user_struct(ucp, ucp_addr, 1);
|
|
|
|
force_sig(TARGET_SIGSEGV);
|
|
|
|
}
|
2023-02-16 08:45:07 +03:00
|
|
|
#endif /* TARGET_SPARC64 */
|