From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932146AbdLPACN (ORCPT ); Fri, 15 Dec 2017 19:02:13 -0500 Received: from mga04.intel.com ([192.55.52.120]:25372 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755861AbdLPACJ (ORCPT ); Fri, 15 Dec 2017 19:02:09 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,407,1508828400"; d="scan'208";a="187135943" Subject: [PATCH] x86/kpti: WARN if kernel memory mapped to userspace is non-global To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Dave Hansen , tglx@linutronix.de, luto@kernel.org, bp@suse.de, brgerst@gmail.com, dvlasenk@redhat.com, hpa@zytor.com, jpoimboe@redhat.com, torvalds@linux-foundation.org, peterz@infradead.org, riel@redhat.com From: Dave Hansen Date: Fri, 15 Dec 2017 16:01:45 -0800 Message-Id: <20171216000145.3328ACA0@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen All memory being mapped out to userspace is shared. That means that it is both safe and _expected_ to have the page table Global bit set. If a PMD is found without Global set, it either a place that could be performing better, or something unexpected is being mapped out to userspace. Both of those are things for which a warning is good. Signed-off-by: Dave Hansen Cc: Thomas Gleixner Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Rik van Riel --- b/arch/x86/mm/kpti.c | 3 +++ 1 file changed, 3 insertions(+) diff -puN arch/x86/mm/kpti.c~kaiser-set-global-in-kernel-for-shared arch/x86/mm/kpti.c --- a/arch/x86/mm/kpti.c~kaiser-set-global-in-kernel-for-shared 2017-12-15 09:47:52.884717268 -0800 +++ b/arch/x86/mm/kpti.c 2017-12-15 10:00:39.134715357 -0800 @@ -157,6 +157,9 @@ kpti_clone_pmds(unsigned long start, uns if (WARN_ON(!target_pmd)) return; + /* Only clone PMDs which we *intend* to share: */ + WARN_ON_ONCE(!(pmd_flags(*target_pmd) & _PAGE_GLOBAL)); + /* * Copy the PMD. That is, the kernelmode and usermode * tables will share the last-level page tables of this _