-/* $OpenBSD: vmm.c,v 1.301 2022/01/11 20:34:22 tobhe Exp $ */
+/* $OpenBSD: vmm.c,v 1.302 2022/01/19 19:39:42 guenther Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
*rax = vmm_cpuid_level;
}
- CPUID_LEAF(*rax, 0, eax, ebx, ecx, edx);
+ /* we fake up values in the range (cpuid_level, vmm_cpuid_level] */
+ if (*rax <= cpuid_level || *rax > 0x80000000)
+ CPUID_LEAF(*rax, *rcx, eax, ebx, ecx, edx);
+ else
+ eax = ebx = ecx = edx = 0;
switch (*rax) {
case 0x00: /* Max level and vendor ID */
*rdx = 0;
break;
case 0x04: /* Deterministic cache info */
- if (*rcx == 0) {
- *rax = eax & VMM_CPUID4_CACHE_TOPOLOGY_MASK;
- *rbx = ebx;
- *rcx = ecx;
- *rdx = edx;
- } else {
- CPUID_LEAF(*rax, *rcx, eax, ebx, ecx, edx);
- *rax = eax & VMM_CPUID4_CACHE_TOPOLOGY_MASK;
- *rbx = ebx;
- *rcx = ecx;
- *rdx = edx;
- }
+ *rax = eax & VMM_CPUID4_CACHE_TOPOLOGY_MASK;
+ *rbx = ebx;
+ *rcx = ecx;
+ *rdx = edx;
break;
case 0x05: /* MONITOR/MWAIT (not supported) */
DPRINTF("%s: function 0x05 (monitor/mwait) not supported\n",
*rcx = 0;
*rdx = 0;
} else {
- CPUID_LEAF(*rax, *rcx, eax, ebx, ecx, edx);
*rax = eax;
*rbx = ebx;
*rcx = ecx;
*rdx = curcpu()->ci_extcacheinfo[3];
break;
case 0x80000007: /* apmi */
- CPUID(0x80000007, *rax, *rbx, *rcx, *rdx);
+ *rax = eax;
+ *rbx = ebx;
+ *rcx = ecx;
+ *rdx = edx;
break;
case 0x80000008: /* Phys bits info and topology (AMD) */
- CPUID(0x80000008, *rax, *rbx, *rcx, *rdx);
- *rbx &= VMM_AMDSPEC_EBX_MASK;
+ *rax = eax;
+ *rbx = ebx & VMM_AMDSPEC_EBX_MASK;
/* Reset %rcx (topology) */
*rcx = 0;
+ *rdx = edx;
break;
default:
DPRINTF("%s: unsupported rax=0x%llx\n", __func__, *rax);