From nobody Wed Nov 5 04:46:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532456508799412.7760058523048; Tue, 24 Jul 2018 11:21:48 -0700 (PDT) Received: from localhost ([::1]:41972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fi1wR-0003Td-Nk for importer@patchew.org; Tue, 24 Jul 2018 14:21:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fi1iH-0000n9-LB for qemu-devel@nongnu.org; Tue, 24 Jul 2018 14:07:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fi1iC-0008BV-NI for qemu-devel@nongnu.org; Tue, 24 Jul 2018 14:07:09 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:58062 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fi1iC-00089c-Bc for qemu-devel@nongnu.org; Tue, 24 Jul 2018 14:07:04 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 1AD381A4599; Tue, 24 Jul 2018 20:07:03 +0200 (CEST) Received: from rtrkw774-lin.mipstec.com (unknown [82.117.201.26]) by mail.rt-rk.com (Postfix) with ESMTPSA id E88131A4165; Tue, 24 Jul 2018 20:07:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Tue, 24 Jul 2018 19:32:04 +0200 Message-Id: <1532453527-22911-53-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532453527-22911-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1532453527-22911-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v4 52/55] linux-user: Add signal.c for nanoMIPS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pburton@wavecomp.com, smarkovic@wavecomp.com, riku.voipio@iki.fi, richard.henderson@linaro.org, laurent@vivier.eu, philippe.mathieu.daude@gmail.com, amarkovic@wavecomp.com, pjovanovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dimitrije Nikolic Add signal.c as a dredirection of regular mips' signal.c, but also amend regular mips' signal.c. this is done to avoid the duplication of large pieces of code. Signed-off-by: Aleksandar Rikalo Signed-off-by: Aleksandar Markovic Signed-off-by: Stefan Markovic --- linux-user/mips/signal.c | 36 +++++++++++++++++++++++++++++++----- linux-user/nanomips/signal.c | 1 + 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 linux-user/nanomips/signal.c diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index 6aa303e..3d7bcbc 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -21,7 +21,15 @@ #include "signal-common.h" #include "linux-user/trace.h" =20 -# if defined(TARGET_ABI_MIPSO32) +#if defined(TARGET_ABI_MIPSP32) +struct target_sigcontext { + uint64_t sc_regs[32]; + uint64_t sc_pc; + uint32_t sc_used_math; + uint32_t sc_reserved; +}; +#define TARGET_ALMASK (~15) +#elif defined(TARGET_ABI_MIPSO32) struct target_sigcontext { uint32_t sc_regmask; /* Unused */ uint32_t sc_status; @@ -43,6 +51,7 @@ struct target_sigcontext { target_ulong sc_hi3; target_ulong sc_lo3; }; +#define TARGET_ALMASK (~7) # else /* N32 || N64 */ struct target_sigcontext { uint64_t sc_regs[32]; @@ -61,6 +70,7 @@ struct target_sigcontext { uint32_t sc_dsp; uint32_t sc_reserved; }; +#define TARGET_ALMASK (~15) # endif /* O32 */ =20 struct sigframe { @@ -91,6 +101,17 @@ static inline int install_sigtramp(unsigned int *tramp,= unsigned int syscall) { int err =3D 0; =20 +#if defined(TARGET_ABI_MIPSP32) + uint16_t *tramp16 =3D (uint16_t *)tramp; + /* + * li $2, __NR__foo_sigreturn + * syscall 0 + */ + __put_user(0x6040 , tramp16 + 0); + __put_user(syscall, tramp16 + 1); + __put_user(0 , tramp16 + 2); + __put_user(0x1008 , tramp16 + 3); +#else /* * Set up the return code ... * @@ -100,6 +121,7 @@ static inline int install_sigtramp(unsigned int *tramp,= unsigned int syscall) =20 __put_user(0x24020000 + syscall, tramp + 0); __put_user(0x0000000c , tramp + 1); +#endif return err; } =20 @@ -116,6 +138,7 @@ static inline void setup_sigcontext(CPUMIPSState *regs, __put_user(regs->active_tc.gpr[i], &sc->sc_regs[i]); } =20 +#if !defined(TARGET_ABI_MIPSP32) __put_user(regs->active_tc.HI[0], &sc->sc_mdhi); __put_user(regs->active_tc.LO[0], &sc->sc_mdlo); =20 @@ -137,6 +160,7 @@ static inline void setup_sigcontext(CPUMIPSState *regs, for (i =3D 0; i < 32; ++i) { __put_user(regs->active_fpu.fpr[i].d, &sc->sc_fpregs[i]); } +#endif } =20 static inline void @@ -146,13 +170,14 @@ restore_sigcontext(CPUMIPSState *regs, struct target_= sigcontext *sc) =20 __get_user(regs->CP0_EPC, &sc->sc_pc); =20 - __get_user(regs->active_tc.HI[0], &sc->sc_mdhi); - __get_user(regs->active_tc.LO[0], &sc->sc_mdlo); - for (i =3D 1; i < 32; ++i) { __get_user(regs->active_tc.gpr[i], &sc->sc_regs[i]); } =20 +#if !defined(TARGET_ABI_MIPSP32) + __get_user(regs->active_tc.HI[0], &sc->sc_mdhi); + __get_user(regs->active_tc.LO[0], &sc->sc_mdlo); + __get_user(regs->active_tc.HI[1], &sc->sc_hi1); __get_user(regs->active_tc.HI[2], &sc->sc_hi2); __get_user(regs->active_tc.HI[3], &sc->sc_hi3); @@ -168,6 +193,7 @@ restore_sigcontext(CPUMIPSState *regs, struct target_si= gcontext *sc) for (i =3D 0; i < 32; ++i) { __get_user(regs->active_fpu.fpr[i].d, &sc->sc_fpregs[i]); } +#endif } =20 /* @@ -185,7 +211,7 @@ get_sigframe(struct target_sigaction *ka, CPUMIPSState = *regs, size_t frame_size) */ sp =3D target_sigsp(get_sp_from_cpustate(regs) - 32, ka); =20 - return (sp - frame_size) & ~7; + return (sp - frame_size) & TARGET_ALMASK; } =20 static void mips_set_hflags_isa_mode_from_pc(CPUMIPSState *env) diff --git a/linux-user/nanomips/signal.c b/linux-user/nanomips/signal.c new file mode 100644 index 0000000..86efc21 --- /dev/null +++ b/linux-user/nanomips/signal.c @@ -0,0 +1 @@ +#include "../mips/signal.c" --=20 2.7.4