Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Aug 2016 14:10:36 +0000 (UTC)
From:      Eric Badger <badger@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: r304429 - in stable/11/sys: amd64/amd64 i386/i386 kern sys x86/x86
Message-ID:  <201608181410.u7IEAasN003647@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: badger
Date: Thu Aug 18 14:10:36 2016
New Revision: 304429
URL: https://svnweb.freebsd.org/changeset/base/304429

Log:
  MFC r302783:
  
    Add explicit detection of KVM hypervisor
  
    Set vm_guest to a new enum value (VM_GUEST_KVM) when kvm is detected and use
    vm_guest in conditionals testing for KVM.
  
    Also, fix a conditional checking if we're running in a VM which caught only
    the generic VM case, but not more specific VMs (KVM, VMWare, etc.).  (Spotted
    by: vangyzen).
  
    Sponsored by:	Dell Inc.
    Approved by:	vangyzen (mentor)

Modified:
  stable/11/sys/amd64/amd64/pmap.c
  stable/11/sys/i386/i386/pmap.c
  stable/11/sys/kern/subr_param.c
  stable/11/sys/sys/systm.h
  stable/11/sys/x86/x86/identcpu.c
  stable/11/sys/x86/x86/local_apic.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/amd64/pmap.c
==============================================================================
--- stable/11/sys/amd64/amd64/pmap.c	Thu Aug 18 12:51:26 2016	(r304428)
+++ stable/11/sys/amd64/amd64/pmap.c	Thu Aug 18 14:10:36 2016	(r304429)
@@ -1224,7 +1224,7 @@ pmap_init(void)
 	 * include at least one feature that is only supported by older Intel
 	 * or newer AMD processors.
 	 */
-	if (vm_guest == VM_GUEST_VM && (cpu_feature & CPUID_SS) == 0 &&
+	if (vm_guest != VM_GUEST_NO && (cpu_feature & CPUID_SS) == 0 &&
 	    (cpu_feature2 & (CPUID2_SSSE3 | CPUID2_SSE41 | CPUID2_AESNI |
 	    CPUID2_AVX | CPUID2_XSAVE)) == 0 && (amd_feature2 & (AMDID2_XOP |
 	    AMDID2_FMA4)) == 0)

Modified: stable/11/sys/i386/i386/pmap.c
==============================================================================
--- stable/11/sys/i386/i386/pmap.c	Thu Aug 18 12:51:26 2016	(r304428)
+++ stable/11/sys/i386/i386/pmap.c	Thu Aug 18 14:10:36 2016	(r304429)
@@ -794,7 +794,7 @@ pmap_init(void)
 	 * include at least one feature that is only supported by older Intel
 	 * or newer AMD processors.
 	 */
-	if (vm_guest == VM_GUEST_VM && (cpu_feature & CPUID_SS) == 0 &&
+	if (vm_guest != VM_GUEST_NO && (cpu_feature & CPUID_SS) == 0 &&
 	    (cpu_feature2 & (CPUID2_SSSE3 | CPUID2_SSE41 | CPUID2_AESNI |
 	    CPUID2_AVX | CPUID2_XSAVE)) == 0 && (amd_feature2 & (AMDID2_XOP |
 	    AMDID2_FMA4)) == 0)

Modified: stable/11/sys/kern/subr_param.c
==============================================================================
--- stable/11/sys/kern/subr_param.c	Thu Aug 18 12:51:26 2016	(r304428)
+++ stable/11/sys/kern/subr_param.c	Thu Aug 18 14:10:36 2016	(r304429)
@@ -148,6 +148,7 @@ static const char *const vm_guest_sysctl
 	"xen",
 	"hv",
 	"vmware",
+	"kvm",
 	NULL
 };
 CTASSERT(nitems(vm_guest_sysctl_names) - 1 == VM_LAST);

Modified: stable/11/sys/sys/systm.h
==============================================================================
--- stable/11/sys/sys/systm.h	Thu Aug 18 12:51:26 2016	(r304428)
+++ stable/11/sys/sys/systm.h	Thu Aug 18 14:10:36 2016	(r304429)
@@ -74,7 +74,7 @@ extern int vm_guest;		/* Running as virt
  * Keep in sync with vm_guest_sysctl_names[].
  */
 enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
-		VM_GUEST_VMWARE, VM_LAST };
+		VM_GUEST_VMWARE, VM_GUEST_KVM, VM_LAST };
 
 #if defined(WITNESS) || defined(INVARIANT_SUPPORT)
 void	kassert_panic(const char *fmt, ...)  __printflike(1, 2);

Modified: stable/11/sys/x86/x86/identcpu.c
==============================================================================
--- stable/11/sys/x86/x86/identcpu.c	Thu Aug 18 12:51:26 2016	(r304428)
+++ stable/11/sys/x86/x86/identcpu.c	Thu Aug 18 14:10:36 2016	(r304429)
@@ -1300,6 +1300,8 @@ identify_hypervisor(void)
 				vm_guest = VM_GUEST_VMWARE;
 			else if (strcmp(hv_vendor, "Microsoft Hv") == 0)
 				vm_guest = VM_GUEST_HV;
+			else if (strcmp(hv_vendor, "KVMKVMKVM") == 0)
+				vm_guest = VM_GUEST_KVM;
 		}
 		return;
 	}

Modified: stable/11/sys/x86/x86/local_apic.c
==============================================================================
--- stable/11/sys/x86/x86/local_apic.c	Thu Aug 18 12:51:26 2016	(r304428)
+++ stable/11/sys/x86/x86/local_apic.c	Thu Aug 18 14:10:36 2016	(r304429)
@@ -499,8 +499,7 @@ native_lapic_init(vm_paddr_t addr)
 	ver = lapic_read32(LAPIC_VERSION);
 	if ((ver & APIC_VER_EOI_SUPPRESSION) != 0) {
 		lapic_eoi_suppression = 1;
-		if (vm_guest == VM_GUEST_VM &&
-		    !strcmp(hv_vendor, "KVMKVMKVM")) {
+		if (vm_guest == VM_GUEST_KVM) {
 			if (bootverbose)
 				printf(
 		       "KVM -- disabling lapic eoi suppression\n");



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