Skip to content

Commit 479428c

Browse files
author
Marc Zyngier
committed
KVM: arm64: nv: Propagate CNTHCTL_EL2.EL1NV{P,V}CT bits
Allow a guest hypervisor to trap accesses to CNT{P,V}CT_EL02 by propagating these trap bits to the host trap configuration. Acked-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent c271269 commit 479428c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/arm64/kvm/arch_timer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,10 @@ static void timer_set_traps(struct kvm_vcpu *vcpu, struct timer_map *map)
824824
* Apply the enable bits that the guest hypervisor has requested for
825825
* its own guest. We can only add traps that wouldn't have been set
826826
* above.
827+
* Implementation choices: we do not support NV when E2H=0 in the
828+
* guest, and we don't support configuration where E2H is writable
829+
* by the guest (either FEAT_VHE or FEAT_E2H0 is implemented, but
830+
* not both). This simplifies the handling of the EL1NV* bits.
827831
*/
828832
if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu)) {
829833
u64 val = __vcpu_sys_reg(vcpu, CNTHCTL_EL2);
@@ -834,6 +838,9 @@ static void timer_set_traps(struct kvm_vcpu *vcpu, struct timer_map *map)
834838

835839
tpt |= !(val & (CNTHCTL_EL1PCEN << 10));
836840
tpc |= !(val & (CNTHCTL_EL1PCTEN << 10));
841+
842+
tpt02 |= (val & CNTHCTL_EL1NVPCT);
843+
tvt02 |= (val & CNTHCTL_EL1NVVCT);
837844
}
838845

839846
/*

0 commit comments

Comments
 (0)