path: root/sys/sys/signal.h
diff options
authorKonstantin Belousov <kib@FreeBSD.org>2019-09-27 18:43:36 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-09-27 18:43:36 +0000
commitdf08823d07104078a7e7148e27c16810626fa4ba (patch)
treec753daf02ac3bbf9f9c15b07aa80d01d1dc51d90 /sys/sys/signal.h
parent3801c66a97adceefb7c991d18f4facf3643de1bb (diff)
Improve MD page fault handlers.
Centralize calculation of signal and ucode delivered on unhandled page fault in new function vm_fault_trap(). MD trap_pfault() now almost always uses the signal numbers and error codes calculated in consistent MI way. This introduces the protection fault compatibility sysctls to all non-x86 architectures which did not have that bug, but apparently they were already much more wrong in selecting delivered signals on protection violations. Change the delivered signal for accesses to mapped area after the backing object was truncated. According to POSIX description for mmap(2): The system shall always zero-fill any partial page at the end of an object. Further, the system shall never write out any modified portions of the last page of an object which are beyond its end. References within the address range starting at pa and continuing for len bytes to whole pages following the end of an object shall result in delivery of a SIGBUS signal. An implementation may generate SIGBUS signals when a reference would cause an error in the mapped object, such as out-of-space condition. Adjust according to the description, keeping the existing compatibility code for SIGSEGV/SIGBUS on protection failures. For situations where kernel cannot handle page fault due to resource limit enforcement, SIGBUS with a new error code BUS_OBJERR is delivered. Also, provide a new error code SEGV_PKUERR for SIGSEGV on amd64 due to protection key access violation. vm_fault_hold() is renamed to vm_fault(). Fixed some nits in trap_pfault()s like mis-interpreting Mach errors as errnos. Removed unneeded truncations of the fault addresses reported by hardware. PR: 211924 Reviewed by: alc Discussed with: jilles, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21566
Notes: svn path=/head/; revision=352807
Diffstat (limited to 'sys/sys/signal.h')
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/sys/signal.h b/sys/sys/signal.h
index 0c9b198855c6..8b45a521c3ee 100644
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -315,11 +315,13 @@ struct siginfo32 {
#define BUS_ADRALN 1 /* Invalid address alignment. */
#define BUS_ADRERR 2 /* Nonexistent physical address. */
#define BUS_OBJERR 3 /* Object-specific hardware error. */
+#define BUS_OOMERR 100 /* Non-standard: No memory. */
/* codes for SIGSEGV */
#define SEGV_MAPERR 1 /* Address not mapped to object. */
#define SEGV_ACCERR 2 /* Invalid permissions for mapped */
/* object. */
+#define SEGV_PKUERR 100 /* x86: PKU violation */
/* codes for SIGFPE */
#define FPE_INTOVF 1 /* Integer overflow. */