From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B09CC43381 for ; Sun, 31 Mar 2019 15:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DDA662086C for ; Sun, 31 Mar 2019 15:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554044428; bh=+6hzimTPsT7ptO61M0GY6/n8hr/WDK7PAosNwA4Db1g=; h=Subject:To:Cc:From:Date:List-ID:From; b=jwF68oM13Wpv69y2MrY6R+/zbfx5XwEXqzCtwUxp8OSvbcrJ0cwqw9DPjcL0GKWOO jN0HaOMTYufmhqZb4/kzhXn0WhWbL7S7HItKuZHjt5WuyQuohW17AHlUmyuGM3Hc91 bvYtfJhaGDF1xzns1xO6GhH5GHiPAXQc4BaNnWSY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731285AbfCaPA2 (ORCPT ); Sun, 31 Mar 2019 11:00:28 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:47859 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731283AbfCaPA2 (ORCPT ); Sun, 31 Mar 2019 11:00:28 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 12DAA20CB1; Sun, 31 Mar 2019 11:00:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 31 Mar 2019 11:00:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=2PIwVJ U+WdJFjj+sWDTLA1gADekG5mBEaPqD7wO/AmA=; b=vf86LujTw+dWjkacQlAfiW 4iRBxKYhP8riG0Mx3X2gj31/O8ext83vLdPyUDIUw9CoA+aoMTrV/et0Rc2Z/Z4p Sb47JM81HZrE1Q4vKGOWVVF+i3X6fp4+zIwfk3WO2Mt041Yh4XVRMWtWzjvA5Zj1 z1GOnJEROrUm4RKwZ7vbHQvhjjuKDhvk7sbF90h0khcFxzb+x7IDZG+ayTd9X64a loGEXmFKTVYBmyQbFsee/lKssbvPIaYlTlZjqgHzNd3TNdoWW9KK5hAMrNBFZ6hd 09dGsgAMKZPELKt07YOJ4kfXsh/Qk1ESAqopQEECA6qvoLjjpSsLX96aerV6/8xA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrledvgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppeekfedrkeeirdekledrud dtjeenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhmnecu vehluhhsthgvrhfuihiivgepud X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 66A94100E5; Sun, 31 Mar 2019 11:00:26 -0400 (EDT) Subject: FAILED: patch "[PATCH] mm/migrate.c: add missing flush_dcache_page for non-mapped" failed to apply to 3.18-stable tree To: lars.persson@axis.com, akpm@linux-foundation.org, larper@axis.com, mgorman@techsingularity.net, paul.burton@mips.com, ralf@linux-mips.org, stable@vger.kernel.org, torvalds@linux-foundation.org Cc: From: Date: Sun, 31 Mar 2019 17:00:18 +0200 Message-ID: <1554044418230147@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 3.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From d2b2c6dd227ba5b8a802858748ec9a780cb75b47 Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Thu, 28 Mar 2019 20:44:28 -0700 Subject: [PATCH] mm/migrate.c: add missing flush_dcache_page for non-mapped page migrate Our MIPS 1004Kc SoCs were seeing random userspace crashes with SIGILL and SIGSEGV that could not be traced back to a userspace code bug. They had all the magic signs of an I/D cache coherency issue. Now recently we noticed that the /proc/sys/vm/compact_memory interface was quite efficient at provoking this class of userspace crashes. Studying the code in mm/migrate.c there is a distinction made between migrating a page that is mapped at the instant of migration and one that is not mapped. Our problem turned out to be the non-mapped pages. For the non-mapped page the code performs a copy of the page content and all relevant meta-data of the page without doing the required D-cache maintenance. This leaves dirty data in the D-cache of the CPU and on the 1004K cores this data is not visible to the I-cache. A subsequent page-fault that triggers a mapping of the page will happily serve the process with potentially stale code. What about ARM then, this bug should have seen greater exposure? Well ARM became immune to this flaw back in 2010, see commit c01778001a4f ("ARM: 6379/1: Assume new page cache pages have dirty D-cache"). My proposed fix moves the D-cache maintenance inside move_to_new_page to make it common for both cases. Link: http://lkml.kernel.org/r/20190315083502.11849-1-larper@axis.com Fixes: 97ee0524614 ("flush cache before installing new page at migraton") Signed-off-by: Lars Persson Reviewed-by: Paul Burton Acked-by: Mel Gorman Cc: Ralf Baechle Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/mm/migrate.c b/mm/migrate.c index ac6f4939bb59..663a5449367a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -248,10 +248,8 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, pte = swp_entry_to_pte(entry); } else if (is_device_public_page(new)) { pte = pte_mkdevmap(pte); - flush_dcache_page(new); } - } else - flush_dcache_page(new); + } #ifdef CONFIG_HUGETLB_PAGE if (PageHuge(new)) { @@ -995,6 +993,13 @@ static int move_to_new_page(struct page *newpage, struct page *page, */ if (!PageMappingFlags(page)) page->mapping = NULL; + + if (unlikely(is_zone_device_page(newpage))) { + if (is_device_public_page(newpage)) + flush_dcache_page(newpage); + } else + flush_dcache_page(newpage); + } out: return rc;