From patchwork Fri Jun 23 09:07:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 9806017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C139160349 for ; Fri, 23 Jun 2017 09:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B31F828560 for ; Fri, 23 Jun 2017 09:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7FBD2861F; Fri, 23 Jun 2017 09:08:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 22F6B28560 for ; Fri, 23 Jun 2017 09:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=P1wfgSZQ4gWgwXbCcnORRqMvslIr+mWYut/K6I7Ahe0=; b=DEE 8zn6pFMDX2RCMJ6x2Y2gRw8qec8A2xctdt0hYxC+rKpdJfCvkm47sZLRnnAaAHvwuQ4ooybF6Jglb tr/V3MSsbV96OcfrbTCfYzBl2jPW/7HIvLai8k4FXzUwg3EJ8+D46cK1lvmgqBk3UUVA2iqbbayUX 94WufwRjA5MpPrVuNUNbZXknqk4htvmwwXdQX+qDQVmnq57o014Lj2v4VYas2Bx/h/kvvR9CnGTJj 8VQHmXjEzdNRhd+waLAXJYEWDLyDwNFMKA9wpTLE8OjvMwagNJJZVy6fm4YhxUDbVSKgx2TCTeRjV WFQowl9y511tbWFzMhWSmfHyrihfVsQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dOKZY-00029E-Sz; Fri, 23 Jun 2017 09:08:12 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dOKZV-00027Y-Ed for linux-arm-kernel@lists.infradead.org; Fri, 23 Jun 2017 09:08:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F5052B; Fri, 23 Jun 2017 02:07:49 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9136A3F557; Fri, 23 Jun 2017 02:07:48 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH] arm64: signal: Make parse_user_sigframe() independent of rt_sigframe layout Date: Fri, 23 Jun 2017 10:07:39 +0100 Message-Id: <1498208859-6099-1-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170623_020809_501539_232073B3 X-CRM114-Status: GOOD ( 11.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Yury Norov MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ILP32 support uses the same struct sigcontext as the native ABI (i.e., LP64), but a different layout for the rest of the signal frame (since siginfo_t and ucontext_t are both ABI-dependent). Since the purpose of parse_user_sigframe() is really to parse sigcontext and not the whole signal frame, the function does not need to depend on the layout of rt_sigframe -- the only purpose of the rt_sigframe pointer is for use as a base to measure the signal frame size. So, this patch renames the function to parse_user_sigcontext() and makes the sigframe base pointer generic. ABI-specific parsers that share the same sigcontext definition can then call it. To minimise churn in this patch, the native LP64 parser is retained under the old name, but becomes a call to parse_user_sigconext(). It may make sense instead to fold this into its restore_sigframe(), depending on how ILP32 support is integrated. Suggested-by: Yury Norov Signed-off-by: Dave Martin --- This patch depends on [1], which does not appear to be applied yet. [1] [PATCH] arm64: signal: Allow expansion of the signal frame http://lists.infradead.org/pipermail/linux-arm-kernel/2017-June/514699.html arch/arm64/kernel/signal.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index e47cd3a..a189321 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -223,16 +223,16 @@ struct user_ctxs { struct fpsimd_context __user *fpsimd; }; -static int parse_user_sigframe(struct user_ctxs *user, - struct rt_sigframe __user *sf) +static int parse_user_sigcontext(struct user_ctxs *user, + struct sigcontext __user const *sc, + void __user const *sigframe_base) { - struct sigcontext __user *const sc = &sf->uc.uc_mcontext; struct _aarch64_ctx __user *head; char __user *base = (char __user *)&sc->__reserved; size_t offset = 0; size_t limit = sizeof(sc->__reserved); bool have_extra_context = false; - char const __user *const sfp = (char const __user *)sf; + char const __user *const sfp = (char const __user *)sigframe_base; user->fpsimd = NULL; @@ -366,6 +366,12 @@ static int parse_user_sigframe(struct user_ctxs *user, return -EINVAL; } +static int parse_user_sigframe(struct user_ctxs *user, + struct rt_sigframe __user const *sf) +{ + return parse_user_sigcontext(user, &sf->uc.uc_mcontext, sf); +} + static int restore_sigframe(struct pt_regs *regs, struct rt_sigframe __user *sf) {