Skip to content
Commit 94046732 authored by Marc Zyngier's avatar Marc Zyngier
Browse files

KVM: arm64: timers: Correctly handle TGE flip with CNTPOFF_EL2



Contrary to common belief, HCR_EL2.TGE has a direct and immediate
effect on the way the EL0 physical counter is offset. Flipping
TGE from 1 to 0 while at EL2 immediately changes the way the counter
compared to the CVAL limit.

This means that we cannot directly save/restore the guest's view of
CVAL, but that we instead must treat it as if CNTPOFF didn't exist.
Only in the world switch, once we figure out that we do have CNTPOFF,
can we must the offset back and forth depending on the polarity of
TGE.

Fixes: 2b4825a8 ("KVM: arm64: timers: Use CNTPOFF_EL2 to offset the physical timer")
Reported-by: default avatarGanapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Tested-by: default avatarGanapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 839d9035
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment