Skip to content

Commit cf8040d

Browse files
author
Gavin Shan
committed
KVM: arm64: VHE: Synchronize restore of host debug registers
JIRA: https://issues.redhat.com/browse/RHEL-93666 When KVM runs in non-protected VHE mode, there's no context synchronization event between __debug_switch_to_host() restoring the host debug registers and __kvm_vcpu_run() unmasking debug exceptions. Due to this, it's theoretically possible for the host to take an unexpected debug exception due to the stale guest configuration. This cannot happen in NVHE/HVHE mode as debug exceptions are masked in the hyp code, and the exception return to the host will provide the necessary context synchronization before debug exceptions can be taken. For now, avoid the problem by adding an ISB after VHE hyp code restores the host debug registers. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Fuad Tabba <tabba@google.com> Cc: Marc Zyngier <maz@kernel.org> Cc: Mark Brown <broonie@kernel.org> Cc: Oliver Upton <oliver.upton@linux.dev> Cc: Will Deacon <will@kernel.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20250617133718.4014181-2-mark.rutland@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org> (cherry picked from commit cade3d5) Signed-off-by: Gavin Shan <gshan@redhat.com> Conflicts: arch/arm64/kvm/hyp/include/hyp/debug-sr.h Contextual conflict due to missed upstream commit beb470d ("KVM: arm64: Use debug_owner to track if debug regs need save/restore")
1 parent 529dfff commit cf8040d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/arm64/kvm/hyp/include/hyp/debug-sr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ static inline void __debug_switch_to_host_common(struct kvm_vcpu *vcpu)
163163
__debug_restore_state(host_dbg, host_ctxt);
164164

165165
vcpu_clear_flag(vcpu, DEBUG_DIRTY);
166+
167+
if (has_vhe())
168+
isb();
166169
}
167170

168171
#endif /* __ARM64_KVM_HYP_DEBUG_SR_H__ */

0 commit comments

Comments
 (0)