From patchwork Sun May 27 15:14:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10429445 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 8C10F601C7 for ; Sun, 27 May 2018 15:34:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B6F028B26 for ; Sun, 27 May 2018 15:34:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 700A428B62; Sun, 27 May 2018 15:34:35 +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,DKIM_SIGNED, DKIM_VALID, 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 93B0028B26 for ; Sun, 27 May 2018 15:34:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 799526B0006; Sun, 27 May 2018 11:34:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 748636B0007; Sun, 27 May 2018 11:34:33 -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 65E466B0008; Sun, 27 May 2018 11:34:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 294BC6B0006 for ; Sun, 27 May 2018 11:34:33 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id s21-v6so6151825plq.4 for ; Sun, 27 May 2018 08:34:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:to:cc:from:date :message-id:mime-version:content-transfer-encoding; bh=h4eQhWrD8vuhidHY0GpVJ2b/NK6eAh8woEXxwbCItzU=; b=Yun+GtK3t9HC2SIr+czgf0Je3xERlfvdGHqnmBuzMjbrf0jG7I7x8Fk5FhxUei1V47 0zzYBXy5BMv58GEqCeIaykStMx+TraBOnJaJAo/jgGIklAmCtgE2RX+cGt5jYh1tICXp ERUiwqcIc+Irk8yg/La9YgDlVuU+nGURfxjSpeVGyy3C980LdsLgZSXJEGKHIK97nT7n sNwrhks33SlrvNp+RNbAzpBBV5Dds49QP4ctATICO41TtAKekuR1Ekqeb7/NXp25dBIO fXkrBklfqb1xE3onuEocmpfSvuN24vR0D1s7oNecK6PCHWAASfbWWMXC0USmGMu/ovD4 Kfmw== X-Gm-Message-State: ALKqPwfAekwGW6T5wJ7dGyPom37ziADtVEmBuSraSAbojB4QxWfmwnYg rFAqtww4YHzyXXF9CY1LTYXwHwIZOQkEoFhgSzCVm9nNqT1AE2tUyAJda0+BSpjF97DlhAV8MUo h+djFpHW/PsSnq4VudFqKw+hmuASDyK0B46nv2H4nOaeAp8RUwcCVe3KQy/MQEZ0= X-Received: by 2002:a65:480a:: with SMTP id h10-v6mr7677472pgs.403.1527435272716; Sun, 27 May 2018 08:34:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo1dk8tO6awPQGu8vSDzwb7ZHM1a646NOjT0LPpBrde/KUPT6u+ehPbwUYtqf8exrK/lqXE X-Received: by 2002:a65:480a:: with SMTP id h10-v6mr7677455pgs.403.1527435271922; Sun, 27 May 2018 08:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527435271; cv=none; d=google.com; s=arc-20160816; b=hGUL+kkw0GGDmfWFGf6Exg/Qv10BINOl/+4sAY3q9gObR10i+bKlvDJ6JSSze2I23x MgEoA1JDjx+ceOgAmFVUdm+UyqQO99M0inS7hPsiaD8hhJqJeU7E2AGFJjIyOanLJKSN sCQK7vUHHHYPJZQXzefrduomsHazmhjC0xs+J7JHQH0wo+wPXAidjQhqmEr3oevU66gp 7rugkWU6BQ0t0Tt1p2k3ZJIa2nKY139SsV51DhR3t1UrFZNpODVfVUYoM6y0NPa1kndG PiWXhR4CmGZPoqXxZV+cDbwU6LUf8wvh2ndW4gaxO3x7eyig5KwIgPtRjfFiIS6FBSjZ aEwQ== 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:dkim-signature:arc-authentication-results; bh=h4eQhWrD8vuhidHY0GpVJ2b/NK6eAh8woEXxwbCItzU=; b=u43vOjzybpd0zWcSusIbn7ztvkTHdpKKAIK+GL5lGw13Ev6EsiBKu2PykvJX6arPzV JcdatR+Gkkrq+fUhOwb7A7JpaGGLNIG7yCbEn3FuDExX2FK/35WiW8o2Le+ghKPnLvg7 nkyuVpgKZJjN5Vdmy0wIjrrBCaZ/sn+yqBF8ylReMW2aTxJHzpTcuZe8MWa/yRz4FHpp AEspqVaG/pEQEbNEUyUg2gByF6AlJwIyXHCsKMmz+A7J9VrzH08qZl/rsNCcKZEeNs7U HwhtlNhbB8CAu0XWRha0gVeyB7OAhGxhkxeyI8XHT7FBYv8KdgF1WYRWRht16iGSO/0W A8mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FBps8fyS; spf=pass (google.com: domain of srs0=ri55=io=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=rI55=IO=linuxfoundation.org=gregkh@kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id s70-v6si21151842pfs.157.2018.05.27.08.34.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 May 2018 08:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of srs0=ri55=io=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FBps8fyS; spf=pass (google.com: domain of srs0=ri55=io=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=rI55=IO=linuxfoundation.org=gregkh@kernel.org Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 0E911208A4; Sun, 27 May 2018 15:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527435271; bh=OXJsMo0DDFyoejgYlyyichyak22nj7DJ5CX4fTEBQjk=; h=Subject:To:Cc:From:Date:From; b=FBps8fySAw1st46g8M99U91Y9sZ9necCqn/RWtFnRKDzU1aDMoBJ5i4bdVzk2eNiR twAjkh9a1mlkqf3r03KQYDWHNDN/rcqGqrTAQZ62LIaASKrVYofs2hOaZtbHR7Zh+T 9i2wOh5DQYzV/H3uAig0AUQCYK5sddiQiYEoWvMw= 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: Sun, 27 May 2018 17:14:40 +0200 Message-ID: <1527434080170115@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 Sun May 27 16:52:54 CEST 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(