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_setup_mdcr_el2 - configure vcpu mdcr_el2 value
77 * - Performance monitors (MDCR_EL2_TPM/MDCR_EL2_TPMCR)
78 * - Debug ROM Address (MDCR_EL2_TDRA)
79 * - OS related registers (MDCR_EL2_TDOSA)
80 * - Statistical profiler (MDCR_EL2_TPMS/MDCR_EL2_E2PB)
81 * - Self-hosted Trace Filter controls (MDCR_EL2_TTRF)
89 vcpu->arch.mdcr_el2 = __this_cpu_read(mdcr_el2) & MDCR_EL2_HPMN_MASK; in kvm_arm_setup_mdcr_el2()
90 vcpu->arch.mdcr_el2 |= (MDCR_EL2_TPM | in kvm_arm_setup_mdcr_el2()
98 if (vcpu->guest_debug) in kvm_arm_setup_mdcr_el2()
100 vcpu->arch.mdcr_el2 |= MDCR_EL2_TDE; in kvm_arm_setup_mdcr_el2()
104 * - Userspace is using the hardware to debug the guest in kvm_arm_setup_mdcr_el2()
106 * - The guest is not using debug (KVM_ARM64_DEBUG_DIRTY is clear). in kvm_arm_setup_mdcr_el2()
108 if ((vcpu->guest_debug & KVM_GUESTDBG_USE_HW) || in kvm_arm_setup_mdcr_el2()
109 !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY)) in kvm_arm_setup_mdcr_el2()
110 vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA; in kvm_arm_setup_mdcr_el2()
112 trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2); in kvm_arm_setup_mdcr_el2()
116 * kvm_arm_vcpu_init_debug - setup vcpu debug traps
130 * kvm_arm_reset_debug_ptr - reset the debug ptr to point to the vcpu state
135 vcpu->arch.debug_ptr = &vcpu->arch.vcpu_debug_state; in kvm_arm_reset_debug_ptr()
139 * kvm_arm_setup_debug - set up debug related stuff
148 * flag on vcpu->arch.flags). Since the guest must not interfere
156 unsigned long mdscr, orig_mdcr_el2 = vcpu->arch.mdcr_el2; in kvm_arm_setup_debug()
158 trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug); in kvm_arm_setup_debug()
163 if (vcpu->guest_debug) { in kvm_arm_setup_debug()
168 * Single Step (ARM ARM D2.12.3 The software step state in kvm_arm_setup_debug()
171 * If we are doing Single Step we need to manipulate in kvm_arm_setup_debug()
173 * step has occurred the hypervisor will trap the in kvm_arm_setup_debug()
176 * If the guest attempts to single step its userspace in kvm_arm_setup_debug()
183 * single-step behind the scenes but everything in kvm_arm_setup_debug()
187 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { in kvm_arm_setup_debug()
209 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_setup_debug()
215 vcpu->arch.debug_ptr = &vcpu->arch.external_debug_state; in kvm_arm_setup_debug()
216 vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY; in kvm_arm_setup_debug()
219 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_setup_debug()
220 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_setup_debug()
223 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_setup_debug()
224 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_setup_debug()
228 BUG_ON(!vcpu->guest_debug && in kvm_arm_setup_debug()
229 vcpu->arch.debug_ptr != &vcpu->arch.vcpu_debug_state); in kvm_arm_setup_debug()
233 vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY; in kvm_arm_setup_debug()
236 if (has_vhe() && orig_mdcr_el2 != vcpu->arch.mdcr_el2) in kvm_arm_setup_debug()
237 write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); in kvm_arm_setup_debug()
244 trace_kvm_arm_clear_debug(vcpu->guest_debug); in kvm_arm_clear_debug()
246 if (vcpu->guest_debug) { in kvm_arm_clear_debug()
253 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_clear_debug()
257 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_clear_debug()
258 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_clear_debug()
261 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_clear_debug()
262 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_clear_debug()