Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 320d25b6 authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Ingo Molnar
Browse files

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: default avatarAndy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/2b544627345f7110160545a3f47031eb45c3ad4f.1453239349.git.luto@kernel.org


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 43c75f93
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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:

/*
+2 −3
Original line number Diff line number Diff line
@@ -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;
}