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
151 vcpu->arch.debug_ptr = &vcpu->arch.vcpu_debug_state; in kvm_arm_reset_debug_ptr()
155 * kvm_arm_setup_debug - set up debug related stuff
164 * flag on vcpu->arch.iflags). Since the guest must not interfere
172 unsigned long mdscr, orig_mdcr_el2 = vcpu->arch.mdcr_el2; in kvm_arm_setup_debug()
174 trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug); in kvm_arm_setup_debug()
179 if (vcpu->guest_debug || kvm_vcpu_os_lock_enabled(vcpu)) { in kvm_arm_setup_debug()
184 * Single Step (ARM ARM D2.12.3 The software step state in kvm_arm_setup_debug()
187 * If we are doing Single Step we need to manipulate in kvm_arm_setup_debug()
189 * step has occurred the hypervisor will trap the in kvm_arm_setup_debug()
192 * If the guest attempts to single step its userspace in kvm_arm_setup_debug()
199 * single-step behind the scenes but everything in kvm_arm_setup_debug()
203 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { in kvm_arm_setup_debug()
205 * If the software step state at the last guest exit in kvm_arm_setup_debug()
206 * was Active-pending, we don't set DBG_SPSR_SS so in kvm_arm_setup_debug()
208 * single-step until the pending Software Step in kvm_arm_setup_debug()
235 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_setup_debug()
241 vcpu->arch.debug_ptr = &vcpu->arch.external_debug_state; in kvm_arm_setup_debug()
245 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_setup_debug()
246 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_setup_debug()
249 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_setup_debug()
250 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_setup_debug()
267 BUG_ON(!vcpu->guest_debug && in kvm_arm_setup_debug()
268 vcpu->arch.debug_ptr != &vcpu->arch.vcpu_debug_state); in kvm_arm_setup_debug()
275 if (has_vhe() && orig_mdcr_el2 != vcpu->arch.mdcr_el2) in kvm_arm_setup_debug()
276 write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); in kvm_arm_setup_debug()
283 trace_kvm_arm_clear_debug(vcpu->guest_debug); in kvm_arm_clear_debug()
288 if (vcpu->guest_debug || kvm_vcpu_os_lock_enabled(vcpu)) { in kvm_arm_clear_debug()
289 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) { in kvm_arm_clear_debug()
293 * until Software Step exception is taken. in kvm_arm_clear_debug()
304 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) { in kvm_arm_clear_debug()
308 &vcpu->arch.debug_ptr->dbg_bcr[0], in kvm_arm_clear_debug()
309 &vcpu->arch.debug_ptr->dbg_bvr[0]); in kvm_arm_clear_debug()
312 &vcpu->arch.debug_ptr->dbg_wcr[0], in kvm_arm_clear_debug()
313 &vcpu->arch.debug_ptr->dbg_wvr[0]); in kvm_arm_clear_debug()