void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)

{

    struct kvm_s390_vm_cpu_processor prop  = {

        .fac_list = { 0 },

    };

    struct kvm_device_attr attr = {

        .group = KVM_S390_VM_CPU_MODEL,

        .attr = KVM_S390_VM_CPU_PROCESSOR,

        .addr = (uint64_t) &prop,

    };

    int rc;



    if (!model) {

        /* compatibility handling if cpu models are disabled */

        if (kvm_s390_cmma_available() && !mem_path) {

            kvm_s390_enable_cmma();

        }

        return;

    }

    if (!kvm_s390_cpu_models_supported()) {

        error_setg(errp, "KVM doesn't support CPU models");

        return;

    }

    prop.cpuid = s390_cpuid_from_cpu_model(model);

    prop.ibc = s390_ibc_from_cpu_model(model);

    /* configure cpu features indicated via STFL(e) */

    s390_fill_feat_block(model->features, S390_FEAT_TYPE_STFL,

                         (uint8_t *) prop.fac_list);

    rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);

    if (rc) {

        error_setg(errp, "KVM: Error configuring the CPU model: %d", rc);

        return;

    }

    /* configure cpu features indicated e.g. via SCLP */

    rc = configure_cpu_feat(model->features);

    if (rc) {

        error_setg(errp, "KVM: Error configuring CPU features: %d", rc);

        return;

    }

    /* configure cpu subfunctions indicated via query / test bit */

    rc = configure_cpu_subfunc(model->features);

    if (rc) {

        error_setg(errp, "KVM: Error configuring CPU subfunctions: %d", rc);

        return;

    }

    /* enable CMM via CMMA - disable on hugetlbfs */

    if (test_bit(S390_FEAT_CMM, model->features)) {

        if (mem_path) {

            error_report("Warning: CMM will not be enabled because it is not "

                         "compatible to hugetlbfs.");

        } else {

            kvm_s390_enable_cmma();

        }

    }

}

void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)

{

    struct kvm_s390_vm_cpu_processor prop  = {

        .fac_list = { 0 },

    };

    struct kvm_device_attr attr = {

        .group = KVM_S390_VM_CPU_MODEL,

        .attr = KVM_S390_VM_CPU_PROCESSOR,

        .addr = (uint64_t) &prop,

    };

    int rc;



    if (!model) {

        

        if (kvm_s390_cmma_available() && !mem_path) {

            kvm_s390_enable_cmma();

        }

        return;

    }

    if (!kvm_s390_cpu_models_supported()) {

        error_setg(errp, "KVM doesn't support CPU models");

        return;

    }

    prop.cpuid = s390_cpuid_from_cpu_model(model);

    prop.ibc = s390_ibc_from_cpu_model(model);

    

    s390_fill_feat_block(model->features, S390_FEAT_TYPE_STFL,

                         (uint8_t *) prop.fac_list);

    rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);

    if (rc) {

        error_setg(errp, "KVM: Error configuring the CPU model: %d", rc);

        return;

    }

    

    rc = configure_cpu_feat(model->features);

    if (rc) {

        error_setg(errp, "KVM: Error configuring CPU features: %d", rc);

        return;

    }

    

    rc = configure_cpu_subfunc(model->features);

    if (rc) {

        error_setg(errp, "KVM: Error configuring CPU subfunctions: %d", rc);

        return;

    }

    

    if (test_bit(S390_FEAT_CMM, model->features)) {

        if (mem_path) {

            error_report("Warning: CMM will not be enabled because it is not "

                         "compatible to hugetlbfs.");

        } else {

            kvm_s390_enable_cmma();

        }

    }

}

void FUNC_0(const S390CPUModel *VAR_0, Error **VAR_1)

{

    struct kvm_s390_vm_cpu_processor VAR_2  = {

        .fac_list = { 0 },

    };

    struct kvm_device_attr VAR_3 = {

        .group = KVM_S390_VM_CPU_MODEL,

        .VAR_3 = KVM_S390_VM_CPU_PROCESSOR,

        .addr = (uint64_t) &VAR_2,

    };

    int VAR_4;



    if (!VAR_0) {

        

        if (kvm_s390_cmma_available() && !mem_path) {

            kvm_s390_enable_cmma();

        }

        return;

    }

    if (!kvm_s390_cpu_models_supported()) {

        error_setg(VAR_1, "KVM doesn't support CPU models");

        return;

    }

    VAR_2.cpuid = s390_cpuid_from_cpu_model(VAR_0);

    VAR_2.ibc = s390_ibc_from_cpu_model(VAR_0);

    

    s390_fill_feat_block(VAR_0->features, S390_FEAT_TYPE_STFL,

                         (uint8_t *) VAR_2.fac_list);

    VAR_4 = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &VAR_3);

    if (VAR_4) {

        error_setg(VAR_1, "KVM: Error configuring the CPU VAR_0: %d", VAR_4);

        return;

    }

    

    VAR_4 = configure_cpu_feat(VAR_0->features);

    if (VAR_4) {

        error_setg(VAR_1, "KVM: Error configuring CPU features: %d", VAR_4);

        return;

    }

    

    VAR_4 = configure_cpu_subfunc(VAR_0->features);

    if (VAR_4) {

        error_setg(VAR_1, "KVM: Error configuring CPU subfunctions: %d", VAR_4);

        return;

    }

    

    if (test_bit(S390_FEAT_CMM, VAR_0->features)) {

        if (mem_path) {

            error_report("Warning: CMM will not be enabled because it is not "

                         "compatible to hugetlbfs.");

        } else {

            kvm_s390_enable_cmma();

        }

    }

}

void FUNC_0(const S390CPUModel *VAR_0, Error **VAR_1)
{ struct kvm_s390_vm_cpu_processor VAR_2  = { .fac_list = { 0 }, }; struct kvm_device_attr VAR_3 = { .group = KVM_S390_VM_CPU_MODEL,
.VAR_3 = KVM_S390_VM_CPU_PROCESSOR,
.addr = (uint64_t) &VAR_2,
}; int VAR_4; if (!VAR_0) { if (kvm_s390_cmma_available() && !mem_path) { kvm_s390_enable_cmma(); } return; } if (!kvm_s390_cpu_models_supported()) { error_setg(VAR_1, "KVM doesn't support CPU models"); return; } VAR_2.cpuid = s390_cpuid_from_cpu_model(VAR_0); VAR_2.ibc = s390_ibc_from_cpu_model(VAR_0); s390_fill_feat_block(VAR_0->features, S390_FEAT_TYPE_STFL,
(uint8_t *) VAR_2.fac_list); VAR_4 = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &VAR_3); if (VAR_4) { error_setg(VAR_1, "KVM: Error configuring the CPU VAR_0: %d", VAR_4); return; } VAR_4 = configure_cpu_feat(VAR_0->features); if (VAR_4) { error_setg(VAR_1, "KVM: Error configuring CPU features: %d", VAR_4); return; } VAR_4 = configure_cpu_subfunc(VAR_0->features); if (VAR_4) { error_setg(VAR_1, "KVM: Error configuring CPU subfunctions: %d", VAR_4); return; } if (test_bit(S390_FEAT_CMM, VAR_0->features)) { if (mem_path) { error_report("Warning: CMM will not be enabled because it is not "
"compatible to hugetlbfs."); } else { kvm_s390_enable_cmma(); } } }