summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2016-01-16 07:46:25 +0000
committerdchagin <dchagin@FreeBSD.org>2016-01-16 07:46:25 +0000
commitfaf7d1b1b8f0ca18354d8d3cf1ac6d387581008e (patch)
tree72f83898fe406fb6842c865be0151e58b277bfd6 /usr.bin
parentf7e7eb71bece1f4b40dd4f81ec39a639522a5793 (diff)
downloadFreeBSD-src-faf7d1b1b8f0ca18354d8d3cf1ac6d387581008e.zip
FreeBSD-src-faf7d1b1b8f0ca18354d8d3cf1ac6d387581008e.tar.gz
MFC r283430:
Teach kdump to understand both linux emulation.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/kdump/Makefile13
-rw-r--r--usr.bin/kdump/kdump.c46
-rw-r--r--usr.bin/kdump/linux32_syscalls.conf11
3 files changed, 51 insertions, 19 deletions
diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
index d450da5..378c416 100644
--- a/usr.bin/kdump/Makefile
+++ b/usr.bin/kdump/Makefile
@@ -3,10 +3,6 @@
.include <bsd.own.mk>
-.if (${MACHINE_ARCH} == "amd64")
-SFX= 32
-.endif
-
.PATH: ${.CURDIR}/../ktrace
PROG= kdump
@@ -24,6 +20,9 @@ CLEANFILES= ioctl.c kdump_subr.c kdump_subr.h
.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386")
CLEANFILES+= linux_syscalls.c
.endif
+.if (${MACHINE_ARCH} == "amd64")
+CLEANFILES+= linux32_syscalls.c
+.endif
ioctl.c: mkioctls
env MACHINE=${MACHINE} CPP="${CPP}" \
@@ -37,7 +36,11 @@ kdump_subr.c: mksubr kdump_subr.h
sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include >${.TARGET}
.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386")
sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
- ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf
+ ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux/syscalls.master ${.CURDIR}/linux_syscalls.conf
+.endif
+.if (${MACHINE_ARCH} == "amd64")
+ sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
+ ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux32/syscalls.master ${.CURDIR}/linux32_syscalls.conf
.endif
.include <bsd.prog.mk>
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index bd0e000..f028e51 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -139,13 +139,11 @@ static struct ktr_header ktr_header;
#if defined(__amd64__) || defined(__i386__)
-void linux_ktrsyscall(struct ktr_syscall *);
-void linux_ktrsysret(struct ktr_sysret *);
+void linux_ktrsyscall(struct ktr_syscall *, u_int);
+void linux_ktrsysret(struct ktr_sysret *, u_int);
extern const char *linux_syscallnames[];
#include <linux_syscalls.c>
-static int nlinux_syscalls = sizeof(linux_syscallnames) / \
- sizeof(linux_syscallnames[0]);
/*
* from linux.h
@@ -165,6 +163,12 @@ static int bsd_to_linux_errno[ELAST + 1] = {
};
#endif
+#if defined(__amd64__)
+extern const char *linux32_syscallnames[];
+
+#include <linux32_syscalls.c>
+#endif
+
struct proc_info
{
TAILQ_ENTRY(proc_info) info;
@@ -331,7 +335,8 @@ main(int argc, char *argv[])
case KTR_SYSCALL:
#if defined(__amd64__) || defined(__i386__)
if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX)
- linux_ktrsyscall((struct ktr_syscall *)m);
+ linux_ktrsyscall((struct ktr_syscall *)m,
+ sv_flags);
else
#endif
ktrsyscall((struct ktr_syscall *)m, sv_flags);
@@ -339,7 +344,8 @@ main(int argc, char *argv[])
case KTR_SYSRET:
#if defined(__amd64__) || defined(__i386__)
if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX)
- linux_ktrsysret((struct ktr_sysret *)m);
+ linux_ktrsysret((struct ktr_sysret *)m,
+ sv_flags);
else
#endif
ktrsysret((struct ktr_sysret *)m, sv_flags);
@@ -1891,16 +1897,28 @@ ktrfaultend(struct ktr_faultend *ktr)
}
#if defined(__amd64__) || defined(__i386__)
+
+#if defined(__amd64__)
+#define NLINUX_SYSCALLS(v) ((v) & SV_ILP32 ? \
+ nitems(linux32_syscallnames) : nitems(linux_syscallnames))
+#define LINUX_SYSCALLNAMES(v, i) ((v) & SV_ILP32 ? \
+ linux32_syscallnames[i] : linux_syscallnames[i])
+#else
+#define NLINUX_SYSCALLS(v) (nitems(linux_syscallnames))
+#define LINUX_SYSCALLNAMES(v, i) (linux_syscallnames[i])
+#endif
+
void
-linux_ktrsyscall(struct ktr_syscall *ktr)
+linux_ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags)
{
int narg = ktr->ktr_narg;
+ unsigned code = ktr->ktr_code;
register_t *ip;
- if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0)
+ if (ktr->ktr_code < 0 || code >= NLINUX_SYSCALLS(sv_flags))
printf("[%d]", ktr->ktr_code);
else {
- printf("%s", linux_syscallnames[ktr->ktr_code]);
+ printf("%s", LINUX_SYSCALLNAMES(sv_flags, ktr->ktr_code));
if (syscallno)
printf("[%d]", ktr->ktr_code);
}
@@ -1915,16 +1933,16 @@ linux_ktrsyscall(struct ktr_syscall *ktr)
}
void
-linux_ktrsysret(struct ktr_sysret *ktr)
+linux_ktrsysret(struct ktr_sysret *ktr, u_int sv_flags)
{
register_t ret = ktr->ktr_retval;
+ unsigned code = ktr->ktr_code;
int error = ktr->ktr_error;
- int code = ktr->ktr_code;
- if (code >= nlinux_syscalls || code < 0)
- printf("[%d] ", code);
+ if (ktr->ktr_code < 0 || code >= NLINUX_SYSCALLS(sv_flags))
+ printf("[%d] ", ktr->ktr_code);
else {
- printf("%s", linux_syscallnames[code]);
+ printf("%s ", LINUX_SYSCALLNAMES(sv_flags, code));
if (syscallno)
printf("[%d]", code);
printf(" ");
diff --git a/usr.bin/kdump/linux32_syscalls.conf b/usr.bin/kdump/linux32_syscalls.conf
new file mode 100644
index 0000000..66a67fd
--- /dev/null
+++ b/usr.bin/kdump/linux32_syscalls.conf
@@ -0,0 +1,11 @@
+# $FreeBSD$
+sysnames="linux32_syscalls.c"
+sysproto="/dev/null"
+sysproto_h=_LINUX32_SYSPROTO_H_
+syshdr="/dev/null"
+syssw="/dev/null"
+sysmk="/dev/null"
+syscallprefix="LINUX32_SYS_"
+switchname="/dev/null"
+namesname="linux32_syscallnames"
+systrace="/dev/null"
OpenPOWER on IntegriCloud