From patchwork Thu May 12 00:20:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9076101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2BA31BF29F for ; Thu, 12 May 2016 00:22:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1737B2014A for ; Thu, 12 May 2016 00:22:36 +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 1EC7F2010B for ; Thu, 12 May 2016 00:22:35 +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 1b0eMx-0004i9-Ib; Thu, 12 May 2016 00:20:47 +0000 Received: from mail-bn1on0069.outbound.protection.outlook.com ([157.56.110.69] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b0eMv-0004h5-0e for linux-arm-kernel@lists.infradead.org; Thu, 12 May 2016 00:20:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=4SP2RmIdod0fPe3CEGhx0tQ5VRVYI9X9vqWPslGiaQU=; b=nwpYIM8IXa7sRf5qpuLOCdxK22jWGMI2WqwwXLvWOpJX+t+EoS1RWRE9OO2M6CoK6uFTcCHAVXZHI9BcEo/EUSJVe8CMcRW53yNETuc6hfSmiAG0d1yaWhv4NZ41yXKQabGPdCu+ByY3c6/l3rkMyBlExmiRT+6exQoJElqwGPs= Authentication-Results: arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (95.143.213.121) by DM3PR07MB2235.namprd07.prod.outlook.com (10.164.33.145) with Microsoft SMTP Server (TLS) id 15.1.492.11; Thu, 12 May 2016 00:20:21 +0000 Date: Thu, 12 May 2016 03:20:00 +0300 From: Yury Norov To: , , , Subject: Re: [RFC6 PATCH v6 00/21] ILP32 for ARM64 Message-ID: <20160512002000.GA30997@yury-N73SV> References: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM2PR09CA0049.eurprd09.prod.outlook.com (10.160.228.145) To DM3PR07MB2235.namprd07.prod.outlook.com (10.164.33.145) X-MS-Office365-Filtering-Correlation-Id: b365f590-3732-4873-ff4b-08d379fb349e X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2235; 2:48dMLTbGukGlJENnw7kuyuBhZPRcwULRxf0PpmadYLop3iT4X/+jIG0BiDJ/D0vz9E8bxi24c/cXCa192RvMiBH781YkF37U1alusfwQBcpYoYkizuE8Jnx0TiVg+lplqvr+JlDm7ST/OisNbf4PJFwLmi+c5LGt4EU2u6zCjaCufa9VqsUgHTetTgkelOPU; 3:5zxDLwnIb7BTFy+cV50GHg3GnDub7cZHKdwxm66J/ei+wylmrefhm9hbB8z0NX6TogEoAA7zhQ1z/VfM6K+8w/1JMaNZ0mgoWf1AB1S6UcIMaqQOrG0R1dXolMDTpG0u X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM3PR07MB2235; X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2235; 25:xaSaW1U6JHth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Kp1TODtFPJwGaZdvxIMqLV2Am82J66T5xcLL1r4r1gjr4u8omZGrR57vw1nFbU58LVXzsvrhCi1U8fOC6N7MXBCgmDIFvLB+MWIwNjGw9Z02+2C2OwbnvztPsfM2N5Aooo10mdOELPjcyG6X2mMbs0v6hPlvOhI+YLxLI3JNjC2818y53pRLldh70d/L7GNinks+mRcBGAkHMJX8INuxG+x9MwZM7A+ZLpD1ZaKoysCj1wqFUK/LcYpzBEXvE999rIlU9IFe/0brpK8Tb1G+nt6wmiVDXGQHLa7VXBdaXvj1csjYW65VNPW49jhRMO2LdjdTFkxM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:DM3PR07MB2235; BCL:0; PCL:0; RULEID:; SRVR:DM3PR07MB2235; X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2235; 4:Rg7werJCwPRcVCfGVKV4sQwJfOMlcyDsKNx+nlkj4p/z6LKQQ17fKorzPcYQTOZB+jr/SvPzeJXIlKA6U8J3Zd5kaVjz9opEANqEm64CmPlPM2tcwl4eA7q+MbSFVk7M6AruiC6My2i9xShAAVMkqZKoWtg10AvB9HEYqZoBDCzujub4GwZyRe8MIHkFkd/iyL59EEGkimBNInbJaZ2kQH2NWLQfM59jbQeanLVBM0tsUVj/6ZF6k3GPJWtt8xgLAC6LAkGI3WNfcSFjggCQhDclKF4NwLat4mfB0j0rgT+W32u1+TbOgJZ2qJass/RbMBfrq1E4q/RCzCtUtWbQBjyPhTl53VYw4wRS/yQnMOlNWSerfUapvaTaH3uKx4ij X-Forefront-PRVS: 0940A19703 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(4326007)(47776003)(97756001)(33716001)(66066001)(2906002)(1076002)(2201001)(6116002)(3846002)(23726003)(92566002)(19580405001)(586003)(46406003)(54356999)(50986999)(76176999)(81166006)(19580395003)(83506001)(9686002)(77096005)(575784001)(50466002)(2950100001)(5008740100001)(33656002)(42186005)(189998001)(5004730100002)(5001770100001)(4001350100001)(76506005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR07MB2235; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM3PR07MB2235; 23:7ZdODpAIKsJ2qtbrpqz1ZhX5wCmDnSgFFDMgKLi/U?= =?us-ascii?Q?s2HDJeKJDT00L7pZmPS7+d0HVAYAX4U3eYrd/uxqIVPpGOAFnNGldeUiOnA4?= =?us-ascii?Q?dtFkYmTw4JFc4oV+7JsSPGUMRpQuVh4yxihxeEyKS9A6WfbvwQonEKjenaWk?= =?us-ascii?Q?wJ0bHhweoHOfVow18Y3AFDo3X6FEchaB7WtMEEoQiW3b8MiOWsEVz8HJA5dD?= =?us-ascii?Q?yKN5tAmcfDzHpw4FdVdbUdxdkEe3E3u1JTFnHJnqOOqeyuN7yOR8zPOA8jnT?= =?us-ascii?Q?shD6N5Fm4NaX32wBn4N05jFjrNTz1Wg7cmYhg2eL93jWvVhxV774AJWndUhd?= =?us-ascii?Q?wo06K7rZi9EGFTOcx6czVtnibL5ok0N7eVdPujKAUOko8CBpesczbJcc+1o3?= =?us-ascii?Q?2UrEDhA+giipRVu+gTyBM8RI2ZctIzwaOoeT8FPWhlr3ZW4CkEXcOBCHnzAt?= =?us-ascii?Q?ckXE+bMdvK2TFjdEGQyMMe5R8jgi1+X7V1/OMku1eF0QhAfj//w/WFRLJ3/p?= =?us-ascii?Q?7+cQy6ARUFwkTgONQFeVR47C1VOiIeXO30TXu7AQtNga4QBRa0TlWZr/wvgZ?= =?us-ascii?Q?3nSMd+plXtFFMEoo3nKcuF4WCL6T5zxTUNSATBPd9UcE8j3Ktr08eRbhNHIT?= =?us-ascii?Q?/zSjMJRw+etuCl3YP2GpsCcYq+Ckc7BHy3rc7fL9nyw+ZGnFBjIlLGFx42pB?= =?us-ascii?Q?+2x3tDrgdEnjXYN51JTiKVJQ8xNRIeRBqfJFQrc/rWu8K7bnpFp2u6pFbpVl?= =?us-ascii?Q?bq3Evw361QDffX1kKxfJ9s0sLUJPKSSw0zQvzI+abNnUQLuszoHfyRwhxQnY?= =?us-ascii?Q?ZsGyHBFyGcc6EQ7fQe9UhcqYY/OAmmbMsxU/pgfM+ucuc9VQze1SpFzlA3sJ?= =?us-ascii?Q?s4uG7pLyz0JjptapE8Eu34NG/+ipW7AcCcFW0TtJSLZWkvT9geVd2QoVw3xU?= =?us-ascii?Q?ZnjcWnN/jB0FT1s1oMgae81opUHroehV1KO1MOfD+LSX+bbOwfv5mXUFy7uu?= =?us-ascii?Q?TX9IgRrBJ9GrfM4mfh2AeYsOij7D9QuH+3RqpeU2tpPSQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2235; 5:BCV4yyvsiR+A1Uuul30Wtx5ROZHYupQr2++ZASfjg0zUoy6W4nD8WWmtaqtkOYOtTsy5mrRDmID60bdRqKRzqHfAwbTmjBIz85bFKjbdCKwMAO4AskY6i9AxGrwaQdVA8YUjKxQnX270YF6n64016g==; 24:4/kVNCZh3ipUsOeWsXlI365CJwzLGy7xiJ+n+Z8byuJzWSdKi3OgosPvF1u3Yjc2ngCl4kNvOnMhg4gLTCV5/mrg8m1XMSnyRTDP4cJXjGU=; 7:lLj3vYDx79U19AncpH6NPW4yZHl1c0UKrv3T9SNMhPK3zPrnzH5IfPRFbwSt9jhAePFG1xWhu05WVdWSKMtJx4lgZPoU7v9FC5oohejOxKqvYnQomCD21G6A6O5WWvh7aBZXgmddORTbuTrmuY/i1g//rPifeW5IutAP8C4oB/J2UebGXAJr3AT1tPfODLyK SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2016 00:20:21.2209 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2235 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160511_172045_329262_12846750 X-CRM114-Status: GOOD ( 11.74 ) 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: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, heiko.carstens@de.ibm.com, linux-doc@vger.kernel.org, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, broonie@kernel.org, bamvor.zhangjian@huawei.com, schwab@suse.de, schwidefsky@de.ibm.com, 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=-5.5 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, 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 Hi, I debugged preadv02 and pwritev02 failures and found very weird bug. Test passes {iovec_base = 0xffffffff, iovec_len = 64} as one element of vector, and kernel reports successful read/write. There are 2 problems: 1. How kernel allows such address to be passed to fs subsystem; 2. How fs successes to read/write at non-mapped, and in fact non-user address. I don't know the answer on 2'nd question, and it might be something generic. But I investigated first problem. The problem is that compat_rw_copy_check_uvector() uses access_ok() to validate user address, and on arm64 it ends up with checking buffer end against current_thread_info()->addr_limit. current_thread_info()->addr_limit for ilp32, and most probably for aarch32 is equal to aarch64 one, and so adress_ok() doesn't fail. It happens because on thread creation we call flush_old_exec() to set addr_limit, and completely ignore compat mode there. This patch fixes it. It also fixes USER_DS macro to return different values depending on compat. This patch is enough to handle preadv02 and pwritev02, but problem #2 is still there. Signed-off-by: Yury Norov --- arch/arm64/include/asm/elf.h | 1 + arch/arm64/include/asm/uaccess.h | 2 +- arch/arm64/kernel/binfmt_elf32.c | 1 + arch/arm64/kernel/binfmt_ilp32.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 7a39683..6ba4952 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -146,6 +146,7 @@ typedef struct user_fpsimd_state elf_fpregset_t; do { \ clear_thread_flag(TIF_32BIT_AARCH64); \ clear_thread_flag(TIF_32BIT); \ + set_fs(TASK_SIZE_64); \ } while (0) #define ARCH_DLINFO \ diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 19cfdc5..3b0dd8d 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -51,7 +51,7 @@ #define KERNEL_DS (-1UL) #define get_ds() (KERNEL_DS) -#define USER_DS TASK_SIZE_64 +#define USER_DS TASK_SIZE #define get_fs() (current_thread_info()->addr_limit) static inline void set_fs(mm_segment_t fs) diff --git a/arch/arm64/kernel/binfmt_elf32.c b/arch/arm64/kernel/binfmt_elf32.c index 5487872..2e8d9f3 100644 --- a/arch/arm64/kernel/binfmt_elf32.c +++ b/arch/arm64/kernel/binfmt_elf32.c @@ -12,6 +12,7 @@ do { \ clear_thread_flag(TIF_32BIT_AARCH64); \ set_thread_flag(TIF_32BIT); \ + set_fs(TASK_SIZE_32); \ } while (0) #define COMPAT_ARCH_DLINFO diff --git a/arch/arm64/kernel/binfmt_ilp32.c b/arch/arm64/kernel/binfmt_ilp32.c index a934fd4..a8599c6 100644 --- a/arch/arm64/kernel/binfmt_ilp32.c +++ b/arch/arm64/kernel/binfmt_ilp32.c @@ -59,6 +59,7 @@ static void cputime_to_compat_timeval(const cputime_t cputime, do { \ set_thread_flag(TIF_32BIT_AARCH64); \ clear_thread_flag(TIF_32BIT); \ + set_fs(TASK_SIZE_32); \ } while (0) #undef ARCH_DLINFO