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>
36 * When single-step is enabled by userspace, we tweak PSTATE.SS on every
38 * for the vcpu after the single-step is disabled.
44 vcpu->arch.guest_debug_preserved.mdscr_el1 = val; in save_guest_debug_regs()
47 vcpu->arch.guest_debug_preserved.mdscr_el1); in save_guest_debug_regs()
49 vcpu->arch.guest_debug_preserved.pstate_ss = in save_guest_debug_regs()
55 u64 val = vcpu->arch.guest_debug_preserved.mdscr_el1; in restore_guest_debug_regs()
62 if (vcpu->arch.guest_debug_preserved.pstate_ss) in restore_guest_debug_regs()
69 * kvm_arm_init_debug - grab what we need for debug
73 * presumably been set-up by some knowledgeable bootcode.
75 * It is called once per-cpu during CPU hyp initialisation.
84 * kvm_arm_setup_mdcr_el2 - configure vcpu mdcr_el2 value
89 * - Performance monitors (MDCR_EL2_TPM/MDCR_EL2_TPMCR)
90 * - Debug ROM Address (MDCR_EL2_TDRA)
91 * - OS related registers (MDCR_EL2_TDOSA)
92 * - Statistical profiler (MDCR_EL2_TPMS/MDCR_EL2_E2PB)
93 * - Self-hosted Trace Filter controls (MDCR_EL2_TTRF)
94 * - Self-hosted Trace (MDCR_EL2_TTRF/MDCR_EL2_E2TB)
102 vcpu->arch.mdcr_el2 = __this_cpu_read(mdcr_el2) & MDCR_EL2_HPMN_MASK; in kvm_arm_setup_mdcr_el2()
103 vcpu->arch.mdcr_el2 |= (MDCR_EL2_TPM | in kvm_arm_setup_mdcr_el2()
111 if (vcpu->guest_debug) in kvm_arm_setup_mdcr_el2()
113 vcpu->arch.mdcr_el2 |= MDCR_EL2_TDE; in kvm_arm_setup_mdcr_el2()
117 * - Userspace is using the hardware to debug the guest in kvm_arm_setup_mdcr_el2()
119 * - The guest is not using debug (DEBUG_DIRTY clear). in kvm_arm_setup_mdcr_el2()
120 * - The guest has enabled the OS Lock (debug exceptions are blocked). in kvm_arm_setup_mdcr_el2()
122 if ((vcpu->guest_debug & KVM_GUESTDBG_USE_HW) || in kvm_arm_setup_mdcr_el2()
125 vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA; in kvm_arm_setup_mdcr_el2()
127 trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2); in kvm_arm_setup_mdcr_el2()
131 * kvm_arm_vcpu_init_debug - setup vcpu debug traps
145 * kvm_arm_reset_debug_ptr - reset the debug ptr to point to the vcpu state
150 vcpu->arch.debug_ptr = &vcpu->arch.vcpu_debug_state; in kvm_arm_reset_debug_ptr()
154 * kvm_arm_setup_debug - set up debug related stuff
163 * flag on vcpu->arch.iflags). Since the guest must not interfere
171 unsigned long mdscr, orig_mdcr_el2 = vcpu->arch.mdcr_el2; in kvm_arm_setup_debug()
173 trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug); in kvm_arm_setup_debug()
178 if (vcpu->guest_debug || kvm_vcpu_os_lock_enabled(vcpu)) { in kvm_arm_setup_debug()
183 * Single Step (ARM ARM D2.12.3 The software step state in kvm_arm_setup_debug()
186 * If we are doing Single Step we need to manipulate in kvm_arm_setup_debug()
188 * step has occurred the hypervisor will trap the in kvm_arm_setup_debug()
191 * If the guest attempts to single step its userspace in kvm_arm_setup_debug()
198 * single-step behind the scenes but everything in kvm_arm_setup_debug()
202 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { in kvm_arm_setup_debug()
204 * If the software step state at the last guest exit in kvm_arm_setup_debug()
205 * was Active-pending, we don't set DBG_SPSR_SS so in kvm_arm_setup_debug()
207 * single-step until the pending Software Step in kvm_arm_setup_debug()
234 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_setup_debug()
240 vcpu->arch.debug_ptr = &vcpu->arch.external_debug_state; in kvm_arm_setup_debug()
244 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_setup_debug()
245 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_setup_debug()
248 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_setup_debug()
249 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_setup_debug()
266 BUG_ON(!vcpu->guest_debug && in kvm_arm_setup_debug()
267 vcpu->arch.debug_ptr != &vcpu->arch.vcpu_debug_state); in kvm_arm_setup_debug()
274 if (has_vhe() && orig_mdcr_el2 != vcpu->arch.mdcr_el2) in kvm_arm_setup_debug()
275 write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); in kvm_arm_setup_debug()
282 trace_kvm_arm_clear_debug(vcpu->guest_debug); in kvm_arm_clear_debug()
287 if (vcpu->guest_debug || kvm_vcpu_os_lock_enabled(vcpu)) { in kvm_arm_clear_debug()
288 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { in kvm_arm_clear_debug()
292 * until Software Step exception is taken. in kvm_arm_clear_debug()
303 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_clear_debug()
307 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_clear_debug()
308 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_clear_debug()
311 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_clear_debug()
312 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_clear_debug()