From owner-svn-src-head@freebsd.org Tue Mar 14 08:12:15 2017 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 5012ED0B2EA; Tue, 14 Mar 2017 08:12:15 +0000 (UTC) (envelope-from dexuan@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 1FBCF1715; Tue, 14 Mar 2017 08:12:15 +0000 (UTC) (envelope-from dexuan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2E8CEVk024652; Tue, 14 Mar 2017 08:12:14 GMT (envelope-from dexuan@FreeBSD.org) Received: (from dexuan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2E8CE6V024651; Tue, 14 Mar 2017 08:12:14 GMT (envelope-from dexuan@FreeBSD.org) Message-Id: <201703140812.v2E8CE6V024651@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dexuan set sender to dexuan@FreeBSD.org using -f From: Dexuan Cui Date: Tue, 14 Mar 2017 08:12:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315235 - head/sys/boot/efi/loader 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.23 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: Tue, 14 Mar 2017 08:12:15 -0000 Author: dexuan Date: Tue Mar 14 08:12:14 2017 New Revision: 315235 URL: https://svnweb.freebsd.org/changeset/base/315235 Log: loader.efi: use stricter check for Hyper-V Some other hypervisors like Xen can pretend to be Hyper-V but obviously they can't implement all Hyper-V features. Let's make sure we're genuine Hyper-V here. Also fix some minor coding style issues. PR: 211746 MFC after: 2 weeks Sponsored by: Microsoft Modified: head/sys/boot/efi/loader/copy.c Modified: head/sys/boot/efi/loader/copy.c ============================================================================== --- head/sys/boot/efi/loader/copy.c Tue Mar 14 08:03:56 2017 (r315234) +++ head/sys/boot/efi/loader/copy.c Tue Mar 14 08:12:14 2017 (r315235) @@ -52,8 +52,11 @@ __FBSDID("$FreeBSD$"); #define CPUID_LEAF_HV_FEATURES 0x40000003 #define CPUID_LEAF_HV_LIMITS 0x40000005 #define CPUID_HV_IFACE_HYPERV 0x31237648 /* HV#1 */ +#define CPUID_HV_MSR_TIME_REFCNT 0x0002 /* MSR_HV_TIME_REF_COUNT */ #define CPUID_HV_MSR_HYPERCALL 0x0020 -static int running_on_hyperv(void) + +static int +running_on_hyperv(void) { char hv_vendor[16]; uint32_t regs[4]; @@ -80,6 +83,8 @@ static int running_on_hyperv(void) do_cpuid(CPUID_LEAF_HV_FEATURES, regs); if ((regs[0] & CPUID_HV_MSR_HYPERCALL) == 0) return (0); + if ((regs[0] & CPUID_HV_MSR_TIME_REFCNT) == 0) + return (0); return (1); } @@ -157,7 +162,7 @@ efi_verify_staging_size(unsigned long *n out: free(map); } -#endif +#endif /* __i386__ || __amd64__ */ #ifndef EFI_STAGING_SIZE #define EFI_STAGING_SIZE 64