target/arm/kvm: Unify kvm_arm_FOO() API
cover target/arm/kvm: Unify kvm_arm_FOO() API
Half of the API takes CPUState, the other ARMCPU...
$ git grep -F 'CPUState *' target/arm/kvm_arm.h | wc -l
16
$ git grep -F 'ARMCPU *' target/arm/kvm_arm.h | wc -l
14Since this is ARM specific, have it always take ARMCPU, and call the generic KVM API casting with the CPU() macro.
Based-on: <[email protected]>
"target/arm: kvm cleanups"
https://lore.kernel.org/qemu-devel/[email protected]/
Philippe Mathieu-Daudé (16):
hw/intc/arm_gicv3: Include missing 'qemu/error-report.h' header target/arm/kvm: Remove unused includes
target/arm/kvm: Have kvm_arm_add_vcpu_properties take a ARMCPU
argument
target/arm/kvm: Have kvm_arm_sve_set_vls take a ARMCPU argument target/arm/kvm: Have kvm_arm_sve_get_vls take a ARMCPU argument target/arm/kvm: Have kvm_arm_set_device_attr take a ARMCPU argument target/arm/kvm: Have kvm_arm_pvtime_init take a ARMCPU argument target/arm/kvm: Have kvm_arm_pmu_init take a ARMCPU argument target/arm/kvm: Have kvm_arm_pmu_set_irq take a ARMCPU argument target/arm/kvm: Have kvm_arm_vcpu_init take a ARMCPU argument target/arm/kvm: Have kvm_arm_vcpu_finalize take a ARMCPU argument target/arm/kvm: Have kvm_arm_[get|put]_virtual_time take ARMCPU
argument
target/arm/kvm: Have kvm_arm_verify_ext_dabt_pending take a ARMCPU arg target/arm/kvm: Have kvm_arm_handle_dabt_nisv take a ARMCPU argument target/arm/kvm: Have kvm_arm_handle_debug take a ARMCPU argument target/arm/kvm: Have kvm_arm_hw_debug_active take a ARMCPU argument
target/arm/kvm_arm.h | 26 ++++----- hw/arm/virt.c | 9 +-- hw/intc/arm_gicv3_its_kvm.c | 1 + target/arm/cpu.c | 2 +- target/arm/cpu64.c | 2 +- target/arm/kvm.c | 111 +++++++++++++++++------------------- 6 files changed, 73 insertions(+), 78 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/16 hw/intc/arm_gicv3: Include missing 'qemu/error-report.h' header
kvm_arm_its_reset_hold() calls warn_report(), itself declared in "qemu/error-report.h".
--- hw/intc/arm_gicv3_its_kvm.c | 1 + 1 file changed, 1 insertion(+)
hw/intc/arm_gicv3_its_kvm.c +1 -0
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "hw/intc/arm_gicv3_its_common.h" #include "hw/qdev-properties.h" #include "sysemu/runstate.h"
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 01/16] hw/intc/arm_gicv3: Include missing 'qemu/error-report.h' header
Quoted 8 lines · Philippe Mathieu-Daudé
kvm_arm_its_reset_hold()callswarn_report(), itself declared in "qemu/error-report.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/intc/arm_gicv3_its_kvm.c | 1 + 1 file changed, 1 insertion(+)
PATCH 2/16 target/arm/kvm: Remove unused includes
In reply to Philippe Mathieu-DaudéBoth MemoryRegion and Error types are forward declared in "qemu/typedefs.h".
--- target/arm/kvm_arm.h | 2 -- 1 file changed, 2 deletions(-)
target/arm/kvm_arm.h +0 -2
@@ -12,8 +12,6 @@#define QEMU_KVM_ARM_H #include "sysemu/kvm.h" -#include "exec/memory.h" -#include "qemu/error-report.h" #define KVM_ARM_VGIC_V2 (1 << 0)#define KVM_ARM_VGIC_V3 (1 << 1)
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 02/16] target/arm/kvm: Remove unused includes
Quoted 8 lines · Philippe Mathieu-Daudé
Both MemoryRegion and Error types are forward declared in "
qemu/typedefs.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm_arm.h | 2 -- 1 file changed, 2 deletions(-)
PATCH 3/16 target/arm/kvm: Have kvm_arm_add_vcpu_properties take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm_arm.h | 4 ++-- target/arm/cpu.c | 2 +- target/arm/kvm.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
target/arm/kvm_arm.h +2 -2
@@ -153,7 +153,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);* Add all KVM specific CPU properties to the CPU object. These * are the CPU properties with "kvm-" prefixed names. */ -void kvm_arm_add_vcpu_properties (Object *obj); +void kvm_arm_add_vcpu_properties (ARMCPU *cpu);/** * kvm_arm_steal_time_finalize:
@@ -243,7 +243,7 @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)g_assert_not_reached (); } -static inline void kvm_arm_add_vcpu_properties (Object *obj) +static inline void kvm_arm_add_vcpu_properties (ARMCPU *cpu) {g_assert_not_reached (); }
target/arm/cpu.c +1 -1
@@ -1686,7 +1686,7 @@ void arm_cpu_post_init(Object *obj) }if (kvm_enabled ()) { -kvm_arm_add_vcpu_properties (obj); +kvm_arm_add_vcpu_properties (cpu); }#ifndef CONFIG_USER_ONLY
target/arm/kvm.c +2 -2
@@ -495,10 +495,10 @@ static void kvm_steal_time_set(Object *obj, bool value, Error **errp) }/* KVM VCPU properties should be prefixed with "kvm-". */ -void kvm_arm_add_vcpu_properties (Object *obj) +void kvm_arm_add_vcpu_properties (ARMCPU *cpu) { -ARMCPU *cpu =ARM_CPU (obj);CPUARMState *env = &cpu->env; +Object *obj =OBJECT (cpu);if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { cpu->kvm_adjvtime = true;
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 03/16] target/arm/kvm: Have kvm_arm_add_vcpu_properties take a ARMCPU argument
Hi Phil,
Quoted 11 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm_arm.h | 4 ++-- target/arm/cpu.c | 2 +- target/arm/kvm.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
With the following comments resolved:
target/arm/kvm_arm.h void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); · line 157
Quoted 11 lines
target/arm/kvm_arm.h +1
-1@@ -153,7 +153,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);* Add all KVM specific CPU properties to the CPU object. These * are the CPU properties with "kvm-" prefixed names. */ -void kvm_arm_add_vcpu_properties (Object *obj); +void kvm_arm_add_vcpu_properties (ARMCPU *cpu);
The function's description needs to be modified since @obj has been renamed to @cpu?
/**
* kvm_arm_add_vcpu_properties:
* @obj: The CPU object to add the properties to *
*/
Quoted 31 lines
target/arm/kvm_arm.h +1
-1/** * kvm_arm_steal_time_finalize: @@ -243,7 +243,7 @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)g_assert_not_reached (); } -static inline void kvm_arm_add_vcpu_properties (Object *obj) +static inline void kvm_arm_add_vcpu_properties (ARMCPU *cpu) {g_assert_not_reached (); }target/arm/cpu.c +1
-1@@ -1686,7 +1686,7 @@ void arm_cpu_post_init(Object *obj) }if (kvm_enabled ()) { -kvm_arm_add_vcpu_properties (obj); +kvm_arm_add_vcpu_properties (cpu); }#ifndef CONFIG_USER_ONLY target/arm/kvm.c +0
-0@@ -495,10 +495,10 @@ static void kvm_steal_time_set(Object *obj, bool value, Error **errp) }
target/arm/kvm.c static void kvm_steal_time_set(Object *obj, bool value, Error **errp) · line 504
Quoted 10 lines
target/arm/kvm.c +2
-2/* KVM VCPU properties should be prefixed with "kvm-". */ -void kvm_arm_add_vcpu_properties (Object *obj) +void kvm_arm_add_vcpu_properties (ARMCPU *cpu) { -ARMCPU *cpu =ARM_CPU (obj);CPUARMState *env = &cpu->env; +Object *obj =OBJECT (cpu);if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { cpu->kvm_adjvtime = true;
Thanks,
Gavin
Re: [PATCH-for-9.0 03/16] target/arm/kvm: Have kvm_arm_add_vcpu_properties take a ARMCPU argument
Quoted 33 lines · Gavin Shan
Hi Phil,
Quoted 11 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/arm/kvm_arm.h| 4 ++--
target/arm/cpu.c | 2 +-
target/arm/kvm.c | 4 ++--3 files changed, 5 insertions(+), 5 deletions(-)With the following comments resolved:
Reviewed-by Gavin Shan <[email protected]>target/arm/kvm_arm.h void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); · line 156
Quoted 10 lines
target/arm/kvm_arm.h +1
-1@@ -153,7 +153,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);* Add all KVM specific CPU properties to the CPU object. These * are the CPU properties with "kvm-" prefixed names. */ -void kvm_arm_add_vcpu_properties (Object *obj); +void kvm_arm_add_vcpu_properties (ARMCPU *cpu);The function's description needs to be modified since @obj has been renamed to @cpu?
Quoted 5 lines
/**
*kvm_arm_add_vcpu_properties:
* @obj: The CPU object to add the properties to *
*/
Oops thanks!
PATCH 4/16 target/arm/kvm: Have kvm_arm_sve_set_vls take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
target/arm/kvm.c +3 -4
@@ -1857,14 +1857,13 @@ uint32_t kvm_arm_sve_get_vls(CPUState *cs)return vls[0 ]; } -static int kvm_arm_sve_set_vls (CPUState *cs) +static int kvm_arm_sve_set_vls (ARMCPU *cpu) { -ARMCPU *cpu =ARM_CPU (cs);uint64_t vls[KVM_ARM64_SVE_VLS_WORDS ] = { cpu->sve_vq.map };assert (cpu->sve_max_vq <=KVM_ARM64_SVE_VQ_MAX ); -return kvm_set_one_reg (cs,KVM_REG_ARM64_SVE_VLS , &vls[0 ]); +return kvm_set_one_reg (CPU (cpu),KVM_REG_ARM64_SVE_VLS , &vls[0 ]); }#define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5
@@ -1921,7 +1920,7 @@ int kvm_arch_init_vcpu(CPUState *cs) }if (cpu_isar_feature (aa64_sve, cpu)) { - ret =kvm_arm_sve_set_vls (cs); + ret =kvm_arm_sve_set_vls (cpu);if (ret) {return ret; }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 04/16] target/arm/kvm: Have kvm_arm_sve_set_vls take a ARMCPU argument
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
PATCH 5/16 target/arm/kvm: Have kvm_arm_sve_get_vls take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm_arm.h | 6 +++--- target/arm/cpu64.c | 2 +- target/arm/kvm.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
target/arm/kvm_arm.h +3 -3
@@ -129,13 +129,13 @@ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray);/** * kvm_arm_sve_get_vls: -* @cs: CPUState +* @cpu: ARMCPU * * Get all the SVE vector lengths supported by the KVM host, setting * the bits corresponding to their length in quadwords minus one * (vq - 1) up to ARM_MAX_VQ. Return the resulting map. */ -uint32_t kvm_arm_sve_get_vls (CPUState *cs); +uint32_t kvm_arm_sve_get_vls (ARMCPU *cpu);/** * kvm_arm_set_cpu_features_from_host:
@@ -278,7 +278,7 @@ static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp)g_assert_not_reached (); } -static inline uint32_t kvm_arm_sve_get_vls (CPUState *cs) +static inline uint32_t kvm_arm_sve_get_vls (ARMCPU *cpu) {g_assert_not_reached (); }
target/arm/cpu64.c +1 -1
@@ -66,7 +66,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)*/ if (kvm_enabled ()) {if (kvm_arm_sve_supported ()) { - cpu->sve_vq.supported =kvm_arm_sve_get_vls (CPU (cpu)); + cpu->sve_vq.supported =kvm_arm_sve_get_vls (cpu); vq_supported = cpu->sve_vq.supported; }else {assert (!cpu_isar_feature (aa64_sve, cpu));
target/arm/kvm.c +1 -1
@@ -1803,7 +1803,7 @@ bool kvm_arm_sve_supported(void)QEMU_BUILD_BUG_ON (KVM_ARM64_SVE_VQ_MIN !=1 ); -uint32_t kvm_arm_sve_get_vls (CPUState *cs) +uint32_t kvm_arm_sve_get_vls (ARMCPU *cpu) {/* Only call this function if kvm_arm_sve_supported() returns true. */ static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS ];
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 05/16] target/arm/kvm: Have kvm_arm_sve_get_vls take a ARMCPU argument
Hi Phil,
Quoted 19 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm_arm.h | 6 +++--- target/arm/cpu64.c | 2 +- target/arm/kvm.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)target/arm/kvm_arm.h +0
-0@@ -129,13 +129,13 @@ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray);/** * kvm_arm_sve_get_vls:
target/arm/kvm_arm.h void kvm_arm_destroy_scratch_host_vcpu(int *fdarray); · line 139
Quoted 10 lines
target/arm/kvm_arm.h +2
-2-* @cs: CPUState +* @cpu: ARMCPU * * Get all the SVE vector lengths supported by the KVM host, setting * the bits corresponding to their length in quadwords minus one * (vq - 1) up to ARM_MAX_VQ. Return the resulting map. */ -uint32_t kvm_arm_sve_get_vls (CPUState *cs); +uint32_t kvm_arm_sve_get_vls (ARMCPU *cpu);
Either @cs or @cpu isn't dereferenced in kvm_arm_sve_get_vls(). So I guess the argument can be simply droped?
Quoted 29 lines
target/arm/kvm_arm.h +1
-1/** * kvm_arm_set_cpu_features_from_host: @@ -278,7 +278,7 @@ static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp)g_assert_not_reached (); } -static inline uint32_t kvm_arm_sve_get_vls (CPUState *cs) +static inline uint32_t kvm_arm_sve_get_vls (ARMCPU *cpu) {g_assert_not_reached (); }target/arm/cpu64.c +1
-1@@ -66,7 +66,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)*/ if (kvm_enabled ()) {if (kvm_arm_sve_supported ()) { - cpu->sve_vq.supported =kvm_arm_sve_get_vls (CPU (cpu)); + cpu->sve_vq.supported =kvm_arm_sve_get_vls (cpu); vq_supported = cpu->sve_vq.supported; }else {assert (!cpu_isar_feature (aa64_sve, cpu));target/arm/kvm.c +0
-0
target/arm/kvm.c bool kvm_arm_sve_supported(void) · line 1809
Quoted 8 lines
target/arm/kvm.c +1
-1@@ -1803,7 +1803,7 @@ bool kvm_arm_sve_supported(void)QEMU_BUILD_BUG_ON (KVM_ARM64_SVE_VQ_MIN !=1 ); -uint32_t kvm_arm_sve_get_vls (CPUState *cs) +uint32_t kvm_arm_sve_get_vls (ARMCPU *cpu) {/* Only call this function if kvm_arm_sve_supported() returns true. */ static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS ];
Thanks,
Gavin
Re: [PATCH-for-9.0 05/16] target/arm/kvm: Have kvm_arm_sve_get_vls take a ARMCPU argument
Hi Gavin,
Quoted 26 lines · Gavin Shan
Hi Phil,
Quoted 23 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/arm/kvm_arm.h| 6 +++---
target/arm/cpu64.c | 2 +-
target/arm/kvm.c | 2 +-3 files changed, 5 insertions(+), 5 deletions(-)target/arm/kvm_arm.h +1
-1@@ -129,13 +129,13 @@ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray); /*** kvm_arm_sve_get_vls: -* @cs: CPUState +* @cpu: ARMCPU * * Get all the SVE vector lengths supported by the KVM host, setting
Quoted 8 lines
target/arm/kvm_arm.h void kvm_arm_destroy_scratch_host_vcpu(int *fdarray); · line 138
Quoted 5 lines
target/arm/kvm_arm.h +1
-1* the bits corresponding to their length in quadwords minus one * (vq - 1) up to ARM_MAX_VQ. Return the resulting map. */ -uint32_t kvm_arm_sve_get_vls (CPUState *cs); +uint32_t kvm_arm_sve_get_vls (ARMCPU *cpu);Either @cs or @cpu isn't dereferenced in
kvm_arm_sve_get_vls(). So I guess the argument can be simply droped?
If KVM eventually supports heterogeneous vCPUs such big.LITTLE, we'd de-reference. But then we'd have a major rework of the code.
Peter, do you have a preference?
Thanks,
Phil.
PATCH 6/16 target/arm/kvm: Have kvm_arm_set_device_attr take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target/arm/kvm.c +6 -6
@@ -1691,18 +1691,18 @@ void kvm_arch_remove_all_hw_breakpoints(void) } } -static bool kvm_arm_set_device_attr (CPUState *cs,struct kvm_device_attr *attr, +static bool kvm_arm_set_device_attr (ARMCPU *cpu,struct kvm_device_attr *attr,const char *name) {int err; - err =kvm_vcpu_ioctl (cs,KVM_HAS_DEVICE_ATTR , attr); + err =kvm_vcpu_ioctl (CPU (cpu),KVM_HAS_DEVICE_ATTR , attr);if (err !=0 ) {error_report ("%s: KVM_HAS_DEVICE_ATTR: %s" , name,strerror (-err));return false; } - err =kvm_vcpu_ioctl (cs,KVM_SET_DEVICE_ATTR , attr); + err =kvm_vcpu_ioctl (CPU (cpu),KVM_SET_DEVICE_ATTR , attr);if (err !=0 ) {error_report ("%s: KVM_SET_DEVICE_ATTR: %s" , name,strerror (-err));return false;
@@ -1721,7 +1721,7 @@ void kvm_arm_pmu_init(CPUState *cs)if (!ARM_CPU (cs)->has_pmu) {return ; } -if (!kvm_arm_set_device_attr (cs, &attr,"PMU" )) { +if (!kvm_arm_set_device_attr (ARM_CPU (cs), &attr,"PMU" )) {error_report ("failed to init PMU" );abort (); }
@@ -1738,7 +1738,7 @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq)if (!ARM_CPU (cs)->has_pmu) {return ; } -if (!kvm_arm_set_device_attr (cs, &attr,"PMU" )) { +if (!kvm_arm_set_device_attr (ARM_CPU (cs), &attr,"PMU" )) {error_report ("failed to set irq for PMU" );abort (); }
@@ -1755,7 +1755,7 @@ void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa)if (ARM_CPU (cs)->kvm_steal_time ==ON_OFF_AUTO_OFF ) {return ; } -if (!kvm_arm_set_device_attr (cs, &attr,"PVTIME IPA" )) { +if (!kvm_arm_set_device_attr (ARM_CPU (cs), &attr,"PVTIME IPA" )) {error_report ("failed to init PVTIME IPA" );abort (); }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 06/16] target/arm/kvm: Have kvm_arm_set_device_attr take a ARMCPU argument
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
PATCH 7/16 target/arm/kvm: Have kvm_arm_pvtime_init take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm_arm.h | 6 +++--- hw/arm/virt.c | 5 +++-- target/arm/kvm.c | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-)
target/arm/kvm_arm.h +3 -3
@@ -205,12 +205,12 @@ void kvm_arm_pmu_init(CPUState *cs);/** * kvm_arm_pvtime_init: -* @cs: CPUState +* @cpu: ARMCPU * @ipa: Per-vcpu guest physical base address of the pvtime structures * * Initializes PVTIME for the VCPU, setting the PVTIME IPA to @ipa. */ -void kvm_arm_pvtime_init (CPUState *cs,uint64_t ipa); +void kvm_arm_pvtime_init (ARMCPU *cpu,uint64_t ipa);int kvm_arm_set_irq (int cpu,int irqtype,int irq,int level);
@@ -268,7 +268,7 @@ static inline void kvm_arm_pmu_init(CPUState *cs)g_assert_not_reached (); } -static inline void kvm_arm_pvtime_init (CPUState *cs,uint64_t ipa) +static inline void kvm_arm_pvtime_init (ARMCPU *cpu,uint64_t ipa) {g_assert_not_reached (); }
hw/arm/virt.c +3 -2
@@ -2003,8 +2003,9 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)kvm_arm_pmu_init (cpu); }if (steal_time) { -kvm_arm_pvtime_init (cpu, pvtime_reg_base + - cpu->cpu_index *PVTIME_SIZE_PER_CPU ); +kvm_arm_pvtime_init (ARM_CPU (cpu), pvtime_reg_base + + cpu->cpu_index + *PVTIME_SIZE_PER_CPU ); } } }else {
target/arm/kvm.c +3 -3
@@ -1744,7 +1744,7 @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) } } -void kvm_arm_pvtime_init (CPUState *cs,uint64_t ipa) +void kvm_arm_pvtime_init (ARMCPU *cpu,uint64_t ipa) {struct kvm_device_attr attr = { .group =KVM_ARM_VCPU_PVTIME_CTRL ,
@@ -1752,10 +1752,10 @@ void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa) .addr = (uint64_t)&ipa, }; -if (ARM_CPU (cs)->kvm_steal_time ==ON_OFF_AUTO_OFF ) { +if (cpu->kvm_steal_time ==ON_OFF_AUTO_OFF ) {return ; } -if (!kvm_arm_set_device_attr (ARM_CPU (cs), &attr,"PVTIME IPA" )) { +if (!kvm_arm_set_device_attr (cpu, &attr,"PVTIME IPA" )) {error_report ("failed to init PVTIME IPA" );abort (); }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 07/16] target/arm/kvm: Have kvm_arm_pvtime_init take a ARMCPU argument
Quoted 11 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm_arm.h | 6 +++--- hw/arm/virt.c | 5 +++-- target/arm/kvm.c | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-)
PATCH 8/16 target/arm/kvm: Have kvm_arm_pmu_init take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm_arm.h | 4 ++-- hw/arm/virt.c | 2 +- target/arm/kvm.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
target/arm/kvm_arm.h +2 -2
@@ -200,8 +200,8 @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa);int kvm_arm_vgic_probe (void ); +void kvm_arm_pmu_init (ARMCPU *cpu);void kvm_arm_pmu_set_irq (CPUState *cs,int irq); -void kvm_arm_pmu_init (CPUState *cs);/** * kvm_arm_pvtime_init:
@@ -263,7 +263,7 @@ static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq)g_assert_not_reached (); } -static inline void kvm_arm_pmu_init (CPUState *cs) +static inline void kvm_arm_pmu_init (ARMCPU *cpu) {g_assert_not_reached (); }
hw/arm/virt.c +1 -1
@@ -2000,7 +2000,7 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)if (kvm_irqchip_in_kernel ()) {kvm_arm_pmu_set_irq (cpu,VIRTUAL_PMU_IRQ ); } -kvm_arm_pmu_init (cpu); +kvm_arm_pmu_init (ARM_CPU (cpu)); }if (steal_time) { kvm_arm_pvtime_init(ARM_CPU(cpu), pvtime_reg_base
target/arm/kvm.c +3 -3
@@ -1711,17 +1711,17 @@ static bool kvm_arm_set_device_attr(ARMCPU *cpu, struct kvm_device_attr *attr,return true; } -void kvm_arm_pmu_init (CPUState *cs) +void kvm_arm_pmu_init (ARMCPU *cpu) {struct kvm_device_attr attr = { .group =KVM_ARM_VCPU_PMU_V3_CTRL , .attr =KVM_ARM_VCPU_PMU_V3_INIT , }; -if (!ARM_CPU (cs)->has_pmu) { +if (!cpu->has_pmu) {return ; } -if (!kvm_arm_set_device_attr (ARM_CPU (cs), &attr,"PMU" )) { +if (!kvm_arm_set_device_attr (cpu, &attr,"PMU" )) {error_report ("failed to init PMU" );abort (); }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 08/16] target/arm/kvm: Have kvm_arm_pmu_init take a ARMCPU argument
Hi Phil,
Quoted 11 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm_arm.h | 4 ++-- hw/arm/virt.c | 2 +- target/arm/kvm.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
One nit below, but I guess it doesn't matter.
target/arm/kvm_arm.h int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa); · line 205
Quoted 12 lines
target/arm/kvm_arm.h +1
-1@@ -200,8 +200,8 @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa);int kvm_arm_vgic_probe (void ); +void kvm_arm_pmu_init (ARMCPU *cpu);void kvm_arm_pmu_set_irq (CPUState *cs,int irq); -void kvm_arm_pmu_init (CPUState *cs);
Why the order of the declaration is changed? I guess the reason would be kvm_arm_pmu_init() is called prior to kvm_arm_pmu_set_irq().
Quoted 39 lines
target/arm/kvm_arm.h +1
-1/** * kvm_arm_pvtime_init: @@ -263,7 +263,7 @@ static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq)g_assert_not_reached (); } -static inline void kvm_arm_pmu_init (CPUState *cs) +static inline void kvm_arm_pmu_init (ARMCPU *cpu) {g_assert_not_reached (); }hw/arm/virt.c +1
-1@@ -2000,7 +2000,7 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)if (kvm_irqchip_in_kernel ()) {kvm_arm_pmu_set_irq (cpu,VIRTUAL_PMU_IRQ ); } -kvm_arm_pmu_init (cpu); +kvm_arm_pmu_init (ARM_CPU (cpu)); }if (steal_time) { kvm_arm_pvtime_init(ARM_CPU(cpu), pvtime_reg_basetarget/arm/kvm.c +1
-1@@ -1711,17 +1711,17 @@ static bool kvm_arm_set_device_attr(ARMCPU *cpu, struct kvm_device_attr *attr,return true; } -void kvm_arm_pmu_init (CPUState *cs) +void kvm_arm_pmu_init (ARMCPU *cpu) {struct kvm_device_attr attr = { .group =KVM_ARM_VCPU_PMU_V3_CTRL , .attr =KVM_ARM_VCPU_PMU_V3_INIT , };
target/arm/kvm.c static bool kvm_arm_set_device_attr(ARMCPU *cpu, struct kvm_device_attr *attr, · line 1727
Quoted 10 lines
target/arm/kvm.c +2
-2-if (!ARM_CPU (cs)->has_pmu) { +if (!cpu->has_pmu) {return ; } -if (!kvm_arm_set_device_attr (ARM_CPU (cs), &attr,"PMU" )) { +if (!kvm_arm_set_device_attr (cpu, &attr,"PMU" )) {error_report ("failed to init PMU" );abort (); }
Thanks,
Gavin
Re: [PATCH-for-9.0 08/16] target/arm/kvm: Have kvm_arm_pmu_init take a ARMCPU argument
Quoted 19 lines · Gavin Shan
Hi Phil,
Quoted 11 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/arm/kvm_arm.h| 4 ++--
hw/arm/virt.c | 2 +-
target/arm/kvm.c | 6 +++---3 files changed, 6 insertions(+), 6 deletions(-)One nit below, but I guess it doesn't matter.
Reviewed-by Gavin Shan <[email protected]>
Quoted 13 lines
target/arm/kvm_arm.h int kvm_arm_get_max_vm_ipa_size(MachineState *ms, · line 203
Quoted 10 lines
target/arm/kvm_arm.h +1
-1@@ -200,8 +200,8 @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa); int kvm_arm_vgic_probe(void); +void kvm_arm_pmu_init (ARMCPU *cpu); void kvm_arm_pmu_set_irq(CPUState *cs, int irq); -void kvm_arm_pmu_init (CPUState *cs);Why the order of the declaration is changed? I guess the reason would be
kvm_arm_pmu_init()is called prior tokvm_arm_pmu_set_irq().
Yes, exactly. Not worth mentioning IMHO.
Thanks!
Phil.
PATCH 9/16 target/arm/kvm: Have kvm_arm_pmu_set_irq take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm_arm.h | 4 ++-- hw/arm/virt.c | 2 +- target/arm/kvm.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
target/arm/kvm_arm.h +2 -2
@@ -201,7 +201,7 @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa);int kvm_arm_vgic_probe (void );void kvm_arm_pmu_init (ARMCPU *cpu); -void kvm_arm_pmu_set_irq (CPUState *cs,int irq); +void kvm_arm_pmu_set_irq (ARMCPU *cpu,int irq);/** * kvm_arm_pvtime_init:
@@ -258,7 +258,7 @@ static inline int kvm_arm_vgic_probe(void)g_assert_not_reached (); } -static inline void kvm_arm_pmu_set_irq (CPUState *cs,int irq) +static inline void kvm_arm_pmu_set_irq (ARMCPU *cpu,int irq) {g_assert_not_reached (); }
hw/arm/virt.c +1 -1
@@ -1998,7 +1998,7 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)if (pmu) {assert (arm_feature (&ARM_CPU (cpu)->env,ARM_FEATURE_PMU ));if (kvm_irqchip_in_kernel ()) { -kvm_arm_pmu_set_irq (cpu,VIRTUAL_PMU_IRQ ); +kvm_arm_pmu_set_irq (ARM_CPU (cpu),VIRTUAL_PMU_IRQ ); }kvm_arm_pmu_init (ARM_CPU (cpu)); }
target/arm/kvm.c +3 -3
@@ -1727,7 +1727,7 @@ void kvm_arm_pmu_init(ARMCPU *cpu) } } -void kvm_arm_pmu_set_irq (CPUState *cs,int irq) +void kvm_arm_pmu_set_irq (ARMCPU *cpu,int irq) {struct kvm_device_attr attr = { .group =KVM_ARM_VCPU_PMU_V3_CTRL ,
@@ -1735,10 +1735,10 @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) .attr = KVM_ARM_VCPU_PMU_V3_IRQ, }; -if (!ARM_CPU (cs)->has_pmu) { +if (!cpu->has_pmu) {return ; } -if (!kvm_arm_set_device_attr (ARM_CPU (cs), &attr,"PMU" )) { +if (!kvm_arm_set_device_attr (cpu, &attr,"PMU" )) {error_report ("failed to set irq for PMU" );abort (); }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 09/16] target/arm/kvm: Have kvm_arm_pmu_set_irq take a ARMCPU argument
Quoted 11 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm_arm.h | 4 ++-- hw/arm/virt.c | 2 +- target/arm/kvm.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
PATCH 10/16 target/arm/kvm: Have kvm_arm_vcpu_init take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
target/arm/kvm.c +5 -6
@@ -60,7 +60,7 @@ static ARMHostCPUFeatures arm_host_cpu_features;/** * kvm_arm_vcpu_init: -* @cs: CPUState +* @cpu: ARMCPU * * Initialize (or reinitialize) the VCPU by invoking the * KVM_ARM_VCPU_INIT ioctl with the CPU type and feature
@@ -68,15 +68,14 @@ static ARMHostCPUFeatures arm_host_cpu_features;* * Returns: 0 if success else < 0 error code */ -static int kvm_arm_vcpu_init (CPUState *cs) +static int kvm_arm_vcpu_init (ARMCPU *cpu) { -ARMCPU *cpu =ARM_CPU (cs);struct kvm_vcpu_init init; init.target = cpu->kvm_target;memcpy (init.features, cpu->kvm_init_features,sizeof (init.features)); -return kvm_vcpu_ioctl (cs,KVM_ARM_VCPU_INIT , &init); +return kvm_vcpu_ioctl (CPU (cpu),KVM_ARM_VCPU_INIT , &init); }/**
@@ -984,7 +983,7 @@ void kvm_arm_reset_vcpu(ARMCPU *cpu)/* Re-init VCPU so that all registers are set to * their respective reset values. */ - ret =kvm_arm_vcpu_init (CPU (cpu)); + ret =kvm_arm_vcpu_init (cpu);if (ret <0 ) {fprintf (stderr,"kvm_arm_vcpu_init failed: %s\n" ,strerror (-ret));abort ();
@@ -1914,7 +1913,7 @@ int kvm_arch_init_vcpu(CPUState *cs) }/* Do KVM_ARM_VCPU_INIT ioctl */ - ret =kvm_arm_vcpu_init (cs); + ret =kvm_arm_vcpu_init (cpu);if (ret) {return ret; }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 10/16] target/arm/kvm: Have kvm_arm_vcpu_init take a ARMCPU argument
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
Re: [PATCH-for-9.0 10/16] target/arm/kvm: Have kvm_arm_vcpu_init take a ARMCPU argument
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
PATCH 11/16 target/arm/kvm: Have kvm_arm_vcpu_finalize take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/arm/kvm.c +4 -4
@@ -80,7 +80,7 @@ static int kvm_arm_vcpu_init(ARMCPU *cpu)/** * kvm_arm_vcpu_finalize: -* @cs: CPUState +* @cpu: ARMCPU * @feature: feature to finalize * * Finalizes the configuration of the specified VCPU feature by
@@ -90,9 +90,9 @@ static int kvm_arm_vcpu_init(ARMCPU *cpu)* * Returns: 0 if success else < 0 error code */ -static int kvm_arm_vcpu_finalize (CPUState *cs,int feature) +static int kvm_arm_vcpu_finalize (ARMCPU *cpu,int feature) { -return kvm_vcpu_ioctl (cs,KVM_ARM_VCPU_FINALIZE , &feature); +return kvm_vcpu_ioctl (CPU (cpu),KVM_ARM_VCPU_FINALIZE , &feature); } bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
@@ -1923,7 +1923,7 @@ int kvm_arch_init_vcpu(CPUState *cs)if (ret) {return ret; } - ret =kvm_arm_vcpu_finalize (cs,KVM_ARM_VCPU_SVE ); + ret =kvm_arm_vcpu_finalize (cpu,KVM_ARM_VCPU_SVE );if (ret) {return ret; }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 11/16] target/arm/kvm: Have kvm_arm_vcpu_finalize take a ARMCPU argument
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
PATCH 12/16 target/arm/kvm: Have kvm_arm_[get|put]_virtual_time take ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
target/arm/kvm.c +10 -13
@@ -1036,20 +1036,19 @@ static int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)/** * kvm_arm_get_virtual_time: -* @cs: CPUState +* @cpu: ARMCPU * * 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;if (cpu->kvm_vtime_dirty) {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) {error_report ("Failed to get KVM_REG_ARM_TIMER_CNT" );abort ();
@@ -1060,20 +1059,19 @@ static void kvm_arm_get_virtual_time(CPUState *cs)/** * kvm_arm_put_virtual_time: -* @cs: CPUState +* @cpu: ARMCPU * * 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;if (!cpu->kvm_vtime_dirty) {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) {error_report ("Failed to set KVM_REG_ARM_TIMER_CNT" );abort ();
@@ -1291,16 +1289,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) { -CPUState *cs = opaque; -ARMCPU *cpu =ARM_CPU (cs); +ARMCPU *cpu = opaque;if (running) {if (cpu->kvm_adjvtime) { -kvm_arm_put_virtual_time (cs); +kvm_arm_put_virtual_time (cpu); } }else {if (cpu->kvm_adjvtime) { -kvm_arm_get_virtual_time (cs); +kvm_arm_get_virtual_time (cpu); } } }
@@ -1881,7 +1878,7 @@ int kvm_arch_init_vcpu(CPUState *cs)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 */ memset (cpu->kvm_init_features,0 ,sizeof (cpu->kvm_init_features));
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 12/16] target/arm/kvm: Have kvm_arm_[get|put]_virtual_time take ARMCPU argument
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
PATCH 13/16 target/arm/kvm: Have kvm_arm_verify_ext_dabt_pending take a ARMCPU arg
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/arm/kvm.c +4 -4
@@ -1172,18 +1172,18 @@ static int kvm_get_vcpu_events(ARMCPU *cpu)/** * kvm_arm_verify_ext_dabt_pending: -* @cs: CPUState +* @cpu: ARMCPU * * Verify the fault status code wrt the Ext DABT injection * * Returns: true if the fault status code is as expected, false otherwise */ -static bool kvm_arm_verify_ext_dabt_pending (CPUState *cs) +static bool kvm_arm_verify_ext_dabt_pending (ARMCPU *cpu) { +CPUState *cs =CPU (cpu);uint64_t dfsr_val;if (!kvm_get_one_reg (cs,ARM64_REG_ESR_EL1 , &dfsr_val)) { -ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;int aarch64_mode =arm_feature (env,ARM_FEATURE_AARCH64 );int lpae =0 ;
@@ -1220,7 +1220,7 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)* an IMPLEMENTATION DEFINED exception (for 32-bit EL1) */ if (!arm_feature (env,ARM_FEATURE_AARCH64 ) && -unlikely (!kvm_arm_verify_ext_dabt_pending (cs))) { +unlikely (!kvm_arm_verify_ext_dabt_pending (cpu))) {error_report ("Data abort exception with no valid ISS generated by " "guest memory access. KVM unable to emulate faulting "
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 13/16] target/arm/kvm: Have kvm_arm_verify_ext_dabt_pending take a ARMCPU arg
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
PATCH 14/16 target/arm/kvm: Have kvm_arm_handle_dabt_nisv take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
target/arm/kvm.c +5 -5
@@ -1304,17 +1304,16 @@ static void kvm_arm_vm_state_change(void *opaque, bool running, RunState state)/** * kvm_arm_handle_dabt_nisv: -* @cs: CPUState +* @cpu: ARMCPU * @esr_iss: ISS encoding (limited) for the exception from Data Abort * ISV bit set to '0b0' -> no valid instruction syndrome * @fault_ipa: faulting address for the synchronous data abort * * Returns: 0 if the exception has been handled, < 0 otherwise */ -static int kvm_arm_handle_dabt_nisv (CPUState *cs,uint64_t esr_iss, +static int kvm_arm_handle_dabt_nisv (ARMCPU *cpu,uint64_t esr_iss,uint64_t fault_ipa) { -ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;/* * Request KVM to inject the external data abort into the guest
@@ -1330,7 +1329,7 @@ static int kvm_arm_handle_dabt_nisv(CPUState *cs, uint64_t esr_iss,*/ events.exception.ext_dabt_pending =1 ;/* KVM_CAP_ARM_INJECT_EXT_DABT implies KVM_CAP_VCPU_EVENTS */ -if (!kvm_vcpu_ioctl (cs,KVM_SET_VCPU_EVENTS , &events)) { +if (!kvm_vcpu_ioctl (CPU (cpu),KVM_SET_VCPU_EVENTS , &events)) { env->ext_dabt_raised =1 ;return 0 ; }
@@ -1422,6 +1421,7 @@ static bool kvm_arm_handle_debug(CPUState *cs,int kvm_arch_handle_exit (CPUState *cs,struct kvm_run *run) { +ARMCPU *cpu =ARM_CPU (cs);int ret =0 ;switch (run->exit_reason) {
@@ -1432,7 +1432,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)break ;case KVM_EXIT_ARM_NISV :/* External DABT with no valid iss to decode */ - ret =kvm_arm_handle_dabt_nisv (cs, run->arm_nisv.esr_iss, + ret =kvm_arm_handle_dabt_nisv (cpu, run->arm_nisv.esr_iss, run->arm_nisv.fault_ipa);break ;default :
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 14/16] target/arm/kvm: Have kvm_arm_handle_dabt_nisv take a ARMCPU argument
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
PATCH 15/16 target/arm/kvm: Have kvm_arm_handle_debug take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/arm/kvm.c +4 -4
@@ -1344,7 +1344,7 @@ static int kvm_arm_handle_dabt_nisv(ARMCPU *cpu, uint64_t esr_iss,/** * kvm_arm_handle_debug: -* @cs: CPUState +* @cpu: ARMCPU * @debug_exit: debug part of the KVM exit structure * * Returns: TRUE if the debug exception was handled.
@@ -1355,11 +1355,11 @@ static int kvm_arm_handle_dabt_nisv(ARMCPU *cpu, uint64_t esr_iss,* ABI just provides user-space with the full exception syndrome * register value to be decoded in QEMU. */ -static bool kvm_arm_handle_debug (CPUState *cs, +static bool kvm_arm_handle_debug (ARMCPU *cpu,struct kvm_debug_exit_arch *debug_exit) {int hsr_ec =syn_get_ec (debug_exit->hsr); -ARMCPU *cpu =ARM_CPU (cs); +CPUState *cs =CPU (cpu);CPUARMState *env = &cpu->env;/* Ensure PC is synchronised */
@@ -1426,7 +1426,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)switch (run->exit_reason) {case KVM_EXIT_DEBUG : -if (kvm_arm_handle_debug (cs, &run->debug.arch)) { +if (kvm_arm_handle_debug (cpu, &run->debug.arch)) { ret =EXCP_DEBUG ; }/* otherwise return to guest */ break ;
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 15/16] target/arm/kvm: Have kvm_arm_handle_debug take a ARMCPU argument
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
PATCH 16/16 target/arm/kvm: Have kvm_arm_hw_debug_active take a ARMCPU argument
In reply to Philippe Mathieu-Daudé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".
--- target/arm/kvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/arm/kvm.c +3 -3
@@ -1455,11 +1455,11 @@ int kvm_arch_process_async_events(CPUState *cs)/** * kvm_arm_hw_debug_active: -* @cs: CPU State +* @cpu: ARMCPU * * Return: TRUE if any hardware breakpoints in use. */ -static bool kvm_arm_hw_debug_active (CPUState *cs) +static bool kvm_arm_hw_debug_active (ARMCPU *cpu) {return ((cur_hw_wps >0 ) || (cur_hw_bps >0 )); }
@@ -1493,7 +1493,7 @@ void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg)if (kvm_sw_breakpoints_active (cs)) { dbg->control |=KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_USE_SW_BP ; } -if (kvm_arm_hw_debug_active (cs)) { +if (kvm_arm_hw_debug_active (ARM_CPU (cs))) { dbg->control |=KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_USE_HW ;kvm_arm_copy_hw_debug_data (&dbg->arch); }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0 16/16] target/arm/kvm: Have kvm_arm_hw_debug_active take a ARMCPU argument
Hi Phil,
Quoted 9 lines · Philippe Mathieu-Daudé
Unify the "
kvm_arm.h" API: All functions related to ARM vCPUs take a ARMCPU* argument. Use theCPU()QOM cast macro When calling the generic vCPU API from "sysemu/kvm.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/kvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
With the following comments addressed:
Quoted 8 lines
target/arm/kvm.c +0
-0@@ -1455,11 +1455,11 @@ int kvm_arch_process_async_events(CPUState *cs)/** * kvm_arm_hw_debug_active:
target/arm/kvm.c int kvm_arch_process_async_events(CPUState *cs) · line 1465
Quoted 10 lines
target/arm/kvm.c +2
-2-* @cs: CPU State +* @cpu: ARMCPU * * Return: TRUE if any hardware breakpoints in use. */ -static bool kvm_arm_hw_debug_active (CPUState *cs) +static bool kvm_arm_hw_debug_active (ARMCPU *cpu) {return ((cur_hw_wps >0 ) || (cur_hw_bps >0 )); }
Either @cs or @cpu isn't dereferenced in kvm_arm_hw_debug_active(). So I guess the argument can be simply droped?
target/arm/kvm.c void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) · line 1499
Quoted 9 lines
target/arm/kvm.c +1
-1@@ -1493,7 +1493,7 @@ void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg)if (kvm_sw_breakpoints_active (cs)) { dbg->control |=KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_USE_SW_BP ; } -if (kvm_arm_hw_debug_active (cs)) { +if (kvm_arm_hw_debug_active (ARM_CPU (cs))) { dbg->control |=KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_USE_HW ;kvm_arm_copy_hw_debug_data (&dbg->arch); }
Thanks,
Gavin
Quoted 25 lines · Philippe Mathieu-Daudé
Half of the API takes CPUState, the other ARMCPU...
$ git grep -F 'CPUState *' target/arm/kvm_arm.h | wc -l 16 $ git grep -F 'ARMCPU *' target/arm/kvm_arm.h | wc -l 14Since this is ARM specific, have it always take ARMCPU, and call the generic KVM API casting with the
CPU()macro.Based-on: <[email protected]>
"target/arm: kvm cleanups"
https://lore.kernel.org/qemu-devel/[email protected]/Philippe Mathieu-Daudé (16):
hw/intc/arm_gicv3: Include missing 'qemu/error-report.h' header target/arm/kvm: Remove unused includes
target/arm/kvm: Havekvm_arm_add_vcpu_propertiestake a ARMCPU
argument
target/arm/kvm: Havekvm_arm_sve_set_vlstake a ARMCPU argument target/arm/kvm: Havekvm_arm_sve_get_vlstake a ARMCPU argument target/arm/kvm: Havekvm_arm_set_device_attrtake a ARMCPU argument target/arm/kvm: Havekvm_arm_pvtime_inittake a ARMCPU argument target/arm/kvm: Havekvm_arm_pmu_inittake a ARMCPU argument target/arm/kvm: Havekvm_arm_pmu_set_irqtake a ARMCPU argument
Quoted 8 lines
target/arm/kvm: Have
kvm_arm_vcpu_inittake a ARMCPU argument target/arm/kvm: Havekvm_arm_vcpu_finalizetake a ARMCPU argument target/arm/kvm: Have kvm_arm_[get|put]_virtual_time take ARMCPU
argument
target/arm/kvm: Havekvm_arm_verify_ext_dabt_pendingtake a ARMCPU arg target/arm/kvm: Havekvm_arm_handle_dabt_nisvtake a ARMCPU argument target/arm/kvm: Havekvm_arm_handle_debugtake a ARMCPU argument target/arm/kvm: Havekvm_arm_hw_debug_activetake a ARMCPU argument
r~
Peter Maydell
AppliedQuoted 10 lines · Philippe Mathieu-Daudé
Half of the API takes CPUState, the other ARMCPU...
$ git grep -F 'CPUState *' target/arm/kvm_arm.h | wc -l 16 $ git grep -F 'ARMCPU *' target/arm/kvm_arm.h | wc -l 14Since this is ARM specific, have it always take ARMCPU, and call the generic KVM API casting with the
CPU()macro.
Applied to target-arm.next for 9.0, thanks.
-- PMM
Quoted 9 lines · Peter Maydell
Quoted 8 lines · Philippe Mathieu-Daudé
Half of the API takes CPUState, the other ARMCPU...
$ git grep -F 'CPUState *' target/arm/kvm_arm.h | wc -l 16 $ git grep -F 'ARMCPU *' target/arm/kvm_arm.h | wc -l 14
Quoted 6 lines
Quoted 2 lines
Since this is ARM specific, have it always take ARMCPU, and call the generic KVM API casting with the
CPU()macro.Applied to target-arm.next for 9.0, thanks.
Thanks Peter, the only change I added from Gavin review is on top of patch #3:
-- >8 --
target/arm/kvm_arm.h +1 -1
@@ -148,7 +148,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);/** * kvm_arm_add_vcpu_properties: -* @obj: The CPU object to add the properties to +* @cpu: The CPU object to add the properties to * * Add all KVM specific CPU properties to the CPU object. These * are the CPU properties with "kvm-" prefixed names.
---
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Peter Maydell
Quoted 10 lines · Philippe Mathieu-Daudé
Half of the API takes CPUState, the other ARMCPU...
$ git grep -F 'CPUState *' target/arm/kvm_arm.h | wc -l 16 $ git grep -F 'ARMCPU *' target/arm/kvm_arm.h | wc -l 14Since this is ARM specific, have it always take ARMCPU, and call the generic KVM API casting with the
CPU()macro.
Quoted 4 lines
Quoted 1 line
Applied to target-arm.next for 9.0, thanks.
Thanks Peter, the only change I added from Gavin review is on top of patch #3:
OK, I've squashed that in.
-- PMM