Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Dec 2018 22:12:58 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341746 - head/sys/i386/i386
Message-ID:  <201812082212.wB8MCwmC000553@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Dec  8 22:12:57 2018
New Revision: 341746
URL: https://svnweb.freebsd.org/changeset/base/341746

Log:
  Fix PAE boot.
  
  With the introduction of M_EXEC support for kmem_malloc(), some kernel
  mappings start having NX bit set in the paging structures early, for
  PAE kernels on machines with NX support, i.e. practically on all
  machines.  In particular, AP trampoline and initialization needs to
  access pages which translations has NX bit set, before initializecpu()
  is called.
  
  Check for CPUID NX feature and enable EFER.NXE before we enable paging
  in mp boot trampoline.  This allows the CPU to use the kernel page
  table instead of generating page fault due to reserved bit set.
  
  PR:	233819
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/i386/i386/mpboot.s

Modified: head/sys/i386/i386/mpboot.s
==============================================================================
--- head/sys/i386/i386/mpboot.s	Sat Dec  8 19:45:05 2018	(r341745)
+++ head/sys/i386/i386/mpboot.s	Sat Dec  8 22:12:57 2018	(r341746)
@@ -99,6 +99,20 @@ NON_GPROF_ENTRY(MPentry)
 	movl	%cr4, %eax
 	orl	$CR4_PAE, %eax
 	movl	%eax, %cr4
+	movl	$0x80000000, %eax
+	cpuid
+	movl	$0x80000001, %ebx
+	cmpl	%ebx, %eax
+	jb	1f
+	movl	%ebx, %eax
+	cpuid
+	testl	$AMDID_NX, %edx
+	je	1f
+	movl	$MSR_EFER, %ecx
+	rdmsr
+	orl	$EFER_NXE,%eax
+	wrmsr
+1:
 #else
 	movl	IdlePTD, %eax
 	movl	%eax,%cr3	



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812082212.wB8MCwmC000553>