diff --git a/hypervisor/arch/x86/guest/vcpuid.c b/hypervisor/arch/x86/guest/vcpuid.c index b6eed1f31..58820d67f 100644 --- a/hypervisor/arch/x86/guest/vcpuid.c +++ b/hypervisor/arch/x86/guest/vcpuid.c @@ -490,6 +490,11 @@ static int32_t set_vcpuid_extended_function(struct acrn_vm *vm) return result; } +static inline bool is_percpu_related(uint32_t leaf) +{ + return ((leaf == 0x1U) || (leaf == 0xbU) || (leaf == 0xdU) || (leaf == 0x19U) || (leaf == 0x80000001U) || (leaf == 0x2U)); +} + int32_t set_vcpuid_entries(struct acrn_vm *vm) { int32_t result; @@ -509,8 +514,7 @@ int32_t set_vcpuid_entries(struct acrn_vm *vm) vm->vcpuid_level = limit; for (i = 1U; i <= limit; i++) { - /* cpuid 1/0xb is percpu related */ - if ((i == 1U) || (i == 0xbU) || (i == 0xdU) || (i == 0x19U)) { + if (is_percpu_related(i)) { continue; } @@ -604,11 +608,6 @@ int32_t set_vcpuid_entries(struct acrn_vm *vm) return result; } -static inline bool is_percpu_related(uint32_t leaf) -{ - return ((leaf == 0x1U) || (leaf == 0xbU) || (leaf == 0xdU) || (leaf == 0x19U) || (leaf == 0x80000001U)); -} - static void guest_cpuid_01h(struct acrn_vcpu *vcpu, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { uint32_t apicid = vlapic_get_apicid(vcpu_vlapic(vcpu)); @@ -850,11 +849,11 @@ void guest_cpuid(struct acrn_vcpu *vcpu, uint32_t *eax, uint32_t *ebx, uint32_t default: /* - * In this switch statement, leaf shall either be 0x01U or 0x0bU - * or 0x0dU or 0x80000001U. All the other cases have been handled properly - * before this switch statement. - * Gracefully return if prior case clauses have not been met. + * In this switch statement, leaf 0x01/0x0b/0x0d/0x19/0x80000001 + * shall be handled specifically. All the other cases + * just return physical value. */ + cpuid_subleaf(leaf, *ecx, eax, ebx, ecx, edx); break; } }