mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-24 07:40:52 +00:00
Add a workaround to the hypervisor detection for older versions of KVM.
Originally KVM set %eax to 0 in the cpuid leaf 0x4000000 rather than to the highest supported leaf in the hypervisor "branch". Detect this case and fixup the %eax value so that the hypervisor is still detected. Reported by: jpaetzel Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D14810
This commit is contained in:
parent
05e8899d7d
commit
7091608617
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331466
@ -1304,6 +1304,18 @@ identify_hypervisor(void)
|
||||
if (cpu_feature2 & CPUID2_HV) {
|
||||
vm_guest = VM_GUEST_VM;
|
||||
do_cpuid(0x40000000, regs);
|
||||
|
||||
/*
|
||||
* KVM from Linux kernels prior to commit
|
||||
* 57c22e5f35aa4b9b2fe11f73f3e62bbf9ef36190 set %eax
|
||||
* to 0 rather than a valid hv_high value. Check for
|
||||
* the KVM signature bytes and fixup %eax to the
|
||||
* highest supported leaf in that case.
|
||||
*/
|
||||
if (regs[0] == 0 && regs[1] == 0x4b4d564b &&
|
||||
regs[2] == 0x564b4d56 && regs[3] == 0x0000004d)
|
||||
regs[0] = 0x40000001;
|
||||
|
||||
if (regs[0] >= 0x40000000) {
|
||||
hv_high = regs[0];
|
||||
((u_int *)&hv_vendor)[0] = regs[1];
|
||||
|
Loading…
Reference in New Issue
Block a user