From nobody Tue Apr 15 19:52:16 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520618616730702.1272903795539; Fri, 9 Mar 2018 10:03:36 -0800 (PST) Received: from localhost ([::1]:47090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euMMh-0006bq-Su for importer@patchew.org; Fri, 09 Mar 2018 13:03:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euLms-0008P8-VH for qemu-devel@nongnu.org; Fri, 09 Mar 2018 12:26:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euLmr-000655-Pg for qemu-devel@nongnu.org; Fri, 09 Mar 2018 12:26:34 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:46996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1euLmr-00060G-G9 for qemu-devel@nongnu.org; Fri, 09 Mar 2018 12:26:33 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1euLmn-00075S-1e for qemu-devel@nongnu.org; Fri, 09 Mar 2018 17:26:29 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 9 Mar 2018 17:26:06 +0000 Message-Id: <20180309172622.4277-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180309172622.4277-1-peter.maydell@linaro.org> References: <20180309172622.4277-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 09/25] aarch64-linux-user: Add support for EXTRA signal frame records 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Richard Henderson The EXTRA record allows for additional space to be allocated beyon what is currently reserved. Add code to emit and read this record type. Nothing uses extra space yet. Signed-off-by: Richard Henderson Message-id: 20180303143823.27055-5-richard.henderson@linaro.org Reviewed-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Peter Maydell --- linux-user/signal.c | 74 +++++++++++++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 0f2b155c33..f8bc0aa397 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1446,6 +1446,15 @@ struct target_fpsimd_context { uint64_t vregs[32 * 2]; /* really uint128_t vregs[32] */ }; =20 +#define TARGET_EXTRA_MAGIC 0x45585401 + +struct target_extra_context { + struct target_aarch64_ctx head; + uint64_t datap; /* 16-byte aligned pointer to extra space cast to __u6= 4 */ + uint32_t size; /* size in bytes of the extra space */ + uint32_t reserved[3]; +}; + struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; @@ -1505,6 +1514,15 @@ static void target_setup_fpsimd_record(struct target= _fpsimd_context *fpsimd, } } =20 +static void target_setup_extra_record(struct target_extra_context *extra, + uint64_t datap, uint32_t extra_size) +{ + __put_user(TARGET_EXTRA_MAGIC, &extra->head.magic); + __put_user(sizeof(struct target_extra_context), &extra->head.size); + __put_user(datap, &extra->datap); + __put_user(extra_size, &extra->size); +} + static void target_setup_end_record(struct target_aarch64_ctx *end) { __put_user(0, &end->magic); @@ -1557,48 +1575,74 @@ static void target_restore_fpsimd_record(CPUARMStat= e *env, static int target_restore_sigframe(CPUARMState *env, struct target_rt_sigframe *sf) { - struct target_aarch64_ctx *ctx; + struct target_aarch64_ctx *ctx, *extra =3D NULL; struct target_fpsimd_context *fpsimd =3D NULL; + uint64_t extra_datap =3D 0; + bool used_extra =3D false; + bool err =3D false; =20 target_restore_general_frame(env, sf); =20 ctx =3D (struct target_aarch64_ctx *)sf->uc.tuc_mcontext.__reserved; while (ctx) { - uint32_t magic, size; + uint32_t magic, size, extra_size; =20 __get_user(magic, &ctx->magic); __get_user(size, &ctx->size); switch (magic) { case 0: if (size !=3D 0) { - return 1; + err =3D true; + goto exit; + } + if (used_extra) { + ctx =3D NULL; + } else { + ctx =3D extra; + used_extra =3D true; } - ctx =3D NULL; continue; =20 case TARGET_FPSIMD_MAGIC: if (fpsimd || size !=3D sizeof(struct target_fpsimd_context)) { - return 1; + err =3D true; + goto exit; } fpsimd =3D (struct target_fpsimd_context *)ctx; break; =20 + case TARGET_EXTRA_MAGIC: + if (extra || size !=3D sizeof(struct target_extra_context)) { + err =3D true; + goto exit; + } + __get_user(extra_datap, + &((struct target_extra_context *)ctx)->datap); + __get_user(extra_size, + &((struct target_extra_context *)ctx)->size); + extra =3D lock_user(VERIFY_READ, extra_datap, extra_size, 0); + break; + default: /* Unknown record -- we certainly didn't generate it. * Did we in fact get out of sync? */ - return 1; + err =3D true; + goto exit; } ctx =3D (void *)ctx + size; } =20 /* Require FPSIMD always. */ - if (!fpsimd) { - return 1; + if (fpsimd) { + target_restore_fpsimd_record(env, fpsimd); + } else { + err =3D true; } - target_restore_fpsimd_record(env, fpsimd); =20 - return 0; + exit: + unlock_user(extra, extra_datap, 0); + return err; } =20 static abi_ulong get_sigframe(struct target_sigaction *ka, CPUARMState *en= v) @@ -1624,7 +1668,8 @@ static void target_setup_frame(int usig, struct targe= t_sigaction *ka, CPUARMState *env) { int size =3D offsetof(struct target_rt_sigframe, uc.tuc_mcontext.__res= erved); - int fpsimd_ofs, end1_ofs, fr_ofs; + int fpsimd_ofs, end1_ofs, fr_ofs, end2_ofs =3D 0; + int extra_ofs =3D 0, extra_base =3D 0, extra_size =3D 0; struct target_rt_sigframe *frame; struct target_rt_frame_record *fr; abi_ulong frame_addr, return_addr; @@ -1644,7 +1689,14 @@ static void target_setup_frame(int usig, struct targ= et_sigaction *ka, =20 target_setup_general_frame(frame, env, set); target_setup_fpsimd_record((void *)frame + fpsimd_ofs, env); + if (extra_ofs) { + target_setup_extra_record((void *)frame + extra_ofs, + frame_addr + extra_base, extra_size); + } target_setup_end_record((void *)frame + end1_ofs); + if (end2_ofs) { + target_setup_end_record((void *)frame + end2_ofs); + } =20 /* Set up the stack frame for unwinding. */ fr =3D (void *)frame + fr_ofs; --=20 2.16.2