static int kvm_has_msr_star(CPUState *env)

{

    static int has_msr_star;

    int ret;



    /* first time */

    if (has_msr_star == 0) {        

        struct kvm_msr_list msr_list, *kvm_msr_list;



        has_msr_star = -1;



        /* Obtain MSR list from KVM.  These are the MSRs that we must

         * save/restore */

        msr_list.nmsrs = 0;

        ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list);

        if (ret < 0)

            return 0;



        /* Old kernel modules had a bug and could write beyond the provided

           memory. Allocate at least a safe amount of 1K. */

        kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) +

                                              msr_list.nmsrs *

                                              sizeof(msr_list.indices[0])));



        kvm_msr_list->nmsrs = msr_list.nmsrs;

        ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, kvm_msr_list);

        if (ret >= 0) {

            int i;



            for (i = 0; i < kvm_msr_list->nmsrs; i++) {

                if (kvm_msr_list->indices[i] == MSR_STAR) {

                    has_msr_star = 1;

                    break;

                }

            }

        }



        free(kvm_msr_list);

    }



    if (has_msr_star == 1)

        return 1;

    return 0;

}

static int kvm_has_msr_star(CPUState *env)

{

    static int has_msr_star;

    int ret;



    

    if (has_msr_star == 0) {        

        struct kvm_msr_list msr_list, *kvm_msr_list;



        has_msr_star = -1;



        



        msr_list.nmsrs = 0;

        ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list);

        if (ret < 0)

            return 0;



        



        kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) +

                                              msr_list.nmsrs *

                                              sizeof(msr_list.indices[0])));



        kvm_msr_list->nmsrs = msr_list.nmsrs;

        ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, kvm_msr_list);

        if (ret >= 0) {

            int i;



            for (i = 0; i < kvm_msr_list->nmsrs; i++) {

                if (kvm_msr_list->indices[i] == MSR_STAR) {

                    has_msr_star = 1;

                    break;

                }

            }

        }



        free(kvm_msr_list);

    }



    if (has_msr_star == 1)

        return 1;

    return 0;

}

        if (ret < 0)
static int FUNC_0(CPUState *VAR_0)

{

    static int VAR_1;

    int VAR_2;



    

    if (VAR_1 == 0) {        

        struct VAR_4 VAR_3, *VAR_4;



        VAR_1 = -1;



        



        VAR_3.nmsrs = 0;

        VAR_2 = kvm_ioctl(VAR_0->kvm_state, KVM_GET_MSR_INDEX_LIST, &VAR_3);

        if (VAR_2 < 0)

            return 0;



        



        VAR_4 = qemu_mallocz(MAX(1024, sizeof(VAR_3) +

                                              VAR_3.nmsrs *

                                              sizeof(VAR_3.indices[0])));



        VAR_4->nmsrs = VAR_3.nmsrs;

        VAR_2 = kvm_ioctl(VAR_0->kvm_state, KVM_GET_MSR_INDEX_LIST, VAR_4);

        if (VAR_2 >= 0) {

            int VAR_5;



            for (VAR_5 = 0; VAR_5 < VAR_4->nmsrs; VAR_5++) {

                if (VAR_4->indices[VAR_5] == MSR_STAR) {

                    VAR_1 = 1;

                    break;

                }

            }

        }



        free(VAR_4);

    }



    if (VAR_1 == 1)

        return 1;

    return 0;

}

static int FUNC_0(CPUState *VAR_0)
{ static int VAR_1; int VAR_2; if (VAR_1 == 0) { struct VAR_4 VAR_3, *VAR_4; VAR_1 = -1; VAR_3.nmsrs = 0; VAR_2 = kvm_ioctl(VAR_0->kvm_state, KVM_GET_MSR_INDEX_LIST, &VAR_3); if (VAR_2 < 0)
return 0; VAR_4 = qemu_mallocz(MAX(1024, sizeof(VAR_3) +
VAR_3.nmsrs *
sizeof(VAR_3.indices[0]))); VAR_4->nmsrs = VAR_3.nmsrs; VAR_2 = kvm_ioctl(VAR_0->kvm_state, KVM_GET_MSR_INDEX_LIST, VAR_4); if (VAR_2 >= 0) { int VAR_5; for (VAR_5 = 0; VAR_5 < VAR_4->nmsrs; VAR_5++) { if (VAR_4->indices[VAR_5] == MSR_STAR) { VAR_1 = 1; break; } } } free(VAR_4); } if (VAR_1 == 1)
return 1; return 0; }