From patchwork Tue May 1 22:33:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10374579 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 087EE6032A for ; Tue, 1 May 2018 22:36:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A7828CF0 for ; Tue, 1 May 2018 22:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7DBE28D01; Tue, 1 May 2018 22:36:49 +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 CFC2C28CF0 for ; Tue, 1 May 2018 22:36:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FCA36B0006; Tue, 1 May 2018 18:36:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2AD456B0007; Tue, 1 May 2018 18:36:45 -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 154C46B0008; Tue, 1 May 2018 18:36:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id D590B6B0006 for ; Tue, 1 May 2018 18:36:44 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id q15so11392257pff.15 for ; Tue, 01 May 2018 15:36:44 -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=1oDTzHiWQL05zaDkcmHNBUMUmvZb2fFwz2k2AT7vIvw=; b=ritaa9EQoLKMZ/08PhMXlItZCYEEQFzgnkYoqDJvfXvZsBVBWuevuK5WVJMza7OUID r356xqdPb2tV/pcIw7f23ukGk3sCFCg3t8ePvDWr4aFsdB/aHtN7E/ZvILeFKFMFa5nh pLqRT9ehO+fo6VOJoGZ3GUdrkKcrVTfWB7Rx9RCaUPyIwRaUGLdzMKz0hLd/BMVyy6l3 JqI50DcH+vDPPvjF5OgguwPI5ES6h0B0PLQA+Sc+XrVyOqPQP8J/2WSuAG+niUjnseEi unuSlZyxbUK13X2lXicgu5IGKaOBW5NnUR8EmqlAwrqoTAD+boOEfNC1fTW+l0z1t8nA yAOw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for 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: ALQs6tAR/IF4n0vITO1l7hWFAZw8AbpiEjd/YO7P+Chp+5MAQq49206H 5Rv2QuP2e+RPXvh1MG/q16S35TEmW3ukgdA/9zRg/7Wh51jlNq10xr/UicFQ3ljPr1i+A0n4+j4 AlaGQR0RUprD9/Q9YQvOpNKzL8AWsgzR5HA1azCbCyP0ZEl7HRm8+jq7b4YLRz8g= X-Received: by 10.167.133.81 with SMTP id y17mr2822067pfn.163.1525214204505; Tue, 01 May 2018 15:36:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrhPA6ys0n9spOFLgilK0w9xrTRUHgSy9Tw9SY4AfwERiSxABl7PgwJTROmFZ+0oSGhXHsl X-Received: by 10.167.133.81 with SMTP id y17mr2822048pfn.163.1525214203798; Tue, 01 May 2018 15:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525214203; cv=none; d=google.com; s=arc-20160816; b=M+5PsBiGLiahmeAseNI4loP2IrGT8GNbRrRZoxe/sy9d5A2FLYbfcaCn0UTuNQbiU5 nrFg9Nm6SqquO7o2aKQgjRU5KtoNdBdnwbHmmmNbm+ziUSBxuFytfYpNISApy74bdTkv 8NrGG+xe8eRAHVe7D8sLwDFsN5UphyCq1rDQbbVVBo+lYu5QQJfCjHgnnUqWDSM3y8V3 lf22Pdswo+Q+RDD47YJy87hjYhWx1okKYLH66HWoQH7VNAaWEmG1up5fQdZDBtAQJNTO C/ij6bSEOteWEWMEKTC0IpKnK+ZDN/F/9IHQL7R5z5zznFY56bwqdgxR/BuNkHKad40g 6X6w== 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=1oDTzHiWQL05zaDkcmHNBUMUmvZb2fFwz2k2AT7vIvw=; b=gS7ntFGbbtoLZ4n79KcSrG7k164DvWWnL5eeTu5Qu5QCecBk8ygfeeUHuoW4MGQNj5 EwvWDJRDnV/JwPL16Ij3NtbVjK+9AI6YNVWCBV/6OcYh1ezBS/9DQxaDSLxKJsuU3HD8 rOh376+roFeVGPqn8vy9FTroIWLlfwtnuXi29/8jYtrU+KUU1jMKyFRzOFF1ofbYBnrY ttQ6ViK+bD0ZFF15cnbKZwDH51WTkASMBePNyscInjvRgY/XqJrcmWPL3xYMOC2fguWA ZHHQPjRuhy6WNiJH+jENiq3wDZVsW70nl2/bqhZQ7NYtkHtkXQ4Jz7kAexvu+nQwLU9J yG3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for 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 w12-v6si8598947pge.165.2018.05.01.15.36.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 15:36:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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: best guess record for 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 6020423712; Tue, 1 May 2018 22:36:43 +0000 (UTC) Subject: Patch "x86/pgtable: Don't set huge PUD/PMD on non-leaf entries" has been added to the 4.16-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 15:33:11 -0700 Message-ID: <152521399136247@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.16-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.16 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 14:59:17 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.16/x86-apic-set-up-through-local-apic-mode-on-the-boot-cpu-if-noapic-specified.patch queue-4.16/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(