Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3491837imu; Sun, 11 Nov 2018 16:18:46 -0800 (PST) X-Google-Smtp-Source: AJdET5ds4gCv/bUIEmrnhKmo/ULpraP9A0actC3DYp0G1htOyyu+04ZZ7+2rq3pvgpZ8OvoxvlFT X-Received: by 2002:a62:de84:: with SMTP id h126-v6mr17877877pfg.129.1541981926240; Sun, 11 Nov 2018 16:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981926; cv=none; d=google.com; s=arc-20160816; b=ZaQ4oE929InCaZfHH0oUaRCSnU/+0Q4+kf2qZRHFUqn72Dsw318spW+KEmNmhtJ+xm 3VXEBBSHvSiUwk81UWbiYfvHehINgldqknT3o44TILVW0HsxaqNfeIvM6pYjfNE2I07t m/av030/U7+EhIFcQ3t3E4Jc5bdF2GgoLGdb97GzZ837YXvcAjvVwqHalnmxP1uxBzoM scxFY/yhkjiMIT1S7K59pTxTQnYiKC9f07FhakRRtz6M/VBXC/It8CDJuQMuo3stYQFi OIPfTsMZWL7xvJP1cR3jn6pNy2MhE/WDZ+K46aYqjrxxaUI/7/aftkGWIdAjCdpIlmzB 1b7A== 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=Lcxf9s6jm2AVYuvfOoCieDpYy8TEh+bAAFcsKbn1Vt0=; b=j5TJqwGZV1Far2omFby6QiLjrY4TzRMKWFrDbyd4tSKlEzBh3/4VKo4YyPxNfxzdH/ ZTm0ULIt/plxPw38G2lgTe61xLFsH9nd5dF1xN+bGtYexAWOZXT2kAdMdJVieh2/KlPD /lX8ExdUwcWyentnDOzhssKxnzgw7Mu/i5HYP+nVBXWR4P1r+5NmxvvNlMdqPkxkApl3 AjKQcVVu18kGvN7Q7X4onaLkH4Ijw6rz7ebPVX8CBDW5edlompmyXudgvDkGP7pCoB7m EB6eqpigBPD5ZsKqeoEgDMPG5lOU4MrixFAxlLPsr0qPxugIraCrB35cXQoSGugRf8wi 38OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VmgsC0jV; 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 b8-v6si16820365plm.190.2018.11.11.16.18.31; Sun, 11 Nov 2018 16:18:46 -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=VmgsC0jV; 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 S1730116AbeKLIRE (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:59348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729990AbeKLIRD (ORCPT ); Mon, 12 Nov 2018 03:17:03 -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 107EF214E0; Sun, 11 Nov 2018 22:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975227; bh=laXd0JNih4gYPcSJrvAKOJMRH3762lpO0HvGwVh6y4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VmgsC0jVNYsN9JrICgYCu+CD3E+UsnRPFLzxcDN9xBoaGayyX+G6U2rRAunZlxLDO 5hVAQ61T0HAvmvGhRU/FgqHmEHAwXDP3rguQje9HC5ggsY3uelKm5jAOCW3O4uM829 eOp898D4OLpdgZsJ79J6LI01gKQPr2uyuBKGWyHg= 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.19 045/361] x86/mm/pat: Disable preemption around __flush_tlb_all() Date: Sun, 11 Nov 2018 14:16:32 -0800 Message-Id: <20181111221626.229054655@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -469,6 +469,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 @@ -2086,9 +2086,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(); }