void kvmppc_set_papr(CPUPPCState *env)

{

    struct kvm_enable_cap cap = {};

    struct kvm_one_reg reg = {};

    struct kvm_sregs sregs = {};

    int ret;

    uint64_t hior = env->spr[SPR_HIOR];



    cap.cap = KVM_CAP_PPC_PAPR;

    ret = kvm_vcpu_ioctl(env, KVM_ENABLE_CAP, &cap);



    if (ret) {

        goto fail;

    }



    /*

     * XXX We set HIOR here. It really should be a qdev property of

     *     the CPU node, but we don't have CPUs converted to qdev yet.

     *

     *     Once we have qdev CPUs, move HIOR to a qdev property and

     *     remove this chunk.

     */

    reg.id = KVM_REG_PPC_HIOR;

    reg.addr = (uintptr_t)&hior;

    ret = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, &reg);

    if (ret) {

        fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"

                        "kernel with support for HV KVM but no PAPR PR \n"

                        "KVM in which case things will work. If they don't \n"

                        "please update your host kernel!\n");

    }



    /* Set SDR1 so kernel space finds the HTAB */

    ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);

    if (ret) {

        goto fail;

    }



    sregs.u.s.sdr1 = env->spr[SPR_SDR1];



    ret = kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);

    if (ret) {

        goto fail;

    }



    return;



fail:

    cpu_abort(env, "This KVM version does not support PAPR\n");

}

void kvmppc_set_papr(CPUPPCState *env)

{

    struct kvm_enable_cap cap = {};

    struct kvm_one_reg reg = {};

    struct kvm_sregs sregs = {};

    int ret;

    uint64_t hior = env->spr[SPR_HIOR];



    cap.cap = KVM_CAP_PPC_PAPR;

    ret = kvm_vcpu_ioctl(env, KVM_ENABLE_CAP, &cap);



    if (ret) {

        goto fail;

    }



    













    reg.id = KVM_REG_PPC_HIOR;

    reg.addr = (uintptr_t)&hior;

    ret = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, &reg);

    if (ret) {

        fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"

                        "kernel with support for HV KVM but no PAPR PR \n"

                        "KVM in which case things will work. If they don't \n"

                        "please update your host kernel!\n");

    }



    

    ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);

    if (ret) {

        goto fail;

    }



    sregs.u.s.sdr1 = env->spr[SPR_SDR1];



    ret = kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);

    if (ret) {

        goto fail;

    }



    return;



fail:

    cpu_abort(env, "This KVM version does not support PAPR\n");

}

    struct kvm_one_reg reg = {};     struct kvm_sregs sregs = {};     uint64_t hior = env->spr[SPR_HIOR];         goto fail;     reg.id = KVM_REG_PPC_HIOR;     reg.addr = (uintptr_t)&hior;     ret = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, &reg);     if (ret) {         fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"                         "kernel with support for HV KVM but no PAPR PR \n"                         "KVM in which case things will work. If they don't \n"                         "please update your host kernel!\n");     ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);     if (ret) {         goto fail;     sregs.u.s.sdr1 = env->spr[SPR_SDR1];     ret = kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);     if (ret) {         goto fail; fail:     cpu_abort(env, "This KVM version does not support PAPR\n");
void FUNC_0(CPUPPCState *VAR_0)

{

    struct kvm_enable_cap VAR_1 = {};

    struct kvm_one_reg VAR_2 = {};

    struct kvm_sregs VAR_3 = {};

    int VAR_4;

    uint64_t hior = VAR_0->spr[SPR_HIOR];



    VAR_1.VAR_1 = KVM_CAP_PPC_PAPR;

    VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_ENABLE_CAP, &VAR_1);



    if (VAR_4) {

        goto fail;

    }



    













    VAR_2.id = KVM_REG_PPC_HIOR;

    VAR_2.addr = (uintptr_t)&hior;

    VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_SET_ONE_REG, &VAR_2);

    if (VAR_4) {

        fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"

                        "kernel with support for HV KVM but no PAPR PR \n"

                        "KVM in which case things will work. If they don't \n"

                        "please update your host kernel!\n");

    }



    

    VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_GET_SREGS, &VAR_3);

    if (VAR_4) {

        goto fail;

    }



    VAR_3.u.s.sdr1 = VAR_0->spr[SPR_SDR1];



    VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_SET_SREGS, &VAR_3);

    if (VAR_4) {

        goto fail;

    }



    return;



fail:

    cpu_abort(VAR_0, "This KVM version does not support PAPR\n");

}

void FUNC_0(CPUPPCState *VAR_0)
{ struct kvm_enable_cap VAR_1 = {}; struct kvm_one_reg VAR_2 = {}; struct kvm_sregs VAR_3 = {}; int VAR_4; uint64_t hior = VAR_0->spr[SPR_HIOR]; VAR_1.VAR_1 = KVM_CAP_PPC_PAPR; VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_ENABLE_CAP, &VAR_1); if (VAR_4) { goto fail; } VAR_2.id = KVM_REG_PPC_HIOR; VAR_2.addr = (uintptr_t)&hior; VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_SET_ONE_REG, &VAR_2); if (VAR_4) { fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"
"kernel with support for HV KVM but no PAPR PR \n"
"KVM in which case things will work. If they don't \n"
"please update your host kernel!\n"); } VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_GET_SREGS, &VAR_3); if (VAR_4) { goto fail; } VAR_3.u.s.sdr1 = VAR_0->spr[SPR_SDR1]; VAR_4 = kvm_vcpu_ioctl(VAR_0, KVM_SET_SREGS, &VAR_3); if (VAR_4) { goto fail; } return; fail:
cpu_abort(VAR_0, "This KVM version does not support PAPR\n"); }