int kvm_init_vcpu(CPUState *env)

{

    KVMState *s = kvm_state;

    long mmap_size;

    int ret;



    DPRINTF("kvm_init_vcpu\n");



    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);

    if (ret < 0) {

        DPRINTF("kvm_create_vcpu failed\n");

        goto err;

    }



    env->kvm_fd = ret;

    env->kvm_state = s;



    mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);

    if (mmap_size < 0) {

        DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n");

        goto err;

    }



    env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,

                        env->kvm_fd, 0);

    if (env->kvm_run == MAP_FAILED) {

        ret = -errno;

        DPRINTF("mmap'ing vcpu state failed\n");

        goto err;

    }



#ifdef KVM_CAP_COALESCED_MMIO

    if (s->coalesced_mmio && !s->coalesced_mmio_ring) {

        s->coalesced_mmio_ring =

            (void *)env->kvm_run + s->coalesced_mmio * PAGE_SIZE;

    }

#endif



    ret = kvm_arch_init_vcpu(env);

    if (ret == 0) {

        qemu_register_reset(kvm_reset_vcpu, env);

        kvm_arch_reset_vcpu(env);

    }

err:

    return ret;

}

int kvm_init_vcpu(CPUState *env)

{

    KVMState *s = kvm_state;

    long mmap_size;

    int ret;



    DPRINTF("kvm_init_vcpu\n");



    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);

    if (ret < 0) {

        DPRINTF("kvm_create_vcpu failed\n");

        goto err;

    }



    env->kvm_fd = ret;

    env->kvm_state = s;



    mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);

    if (mmap_size < 0) {

        DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n");

        goto err;

    }



    env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,

                        env->kvm_fd, 0);

    if (env->kvm_run == MAP_FAILED) {

        ret = -errno;

        DPRINTF("mmap'ing vcpu state failed\n");

        goto err;

    }



#ifdef KVM_CAP_COALESCED_MMIO

    if (s->coalesced_mmio && !s->coalesced_mmio_ring) {

        s->coalesced_mmio_ring =

            (void *)env->kvm_run + s->coalesced_mmio * PAGE_SIZE;

    }

#endif



    ret = kvm_arch_init_vcpu(env);

    if (ret == 0) {

        qemu_register_reset(kvm_reset_vcpu, env);

        kvm_arch_reset_vcpu(env);

    }

err:

    return ret;

}

#endif #endif #endif #ifdef KVM_CAP_COALESCED_MMIO #endif #ifdef KVM_CAP_COALESCED_MMIO #endif #ifdef KVM_CAP_COALESCED_MMIO #endif #ifdef KVM_CAP_COALESCED_MMIO #endif         goto err; #ifdef KVM_CAP_COALESCED_MMIO #endif #ifdef KVM_CAP_COALESCED_MMIO #endif     KVMState *s = kvm_state; #endif #endif #endif #endif #endif
int FUNC_0(CPUState *VAR_0)

{

    KVMState *s = kvm_state;

    long VAR_1;

    int VAR_2;



    DPRINTF("FUNC_0\n");



    VAR_2 = kvm_vm_ioctl(s, KVM_CREATE_VCPU, VAR_0->cpu_index);

    if (VAR_2 < 0) {

        DPRINTF("kvm_create_vcpu failed\n");

        goto err;

    }



    VAR_0->kvm_fd = VAR_2;

    VAR_0->kvm_state = s;



    VAR_1 = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);

    if (VAR_1 < 0) {

        DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n");

        goto err;

    }



    VAR_0->kvm_run = mmap(NULL, VAR_1, PROT_READ | PROT_WRITE, MAP_SHARED,

                        VAR_0->kvm_fd, 0);

    if (VAR_0->kvm_run == MAP_FAILED) {

        VAR_2 = -errno;

        DPRINTF("mmap'ing vcpu state failed\n");

        goto err;

    }



#ifdef KVM_CAP_COALESCED_MMIO

    if (s->coalesced_mmio && !s->coalesced_mmio_ring) {

        s->coalesced_mmio_ring =

            (void *)VAR_0->kvm_run + s->coalesced_mmio * PAGE_SIZE;

    }

#endif



    VAR_2 = kvm_arch_init_vcpu(VAR_0);

    if (VAR_2 == 0) {

        qemu_register_reset(kvm_reset_vcpu, VAR_0);

        kvm_arch_reset_vcpu(VAR_0);

    }

err:

    return VAR_2;

}

int FUNC_0(CPUState *VAR_0)
{ KVMState *s = kvm_state; long VAR_1; int VAR_2; DPRINTF("FUNC_0\n"); VAR_2 = kvm_vm_ioctl(s, KVM_CREATE_VCPU, VAR_0->cpu_index); if (VAR_2 < 0) { DPRINTF("kvm_create_vcpu failed\n"); goto err; } VAR_0->kvm_fd = VAR_2; VAR_0->kvm_state = s; VAR_1 = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0); if (VAR_1 < 0) { DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n"); goto err; } VAR_0->kvm_run = mmap(NULL, VAR_1, PROT_READ | PROT_WRITE, MAP_SHARED,
VAR_0->kvm_fd, 0); if (VAR_0->kvm_run == MAP_FAILED) { VAR_2 = -errno; DPRINTF("mmap'ing vcpu state failed\n"); goto err; } #ifdef KVM_CAP_COALESCED_MMIO
if (s->coalesced_mmio && !s->coalesced_mmio_ring) { s->coalesced_mmio_ring =
(void *)VAR_0->kvm_run + s->coalesced_mmio * PAGE_SIZE; } #endif
VAR_2 = kvm_arch_init_vcpu(VAR_0); if (VAR_2 == 0) { qemu_register_reset(kvm_reset_vcpu, VAR_0); kvm_arch_reset_vcpu(VAR_0); } err:
return VAR_2; }