From patchwork Fri Feb 16 21:56:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 128651 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1017546ljc; Fri, 16 Feb 2018 13:59:44 -0800 (PST) X-Google-Smtp-Source: AH8x224lLAOmS6sQi+SVIupE4eAy9fDtrUUWxdWc2kdBDPxt3/Q8iI79p17vVGHujre9H+7HbA96 X-Received: by 10.129.37.14 with SMTP id l14mr5933360ywl.412.1518818383933; Fri, 16 Feb 2018 13:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518818383; cv=none; d=google.com; s=arc-20160816; b=Lj6Hiq8K8lvHoonYHEsYRNMsiFMvJQFTaqOJtij7bSgqpAfwaEMwZtfVuxeZR+I2bl UjHPbIvouNrWi2byG9UwJAHwkO1od4xNUrkg2zq0zhrjcHSy7c3nLNpusI7RiCoeHqwi NRyqnQ2TlprQYM0DLiuTDsnxPSvpm0czFxROMtZXmyQqSbLGDX+02naNm62g5cgvjzGC 6bUDBbwqky4Aw1N+/fkP2TeyXq53cG7rkswVqLKvIxGCzpTsSPCPjVwp6dShbxwyTGwX dak0oVtII+FADce/roBbFdS9l7gqjCVziwLAkNN1HfeKS9/GdseUzRccrk96ysGW07bG pGCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=pnJnOBb4bnqWYBFZVnu+EyVcw82Gc2SEw4s7fOWRy0A=; b=MrSeGeZIx4b1GdJkR2q6Bbh+8ozVQcRrxKDk9JKkBPuBwh7icsDqgBe/WMaL+py/Iz uskfdVdI3M1/cZ9jQcZkcwM8pBrUHRrCpgBXSRNdGdPHlPby3XiBCn8mVTxicNSBtAHF 4maO92/iw+F3s3OLEUeu2etwp0o0V4FrsquEFNYKJ9Ntcd9Yo2/Ef4IsMvpLgk7tkl3G VYR5MCIgdHRT/K3lUxQ7UlNDilygvar1z2juDbsiKtJunrF7PSG59snOKl9c5JleR4q7 1SAFjpc3yrzV8ep5sipNA9//rx/Tmo3/52x2MmT1EuOvsYN6i8C3wg9SaES8h1fkFPFz WARQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hEcP2Z0O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n142si1554700yba.153.2018.02.16.13.59.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 16 Feb 2018 13:59:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hEcP2Z0O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emo2h-0000vM-AY for patch@linaro.org; Fri, 16 Feb 2018 16:59:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emnzQ-0006ln-RC for qemu-devel@nongnu.org; Fri, 16 Feb 2018 16:56:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emnzP-0007QA-SJ for qemu-devel@nongnu.org; Fri, 16 Feb 2018 16:56:20 -0500 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:34081) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1emnzP-0007Pv-Jv for qemu-devel@nongnu.org; Fri, 16 Feb 2018 16:56:19 -0500 Received: by mail-pl0-x242.google.com with SMTP id bd10so2396504plb.1 for ; Fri, 16 Feb 2018 13:56:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pnJnOBb4bnqWYBFZVnu+EyVcw82Gc2SEw4s7fOWRy0A=; b=hEcP2Z0OmTnPITCTHhOrG4qZNMX2ku5vHoqTN+NJN5rDhfhv7UJA4m6JAVC8G53ocY QVomMhn0vqkK2EjkZYWhUzgOsE+M8AlI1yMmRu9OoV7OhbIzST8eKfs3vKjKzO7dvjH0 MxJb/EdC/dlD/WrUDIKhxGav6BwCdJMHF4rzg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pnJnOBb4bnqWYBFZVnu+EyVcw82Gc2SEw4s7fOWRy0A=; b=loTILtl0CX5wwt2t49vghUp0QlueGPfI7VJH+QfzTMz0wFj5BujfoYOaB/sGsxQ51E OcxLgkLi9hi5bAJJaW2WKJIL1gBojknJpaN9AenzZNCq49AJtLOt508tl0qqK4sYnBKR XYY0wQ884EEvB3xSn8gbIRJ8NSQonyMEj//4eW/V1qbTopBNp8H2cujlzgkF23zTlNCT RGnH+SFl6DxqBngPskPoWlY1ydfwzurW2j5Cr5t17jndZN1nKPVqItpmhS4eaKcgon7b bOGLJycvckvobsoah8sX8jwp25XY3LK4tXMfS5UdHGapA8thZ3rcQ0S2G/noY9FhAA5E t3OQ== X-Gm-Message-State: APf1xPCYTX77AZSXi2zsw7bQcjSYMuGz7xo2IV9wGisU4pT0f3W7CTxi OD18qt0Du2ulaoU2i5Pkjmjuobx5WWQ= X-Received: by 2002:a17:902:7841:: with SMTP id e1-v6mr7017559pln.130.1518818178260; Fri, 16 Feb 2018 13:56:18 -0800 (PST) Received: from cloudburst.twiddle.net ([50.0.192.64]) by smtp.gmail.com with ESMTPSA id b88sm39230538pfd.108.2018.02.16.13.56.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Feb 2018 13:56:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:56:07 -0800 Message-Id: <20180216215608.13227-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180216215608.13227-1-richard.henderson@linaro.org> References: <20180216215608.13227-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v3 4/5] 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/signal.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) -- 2.14.3 diff --git a/linux-user/signal.c b/linux-user/signal.c index f9eef3d753..ca0ba28c98 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1443,6 +1443,15 @@ struct target_fpsimd_context { uint64_t vregs[32 * 2]; /* really uint128_t vregs[32] */ }; +#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 __u64 */ + 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; @@ -1502,6 +1511,15 @@ static void target_setup_fpsimd_record(struct target_fpsimd_context *fpsimd, } } +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); @@ -1554,14 +1572,16 @@ static void target_restore_fpsimd_record(CPUARMState *env, static int target_restore_sigframe(CPUARMState *env, struct target_rt_sigframe *sf) { - struct target_aarch64_ctx *ctx; + struct target_aarch64_ctx *ctx, *extra = NULL; struct target_fpsimd_context *fpsimd = NULL; + uint64_t extra_datap = 0; + bool used_extra = false; target_restore_general_frame(env, sf); ctx = (struct target_aarch64_ctx *)sf->uc.tuc_mcontext.__reserved; while (ctx) { - uint32_t magic, size; + uint32_t magic, size, extra_size; __get_user(magic, &ctx->magic); __get_user(size, &ctx->size); @@ -1570,7 +1590,12 @@ static int target_restore_sigframe(CPUARMState *env, if (size != 0) { return 1; } - ctx = NULL; + if (used_extra) { + ctx = NULL; + } else { + ctx = extra; + used_extra = true; + } continue; case TARGET_FPSIMD_MAGIC: @@ -1580,6 +1605,17 @@ static int target_restore_sigframe(CPUARMState *env, fpsimd = (struct target_fpsimd_context *)ctx; break; + case TARGET_EXTRA_MAGIC: + if (extra || size != sizeof(struct target_extra_context)) { + return 1; + } + __get_user(extra_datap, + &((struct target_extra_context *)ctx)->datap); + __get_user(extra_size, + &((struct target_extra_context *)ctx)->size); + extra = 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? @@ -1595,6 +1631,9 @@ static int target_restore_sigframe(CPUARMState *env, } target_restore_fpsimd_record(env, fpsimd); + if (extra) { + unlock_user(extra, extra_datap, 0); + } return 0; } @@ -1621,7 +1660,8 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, CPUARMState *env) { int size = offsetof(struct target_rt_sigframe, uc.tuc_mcontext.__reserved); - int fpsimd_ofs, end1_ofs, fr_ofs; + int fpsimd_ofs, end1_ofs, fr_ofs, end2_ofs = 0; + int extra_ofs = 0, extra_base = 0, extra_size = 0; struct target_rt_sigframe *frame; struct target_rt_frame_record *fr; abi_ulong frame_addr, return_addr; @@ -1641,7 +1681,14 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, 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); + } /* Set up the stack frame for unwinding. */ fr = (void *)frame + fr_ofs;