From owner-svn-src-head@FreeBSD.ORG Sun May 24 16:22:05 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2F45B9BF; Sun, 24 May 2015 16:22:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1005C137F; Sun, 24 May 2015 16:22:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4OGM4ch083581; Sun, 24 May 2015 16:22:04 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4OGM4RZ083577; Sun, 24 May 2015 16:22:04 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201505241622.t4OGM4RZ083577@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 24 May 2015 16:22:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283430 - head/usr.bin/kdump X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2015 16:22:05 -0000 Author: dchagin Date: Sun May 24 16:22:03 2015 New Revision: 283430 URL: https://svnweb.freebsd.org/changeset/base/283430 Log: Teach kdump to understand both linux emulation. Differential Revision: https://reviews.freebsd.org/D1079 Reviewed by: emaste Added: head/usr.bin/kdump/linux32_syscalls.conf (contents, props changed) Modified: head/usr.bin/kdump/Makefile head/usr.bin/kdump/kdump.c Modified: head/usr.bin/kdump/Makefile ============================================================================== --- head/usr.bin/kdump/Makefile Sun May 24 16:19:57 2015 (r283429) +++ head/usr.bin/kdump/Makefile Sun May 24 16:22:03 2015 (r283430) @@ -3,10 +3,6 @@ .include -.if (${MACHINE_ARCH} == "amd64") -SFX= 32 -.endif - .PATH: ${.CURDIR}/../ktrace PROG= kdump @@ -30,6 +26,9 @@ CLEANFILES= ioctl.c kdump_subr.c kdump_s .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}" \ @@ -43,7 +42,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 Modified: head/usr.bin/kdump/kdump.c ============================================================================== --- head/usr.bin/kdump/kdump.c Sun May 24 16:19:57 2015 (r283429) +++ head/usr.bin/kdump/kdump.c Sun May 24 16:22:03 2015 (r283430) @@ -146,13 +146,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 -static int nlinux_syscalls = sizeof(linux_syscallnames) / \ - sizeof(linux_syscallnames[0]); /* * from linux.h @@ -172,6 +170,12 @@ static int bsd_to_linux_errno[ELAST + 1] }; #endif +#if defined(__amd64__) +extern const char *linux32_syscallnames[]; + +#include +#endif + struct proc_info { TAILQ_ENTRY(proc_info) info; @@ -400,7 +404,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); @@ -408,7 +413,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); @@ -1970,16 +1976,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); } @@ -1994,16 +2012,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(" "); Added: head/usr.bin/kdump/linux32_syscalls.conf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/kdump/linux32_syscalls.conf Sun May 24 16:22:03 2015 (r283430) @@ -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"