usermem: add MISALIGNED
authorAlan Cox <alan@linux.intel.com>
Thu, 11 Feb 2016 20:00:26 +0000 (20:00 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 11 Feb 2016 20:00:26 +0000 (20:00 +0000)
Word sized misaligned user space memory accesses can now be faulted if
desired by the platform

Kernel/usermem.c

index 5051ffe..baadab0 100644 (file)
@@ -45,6 +45,12 @@ uint16_t ugetw(const void *user)
 {
        if (!valaddr(user, 2))
                return -1;
+#ifdef MISALIGNED
+       if (MISALIGNED(user, 2)) }
+               ssig(udata.u_proc, SIGBUS);
+               return -1;
+       }
+#endif
        return _ugetw(user);
 }
 
@@ -82,6 +88,12 @@ int uputw(uint16_t value, void *user)
 {
        if (!valaddr(user, 2))
                return -1;
+#ifdef MISALIGNED
+       if (MISALIGNED(user, 2)) }
+               ssig(udata.u_proc, SIGBUS);
+               return -1;
+       }
+#endif
        return _uputw(value,user);
 }