From patchwork Fri Apr 14 10:09:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 9681009 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 8328760386 for ; Fri, 14 Apr 2017 10:16:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73F0F28663 for ; Fri, 14 Apr 2017 10:16:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 684472866A; Fri, 14 Apr 2017 10:16:25 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID 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 D6DE628663 for ; Fri, 14 Apr 2017 10:16:24 +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: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=t2jNPlP6WDmuu80gczd464yKgLh7Q5q6jpjISEwSMhY=; b=kxv87i9DfZZECR y8Mxafqs/kPnBvRy/iuZRJw+CBY0HepnTTSrJy9HmjXHWAUnljlTjXxAt/6LYpslHUtzXlxae4Xdn y382S3x4ZxnJADn6I9/7j3kNfjOY4rBDwMqfRZ1W6Lsshp6Xgxi3TNcc8MyYD8oj+A+/vgWsOnAfM 01pBka0l9U/v8lVy5DcSmH9r0LyWc1g9A6N9aRhKTOcTZgoLC0/C5DYlC4Sm4BNVd31Ozosydolxa UBM9OBeJdq62hevEbJNCaSl2HshAwWhyaTseaZEPjSxVgW2v8BsGHWN7UFCxOaI+a2vB8RhtZrLNA Nk+18Rpn7AJP0NA8UtJA==; 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 1cyyH9-0000iB-Hh; Fri, 14 Apr 2017 10:16:23 +0000 Received: from mail-he1eur01on0096.outbound.protection.outlook.com ([104.47.0.96] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cyyFL-0005Qr-QT for linux-arm-kernel@lists.infradead.org; Fri, 14 Apr 2017 10:14:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NZUCAtwsjPIypNdfiaXpFy03p8tXnBAes0thR36N3xI=; b=Kl8/GQ8d5zl0KBkHvje1AuUwFQVtndLGRgyW5WKe06P0yZSzuRRIFe+RYSU1DCpxy8MO0CxLcE/ihLJtMsYP987a7hfrpjZx5sz6uSmhXqHVzsf+KPuU0dakv9ujhwH3Ph7911X05zrp+4+MVwDl7eYWICDwRbei6Oipx7Vhc6I= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=virtuozzo.com; Received: from dsafonov.sw.ru (195.214.232.6) by AM5PR0801MB1732.eurprd08.prod.outlook.com (10.169.247.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Fri, 14 Apr 2017 10:14:02 +0000 From: Dmitry Safonov To: Subject: [PATCH] ARM/shmem: Drop page coloring align for non-VIPT CPUs Date: Fri, 14 Apr 2017 13:09:53 +0300 Message-ID: <20170414100953.4703-1-dsafonov@virtuozzo.com> X-Mailer: git-send-email 2.12.2 MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: VI1PR08CA0038.eurprd08.prod.outlook.com (10.164.95.48) To AM5PR0801MB1732.eurprd08.prod.outlook.com (10.169.247.10) X-MS-Office365-Filtering-Correlation-Id: eb16240a-8e62-47b3-d048-08d4831efa3f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:AM5PR0801MB1732; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1732; 3:ssCe1YxWY30DhyVCizrbDiWr/+/HVoXNRcFTQjOL85J0XiwOyHXi3EyHL5WX8TnjLN8YkRclAjahXuENzZunOh6qSzO467G2RLVOcY9VU2svCvbTp93UZOukHlmXii6bDybPzoYnE0atdyHEM+P1Te9rfSWDM6JvmWpFe3xHVZiSRkezbW9pgiknGp5lhRu8ewX2BD4tpAtGf/k/xeLOHrWm4/Kx3qL987PgVbu9hXIPr3nvuNR9VwjYJ3GQ6Jx7bYDpHb9r+HrdqvSar5W+hMrLbIaJnhh0efj8a6f2iPfWE2pk+qL782ja4Tk1fzaXBvFPLara9UW4Cy8VnAZeaw==; 25:BpxFnC+pzJ0BwAg6Ob2tG2PwxJXgA/Op/Cwrq51ZmDFgvqZ96HECSoWEmuOIdGXkOL/cHDxbxKtcoUc3AQX6MOmhYPlv01MkfgZAjDERpRX4RK2UATnTv9JONEOOOaVhl46gdO7Rum1kGz0lCKkPbbLjaN0ybdSiVwUgajMWKTrq/5o5f9kgXNoFSchSkQHuFy6otcYkJNQYR9UD8iYwtBeeeisWAC4xbs16oCnVzNNkgscO50NkQ9gon8D12Kbzz8uQjKRfwVG2EXz2kQK3oI6Wev3jWB1uD68iDAt8Kd1VvOqKpCCVK+gd+5C2co28EHSiAQeJlD8AUB5T1rxqskfu3oi5QMTa6KXfzBBJQ5OYWK7qWG/FkJG9iluRBDDFhHvxl/aE+HCDeX+zCzBWs8ANNryfgpUIlTYhNwp+gxYIXFSOl7canSIQ7/kK9RlOU4QNQAIUnUGXLwOA5hbr8Q== X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1732; 31:IzuTPOXJZvy2SX+i4G29zuy8Es8hE3pp88NlG9t5BQd1oy6CIdZSzxm6E5RYhk3kwdNaouYAt1DRGf4gf51NWe6JeeZ2LuxvclnY2XhaCTvmAibWEedL1e1Gsd+ddxo4f28A4tRfUPTgcwj/LjIx2XhL5gq4jtILv0wL6T8WXPzIOU7SMfmBtSzX+sYgL/Dkrm1Qii9pTMTsGBFHW9XAfj8/CiRr4P4VOUptR6ciOhE=; 20:66oDYG6pPHnh3a9t3v35aROc1b1eX+ZL+BPGfWBGtmM5Pu/4vXsguaPJxS06GaGpjBAUCtpdD7QkYvpuRdrdihmWs7GG4Z5yfM/ib/z9ZqDMJIjMwXBBNMogPpH96lOjMZCynLSEk8AS5xXoG+OYqJtF8+4yhjsYkzR3e6dzwi8KZX0+1EF8TfoEshD5f1ckIdx74rn12kT81UYqkn5H90NrZ9rMdZcGUalsUapvNHqnnyl/1x2Msu0Ui/fgnTMcaR+gze+cigWOc8Yh68h4AI7U1eF0fB4crk5HQwD+cA+FQIbvuiZoz2OWd4g6UwlqmDfSj9GJH/ZLHqUrZqwB8BSGQDJYUcL8f+hgwvdKa97hdm31PI1tmNLz709JDQ8G+U0uqBrfqcWDUx7uoY/KoeodXSS8+qvezuevQ+UccrA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(258649278758335); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(6072148); SRVR:AM5PR0801MB1732; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1732; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1732; 4:+zjZP/XyilUcqNS5V/u4JrmiRek4xA/aWGVCiBMdim+eH6tKRzVpdNb6RWoCYBV1PCntul8SB/Sxq88WDDp2umf/1UsfSRenCf392DzHbUe1LbCCmDXPaT4PcBXkErB+5JjOSzgyojPPB47GYmoOscODGct655aZuD0y8Gc8515jyMEuTVJmKZeZjhf/gFO0oMXNu4vGukb14RPILk0rRkllsn++A9zSpae1hQ8JHIXrTZEcWDM36pEjGB0y4CRmfibVjY278IjEj7MbkVz/dLlYT0IgWQdqk7liePE6qHzwIH2QnU1swZgc8aBrpaq2Xv1DBgI/PlKaIcnRNRmcNh4kialp39APV94DY+QxxijTTEgNt4MNw8JtJHa6fu5JUkBtZPsfTaozZE8fIgWuyKQZkYCIrWMJWlWUeD8PvqobxkOXLAZJDVPRPi8fDpAiFGTf5ioyxILfonHpYhMkHwMKWjry9xbGyltWA3wMmsvGVgLVs5epD0OJZ2g3H1FbMgcs7RB3NsoeX0CMNcrg/TaZEk6lDPYMZPCF1A1gETHDpGxZTxop1LnkNsKvwQcpRVYY8+frDy3gYOYwN5alkffESIqQSbBOk49j/0PNNyl/kJtptZ/ofhsjzHSWIrA3I1x/AgjMzELcfacIgo4qQQlokuIJCPVe2j0pjEJf3Z192+x0xRsdA0ITew2wWylUrnueMBwKjq1HDbdQOy9+BVRVxCOhY38zI4udyb8JavTbkAFfiLcYF5rfQbJ374dkzk93VKEpDf07UST10RtuVZE6kMhogOKP7iZYUhT+VkM= X-Forefront-PRVS: 02778BF158 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39410400002)(39400400002)(39830400002)(39450400003)(6916009)(4326008)(81166006)(966004)(6306002)(6666003)(6486002)(8676002)(6512007)(1076002)(25786009)(50226002)(53936002)(36756003)(3846002)(66066001)(6116002)(47776003)(2351001)(86362001)(2906002)(110136004)(107886003)(38730400002)(5660300001)(189998001)(7736002)(50466002)(48376002)(305945005)(53416004)(42186005)(5890100001)(6506006)(50986999)(33646002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0801MB1732; H:dsafonov.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1732; 23:tFmAMGv9pcTglDVInc3Z7/icI2rQRLBH/eFdT/k?= =?us-ascii?Q?JWlVD+E8WXRa733xstL0Ua3WjJelf8J8BwA5ZNMsIfad6VlyiWVaIPzd+V67?= =?us-ascii?Q?GnT2JqXAI6R4oBqkA7qUbNyO5RL2dJrPemMl6Wq9S3Y+Uxwu7QJcAmlYvI3/?= =?us-ascii?Q?FgjsfwKPhaU5AnWKqxKUqO/eyWUeRPGP28BKWmzARi9/MPf90QHmOLSo/XvV?= =?us-ascii?Q?6dQ61Z1f+K/zy62Cp1vgSNWo4T+p7LXDcYglhb5d/YzIyzFQbP6iktiMHDwQ?= =?us-ascii?Q?lMaA41aI2rLO5Np6PbtU5O9XfAXvuHYE80N/Aq1VovsQXhH3XFKqiDZI6KCF?= =?us-ascii?Q?kqMqFyNoodCWoseM1l97yEZ84pYBq9o3TgfULMz98jSjArJP8KkJm4E/TPxJ?= =?us-ascii?Q?GWd6/gGwtL1Hzge+svoq+7mFRuRD4K/IvK8ruXiF0r0LnbepOfCsGVByiY+5?= =?us-ascii?Q?1+XNnEaWdAWnf/ngDG/LpA0F7IPi+mhK9P/f40mJgxBnPwFyJlUPUpXePNlg?= =?us-ascii?Q?bpLaRP0GI8UN5L+PHuGiph5vDdSmmC5gQ8O/dqhLTF7ZZ5LnAPdMH4UNjyEa?= =?us-ascii?Q?UOq08phD19x0VMK1DUI6omTJFMvE4RS3UZpgPph/8XxQrDK7PJUrqzL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drHTyi/YQoJUbhybDHeHHveUtllPxda9DhxY7bs3Uooc7oV5D5Wkx7uBuT/YVny7NwzLd+/GLbMs0ib3v7knrdokc6kBp2pbDTlwOSSPuQ==; 24:WSFxHPZLKAtPzKFgQwm3G+ZIt0ODML00AWd1rrnJQxgVa/uoVFcXH/kygndGOT3TKdbGa26ewqmUPSH6U7VK9iykz8SrQu8PyJo1UkRK6kM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1732; 7:bk2RNxap/n9j/q2TERKryldzQTntfkxy+gULUnPOcqcL/9w9XKJIA1839ojJJKonaScvIqaY6yRmVA5EkrtlPvFSLHCacgkTBNEWvj34HxgpgmudQNASPPz9U3XQkJc8RLTtmiSJm520TmgBGVf4HA9yevmQVCQObLj4HXJaKHkddG2105Vop7JzBHWqyuRnxcae4R542O0ipy3RbFo/k1kdkIIjTORbb6g1SeyvG+pbFd1m5cq0lRkm+UcGPOGQXK32Hy7TsPqS06uYJtmhiHSsz/WpvLCw3YYa0K7oslAoKiojrZKXQzA6k0Btf1gh1jN8QN6NfBZaupcLARL+nQ==; 20:LEII+GLZ9sUW+DQ2XJngJUVGgr4m2D9rp6DRNOQ75iQruon4t/YW9LJ9Qtv4ZbhlN/xhnaIsCLqJMPnWHm36paTMz+1ReRgdh5lvGDDwNMg0MhfRDKWD97BB7befJzeOsQF8O0YryQzzHxYg7MmRZDO/lgJk2J73dxCh1pGmNNI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2017 10:14:02.8108 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1732 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170414_031432_873201_B1700670 X-CRM114-Status: GOOD ( 11.32 ) 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: Dmitry Safonov , Will Deacon , Russell King , Christopher Covington , 0x7f454c46@gmail.com, Cyrill Gorcunov , linux-arm-kernel@lists.infradead.org, Pavel Emelyanov 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 On ARMv6 CPUs with VIPT caches there are aliasing issues: if two different cache line indexes correspond to the same physical address, then changes made to one of the alias might be lost or they can overwrite each other. To overcome aliasing issues, the align for shared mappings was introduced with: commit 4197692eef113eeb8e3e413cc70993a5e667e5b8 Author: Russell King Date: Wed Apr 28 22:22:33 2004 +0100 [ARM] Fix shared mmap()ings for ARM VIPT caches. This allows us to appropriately align shared mappings on VIPT caches with aliasing issues. Which introduced 4 pages align with SHMLBA, which resulted in unique physical address after any tag in cache (because two upper bits corresponding to page address get unused in tags). As this workaround is not needed by non-VIPT caches (like most armv7 CPUs which have PIPT caches), ARM mmap() code checks if cache is VIPT aliasing for MAP_SHARED. The problem here is in shmat() syscall: 1. if shmaddr is NULL then do_shmat() uses arch_get_unmapped_area() to allocate shared mapping. 2. if shmaddr is specified then do_shmat() checks that address has SHMLBA alignment regardless to CPU cache aliasing. Which results on ARMv7 CPUs that shmat() with NULL shmaddr may return non-SHMLBA aligned address (page-aligned), but shmat() with the same address will fail. That is not critical issue for CRIU as after shmat() with NULL address, we can mremap() resulted shmem to restore shared memory mappings on the same address where they were on checkpointing. But it's still worth fixing because we can't reliably tell from userspace if the platform has VIPT cache, and so this mremap() workaround is done with HUGE warning that restoring application, that uses SHMBLA-unaligned shmem on ARMv6 CPU with VIPT cache may result in data corruptions. I also changed SHMLBA build-time check to init-time WARN_ON(), as it's not constant afterward. This is resend of the patch from discussion: http://www.spinics.net/lists/arm-kernel/msg258870.html Cc: linux-arm-kernel@lists.infradead.org Cc: Will Deacon Cc: Russell King Cc: Christopher Covington Cc: Cyrill Gorcunov Cc: Pavel Emelyanov Suggested-by: Russell King Signed-off-by: Dmitry Safonov --- arch/arm/include/asm/shmparam.h | 8 ++++---- arch/arm/mm/copypage-v6.c | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/shmparam.h b/arch/arm/include/asm/shmparam.h index a5223b3a9bf9..6e1a72cbdf78 100644 --- a/arch/arm/include/asm/shmparam.h +++ b/arch/arm/include/asm/shmparam.h @@ -1,16 +1,16 @@ #ifndef _ASMARM_SHMPARAM_H #define _ASMARM_SHMPARAM_H +#include + /* * This should be the size of the virtually indexed cache/ways, * or page size, whichever is greater since the cache aliases * every size/ways bytes. */ -#define SHMLBA (4 * PAGE_SIZE) /* attach addr a multiple of this */ +#define SHMLBA (cache_is_vipt_aliasing() ? 4 * PAGE_SIZE : PAGE_SIZE) -/* - * Enforce SHMLBA in shmat - */ +/* Enforce SHMLBA in shmat */ #define __ARCH_FORCE_SHMLBA #endif /* _ASMARM_SHMPARAM_H */ diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c index 70423345da26..9b22c530e8b6 100644 --- a/arch/arm/mm/copypage-v6.c +++ b/arch/arm/mm/copypage-v6.c @@ -20,10 +20,6 @@ #include "mm.h" -#if SHMLBA > 16384 -#error FIX ME -#endif - static DEFINE_RAW_SPINLOCK(v6_lock); /* @@ -129,6 +125,7 @@ struct cpu_user_fns v6_user_fns __initdata = { static int __init v6_userpage_init(void) { + WARN_ON(SHMLBA > 16384); if (cache_is_vipt_aliasing()) { cpu_user.cpu_clear_user_highpage = v6_clear_user_highpage_aliasing; cpu_user.cpu_copy_user_highpage = v6_copy_user_highpage_aliasing;