summaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm/debug.c
diff options
context:
space:
mode:
authorAlex Bennée2017-11-16 16:39:19 +0100
committerChristoffer Dall2017-11-29 16:46:19 +0100
commit696673d192f52c2c5a702224ee21f005318a844b (patch)
treea7a25cf68c0197ab08ccf120b5b16c714092e8a1 /arch/arm64/kvm/debug.c
parentarm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one (diff)
downloadkernel-qcow2-linux-696673d192f52c2c5a702224ee21f005318a844b.tar.gz
kernel-qcow2-linux-696673d192f52c2c5a702224ee21f005318a844b.tar.xz
kernel-qcow2-linux-696673d192f52c2c5a702224ee21f005318a844b.zip
KVM: arm/arm64: debug: Introduce helper for single-step
After emulating instructions we may want return to user-space to handle single-step debugging. Introduce a helper function, which, if single-step is enabled, sets the run structure for return and returns true. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Julien Thierry <julien.thierry@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'arch/arm64/kvm/debug.c')
-rw-r--r--arch/arm64/kvm/debug.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
index dbadfaf850a7..fa63b28c65e0 100644
--- a/arch/arm64/kvm/debug.c
+++ b/arch/arm64/kvm/debug.c
@@ -221,3 +221,24 @@ void kvm_arm_clear_debug(struct kvm_vcpu *vcpu)
}
}
}
+
+
+/*
+ * After successfully emulating an instruction, we might want to
+ * return to user space with a KVM_EXIT_DEBUG. We can only do this
+ * once the emulation is complete, though, so for userspace emulations
+ * we have to wait until we have re-entered KVM before calling this
+ * helper.
+ *
+ * Return true (and set exit_reason) to return to userspace or false
+ * if no further action is required.
+ */
+bool kvm_arm_handle_step_debug(struct kvm_vcpu *vcpu, struct kvm_run *run)
+{
+ if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) {
+ run->exit_reason = KVM_EXIT_DEBUG;
+ run->debug.arch.hsr = ESR_ELx_EC_SOFTSTP_LOW << ESR_ELx_EC_SHIFT;
+ return true;
+ }
+ return false;
+}