From nobody Fri Jun 17 19:40:56 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 54E4B85D60A; Fri, 17 Jun 2022 19:40:58 +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 4LPqCY1wvsz3hdV; Fri, 17 Jun 2022 19:40:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494857; 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=lWaKdEJz2BP3PM5MLRYvmxmnsKNQpgl5kKIb3VyPL6g=; b=IH+l6TOV04FJTmXI6OfScJ7kQvtxTr6gzCZPmtAiT0crB9jT1d5jgE0e0Ilb3D/yAAvZa7 QJGso/RWQjtY1QQuSJ5X7ZnpjkP9CXrN5xLEOwECTG/dvVF3QnBEuy8kN7wywfUBJ4CQey b79B1coGXLqYgYyQ2s4hOcxj9LQGE0YUXwHl9TJ9sh/9KIWz4Ri7XD6Z6embNhCwPTQDqU ZkBt3Fa2ns4Zqb5Rdoq5nPACB07Kv7MWNdVLRQ7BO8+pBJ3Nw1FJre53PCaHzL9LZp+rm8 e4LqG7wz0PeNygHxqv5Dc+deFt69aovCIQ9HGoRVrkHyDw6V3itNVOPN4bae8g== 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 5074C259D7; Fri, 17 Jun 2022 19:40:56 +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 25HJeua6027449; Fri, 17 Jun 2022 19:40:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJeuJU027434; Fri, 17 Jun 2022 19:40:56 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:40:56 GMT Message-Id: <202206171940.25HJeuJU027434@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: f327f595cb98 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: f327f595cb9863f632169a6969e5fe0dbc69d530 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494857; 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=lWaKdEJz2BP3PM5MLRYvmxmnsKNQpgl5kKIb3VyPL6g=; b=W2nmL06t97cEF0+yjYNrD6EiyMMJcPGd7vRwkNmbbV9s0NOMVsYfdvpAxC9WT/+ycc+Z3u RmjDWZLmwF0YLx22zRSFQhAZOMW6sifEv960nv5g6/rNMqKOMNieBqZKoSpmBTlkDWugdX SLJz0R3mNowB0TuUZif1JRQeKDay6oce7x7Tp3uRgeTR51CUZmlzz8E5eGv/FmjyK1G1EA +Ul3vx777VYNGFS/yJttbB2JfjEEsWjVDFEfy74eg2Ya67QRXwLeHkxyJ+D/6ST0s8++xG N30X7GfU283mTIneP3tQ4kEQqrPSJgax5PE+IEHI7GWJrIDuxNVMxBNyBmT+sw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494857; a=rsa-sha256; cv=none; b=uCe36ZtgXczxlphlw4GttAkZYSkVyaMKv+5YkxdbB0LwjTSHyy9ntOMzAwWTpfIyz+Oc4g Mg3IAi4k4hMOk7WdkZoHHZpaDJhlB0HGZswgzpF1wwhCbnT91T82zpOcWWm3N8XA32bKM3 9acbDNk/+zBw3cQydwA54hRjANQTM9UOvO9Kmgjeq0ar/7IY9FfC9fKIDOtN8fuEVo9eDg 8vtBByo+/BvsBbm50a+jj25ioUJzY3nESIzdLXTE7qACQnoi6lYAlLyVFp5RQl/yQdEs0P APDOXWgD5Sw0MQyY9aYFwnU07KS/NF1PAho1giX4Do6jvtp1+gkXagQylUWtNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f327f595cb9863f632169a6969e5fe0dbc69d530 commit f327f595cb9863f632169a6969e5fe0dbc69d530 Author: Dmitry Chagin AuthorDate: 2022-05-23 10:16:26 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:35:28 +0000 linux(4): Deduplicate translate_traps() As translate_traps() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks (cherry picked from commit 2434137f690dabc35586ab45fc4c4ecc5b71184f) --- 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 af3688b9ab74..96df6b25cf12 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 715be5c36647..a01c7271c122 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 3c0dc4ac62cf..9b99a5dfbed0 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_ */