int kvm_arch_get_registers(CPUState *cs)

{

    S390CPU *cpu = S390_CPU(cs);

    CPUS390XState *env = &cpu->env;

    struct kvm_one_reg reg;

    struct kvm_sregs sregs;

    struct kvm_regs regs;

    int i, r;



    /* get the PSW */

    env->psw.addr = cs->kvm_run->psw_addr;

    env->psw.mask = cs->kvm_run->psw_mask;



    /* the GPRS */

    if (cap_sync_regs && cs->kvm_run->kvm_valid_regs & KVM_SYNC_GPRS) {

        for (i = 0; i < 16; i++) {

            env->regs[i] = cs->kvm_run->s.regs.gprs[i];

        }

    } else {

        r = kvm_vcpu_ioctl(cs, KVM_GET_REGS, &regs);

        if (r < 0) {

            return r;

        }

         for (i = 0; i < 16; i++) {

            env->regs[i] = regs.gprs[i];

        }

    }



    /* The ACRS and CRS */

    if (cap_sync_regs &&

        cs->kvm_run->kvm_valid_regs & KVM_SYNC_ACRS &&

        cs->kvm_run->kvm_valid_regs & KVM_SYNC_CRS) {

        for (i = 0; i < 16; i++) {

            env->aregs[i] = cs->kvm_run->s.regs.acrs[i];

            env->cregs[i] = cs->kvm_run->s.regs.crs[i];

        }

    } else {

        r = kvm_vcpu_ioctl(cs, KVM_GET_SREGS, &sregs);

        if (r < 0) {

            return r;

        }

         for (i = 0; i < 16; i++) {

            env->aregs[i] = sregs.acrs[i];

            env->cregs[i] = sregs.crs[i];

        }

    }



    /* The prefix */

    if (cap_sync_regs && cs->kvm_run->kvm_valid_regs & KVM_SYNC_PREFIX) {

        env->psa = cs->kvm_run->s.regs.prefix;

    }



    /* One Regs */

    reg.id = KVM_REG_S390_CPU_TIMER;

    reg.addr = (__u64)&(env->cputm);

    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

    if (r < 0) {

        return r;

    }



    reg.id = KVM_REG_S390_CLOCK_COMP;

    reg.addr = (__u64)&(env->ckc);

    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

    if (r < 0) {

        return r;

    }



    reg.id = KVM_REG_S390_TODPR;

    reg.addr = (__u64)&(env->todpr);

    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

    if (r < 0) {

        return r;

    }



    if (cap_async_pf) {

        reg.id = KVM_REG_S390_PFTOKEN;

        reg.addr = (__u64)&(env->pfault_token);

        r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

        if (r < 0) {

            return r;

        }



        reg.id = KVM_REG_S390_PFCOMPARE;

        reg.addr = (__u64)&(env->pfault_compare);

        r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

        if (r < 0) {

            return r;

        }



        reg.id = KVM_REG_S390_PFSELECT;

        reg.addr = (__u64)&(env->pfault_select);

        r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

        if (r < 0) {

            return r;

        }

    }



    return 0;

}

int kvm_arch_get_registers(CPUState *cs)

