KVM: arm/arm64: No need to zero CNTVOFF in kvm_timer_vcpu_put() for VHE
PATCH 1/1 KVM: arm/arm64: No need to zero CNTVOFF in kvm_timer_vcpu_put() for VHE
In AArch64/AArch32, the virtual counter uses a fixed virtual offset of zero in the following situations as per ARMv8 specifications:
1) HCR_EL2.E2H is 1, and CNTVCT_EL0/CNTVCT are read from EL2.
2) HCR_EL2.{E2H, TGE} is {1, 1}, and either:
— CNTVCT_EL0 is read from Non-secure EL0 or EL2. — CNTVCT is read from Non-secure EL0.
So, no need to zero CNTVOFF_EL2/CNTVOFF for VHE case.
--- virt/kvm/arm/arch_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
virt/kvm/arm/arch_timer.c +4 -2
@@ -541,9 +541,11 @@ void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu)* The kernel may decide to run userspace after calling vcpu_put, so * we reset cntvoff to 0 to ensure a consistent read between user * accesses to the virtual counter and kernel access to the physical -* counter. +* counter of non-VHE case. For VHE, the virtual counter uses a fixed +* virtual offset of zero, so no need to zero CNTVOFF_EL2 register. */ -set_cntvoff (0 ); +if (!has_vhe ()) +set_cntvoff (0 ); }/*
Signature · 8 lines
Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Shanker,
Quoted 23 lines · Shanker Donthineni
In AArch64/AArch32, the virtual counter uses a fixed virtual offset of zero in the following situations as per ARMv8 specifications:
1) HCR_EL2.E2H is 1, and CNTVCT_EL0/CNTVCT are read from EL2.
2) HCR_EL2.{E2H, TGE} is {1, 1}, and either:
—CNTVCT_EL0is read from Non-secure EL0 or EL2. — CNTVCT is read from Non-secure EL0.So, no need to zero CNTVOFF_EL2/CNTVOFF for VHE case.
Signed-off-by Shanker Donthineni <[email protected]>--- virt/kvm/arm/arch_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)virt/kvm/arm/arch_timer.c +0
-0@@ -541,9 +541,11 @@ void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu)* The kernel may decide to run userspace after calling vcpu_put, so * we reset cntvoff to 0 to ensure a consistent read between user * accesses to the virtual counter and kernel access to the physical
virt/kvm/arm/arch_timer.c void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu) · line 551
Quoted 10 lines
virt/kvm/arm/arch_timer.c +4
-2-* counter. +* counter of non-VHE case. For VHE, the virtual counter uses a fixed +* virtual offset of zero, so no need to zero CNTVOFF_EL2 register. */ -set_cntvoff (0 ); +if (!has_vhe ()) +set_cntvoff (0 ); }/*
I'm okay with this change. I don't think there's a huge gain here though.
Marc, any thoughts or concerns?
Thanks,
-Christoffer
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Marc Zyngier
Acked-byQuoted 36 lines · Christoffer Dall
Hi Shanker,
Quoted 32 lines · Shanker Donthineni
In AArch64/AArch32, the virtual counter uses a fixed virtual offset of zero in the following situations as per ARMv8 specifications:
1) HCR_EL2.E2H is 1, and CNTVCT_EL0/CNTVCT are read from EL2.
2) HCR_EL2.{E2H, TGE} is {1, 1}, and either:
―CNTVCT_EL0is read from Non-secure EL0 or EL2. ― CNTVCT is read from Non-secure EL0.So, no need to zero CNTVOFF_EL2/CNTVOFF for VHE case.
Signed-off-by Shanker Donthineni <[email protected]>--- virt/kvm/arm/arch_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)virt/kvm/arm/arch_timer.c +4
-2@@ -541,9 +541,11 @@ void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu)* The kernel may decide to run userspace after calling vcpu_put, so * we reset cntvoff to 0 to ensure a consistent read between user * accesses to the virtual counter and kernel access to the physical -* counter. +* counter of non-VHE case. For VHE, the virtual counter uses a fixed +* virtual offset of zero, so no need to zero CNTVOFF_EL2 register. */ -set_cntvoff (0 ); +if (!has_vhe ()) +set_cntvoff (0 ); }
Quoted 6 lines
virt/kvm/arm/arch_timer.c void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu) · line 551
Quoted 1 line
virt/kvm/arm/arch_timer.c +0
-0/* I'm okay with this change. I don't think there's a huge gain here though.
Marc, any thoughts or concerns?
None. I don't think this brings any visible performance gain, but hey, why not.
M.
Signature · 1 line
Jazz is not dead, it just smell funny.