Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Mar 2017 05:05:12 +0000 (UTC)
From:      Peter Grehan <grehan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r315927 - in stable/11/sys: amd64/vmm x86/include x86/x86
Message-ID:  <201703250505.v2P55Cx1099042@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: grehan
Date: Sat Mar 25 05:05:12 2017
New Revision: 315927
URL: https://svnweb.freebsd.org/changeset/base/315927

Log:
  MFC  r315361 and  r315364: Hide MONITORX/MWAITX from guests.
  
  r315361
    Add the AMD MONITORX/MWAITX feature definition introduced in
    Bulldozer/Ryzen CPUs.
  
  r315364
    Hide the AMD MONITORX/MWAITX capability.
    Otherwise, recent Linux guests will use these instructions, resulting
    in #UD exceptions since bhyve doesn't implement MONITOR/MWAIT exits.
  
    This fixes boot-time hangs in recent Linux guests on Ryzen CPUs
    (and probably Bulldozer aka AMD FX as well).

Modified:
  stable/11/sys/amd64/vmm/x86.c
  stable/11/sys/x86/include/specialreg.h
  stable/11/sys/x86/x86/identcpu.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/vmm/x86.c
==============================================================================
--- stable/11/sys/amd64/vmm/x86.c	Sat Mar 25 02:55:13 2017	(r315926)
+++ stable/11/sys/amd64/vmm/x86.c	Sat Mar 25 05:05:12 2017	(r315927)
@@ -176,6 +176,9 @@ x86_emulate_cpuid(struct vm *vm, int vcp
 			/* Don't advertise the OS visible workaround feature */
 			regs[2] &= ~AMDID2_OSVW;
 
+			/* Hide mwaitx/monitorx capability from the guest */
+			regs[2] &= ~AMDID2_MWAITX;
+
 			/*
 			 * Hide rdtscp/ia32_tsc_aux until we know how
 			 * to deal with them.

Modified: stable/11/sys/x86/include/specialreg.h
==============================================================================
--- stable/11/sys/x86/include/specialreg.h	Sat Mar 25 02:55:13 2017	(r315926)
+++ stable/11/sys/x86/include/specialreg.h	Sat Mar 25 05:05:12 2017	(r315927)
@@ -227,6 +227,7 @@
 #define	AMDID2_DBE	0x04000000
 #define	AMDID2_PTSC	0x08000000
 #define	AMDID2_PTSCEL2I	0x10000000
+#define	AMDID2_MWAITX	0x20000000
 
 /*
  * CPUID instruction 1 eax info

Modified: stable/11/sys/x86/x86/identcpu.c
==============================================================================
--- stable/11/sys/x86/x86/identcpu.c	Sat Mar 25 02:55:13 2017	(r315926)
+++ stable/11/sys/x86/x86/identcpu.c	Sat Mar 25 05:05:12 2017	(r315927)
@@ -906,7 +906,7 @@ printcpuinfo(void)
 				"\033DBE"	/* Data Breakpoint extension */
 				"\034PTSC"	/* Performance TSC */
 				"\035PL2I"	/* L2I perf count */
-				"\036<b29>"
+		       	        "\036MWAITX"	/* MONITORX/MWAITX instructions */
 				"\037<b30>"
 				"\040<b31>"
 				);



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