qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Subject: [PATCH 07/21] target/arm/kvm: Move kvm_arm_handle_debug and unexport
Date: Wed, 22 Nov 2023 22:42:05 -0600	[thread overview]
Message-ID: <20231123044219.896776-8-richard.henderson@linaro.org> (raw)
In-Reply-To: <20231123044219.896776-1-richard.henderson@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/kvm_arm.h |  9 ------
 target/arm/kvm.c     | 77 ++++++++++++++++++++++++++++++++++++++++++++
 target/arm/kvm64.c   | 70 ----------------------------------------
 3 files changed, 77 insertions(+), 79 deletions(-)

diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index ac4856cb46..9fa9cb7f76 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -445,13 +445,4 @@ static inline uint32_t kvm_arm_sve_get_vls(CPUState *cs)
 
 #endif
 
-/**
- * kvm_arm_handle_debug:
- * @cs: CPUState
- * @debug_exit: debug part of the KVM exit structure
- *
- * Returns: TRUE if the debug exception was handled.
- */
-bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit);
-
 #endif
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 4608bea7df..55e1b4f26e 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -988,6 +988,83 @@ static int kvm_arm_handle_dabt_nisv(CPUState *cs, uint64_t esr_iss,
     return -1;
 }
 
+/**
+ * kvm_arm_handle_debug:
+ * @cs: CPUState
+ * @debug_exit: debug part of the KVM exit structure
+ *
+ * Returns: TRUE if the debug exception was handled.
+ *
+ * See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register
+ *
+ * To minimise translating between kernel and user-space the kernel
+ * ABI just provides user-space with the full exception syndrome
+ * register value to be decoded in QEMU.
+ */
+static bool kvm_arm_handle_debug(CPUState *cs,
+                                 struct kvm_debug_exit_arch *debug_exit)
+{
+    int hsr_ec = syn_get_ec(debug_exit->hsr);
+    ARMCPU *cpu = ARM_CPU(cs);
+    CPUARMState *env = &cpu->env;
+
+    /* Ensure PC is synchronised */
+    kvm_cpu_synchronize_state(cs);
+
+    switch (hsr_ec) {
+    case EC_SOFTWARESTEP:
+        if (cs->singlestep_enabled) {
+            return true;
+        } else {
+            /*
+             * The kernel should have suppressed the guest's ability to
+             * single step at this point so something has gone wrong.
+             */
+            error_report("%s: guest single-step while debugging unsupported"
+                         " (%"PRIx64", %"PRIx32")",
+                         __func__, env->pc, debug_exit->hsr);
+            return false;
+        }
+        break;
+    case EC_AA64_BKPT:
+        if (kvm_find_sw_breakpoint(cs, env->pc)) {
+            return true;
+        }
+        break;
+    case EC_BREAKPOINT:
+        if (find_hw_breakpoint(cs, env->pc)) {
+            return true;
+        }
+        break;
+    case EC_WATCHPOINT:
+    {
+        CPUWatchpoint *wp = find_hw_watchpoint(cs, debug_exit->far);
+        if (wp) {
+            cs->watchpoint_hit = wp;
+            return true;
+        }
+        break;
+    }
+    default:
+        error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")",
+                     __func__, debug_exit->hsr, env->pc);
+    }
+
+    /* If we are not handling the debug exception it must belong to
+     * the guest. Let's re-use the existing TCG interrupt code to set
+     * everything up properly.
+     */
+    cs->exception_index = EXCP_BKPT;
+    env->exception.syndrome = debug_exit->hsr;
+    env->exception.vaddress = debug_exit->far;
+    env->exception.target_el = 1;
+    qemu_mutex_lock_iothread();
+    arm_cpu_do_interrupt(cs);
+    qemu_mutex_unlock_iothread();
+
+    return false;
+}
+
 int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
 {
     int ret = 0;
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 352643e066..6b6db9374c 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -1121,73 +1121,3 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
     }
     return 0;
 }
