From nobody Mon May 23 10:20:12 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 ACD281B39416; Mon, 23 May 2022 10:20:12 +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 4L6Cy44NT8z3FPj; Mon, 23 May 2022 10:20:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653301212; 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=n0S+iwA1WwRFeXmrUuHx081ihYpCnNaXYJK8gnJOw+o=; b=G11hoBGxD8G58ebPT4HVe3OmJZhODFx56NPLuC18/o0T+lkTwuplp+AkZPNAhg/z7/SaiW ZeXPuOGS/zJ1TwwkCaoTQtJ2fTnO44LljqjPn0e3AQOvwjGRXMkJeAgIi0YqSDCxKgykTY 9NqQ7YCv+HX1ViYHqhNi3yB4PdTgb4bkvq/fLL+ZUnoV6JRAWzv3yJuGKpg6o+QH2Druk9 SZiCvGLjO5oLSs3fLlLNpVY9Jar/sQgs1NTmnPLlYg9wxEd/FX5JXlVHq38FPkAQywoq71 0sfCHX5Zf1ckluLNa8HGTnRMo82IsAyLRwxoQjSn5ph46ervcqzyNgAoqb5V8w== 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 76FD15FE2; Mon, 23 May 2022 10:20:12 +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 24NAKCBk028064; Mon, 23 May 2022 10:20:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24NAKC8I028058; Mon, 23 May 2022 10:20:12 GMT (envelope-from git) Date: Mon, 23 May 2022 10:20:12 GMT Message-Id: <202205231020.24NAKC8I028058@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: 2434137f690d - main - linux(4): Deduplicate translate_traps() 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: 2434137f690dabc35586ab45fc4c4ecc5b71184f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653301212; 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=n0S+iwA1WwRFeXmrUuHx081ihYpCnNaXYJK8gnJOw+o=; b=HnPXrU2jCxImMlTQRKcd+FKTwiIYbqY3bzgpC2vtTiyW6mXBIjtfapR3cyUcM6EvzKCjQp rPZxbTZVCuFMXLN0/OA1gGGXaNZ8QhdDwoFP5WV6Wohcb8U+Fje4XrLuR71oO6XA1/28po 6BgpntnS9lY8sO4f0M1ST0eRT1i9p9Cr+WwNV69DcggjFjdr3ve16D9GTl52164ch7YsDM dsNhCdsOFlQntolKNpAw4FFQsMRs5MrGYBv5FyGPSOhfO9EJH78ayEq927CibqgK3tVDtV 3NaUw6g6gxayGF6zlGLd+tgXX/gvRe20lqVRpGRTCyP+/Pbdfdp9CS6oJIX8+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653301212; a=rsa-sha256; cv=none; b=UBCAXPbcaCJAQ9x9mIL9+HQrKXbW9Uz9jnj0C8UNS3Xz+BOLPvJpZ3JiXlzJKBTv81NHbE NQKcVHADHwC49bqkrDwoTPJOHwJKuBWv7QKoxWIFR+umrrKJXGYEeGcNnb3/VQo2K4NIOt piDn172EE7ToIwHDckUIa4pX5YpzFiJqtmWai1jA+5H8nFYxWw5eCiIc1Dfx1yM+wopjhA B9+lqN609QE3oMcE61LdnX9v5x2n0mDmUsqtMB4cUOPLgHkibEHkutD/fSTVcd4xF0Y4Xh BRUb9NOoawNa8mSWIAqQgI0T1L+ysB0UecWg46mcIsPsOshj6kAiaWrSCVS9kA== 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=2434137f690dabc35586ab45fc4c4ecc5b71184f commit 2434137f690dabc35586ab45fc4c4ecc5b71184f Author: Dmitry Chagin AuthorDate: 2022-05-23 10:16:26 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-23 10:16:26 +0000 linux(4): Deduplicate translate_traps() As translate_traps() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks --- sys/amd64/linux/linux_sysvec.c | 23 ---------------- sys/amd64/linux32/linux32_sysvec.c | 22 --------------- sys/i386/linux/linux_sysvec.c | 22 --------------- sys/modules/linux/Makefile | 3 +- sys/modules/linux_common/Makefile | 6 +++- sys/x86/linux/linux_x86.c | 56 ++++++++++++++++++++++++++++++++++++++ sys/x86/linux/linux_x86.h | 2 ++ 7 files changed, 65 insertions(+), 69 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index fbdd40433198..4592c2c26e12 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -176,29 +176,6 @@ LINUX_VDSO_SYM_INTPTR(kern_timekeep_base); LINUX_VDSO_SYM_INTPTR(kern_tsc_selector); LINUX_VDSO_SYM_INTPTR(kern_cpu_selector); -/* - * If FreeBSD & Linux have a difference of opinion about what a trap - * means, deal with it here. - * - * MPSAFE - */ -static int -linux_translate_traps(int signal, int trap_code) -{ - - if (signal != SIGBUS) - return (signal); - switch (trap_code) { - case T_PROTFLT: - case T_TSSFLT: - case T_DOUBLEFLT: - case T_PAGEFLT: - return (SIGSEGV); - default: - return (signal); - } -} - static int linux_fetch_syscall_args(struct thread *td) { diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 991047571e7d..ff6b1f882bc9 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -190,28 +190,6 @@ LINUX_VDSO_SYM_INTPTR(kern_tsc_selector); LINUX_VDSO_SYM_INTPTR(kern_cpu_selector); LINUX_VDSO_SYM_CHAR(linux_platform); -/* - * If FreeBSD & Linux have a difference of opinion about what a trap - * means, deal with it here. - * - * MPSAFE - */ -static int -linux_translate_traps(int signal, int trap_code) -{ - if (signal != SIGBUS) - return (signal); - switch (trap_code) { - case T_PROTFLT: - case T_TSSFLT: - case T_DOUBLEFLT: - case T_PAGEFLT: - return (SIGSEGV); - default: - return (signal); - } -} - static int linux_copyout_auxargs(struct image_params *imgp, uintptr_t base) { diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 2fd259aca1e5..f4c14abe6996 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -164,28 +164,6 @@ LINUX_VDSO_SYM_INTPTR(kern_timekeep_base); LINUX_VDSO_SYM_INTPTR(kern_tsc_selector); LINUX_VDSO_SYM_INTPTR(kern_cpu_selector); -/* - * If FreeBSD & Linux have a difference of opinion about what a trap - * means, deal with it here. - * - * MPSAFE - */ -static int -linux_translate_traps(int signal, int trap_code) -{ - if (signal != SIGBUS) - return (signal); - switch (trap_code) { - case T_PROTFLT: - case T_TSSFLT: - case T_DOUBLEFLT: - case T_PAGEFLT: - return (SIGSEGV); - default: - return (signal); - } -} - static int linux_fixup(uintptr_t *stack_base, struct image_params *imgp) { diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile index b94605853743..be6231f767f1 100644 --- a/sys/modules/linux/Makefile +++ b/sys/modules/linux/Makefile @@ -41,7 +41,8 @@ OBJS= linux${SFX}_vdso.so .if ${MACHINE_CPUARCH} == "i386" SRCS+= linux_ptrace_machdep.c imgact_linux.c linux_util.c linux_mib.c \ - linux_mmap.c linux_dummy.c linux_emul.c linux_errno.c opt_cpu.h linux.c + linux_mmap.c linux_dummy.c linux_emul.c linux_errno.c opt_cpu.h linux.c \ + linux_x86.c .endif .if ${MACHINE_CPUARCH} == "i386" diff --git a/sys/modules/linux_common/Makefile b/sys/modules/linux_common/Makefile index 1815714e9202..033fabe27188 100644 --- a/sys/modules/linux_common/Makefile +++ b/sys/modules/linux_common/Makefile @@ -1,12 +1,16 @@ # $FreeBSD$ -.PATH: ${SRCTOP}/sys/compat/linux +.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/x86/linux KMOD= linux_common SRCS= linux_common.c linux_mib.c linux_mmap.c linux_util.c linux_emul.c \ linux_dummy.c linux_errno.c \ linux.c device_if.h vnode_if.h bus_if.h opt_inet6.h +.if ${MACHINE_CPUARCH} == "amd64" +SRCS+= linux_x86.c +.endif + EXPORT_SYMS= EXPORT_SYMS+= linux_emul_path EXPORT_SYMS+= linux_get_osname diff --git a/sys/x86/linux/linux_x86.c b/sys/x86/linux/linux_x86.c new file mode 100644 index 000000000000..160a721b1418 --- /dev/null +++ b/sys/x86/linux/linux_x86.c @@ -0,0 +1,56 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 1994-1996 Søren Schmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include + +/* + * If FreeBSD & Linux have a difference of opinion about what a trap + * means, deal with it here. + */ +int +linux_translate_traps(int signal, int trap_code) +{ + if (signal != SIGBUS) + return (signal); + switch (trap_code) { + case T_PROTFLT: + case T_TSSFLT: + case T_DOUBLEFLT: + case T_PAGEFLT: + return (SIGSEGV); + default: + return (signal); + } +} diff --git a/sys/x86/linux/linux_x86.h b/sys/x86/linux/linux_x86.h index 79e6e7fbfeec..a7eb871113ee 100644 --- a/sys/x86/linux/linux_x86.h +++ b/sys/x86/linux/linux_x86.h @@ -35,4 +35,6 @@ int linux_vdso_tsc_selector_idx(void); int linux_vdso_cpu_selector_idx(void); +int linux_translate_traps(int, int); + #endif /* _X86_INCLUDE_LINUX_LINUX_X86_H_ */