Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64 sprinkle LE32TOH to fetch instructions on a...



details:   https://anonhg.NetBSD.org/src/rev/d1aa032b7872
branches:  trunk
changeset: 943985:d1aa032b7872
user:      ryo <ryo%NetBSD.org@localhost>
date:      Mon Sep 14 10:53:02 2020 +0000

description:
sprinkle LE32TOH to fetch instructions on aarch64eb

diffstat:

 sys/arch/aarch64/aarch64/db_interface.c |   8 ++++++--
 sys/arch/aarch64/aarch64/trap.c         |   5 +++--
 sys/arch/aarch64/include/db_machdep.h   |  12 +++++++++++-
 3 files changed, 20 insertions(+), 5 deletions(-)

diffs (129 lines):

diff -r 6ef39b0c0bfe -r d1aa032b7872 sys/arch/aarch64/aarch64/db_interface.c
--- a/sys/arch/aarch64/aarch64/db_interface.c   Mon Sep 14 10:06:35 2020 +0000
+++ b/sys/arch/aarch64/aarch64/db_interface.c   Mon Sep 14 10:53:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.9 2020/08/11 19:46:56 skrll Exp $ */
+/* $NetBSD: db_interface.c,v 1.10 2020/09/14 10:53:02 ryo Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.9 2020/08/11 19:46:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.10 2020/09/14 10:53:02 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -234,6 +234,8 @@
 db_addr_t
 db_branch_taken(db_expr_t inst, db_addr_t pc, db_regs_t *regs)
 {
+       LE32TOH(inst);
+
 #define INSN_FMT_RN(insn)              (((insn) >> 5) & 0x1f)
 #define INSN_FMT_IMM26(insn)   ((insn) & 0x03ffffff)
 #define INSN_FMT_IMM19(insn)   (((insn) >> 5) & 0x7ffff)
@@ -267,6 +269,8 @@
 bool
 db_inst_unconditional_flow_transfer(db_expr_t inst)
 {
+       LE32TOH(inst);
+
        if (((inst & 0xfffffc1f) == 0xd65f0000) ||      /* ret xN */
            ((inst & 0xfc000000) == 0x94000000) ||      /* bl */
            ((inst & 0xfffffc1f) == 0xd63f0000) ||      /* blr */
diff -r 6ef39b0c0bfe -r d1aa032b7872 sys/arch/aarch64/aarch64/trap.c
--- a/sys/arch/aarch64/aarch64/trap.c   Mon Sep 14 10:06:35 2020 +0000
+++ b/sys/arch/aarch64/aarch64/trap.c   Mon Sep 14 10:53:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.36 2020/08/02 06:58:16 maxv Exp $ */
+/* $NetBSD: trap.c,v 1.37 2020/09/14 10:53:02 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.36 2020/08/02 06:58:16 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.37 2020/09/14 10:53:02 ryo Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -386,6 +386,7 @@
                return EMUL_ARM_FAULT;
        }
 
+       LE32TOH(insn);
        if ((insn & 0xffffffe0) == 0xd53b0020) {
                /* mrs x?,ctr_el0 */
                unsigned int Xt = insn & 31;
diff -r 6ef39b0c0bfe -r d1aa032b7872 sys/arch/aarch64/include/db_machdep.h
--- a/sys/arch/aarch64/include/db_machdep.h     Mon Sep 14 10:06:35 2020 +0000
+++ b/sys/arch/aarch64/include/db_machdep.h     Mon Sep 14 10:53:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.10 2020/07/08 03:45:13 ryo Exp $ */
+/* $NetBSD: db_machdep.h,v 1.11 2020/09/14 10:53:02 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -76,7 +76,11 @@
 
 #define BKPT_ADDR(addr)                (addr)
 #define BKPT_SIZE              4
+#ifdef __AARCH64EB__
+#define BKPT_INSN              0x000020d4      /* brk #0 */
+#else
 #define BKPT_INSN              0xd4200000      /* brk #0 */
+#endif
 #define BKPT_SET(insn, addr)   (BKPT_INSN)
 
 typedef struct trapframe db_regs_t;
@@ -99,18 +103,21 @@
 static inline bool
 inst_return(db_expr_t insn)
 {
+       LE32TOH(insn);
        return ((insn & 0xfffffc1f) == 0xd65f0000);     /* ret xN */
 }
 
 static inline bool
 inst_trap_return(db_expr_t insn)
 {
+       LE32TOH(insn);
        return insn == 0xd69f03e0;                      /* eret */
 }
 
 static inline bool
 inst_call(db_expr_t insn)
 {
+       LE32TOH(insn);
        return ((insn & 0xfc000000) == 0x94000000)      /* bl */
            || ((insn & 0xfffffc1f) == 0xd63f0000);     /* blr */
 }
@@ -118,6 +125,7 @@
 static inline bool
 inst_load(db_expr_t insn)
 {
+       LE32TOH(insn);
        return
            ((insn & 0xffe00c00) == 0xb8800000) ||      /* ldursw */
            /* ldrsw imm{pre,post}idx */
@@ -155,6 +163,7 @@
 static inline bool
 inst_store(db_expr_t insn)
 {
+       LE32TOH(insn);
        return
            ((insn & 0xbfe00000) == 0x88200000) ||      /* stlxp,stxp */
            /* stp {pre,post}idx,stp signed,stnp */
@@ -178,6 +187,7 @@
 static inline bool
 inst_branch(db_expr_t insn)
 {
+       LE32TOH(insn);
        return
            ((insn & 0xff000010) == 0x54000000) ||      /* b.cond */
            ((insn & 0xfc000000) == 0x14000000) ||      /* b imm */



Home | Main Index | Thread Index | Old Index