Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src make kernel-groveling crash(8) work on aarch64
details: https://anonhg.NetBSD.org/src/rev/9344872ebe96
branches: trunk
changeset: 433460:9344872ebe96
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Sat Sep 15 19:47:48 2018 +0000
description:
make kernel-groveling crash(8) work on aarch64
diffstat:
sys/arch/aarch64/aarch64/db_disasm.c | 5 +++--
sys/arch/aarch64/aarch64/db_machdep.c | 11 +++++++++--
sys/arch/aarch64/aarch64/db_trace.c | 25 +++++++++++++++++++------
sys/arch/aarch64/aarch64/disasm.c | 8 ++++++--
sys/arch/aarch64/include/db_machdep.h | 4 +++-
sys/arch/aarch64/include/machdep.h | 5 ++++-
sys/arch/aarch64/include/pmap.h | 5 ++++-
usr.sbin/crash/Makefile | 6 +++++-
8 files changed, 53 insertions(+), 16 deletions(-)
diffs (truncated from 350 to 300 lines):
diff -r e4c3dbf929a4 -r 9344872ebe96 sys/arch/aarch64/aarch64/db_disasm.c
--- a/sys/arch/aarch64/aarch64/db_disasm.c Sat Sep 15 19:16:58 2018 +0000
+++ b/sys/arch/aarch64/aarch64/db_disasm.c Sat Sep 15 19:47:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_disasm.c,v 1.3 2018/07/17 10:07:49 ryo Exp $ */
+/* $NetBSD: db_disasm.c,v 1.4 2018/09/15 19:47:48 jakllsch Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.3 2018/07/17 10:07:49 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.4 2018/09/15 19:47:48 jakllsch Exp $");
#include <sys/param.h>
#include <machine/db_machdep.h>
@@ -35,6 +35,7 @@
#include <ddb/db_sym.h>
#include <ddb/db_output.h>
#include <ddb/db_access.h>
+#include <ddb/db_user.h>
#include <arch/aarch64/aarch64/disasm.h>
diff -r e4c3dbf929a4 -r 9344872ebe96 sys/arch/aarch64/aarch64/db_machdep.c
--- a/sys/arch/aarch64/aarch64/db_machdep.c Sat Sep 15 19:16:58 2018 +0000
+++ b/sys/arch/aarch64/aarch64/db_machdep.c Sat Sep 15 19:47:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.7 2018/08/14 05:51:54 ryo Exp $ */
+/* $NetBSD: db_machdep.c,v 1.8 2018/09/15 19:47:48 jakllsch Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.7 2018/08/14 05:51:54 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.8 2018/09/15 19:47:48 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -55,6 +55,7 @@
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
#include <ddb/db_interface.h>
+#include <ddb/db_user.h>
#include <dev/cons.h>
@@ -78,6 +79,7 @@
NULL, NULL)
},
#endif
+#if defined(_KERNEL)
{
DDB_ADD_CMD(
"cpuinfo", db_md_cpuinfo_cmd, 0,
@@ -124,6 +126,7 @@
"<param>",
"\tparam: <address> | <#>")
},
+#endif
{
DDB_ADD_CMD(NULL, NULL, 0,
NULL,
@@ -215,6 +218,7 @@
tf->tf_reg[30], tf->tf_sp);
}
+#if defined(_KERNEL)
void
db_md_cpuinfo_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
const char *modif)
@@ -715,6 +719,7 @@
show_watchpoints();
}
+#endif
#ifdef MULTIPROCESSOR
volatile struct cpu_info *db_trigger;
@@ -755,6 +760,7 @@
#endif /* _KERNEL */
#endif /* MULTIPROCESSOR */
+#ifdef DDB
int
kdb_trap(int type, struct trapframe *tf)
{
@@ -846,3 +852,4 @@
return 1;
}
+#endif
diff -r e4c3dbf929a4 -r 9344872ebe96 sys/arch/aarch64/aarch64/db_trace.c
--- a/sys/arch/aarch64/aarch64/db_trace.c Sat Sep 15 19:16:58 2018 +0000
+++ b/sys/arch/aarch64/aarch64/db_trace.c Sat Sep 15 19:47:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_trace.c,v 1.5 2018/09/15 19:16:58 jakllsch Exp $ */
+/* $NetBSD: db_trace.c,v 1.6 2018/09/15 19:47:48 jakllsch Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.5 2018/09/15 19:16:58 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.6 2018/09/15 19:47:48 jakllsch Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -53,8 +53,9 @@
#define MAXBACKTRACE 128 /* against infinite loop */
+__CTASSERT(VM_MIN_ADDRESS == 0);
#define IN_USER_VM_ADDRESS(addr) \
- ((VM_MIN_ADDRESS <= (addr)) && ((addr) < VM_MAX_ADDRESS))
+ ((addr) < VM_MAX_ADDRESS)
#define IN_KERNEL_VM_ADDRESS(addr) \
((VM_MIN_KERNEL_ADDRESS <= (addr)) && ((addr) < VM_MAX_KERNEL_ADDRESS))
@@ -74,6 +75,7 @@
static const char *
getlwpnamebysp(uint64_t sp)
{
+#if defined(_KERNEL)
lwp_t *lwp;
for (lwp = db_lwp_first(); lwp != NULL; lwp = db_lwp_next(lwp)) {
@@ -82,6 +84,7 @@
return lwp->l_name;
}
}
+#endif
return "unknown";
}
@@ -157,6 +160,7 @@
}
}
+#if defined(_KERNEL)
if (!have_addr) {
if (trace_lwp) {
addr = (db_expr_t)curlwp;
@@ -166,6 +170,7 @@
tf = DDB_REGS;
}
}
+#endif
if (trace_thread) {
proc_t *pp, p;
@@ -193,12 +198,15 @@
db_read_bytes(addr, sizeof(l), (char *)&l);
db_read_bytes((db_addr_t)l.l_proc, sizeof(p), (char *)&p);
- if (addr == (db_addr_t)curlwp) {
+#if defined(_KERNEL)
+ if (addr == (db_expr_t)curlwp) {
fp = (uint64_t)&DDB_REGS->tf_reg[29]; /* ®[29]={fp,lr} */
tf = DDB_REGS;
(*pr)("trace: pid %d lid %d (curlwp) at tf %p\n",
p.p_pid, l.l_lid, tf);
- } else {
+ } else
+#endif
+ {
tf = l.l_md.md_ktf;
db_read_bytes((db_addr_t)&tf->tf_reg[29], sizeof(fp), (char *)&fp);
(*pr)("trace: pid %d lid %d at tf %p\n",
@@ -215,12 +223,14 @@
count = MAXBACKTRACE;
if (tf != NULL) {
+#if defined(_KERNEL)
(*pr)("---- trapframe %p (%zu bytes) ----\n",
tf, sizeof(*tf));
dump_trapframe(tf, pr);
(*pr)("------------------------"
"------------------------\n");
+#endif
lastfp = lastlr = lr = fp = 0;
db_read_bytes((db_addr_t)&tf->tf_pc, sizeof(lr), (char *)&lr);
db_read_bytes((db_addr_t)&tf->tf_reg[29], sizeof(fp), (char *)&fp);
@@ -243,6 +253,7 @@
if (!trace_user && IN_USER_VM_ADDRESS(lr))
break;
+#if defined(_KERNEL)
extern char el1_trap[]; /* XXX */
extern char el0_trap[]; /* XXX */
if (((char *)(lr - 4) == (char *)el0_trap) ||
@@ -281,7 +292,9 @@
pr_traceaddr("fp", fp, lr, flags, pr);
- } else {
+ } else
+#endif
+ {
pr_traceaddr("fp", fp, lr - 4, flags, pr);
}
}
diff -r e4c3dbf929a4 -r 9344872ebe96 sys/arch/aarch64/aarch64/disasm.c
--- a/sys/arch/aarch64/aarch64/disasm.c Sat Sep 15 19:16:58 2018 +0000
+++ b/sys/arch/aarch64/aarch64/disasm.c Sat Sep 15 19:47:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disasm.c,v 1.4 2018/07/28 09:54:32 ryo Exp $ */
+/* $NetBSD: disasm.c,v 1.5 2018/09/15 19:47:48 jakllsch Exp $ */
/*
* Copyright (c) 2018 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disasm.c,v 1.4 2018/07/28 09:54:32 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disasm.c,v 1.5 2018/09/15 19:47:48 jakllsch Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -35,6 +35,10 @@
#include <arch/aarch64/aarch64/disasm.h>
+#ifndef _KERNEL
+#include <stdio.h>
+#include <stdbool.h>
+#endif
#define PRINTF di->di_printf
#define PRINTADDR di->di_printaddr
diff -r e4c3dbf929a4 -r 9344872ebe96 sys/arch/aarch64/include/db_machdep.h
--- a/sys/arch/aarch64/include/db_machdep.h Sat Sep 15 19:16:58 2018 +0000
+++ b/sys/arch/aarch64/include/db_machdep.h Sat Sep 15 19:47:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.6 2018/07/17 10:07:49 ryo Exp $ */
+/* $NetBSD: db_machdep.h,v 1.7 2018/09/15 19:47:48 jakllsch Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -68,6 +68,7 @@
#include <sys/types.h>
#include <aarch64/frame.h>
+#include <ddb/db_user.h>
typedef long long int db_expr_t;
#define DDB_EXPR_FMT "ll"
@@ -214,6 +215,7 @@
#define WATCHPOINT_ACCESS_LOADSTORE 0x03
#define WATCHPOINT_ACCESS_MASK 0x03
+#define DB_ELF_SYMBOLS
#elif defined(__arm__)
diff -r e4c3dbf929a4 -r 9344872ebe96 sys/arch/aarch64/include/machdep.h
--- a/sys/arch/aarch64/include/machdep.h Sat Sep 15 19:16:58 2018 +0000
+++ b/sys/arch/aarch64/include/machdep.h Sat Sep 15 19:47:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.h,v 1.4 2018/08/05 06:48:50 skrll Exp $ */
+/* $NetBSD: machdep.h,v 1.5 2018/09/15 19:47:48 jakllsch Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -36,6 +36,7 @@
// initarm_common
#include <machine/bootconfig.h>
+struct boot_physmem;
static inline paddr_t
aarch64_kern_vtophys(vaddr_t va)
@@ -108,6 +109,7 @@
int cpu_set_onfault(struct faultbuf *) __returns_twice;
void cpu_jump_onfault(struct trapframe *, const struct faultbuf *, int);
+#if defined(_KERNEL)
static inline void
cpu_unset_onfault(void)
{
@@ -128,6 +130,7 @@
curlwp->l_md.md_onfault = NULL;
return fb;
}
+#endif
/* fpu.c */
void fpu_attach(struct cpu_info *);
diff -r e4c3dbf929a4 -r 9344872ebe96 sys/arch/aarch64/include/pmap.h
--- a/sys/arch/aarch64/include/pmap.h Sat Sep 15 19:16:58 2018 +0000
+++ b/sys/arch/aarch64/include/pmap.h Sat Sep 15 19:47:48 2018 +0000
Home |
Main Index |
Thread Index |
Old Index