uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,

                                      uint32_t index, int reg)

{

    struct kvm_cpuid2 *cpuid;

    int i, max;

    uint32_t ret = 0;

    uint32_t cpuid_1_edx;



    if (!kvm_check_extension(env->kvm_state, KVM_CAP_EXT_CPUID)) {

        return -1U;

    }



    max = 1;

    while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {

        max *= 2;

    }



    for (i = 0; i < cpuid->nent; ++i) {

        if (cpuid->entries[i].function == function &&

            cpuid->entries[i].index == index) {

            switch (reg) {

            case R_EAX:

                ret = cpuid->entries[i].eax;

                break;

            case R_EBX:

                ret = cpuid->entries[i].ebx;

                break;

            case R_ECX:

                ret = cpuid->entries[i].ecx;

                break;

            case R_EDX:

                ret = cpuid->entries[i].edx;

                switch (function) {

                case 1:

                    /* KVM before 2.6.30 misreports the following features */

                    ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;

                    break;

                case 0x80000001:

                    /* On Intel, kvm returns cpuid according to the Intel spec,

                     * so add missing bits according to the AMD spec:

                     */

                    cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);

                    ret |= cpuid_1_edx & 0x183f7ff;

                    break;

                }

                break;

            }

        }

    }



    qemu_free(cpuid);



    return ret;

}

uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,

                                      uint32_t index, int reg)

{

    struct kvm_cpuid2 *cpuid;

    int i, max;

    uint32_t ret = 0;

    uint32_t cpuid_1_edx;



    if (!kvm_check_extension(env->kvm_state, KVM_CAP_EXT_CPUID)) {

        return -1U;

    }



    max = 1;

    while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {

        max *= 2;

    }



    for (i = 0; i < cpuid->nent; ++i) {

        if (cpuid->entries[i].function == function &&

            cpuid->entries[i].index == index) {

            switch (reg) {

            case R_EAX:

                ret = cpuid->entries[i].eax;

                break;

            case R_EBX:

                ret = cpuid->entries[i].ebx;

                break;

            case R_ECX:

                ret = cpuid->entries[i].ecx;

                break;

            case R_EDX:

                ret = cpuid->entries[i].edx;

                switch (function) {

                case 1:

                    

                    ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;

                    break;

                case 0x80000001:

                    





                    cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);

                    ret |= cpuid_1_edx & 0x183f7ff;

                    break;

                }

                break;

            }

        }

    }



    qemu_free(cpuid);



    return ret;

}

    if (!kvm_check_extension(env->kvm_state, KVM_CAP_EXT_CPUID)) {         return -1U; uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,                                       uint32_t index, int reg)
uint32_t FUNC_0(CPUState *env, uint32_t function,

                                      uint32_t index, int reg)

{

    struct kvm_cpuid2 *VAR_0;

    int VAR_1, VAR_2;

    uint32_t ret = 0;

    uint32_t cpuid_1_edx;



    if (!kvm_check_extension(env->kvm_state, KVM_CAP_EXT_CPUID)) {

        return -1U;

    }



    VAR_2 = 1;

    while ((VAR_0 = try_get_cpuid(env->kvm_state, VAR_2)) == NULL) {

        VAR_2 *= 2;

    }



    for (VAR_1 = 0; VAR_1 < VAR_0->nent; ++VAR_1) {

        if (VAR_0->entries[VAR_1].function == function &&

            VAR_0->entries[VAR_1].index == index) {

            switch (reg) {

            case R_EAX:

                ret = VAR_0->entries[VAR_1].eax;

                break;

            case R_EBX:

                ret = VAR_0->entries[VAR_1].ebx;

                break;

            case R_ECX:

                ret = VAR_0->entries[VAR_1].ecx;

                break;

            case R_EDX:

                ret = VAR_0->entries[VAR_1].edx;

                switch (function) {

                case 1:

                    

                    ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;

                    break;

                case 0x80000001:

                    





                    cpuid_1_edx = FUNC_0(env, 1, 0, R_EDX);

                    ret |= cpuid_1_edx & 0x183f7ff;

                    break;

                }

                break;

            }

        }

    }



    qemu_free(VAR_0);



    return ret;

}

uint32_t FUNC_0(CPUState *env, uint32_t function,
uint32_t index, int reg)
{ struct kvm_cpuid2 *VAR_0; int VAR_1, VAR_2; uint32_t ret = 0; uint32_t cpuid_1_edx; if (!kvm_check_extension(env->kvm_state, KVM_CAP_EXT_CPUID)) { return -1U; } VAR_2 = 1; while ((VAR_0 = try_get_cpuid(env->kvm_state, VAR_2)) == NULL) { VAR_2 *= 2; } for (VAR_1 = 0; VAR_1 < VAR_0->nent; ++VAR_1) { if (VAR_0->entries[VAR_1].function == function &&
VAR_0->entries[VAR_1].index == index) { switch (reg) { case R_EAX:
ret = VAR_0->entries[VAR_1].eax; break; case R_EBX:
ret = VAR_0->entries[VAR_1].ebx; break; case R_ECX:
ret = VAR_0->entries[VAR_1].ecx; break; case R_EDX:
ret = VAR_0->entries[VAR_1].edx; switch (function) { case 1:
ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA; break; case 0x80000001:
cpuid_1_edx = FUNC_0(env, 1, 0, R_EDX); ret |= cpuid_1_edx & 0x183f7ff; break; } break; } } } qemu_free(VAR_0); return ret; }