From owner-svn-src-head@freebsd.org Wed Jul 13 19:19:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F3A4B982C5; Wed, 13 Jul 2016 19:19:20 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 381EE1A91; Wed, 13 Jul 2016 19:19:20 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6DJJJJx012414; Wed, 13 Jul 2016 19:19:19 GMT (envelope-from badger@FreeBSD.org) Received: (from badger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6DJJIcu012408; Wed, 13 Jul 2016 19:19:18 GMT (envelope-from badger@FreeBSD.org) Message-Id: <201607131919.u6DJJIcu012408@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: badger set sender to badger@FreeBSD.org using -f From: Eric Badger Date: Wed, 13 Jul 2016 19:19:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302783 - in head/sys: amd64/amd64 i386/i386 kern sys x86/x86 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2016 19:19:20 -0000 Author: badger Date: Wed Jul 13 19:19:18 2016 New Revision: 302783 URL: https://svnweb.freebsd.org/changeset/base/302783 Log: 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). Differential revision: https://reviews.freebsd.org/D7172 Sponsored by: Dell Inc. Approved by: kib (mentor), vangyzen (mentor) Reviewed by: alc MFC after: 4 weeks Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c head/sys/kern/subr_param.c head/sys/sys/systm.h head/sys/x86/x86/identcpu.c head/sys/x86/x86/local_apic.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Wed Jul 13 19:16:32 2016 (r302782) +++ head/sys/amd64/amd64/pmap.c Wed Jul 13 19:19:18 2016 (r302783) @@ -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: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Wed Jul 13 19:16:32 2016 (r302782) +++ head/sys/i386/i386/pmap.c Wed Jul 13 19:19:18 2016 (r302783) @@ -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: head/sys/kern/subr_param.c ============================================================================== --- head/sys/kern/subr_param.c Wed Jul 13 19:16:32 2016 (r302782) +++ head/sys/kern/subr_param.c Wed Jul 13 19:19:18 2016 (r302783) @@ -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: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Wed Jul 13 19:16:32 2016 (r302782) +++ head/sys/sys/systm.h Wed Jul 13 19:19:18 2016 (r302783) @@ -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: head/sys/x86/x86/identcpu.c ============================================================================== --- head/sys/x86/x86/identcpu.c Wed Jul 13 19:16:32 2016 (r302782) +++ head/sys/x86/x86/identcpu.c Wed Jul 13 19:19:18 2016 (r302783) @@ -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: head/sys/x86/x86/local_apic.c ============================================================================== --- head/sys/x86/x86/local_apic.c Wed Jul 13 19:16:32 2016 (r302782) +++ head/sys/x86/x86/local_apic.c Wed Jul 13 19:19:18 2016 (r302783) @@ -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");