aboutsummaryrefslogtreecommitdiff
path: root/sys/x86/linux
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2022-05-23 10:16:26 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2022-05-23 10:16:26 +0000
commit2434137f690dabc35586ab45fc4c4ecc5b71184f (patch)
treed2a2fae16897aa4e5fa923427a643eee1eabfca0 /sys/x86/linux
parentb387a075d9db81a7bcc3adcc7c1c5ba93e8d8f66 (diff)
Diffstat (limited to 'sys/x86/linux')
-rw-r--r--sys/x86/linux/linux_x86.c56
-rw-r--r--sys/x86/linux/linux_x86.h2
2 files changed, 58 insertions, 0 deletions
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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/signal.h>
+#include <x86/trap.h>
+
+#include <x86/linux/linux_x86.h>
+
+/*
+ * 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_ */