qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/arm/cpu: adjust virtual time for cortex series cpu
@ 2020-05-30  9:22 Ying Fang
  2020-06-01 12:41 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Ying Fang @ 2020-05-30  9:22 UTC (permalink / raw)
  To: drjones, qemu-devel, qemu-arm
  Cc: peter.maydell, zhang.zhanghailiang, wu.wubin

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 cortex series cpu which has
the gernic timer feature enabled.

Signed-off-by: Ying Fang <fangying1@huawei.com>
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 32bec156f2..a564141b22 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1973,6 +1973,9 @@ static void cortex_a7_initfn(Object *obj)
     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
     define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
+    if (kvm_enabled()) {
+        kvm_arm_add_vcpu_properties(obj);
+    }
 }
 
 static void cortex_a15_initfn(Object *obj)
@@ -2015,6 +2018,9 @@ static void cortex_a15_initfn(Object *obj)
     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
     define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
+    if (kvm_enabled()) {
+        kvm_arm_add_vcpu_properties(obj);
+    }
 }
 
 #ifndef TARGET_AARCH64
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index cbc5c3868f..3922347b83 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -137,6 +137,9 @@ static void aarch64_a57_initfn(Object *obj)
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
+    if (kvm_enabled()) {
+        kvm_arm_add_vcpu_properties(obj);
+    }
 }
 
 static void aarch64_a53_initfn(Object *obj)
@@ -190,6 +193,9 @@ static void aarch64_a53_initfn(Object *obj)
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
+    if (kvm_enabled()) {
+        kvm_arm_add_vcpu_properties(obj);
+    }
 }
 
 static void aarch64_a72_initfn(Object *obj)
@@ -241,6 +247,9 @@ static void aarch64_a72_initfn(Object *obj)
     cpu->gic_vpribits = 5;
     cpu->gic_vprebits = 5;
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
+    if (kvm_enabled()) {
+        kvm_arm_add_vcpu_properties(obj);
+    }
 }
 
 void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
-- 
2.23.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/arm/cpu: adjust virtual time for cortex series cpu
  2020-05-30  9:22 [PATCH] target/arm/cpu: adjust virtual time for cortex series cpu Ying Fang
@ 2020-06-01 12:41 ` Peter Maydell
  2020-06-03  1:04   ` Ying Fang
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2020-06-01 12:41 UTC (permalink / raw)
  To: Ying Fang
  Cc: Andrew Jones, qemu-arm, QEMU Developers, wu.wubin, zhanghailiang

On Sat, 30 May 2020 at 10:22, Ying Fang <fangying1@huawei.com> wrote:
>
> 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 cortex series cpu which has
> the gernic timer feature enabled.
>
> Signed-off-by: Ying Fang <fangying1@huawei.com>
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index 32bec156f2..a564141b22 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -1973,6 +1973,9 @@ static void cortex_a7_initfn(Object *obj)
>      cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
>      cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
>      define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
> +    if (kvm_enabled()) {
> +        kvm_arm_add_vcpu_properties(obj);
> +    }
>  }

If we have the same bit of code in all these initfns,
that suggests we should probably actually be doing this
in some more generic place conditional on some cpu feature
or other test. The commit message suggests we should add
this property for every CPU which is using KVM and has
the generic timers, in which case we could perhaps
have the call to kvm_arm_add_vcpu_properties moved to
arm_cpu_post_init(), and then have the kvm_arm_add_vcpu_properties
function check the ARM_FEATURE_GENERIC_TIMER flag to see
whether to add the property or not.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/arm/cpu: adjust virtual time for cortex series cpu
  2020-06-01 12:41 ` Peter Maydell
@ 2020-06-03  1:04   ` Ying Fang
  0 siblings, 0 replies; 3+ messages in thread
From: Ying Fang @ 2020-06-03  1:04 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Andrew Jones, qemu-arm, QEMU Developers, wu.wubin, zhanghailiang



On 2020/6/1 20:41, Peter Maydell wrote:
> On Sat, 30 May 2020 at 10:22, Ying Fang <fangying1@huawei.com> wrote:
>>
>> 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 cortex series cpu which has
>> the gernic timer feature enabled.
>>
>> Signed-off-by: Ying Fang <fangying1@huawei.com>
>> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
>> index 32bec156f2..a564141b22 100644
>> --- a/target/arm/cpu.c
>> +++ b/target/arm/cpu.c
>> @@ -1973,6 +1973,9 @@ static void cortex_a7_initfn(Object *obj)
>>       cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
>>       cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
>>       define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
>> +    if (kvm_enabled()) {
>> +        kvm_arm_add_vcpu_properties(obj);
>> +    }
>>   }
> 
> If we have the same bit of code in all these initfns,
> that suggests we should probably actually be doing this
> in some more generic place conditional on some cpu feature
> or other test. The commit message suggests we should add
> this property for every CPU which is using KVM and has
> the generic timers, in which case we could perhaps
> have the call to kvm_arm_add_vcpu_properties moved to
> arm_cpu_post_init(), and then have the kvm_arm_add_vcpu_properties
> function check the ARM_FEATURE_GENERIC_TIMER flag to see
> whether to add the property or not.
Thanks for pointing it out, to put kvm_arm_add_vcpu_properties into
arm_cpu_post_init is much better.

I will send a V2.
> 
> thanks
> -- PMM
> 
> .
> 
Thanks
Ying.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-03  1:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30  9:22 [PATCH] target/arm/cpu: adjust virtual time for cortex series cpu Ying Fang
2020-06-01 12:41 ` Peter Maydell
2020-06-03  1:04   ` Ying Fang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).