diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-08-21 12:29:47 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-22 12:53:44 -0700 |
commit | ded9a68d8f3c38f2aa951f45bd0a2335bcd53c8a (patch) | |
tree | 857b804d17481fa804587440426007a7520b89b2 /src/panfrost | |
parent | f06e8f7fe9f809bdecb9efeed13f9831e908b2d7 (diff) |
pan/decode: Validate and simplify FRAGMENT payloads
There are a number of conditions we need to test for to statically check
for TILE_RANGE_FAULTs, but once these checks are in order, we can print
as-is.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/pandecode/decode.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c index 7df17ec7b3e..7c8c5ca95c0 100644 --- a/src/panfrost/pandecode/decode.c +++ b/src/panfrost/pandecode/decode.c @@ -2581,22 +2581,51 @@ pandecode_fragment_job(const struct pandecode_mapped_memory *mem, expected_tag |= (MALI_POSITIVE(info.rt_count) << 2); } - pandecode_log("struct mali_payload_fragment payload_%"PRIx64"_%d = {\n", payload, job_no); - pandecode_indent++; - if ((s->min_tile_coord | s->max_tile_coord) & ~(MALI_X_COORD_MASK | MALI_Y_COORD_MASK)) { pandecode_msg("XXX: unexpected tile coordinate bits\n"); pandecode_prop("min_tile_coord = 0x%X\n", s->min_tile_coord); pandecode_prop("max_tile_coord = 0x%X\n", s->min_tile_coord); } - pandecode_prop("min_tile_coord = MALI_COORDINATE_TO_TILE_MIN(%d, %d)", - MALI_TILE_COORD_X(s->min_tile_coord) << MALI_TILE_SHIFT, - MALI_TILE_COORD_Y(s->min_tile_coord) << MALI_TILE_SHIFT); + /* Extract tile coordinates */ + + unsigned min_x = MALI_TILE_COORD_X(s->min_tile_coord) << MALI_TILE_SHIFT; + unsigned min_y = MALI_TILE_COORD_Y(s->min_tile_coord) << MALI_TILE_SHIFT; + + unsigned max_x = (MALI_TILE_COORD_X(s->max_tile_coord) + 1) << MALI_TILE_SHIFT; + unsigned max_y = (MALI_TILE_COORD_Y(s->max_tile_coord) + 1) << MALI_TILE_SHIFT; + + /* For the max, we also want the floored (rather than ceiled) version for checking */ + + unsigned max_x_f = (MALI_TILE_COORD_X(s->max_tile_coord)) << MALI_TILE_SHIFT; + unsigned max_y_f = (MALI_TILE_COORD_Y(s->max_tile_coord)) << MALI_TILE_SHIFT; + + /* Validate the coordinates are well-ordered */ + + if (min_x == max_x) + pandecode_msg("XXX: empty X coordinates (%u = %u)\n", min_x, max_x); + else if (min_x > max_x) + pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); - pandecode_prop("max_tile_coord = MALI_COORDINATE_TO_TILE_MAX(%d, %d)", - (MALI_TILE_COORD_X(s->max_tile_coord) + 1) << MALI_TILE_SHIFT, - (MALI_TILE_COORD_Y(s->max_tile_coord) + 1) << MALI_TILE_SHIFT); + if (min_y == max_y) + pandecode_msg("XXX: empty X coordinates (%u = %u)\n", min_x, max_x); + else if (min_y > max_y) + pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); + + /* Validate the coordinates fit inside the framebuffer. We use floor, + * rather than ceil, for the max coordinates, since the tile + * coordinates for something like an 800x600 framebuffer will actually + * resolve to 800x608, which would otherwise trigger a Y-overflow */ + + if ((min_x > info.width) || (max_x_f > info.width)) + pandecode_msg("XXX: tile coordinates overflow in X direction\n"); + + if ((min_y > info.height) || (max_y_f > info.height)) + pandecode_msg("XXX: tile coordinates overflow in Y direction\n"); + + /* After validation, we print */ + + pandecode_log("fragment (%u, %u) ... (%u, %u)\n\n", min_x, min_y, max_x, max_y); /* The FBD is a tagged pointer */ @@ -2605,9 +2634,6 @@ pandecode_fragment_job(const struct pandecode_mapped_memory *mem, if (tag != expected_tag) pandecode_msg("XXX: expected FBD tag %X but got %X\n", expected_tag, tag); - pandecode_indent--; - pandecode_log("};\n"); - return sizeof(*s); } |