-
-/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register
- *
- * To minimise translating between kernel and user-space the kernel
- * ABI just provides user-space with the full exception syndrome
- * register value to be decoded in QEMU.
- */
-
-bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit)
-{
-    int hsr_ec = syn_get_ec(debug_exit->hsr);
-    ARMCPU *cpu = ARM_CPU(cs);
-    CPUARMState *env = &cpu->env;
-
-    /* Ensure PC is synchronised */
-    kvm_cpu_synchronize_state(cs);
-
-    switch (hsr_ec) {
-    case EC_SOFTWARESTEP:
-        if (cs->singlestep_enabled) {
-            return true;
-        } else {
-            /*
-             * The kernel should have suppressed the guest's ability to
-             * single step at this point so something has gone wrong.
-             */
-            error_report("%s: guest single-step while debugging unsupported"
-                         " (%"PRIx64", %"PRIx32")",
-                         __func__, env->pc, debug_exit->hsr);
-            return false;
-        }
-        break;
-    case EC_AA64_BKPT:
-        if (kvm_find_sw_breakpoint(cs, env->pc)) {
-            return true;
-        }
-        break;
-    case EC_BREAKPOINT:
-        if (find_hw_breakpoint(cs, env->pc)) {
-            return true;
-        }
-        break;
-    case EC_WATCHPOINT:
-    {
-        CPUWatchpoint *wp = find_hw_watchpoint(cs, debug_exit->far);
-        if (wp) {
-            cs->watchpoint_hit = wp;
-            return true;
-        }
-        break;
-    }
-    default:
-        error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")",
-                     __func__, debug_exit->hsr, env->pc);
-    }
-
-    /* If we are not handling the debug exception it must belong to
-     * the guest. Let's re-use the existing TCG interrupt code to set
-     * everything up properly.
-     */
-    cs->exception_index = EXCP_BKPT;
-    env->exception.syndrome = debug_exit->hsr;
-    env->exception.vaddress = debug_exit->far;
-    env->exception.target_el = 1;
-    qemu_mutex_lock_iothread();
-    arm_cpu_do_interrupt(cs);
-    qemu_mutex_unlock_iothread();
-
-    return false;
-}
-- 
2.34.1



  parent reply	other threads:[~2023-11-23  4:44 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23  4:41 [PATCH for-9.0 00/21] target/arm: kvm cleanups Richard Henderson
2023-11-23  4:41 ` [PATCH 01/21] accel/kvm: Make kvm_has_guest_debug static Richard Henderson
2023-11-23 11:30   ` Philippe Mathieu-Daudé
2023-11-26 23:36   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 02/21] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe Richard Henderson
2023-11-24 12:03   ` Philippe Mathieu-Daudé
2023-11-26 23:39   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 03/21] target/arm/kvm: Merge kvm_arm_init_debug into kvm_arch_init Richard Henderson
2023-11-23 11:31   ` Philippe Mathieu-Daudé
2023-11-26 23:42   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 04/21] target/arm/kvm: Move kvm_arm_verify_ext_dabt_pending and unexport Richard Henderson
2023-11-23 11:32   ` Philippe Mathieu-Daudé
2023-11-26 23:46   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 05/21] target/arm/kvm: Move kvm_arm_copy_hw_debug_data " Richard Henderson
2023-11-23 11:32   ` Philippe Mathieu-Daudé
2023-11-26 23:48   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 06/21] target/arm/kvm: Move kvm_arm_hw_debug_active " Richard Henderson
2023-11-23 11:34   ` Philippe Mathieu-Daudé
2023-11-26 23:51   ` Gavin Shan
2023-11-23  4:42 ` Richard Henderson [this message]
2023-11-23 11:35   ` [PATCH 07/21] target/arm/kvm: Move kvm_arm_handle_debug " Philippe Mathieu-Daudé
2023-11-26 23:53   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 08/21] target/arm/kvm: Unexport kvm_arm_{get, put}_virtual_time Richard Henderson
2023-11-23 11:40   ` Philippe Mathieu-Daudé
2023-11-26 23:55   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 09/21] target/arm/kvm: Inline kvm_arm_steal_time_supported Richard Henderson
2023-11-23 11:41   ` Philippe Mathieu-Daudé
2023-11-26 23:57   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 10/21] target/arm/kvm: Move kvm_arm_get_host_cpu_features and unexport Richard Henderson
2023-11-24 11:37   ` Philippe Mathieu-Daudé
2023-11-27  0:01   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 11/21] target/arm/kvm: Use a switch for kvm_arm_cpreg_level Richard Henderson
2023-11-23 11:42   ` Philippe Mathieu-Daudé
2023-11-27  0:06   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 12/21] target/arm/kvm: Move kvm_arm_cpreg_level and unexport Richard Henderson
2023-11-24 11:34   ` Philippe Mathieu-Daudé
2023-11-27  0:08   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 13/21] target/arm/kvm: Move kvm_arm_reg_syncs_via_cpreg_list " Richard Henderson
2023-11-23 11:43   ` Philippe Mathieu-Daudé
2023-11-27  0:11   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 14/21] target/arm/kvm: Merge kvm64.c into kvm.c Richard Henderson
2023-11-24 11:41   ` Philippe Mathieu-Daudé
2023-11-27  0:14   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 15/21] target/arm/kvm: Unexport kvm_arm_vcpu_init Richard Henderson
2023-11-23 11:44   ` Philippe Mathieu-Daudé
2023-11-27  0:17   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 16/21] target/arm/kvm: Unexport kvm_arm_vcpu_finalize Richard Henderson
2023-11-23 11:44   ` Philippe Mathieu-Daudé
2023-11-27  0:18   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 17/21] target/arm/kvm: Unexport kvm_arm_init_cpreg_list Richard Henderson
2023-11-23 17:33   ` Philippe Mathieu-Daudé
2023-11-27  0:20   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 18/21] target/arm/kvm: Init cap_has_inject_serror_esr in kvm_arch_init Richard Henderson
2023-11-24 11:49   ` Philippe Mathieu-Daudé
2023-11-24 11:54   ` Philippe Mathieu-Daudé
2023-12-11 17:09     ` Richard Henderson
2023-12-11 18:43       ` Philippe Mathieu-Daudé
2023-12-11 18:58         ` Richard Henderson
2023-11-27  0:21   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 19/21] target/arm/kvm: Unexport kvm_{get,put}_vcpu_events Richard Henderson
2023-11-23 17:34   ` Philippe Mathieu-Daudé
2023-11-27  0:23   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 20/21] target/arm/kvm: Unexport and tidy kvm_arm_sync_mpstate_to_{kvm, qemu} Richard Henderson
2023-11-24 12:05   ` Philippe Mathieu-Daudé
2023-12-11 14:34     ` Peter Maydell
2023-12-11 18:43       ` Philippe Mathieu-Daudé
2023-11-27  0:28   ` Gavin Shan
2023-11-23  4:42 ` [PATCH 21/21] target/arm/kvm: Unexport kvm_arm_vm_state_change Richard Henderson
2023-11-24 11:33   ` Philippe Mathieu-Daudé
2023-11-27  0:29   ` Gavin Shan
2023-11-23 17:40 ` [PATCH for-9.0 00/21] target/arm: kvm cleanups Philippe Mathieu-Daudé
2023-11-23 19:14   ` Philippe Mathieu-Daudé
2023-11-24 12:05 ` Philippe Mathieu-Daudé
2023-12-11 14:35 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231123044219.896776-8-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).