Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751358AbdFDMEn (ORCPT ); Sun, 4 Jun 2017 08:04:43 -0400 Received: from mail-bl2nam02on0042.outbound.protection.outlook.com ([104.47.38.42]:37187 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751444AbdFDMEU (ORCPT ); Sun, 4 Jun 2017 08:04:20 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com, Bamvor Jian Zhang Subject: [PATCH 19/20] arm64:ilp32: add vdso-ilp32 and use for signal return Date: Sun, 4 Jun 2017 15:00:08 +0300 Message-Id: <20170604120009.342-20-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: DB6PR02CA0003.eurprd02.prod.outlook.com (10.170.218.144) To BY1PR0701MB1272.namprd07.prod.outlook.com (10.160.108.18) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0701MB1272: X-MS-Office365-Filtering-Correlation-Id: ffaaf7e0-046c-4feb-ed15-08d4ab41c7cb X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1272; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;3:PH1Cyh/i3cepCbq77kDpC0pu7yIYU5c0YSOq1WgFYLI2K3auMkvdk47MArSIC7PUrsLr2uU5etd7mD4agomYLuxhcDRWq+Iemn3cJy7B8Y3Nac55ArmpLWCwgNsdcYLfT1//jCshL6pvZakdwOGFi4VJ1+OBPi979l3TmIFKsqGF2NrWTEwTnQ99hyyxdSZntUc4bsjEYP6bo9VYrmEGfU+PdrNd4xGNV3pTObdV2r+BQkNHSrP1J8f+Zv3c9YsF3qZZTA6v4OyjH86eXTr5cQ5BNwYPK1+3o9LIZggatSqSMdFZSHlcamRu8xPjchkfU472bRuWqbq5dCjUCTnAyg==;25:PxWTTxuBVt5GvJJdntK7ik+TxifBqEAwFEbiNYmKYm2smeObhU7TblrAMovhrcVsOwolH6SGMT6YCrLAnsAetkgxzXxW4aidepiOOL4LANK4VHw+o1IdBGDoBMhqJBkowh+63ujc/m1TvXbny8S8lokMK2boOFksd+BcT94EKTcQSQiNsEm37sbb5jSTJualRCXAC2fRNtfaQwMBmLjDOFx/XzxtGJA6act+LKVCWj+ly7gqN4qcbwqt9l7esOn2z2vRmii1cofwM7kNbxDcC1lw/g0bHstcUynybwnBt7Rb5jEJP/vViHpbPYdMgFWDtsTKmdR72/z/2aW0jIjEP24D8RKsX2jKowzTEYZbOpGhN9Q/G/gFfNEh9R9c2Y9TZLKc6TVRG9zVJO6rQjCTVXbHZaeNRpefwHzAUd7EOY+bqNdeXDqRYvf2FcautqmR8IbjLhTNsY3OwA7ruxcuBPQOF/4aIm/WIWQstEPUXmg= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;31:xNANGPE8KP/FuVsY2J5wLsccssXPuh1wgyBGuMn7KAj9e58J7+V1OBW1qH0HCvWYWQecwIhSKmZgg1uNkrnXO+j2ioN2VjUpPAcKTWbs2RQB7BfqBc46fG+FfvJcz4tuQgceONVjeN5W0ly95wMi7eE/ZfpMk5vacMlEXZEQDWSqJVvmxphQ5so7LteCZnyrtKPCwkujqfTgIaTqRfs6AeoH4+u6JMZNiAB9B/TXMJk=;20:s7I8T5It8jg8oyxptpRSj8cH5J8Afocni6UKjvEAwGYkayvP/0PtVqc3z+NUyL/kwA2qltrCDUgEJbXyXnLLDF9ZlJEGj359eqoEhgGn6sdCZrcFMtT4+TGwxJE2Kh2Y+ME+lscwhuqiiQSt5SWLAZcTiKIFExTOZk2u6I5id5fyVx5qlvF3njdQ6wKq+9smlIZ0S3wRA7LEf9F9/zMpVKTGUTYObs9S0tGVTeMdNR+mGm53kuFgej/79IDDW1WdBipqP5JrvCgThboenk/2C8TWFCUP/7v0m4QPNeaqoHq0+Eo8d/vCD97yJw23s8LPKVpW5vrpVIB/DOzSdNm1HJ7aD27Z442XjzHypnot+r1kb3tYYa+kM+qVjRDjM1ubfHa/5TZH63TSrDFwzQ34qPOLD4gvl9+zBwBYHTc6AqzrHZOSc16fgr2iYhCYrkA4sbkpApnZFC9pckEwXuaetvSfI9ZFSrKMQO/6uRYzo0DKUuRVUEHm1UAg3zIdBVz97TmYut/XwE5hJpQcihYWusNJF9P7dJAKCC1CGBIWOjZRWMl/8O1auEkmWRjwcR4fd2EpPnYF4vbLz0WziTItNWj8M2WktmRGKdNlRlUdkl4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(180628864354917)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0701MB1272;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0701MB1272; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1272;4:b1Q18yMzKfu+lUy0OfFI3LAP3ljVXfgxblXFj8Zi?= =?us-ascii?Q?s5uhj/5V9SWka4hxhLTAE4HMZY+/8lZ5M4H5GL8J8A+pr2YE2SFjyK5XvaR5?= =?us-ascii?Q?xQPlgJuARPH/XjqOsLskVAnM6r8Zo+3JXpPJOMOLRG1ZsCMVJnZ1dxQ2Swtl?= =?us-ascii?Q?qPCcrciT393YLfFxHISZyDqW5Eb+Bq50IU9b7avcr2wEZWmRmlzsKV4b2+YM?= =?us-ascii?Q?MIk/p30yV8M87iOL7APJmGD7tM5trdunEgd3lDxoeeb3az2tC0xpkttaHwjI?= =?us-ascii?Q?krHWZ5WpKGcRXDTTAKhwxZjsV6QNBb+DeYMv1xrX3B1kk+l5mRUOk01OpLsT?= =?us-ascii?Q?/KrV1FRhloFm2Sp6BE11v3uW65L/7vtnp3QTr6jZLt1ZP7j1+lpHXp7GKw4i?= =?us-ascii?Q?m5WFpfAiNMiZLvawGmiqDEj0VqQ6nlykydJwhVF5lx/7c6GlQIWXRE580dmC?= =?us-ascii?Q?7sE3StRiCSvW7q1GPZnks1cbfho2MDJFOOT41RiKVZI8Ww+YdQrhsJyJXTRR?= =?us-ascii?Q?1Bh7SnoD73ApyuYrULbI0KVKHVTPmccDXfy59hhzTf19kawm2EJdJwL9PqpZ?= =?us-ascii?Q?cKm5RFN1YMIsAC8pulYHELD+IucIzI/o9jCfwX4JEQY5KPkpfoY+QAMUzNz/?= =?us-ascii?Q?imktFIPMlYQr+rmtDXLMTSxxzfVtnRDpXg/NCoHiTTcDUGCOKpQUHDdb0dwX?= =?us-ascii?Q?8WwO3d+GZsfMhZhWZkb4D1To4iBgB/XgfpvgJ+bkB13dYNBXX9Li0Jn5yUp4?= =?us-ascii?Q?x1lKVm0EfxMD+hO7elKUE6i+ss6wFfpU+QfaCDdBvaR3teuypKlgFK3lvhaF?= =?us-ascii?Q?Gm5e/xUIvLONMqYoM++p4RsFyXCwakPeKvyBEed4lezWKGVYIz8bpAAyiDu6?= =?us-ascii?Q?KT0i7HzJIbJhVGWToKDkJg+KidOrd/2m/VXgkKYRmvsFaLdUBLIi05SFVpRB?= =?us-ascii?Q?X30b0gFId6x3DB6sE+dlwrgRgQ1HaZVyYE5TVuNUer3qe0uu2DH9SJKQon6C?= =?us-ascii?Q?2Wi8TM9slXAlunDC0heoW4/jhT4ZEurfkUsorOiQx5UJDjfYJuIDgWqsTGIJ?= =?us-ascii?Q?0mNczv0rgYEUKY59m9Ha5uI93OSUwkKwdMdRr2+Y2yr4fHmZazcMnk/KQToi?= =?us-ascii?Q?l7KX/sOYHmFHLJiUF0VAtH22K8VF3Y3E59pl0knRwgL8YKuoHtaFzhGZKq1t?= =?us-ascii?Q?Wy56Pd1CrGHCVpX9auM2iGxM8iOR8btZB1kmOlulMphrNknOO3yAlgJQ+g?= =?us-ascii?Q?=3D=3D?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(39850400002)(39400400002)(39410400002)(6666003)(42882006)(6306002)(2950100002)(6496005)(47776003)(38730400002)(66066001)(36756003)(6486002)(54906002)(478600001)(48376002)(72206003)(2906002)(50466002)(81166006)(76506005)(3846002)(305945005)(53936002)(33646002)(6116002)(5660300001)(42186005)(50986999)(25786009)(50226002)(76176999)(1076002)(4326008)(189998001)(8676002)(7416002)(7406005)(5003940100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1272;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1272;23:lWKFsfrXOn47e0H6IflQGi9tbLmisoO6RrmKkTG?= =?us-ascii?Q?lZNFW0mrZqmhecZZJdTdqJuLkOVPNxZ8PFeZhuE1SehHApWMoUX78mvYL2yf?= =?us-ascii?Q?bhYWo0lmAuWivCDdFb00FKb7it3Mwandiga3PjYgkadH1DS1jir73WmTjmmS?= =?us-ascii?Q?7ub54ml1c6gLGVShvj0cRI6/dC6I14fAmHH8OW+YrBce89ibPI04GxeE+3XV?= =?us-ascii?Q?jLLu97Pao63P0X9vUKhG0+m86brbRYSTLG3mspPG7R33UGji/dYdl8K6ZqKX?= =?us-ascii?Q?uUTA1GL2xAYzFQ23vxlLWVqisiEsHJqLU0JtOa/9VgROmRDxLoQz22303in/?= =?us-ascii?Q?9Trms0MyJbreTXdj6j55wso3Zyw6Fh5BEN6Oe6pLZOeUhped7LQfFTWAgAXk?= =?us-ascii?Q?NxBRif3gEvRwj+kfnfeMHHTCqksLjV4RLrVmUdzUT83t8rI3GWkwTkr9feme?= =?us-ascii?Q?vY3JeXJGCU/ouOzebtYeDCEss1YVsJDHaVlzCp1IJMZy6aRWyILb71aNNwzL?= =?us-ascii?Q?e8oE8mO+ZKOkh0ASaNPACCmeeS8LGi93v3NBnze2WRhTClQRKOtQLvUYeNz6?= =?us-ascii?Q?YVJKwhm3a1HLEYiU1e8hzOHeMMHWNzYgfs0M6Q470uS6nuZRfEblBOLd0giq?= =?us-ascii?Q?jdCDhxn+BA1K8wTtFqZfl9gEtR+9LVn7bvrc3Dl+qkIgPBu1kRRqTnRdHgsS?= =?us-ascii?Q?3jMp6VSfHxjnXd2UW7CmC4qJ6V0ujInBOYc3YXgbWiUEOMmWAj+qHCWeMfBQ?= =?us-ascii?Q?VAvwdnGzj2dE8o5kxJUvT4eRsRwa5LjzHjGILjzSts7caIT9WsUn5Fr9jLw/?= =?us-ascii?Q?/lyLIksxr+PwLbLg7Tdg7yDWaX8h7gsDrEyMnqPKVzAS5K35zOXMjjWkCZZa?= =?us-ascii?Q?WVi4eNd+sbJMg4O6/1+tFP6kchld6+krXRx3Gl6jotf9a+q4y1Ql0yroJf2M?= =?us-ascii?Q?z/Mj4j7q1MPKLN0yq3f27f7ExjJNRp2NOFEVERSrYZ8fv9z4rW5a5J88pD5M?= =?us-ascii?Q?fhj3F+iAs/NoCrweEap9V3hdEiQKy+YMaZCQK4u9+sd/9dTRgRJwsdWPx404?= =?us-ascii?Q?IgR5VBm8=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;6:MgO0scHtWVCeaBzAad55J8arpKPhWMQzI+Bc9MAqafPcdEip2YsJIiqz14tax9eeJdZIN5pxSCPsu3T+8Qq5xfD7Wby0elaZP4JwcgOaSGi+LawIhnoEhbfNdEdfcC667Np9KMeQXdM05SXfRwhpgkJ6vIEaYh+BALrpqjSP4viu9eC0ly853PeXJO7Sl05Q8q/+O79EygOXAgetOAk23ZGpnRB3b86RkCmNXxTFAIgJeUpFv0MRSyyPAvoBdH9Dc/PvUL5dtcv4lrnyTgrZQa4auLJSXLBEfEwPk5etThdgDMEaY8SKEmrce7kf1lqQ6QNNOX+QbEbc0ZiMfihgNj9gauTVAQd1W1NiltiKQo2j1Wiej9+XkOvz/FWVV4yH4L1z7biYbBhaYOuA9QsmcZCFOorPICrpny82dyNZRIXxqw0IKOK+kGAkyuguEux9YAGMo/Wnpy5e9IZzkwI1yHU+qQPOAJPe+Wz3fZ+x7bFGjiEx0ZbiqaTCDkdilW/f+sHaqeHS34t8hCvxVgU+TA== X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;5:UdYEp/dUq1xlJiS70O5H8quqQ6Cnyo75gvHBkSJOuorTLM3z5W5AaZ1dT2iUbd+bilRGRlRXxk5uV+k1FoVpAr/Xpv4ebnsfUBFcjrVNI4om86NtjmbJoqB6LxsK6SwEski7yKPokOVLZ92e2uIw5p2/FY1qQLDvQM27UNFon4LNR2oDq4GqU/AWY+mpsAvU3Ny2j5p89TAvlfOjqGUMMN8/rQbShzCMZkSrKdbXl/uXfz43cdRWtelr0elY2Llelqo2iU45o3Okvqa5epmHCIQ+zAeZTm733e000UFzb8t36TI2liGuQN+i0LCeMBjkF0PeZyy1uKhMpYwJaYRgFCMF5jyYlWWWZcQ8XcK3lQ5b3aS7Fs90PN2oiL6Oz1BtpUe8F8GTNHC1osE2y3PmfGHnwCanaUt+QTy7ZMtS+Y4OJiBXPZYO/J8TwREIODM/1dx/FDlh/kNQBydJD8ur2ZqO9WTFI7ZlM7Ftcf83rPFPqkultDunt+O0xU+G4f+L;24:HEdFGmrQzXTpclRhJh92zWvXe5nSrnYLmqChUvbjTFJdKQWswTDWSaQXicdDRIiWCM816axlER/J66LJ2apaxObhjeV1TifgqHV+E8OC+94= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;7:mO3DXBoar4FNaVAU2OG8J7L/UoR+b51nXlBIV2q+ZKwYQ3jDvYQuqVp1WhRUh0K+UPHV7w3/2/PBT2hHcIvqvNTc43LifwrJQVV89/h1JC46KTtDG4vQrgEcnWCWAJ1P6LQupaloZgNM6M3Sm2tVwbjkZHlam4mdJfFe94QYuutN3VL0ymd5CzoxHW9sL671QPjebmRwNAFqmLteYi8wiYE3gS8jSlxSGIyaKEWB0P7lxhKnmPhzlwO9Ii6n9/FS+swv6htxghjkrvJYoluiEsVoXCQ2r52I72H5crt+OI1C8ZN0eG31CD/KsS135qKdCmSkMGt6iBcKtsKsVhO/OA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:03:57.3555 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1272 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 17667 Lines: 564 From: Philipp Tomsich ILP32 VDSO exports following 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 data page before code pages in sync with commit 601255ae3c98 ("arm64: vdso: move data page before code pages") Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov Signed-off-by: Bamvor Jian Zhang --- arch/arm64/Makefile | 3 + arch/arm64/include/asm/vdso.h | 6 ++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/asm-offsets.c | 7 ++ arch/arm64/kernel/signal.c | 2 + arch/arm64/kernel/vdso-ilp32/.gitignore | 2 + arch/arm64/kernel/vdso-ilp32/Makefile | 80 ++++++++++++++++++++++ arch/arm64/kernel/vdso-ilp32/vdso-ilp32.S | 33 ++++++++++ arch/arm64/kernel/vdso-ilp32/vdso-ilp32.lds.S | 95 +++++++++++++++++++++++++++ arch/arm64/kernel/vdso.c | 65 +++++++++++++++--- arch/arm64/kernel/vdso/gettimeofday.S | 20 +++++- arch/arm64/kernel/vdso/vdso.S | 6 +- 12 files changed, 304 insertions(+), 16 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/Makefile b/arch/arm64/Makefile index 5ddfb3140f7a..ee9f47190d8f 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -152,6 +152,9 @@ archclean: prepare: vdso_prepare vdso_prepare: prepare0 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h +ifeq ($(CONFIG_ARM64_ILP32), y) + $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso-ilp32 include/generated/vdso-ilp32-offsets.h +endif define archhelp echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h index 839ce0031bd5..649a9a416500 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 f3bf1b74bb4a..0e628f67e249 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -58,6 +58,7 @@ arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o arm64-obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-y += $(arm64-obj-y) vdso/ probes/ +obj-$(CONFIG_ARM64_ILP32) += vdso-ilp32/ obj-m += $(arm64-obj-m) head-y := head.o extra-y += $(head-y) vmlinux.lds diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index aec5b6cedc7c..c8a09718e998 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -121,6 +121,13 @@ int main(void) DEFINE(TSPEC_TV_SEC, offsetof(struct timespec, tv_sec)); DEFINE(TSPEC_TV_NSEC, offsetof(struct timespec, tv_nsec)); BLANK(); +#ifdef CONFIG_COMPAT + DEFINE(COMPAT_TVAL_TV_SEC, offsetof(struct compat_timeval, tv_sec)); + DEFINE(COMPAT_TVAL_TV_USEC, offsetof(struct compat_timeval, tv_usec)); + DEFINE(COMPAT_TSPEC_TV_SEC, offsetof(struct compat_timespec, tv_sec)); + DEFINE(COMPAT_TSPEC_TV_NSEC, offsetof(struct compat_timespec, tv_nsec)); + BLANK(); +#endif DEFINE(TZ_MINWEST, offsetof(struct timezone, tz_minuteswest)); DEFINE(TZ_DSTTIME, offsetof(struct timezone, tz_dsttime)); BLANK(); diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index b78f4c255636..a7f201dba9de 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -267,6 +267,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 000000000000..61806c3fd68b --- /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 000000000000..8fac22a8b90e --- /dev/null +++ b/arch/arm64/kernel/vdso-ilp32/Makefile @@ -0,0 +1,80 @@ +# +# 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) + +# Disable gcov profiling for VDSO code +GCOV_PROFILE := n + +# Workaround for bare-metal (ELF) toolchains that neglect to pass -shared +# down to collect2, resulting in silent corruption of the vDSO image. +ccflags-y += -Wl,-shared + +obj-y += vdso-ilp32.o +extra-y += vdso-ilp32.lds +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 > $@ +endef + +include/generated/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) + +# This one should be fine because ILP32 uses the same generic +# __NR_rt_sigreturn syscall number. +$(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 000000000000..46ac0728443c --- /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 000000000000..c82098f7037d --- /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_4.12 { + 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 9d4490251793..71bee9243760 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -37,8 +37,13 @@ #include #include -extern char vdso_start, vdso_end; -static unsigned long vdso_pages __ro_after_init; +extern char vdso_lp64_start, vdso_lp64_end; +static unsigned long vdso_lp64_pages __ro_after_init; + +#ifdef CONFIG_ARM64_ILP32 +extern char vdso_ilp32_start, vdso_ilp32_end; +static unsigned long vdso_ilp32_pages __ro_after_init; +#endif /* * The vDSO data page. @@ -110,7 +115,17 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) } #endif /* CONFIG_AARCH32_EL0 */ -static struct vm_special_mapping vdso_spec[2] __ro_after_init = { +static struct vm_special_mapping vdso_lp64_spec[2] __ro_after_init = { + { + .name = "[vvar]", + }, + { + .name = "[vdso]", + }, +}; + +#ifdef CONFIG_ARM64_ILP32 +static struct vm_special_mapping vdso_ilp32_spec[2] __ro_after_init = { { .name = "[vvar]", }, @@ -118,21 +133,27 @@ static struct vm_special_mapping vdso_spec[2] __ro_after_init = { .name = "[vdso]", }, }; +#endif -static int __init vdso_init(void) +static int __init vdso_init(char *vdso_start, char *vdso_end, + unsigned long *vdso_pagesp, + struct vm_special_mapping *vdso_spec) { int i; + unsigned long vdso_pages; struct page **vdso_pagelist; unsigned long pfn; - 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 *), @@ -145,7 +166,7 @@ static int __init vdso_init(void) /* Grab the vDSO code pages. */ - pfn = sym_to_pfn(&vdso_start); + pfn = sym_to_pfn(vdso_start); for (i = 0; i < vdso_pages; i++) vdso_pagelist[i + 1] = pfn_to_page(pfn + i); @@ -155,7 +176,22 @@ static int __init vdso_init(void) return 0; } -arch_initcall(vdso_init); + +static int __init vdso_lp64_init(void) +{ + return vdso_init(&vdso_lp64_start, &vdso_lp64_end, + &vdso_lp64_pages, vdso_lp64_spec); +} +arch_initcall(vdso_lp64_init); + +#ifdef CONFIG_ARM64_ILP32 +static int __init vdso_ilp32_init(void) +{ + return vdso_init(&vdso_ilp32_start, &vdso_ilp32_end, + &vdso_ilp32_pages, vdso_ilp32_spec); +} +arch_initcall(vdso_ilp32_init); +#endif int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) @@ -163,8 +199,17 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, struct mm_struct *mm = current->mm; unsigned long vdso_base, vdso_text_len, vdso_mapping_len; void *ret; + unsigned long pages = vdso_lp64_pages; + struct vm_special_mapping *vdso_spec = vdso_lp64_spec; + +#ifdef CONFIG_ARM64_ILP32 + if (is_ilp32_compat_task()) { + pages = vdso_ilp32_pages; + vdso_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; diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S index e00b4671bd7c..062a33df4ba5 100644 --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ b/arch/arm64/kernel/vdso/gettimeofday.S @@ -25,6 +25,16 @@ #define NSEC_PER_SEC_LO16 0xca00 #define NSEC_PER_SEC_HI16 0x3b9a +#ifdef __LP64__ +#define PTR_REG(n) x##n +#define OFFSET(n) n +#define DELOUSE(n) +#else +#define PTR_REG(n) w##n +#define OFFSET(n) COMPAT_##n +#define DELOUSE(n) mov w##n, w##n +#endif + vdso_data .req x6 seqcnt .req w7 w_tmp .req w8 @@ -119,7 +129,7 @@ x_tmp .req x8 .if \shift == 1 lsr x11, x11, x12 .endif - stp x10, x11, [x1, #TSPEC_TV_SEC] + stp PTR_REG(10), PTR_REG(11), [x1, #OFFSET(TSPEC_TV_SEC)] mov x0, xzr ret .endm @@ -136,6 +146,8 @@ x_tmp .req x8 /* int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); */ ENTRY(__kernel_gettimeofday) .cfi_startproc + DELOUSE(0) + DELOUSE(1) adr vdso_data, _vdso_data /* If tv is NULL, skip to the timezone code. */ cbz x0, 2f @@ -160,7 +172,7 @@ ENTRY(__kernel_gettimeofday) mov x13, #1000 lsl x13, x13, x12 udiv x11, x11, x13 - stp x10, x11, [x0, #TVAL_TV_SEC] + stp PTR_REG(10), PTR_REG(11), [x0, #OFFSET(TVAL_TV_SEC)] 2: /* If tz is NULL, return 0. */ cbz x1, 3f @@ -182,6 +194,7 @@ ENDPROC(__kernel_gettimeofday) /* int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); */ ENTRY(__kernel_clock_gettime) .cfi_startproc + DELOUSE(1) cmp w0, #JUMPSLOT_MAX b.hi syscall adr vdso_data, _vdso_data @@ -297,6 +310,7 @@ ENDPROC(__kernel_clock_gettime) /* int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); */ ENTRY(__kernel_clock_getres) .cfi_startproc + DELOUSE(1) cmp w0, #CLOCK_REALTIME ccmp w0, #CLOCK_MONOTONIC, #0x4, ne ccmp w0, #CLOCK_MONOTONIC_RAW, #0x4, ne @@ -311,7 +325,7 @@ ENTRY(__kernel_clock_getres) ldr x2, 6f 2: cbz w1, 3f - stp xzr, x2, [x1] + stp PTR_REG(zr), PTR_REG(2), [x1] 3: /* res == NULL. */ mov w0, wzr diff --git a/arch/arm64/kernel/vdso/vdso.S b/arch/arm64/kernel/vdso/vdso.S index 82379a70ef03..a40ae2485430 100644 --- a/arch/arm64/kernel/vdso/vdso.S +++ b/arch/arm64/kernel/vdso/vdso.S @@ -21,12 +21,12 @@ #include #include - .globl vdso_start, vdso_end + .globl vdso_lp64_start, vdso_lp64_end .section .rodata .balign PAGE_SIZE -vdso_start: +vdso_lp64_start: .incbin "arch/arm64/kernel/vdso/vdso.so" .balign PAGE_SIZE -vdso_end: +vdso_lp64_end: .previous -- 2.11.0