target/arm/kvm: Have kvm_arm_[get|put]_virtual_time take ARMCPU argument

Unify the "kvm_arm.h" API: All functions related to ARM vCPUs
take a ARMCPU* argument. Use the CPU() QOM cast macro When
calling the generic vCPU API from "sysemu/kvm.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Message-id: 20231123183518.64569-13-philmd@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2023-12-19 17:57:47 +00:00 committed by Peter Maydell
parent 0d31a63186
commit 76acc98799

View File

@ -1034,20 +1034,19 @@ static int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)
/** /**
* kvm_arm_get_virtual_time: * kvm_arm_get_virtual_time:
* @cs: CPUState * @cpu: ARMCPU
* *
* Gets the VCPU's virtual counter and stores it in the KVM CPU state. * Gets the VCPU's virtual counter and stores it in the KVM CPU state.
*/ */
static void kvm_arm_get_virtual_time(CPUState *cs) static void kvm_arm_get_virtual_time(ARMCPU *cpu)
{ {
ARMCPU *cpu = ARM_CPU(cs);
int ret; int ret;
if (cpu->kvm_vtime_dirty) { if (cpu->kvm_vtime_dirty) {
return; return;
} }
ret = kvm_get_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime); ret = kvm_get_one_reg(CPU(cpu), KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime);
if (ret) { if (ret) {
error_report("Failed to get KVM_REG_ARM_TIMER_CNT"); error_report("Failed to get KVM_REG_ARM_TIMER_CNT");
abort(); abort();
@ -1058,20 +1057,19 @@ static void kvm_arm_get_virtual_time(CPUState *cs)
/** /**
* kvm_arm_put_virtual_time: * kvm_arm_put_virtual_time:
* @cs: CPUState * @cpu: ARMCPU
* *
* Sets the VCPU's virtual counter to the value stored in the KVM CPU state. * Sets the VCPU's virtual counter to the value stored in the KVM CPU state.
*/ */
static void kvm_arm_put_virtual_time(CPUState *cs) static void kvm_arm_put_virtual_time(ARMCPU *cpu)
{ {
ARMCPU *cpu = ARM_CPU(cs);
int ret; int ret;
if (!cpu->kvm_vtime_dirty) { if (!cpu->kvm_vtime_dirty) {
return; return;
} }
ret = kvm_set_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime); ret = kvm_set_one_reg(CPU(cpu), KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime);
if (ret) { if (ret) {
error_report("Failed to set KVM_REG_ARM_TIMER_CNT"); error_report("Failed to set KVM_REG_ARM_TIMER_CNT");
abort(); abort();
@ -1289,16 +1287,15 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
static void kvm_arm_vm_state_change(void *opaque, bool running, RunState state) static void kvm_arm_vm_state_change(void *opaque, bool running, RunState state)
{ {
CPUState *cs = opaque; ARMCPU *cpu = opaque;
ARMCPU *cpu = ARM_CPU(cs);
if (running) { if (running) {
if (cpu->kvm_adjvtime) { if (cpu->kvm_adjvtime) {
kvm_arm_put_virtual_time(cs); kvm_arm_put_virtual_time(cpu);
} }
} else { } else {
if (cpu->kvm_adjvtime) { if (cpu->kvm_adjvtime) {
kvm_arm_get_virtual_time(cs); kvm_arm_get_virtual_time(cpu);
} }
} }
} }
@ -1879,7 +1876,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
return -EINVAL; return -EINVAL;
} }
qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs); qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cpu);
/* Determine init features for this CPU */ /* Determine init features for this CPU */
memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features)); memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));