svn commit: r332743 - in stable: 10/sys/x86/x86 11/sys/x86/x86

John Baldwin jhb at FreeBSD.org
Thu Apr 19 00:11:02 UTC 2018


Author: jhb
Date: Thu Apr 19 00:11:02 2018
New Revision: 332743
URL: https://svnweb.freebsd.org/changeset/base/332743

Log:
  MFC 331466:
  Add a workaround to the hypervisor detection for older versions of KVM.
  
  Originally KVM set %eax to 0 in the cpuid leaf 0x4000000 rather than
  to the highest supported leaf in the hypervisor "branch".  Detect this
  case and fixup the %eax value so that the hypervisor is still
  detected.

Modified:
  stable/10/sys/x86/x86/identcpu.c
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/x86/x86/identcpu.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/10/sys/x86/x86/identcpu.c
==============================================================================
--- stable/10/sys/x86/x86/identcpu.c	Wed Apr 18 23:08:10 2018	(r332742)
+++ stable/10/sys/x86/x86/identcpu.c	Thu Apr 19 00:11:02 2018	(r332743)
@@ -1247,6 +1247,18 @@ identify_hypervisor(void)
 	if (cpu_feature2 & CPUID2_HV) {
 		vm_guest = VM_GUEST_VM;
 		do_cpuid(0x40000000, regs);
+
+		/*
+		 * KVM from Linux kernels prior to commit
+		 * 57c22e5f35aa4b9b2fe11f73f3e62bbf9ef36190 set %eax
+		 * to 0 rather than a valid hv_high value.  Check for
+		 * the KVM signature bytes and fixup %eax to the
+		 * highest supported leaf in that case.
+		 */
+		if (regs[0] == 0 && regs[1] == 0x4b4d564b &&
+		    regs[2] == 0x564b4d56 && regs[3] == 0x0000004d)
+			regs[0] = 0x40000001;
+			
 		if (regs[0] >= 0x40000000) {
 			hv_high = regs[0];
 			((u_int *)&hv_vendor)[0] = regs[1];


More information about the svn-src-all mailing list