Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2018 22:36:25 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r331466 - head/sys/x86/x86
Message-ID:  <201803232236.w2NMaP8f088065@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Mar 23 22:36:24 2018
New Revision: 331466
URL: https://svnweb.freebsd.org/changeset/base/331466

Log:
  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.
  
  Reported by:	jpaetzel
  Reviewed by:	kib
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D14810

Modified:
  head/sys/x86/x86/identcpu.c

Modified: head/sys/x86/x86/identcpu.c
==============================================================================
--- head/sys/x86/x86/identcpu.c	Fri Mar 23 21:06:06 2018	(r331465)
+++ head/sys/x86/x86/identcpu.c	Fri Mar 23 22:36:24 2018	(r331466)
@@ -1304,6 +1304,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];



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