sna: Wrap CPU access for composite operations with sigtrap
Anytime we access a mmap() we need to be prepared for the kernel to send us a SIGBUS, but we were missing a few sigtraps around calls to pixman_fill and pixman_blt. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
a16a7e36ca
commit
335ac8742e
|
|
@ -2365,21 +2365,26 @@ skip_inplace_map:
|
|||
assert(pixmap->devPrivate.ptr == MAP(priv->cpu_bo->map__cpu));
|
||||
}
|
||||
|
||||
assert(pixmap->devKind);
|
||||
if (priv->clear_color == 0 ||
|
||||
pixmap->drawable.bitsPerPixel == 8 ||
|
||||
priv->clear_color == (1 << pixmap->drawable.depth) - 1) {
|
||||
memset(pixmap->devPrivate.ptr, priv->clear_color,
|
||||
(size_t)pixmap->devKind * pixmap->drawable.height);
|
||||
} else {
|
||||
pixman_fill(pixmap->devPrivate.ptr,
|
||||
pixmap->devKind/sizeof(uint32_t),
|
||||
pixmap->drawable.bitsPerPixel,
|
||||
0, 0,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
priv->clear_color);
|
||||
}
|
||||
if (sigtrap_get() == 0) {
|
||||
assert(pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
if (priv->clear_color == 0 ||
|
||||
pixmap->drawable.bitsPerPixel == 8 ||
|
||||
priv->clear_color == (1 << pixmap->drawable.depth) - 1) {
|
||||
memset(pixmap->devPrivate.ptr, priv->clear_color,
|
||||
(size_t)pixmap->devKind * pixmap->drawable.height);
|
||||
} else {
|
||||
pixman_fill(pixmap->devPrivate.ptr,
|
||||
pixmap->devKind/sizeof(uint32_t),
|
||||
pixmap->drawable.bitsPerPixel,
|
||||
0, 0,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
priv->clear_color);
|
||||
}
|
||||
sigtrap_put();
|
||||
} else
|
||||
return false;
|
||||
|
||||
clear_done:
|
||||
sna_damage_all(&priv->cpu_damage, pixmap);
|
||||
|
|
@ -2929,6 +2934,7 @@ move_to_cpu:
|
|||
}
|
||||
|
||||
assert(pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
do {
|
||||
pixman_fill(pixmap->devPrivate.ptr,
|
||||
pixmap->devKind/sizeof(uint32_t),
|
||||
|
|
@ -6869,6 +6875,7 @@ fallback:
|
|||
|
||||
assert(dst_pixmap->devPrivate.ptr);
|
||||
assert(dst_pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
do {
|
||||
pixman_fill(dst_pixmap->devPrivate.ptr,
|
||||
dst_pixmap->devKind/sizeof(uint32_t),
|
||||
|
|
@ -17064,6 +17071,7 @@ sna_get_image__fast(PixmapPtr pixmap,
|
|||
__FUNCTION__, priv->clear_color));
|
||||
assert(DAMAGE_IS_ALL(priv->gpu_damage));
|
||||
assert(priv->cpu_damage == NULL);
|
||||
sigtrap_assert_active();
|
||||
|
||||
if (priv->clear_color == 0 ||
|
||||
pixmap->drawable.bitsPerPixel == 8 ||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,11 @@ static const uint8_t fill_ROP[] = {
|
|||
ROP_1
|
||||
};
|
||||
|
||||
static void sig_done(struct sna *sna, const struct sna_composite_op *op)
|
||||
{
|
||||
sigtrap_put();
|
||||
}
|
||||
|
||||
static void nop_done(struct sna *sna, const struct sna_composite_op *op)
|
||||
{
|
||||
assert(sna->kgem.nbatch <= KGEM_BATCH_SIZE(&sna->kgem));
|
||||
|
|
@ -1005,6 +1010,7 @@ static void blt_composite_fill__cpu(struct sna *sna,
|
|||
|
||||
assert(op->dst.pixmap->devPrivate.ptr);
|
||||
assert(op->dst.pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
pixman_fill(op->dst.pixmap->devPrivate.ptr,
|
||||
op->dst.pixmap->devKind / sizeof(uint32_t),
|
||||
op->dst.pixmap->drawable.bitsPerPixel,
|
||||
|
|
@ -1024,6 +1030,7 @@ blt_composite_fill_box_no_offset__cpu(struct sna *sna,
|
|||
|
||||
assert(op->dst.pixmap->devPrivate.ptr);
|
||||
assert(op->dst.pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
pixman_fill(op->dst.pixmap->devPrivate.ptr,
|
||||
op->dst.pixmap->devKind / sizeof(uint32_t),
|
||||
op->dst.pixmap->drawable.bitsPerPixel,
|
||||
|
|
@ -1044,6 +1051,7 @@ blt_composite_fill_boxes_no_offset__cpu(struct sna *sna,
|
|||
|
||||
assert(op->dst.pixmap->devPrivate.ptr);
|
||||
assert(op->dst.pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
pixman_fill(op->dst.pixmap->devPrivate.ptr,
|
||||
op->dst.pixmap->devKind / sizeof(uint32_t),
|
||||
op->dst.pixmap->drawable.bitsPerPixel,
|
||||
|
|
@ -1065,6 +1073,7 @@ blt_composite_fill_box__cpu(struct sna *sna,
|
|||
|
||||
assert(op->dst.pixmap->devPrivate.ptr);
|
||||
assert(op->dst.pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
pixman_fill(op->dst.pixmap->devPrivate.ptr,
|
||||
op->dst.pixmap->devKind / sizeof(uint32_t),
|
||||
op->dst.pixmap->drawable.bitsPerPixel,
|
||||
|
|
@ -1086,6 +1095,7 @@ blt_composite_fill_boxes__cpu(struct sna *sna,
|
|||
|
||||
assert(op->dst.pixmap->devPrivate.ptr);
|
||||
assert(op->dst.pixmap->devKind);
|
||||
sigtrap_assert_active();
|
||||
pixman_fill(op->dst.pixmap->devPrivate.ptr,
|
||||
op->dst.pixmap->devKind / sizeof(uint32_t),
|
||||
op->dst.pixmap->drawable.bitsPerPixel,
|
||||
|
|
@ -1464,6 +1474,7 @@ prepare_blt_clear(struct sna *sna,
|
|||
DBG(("%s\n", __FUNCTION__));
|
||||
|
||||
if (op->dst.bo == NULL) {
|
||||
op->u.blt.pixel = 0;
|
||||
op->blt = blt_composite_fill__cpu;
|
||||
if (op->dst.x|op->dst.y) {
|
||||
op->box = blt_composite_fill_box__cpu;
|
||||
|
|
@ -1474,9 +1485,8 @@ prepare_blt_clear(struct sna *sna,
|
|||
op->boxes = blt_composite_fill_boxes_no_offset__cpu;
|
||||
op->thread_boxes = blt_composite_fill_boxes_no_offset__cpu;
|
||||
}
|
||||
op->done = nop_done;
|
||||
op->u.blt.pixel = 0;
|
||||
return true;
|
||||
op->done = sig_done;
|
||||
return sigtrap_get() == 0;
|
||||
}
|
||||
|
||||
op->blt = blt_composite_fill;
|
||||
|
|
@ -1519,8 +1529,8 @@ prepare_blt_fill(struct sna *sna,
|
|||
op->boxes = blt_composite_fill_boxes_no_offset__cpu;
|
||||
op->thread_boxes = blt_composite_fill_boxes_no_offset__cpu;
|
||||
}
|
||||
op->done = nop_done;
|
||||
return true;
|
||||
op->done = sig_done;
|
||||
return sigtrap_get() == 0;
|
||||
}
|
||||
|
||||
op->blt = blt_composite_fill;
|
||||
|
|
@ -2436,6 +2446,9 @@ prepare_blt_put(struct sna *sna,
|
|||
op->box = blt_put_composite_box;
|
||||
op->boxes = blt_put_composite_boxes;
|
||||
}
|
||||
|
||||
op->done = nop_done;
|
||||
return true;
|
||||
} else {
|
||||
if (alpha_fixup) {
|
||||
op->u.blt.pixel = alpha_fixup;
|
||||
|
|
@ -2447,10 +2460,10 @@ prepare_blt_put(struct sna *sna,
|
|||
op->box = blt_put_composite_box__cpu;
|
||||
op->boxes = blt_put_composite_boxes__cpu;
|
||||
}
|
||||
}
|
||||
op->done = nop_done;
|
||||
|
||||
return true;
|
||||
op->done = sig_done;
|
||||
return sigtrap_get() == 0;
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
|
|
@ -592,6 +592,8 @@ lerp32_opacity(PixmapPtr scratch,
|
|||
uint32_t *ptr;
|
||||
int stride, i;
|
||||
|
||||
sigtrap_assert_active();
|
||||
|
||||
ptr = (uint32_t*)((uint8_t *)scratch->devPrivate.ptr + scratch->devKind * y);
|
||||
ptr += x;
|
||||
stride = scratch->devKind / 4;
|
||||
|
|
|
|||
|
|
@ -2370,6 +2370,7 @@ tor_blt_lerp32(struct sna *sna,
|
|||
if (coverage == 0)
|
||||
return;
|
||||
|
||||
sigtrap_assert_active();
|
||||
ptr += box->y1 * stride + box->x1;
|
||||
|
||||
h = box->y2 - box->y1;
|
||||
|
|
|
|||
|
|
@ -1013,6 +1013,7 @@ mono_inplace_fill_box(struct sna *sna,
|
|||
box->x2 - box->x1,
|
||||
box->y2 - box->y1,
|
||||
fill->color));
|
||||
sigtrap_assert_active();
|
||||
pixman_fill(fill->data, fill->stride, fill->bpp,
|
||||
box->x1, box->y1,
|
||||
box->x2 - box->x1,
|
||||
|
|
@ -1034,6 +1035,7 @@ mono_inplace_fill_boxes(struct sna *sna,
|
|||
box->x2 - box->x1,
|
||||
box->y2 - box->y1,
|
||||
fill->color));
|
||||
sigtrap_assert_active();
|
||||
pixman_fill(fill->data, fill->stride, fill->bpp,
|
||||
box->x1, box->y1,
|
||||
box->x2 - box->x1,
|
||||
|
|
|
|||
|
|
@ -2386,6 +2386,7 @@ tor_blt_lerp32(struct sna *sna,
|
|||
if (coverage == 0)
|
||||
return;
|
||||
|
||||
sigtrap_assert_active();
|
||||
ptr += box->y1 * stride + box->x1;
|
||||
|
||||
h = box->y2 - box->y1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue