From patchwork Mon Sep 11 15:27:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 9947631 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 A42E06024A for ; Mon, 11 Sep 2017 15:49:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 959D628C5F for ; Mon, 11 Sep 2017 15:49:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89B0F28C61; Mon, 11 Sep 2017 15:49:27 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable 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 0BAF528C5F for ; Mon, 11 Sep 2017 15:49:26 +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=GAeCm0Tg49xC06AdCi+ZMia2TNwj13TXiZwDSeDHrFo=; b=nuP AFapmHbiRJbPuWn7PVkD1v5uyACDNiripqNAZ57tz870QC8PkuhTay5IncCx++7iSK7NiWC7ecbrX v2Kek6B9rHheGDHEqDr097piz8GoCXx0JrQyt7rXrwA9AmdZZ9YO1kktddbV6Y34+du/ric4L9OfM pe4gGKOZX2d+2IMGTqVxMEfFpynmXDE/kHInl/Vvvfh6llb+jkj4ovn3ABJLznnsuh7gHxXQphdy+ iMkrf0i6JagscJG3prr8jKT4gpmlFq6VdEYOCkQ4CQ5TGzEn/j3r9Gsr3DOZBxZVurwlVCni7X51J 9wLVanlxsyjnapOuh6yy3AXbEv4nAMA==; 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 1drQxd-0002b2-Ro; Mon, 11 Sep 2017 15:49:21 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1drQxU-0002ZO-DW for linux-arm-kernel@bombadil.infradead.org; Mon, 11 Sep 2017 15:49:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=i/o6H6/hs+7V5pp///TvAWw/Xg6dft+IUJGhJpBWQ2A=; b=LnjEBb3ZYvu4E7xidxXOY8BPh VDoubmEVXkPiLqnoQsOC8XaxlvyeCPgsx62oJeHaRNVz6aSuXEStuvxMan7Rx2BHBau/AhIQV2is+ D7hxpFacLYq1SswndrDm45FaGrQtB8t0MIB6buS9clsAjO8rzNnScnQYJKhBUBX1If1iK334gCGOi RUB+g7hy0huotI1uySFe9T2OKAbf5IjGFKB+3MCA3fbTzg2hrzKu2f60Sz3tQveTYP3WQ2GY5Hfua 0FFhbM4mO5QHFHcZB/DLuaPLocklMnDPJ4b+B2XnxONTtCgllwoG2FrA+uVbfPy+WOP4LR6P9/Kc+ X3fi66vTA==; Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1drQdI-0003Jh-J4 for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2017 15:28:23 +0000 Received: by mail-pg0-x236.google.com with SMTP id j16so5535460pga.1 for ; Mon, 11 Sep 2017 08:27:57 -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; bh=i/o6H6/hs+7V5pp///TvAWw/Xg6dft+IUJGhJpBWQ2A=; b=n4z6lOCG9eim7axIqwl1sbbjPNtTZDLbzKWHbvZrwAd6/wvzVs+ioQQNxac2oVKO+n yhFwQbARDwPa1nbWJUT0BgVOHQSLl2Aq1Y3erz0Yk/G83jdlXMexvMxJ0CrY/hOGGGdg sHH/Vi5eeaclAF3JNqLsw8/Ps1dS03pSg1aq0zJnHEv7fY0JgBI7Aw2ld1AmonuXcl/i 8Czgs9uLDwyhYju4PNYkaV/KVg4L4Ya54Ihl1rCQrw8MA7qiyPCDGCqGU2UCTbxAyBgg /yFgbPRbGsKjk0EtNaQhaRQxnQaSaIPxPuH6DlsKCgNnhelyYb76wQ7re3juZ3y1iwSv 19xA== 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; bh=i/o6H6/hs+7V5pp///TvAWw/Xg6dft+IUJGhJpBWQ2A=; b=gxiwqt//5+rMhVb5d3Ln1Zmp57Ylb9GEdzkJ91fUKhKGPYY+p7I4ZLkC8Yl9PLIUqr 6Ama0h9SOGGy2AsxDkgIV7N3UNm7ER3z/fHuJbhf1idoBJXRvxV96OQw5VXrs0UcfHmC tEtPArVXnIv55tjYOLzgUHYlypdcaIJrERc5ssNv2IdjvZLwlfoIXYCQAujy2pbNGsr1 mpUg6QrK6FIVOALaGyR8UCXORRmZ0x92tv7WY6gQ/LuwpOsMcczCN/cfNW960enXiMaO hcNEm8f9nj4vWQopIR0QW4aGWn03I5YGWSHhHiYyG3uC52K/+ZDomm/dS7i/+sbCZtlC eBgA== X-Gm-Message-State: AHPjjUh2sSkBiIglcg0wteOOATXCoUg1NEsV4bpXnkXBua4+yGMebjS5 80jxJ9wH7UNgo6Hy X-Google-Smtp-Source: ADKCNb4f/T+HPwPV7wZ1NFEmbJcTvbPE6zaEQ6QbotaSNEXjThy4T93XjcLYHrxsmvQ/OMMHPLJh1g== X-Received: by 10.101.78.7 with SMTP id r7mr12520036pgt.64.1505143675078; Mon, 11 Sep 2017 08:27:55 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([100.98.120.17]) by smtp.gmail.com with ESMTPSA id i2sm13458940pgq.81.2017.09.11.08.27.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Sep 2017 08:27:54 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] arm64: compat: Split the sigreturn trampolines and kuser helpers (assembler sources) Date: Mon, 11 Sep 2017 08:27:40 -0700 Message-Id: <20170911152748.95593-1-salyzyn@android.com> X-Mailer: git-send-email 2.14.1.581.gf28d330327-goog 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@arm.com, jszhang@marvell.com, Mark Salyzyn , ard.biesheuvel@linaro.org, john.stultz@linaro.org, keescook@chromium.org, takahiro.akashi@linaro.org, peterz@infradead.org, catalin.marinas@arm.com, kevin.brodsky@arm.com, will.deacon@arm.com, Dave.Martin@arm.com, borntraeger@de.ibm.com, mmarek@suse.com, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, credmonster@gmail.com, labbott@redhat.com, mingo@kernel.org, zijun_hu@htc.com 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 From: Kevin Brodsky AArch32 processes are currently installed a special [vectors] page that contains the sigreturn trampolines and the kuser helpers, at the fixed address mandated by the kuser helpers ABI. Having both functionalities in the same page has become problematic, because: * It makes it impossible to disable the kuser helpers (the sigreturn trampolines cannot be removed), which is possible on arm. * A future 32-bit vDSO would provide the sigreturn trampolines itself, making those in [vectors] redundant. This patch addresses the problem by moving the sigreturn trampolines sources to its own file. Wrapped the comments to reduce the wrath of checkpatch.pl. Signed-off-by: Kevin Brodsky Signed-off-by: Mark Salyzyn v2: - split off from previous v1 'arm64: compat: Add CONFIG_KUSER_HELPERS' - adjust makefile so one line for each of the assembler source modules v3: - rebase --- arch/arm64/kernel/Makefile | 4 ++- arch/arm64/kernel/kuser32.S | 48 ++--------------------------- arch/arm64/kernel/sigreturn32.S | 67 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 arch/arm64/kernel/sigreturn32.S diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f2b4e816b6de..59e1b2b002e5 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -27,8 +27,10 @@ OBJCOPYFLAGS := --prefix-symbols=__efistub_ $(obj)/%.stub.o: $(obj)/%.o FORCE $(call if_changed,objcopy) -arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ +arm64-obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o entry32.o +arm64-obj-$(CONFIG_COMPAT) += sigreturn32.o +arm64-obj-$(CONFIG_COMPAT) += kuser32.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o diff --git a/arch/arm64/kernel/kuser32.S b/arch/arm64/kernel/kuser32.S index 997e6b27ff6a..d15b5c2935b3 100644 --- a/arch/arm64/kernel/kuser32.S +++ b/arch/arm64/kernel/kuser32.S @@ -20,16 +20,13 @@ * * AArch32 user helpers. * - * Each segment is 32-byte aligned and will be moved to the top of the high - * vector page. New segments (if ever needed) must be added in front of - * existing ones. This mechanism should be used only for things that are - * really small and justified, and not be abused freely. + * These helpers are provided for compatibility with AArch32 binaries that + * still need them. They are installed at a fixed address by + * aarch32_setup_additional_pages(). * * See Documentation/arm/kernel_user_helpers.txt for formal definitions. */ -#include - .align 5 .globl __kuser_helper_start __kuser_helper_start: @@ -77,42 +74,3 @@ __kuser_helper_version: // 0xffff0ffc .word ((__kuser_helper_end - __kuser_helper_start) >> 5) .globl __kuser_helper_end __kuser_helper_end: - -/* - * AArch32 sigreturn code - * - * For ARM syscalls, the syscall number has to be loaded into r7. - * We do not support an OABI userspace. - * - * For Thumb syscalls, we also pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ - .globl __aarch32_sigret_code_start -__aarch32_sigret_code_start: - - /* - * ARM Code - */ - .byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_sigreturn - .byte __NR_compat_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_sigreturn - - /* - * Thumb code - */ - .byte __NR_compat_sigreturn, 0x27 // svc #__NR_compat_sigreturn - .byte __NR_compat_sigreturn, 0xdf // mov r7, #__NR_compat_sigreturn - - /* - * ARM code - */ - .byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_rt_sigreturn - .byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_rt_sigreturn - - /* - * Thumb code - */ - .byte __NR_compat_rt_sigreturn, 0x27 // svc #__NR_compat_rt_sigreturn - .byte __NR_compat_rt_sigreturn, 0xdf // mov r7, #__NR_compat_rt_sigreturn - - .globl __aarch32_sigret_code_end -__aarch32_sigret_code_end: diff --git a/arch/arm64/kernel/sigreturn32.S b/arch/arm64/kernel/sigreturn32.S new file mode 100644 index 000000000000..6ecda4d84cd5 --- /dev/null +++ b/arch/arm64/kernel/sigreturn32.S @@ -0,0 +1,67 @@ +/* + * sigreturn trampolines for AArch32. + * + * Copyright (C) 2005-2011 Nicolas Pitre + * Copyright (C) 2012 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * + * AArch32 sigreturn code + * + * For ARM syscalls, the syscall number has to be loaded into r7. + * We do not support an OABI userspace. + * + * For Thumb syscalls, we also pass the syscall number via r7. We therefore + * need two 16-bit instructions. + */ + +#include + + .globl __aarch32_sigret_code_start +__aarch32_sigret_code_start: + + /* + * ARM Code + */ + // mov r7, #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 + // svc #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x00, 0x00, 0xef + + /* + * Thumb code + */ + // svc #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x27 + // mov r7, #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0xdf + + /* + * ARM code + */ + // mov r7, #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 + // svc #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef + + /* + * Thumb code + */ + // svc #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x27 + // mov r7, #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0xdf + + .globl __aarch32_sigret_code_end +__aarch32_sigret_code_end: