]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0
authorMichal Orzel <michal.orzel@amd.com>
Thu, 28 Sep 2023 09:44:04 +0000 (11:44 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 21 Oct 2023 07:24:58 +0000 (10:24 +0300)
commit31c6d1d6549a153c0e6023308b47794672c5275b
tree976d9e620b5656aa4bc2467cb505ff9f3b325c1a
parent59ee12a961bbde4e2be6766ba297c03a3d670356
target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0

On an attempt to access CNTPCT_EL0 from EL0 using a guest running on top
of Xen, a trap from EL2 was observed which is something not reproducible
on HW (also, Xen does not trap accesses to physical counter).

This is because gt_counter_access() checks for an incorrect bit (1
instead of 0) of CNTHCTL_EL2 if HCR_EL2.E2H is 0 and access is made to
physical counter. Refer ARM ARM DDI 0487J.a, D19.12.2:
When HCR_EL2.E2H is 0:
 - EL1PCTEN, bit [0]: refers to physical counter
 - EL1PCEN, bit [1]: refers to physical timer registers

Drop entire block "if (hcr & HCR_E2H) {...} else {...}" from EL0 case
and fall through to EL1 case, given that after fixing checking for the
correct bit, the handling is the same.

Fixes: 5bc8437136fb ("target/arm: Update timer access for VHE")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Message-id: 20230928094404.20802-1-michal.orzel@amd.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit d01448c79d89cfdc86228081b1dd1dfaf85fb4c3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/arm/helper.c