summaryrefslogtreecommitdiffstats
path: root/include/kvm/arm_arch_timer.h
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2024-10-23 16:53:14 +0200
committerOliver Upton <oliver.upton@linux.dev>2024-10-31 03:42:29 +0100
commit164b5e20cdf6038f1b38867d2f6252ec6f10c356 (patch)
tree6894bd0f2d469d83a822f07475999655825d4663 /include/kvm/arm_arch_timer.h
parentKVM: arm64: nv: Add missing EL2->EL1 mappings in get_el2_to_el1_mapping() (diff)
downloadlinux-164b5e20cdf6038f1b38867d2f6252ec6f10c356.tar.xz
linux-164b5e20cdf6038f1b38867d2f6252ec6f10c356.zip
KVM: arm64: nv: Handle CNTHCTL_EL2 specially
Accessing CNTHCTL_EL2 is fraught with danger if running with HCR_EL2.E2H=1: half of the bits are held in CNTKCTL_EL1, and thus can be changed behind our back, while the rest lives in the CNTHCTL_EL2 shadow copy that is memory-based. Yes, this is a lot of fun! Make sure that we merge the two on read access, while we can write to CNTKCTL_EL1 in a more straightforward manner. Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20241023145345.1613824-7-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to '')
-rw-r--r--include/kvm/arm_arch_timer.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h
index c819c5d16613..fd650a8789b9 100644
--- a/include/kvm/arm_arch_timer.h
+++ b/include/kvm/arm_arch_timer.h
@@ -147,6 +147,9 @@ u64 timer_get_cval(struct arch_timer_context *ctxt);
void kvm_timer_cpu_up(void);
void kvm_timer_cpu_down(void);
+/* CNTKCTL_EL1 valid bits as of DDI0487J.a */
+#define CNTKCTL_VALID_BITS (BIT(17) | GENMASK_ULL(9, 0))
+
static inline bool has_cntpoff(void)
{
return (has_vhe() && cpus_have_final_cap(ARM64_HAS_ECV_CNTPOFF));