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_display.c | |
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_display.c')
-rw-r--r-- | src/sna/sna_display.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 032c7769..28ddce5f 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3855,8 +3855,7 @@ sna_crtc_redisplay__fallback(xf86CrtcPtr crtc, RegionPtr region) PictFormatPtr format; PicturePtr src, dst; PixmapPtr pixmap; - BoxPtr b; - int n, error; + int error; void *ptr; DBG(("%s: compositing transformed damage boxes\n", __FUNCTION__)); @@ -3907,25 +3906,29 @@ sna_crtc_redisplay__fallback(xf86CrtcPtr crtc, RegionPtr region) goto free_src; kgem_bo_sync__gtt(&sna->kgem, sna_crtc->bo); - n = REGION_NUM_RECTS(region); - b = REGION_RECTS(region); - do { - BoxRec box; - - box = *b++; - transformed_box(&box, crtc); - - DBG(("%s: (%d, %d)x(%d, %d) -> (%d, %d), (%d, %d)\n", - __FUNCTION__, - b[-1].x1, b[-1].y1, b[-1].x2-b[-1].x1, b[-1].y2-b[-1].y1, - box.x1, box.y1, box.x2, box.y2)); - fbComposite(PictOpSrc, src, NULL, dst, - box.x1, box.y1, - 0, 0, - box.x1, box.y1, - box.x2 - box.x1, box.y2 - box.y1); - } while (--n); + if (sigtrap_get() == 0) { /* paranoia */ + const BoxRec *b = REGION_RECTS(region); + int n = REGION_NUM_RECTS(region); + do { + BoxRec box; + + box = *b++; + transformed_box(&box, crtc); + + DBG(("%s: (%d, %d)x(%d, %d) -> (%d, %d), (%d, %d)\n", + __FUNCTION__, + b[-1].x1, b[-1].y1, b[-1].x2-b[-1].x1, b[-1].y2-b[-1].y1, + box.x1, box.y1, box.x2, box.y2)); + + fbComposite(PictOpSrc, src, NULL, dst, + box.x1, box.y1, + 0, 0, + box.x1, box.y1, + box.x2 - box.x1, box.y2 - box.y1); + } while (--n); + sigtrap_put(); + } FreePicture(dst, None); free_src: |