From nobody Mon May 23 10:20:13 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CAE531B39420; Mon, 23 May 2022 10:20:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L6Cy55BqZz3Ff8; Mon, 23 May 2022 10:20:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653301213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iYS2pAndhS5GSo/NDkFCkLQvcHtk8YMLGCH8FqussRA=; b=xhqcTtiJSd2mpTJl9YRFSRQCARMQJ1aTk0pagymzrSY87zzJP4Mt8bV0ORBMfni4I5mNHY XxSQeLhCK+vcgFFEmZnuwty0fyTP648FsC1k2EW2u7jUsU/JKax9KJ/ILrASKdAa+6N/X7 h8jh76AfbgN6BgZEZE0L23/veL279WWNAPwmXUEDzbMZmsthetpGx3UZZWeci8BFUKpu3p 08oArwKHuftf5d4mW6opQ32JhYbA5trM+4eRsba5H3QcKUhuDag36KQWxfF7L7thu/H3Ij CgIs0fFfO2d+av215l+0NqOinH8eFIQylDk9W2ylHdCtj2UUqIfYTsnqr+K+wg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F9F86005; Mon, 23 May 2022 10:20:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24NAKD56028576; Mon, 23 May 2022 10:20:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24NAKDCW028569; Mon, 23 May 2022 10:20:13 GMT (envelope-from git) Date: Mon, 23 May 2022 10:20:13 GMT Message-Id: <202205231020.24NAKDCW028569@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 9016ec056ae3 - main - linux(4): Deduplicate bsd_to_linux_trapcode() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9016ec056ae3896522798ead39bb2f3ff4f68809 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653301213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iYS2pAndhS5GSo/NDkFCkLQvcHtk8YMLGCH8FqussRA=; b=vY+4GJ+h0ZegKN+wXm5cyTuGUuXYl3jMrEbHgqJ/XZf8jMc5qfDCWYrgzjO78xXfi3oSxV H9GZl1IPZ+Cx7+XTgAniEHByRf0aEoxCxnrBu4oREEpuQJ2SGJqvP0q/e09pgHTtw6Q/XS jON4LfmBB4UHk9uD3NcjkZ8NHCbIdkS7T7veijJPNys0Fd7THmEBsHiggeg+nut5Hkg1SC l0AT2+hxl+3IY2ZtMOuP6Cy+ZwUXyAeDjG7PvfFnH1x6KCfXNE3jwrQ8C9T/kqy5dKH2kL HyZ0s3/x8yqPuUgtMPEGF5M/bb1l5H4f/khaCjIBt/gVFjOe6ApKrjs0nsNAMw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653301213; a=rsa-sha256; cv=none; b=WC+65cOarG7ICTwRPeZgKDREyeGxbyk245QDB5+JKzOFlfvTsc89kL4ziEYz1mS4aytkJ5 cO81xruKM4PupnSGeX+oxwbl+4lOKmiuKF0Ep+3/bPwhlhxl+oTRGrhS1mrtMEZJaN13E+ Ca/+fTM2Sh/7abXizrk0jK2xDg8uffL/rWHMz9aV5SHc7p0XtsfaQ5r6W4BxUM+jIKKdeU 3rtsxejqCs4HxH46QQPaSW/QEx15BgoYLwza6kPv76baczTG8MmtTJ6OY9OWL0RICJtIOS Ke+XvPYmergL37R9qX1Bj4acg1lor1iOEsBdOTU440Cc7IbQYCxzAssDlf+VQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=9016ec056ae3896522798ead39bb2f3ff4f68809 commit 9016ec056ae3896522798ead39bb2f3ff4f68809 Author: Dmitry Chagin AuthorDate: 2022-05-23 10:16:58 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-23 10:16:58 +0000 linux(4): Deduplicate bsd_to_linux_trapcode() As bsd_to_linux_trapcode() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks --- sys/amd64/linux/linux_sysvec.c | 39 ---------------------------------- sys/amd64/linux32/linux32_sysvec.c | 39 ---------------------------------- sys/i386/linux/linux_sysvec.c | 39 ---------------------------------- sys/x86/linux/linux_x86.c | 43 ++++++++++++++++++++++++++++++++++++++ sys/x86/linux/linux_x86.h | 1 + 5 files changed, 44 insertions(+), 117 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 4592c2c26e12..acfc4d6831f3 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -131,45 +131,6 @@ static int linux_on_exec_vmspace(struct proc *p, static void linux_set_fork_retval(struct thread *td); static int linux_vsyscall(struct thread *td); -#define LINUX_T_UNKNOWN 255 -static int _bsd_to_linux_trapcode[] = { - LINUX_T_UNKNOWN, /* 0 */ - 6, /* 1 T_PRIVINFLT */ - LINUX_T_UNKNOWN, /* 2 */ - 3, /* 3 T_BPTFLT */ - LINUX_T_UNKNOWN, /* 4 */ - LINUX_T_UNKNOWN, /* 5 */ - 16, /* 6 T_ARITHTRAP */ - 254, /* 7 T_ASTFLT */ - LINUX_T_UNKNOWN, /* 8 */ - 13, /* 9 T_PROTFLT */ - 1, /* 10 T_TRCTRAP */ - LINUX_T_UNKNOWN, /* 11 */ - 14, /* 12 T_PAGEFLT */ - LINUX_T_UNKNOWN, /* 13 */ - 17, /* 14 T_ALIGNFLT */ - LINUX_T_UNKNOWN, /* 15 */ - LINUX_T_UNKNOWN, /* 16 */ - LINUX_T_UNKNOWN, /* 17 */ - 0, /* 18 T_DIVIDE */ - 2, /* 19 T_NMI */ - 4, /* 20 T_OFLOW */ - 5, /* 21 T_BOUND */ - 7, /* 22 T_DNA */ - 8, /* 23 T_DOUBLEFLT */ - 9, /* 24 T_FPOPFLT */ - 10, /* 25 T_TSSFLT */ - 11, /* 26 T_SEGNPFLT */ - 12, /* 27 T_STKFLT */ - 18, /* 28 T_MCHK */ - 19, /* 29 T_XMMFLT */ - 15 /* 30 T_RESERVED */ -}; -#define bsd_to_linux_trapcode(code) \ - ((code) +#define LINUX_T_UNKNOWN 255 +static int _bsd_to_linux_trapcode[] = { + LINUX_T_UNKNOWN, /* 0 */ + 6, /* 1 T_PRIVINFLT */ + LINUX_T_UNKNOWN, /* 2 */ + 3, /* 3 T_BPTFLT */ + LINUX_T_UNKNOWN, /* 4 */ + LINUX_T_UNKNOWN, /* 5 */ + 16, /* 6 T_ARITHTRAP */ + 254, /* 7 T_ASTFLT */ + LINUX_T_UNKNOWN, /* 8 */ + 13, /* 9 T_PROTFLT */ + 1, /* 10 T_TRCTRAP */ + LINUX_T_UNKNOWN, /* 11 */ + 14, /* 12 T_PAGEFLT */ + LINUX_T_UNKNOWN, /* 13 */ + 17, /* 14 T_ALIGNFLT */ + LINUX_T_UNKNOWN, /* 15 */ + LINUX_T_UNKNOWN, /* 16 */ + LINUX_T_UNKNOWN, /* 17 */ + 0, /* 18 T_DIVIDE */ + 2, /* 19 T_NMI */ + 4, /* 20 T_OFLOW */ + 5, /* 21 T_BOUND */ + 7, /* 22 T_DNA */ + 8, /* 23 T_DOUBLEFLT */ + 9, /* 24 T_FPOPFLT */ + 10, /* 25 T_TSSFLT */ + 11, /* 26 T_SEGNPFLT */ + 12, /* 27 T_STKFLT */ + 18, /* 28 T_MCHK */ + 19, /* 29 T_XMMFLT */ + 15 /* 30 T_RESERVED */ +}; + /* * If FreeBSD & Linux have a difference of opinion about what a trap * means, deal with it here. @@ -54,3 +89,11 @@ linux_translate_traps(int signal, int trap_code) return (signal); } } + +int +bsd_to_linux_trapcode(int code) +{ + + return (code < nitems(_bsd_to_linux_trapcode) ? + _bsd_to_linux_trapcode[code] : LINUX_T_UNKNOWN); +} \ No newline at end of file diff --git a/sys/x86/linux/linux_x86.h b/sys/x86/linux/linux_x86.h index a7eb871113ee..ce083bb1c3f5 100644 --- a/sys/x86/linux/linux_x86.h +++ b/sys/x86/linux/linux_x86.h @@ -36,5 +36,6 @@ int linux_vdso_tsc_selector_idx(void); int linux_vdso_cpu_selector_idx(void); int linux_translate_traps(int, int); +int bsd_to_linux_trapcode(int); #endif /* _X86_INCLUDE_LINUX_LINUX_X86_H_ */