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
This commit is contained in:
parent
a1fa02673a
commit
38955f5698
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315235
@ -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 *nr_pages)
|
||||
out:
|
||||
free(map);
|
||||
}
|
||||
#endif
|
||||
#endif /* __i386__ || __amd64__ */
|
||||
|
||||
#ifndef EFI_STAGING_SIZE
|
||||
#define EFI_STAGING_SIZE 64
|
||||
|
Loading…
Reference in New Issue
Block a user