Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Mar 2017 05:09:03 +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-10@freebsd.org
Subject:   svn commit: r315928 - in stable/10/sys: amd64/vmm x86/include x86/x86
Message-ID:  <201703250509.v2P593tK099229@repo.freebsd.org>

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

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/10/sys/amd64/vmm/x86.c
  stable/10/sys/x86/include/specialreg.h
  stable/10/sys/x86/x86/identcpu.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/vmm/x86.c
==============================================================================
--- stable/10/sys/amd64/vmm/x86.c	Sat Mar 25 05:05:12 2017	(r315927)
+++ stable/10/sys/amd64/vmm/x86.c	Sat Mar 25 05:09:03 2017	(r315928)
@@ -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/10/sys/x86/include/specialreg.h
==============================================================================
--- stable/10/sys/x86/include/specialreg.h	Sat Mar 25 05:05:12 2017	(r315927)
+++ stable/10/sys/x86/include/specialreg.h	Sat Mar 25 05:09:03 2017	(r315928)
@@ -226,6 +226,7 @@
 #define	AMDID2_DBE	0x04000000
 #define	AMDID2_PTSC	0x08000000
 #define	AMDID2_PTSCEL2I	0x10000000
+#define	AMDID2_MWAITX	0x20000000
 
 /*
  * CPUID instruction 1 eax info

Modified: stable/10/sys/x86/x86/identcpu.c
==============================================================================
--- stable/10/sys/x86/x86/identcpu.c	Sat Mar 25 05:05:12 2017	(r315927)
+++ stable/10/sys/x86/x86/identcpu.c	Sat Mar 25 05:09:03 2017	(r315928)
@@ -875,7 +875,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?201703250509.v2P593tK099229>