From patchwork Mon Oct 1 17:58:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 10622517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF76015A7 for ; Mon, 1 Oct 2018 18:07:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA8DD282E8 for ; Mon, 1 Oct 2018 18:07:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE6AA284D2; Mon, 1 Oct 2018 18:07:15 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 E9F89282E8 for ; Mon, 1 Oct 2018 18:07: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=ImcM3FbXIaIAfz807KZuDdjtUFcnb5lum3sTCkHB/PM=; b=KYocINhbGSz/XA lC/oK7UXHZ8ssTLKlFfy3LyFsl8WMJrqYhDi/sChpehsGljvocmPwGUlpuJXuEpygEYKhP02bylqj 6rKSW8YEDHAUk8xrs4gZX6kpFneXUx2b8tCPFFFottN7bZpKK5iWaafjZG/yP+wpuqY6wc0AI8Mv2 PIuiQXqqXmVgEpMMQaczKJsdFqiH1LY2eJVNua/naladHsnr6xXP/QlrGtNLODV9ONXqp/xvTpn3Q 9C9i9b7Ni/ub5b1ZBn5uC4Uq1eJOqdauzDjJ8tCBrKhbeHn7oXjXvJlhRxeQhEcY4FY8MV3Ga9D2N g0sNf3MKcXTlfRYTZ75g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g72b1-00026J-B9; Mon, 01 Oct 2018 18:07:03 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g72Y7-000843-1R for linux-arm-kernel@lists.infradead.org; Mon, 01 Oct 2018 18:04:57 +0000 Received: by mail-pg1-x544.google.com with SMTP id g2-v6so9994173pgu.11 for ; Mon, 01 Oct 2018 11:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1hKeDyS7++2kPLhT6ee9TedPtguPWVHoNSg0EUEDYTo=; b=bj/+0aZQis38X7vMaKa1q1epw4H/mDhp+7DZ/2LLBaVPV7GMTS3288hT2MQafC3pFN FezI7BNXxmEGJshC99GRPvb65H6oIqcv0/ur/3Hx9rqfX01ogQlaiyKKNPr3rmfSybOv mW7oTId3mLTbQBTeG8N1ixPn6m5B6G2uC72/M4KHFqbBdjSrd8+Y7aIrbfXf9B/1kRN6 +RQewISC9nEJETMCmo7wCw07JaEWJDFK8U5jp17tERv5LtGkpENuDDA9qlomjT3D6rhN pHbQ8AN4ApJCEpPVh7lpsQ+bK/4dtdzy3XmfXoUMLhcMtAUfF69bSHXz0v5HfEMqNM+C 4EKQ== 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:mime-version:content-transfer-encoding; bh=1hKeDyS7++2kPLhT6ee9TedPtguPWVHoNSg0EUEDYTo=; b=QmDYfaMPapAdDdlWGPNhGyR+fnxPx59YkiqXTa2EA8RW9cje+52cmdO5W6bL8HEP+i mKDpxBU+wnnGwBHP0PqdFFhfZ+xXAoKxl+c4ihDtXIbdwjnE0HP6Zbx584F4qc/oYfi8 CHCUMi6R+rMFSSZWOpvU2aNie76SUM01kZ/NhfZRo4Ys5TwqB1+Pg1hP5fhyiMlF3ZPv lVFqsclyinuP8mDtXkh5hfdbI/DriLbCaHXob9jhDfatCR3D7VPfFWXvtc2MutT3XIRO 0rdCZii6PX4aIL3AeLooqo49NE46qnrbBWl/dREfoQks/RJjV3hUYs/LnNfgMTcR1X/a qZJA== X-Gm-Message-State: ABuFfohTSRLxcmsFR7vuGgFYeR7Vai7hNGuVdZVameICplYfj4Ixj62n ytMvnq59G066TqoEyMJeqo8cLA== X-Google-Smtp-Source: ACcGV63B/pJSvdD06HWIEEXmyh6QACgBQh+CzoBPwnCYSUPwaaYfNq8ul0BbibGqdUx5UrxoX7A0jA== X-Received: by 2002:a63:1d62:: with SMTP id d34-v6mr1925726pgm.180.1538417032183; Mon, 01 Oct 2018 11:03:52 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1612:b4fb:6752:f21f:3502]) by smtp.gmail.com with ESMTPSA id d186-v6sm24469261pfg.173.2018.10.01.11.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 11:03:51 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Subject: RESEND [PATCH] arm64: compat: Expose offset to registers in sigframes Date: Mon, 1 Oct 2018 10:58:37 -0700 Message-Id: <20181001175845.168430-18-salyzyn@android.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181001175845.168430-1-salyzyn@android.com> References: <20181001175845.168430-1-salyzyn@android.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181001_110403_101352_20B2431B X-CRM114-Status: GOOD ( 16.02 ) 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: Mark Rutland , Catalin Marinas , Will Deacon , Andy Lutomirski , Russell King , Andy Gross , Laura Abbott , Dave Martin , "Eric W . Biederman" , Kees Cook , Marc Zyngier , Kevin Brodsky , John Stultz , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Dmitry Safonov , android-kernel@android.com, Jeremy Linton , Mark Salyzyn , James Morse , Andrew Pinski , Christoffer Dall 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 From: Kevin Brodsky This will be needed to provide unwinding information in compat sigreturn trampolines, part of the future compat vDSO. There is no obvious header the compat_sig* struct's should be moved to, so let's put them in signal32.h. Also fix minor style issues reported by checkpatch. Signed-off-by: Kevin Brodsky Signed-off-by: Mark Salyzyn Tested-by: Mark Salyzyn Cc: James Morse Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Lutomirski Cc: Dmitry Safonov Cc: John Stultz Cc: Mark Rutland Cc: Laura Abbott Cc: Kees Cook Cc: Ard Biesheuvel Cc: Andy Gross Cc: Kevin Brodsky Cc: Andrew Pinski Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: Dave Martin Cc: Eric W. Biederman Cc: Jeremy Linton Cc: android-kernel@android.com NB: Basically unchanged as part of a vDSO32 effort through 4 revisions, Resubmitted as a standalone change for quicker approval. --- arch/arm64/include/asm/signal32.h | 46 +++++++++++++++++++++++++++++++ arch/arm64/kernel/asm-offsets.c | 13 +++++++++ arch/arm64/kernel/signal32.c | 46 ------------------------------- 3 files changed, 59 insertions(+), 46 deletions(-) diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h index 58e288aaf0ba..bcd0e139ee4a 100644 --- a/arch/arm64/include/asm/signal32.h +++ b/arch/arm64/include/asm/signal32.h @@ -20,6 +20,52 @@ #ifdef CONFIG_COMPAT #include +struct compat_sigcontext { + /* We always set these two fields to 0 */ + compat_ulong_t trap_no; + compat_ulong_t error_code; + + compat_ulong_t oldmask; + compat_ulong_t arm_r0; + compat_ulong_t arm_r1; + compat_ulong_t arm_r2; + compat_ulong_t arm_r3; + compat_ulong_t arm_r4; + compat_ulong_t arm_r5; + compat_ulong_t arm_r6; + compat_ulong_t arm_r7; + compat_ulong_t arm_r8; + compat_ulong_t arm_r9; + compat_ulong_t arm_r10; + compat_ulong_t arm_fp; + compat_ulong_t arm_ip; + compat_ulong_t arm_sp; + compat_ulong_t arm_lr; + compat_ulong_t arm_pc; + compat_ulong_t arm_cpsr; + compat_ulong_t fault_address; +}; + +struct compat_ucontext { + compat_ulong_t uc_flags; + compat_uptr_t uc_link; + compat_stack_t uc_stack; + struct compat_sigcontext uc_mcontext; + compat_sigset_t uc_sigmask; + int __unused[32 - (sizeof(compat_sigset_t) / sizeof(int))]; + compat_ulong_t uc_regspace[128] __aligned(8); +}; + +struct compat_sigframe { + struct compat_ucontext uc; + compat_ulong_t retcode[2]; +}; + +struct compat_rt_sigframe { + struct compat_siginfo info; + struct compat_sigframe sig; +}; + int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set, struct pt_regs *regs); int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 8938a4223690..a79507c5d845 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +82,18 @@ int main(void) DEFINE(S_STACKFRAME, offsetof(struct pt_regs, stackframe)); DEFINE(S_FRAME_SIZE, sizeof(struct pt_regs)); BLANK(); +#ifdef CONFIG_COMPAT + DEFINE(COMPAT_SIGFRAME_REGS_OFFSET, + offsetof(struct compat_sigframe, uc) + + offsetof(struct compat_ucontext, uc_mcontext) + + offsetof(struct compat_sigcontext, arm_r0)); + DEFINE(COMPAT_RT_SIGFRAME_REGS_OFFSET, + offsetof(struct compat_rt_sigframe, sig) + + offsetof(struct compat_sigframe, uc) + + offsetof(struct compat_ucontext, uc_mcontext) + + offsetof(struct compat_sigcontext, arm_r0)); + BLANK(); +#endif DEFINE(MM_CONTEXT_ID, offsetof(struct mm_struct, context.id.counter)); BLANK(); DEFINE(VMA_VM_MM, offsetof(struct vm_area_struct, vm_mm)); diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index 52f0d44417c8..6b421666b5b8 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -30,42 +30,6 @@ #include #include -struct compat_sigcontext { - /* We always set these two fields to 0 */ - compat_ulong_t trap_no; - compat_ulong_t error_code; - - compat_ulong_t oldmask; - compat_ulong_t arm_r0; - compat_ulong_t arm_r1; - compat_ulong_t arm_r2; - compat_ulong_t arm_r3; - compat_ulong_t arm_r4; - compat_ulong_t arm_r5; - compat_ulong_t arm_r6; - compat_ulong_t arm_r7; - compat_ulong_t arm_r8; - compat_ulong_t arm_r9; - compat_ulong_t arm_r10; - compat_ulong_t arm_fp; - compat_ulong_t arm_ip; - compat_ulong_t arm_sp; - compat_ulong_t arm_lr; - compat_ulong_t arm_pc; - compat_ulong_t arm_cpsr; - compat_ulong_t fault_address; -}; - -struct compat_ucontext { - compat_ulong_t uc_flags; - compat_uptr_t uc_link; - compat_stack_t uc_stack; - struct compat_sigcontext uc_mcontext; - compat_sigset_t uc_sigmask; - int __unused[32 - (sizeof (compat_sigset_t) / sizeof (int))]; - compat_ulong_t uc_regspace[128] __attribute__((__aligned__(8))); -}; - struct compat_vfp_sigframe { compat_ulong_t magic; compat_ulong_t size; @@ -92,16 +56,6 @@ struct compat_aux_sigframe { unsigned long end_magic; } __attribute__((__aligned__(8))); -struct compat_sigframe { - struct compat_ucontext uc; - compat_ulong_t retcode[2]; -}; - -struct compat_rt_sigframe { - struct compat_siginfo info; - struct compat_sigframe sig; -}; - #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) static inline int put_sigset_t(compat_sigset_t __user *uset, sigset_t *set)