Lines Matching +full:step +full:- +full:up
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2015 - Linaro Ltd
12 #include <asm/debug-monitors.h>
40 vcpu->arch.guest_debug_preserved.mdscr_el1 = val; in save_guest_debug_regs()
43 vcpu->arch.guest_debug_preserved.mdscr_el1); in save_guest_debug_regs()
48 u64 val = vcpu->arch.guest_debug_preserved.mdscr_el1; in restore_guest_debug_regs()
57 * kvm_arm_init_debug - grab what we need for debug
61 * presumably been set-up by some knowledgeable bootcode.
63 * It is called once per-cpu during CPU hyp initialisation.
72 * kvm_arm_reset_debug_ptr - reset the debug ptr to point to the vcpu state
77 vcpu->arch.debug_ptr = &vcpu->arch.vcpu_debug_state; in kvm_arm_reset_debug_ptr()
81 * kvm_arm_setup_debug - set up debug related stuff
88 * - Performance monitors (MDCR_EL2_TPM/MDCR_EL2_TPMCR)
89 * - Debug ROM Address (MDCR_EL2_TDRA)
90 * - OS related registers (MDCR_EL2_TDOSA)
91 * - Statistical profiler (MDCR_EL2_TPMS/MDCR_EL2_E2PB)
95 * flag on vcpu->arch.flags). Since the guest must not interfere
103 bool trap_debug = !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY); in kvm_arm_setup_debug()
104 unsigned long mdscr, orig_mdcr_el2 = vcpu->arch.mdcr_el2; in kvm_arm_setup_debug()
106 trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug); in kvm_arm_setup_debug()
112 vcpu->arch.mdcr_el2 = __this_cpu_read(mdcr_el2) & MDCR_EL2_HPMN_MASK; in kvm_arm_setup_debug()
113 vcpu->arch.mdcr_el2 |= (MDCR_EL2_TPM | in kvm_arm_setup_debug()
120 if (vcpu->guest_debug) { in kvm_arm_setup_debug()
122 vcpu->arch.mdcr_el2 |= MDCR_EL2_TDE; in kvm_arm_setup_debug()
128 * Single Step (ARM ARM D2.12.3 The software step state in kvm_arm_setup_debug()
131 * If we are doing Single Step we need to manipulate in kvm_arm_setup_debug()
133 * step has occurred the hypervisor will trap the in kvm_arm_setup_debug()
136 * If the guest attempts to single step its userspace in kvm_arm_setup_debug()
143 * single-step behind the scenes but everything in kvm_arm_setup_debug()
147 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { in kvm_arm_setup_debug()
169 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_setup_debug()
175 vcpu->arch.debug_ptr = &vcpu->arch.external_debug_state; in kvm_arm_setup_debug()
176 vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY; in kvm_arm_setup_debug()
180 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_setup_debug()
181 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_setup_debug()
184 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_setup_debug()
185 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_setup_debug()
189 BUG_ON(!vcpu->guest_debug && in kvm_arm_setup_debug()
190 vcpu->arch.debug_ptr != &vcpu->arch.vcpu_debug_state); in kvm_arm_setup_debug()
194 vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA; in kvm_arm_setup_debug()
198 vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY; in kvm_arm_setup_debug()
201 if (has_vhe() && orig_mdcr_el2 != vcpu->arch.mdcr_el2) in kvm_arm_setup_debug()
202 write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); in kvm_arm_setup_debug()
204 trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2); in kvm_arm_setup_debug()
210 trace_kvm_arm_clear_debug(vcpu->guest_debug); in kvm_arm_clear_debug()
212 if (vcpu->guest_debug) { in kvm_arm_clear_debug()
219 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_clear_debug()
223 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_clear_debug()
224 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_clear_debug()
227 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_clear_debug()
228 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_clear_debug()