svn commit: r315235 - head/sys/boot/efi/loader

Dexuan Cui dexuan at FreeBSD.org
Tue Mar 14 08:12:15 UTC 2017


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


More information about the svn-src-head mailing list