Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4956350imm; Tue, 26 Jun 2018 03:35:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIkVc5LwSkadboKTz4pxThs6nm3truiCwnpeVZ84dX2QrgJUJAFDh14TEpXIWLqzy7Fg0BN X-Received: by 2002:a17:902:b28c:: with SMTP id u12-v6mr1035035plr.16.1530009335676; Tue, 26 Jun 2018 03:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530009335; cv=none; d=google.com; s=arc-20160816; b=Ylq+lCCaRcywDpxZ8Vau8eO0WplIjjYkywOGX7FmYr2CPfqiQFSkAqm70Dd3ld+h6e EEeDa4r17qS+m6OHJmvGfy1ayyvq4uWQn/T51XOYWucP0zVXdNAmUlR9P3F86OiZ0iJb QG9a2cBvidaWAqf/liUdYpGpiOJv4z+iEaoQM1AS7+M1FetElqbYOmJn3LLkex/LXtqw nuDRpkow9P0VJ4M/tXsT4avmIhgnOtkpGhcWS7BXUCUYB/xYmciVRQkqHv6l91Lsp4II /vGmMnSXkjoDWoTh9c9x/7uYQ2emMY0bI+LdZpROVABxDDifFluYByVI9dVaoNIu3Fot FzpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=c3QYlw8oL1HOMWRbmcSfMLuAG/uzykSYyZ5H8nph6Jo=; b=cBZMz+pbq+R5uEjmCZUyoV97tjuV3CZ6gD3cfTb/9qcMtiUU1QWDLfAcHT0FrLnK1L n2GGxVM8/gQqsV2bDwIwVC8/fnaasM4nyoIpRzjcUNvQqqlBdFOIK870heeziXzOzGmc IbLYFcX5stGEltylUdBsQAKIx1FXia+qFstMpBXlUBRKOPiH67u18hbM8M338Ouy65Yp GaaZis/QpETk+d3m1UBTowVwAX8aEOd82uIgvzxEkOPBmhD6WwqKDxckbtqbIU/5aDue pvXfTEfQLmt4NGvNZwKvOXktOQmmpCUgCL8SPO9Afjyo+k93LwaJhnsyWnMIT4tpSqK1 6Ygw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20-v6si1161420pga.21.2018.06.26.03.35.21; Tue, 26 Jun 2018 03:35:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965050AbeFZKde (ORCPT + 99 others); Tue, 26 Jun 2018 06:33:34 -0400 Received: from terminus.zytor.com ([198.137.202.136]:54089 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933880AbeFZKdb (ORCPT ); Tue, 26 Jun 2018 06:33:31 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5QAXBK01649344 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 26 Jun 2018 03:33:11 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5QAXBgs1649341; Tue, 26 Jun 2018 03:33:11 -0700 Date: Tue, 26 Jun 2018 03:33:11 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Andrey Ryabinin Message-ID: Cc: linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, torvalds@linux-foundation.org, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, aryabinin@virtuozzo.com, peterz@infradead.org Reply-To: aryabinin@virtuozzo.com, peterz@infradead.org, mingo@kernel.org, hpa@zytor.com, kirill.shutemov@linux.intel.com, tglx@linutronix.de, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org In-Reply-To: <20180625102427.15015-1-aryabinin@virtuozzo.com> References: <20180625102427.15015-1-aryabinin@virtuozzo.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/mm: Don't free P4D table when it is folded at runtime Git-Commit-ID: 0e311d237d7f3022b7dafb639b42541bfb42fe94 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0e311d237d7f3022b7dafb639b42541bfb42fe94 Gitweb: https://git.kernel.org/tip/0e311d237d7f3022b7dafb639b42541bfb42fe94 Author: Andrey Ryabinin AuthorDate: Mon, 25 Jun 2018 13:24:27 +0300 Committer: Ingo Molnar CommitDate: Tue, 26 Jun 2018 09:21:48 +0200 x86/mm: Don't free P4D table when it is folded at runtime When the P4D page table layer is folded at runtime, the p4d_free() should do nothing, the same as in . It seems this bug should cause double-free in efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing. Signed-off-by: Andrey Ryabinin Reviewed-by: Kirill A. Shutemov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: stable@vger.kernel.org # 4.17 Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime") Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h index ada6410fd2ec..fbd578daa66e 100644 --- a/arch/x86/include/asm/pgalloc.h +++ b/arch/x86/include/asm/pgalloc.h @@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) { + if (!pgtable_l5_enabled()) + return; + BUG_ON((unsigned long)p4d & (PAGE_SIZE-1)); free_page((unsigned long)p4d); }