{

    S390CPU *cpu = S390_CPU(cs);

    CPUS390XState *env = &cpu->env;

    struct kvm_one_reg reg;

    struct kvm_sregs sregs;

    struct kvm_regs regs;

    int i, r;



    

    env->psw.addr = cs->kvm_run->psw_addr;

    env->psw.mask = cs->kvm_run->psw_mask;



    

    if (cap_sync_regs && cs->kvm_run->kvm_valid_regs & KVM_SYNC_GPRS) {

        for (i = 0; i < 16; i++) {

            env->regs[i] = cs->kvm_run->s.regs.gprs[i];

        }

    } else {

        r = kvm_vcpu_ioctl(cs, KVM_GET_REGS, &regs);

        if (r < 0) {

            return r;

        }

         for (i = 0; i < 16; i++) {

            env->regs[i] = regs.gprs[i];

        }

    }



    

    if (cap_sync_regs &&

        cs->kvm_run->kvm_valid_regs & KVM_SYNC_ACRS &&

        cs->kvm_run->kvm_valid_regs & KVM_SYNC_CRS) {

        for (i = 0; i < 16; i++) {

            env->aregs[i] = cs->kvm_run->s.regs.acrs[i];

            env->cregs[i] = cs->kvm_run->s.regs.crs[i];

        }

    } else {

        r = kvm_vcpu_ioctl(cs, KVM_GET_SREGS, &sregs);

        if (r < 0) {

            return r;

        }

         for (i = 0; i < 16; i++) {

            env->aregs[i] = sregs.acrs[i];

            env->cregs[i] = sregs.crs[i];

        }

    }



    

    if (cap_sync_regs && cs->kvm_run->kvm_valid_regs & KVM_SYNC_PREFIX) {

        env->psa = cs->kvm_run->s.regs.prefix;

    }



    

    reg.id = KVM_REG_S390_CPU_TIMER;

    reg.addr = (__u64)&(env->cputm);

    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

    if (r < 0) {

        return r;

    }



    reg.id = KVM_REG_S390_CLOCK_COMP;

    reg.addr = (__u64)&(env->ckc);

    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

    if (r < 0) {

        return r;

    }



    reg.id = KVM_REG_S390_TODPR;

    reg.addr = (__u64)&(env->todpr);

    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

    if (r < 0) {

        return r;

    }



    if (cap_async_pf) {

        reg.id = KVM_REG_S390_PFTOKEN;

        reg.addr = (__u64)&(env->pfault_token);

        r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

        if (r < 0) {

            return r;

        }



        reg.id = KVM_REG_S390_PFCOMPARE;

        reg.addr = (__u64)&(env->pfault_compare);

        r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

        if (r < 0) {

            return r;

        }



        reg.id = KVM_REG_S390_PFSELECT;

        reg.addr = (__u64)&(env->pfault_select);

        r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);

        if (r < 0) {

            return r;

        }

    }



    return 0;

}

int FUNC_0(CPUState *VAR_0)

{

    S390CPU *cpu = S390_CPU(VAR_0);

    CPUS390XState *env = &cpu->env;

    struct kvm_one_reg VAR_1;

    struct kvm_sregs VAR_2;

    struct kvm_regs VAR_3;

    int VAR_4, VAR_5;



    

    env->psw.addr = VAR_0->kvm_run->psw_addr;

    env->psw.mask = VAR_0->kvm_run->psw_mask;



    

    if (cap_sync_regs && VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_GPRS) {

        for (VAR_4 = 0; VAR_4 < 16; VAR_4++) {

            env->VAR_3[VAR_4] = VAR_0->kvm_run->s.VAR_3.gprs[VAR_4];

        }

    } else {

        VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_REGS, &VAR_3);

        if (VAR_5 < 0) {

            return VAR_5;

        }

         for (VAR_4 = 0; VAR_4 < 16; VAR_4++) {

            env->VAR_3[VAR_4] = VAR_3.gprs[VAR_4];

        }

    }



    

    if (cap_sync_regs &&

        VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_ACRS &&

        VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_CRS) {

        for (VAR_4 = 0; VAR_4 < 16; VAR_4++) {

            env->aregs[VAR_4] = VAR_0->kvm_run->s.VAR_3.acrs[VAR_4];

            env->cregs[VAR_4] = VAR_0->kvm_run->s.VAR_3.crs[VAR_4];

        }

    } else {

        VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_SREGS, &VAR_2);

        if (VAR_5 < 0) {

            return VAR_5;

        }

         for (VAR_4 = 0; VAR_4 < 16; VAR_4++) {

            env->aregs[VAR_4] = VAR_2.acrs[VAR_4];

            env->cregs[VAR_4] = VAR_2.crs[VAR_4];

        }

    }



    

    if (cap_sync_regs && VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_PREFIX) {

        env->psa = VAR_0->kvm_run->s.VAR_3.prefix;

    }



    

    VAR_1.id = KVM_REG_S390_CPU_TIMER;

    VAR_1.addr = (__u64)&(env->cputm);

    VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1);

    if (VAR_5 < 0) {

        return VAR_5;

    }



    VAR_1.id = KVM_REG_S390_CLOCK_COMP;

    VAR_1.addr = (__u64)&(env->ckc);

    VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1);

    if (VAR_5 < 0) {

        return VAR_5;

    }



    VAR_1.id = KVM_REG_S390_TODPR;

    VAR_1.addr = (__u64)&(env->todpr);

    VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1);

    if (VAR_5 < 0) {

        return VAR_5;

    }



    if (cap_async_pf) {

        VAR_1.id = KVM_REG_S390_PFTOKEN;

        VAR_1.addr = (__u64)&(env->pfault_token);

        VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1);

        if (VAR_5 < 0) {

            return VAR_5;

        }



        VAR_1.id = KVM_REG_S390_PFCOMPARE;

        VAR_1.addr = (__u64)&(env->pfault_compare);

        VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1);

        if (VAR_5 < 0) {

            return VAR_5;

        }



        VAR_1.id = KVM_REG_S390_PFSELECT;

        VAR_1.addr = (__u64)&(env->pfault_select);

        VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1);

        if (VAR_5 < 0) {

            return VAR_5;

        }

    }



    return 0;

}

