Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/x86.c
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
int | int | ||||
x86_emulate_cpuid(struct vm *vm, int vcpu_id, | x86_emulate_cpuid(struct vm *vm, int vcpu_id, | ||||
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) | uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) | ||||
{ | { | ||||
const struct xsave_limits *limits; | const struct xsave_limits *limits; | ||||
uint64_t cr4; | uint64_t cr4; | ||||
int error, enable_invpcid, level, width, x2apic_id; | int error, enable_invpcid, enable_rdpid, enable_rdtscp, level, | ||||
width, x2apic_id; | |||||
unsigned int func, regs[4], logical_cpus; | unsigned int func, regs[4], logical_cpus; | ||||
enum x2apic_state x2apic_state; | enum x2apic_state x2apic_state; | ||||
uint16_t cores, maxcpus, sockets, threads; | uint16_t cores, maxcpus, sockets, threads; | ||||
VCPU_CTR2(vm, vcpu_id, "cpuid %#x,%#x", *eax, *ecx); | VCPU_CTR2(vm, vcpu_id, "cpuid %#x,%#x", *eax, *ecx); | ||||
/* | /* | ||||
* Requests for invalid CPUID levels should map to the highest | * Requests for invalid CPUID levels should map to the highest | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | case CPUID_8000_0001: | ||||
regs[2] &= ~AMDID2_NODE_ID; | regs[2] &= ~AMDID2_NODE_ID; | ||||
/* Don't advertise the OS visible workaround feature */ | /* Don't advertise the OS visible workaround feature */ | ||||
regs[2] &= ~AMDID2_OSVW; | regs[2] &= ~AMDID2_OSVW; | ||||
/* Hide mwaitx/monitorx capability from the guest */ | /* Hide mwaitx/monitorx capability from the guest */ | ||||
regs[2] &= ~AMDID2_MWAITX; | regs[2] &= ~AMDID2_MWAITX; | ||||
/* | /* Advertise RDTSCP if it is enabled. */ | ||||
* Hide rdtscp/ia32_tsc_aux until we know how | error = vm_get_capability(vm, vcpu_id, | ||||
* to deal with them. | VM_CAP_RDTSCP, &enable_rdtscp); | ||||
*/ | if (error == 0 && enable_rdtscp) | ||||
regs[3] |= AMDID_RDTSCP; | |||||
else | |||||
regs[3] &= ~AMDID_RDTSCP; | regs[3] &= ~AMDID_RDTSCP; | ||||
break; | break; | ||||
case CPUID_8000_0007: | case CPUID_8000_0007: | ||||
/* | /* | ||||
* AMD uses this leaf to advertise the processor's | * AMD uses this leaf to advertise the processor's | ||||
* power monitoring and RAS capabilities. These | * power monitoring and RAS capabilities. These | ||||
* features are hardware-specific and exposing | * features are hardware-specific and exposing | ||||
* them to a guest doesn't make a lot of sense. | * them to a guest doesn't make a lot of sense. | ||||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | case CPUID_0000_0007: | ||||
CPUID_STDEXT_ERMS | CPUID_STDEXT_RTM | | CPUID_STDEXT_ERMS | CPUID_STDEXT_RTM | | ||||
CPUID_STDEXT_AVX512F | | CPUID_STDEXT_AVX512F | | ||||
CPUID_STDEXT_RDSEED | | CPUID_STDEXT_RDSEED | | ||||
CPUID_STDEXT_AVX512PF | | CPUID_STDEXT_AVX512PF | | ||||
CPUID_STDEXT_AVX512ER | | CPUID_STDEXT_AVX512ER | | ||||
CPUID_STDEXT_AVX512CD | CPUID_STDEXT_SHA); | CPUID_STDEXT_AVX512CD | CPUID_STDEXT_SHA); | ||||
regs[2] = 0; | regs[2] = 0; | ||||
regs[3] &= CPUID_STDEXT3_MD_CLEAR; | regs[3] &= CPUID_STDEXT3_MD_CLEAR; | ||||
/* Advertise RDPID if it is enabled. */ | |||||
error = vm_get_capability(vm, vcpu_id, | |||||
VM_CAP_RDPID, &enable_rdpid); | |||||
if (error == 0 && enable_rdpid) | |||||
regs[2] |= CPUID_STDEXT2_RDPID; | |||||
/* Advertise INVPCID if it is enabled. */ | /* Advertise INVPCID if it is enabled. */ | ||||
error = vm_get_capability(vm, vcpu_id, | error = vm_get_capability(vm, vcpu_id, | ||||
VM_CAP_ENABLE_INVPCID, &enable_invpcid); | VM_CAP_ENABLE_INVPCID, &enable_invpcid); | ||||
if (error == 0 && enable_invpcid) | if (error == 0 && enable_invpcid) | ||||
regs[1] |= CPUID_STDEXT_INVPCID; | regs[1] |= CPUID_STDEXT_INVPCID; | ||||
} | } | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |