Skip to content

Commit 05d9f34

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: nv: Exclude guest's TWED configuration when TWE isn't set
Ignore the guest hypervisor's configured TWE delay if it hasn't actually requested WFE traps. Otherwise, OR'ing these fields into the effective HCR when the guest sets TWE is safe as KVM doesn't use FEAT_TWED and leaves the fields initialized to 0. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 09dc6b4 commit 05d9f34

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ static u64 __compute_hcr(struct kvm_vcpu *vcpu)
9595
/* Force NV2 in case the guest is forgetful... */
9696
guest_hcr |= HCR_NV2;
9797
}
98+
99+
/*
100+
* Exclude the guest's TWED configuration if it hasn't set TWE
101+
* to avoid potentially delaying traps for the host.
102+
*/
103+
if (!(guest_hcr & HCR_TWE))
104+
guest_hcr &= ~(HCR_EL2_TWEDEn | HCR_EL2_TWEDEL);
98105
}
99106

100107
BUG_ON(host_data_test_flag(VCPU_IN_HYP_CONTEXT) &&

0 commit comments

Comments
 (0)