Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3440890imu; Sun, 11 Nov 2018 15:09:38 -0800 (PST) X-Google-Smtp-Source: AJdET5cLBFC7vEtCos/A/A+VhosKJSXSkaeAxJoDoILXwhjbDjU5Sc1gRxTi6fG53XV7BkQPxP4W X-Received: by 2002:a17:902:b592:: with SMTP id a18-v6mr17205864pls.248.1541977778392; Sun, 11 Nov 2018 15:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977778; cv=none; d=google.com; s=arc-20160816; b=UXBYQ/mnZhnMtuUgAM+QojJUtFU5BWWLQea16Z1VacQvjuQQKoDvZuyKAkU3o/jnTx 1SjKeSLRyBGxtDKuEy7vslaMnithR3iIGTvGDE3rMXjKWFj7Rq7zzik57i71AvHYKaeC o4XVHIh+wr98DGMk62rDqghZWdUGcbZKTABxcNgJIxuUHL9AAn2jzZKcKe2NYVmxGb2S lIZb5DbnIUAu7bczN7Q1szdf2wmz2u5Uk6zlXpBPfZaTeTawbas3YwP+dZuKu5sue4Oz iSq7s2euzTa1TlNbD1pcdB9Yo3rsG9OYDmk+Zrsp5N95bjMATgn/PFv9i+EfTCf8LqFH JBDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WYiA64yenUgktEpUVS0xRrjNNYxV35D460YvFkZtUWs=; b=jS7RelMv8ekRyif65q216kQdQxHaLZsqum5tqUg5KQxl5rpJaD+ImNfVl/1X4Z5rMJ nsxDBU+7xgpqTpzgu/uTqzpbFu/Waro7HXOoB7bPYBKKUO/7LT1sZgxuI3Clnh1MKzDf TZxi2K4oA6bAu8606nrvLkB6qQnsz0Ex3VOZmBfHtfZ0mgnjJH2g+htmyTFWLIqcmNb4 NA7d9GJstTl/6GBcikJx3Bm+MnSUIkSeIyO/tmY1Z9ds9wtEc0zjaIdTXbAvggi4udlr rFaW3LmXfq7Tav83a40FzQoXzF3X9IfccEPvw5M/qjtBHcGqoMELyDjj+uSN5rGuGvZd L53A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GhPduF/M"; 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 y21si14884332pga.364.2018.11.11.15.09.23; Sun, 11 Nov 2018 15:09:38 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="GhPduF/M"; 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 S2390248AbeKLIWE (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:50044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390163AbeKLIWC (ORCPT ); Mon, 12 Nov 2018 03:22:02 -0500 Received: from localhost (unknown [206.108.79.134]) (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 2723A21780; Sun, 11 Nov 2018 22:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975525; bh=NGnSLJ8RbFtDbfZlKfoRY1cq9X92ZKJbVMuuCFGd3y4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhPduF/MoXzdlEQE6mvyvBlQvi6QllzHBd4NbM85rQ0IZ6aPeoHTEGCdbKVb22OLL +z/cDC7SqBRqG+jaSbpmU6WpWEMtwQm8nZ7dOCWYRIuXZqVMZEgNFRZG8hbA0IkCq9 izapsFPkyT9IiCmlOxxJ0O+DJFCiMnkl0hZUw8rc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , Thomas Gleixner , Andy Lutomirski , Dave Hansen , Peter Zijlstra , Borislav Petkov Subject: [PATCH 4.14 022/222] x86/mm/pat: Disable preemption around __flush_tlb_all() Date: Sun, 11 Nov 2018 14:21:59 -0800 Message-Id: <20181111221650.152810263@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sebastian Andrzej Siewior commit f77084d96355f5fba8e2c1fb3a51a393b1570de7 upstream. The WARN_ON_ONCE(__read_cr3() != build_cr3()) in switch_mm_irqs_off() triggers every once in a while during a snapshotted system upgrade. The warning triggers since commit decab0888e6e ("x86/mm: Remove preempt_disable/enable() from __native_flush_tlb()"). The callchain is: get_page_from_freelist() -> post_alloc_hook() -> __kernel_map_pages() with CONFIG_DEBUG_PAGEALLOC enabled. Disable preemption during CR3 reset / __flush_tlb_all() and add a comment why preemption has to be disabled so it won't be removed accidentaly. Add another preemptible() check in __flush_tlb_all() to catch callers with enabled preemption when PGE is enabled, because PGE enabled does not trigger the warning in __native_flush_tlb(). Suggested by Andy Lutomirski. Fixes: decab0888e6e ("x86/mm: Remove preempt_disable/enable() from __native_flush_tlb()") Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner Cc: Andy Lutomirski Cc: Dave Hansen Cc: Peter Zijlstra Cc: Borislav Petkov Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20181017103432.zgv46nlu3hc7k4rq@linutronix.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/tlbflush.h | 6 ++++++ arch/x86/mm/pageattr.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -466,6 +466,12 @@ static inline void __native_flush_tlb_on */ static inline void __flush_tlb_all(void) { + /* + * This is to catch users with enabled preemption and the PGE feature + * and don't trigger the warning in __native_flush_tlb(). + */ + VM_WARN_ON_ONCE(preemptible()); + if (boot_cpu_has(X86_FEATURE_PGE)) { __flush_tlb_global(); } else { --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -2037,9 +2037,13 @@ void __kernel_map_pages(struct page *pag /* * We should perform an IPI and flush all tlbs, - * but that can deadlock->flush only current cpu: + * but that can deadlock->flush only current cpu. + * Preemption needs to be disabled around __flush_tlb_all() due to + * CR3 reload in __native_flush_tlb(). */ + preempt_disable(); __flush_tlb_all(); + preempt_enable(); arch_flush_lazy_mmu_mode(); }