diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-09-26 23:23:47 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-09-27 10:47:18 +0100 |
commit | 6ac1ac98c28d38b539f465c5ac488d879f1c2ab6 (patch) | |
tree | 449febdd0d44dc5fffa425e8ba65ee6bad3e610b /src/sna/sna.h | |
parent | 7025956558cfc391b553c9adb39d2a38fe494946 (diff) |
sna: Catch SIGBUS to prevent X death
We know that when we access either a CPU or GTT mmap we are vulernable
to receiving a SIGBUS. In fact, we can catch these and abort the
operation preventing X and all of its clients from randomly dieing.
This helps for instance if you try and use a 1GiB frontbuffer on a 2GiB
machine...
For complete protection, we also need to catch signals for all GTT maps,
such as VBO and staging buffers. (TBD)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna.h')
-rw-r--r-- | src/sna/sna.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index d3890267..f7c5315c 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -69,6 +69,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <libudev.h> #endif +#include <signal.h> +#include <setjmp.h> + #include "compiler.h" #if HAS_DEBUG_FULL @@ -973,4 +976,16 @@ void sna_image_composite(pixman_op_t op, uint16_t width, uint16_t height); +extern jmp_buf sigjmp; +extern volatile sig_atomic_t sigtrap; + +#define sigtrap_assert() assert(sigtrap == 0) +#define sigtrap_get() sigsetjmp(sigjmp, ++sigtrap) + +static inline void sigtrap_put(void) +{ + --sigtrap; + sigtrap_assert(); +} + #endif /* _SNA_H */ |