From patchwork Fri Nov 9 12:37:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10675859 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 9DA9715A6 for ; Fri, 9 Nov 2018 12:43:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AF582E350 for ; Fri, 9 Nov 2018 12:43:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E2EA2E574; Fri, 9 Nov 2018 12:43:45 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 0D4232E350 for ; Fri, 9 Nov 2018 12:43:45 +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=mAE15PbWMSO6/gv77cSOGg0zAqrCtfBSqwXdyygVuVA=; b=QKwFT+CY4R814l l2TyrDlt3d6lW7TeI1JBdt5ZAMu+ApgxnxT5G6IMZXOG1xSPaJwThdgftsVxzt/zQvqUXaqX7hJjs 1CjM12O13LAqbdxXerJ8DCetAZYp1iN/0JtUcwDWGsWZEQalN6e7l/pe6AfYA8pVi2lG0blWJSStA MAA0tb3aWSo5OSsR+Jy/EekfAdULprYHgAnpvJdap/PZStOQlaqAFsLSuNf1F4xbbSSN2yZ4dibpp NMq3kDr61NC0gvcbgjMeVkFNnBzXdrdKGdPxE0/IXL+r1JxojYHOhW83YxUJbFh4CLmHGw3YSo0PW mwvRbAftT1zubsrDkrrA==; 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 1gL68U-0002La-FO; Fri, 09 Nov 2018 12:43:42 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL63b-0005AA-Jt for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Nov 2018 12:38:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6sks3uYSPlInlPVx28xPo079caH15XDHo13x3+y+VFU=; b=uw6g5b/0CEImIttDUBxA/bUHyI N4QoGvAK7um/d3iYjeuPHM0GEuyuyHLNUDn4rd63t2z8YSt9hNmH1KkkExZqL0uxzIiVCKmYeG5ya WOp3VufhxZSGpRaZVO3F6qS+PKQbESLV0+u1FRX+uivNXGTdCKP5jmJzdMq5Zr4d8mMNMtjkUPVUx zRAQZH3QbLhAtd04W7HVt1gFink3T/6yvpNc600Ju3GUugZP1L5VzT/Txuz17ENftMLWMQidy5JHx tD6eDN/Dl8qzilDfFqg5HSeXZOWT/fhLYo/UXcy+wR8vCx1rY4CyBP0Xbr5uElxltKvm3Gf1F+sHG vy82dBIw==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL63Y-0006W7-Iu for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2018 12:38:38 +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 52F1F80D; Fri, 9 Nov 2018 04:38:36 -0800 (PST) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 414F73F718; Fri, 9 Nov 2018 04:38:34 -0800 (PST) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 20/27] arm64: compat: Get sigreturn trampolines from vDSO Date: Fri, 9 Nov 2018 12:37:23 +0000 Message-Id: <20181109123730.8743-21-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181109123730.8743-1-vincenzo.frascino@arm.com> References: <20181109123730.8743-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181109_123836_785150_577CAEA3 X-CRM114-Status: GOOD ( 15.47 ) 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: Arnd Bergmann , Catalin Marinas , Daniel Lezcano , Will Deacon , Russell King , Ralf Baechle , Mark Salyzyn , Paul Burton , Thomas Gleixner , Peter Collingbourne 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 When the compat vDSO is enabled, the sigreturn trampolines are not anymore available through [sigpage] but through [vdso]. This patch adds the relevant code the enable the feature. Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Vincenzo Frascino --- arch/arm64/include/asm/vdso.h | 3 +++ arch/arm64/kernel/signal32.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h index 839ce0031bd5..9b197e5ea759 100644 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -28,6 +28,9 @@ #ifndef __ASSEMBLY__ #include +#ifdef CONFIG_COMPAT_VDSO +#include +#endif #define VDSO_SYMBOL(base, name) \ ({ \ diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index 16c490a83131..be471a81084e 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -29,6 +29,7 @@ #include #include #include +#include struct compat_vfp_sigframe { compat_ulong_t magic; @@ -333,7 +334,6 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka, compat_ulong_t retcode; compat_ulong_t spsr = regs->pstate & ~(PSR_f | PSR_AA32_E_BIT); int thumb; - void *sigreturn_base; /* Check if the handler is written for ARM or Thumb */ thumb = handler & 1; @@ -353,14 +353,39 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka, retcode = ptr_to_compat(ka->sa.sa_restorer); } else { /* Set up sigreturn pointer */ +#ifdef CONFIG_COMPAT_VDSO + void *vdso_base = current->mm->context.vdso; + void *vdso_trampoline; + + if (ka->sa.sa_flags & SA_SIGINFO) { + if (thumb) { + vdso_trampoline = VDSO_SYMBOL(vdso_base, + compat_rt_sigreturn_thumb); + } else { + vdso_trampoline = VDSO_SYMBOL(vdso_base, + compat_rt_sigreturn_arm); + } + } else { + if (thumb) { + vdso_trampoline = VDSO_SYMBOL(vdso_base, + compat_sigreturn_thumb); + } else { + vdso_trampoline = VDSO_SYMBOL(vdso_base, + compat_sigreturn_arm); + } + } + + retcode = ptr_to_compat(vdso_trampoline) + thumb; +#else unsigned int idx = thumb << 1; - sigreturn_base = current->mm->context.vdso; + void *sigreturn_base = current->mm->context.vdso; if (ka->sa.sa_flags & SA_SIGINFO) idx += 3; retcode = ptr_to_compat(sigreturn_base) + (idx << 2) + thumb; +#endif } regs->regs[0] = usig;