The function debugger_trap_entry() is somewhat large for an inlined
function. This commit moves debugger_trap_entry() into debugger.c and
makes it not inlined.
Signed-off-by: Bobby Eshleman <bobby.eshleman@gmail.com>
---
Changes in v2:
- Move obj-$(CONFIG_CRASH_DEBUG) += debugger.o to be in alphabetical
order
- Constify cpu_user_regs *regs and struct vcpu *v in
debugger_trap_entry()
xen/arch/x86/Makefile | 1 +
xen/arch/x86/debugger.c | 41 ++++++++++++++++++++++++++++++++++
xen/include/asm-x86/debugger.h | 26 ++-------------------
3 files changed, 44 insertions(+), 24 deletions(-)
create mode 100644 xen/arch/x86/debugger.c
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 2ec883456e..c5c9f37570 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_PV) += compat.o
obj-$(CONFIG_PV32) += x86_64/compat.o
obj-$(CONFIG_KEXEC) += crash.o
obj-$(CONFIG_GDBSX) += debug.o
+obj-$(CONFIG_CRASH_DEBUG) += debugger.o
obj-y += delay.o
obj-y += desc.o
obj-bin-y += dmi_scan.init.o
diff --git a/xen/arch/x86/debugger.c b/xen/arch/x86/debugger.c
new file mode 100644
index 0000000000..985c1275b4
--- /dev/null
+++ b/xen/arch/x86/debugger.c
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * x86 crash debug hooks
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <asm/debugger.h>
+#include <xen/domain.h>
+#include <xen/event.h>
+#include <xen/sched.h>
+
+bool debugger_trap_entry(
+ unsigned int vector, const struct cpu_user_regs *regs)
+{
+ /*
+ * This function is called before any checks are made. Amongst other
+ * things, be aware that during early boot, current is not a safe pointer
+ * to follow.
+ */
+ const struct vcpu *v = current;
+
+ if ( vector != TRAP_int3 && vector != TRAP_debug )
+ return false;
+
+ if ( guest_mode(regs) && guest_kernel_mode(v, regs) &&
+ v->domain->debugger_attached )
+ {
+ if ( vector != TRAP_debug ) /* domain pause is good enough */
+ current->arch.gdbsx_vcpu_event = vector;
+ domain_pause_for_debugger();
+ return true;
+ }
+
+ return false;
+}
diff --git a/xen/include/asm-x86/debugger.h b/xen/include/asm-x86/debugger.h
index c856c1b795..75e35c7902 100644
--- a/xen/include/asm-x86/debugger.h
+++ b/xen/include/asm-x86/debugger.h
@@ -31,30 +31,8 @@ static inline bool debugger_trap_fatal(
/* Int3 is a trivial way to gather cpu_user_regs context. */
#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
-static inline bool debugger_trap_entry(
- unsigned int vector, struct cpu_user_regs *regs)
-{
- /*
- * This function is called before any checks are made. Amongst other
- * things, be aware that during early boot, current is not a safe pointer
- * to follow.
- */
- struct vcpu *v = current;
-
- if ( vector != TRAP_int3 && vector != TRAP_debug )
- return false;
-
- if ( guest_mode(regs) && guest_kernel_mode(v, regs) &&
- v->domain->debugger_attached )
- {
- if ( vector != TRAP_debug ) /* domain pause is good enough */
- current->arch.gdbsx_vcpu_event = vector;
- domain_pause_for_debugger();
- return true;
- }
-
- return false;
-}
+bool debugger_trap_entry(
+ unsigned int vector, const struct cpu_user_regs *regs);
#ifdef CONFIG_GDBSX
unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(void) buf,
--
2.30.0
On 14.07.2021 22:37, Bobby Eshleman wrote: > The function debugger_trap_entry() is somewhat large for an inlined > function. This commit moves debugger_trap_entry() into debugger.c and > makes it not inlined. > > Signed-off-by: Bobby Eshleman <bobby.eshleman@gmail.com> Acked-by: Jan Beulich <jbeulich@suse.com>
© 2016 - 2026 Red Hat, Inc.