From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935259AbcATLOX (ORCPT ); Wed, 20 Jan 2016 06:14:23 -0500 Received: from terminus.zytor.com ([198.137.202.10]:60745 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935188AbcATLOT (ORCPT ); Wed, 20 Jan 2016 06:14:19 -0500 Date: Wed, 20 Jan 2016 03:12:59 -0800 From: tip-bot for Andy Lutomirski Message-ID: Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, brgerst@gmail.com, torvalds@linux-foundation.org, tglx@linutronix.de, efault@gmx.de, luto@amacapital.net, hpa@zytor.com, mingo@kernel.org, luto@kernel.org, sds@tycho.nsa.gov, pavel@ucw.cz, bp@alien8.de, dvlasenk@redhat.com, arjan@linux.intel.com Reply-To: luto@kernel.org, sds@tycho.nsa.gov, pavel@ucw.cz, dvlasenk@redhat.com, bp@alien8.de, arjan@linux.intel.com, linux-kernel@vger.kernel.org, peterz@infradead.org, brgerst@gmail.com, tglx@linutronix.de, torvalds@linux-foundation.org, efault@gmx.de, luto@amacapital.net, hpa@zytor.com, mingo@kernel.org In-Reply-To: <2b544627345f7110160545a3f47031eb45c3ad4f.1453239349.git.luto@kernel.org> References: <2b544627345f7110160545a3f47031eb45c3ad4f.1453239349.git.luto@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/mm/32: Set NX in __supported_pte_mask before enabling paging Git-Commit-ID: 320d25b6a05f8b73c23fc21025d2906ecdd2d4fc 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 320d25b6a05f8b73c23fc21025d2906ecdd2d4fc Gitweb: http://git.kernel.org/tip/320d25b6a05f8b73c23fc21025d2906ecdd2d4fc Author: Andy Lutomirski AuthorDate: Tue, 19 Jan 2016 13:38:58 -0800 Committer: Ingo Molnar CommitDate: Wed, 20 Jan 2016 11:39:14 +0100 x86/mm/32: Set NX in __supported_pte_mask before enabling paging There's a short window in which very early mappings can end up with NX clear because they are created before we've noticed that we have NX. It turns out that we detect NX very early, so there's no need to defer __supported_pte_mask setup. Signed-off-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Mike Galbraith Cc: Pavel Machek Cc: Peter Zijlstra Cc: Stephen Smalley Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/2b544627345f7110160545a3f47031eb45c3ad4f.1453239349.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/head_32.S | 6 ++++++ arch/x86/mm/setup_nx.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index 6bc9ae2..57fc3f8 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S @@ -389,6 +389,12 @@ default_entry: /* Make changes effective */ wrmsr + /* + * And make sure that all the mappings we set up have NX set from + * the beginning. + */ + orl $(1 << (_PAGE_BIT_NX - 32)), pa(__supported_pte_mask + 4) + enable_paging: /* diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c index 92e2eac..78f5d59 100644 --- a/arch/x86/mm/setup_nx.c +++ b/arch/x86/mm/setup_nx.c @@ -31,9 +31,8 @@ early_param("noexec", noexec_setup); void x86_configure_nx(void) { - if (boot_cpu_has(X86_FEATURE_NX) && !disable_nx) - __supported_pte_mask |= _PAGE_NX; - else + /* If disable_nx is set, clear NX on all new mappings going forward. */ + if (disable_nx) __supported_pte_mask &= ~_PAGE_NX; }