From patchwork Thu Jan 14 17:23:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8034671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DA5F29F744 for ; Thu, 14 Jan 2016 17:34:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 785B520430 for ; Thu, 14 Jan 2016 17:34:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0BBAB2037E for ; Thu, 14 Jan 2016 17:34:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJllm-0003lU-Ie; Thu, 14 Jan 2016 17:33:10 +0000 Received: from mail-by2on0054.outbound.protection.outlook.com ([207.46.100.54] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJlhI-000735-JU for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2016 17:28:59 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by CO2PR07MB619.namprd07.prod.outlook.com (10.141.228.151) with Microsoft SMTP Server (TLS) id 15.1.361.13; Thu, 14 Jan 2016 17:28:06 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 18/21] arm64:ilp32: add vdso-ilp32 and use for signal return Date: Thu, 14 Jan 2016 20:23:15 +0300 Message-ID: <1452792198-10718-19-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> References: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: DB5PR02CA0040.eurprd02.prod.outlook.com (25.161.237.50) To CO2PR07MB619.namprd07.prod.outlook.com (10.141.228.151) X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 2:0LtwIEoUvbaHfkLGWku6Nvs3GXCakqzctDpEiAJZzOBnh29ZigRzZ1JInlcjIYEyOFQFymWllk+X4rBMrWf21c16jpVOmfcc/pY4LPbPckETHd1K8G0k4BCBL8+kg4V921MJAovxdSLEsp4wyVtoHA==; 3:oDIfzUlKMy8xeULRTAOHjrVC/PiqMl4pnzhq/6B3AFfWbrgGnaoapy6+sPgPcpimOnl+mBsF+pR79dntA7NOSjTey57Fnli3L4iQ4ALuOvm/G14a7+kyZogDwTelSnzv; 25:3/wB5Orml40M6W9FfZisTQnjZ3ZYGCHw2jHVXrg6sqQBV4HMZqzaI5Py0hjH6+pGLWiqEuqNLSLHRdN8ZVBHlttJDEsrdTRhVH0FmYK0JBu4B69YVqxuCJfZ25uFq06IUKWL63PpUbHKXF5SJLyJvy2tSSLS21YsakEDWDhl8GsvAmXCLzZmMKXW9EdKrq1KI0FBAYSMaQB7rhNYnujx9xvZnA89ciakZhQsV5O5Qzipld72UFJzHnHFHOpt73no X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB619; X-MS-Office365-Filtering-Correlation-Id: 66b8383e-9b17-41cb-c58c-08d31d081111 X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 20:XNWYtYdQbyheKukh1QFApCHsFtJHYIjUAFE04STlhi3vMEnrQaUwQF/1U5z3amw7DmwqmoMdQF21thQe6LKYWUctZhPUwWHSFOno3DGC7yKGy/C/f/bB4fInCIGRXH7nR99ef/tVhwOOM1TSNvvDnrfr2/aBoNGldUA+13M1UvUT8JaSwE5aF26dEJlzWusfgOas/NEDki1GiAFsrlN/0DksFy/stwSOJB6p0Ik+g+7CyNEh5LxUq8sFGsPVGawYKWdRCud4jWwA8/EYrdgazw5jKiKxrGudqIOuODKhozGTuzGLLGb0Ue0mlDugO8mBWw11LP2NWUwd24X1LdlYX7KGCA+GXSJ9XKqAAs/IrAX2tKJV390HYr76tEh/V3CamATEWSV36vLdExm8H7UTAHisYnVC9vmbWExTOtvE1aBMI9ML9iF30t1Wh1nZ2krk3DwbK4WU05BdCRU2wm3ay3xZAEP3Tyn1yabS4Kv5RVwgCyicbvAiSk4knJIZOHNsk7Ixpg4iTtbs0cqkzpcI1Y+wvOwz8GA3Z4qAh1N1pibYdJxa1c9FIUOGGfHcpUjh9o6Dcg0Nc0FJcusDrjy38mZNJOZXQxnZ+TSZRkOI00Q= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187)(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:CO2PR07MB619; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB619; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 4:qybLz2tEd0pCq0hIX7tck3qcroIvyB0X3QDY/NHRqr0ZLWTMV1Gi+yYKWni8TTIR+/mnJG/MmbwO2QsoB/zyfIzBo3A1SHmb8wDRjRbyUMg74+mAEs4OUcT5jwkZQxvDryp0BBoCi6DguciUumM03iTL2FE14Xfq5EGk80zmisFL5MCr41Le2r20lciVsl5UwNeOSdC1kxRWkSf+4hLFkBczOb0RG25fwub5lslVoYApWZEY/lmp65apBEl3ZMZYGf0bkLYm9vKk08STdJ8NHr6rhdPZDLW985tCxr3mrqUU4B0Pb7SwUlLdOHgP0BdZRetFKm4wK00JK9wPElO8ZzvZX7By19jBE+LE462Zv8NfXlNoyxM8W6HAZKaIhNV6oV6mvTSvNLbqrjvOK7b5Y8v+b1ww7y28sG9d6K8ZhBcus6KbxKcrImYARgkLe69SU61/e0YAqdlOZN5j8nHD3g== X-Forefront-PRVS: 08213D42D3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(5004730100002)(101416001)(106356001)(97736004)(586003)(66066001)(81156007)(3846002)(5008740100001)(2906002)(5003940100001)(48376002)(36756003)(1096002)(19580395003)(2201001)(5001960100002)(189998001)(87976001)(2950100001)(50466002)(42186005)(33646002)(6116002)(229853001)(77096005)(40100003)(47776003)(105586002)(50986999)(122386002)(76506005)(4326007)(50226001)(19580405001)(5001770100001)(92566002)(15975445007)(76176999)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB619; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB619; 23:qS8kX3znUazclUGWtybPJ68GIJjiicnmQixs0X/QGS?= =?us-ascii?Q?xbieB3py3ZQmjad2VhVTbfzkfc/Irj/F7IhCgXhE46yUgevdrnj8mbrCF7Z5?= =?us-ascii?Q?ruQlR4uuRpJljkJuB8YXt6xf25KFZD2X6D9MFT4e5KwZi+UBBfXdqoDWulO9?= =?us-ascii?Q?6qJIa2OMJlbu+12qbuG/2PQlJIJpP1rb31SmVFdvrjrmbhIoy5E9A1tHkY8G?= =?us-ascii?Q?NlJnsbja7/QEtC5j0KJda1hJIfPltGVR3szsQ5TeHjVSX1cQq5DFBsM1elGC?= =?us-ascii?Q?TxyNdKMii8a+8ti0FRauPzH240IUFz9VjXui+aVtco3PiH73TG0Qw5v1eaLs?= =?us-ascii?Q?zouMT7oSXtXk4F8V9F2A5ZtUDDVM8vaJO8rIKhc0Jta6dq16g0ZdBRIrHkZt?= =?us-ascii?Q?+8o3+ZmX0wZfFI9HKQhe5opeXQL8bPwozSLtUDdkrYqGl3+NuqTLEFRwHZIT?= =?us-ascii?Q?5lV/txO2X6NRYVdQMRRhDfsvrXczOuOaIwDX1d0bDxKqYSeSU2D3LJbccPYy?= =?us-ascii?Q?WfdG4oJ9MtvYfjPNC42LfSl3zaMtVFN6V/dA4jZpK7RJdXKNx6yFeTVClQRK?= =?us-ascii?Q?GD9O7aqRhs6jaKyNjgCd8bpoVz9GbR3Gi++KyJIbEa5Sv+jZlmw760oGkKqs?= =?us-ascii?Q?tn4DALj7GDvPC6uq27xJ60IYc1L2vHR0QHvLkMN/I/VUxElDp3fqIiEUmfLo?= =?us-ascii?Q?f4gwKtcdDvYshg/ta/reXcWhZ9UZ5LTE3VDjFVaO0VXD6LjCKR9HrXzvI2ju?= =?us-ascii?Q?8oN1iQnsHnWvvIPESGYdZ1E/+WwL/w9v9OGApJEXA6gJONTFPsa4GYE7vdqU?= =?us-ascii?Q?HqxKs7GBSXefRDPrN+TO410OtdQ3Y743Wa/l/BdTWg13iYrGgJPc0skMKSiX?= =?us-ascii?Q?CrqA33ZqPqYTNz3UX0LZQv8ntNnIVnvspn2tEpoUlDboRVi7FPcoTIbG0CQ4?= =?us-ascii?Q?FZWu96Sz/jqZIBp13tjyD8kuAjh9NSycwpOO6zUOPB7WDIUkqILXlz4yri8K?= =?us-ascii?Q?uCuORCBq3R5oCprxOR3j+kuLz+eexrxg6Yu0SFeuxwLA5zIYIi33BbRpQ7rP?= =?us-ascii?Q?R6jyAjYoTuoaFcltxQPIBASwuKwOjFrmoNUsZMScH1calqzxBCjCUfcLZ09v?= =?us-ascii?Q?JpDK/170b3v+V94Zhfp26YEmP/MfO2TV3nt+pOgHwioRS6FV9+cg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 5:Tug0eIIGcQN/ado9qpk3PPM3TOs8wOvY4j0gE66BjtPQpHIaNloOcQUZoz2ldQ0plSwjMm2smU8e2JkNOYnRe2Fd6HEkO1e7WSQmiuT4JDMedNqMq9h/l2ZtJSpcGH3OOt2KbXPpOIdaQr+U+vazRA==; 24:2tJnc2ZRt1s/VBNsMe40OxDGPxnhVJpK1Vh9t/mJqiSjo4EbKTVl7OFy7OmNYLCBY50kkZu9e00avZ/eT3oxyp+BKAWxOZYMf6QGHuRnRn8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2016 17:28:06.8005 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB619 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160114_092833_087078_948F27E5 X-CRM114-Status: GOOD ( 14.71 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, jan.dakinevich@gmail.com, schwidefsky@de.ibm.com, Nathan_Lynch@mentor.com, Philipp Tomsich , joseph@codesourcery.com, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Philipp Tomsich ILP32 VDSO exports next symbols: __kernel_rt_sigreturn; __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; What shared object to use, kernel selects depending on result of is_ilp32_compat_task() in arch/arm64/kernel/vdso.c, so it substitutes correct pages and spec. Adjusted to move the move data page before code pages in sync with commit 601255ae3c98fdeeee3a8bb4696425e4f868b4f1 Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov --- arch/arm64/include/asm/vdso.h | 6 ++ arch/arm64/kernel/Makefile | 5 ++ arch/arm64/kernel/signal.c | 2 + arch/arm64/kernel/vdso-ilp32/.gitignore | 2 + arch/arm64/kernel/vdso-ilp32/Makefile | 72 ++++++++++++++++++++ arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S | 33 ++++++++++ arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S | 95 +++++++++++++++++++++++++++ arch/arm64/kernel/vdso.c | 61 ++++++++++++++--- 8 files changed, 266 insertions(+), 10 deletions(-) create mode 100644 arch/arm64/kernel/vdso-ilp32/.gitignore create mode 100644 arch/arm64/kernel/vdso-ilp32/Makefile create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S create mode 100644 arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h index 839ce00..649a9a4 100644 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -29,6 +29,12 @@ #include +#ifdef CONFIG_ARM64_ILP32 +#include +#else +#define vdso_offset_sigtramp_ilp32 +#endif + #define VDSO_SYMBOL(base, name) \ ({ \ (void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index c846626..19d7e17 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -46,6 +46,7 @@ arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o arm64-obj-$(CONFIG_ACPI) += acpi.o obj-y += $(arm64-obj-y) vdso/ +obj-$(CONFIG_ARM64_ILP32) += vdso-ilp32/ obj-m += $(arm64-obj-m) head-y := head.o extra-y += $(head-y) vmlinux.lds @@ -53,3 +54,7 @@ extra-y += $(head-y) vmlinux.lds # vDSO - this must be built first to generate the symbol offsets $(call objectify,$(arm64-obj-y)): $(obj)/vdso/vdso-offsets.h $(obj)/vdso/vdso-offsets.h: $(obj)/vdso + +# vDSO - this must be built first to generate the symbol offsets +$(call objectify,$(arm64-obj-y)): $(obj)/vdso-ilp32/vdso-ilp32-offsets.h +$(obj)/vdso-ilp32/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32 diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index f8d4c92..0648aa5 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -241,6 +241,8 @@ void setup_return(struct pt_regs *regs, struct k_sigaction *ka, if (ka->sa.sa_flags & SA_RESTORER) sigtramp = ka->sa.sa_restorer; + else if (is_ilp32_compat_task()) + sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp_ilp32); else sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); diff --git a/arch/arm64/kernel/vdso-ilp32/.gitignore b/arch/arm64/kernel/vdso-ilp32/.gitignore new file mode 100644 index 0000000..61806c3 --- /dev/null +++ b/arch/arm64/kernel/vdso-ilp32/.gitignore @@ -0,0 +1,2 @@ +vdso-ilp32.lds +vdso-ilp32-offsets.h diff --git a/arch/arm64/kernel/vdso-ilp32/Makefile b/arch/arm64/kernel/vdso-ilp32/Makefile new file mode 100644 index 0000000..c8f5472 --- /dev/null +++ b/arch/arm64/kernel/vdso-ilp32/Makefile @@ -0,0 +1,72 @@ +# +# Building a vDSO image for AArch64. +# +# Author: Will Deacon +# Heavily based on the vDSO Makefiles for other archs. +# + +obj-ilp32-vdso := gettimeofday-ilp32.o note-ilp32.o sigreturn-ilp32.o + +# Build rules +targets := $(obj-ilp32-vdso) vdso-ilp32.so vdso-ilp32.so.dbg +obj-ilp32-vdso := $(addprefix $(obj)/, $(obj-ilp32-vdso)) + +ccflags-y := -shared -fno-common -fno-builtin +ccflags-y += -nostdlib -Wl,-soname=linux-ilp32-vdso.so.1 \ + $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) + +obj-y += vdso-ilp32.o +extra-y += vdso-ilp32.lds vdso-ilp32-offsets.h +CPPFLAGS_vdso-ilp32.lds += -P -C -U$(ARCH) -mabi=ilp32 + +# Force dependency (incbin is bad) +$(obj)/vdso-ilp32.o : $(obj)/vdso-ilp32.so + +# Link rule for the .so file, .lds has to be first +$(obj)/vdso-ilp32.so.dbg: $(src)/vdso-ilp32.lds $(obj-ilp32-vdso) + $(call if_changed,vdso-ilp32ld) + +# Strip rule for the .so file +$(obj)/%.so: OBJCOPYFLAGS := -S +$(obj)/%.so: $(obj)/%.so.dbg FORCE + $(call if_changed,objcopy) + +# Generate VDSO offsets using helper script +gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh +quiet_cmd_vdsosym = VDSOSYM $@ +define cmd_vdsosym + $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ && \ + cp $@ include/generated/ +endef + +$(obj)/vdso-ilp32-offsets.h: $(obj)/vdso-ilp32.so.dbg FORCE + $(call if_changed,vdsosym) + +# Assembly rules for the .S files +#$(obj-ilp32-vdso): %.o: $(src)/../vdso/$(subst -ilp32,,%.S) +# $(call if_changed_dep,vdso-ilp32as) + +$(obj)/gettimeofday-ilp32.o: $(src)/../vdso/gettimeofday.S + $(call if_changed_dep,vdso-ilp32as) + +$(obj)/note-ilp32.o: $(src)/../vdso/note.S + $(call if_changed_dep,vdso-ilp32as) + +$(obj)/sigreturn-ilp32.o: $(src)/../vdso/sigreturn.S + $(call if_changed_dep,vdso-ilp32as) + +# Actual build commands +quiet_cmd_vdso-ilp32ld = VDSOILP32L $@ + cmd_vdso-ilp32ld = $(CC) $(c_flags) -mabi=ilp32 -Wl,-n -Wl,-T $^ -o $@ +quiet_cmd_vdso-ilp32as = VDSOILP32A $@ + cmd_vdso-ilp32as = $(CC) $(a_flags) -mabi=ilp32 -c -o $@ $< + +# Install commands for the unstripped file +quiet_cmd_vdso_install = INSTALL $@ + cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ + +vdso-ilp32.so: $(obj)/vdso-ilp32.so.dbg + @mkdir -p $(MODLIB)/vdso + $(call cmd,vdso_install) + +vdso_install: vdso-ilp32.so diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S new file mode 100644 index 0000000..46ac072 --- /dev/null +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 ARM Limited + * + * 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 . + * + * Author: Will Deacon + */ + +#include +#include +#include +#include + + __PAGE_ALIGNED_DATA + + .globl vdso_ilp32_start, vdso_ilp32_end + .balign PAGE_SIZE +vdso_ilp32_start: + .incbin "arch/arm64/kernel/vdso-ilp32/vdso-ilp32.so" + .balign PAGE_SIZE +vdso_ilp32_end: + + .previous diff --git a/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S new file mode 100644 index 0000000..ddc63fd --- /dev/null +++ b/arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S @@ -0,0 +1,95 @@ +/* + * GNU linker script for the VDSO library. + * + * Copyright (C) 2012 ARM Limited + * + * 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 . + * + * Author: Will Deacon + * Heavily based on the vDSO linker scripts for other archs. + */ + +#include +#include +#include + +SECTIONS +{ + PROVIDE(_vdso_data = . - PAGE_SIZE); + . = VDSO_LBASE + SIZEOF_HEADERS; + + .hash : { *(.hash) } :text + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + + .note : { *(.note.*) } :text :note + + . = ALIGN(16); + + .text : { *(.text*) } :text =0xd503201f + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + + .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr + .eh_frame : { KEEP (*(.eh_frame)) } :text + + .dynamic : { *(.dynamic) } :text :dynamic + + .rodata : { *(.rodata*) } :text + + _end = .; + PROVIDE(end = .); + + /DISCARD/ : { + *(.note.GNU-stack) + *(.data .data.* .gnu.linkonce.d.* .sdata*) + *(.bss .sbss .dynbss .dynsbss) + } +} + +/* + * We must supply the ELF program headers explicitly to get just one + * PT_LOAD segment, and set the flags explicitly to make segments read-only. + */ +PHDRS +{ + text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ + dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ + note PT_NOTE FLAGS(4); /* PF_R */ + eh_frame_hdr PT_GNU_EH_FRAME; +} + +/* + * This controls what symbols we export from the DSO. + */ +VERSION +{ + LINUX_2.6 { + global: + __kernel_rt_sigreturn; + __kernel_gettimeofday; + __kernel_clock_gettime; + __kernel_clock_getres; + local: *; + }; +} + +/* + * Make the sigreturn code visible to the kernel. + */ +VDSO_sigtramp_ilp32 = __kernel_rt_sigreturn; diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 26352a6..521a8e4 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -40,6 +40,12 @@ extern char vdso_start, vdso_end; static unsigned long vdso_pages; static struct page **vdso_pagelist; +#ifdef CONFIG_ARM64_ILP32 +extern char vdso_ilp32_start, vdso_ilp32_end; +static unsigned long vdso_ilp32_pages; +static struct page **vdso_ilp32_pagelist; +#endif + /* * The vDSO data page. */ @@ -109,24 +115,29 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) } #endif /* CONFIG_AARCH32_EL0 */ -static struct vm_special_mapping vdso_spec[2]; - -static int __init vdso_init(void) +static int __init vdso_init_common(char *vdso_start, char *vdso_end, + unsigned long *vdso_pagesp, + struct page ***vdso_pagelistp, + struct vm_special_mapping* vdso_spec) { int i; + unsigned long vdso_pages; + struct page **vdso_pagelist; - if (memcmp(&vdso_start, "\177ELF", 4)) { + if (memcmp(vdso_start, "\177ELF", 4)) { pr_err("vDSO is not a valid ELF object!\n"); return -EINVAL; } - vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT; + vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT; + *vdso_pagesp = vdso_pages; pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n", - vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data); + vdso_pages + 1, vdso_pages, vdso_start, 1L, vdso_data); /* Allocate the vDSO pagelist, plus a page for the data. */ vdso_pagelist = kcalloc(vdso_pages + 1, sizeof(struct page *), GFP_KERNEL); + *vdso_pagelistp = vdso_pagelist; if (vdso_pagelist == NULL) return -ENOMEM; @@ -135,7 +146,7 @@ static int __init vdso_init(void) /* Grab the vDSO code pages. */ for (i = 0; i < vdso_pages; i++) - vdso_pagelist[i + 1] = virt_to_page(&vdso_start + i * PAGE_SIZE); + vdso_pagelist[i + 1] = virt_to_page(vdso_start + i * PAGE_SIZE); /* Populate the special mapping structures */ vdso_spec[0] = (struct vm_special_mapping) { @@ -150,16 +161,46 @@ static int __init vdso_init(void) return 0; } + +static struct vm_special_mapping vdso_spec[2]; + +static int __init vdso_init(void) +{ + return vdso_init_common(&vdso_start, &vdso_end, + &vdso_pages, &vdso_pagelist, + vdso_spec); +} arch_initcall(vdso_init); +#ifdef CONFIG_ARM64_ILP32 +static struct vm_special_mapping vdso_ilp32_spec[2]; + +static int __init vdso_ilp32_init(void) +{ + return vdso_init_common(&vdso_ilp32_start, &vdso_ilp32_end, + &vdso_ilp32_pages, &vdso_ilp32_pagelist, + vdso_ilp32_spec); +} +arch_initcall(vdso_ilp32_init); +#endif + int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) { struct mm_struct *mm = current->mm; unsigned long vdso_base, vdso_text_len, vdso_mapping_len; void *ret; + unsigned long pages = vdso_pages; + struct vm_special_mapping *spec = vdso_spec; + +#ifdef CONFIG_ARM64_ILP32 + if (is_ilp32_compat_task()) { + pages = vdso_ilp32_pages; + spec = vdso_ilp32_spec; + } +#endif - vdso_text_len = vdso_pages << PAGE_SHIFT; + vdso_text_len = pages << PAGE_SHIFT; /* Be sure to map the data page */ vdso_mapping_len = vdso_text_len + PAGE_SIZE; @@ -171,7 +212,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, } ret = _install_special_mapping(mm, vdso_base, PAGE_SIZE, VM_READ|VM_MAYREAD, - &vdso_spec[0]); + &spec[0]); if (IS_ERR(ret)) goto up_fail; @@ -180,7 +221,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, ret = _install_special_mapping(mm, vdso_base, vdso_text_len, VM_READ|VM_EXEC| VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, - &vdso_spec[1]); + &spec[1]); if (IS_ERR(ret)) goto up_fail;