Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 May 2019 22:56:22 +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: r348075 - in head/sys: amd64/amd64 i386/i386 x86/x86
Message-ID:  <201905212256.x4LMuMbB089052@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue May 21 22:56:21 2019
New Revision: 348075
URL: https://svnweb.freebsd.org/changeset/base/348075

Log:
  Do not call hw_mds_recalculate() from initializecpu().
  
  If MDS mitigation is enabled by the tunable but MDS microcode is not
  early-loaded, software mitigation is selected.  This causes
  initializecpu() to try to allocate memory which makes boot process
  very unhappy.
  
  Create SYSINIT that runs sufficiently late to succeed.
  
  Reported by:	naddy
  PR:	237968
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/initcpu.c
  head/sys/i386/i386/initcpu.c
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/amd64/amd64/initcpu.c
==============================================================================
--- head/sys/amd64/amd64/initcpu.c	Tue May 21 22:24:38 2019	(r348074)
+++ head/sys/amd64/amd64/initcpu.c	Tue May 21 22:56:21 2019	(r348075)
@@ -257,7 +257,6 @@ initializecpu(void)
 	hw_ibrs_recalculate();
 	hw_ssb_recalculate(false);
 	amd64_syscall_ret_flush_l1d_recalc();
-	hw_mds_recalculate();
 	switch (cpu_vendor_id) {
 	case CPU_VENDOR_AMD:
 		init_amd();

Modified: head/sys/i386/i386/initcpu.c
==============================================================================
--- head/sys/i386/i386/initcpu.c	Tue May 21 22:24:38 2019	(r348074)
+++ head/sys/i386/i386/initcpu.c	Tue May 21 22:56:21 2019	(r348075)
@@ -749,7 +749,6 @@ initializecpu(void)
 		msr = rdmsr(MSR_EFER) | EFER_NXE;
 		wrmsr(MSR_EFER, msr);
 	}
-	hw_mds_recalculate();
 	if ((amd_feature & AMDID_RDTSCP) != 0 ||
 	    (cpu_stdext_feature2 & CPUID_STDEXT2_RDPID) != 0)
 		wrmsr(MSR_TSC_AUX, PCPU_GET(cpuid));

Modified: head/sys/x86/x86/cpu_machdep.c
==============================================================================
--- head/sys/x86/x86/cpu_machdep.c	Tue May 21 22:24:38 2019	(r348074)
+++ head/sys/x86/x86/cpu_machdep.c	Tue May 21 22:56:21 2019	(r348075)
@@ -1106,6 +1106,14 @@ hw_mds_recalculate(void)
 	}
 }
 
+static void
+hw_mds_recalculate_boot(void *arg __unused)
+{
+
+	hw_mds_recalculate();
+}
+SYSINIT(mds_recalc, SI_SUB_SMP, SI_ORDER_ANY, hw_mds_recalculate_boot, NULL);
+
 static int
 sysctl_mds_disable_handler(SYSCTL_HANDLER_ARGS)
 {



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