Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/x86.c
Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | switch (func) { | ||||
case CPUID_8000_0002: | case CPUID_8000_0002: | ||||
case CPUID_8000_0003: | case CPUID_8000_0003: | ||||
case CPUID_8000_0004: | case CPUID_8000_0004: | ||||
case CPUID_8000_0006: | case CPUID_8000_0006: | ||||
cpuid_count(*eax, *ecx, regs); | cpuid_count(*eax, *ecx, regs); | ||||
break; | break; | ||||
case CPUID_8000_0008: | case CPUID_8000_0008: | ||||
cpuid_count(*eax, *ecx, regs); | cpuid_count(*eax, *ecx, regs); | ||||
if (vmm_is_amd()) { | if (vmm_is_svm()) { | ||||
/* | /* | ||||
* As on Intel (0000_0007:0, EDX), mask out | * As on Intel (0000_0007:0, EDX), mask out | ||||
* unsupported or unsafe AMD extended features | * unsupported or unsafe AMD extended features | ||||
* (8000_0008 EBX). | * (8000_0008 EBX). | ||||
*/ | */ | ||||
regs[1] &= (AMDFEID_CLZERO | AMDFEID_IRPERF | | regs[1] &= (AMDFEID_CLZERO | AMDFEID_IRPERF | | ||||
AMDFEID_XSAVEERPTR); | AMDFEID_XSAVEERPTR); | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | case CPUID_8000_0007: | ||||
* TSC to keep track of time. | * TSC to keep track of time. | ||||
*/ | */ | ||||
if (tsc_is_invariant && smp_tsc) | if (tsc_is_invariant && smp_tsc) | ||||
regs[3] |= AMDPM_TSC_INVARIANT; | regs[3] |= AMDPM_TSC_INVARIANT; | ||||
break; | break; | ||||
case CPUID_8000_001D: | case CPUID_8000_001D: | ||||
/* AMD Cache topology, like 0000_0004 for Intel. */ | /* AMD Cache topology, like 0000_0004 for Intel. */ | ||||
if (!vmm_is_amd()) | if (!vmm_is_svm()) | ||||
goto default_leaf; | goto default_leaf; | ||||
/* | /* | ||||
* Similar to Intel, generate a ficticious cache | * Similar to Intel, generate a ficticious cache | ||||
* topology for the guest with L3 shared by the | * topology for the guest with L3 shared by the | ||||
* package, and L1 and L2 local to a core. | * package, and L1 and L2 local to a core. | ||||
*/ | */ | ||||
vm_get_topology(vm, &sockets, &cores, &threads, | vm_get_topology(vm, &sockets, &cores, &threads, | ||||
Show All 25 Lines | case CPUID_8000_001D: | ||||
regs[0] = (logical_cpus << 14) | (1 << 8) | | regs[0] = (logical_cpus << 14) | (1 << 8) | | ||||
(level << 5) | func; | (level << 5) | func; | ||||
regs[1] = (func > 0) ? (CACHE_LINE_SIZE - 1) : 0; | regs[1] = (func > 0) ? (CACHE_LINE_SIZE - 1) : 0; | ||||
regs[2] = 0; | regs[2] = 0; | ||||
regs[3] = 0; | regs[3] = 0; | ||||
break; | break; | ||||
case CPUID_8000_001E: | case CPUID_8000_001E: | ||||
/* AMD Family 16h+ additional identifiers */ | /* | ||||
if (!vmm_is_amd() || CPUID_TO_FAMILY(cpu_id) < 0x16) | * AMD Family 16h+ and Hygon Family 18h additional | ||||
* identifiers. | |||||
*/ | |||||
if (!vmm_is_svm() || CPUID_TO_FAMILY(cpu_id) < 0x16) | |||||
goto default_leaf; | goto default_leaf; | ||||
vm_get_topology(vm, &sockets, &cores, &threads, | vm_get_topology(vm, &sockets, &cores, &threads, | ||||
&maxcpus); | &maxcpus); | ||||
regs[0] = vcpu_id; | regs[0] = vcpu_id; | ||||
threads = MIN(0xFF, threads - 1); | threads = MIN(0xFF, threads - 1); | ||||
regs[1] = (threads << 8) | | regs[1] = (threads << 8) | | ||||
(vcpu_id >> log2(threads + 1)); | (vcpu_id >> log2(threads + 1)); | ||||
▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines |