diff --git a/sys/arm64/arm64/debug_monitor.c b/sys/arm64/arm64/debug_monitor.c index 37e82d0aa77..dcb3645cf5d 100644 --- a/sys/arm64/arm64/debug_monitor.c +++ b/sys/arm64/arm64/debug_monitor.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -534,7 +535,13 @@ dbg_monitor_exit(struct thread *thread, struct trapframe *frame) { int i; - frame->tf_spsr |= PSR_D; + /* + * PSR_D is an aarch64-only flag. On aarch32, it switches + * the processor to big-endian, so avoid setting it for + * 32bits binaries. + */ + if (!(SV_PROC_FLAG(thread->td_proc, SV_ILP32))) + frame->tf_spsr |= PSR_D; if ((thread->td_pcb->pcb_dbg_regs.dbg_flags & DBGMON_ENABLED) != 0) { /* Install the kernel version of the registers */ dbg_register_sync(&thread->td_pcb->pcb_dbg_regs);