Skip to content

Commit

Permalink
KVM: arm/arm64: No need to zero CNTVOFF in kvm_timer_vcpu_put() for VHE
Browse files Browse the repository at this point in the history
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.

Acked-by: Marc Zyngier <[email protected]>
Acked-by: Christoffer Dall <[email protected]>
Signed-off-by: Shanker Donthineni <[email protected]>
Signed-off-by: Christoffer Dall <[email protected]>
  • Loading branch information
Shanker Donthineni authored and chazy committed Feb 26, 2018
1 parent b9fb173 commit 250be9d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions virt/kvm/arm/arch_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit 250be9d

Please sign in to comment.