aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2007-12-04 12:33:03 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2007-12-04 12:33:03 +0000
commitd24031dd0cd7426670045968bda8cc501303cd0f (patch)
treeaea956d1d43fb99bb7f3a157f35c56a65ec5cc87 /sys/amd64
parentf231de478ebb97e0d19fe8c0f95bcd7ac78492bc (diff)
Notes
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/trap.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 2ce8ed48d350..7e95cbc5728c 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -144,6 +144,9 @@ SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW,
static int panic_on_nmi = 1;
SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW,
&panic_on_nmi, 0, "Panic on NMI");
+static int prot_fault_translation = 0;
+SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW,
+ &prot_fault_translation, 0, "Select signal to deliver on protection fault");
extern char *syscallnames[];
@@ -312,8 +315,32 @@ trap(struct trapframe *frame)
if (i == SIGSEGV)
ucode = SEGV_MAPERR;
else {
- i = SIGSEGV; /* XXX hack */
- ucode = SEGV_ACCERR;
+ if (prot_fault_translation == 0) {
+ /*
+ * Autodetect.
+ * This check also covers the images
+ * without the ABI-tag ELF note.
+ */
+ if (p->p_osrel >= 700004) {
+ i = SIGSEGV;
+ ucode = SEGV_ACCERR;
+ } else {
+ i = SIGBUS;
+ ucode = BUS_PAGE_FAULT;
+ }
+ } else if (prot_fault_translation == 1) {
+ /*
+ * Always compat mode.
+ */
+ i = SIGBUS;
+ ucode = BUS_PAGE_FAULT;
+ } else {
+ /*
+ * Always SIGSEGV mode.
+ */
+ i = SIGSEGV;
+ ucode = SEGV_ACCERR;
+ }
}
break;