Commit 50a2c6e5 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

kvm: reset state from the CPU's reset method



Now that we have a CPU object with a reset method, it is better to
keep the KVM reset close to the CPU reset.  Using qemu_register_reset
as we do now keeps them far apart.

With this patch, PPC no longer calls the kvm_arch_ function, so
it can get removed there.  Other arches call it from their CPU
reset handler, and the function gets an ARMCPU/X86CPU/S390CPU.

Note that ARM- and s390-specific functions are called kvm_arm_*
and kvm_s390_*, while x86-specific functions are called kvm_arch_*.
That follows the convention used by the different architectures.
Changing that is the topic of a separate patch.

Reviewed-by: default avatarGleb Natapov <gnatapov@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 7848c8d1
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -245,8 +245,6 @@ int kvm_arch_init_vcpu(CPUState *cpu);
/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
unsigned long kvm_arch_vcpu_id(CPUState *cpu);

void kvm_arch_reset_vcpu(CPUState *cpu);

int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
int kvm_arch_on_sigbus(int code, void *addr);

+0 −11
Original line number Diff line number Diff line
@@ -223,13 +223,6 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
    return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem);
}

static void kvm_reset_vcpu(void *opaque)
{
    CPUState *cpu = opaque;

    kvm_arch_reset_vcpu(cpu);
}

int kvm_init_vcpu(CPUState *cpu)
{
    KVMState *s = kvm_state;
@@ -269,10 +262,6 @@ int kvm_init_vcpu(CPUState *cpu)
    }

    ret = kvm_arch_init_vcpu(cpu);
    if (ret == 0) {
        qemu_register_reset(kvm_reset_vcpu, cpu);
        kvm_arch_reset_vcpu(cpu);
    }
err:
    return ret;
}
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "hw/arm/arm.h"
#include "sysemu/sysemu.h"
#include "sysemu/kvm.h"
#include "kvm_arm.h"

static void arm_cpu_set_pc(CPUState *cs, vaddr value)
{
@@ -165,6 +166,12 @@ static void arm_cpu_reset(CPUState *s)
     * tb_flush().
     */
    tb_flush(env);

#ifndef CONFIG_USER_ONLY
    if (kvm_enabled()) {
        kvm_arm_reset_vcpu(cpu);
    }
#endif
}

#ifndef CONFIG_USER_ONLY
+1 −3
Original line number Diff line number Diff line
@@ -510,11 +510,9 @@ int kvm_arch_get_registers(CPUState *cs)
    return 0;
}

void kvm_arch_reset_vcpu(CPUState *cs)
void kvm_arm_reset_vcpu(ARMCPU *cpu)
{
    /* Feed the kernel back its initial register state */
    ARMCPU *cpu = ARM_CPU(cs);

    memmove(cpu->cpreg_values, cpu->cpreg_reset_values,
            cpu->cpreg_array_len * sizeof(cpu->cpreg_values[0]));

+1 −1
Original line number Diff line number Diff line
@@ -260,6 +260,6 @@ int kvm_arch_get_registers(CPUState *cs)
    return ret;
}

void kvm_arch_reset_vcpu(CPUState *cs)
void kvm_arm_reset_vcpu(ARMCPU *cpu)
{
}
Loading