target/arm/cpu: adjust virtual time for arm cpu
PATCH v3 1/1 target/arm/cpu: adjust virtual time for arm cpu
From: fangying <[email protected]>
Virtual time adjustment was implemented for virt-5.0 machine type, but the cpu property was enabled only for host-passthrough and max cpu model. Let's add it for arm cpu which has the generic timer feature enabled.
---
v3:
- set kvm-no-adjvtime property in kvm_arm_add_vcpu_properties
v2:
- move kvm_arm_add_vcpu_properties into arm_cpu_post_init
v1:
- initial commit
- https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08518.html
target/arm/cpu.c +4 -2
@@ -1245,6 +1245,10 @@ void arm_cpu_post_init(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_GENERIC_TIMER )) {qdev_property_add_static (DEVICE (cpu), &arm_cpu_gt_cntfrq_property); } + +if (kvm_enabled ()) { +kvm_arm_add_vcpu_properties (obj); + } }static void arm_cpu_finalizefn (Object *obj)
@@ -2029,7 +2033,6 @@ static void arm_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {cortex_a15_initfn (obj);
@@ -2183,7 +2186,6 @@ static void arm_host_initfn(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); } -kvm_arm_add_vcpu_properties (obj);arm_cpu_post_init (obj); }
target/arm/cpu64.c +0 -1
@@ -592,7 +592,6 @@ static void aarch64_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {uint64_t t;uint32_t u;
target/arm/kvm.c +11 -10
@@ -194,17 +194,18 @@ static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)/* KVM VCPU properties should be prefixed with "kvm-". */ void kvm_arm_add_vcpu_properties (Object *obj) { -if (!kvm_enabled ()) { -return ; - } +ARMCPU *cpu =ARM_CPU (obj); +CPUARMState *env = &cpu->env; -ARM_CPU (obj)->kvm_adjvtime = true; -object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, - kvm_no_adjvtime_set); -object_property_set_description (obj,"kvm-no-adjvtime" , -"Set on to disable the adjustment of " -"the virtual counter. VM stopped time " -"will be counted." ); +if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { + cpu->kvm_adjvtime = true; +object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, + kvm_no_adjvtime_set); +object_property_set_description (obj,"kvm-no-adjvtime" , +"Set on to disable the adjustment of " +"the virtual counter. VM stopped time " +"will be counted." ); + } }bool kvm_arm_pmu_supported (CPUState *cpu)
Signature · 1 line
2.23.0
Quoted 8 lines · Ying Fang
From: fangying <[email protected]>
Virtual time adjustment was implemented for virt-5.0 machine type, but the cpu property was enabled only for host-passthrough and max cpu model. Let's add it for arm cpu which has the generic timer feature enabled.
Suggested-by Andrew Jones <[email protected]>
This isn't true. I did suggest the way to arrange the code, after Peter suggested to move the kvm_arm_add_vcpu_properties() call to arm_cpu_post_init(), but I didn't suggest making this change in general, which is what this tag means. In fact, I've argued that it's pretty pointless to do this, since KVM users should be using '-cpu host' or '-cpu max' anyway. Since I don't need credit for the code arranging, please just drop the tag. Peter can maybe do that on merge though. Also, despite not agreeing that we need this change today, as there's nothing wrong with it and it looks good to me
Thanks,
drew
Quoted 93 lines
Signed-off-by Ying Fang <[email protected]>---
v3:
- set kvm-no-adjvtime property inkvm_arm_add_vcpu_propertiesv2:
- movekvm_arm_add_vcpu_propertiesintoarm_cpu_post_initv1:
- initial commit
- https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08518.htmltarget/arm/cpu.c +4
-2@@ -1245,6 +1245,10 @@ void arm_cpu_post_init(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_GENERIC_TIMER )) {qdev_property_add_static (DEVICE (cpu), &arm_cpu_gt_cntfrq_property); } + +if (kvm_enabled ()) { +kvm_arm_add_vcpu_properties (obj); + } }static void arm_cpu_finalizefn (Object *obj)@@ -2029,7 +2033,6 @@ static void arm_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {cortex_a15_initfn (obj);@@ -2183,7 +2186,6 @@ static void arm_host_initfn(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); } -kvm_arm_add_vcpu_properties (obj);arm_cpu_post_init (obj); }target/arm/cpu64.c +0
-1@@ -592,7 +592,6 @@ static void aarch64_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {uint64_t t;uint32_t u;target/arm/kvm.c +11
-10@@ -194,17 +194,18 @@ static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)/* KVM VCPU properties should be prefixed with "kvm-". */ void kvm_arm_add_vcpu_properties (Object *obj) { -if (!kvm_enabled ()) { -return ; - } +ARMCPU *cpu =ARM_CPU (obj); +CPUARMState *env = &cpu->env; -ARM_CPU (obj)->kvm_adjvtime = true; -object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, - kvm_no_adjvtime_set); -object_property_set_description (obj,"kvm-no-adjvtime" , -"Set on to disable the adjustment of " -"the virtual counter. VM stopped time " -"will be counted." ); +if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { + cpu->kvm_adjvtime = true; +object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, + kvm_no_adjvtime_set); +object_property_set_description (obj,"kvm-no-adjvtime" , +"Set on to disable the adjustment of " +"the virtual counter. VM stopped time " +"will be counted." ); + } }bool kvm_arm_pmu_supported (CPUState *cpu)Signature · 1 line
2.23.0
Quoted 8 lines · Andrew Jones
Quoted 7 lines · Ying Fang
From: fangying <[email protected]>
Virtual time adjustment was implemented for virt-5.0 machine type, but the cpu property was enabled only for host-passthrough and max cpu model. Let's add it for arm cpu which has the generic timer feature enabled.
Quoted 6 lines
Quoted 1 line
Suggested-by Andrew Jones <[email protected]>This isn't true. I did suggest the way to arrange the code, after Peter suggested to move the
kvm_arm_add_vcpu_properties()call toarm_cpu_post_init(), but I didn't suggest making this change in general, which is what this tag means. In fact, I've argued that it's pretty
I'm quite sorry for adding it here.
Quoted 2 lines
pointless to do this, since KVM users should be using '-cpu host' or '-cpu max' anyway. Since I don't need credit for the code arranging,
As discussed in thread [1], there is a situation where a 'custom' cpu mode is needed for us to keep instruction set compatibility so that migration can be done, just like x86 does. And we are planning to add support for it if nobody is currently doing that.
Thanks.
Ying
[1]: https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00022.html
Quoted 105 lines
please just drop the tag. Peter can maybe do that on merge though. Also, despite not agreeing that we need this change today, as there's nothing wrong with it and it looks good to me
Reviewed-by Andrew Jones <[email protected]>Thanks,
drewQuoted 93 lines
Signed-off-by Ying Fang <[email protected]>---
v3:
- set kvm-no-adjvtime property inkvm_arm_add_vcpu_propertiesv2:
- movekvm_arm_add_vcpu_propertiesintoarm_cpu_post_initv1:
- initial commit
- https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08518.htmltarget/arm/cpu.c +4
-2@@ -1245,6 +1245,10 @@ void arm_cpu_post_init(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_GENERIC_TIMER )) {qdev_property_add_static (DEVICE (cpu), &arm_cpu_gt_cntfrq_property); } + +if (kvm_enabled ()) { +kvm_arm_add_vcpu_properties (obj); + } }static void arm_cpu_finalizefn (Object *obj)@@ -2029,7 +2033,6 @@ static void arm_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {cortex_a15_initfn (obj);@@ -2183,7 +2186,6 @@ static void arm_host_initfn(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); } -kvm_arm_add_vcpu_properties (obj);arm_cpu_post_init (obj); }target/arm/cpu64.c +0
-1@@ -592,7 +592,6 @@ static void aarch64_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {uint64_t t;uint32_t u;target/arm/kvm.c +11
-10@@ -194,17 +194,18 @@ static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)/* KVM VCPU properties should be prefixed with "kvm-". */ void kvm_arm_add_vcpu_properties (Object *obj) { -if (!kvm_enabled ()) { -return ; - } +ARMCPU *cpu =ARM_CPU (obj); +CPUARMState *env = &cpu->env; -ARM_CPU (obj)->kvm_adjvtime = true; -object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, - kvm_no_adjvtime_set); -object_property_set_description (obj,"kvm-no-adjvtime" , -"Set on to disable the adjustment of " -"the virtual counter. VM stopped time " -"will be counted." ); +if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { + cpu->kvm_adjvtime = true; +object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, + kvm_no_adjvtime_set); +object_property_set_description (obj,"kvm-no-adjvtime" , +"Set on to disable the adjustment of " +"the virtual counter. VM stopped time " +"will be counted." ); + } }bool kvm_arm_pmu_supported (CPUState *cpu)Signature · 1 line
2.23.0.
Quoted 11 lines · Ying Fang
Quoted 8 lines · Andrew Jones
Quoted 7 lines · Ying Fang
From: fangying <[email protected]>
Virtual time adjustment was implemented for virt-5.0 machine type, but the cpu property was enabled only for host-passthrough and max cpu model. Let's add it for arm cpu which has the generic timer feature enabled.
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
Suggested-by Andrew Jones <[email protected]>This isn't true. I did suggest the way to arrange the code, after Peter suggested to move the
kvm_arm_add_vcpu_properties()call toarm_cpu_post_init(), but I didn't suggest making this change in general, which is what this tag means. In fact, I've argued that it's prettyI'm quite sorry for adding it here.
No problem.
Quoted 5 lines
Quoted 2 lines
pointless to do this, since KVM users should be using '-cpu host' or '-cpu max' anyway. Since I don't need credit for the code arranging,
As discussed in thread [1], there is a situation where a 'custom' cpu mode is needed for us to keep instruction set compatibility so that migration can be done, just like x86 does.
I understand the motivation. But, as I've said, KVM doesn't work that way.
Quoted 2 lines
And we are planning to add support for it if
nobody is currently doing that.
Great! I'm looking forward to seeing the KVM patches. Especially since, without the KVM patches, the 'custom' CPU model isn't a custom CPU model, it's just a misleading way to use host passthrough. Indeed, I'm a bit opposed to allowing anything other than '-cpu host' and '-cpu max' (with features explicitly enabled/disabled, e.g. -cpu host,pmu=off) to work until KVM actually works with CPU models. Otherwise, how do we know the difference between a model that actually works and one that is just misleadingly named?
Thanks,
drew
Quoted 104 lines
Thanks.
Ying[1]: https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00022.html
Quoted 98 lines
please just drop the tag. Peter can maybe do that on merge though. Also, despite not agreeing that we need this change today, as there's nothing wrong with it and it looks good to me
Reviewed-by Andrew Jones <[email protected]>Thanks,
drewQuoted 86 lines
Signed-off-by Ying Fang <[email protected]>---
v3:
- set kvm-no-adjvtime property inkvm_arm_add_vcpu_propertiesv2:
- movekvm_arm_add_vcpu_propertiesintoarm_cpu_post_initv1:
- initial commit
- https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08518.htmltarget/arm/cpu.c +4
-2@@ -1245,6 +1245,10 @@ void arm_cpu_post_init(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_GENERIC_TIMER )) {qdev_property_add_static (DEVICE (cpu), &arm_cpu_gt_cntfrq_property); } + +if (kvm_enabled ()) { +kvm_arm_add_vcpu_properties (obj); + } }static void arm_cpu_finalizefn (Object *obj)@@ -2029,7 +2033,6 @@ static void arm_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {cortex_a15_initfn (obj);@@ -2183,7 +2186,6 @@ static void arm_host_initfn(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); } -kvm_arm_add_vcpu_properties (obj);arm_cpu_post_init (obj); }target/arm/cpu64.c +0
-1@@ -592,7 +592,6 @@ static void aarch64_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {uint64_t t;uint32_t u;target/arm/kvm.c +11
-10@@ -194,17 +194,18 @@ static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)/* KVM VCPU properties should be prefixed with "kvm-". */ void kvm_arm_add_vcpu_properties (Object *obj) { -if (!kvm_enabled ()) { -return ; - } +ARMCPU *cpu =ARM_CPU (obj); +CPUARMState *env = &cpu->env; -ARM_CPU (obj)->kvm_adjvtime = true; -object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, - kvm_no_adjvtime_set); -object_property_set_description (obj,"kvm-no-adjvtime" , -"Set on to disable the adjustment of " -"the virtual counter. VM stopped time " -"will be counted." ); +if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { + cpu->kvm_adjvtime = true; +object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, + kvm_no_adjvtime_set); +object_property_set_description (obj,"kvm-no-adjvtime" , +"Set on to disable the adjustment of " +"the virtual counter. VM stopped time " +"will be counted." ); + } }bool kvm_arm_pmu_supported (CPUState *cpu)Signature · 1 line
2.23.0.
Quoted 33 lines · Andrew Jones
Quoted 11 lines · Ying Fang
Quoted 8 lines · Andrew Jones
Quoted 7 lines · Ying Fang
From: fangying <[email protected]>
Virtual time adjustment was implemented for virt-5.0 machine type, but the cpu property was enabled only for host-passthrough and max cpu model. Let's add it for arm cpu which has the generic timer feature enabled.
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
Suggested-by Andrew Jones <[email protected]>This isn't true. I did suggest the way to arrange the code, after Peter suggested to move the
kvm_arm_add_vcpu_properties()call toarm_cpu_post_init(), but I didn't suggest making this change in general, which is what this tag means. In fact, I've argued that it's prettyI'm quite sorry for adding it here.
No problem.
Quoted 5 lines
Quoted 2 lines
pointless to do this, since KVM users should be using '-cpu host' or '-cpu max' anyway. Since I don't need credit for the code arranging,
As discussed in thread [1], there is a situation where a 'custom' cpu mode is needed for us to keep instruction set compatibility so that migration can be done, just like x86 does.
I understand the motivation. But, as I've said, KVM doesn't work that way.
Quoted 2 lines
And we are planning to add support for it if
nobody is currently doing that.
Quoted 8 lines
Great! I'm looking forward to seeing the KVM patches. Especially since, without the KVM patches, the 'custom' CPU model isn't a custom CPU model, it's just a misleading way to use host passthrough. Indeed, I'm a bit opposed to allowing anything other than '-cpu host' and '-cpu max' (with features explicitly enabled/disabled, e.g. -cpu host,pmu=off) to work until KVM actually works with CPU models. Otherwise, how do we know the difference between a model that actually works and one that is just misleadingly named?
Yes you are right here.
My colleague zhanghailiang and me are now working on it. We will post the patch set soon.
Quoted 111 lines
Thanks,
drewQuoted 104 lines
Thanks.
Ying[1]: https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00022.html
Quoted 98 lines
please just drop the tag. Peter can maybe do that on merge though. Also, despite not agreeing that we need this change today, as there's nothing wrong with it and it looks good to me
Reviewed-by Andrew Jones <[email protected]>Thanks,
drewQuoted 86 lines
Signed-off-by Ying Fang <[email protected]>---
v3:
- set kvm-no-adjvtime property inkvm_arm_add_vcpu_propertiesv2:
- movekvm_arm_add_vcpu_propertiesintoarm_cpu_post_initv1:
- initial commit
- https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08518.htmltarget/arm/cpu.c +4
-2@@ -1245,6 +1245,10 @@ void arm_cpu_post_init(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_GENERIC_TIMER )) {qdev_property_add_static (DEVICE (cpu), &arm_cpu_gt_cntfrq_property); } + +if (kvm_enabled ()) { +kvm_arm_add_vcpu_properties (obj); + } }static void arm_cpu_finalizefn (Object *obj)@@ -2029,7 +2033,6 @@ static void arm_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {cortex_a15_initfn (obj);@@ -2183,7 +2186,6 @@ static void arm_host_initfn(Object *obj)if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); } -kvm_arm_add_vcpu_properties (obj);arm_cpu_post_init (obj); }target/arm/cpu64.c +0
-1@@ -592,7 +592,6 @@ static void aarch64_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); -kvm_arm_add_vcpu_properties (obj); }else {uint64_t t;uint32_t u;target/arm/kvm.c +11
-10@@ -194,17 +194,18 @@ static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)/* KVM VCPU properties should be prefixed with "kvm-". */ void kvm_arm_add_vcpu_properties (Object *obj) { -if (!kvm_enabled ()) { -return ; - } +ARMCPU *cpu =ARM_CPU (obj); +CPUARMState *env = &cpu->env; -ARM_CPU (obj)->kvm_adjvtime = true; -object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, - kvm_no_adjvtime_set); -object_property_set_description (obj,"kvm-no-adjvtime" , -"Set on to disable the adjustment of " -"the virtual counter. VM stopped time " -"will be counted." ); +if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { + cpu->kvm_adjvtime = true; +object_property_add_bool (obj,"kvm-no-adjvtime" , kvm_no_adjvtime_get, + kvm_no_adjvtime_set); +object_property_set_description (obj,"kvm-no-adjvtime" , +"Set on to disable the adjustment of " +"the virtual counter. VM stopped time " +"will be counted." ); + } }bool kvm_arm_pmu_supported (CPUState *cpu)Signature · 1 line
2.23.0.
.
Peter Maydell
AppliedQuoted 10 lines · Ying Fang
From: fangying <[email protected]>
Virtual time adjustment was implemented for virt-5.0 machine type, but the cpu property was enabled only for host-passthrough and max cpu model. Let's add it for arm cpu which has the generic timer feature enabled.
Suggested-by Andrew Jones <[email protected]>Signed-off-by Ying Fang <[email protected]>
Applied to target-arm.next, thanks (with a minor commit message wording tweak, and the suggested-by tag removed).
-- PMM