From patchwork Tue May 1 23:49:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10374647 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 07F2E6032A for ; Tue, 1 May 2018 23:55:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC77128CDC for ; Tue, 1 May 2018 23:55:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0D0728D3B; Tue, 1 May 2018 23:55:40 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21C9228CDC for ; Tue, 1 May 2018 23:55:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 186CC6B0007; Tue, 1 May 2018 19:55:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 13A9B6B0008; Tue, 1 May 2018 19:55:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 000016B0009; Tue, 1 May 2018 19:55:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id ACF616B0007 for ; Tue, 1 May 2018 19:55:37 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id z24so4707733pfn.5 for ; Tue, 01 May 2018 16:55:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:to:cc :from:date:message-id:mime-version:content-transfer-encoding; bh=Ci0SmE9oEuTlpWIxSN5FOOjYwKEu08FNfkYVNSP2khI=; b=MdxdH7pXF/kdwQhenDiZlUClLqkLI3eOpDK3Oz+axTfyX6I40gTQj41ME55VSEEVzH yITur9aJ0jWW0eG+WevNY/vwx6bLIfLjWqVR1oOloDuqy2mDJUgXUZG+ry89qmPzhmIe I54CSs5ZgZXqKte4iLCxQSk7EN5uIARYGxGcficOTOPt2BkEZ5V+FbsweLnOD8mPFpVr 0XE8ZwZmcHSmB6KsraVaWejtOZ2rxcU7pl6Lf5ddVVOWbveMnFHmhBs+egWAx6FjNfdy 7A3oNuKYEiPfNtcSzlaxaTp4OMS3kkdUYZnPq/chuBmnAe/1MqNzVX/0tMt0v9jnVJfs F0CA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=xkJU=HU=linuxfoundation.org=gregkh@kernel.org X-Gm-Message-State: ALQs6tCrtkoNekRTEett7pl8+OtPBYCCGi0ov95Jmt3M6MYR4UJm9HU9 Ikw0VhirF4ojkBwFPRrup977L04y3JEWkUxi9s5GhcUE/I8xLk1EMsB8gz4zxruxuLrLTgIDVzN 2bCVCYGVuTuch4ZJcjDYnBHERQ95bshYfbppOmf/DhtNNv7KPSt2/8IFBvUyqxek= X-Received: by 10.98.7.75 with SMTP id b72mr10024774pfd.133.1525218937359; Tue, 01 May 2018 16:55:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrZeRkg6StyefxAuuKqS0lQkas9sCM8e9PRfB0XGE37YB5+GDTqndIQB4dE0i6Pjm+r11Rf X-Received: by 10.98.7.75 with SMTP id b72mr10024755pfd.133.1525218936539; Tue, 01 May 2018 16:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525218936; cv=none; d=google.com; s=arc-20160816; b=N6IC7UsLiEYAsF7zDgqqC94QkWNMvSpN/wlB6ZXgpe3+cQW7HYYKHQ6FvesyMF2I36 h+ORxRR0x0l15TAzbM8cRdAtywPa6dlJKErkYWb24JALVDokagqA4Cd+4OzQbjXK2orh cbqLGme6JLisP3ucNH3JsPEuzLX1jSFTF9tJiCCD+CWC3ARRch1zbMrydv3QYBKmrCcH 4/PC/lJTT/VGxTMtsTRgWLUvfSx8ZIbtyahX/LGDHAe+EyDfTEWezjGB5f4T3I6ih23w A3i0uoBbaJmtNj1pby19M2UvtoNwAGom6inYv8LpQnEz0vsR5jlEL6jm07ypwmLgFIbE qkcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:from:cc:to :subject:arc-authentication-results; bh=Ci0SmE9oEuTlpWIxSN5FOOjYwKEu08FNfkYVNSP2khI=; b=L9vkDobkRM+agW+PYqux0jN4ddLRE/JapVWnilZ7TO+2DW/a+u3f+PTnat/XFgeSDt EixzMtaoTBMR4Glm5JxDpC3xJWv8Helge/66U1AcdpoIg8vUeAyUVsSDjwmPbIojdmLM IJiAxheCKGm4cZKEw1+HKsZgg4yu+fbT3DNxhGpnnuNMeJJ/wiZ1E34PfD+oEW7kZ7Av zKLfIk0nSawHeWYJp4uYT3qbzSxkrlw6llwU+mJsGMrVtjGfwiYh+5e+wtcnFU0AZDiV rceD6fRJFxi29w4N/03/vc3l4dTZQgm7axfiJENBlXPwR7VJm/PlBcMOiXditaddkEZQ pwKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=xkJU=HU=linuxfoundation.org=gregkh@kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id z124si10712611pfb.188.2018.05.01.16.55.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 16:55:36 -0700 (PDT) Received-SPF: pass (google.com: domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=xkJU=HU=linuxfoundation.org=gregkh@kernel.org Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0235E23764; Tue, 1 May 2018 23:55:36 +0000 (UTC) Subject: Patch "x86/pgtable: Don't set huge PUD/PMD on non-leaf entries" has been added to the 4.14-stable tree To: 20180411152437.GC15462@8bytes.org, David.Laight@aculab.com, aarcange@redhat.com, alexander.levin@microsoft.com, aliguori@amazon.com, boris.ostrovsky@oracle.com, bp@alien8.de, brgerst@gmail.com, daniel.gruss@iaik.tugraz.at, dave.hansen@intel.com, dhgutteridge@sympatico.ca, dvlasenk@redhat.com, eduval@amazon.com, gregkh@linuxfoundation.org, hughd@google.com, jgross@suse.com, jkosina@suse.cz, joro@8bytes.org, jpoimboe@redhat.com, jroedel@suse.de, keescook@google.com, linux-mm@kvack.org, llong@redhat.com, luto@kernel.org, mingo@kernel.org, pavel@ucw.cz, peterz@infradead.org, tglx@linutronix.de, torvalds@linux-foundation.org, will.deacon@arm.com Cc: From: Date: Tue, 01 May 2018 16:49:20 -0700 Message-ID: <1525218560246173@kroah.com> MIME-Version: 1.0 X-stable: commit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is a note to let you know that I've just added the patch titled x86/pgtable: Don't set huge PUD/PMD on non-leaf entries to the 4.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: x86-pgtable-don-t-set-huge-pud-pmd-on-non-leaf-entries.patch and it can be found in the queue-4.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From foo@baz Tue May 1 16:18:20 PDT 2018 From: Joerg Roedel Date: Wed, 11 Apr 2018 17:24:38 +0200 Subject: x86/pgtable: Don't set huge PUD/PMD on non-leaf entries From: Joerg Roedel [ Upstream commit e3e288121408c3abeed5af60b87b95c847143845 ] The pmd_set_huge() and pud_set_huge() functions are used from the generic ioremap() code to establish large mappings where this is possible. But the generic ioremap() code does not check whether the PMD/PUD entries are already populated with a non-leaf entry, so that any page-table pages these entries point to will be lost. Further, on x86-32 with SHARED_KERNEL_PMD=0, this causes a BUG_ON() in vmalloc_sync_one() when PMD entries are synced from swapper_pg_dir to the current page-table. This happens because the PMD entry from swapper_pg_dir was promoted to a huge-page entry while the current PGD still contains the non-leaf entry. Because both entries are present and point to a different page, the BUG_ON() triggers. This was actually triggered with pti-x32 enabled in a KVM virtual machine by the graphics driver. A real and better fix for that would be to improve the page-table handling in the generic ioremap() code. But that is out-of-scope for this patch-set and left for later work. Reported-by: David H. Gutteridge Signed-off-by: Joerg Roedel Reviewed-by: Thomas Gleixner Cc: Andrea Arcangeli Cc: Andy Lutomirski Cc: Boris Ostrovsky Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: David Laight Cc: Denys Vlasenko Cc: Eduardo Valentin Cc: Greg KH Cc: Jiri Kosina Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Linus Torvalds Cc: Pavel Machek Cc: Peter Zijlstra Cc: Waiman Long Cc: Will Deacon Cc: aliguori@amazon.com Cc: daniel.gruss@iaik.tugraz.at Cc: hughd@google.com Cc: keescook@google.com Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180411152437.GC15462@8bytes.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/pgtable.c | 9 +++++++++ 1 file changed, 9 insertions(+) Patches currently in stable-queue which might be from joro@8bytes.org are queue-4.14/x86-apic-set-up-through-local-apic-mode-on-the-boot-cpu-if-noapic-specified.patch queue-4.14/x86-pgtable-don-t-set-huge-pud-pmd-on-non-leaf-entries.patch --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include @@ -636,6 +637,10 @@ int pud_set_huge(pud_t *pud, phys_addr_t (mtrr != MTRR_TYPE_WRBACK)) return 0; + /* Bail out if we are we on a populated non-leaf entry: */ + if (pud_present(*pud) && !pud_huge(*pud)) + return 0; + prot = pgprot_4k_2_large(prot); set_pte((pte_t *)pud, pfn_pte( @@ -664,6 +669,10 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t return 0; } + /* Bail out if we are we on a populated non-leaf entry: */ + if (pmd_present(*pmd) && !pmd_huge(*pmd)) + return 0; + prot = pgprot_4k_2_large(prot); set_pte((pte_t *)pmd, pfn_pte(