Bug 237968

Summary: 12-STABLE: MDS software mitigation locks up on Haswell
Product: Base System Reporter: Christian Weisgerber <naddy>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Some People CC: emaste, kib
Priority: ---    
Version: 12.0-STABLE   
Hardware: amd64   
OS: Any   

Description Christian Weisgerber freebsd_committer freebsd_triage 2019-05-18 16:52:14 UTC
FreeBSD 12.0-STABLE r347955 GENERIC amd64

hw.mds_disable=3 (Automatic VERW or Software selection) in /boot/loader.conf

Enabling Microarchitectural Data Sampling mitigation on a Haswell Xeon without MD_CLEAR microcode causes the kernel to hang on boot after the ioapic0 line.

CPU: Intel(R) Xeon(R) CPU E3-1225 v3 @ 3.20GHz (3192.67-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x306c3  Family=0x6  Model=0x3c  Stepping=3
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,C
MOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
Features2=0x7ffafbff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x21<LAHF,ABM>
  Structured Extended Features=0x27ab<FSGSBASE,TSCADJ,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,NFPUSG>
  Structured Extended Features3=0x9c000000<IBPB,STIBP,L1DFL,SSBD>
  XSAVE Features=0x1<XSAVEOPT>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
  TSC: P-state invariant, performance statistics
Comment 1 commit-hook freebsd_committer freebsd_triage 2019-05-21 22:56:41 UTC
A commit references this bug:

Author: kib
Date: Tue May 21 22:56:22 UTC 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

Changes:
  head/sys/amd64/amd64/initcpu.c
  head/sys/i386/i386/initcpu.c
  head/sys/x86/x86/cpu_machdep.c
Comment 2 Christian Weisgerber freebsd_committer freebsd_triage 2019-06-02 14:12:56 UTC
This was also committed to stable/12 (r348357) and stable/11 (r348362).
I confirm that this fixes the problem in 12-STABLE.