int FUNC_0(CPUState *VAR_0)
{ S390CPU *cpu = S390_CPU(VAR_0); CPUS390XState *env = &cpu->env; struct kvm_one_reg VAR_1; struct kvm_sregs VAR_2; struct kvm_regs VAR_3; int VAR_4, VAR_5; env->psw.addr = VAR_0->kvm_run->psw_addr; env->psw.mask = VAR_0->kvm_run->psw_mask; if (cap_sync_regs && VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_GPRS) { for (VAR_4 = 0; VAR_4 < 16; VAR_4++) { env->VAR_3[VAR_4] = VAR_0->kvm_run->s.VAR_3.gprs[VAR_4]; } } else { VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_REGS, &VAR_3); if (VAR_5 < 0) { return VAR_5; } for (VAR_4 = 0; VAR_4 < 16; VAR_4++) { env->VAR_3[VAR_4] = VAR_3.gprs[VAR_4]; } } if (cap_sync_regs &&
VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_ACRS &&
VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_CRS) { for (VAR_4 = 0; VAR_4 < 16; VAR_4++) { env->aregs[VAR_4] = VAR_0->kvm_run->s.VAR_3.acrs[VAR_4]; env->cregs[VAR_4] = VAR_0->kvm_run->s.VAR_3.crs[VAR_4]; } } else { VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_SREGS, &VAR_2); if (VAR_5 < 0) { return VAR_5; } for (VAR_4 = 0; VAR_4 < 16; VAR_4++) { env->aregs[VAR_4] = VAR_2.acrs[VAR_4]; env->cregs[VAR_4] = VAR_2.crs[VAR_4]; } } if (cap_sync_regs && VAR_0->kvm_run->kvm_valid_regs & KVM_SYNC_PREFIX) { env->psa = VAR_0->kvm_run->s.VAR_3.prefix; } VAR_1.id = KVM_REG_S390_CPU_TIMER; VAR_1.addr = (__u64)&(env->cputm); VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1); if (VAR_5 < 0) { return VAR_5; } VAR_1.id = KVM_REG_S390_CLOCK_COMP; VAR_1.addr = (__u64)&(env->ckc); VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1); if (VAR_5 < 0) { return VAR_5; } VAR_1.id = KVM_REG_S390_TODPR; VAR_1.addr = (__u64)&(env->todpr); VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1); if (VAR_5 < 0) { return VAR_5; } if (cap_async_pf) { VAR_1.id = KVM_REG_S390_PFTOKEN; VAR_1.addr = (__u64)&(env->pfault_token); VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1); if (VAR_5 < 0) { return VAR_5; } VAR_1.id = KVM_REG_S390_PFCOMPARE; VAR_1.addr = (__u64)&(env->pfault_compare); VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1); if (VAR_5 < 0) { return VAR_5; } VAR_1.id = KVM_REG_S390_PFSELECT; VAR_1.addr = (__u64)&(env->pfault_select); VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_GET_ONE_REG, &VAR_1); if (VAR_5 < 0) { return VAR_5; } } return 0; }