v3d: fix indirect BO allocation for uniforms
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 26 Nov 2019 14:28:52 +0000 (15:28 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Wed, 27 Nov 2019 07:43:13 +0000 (08:43 +0100)
commit18a09e788d8d0e122263159cb6cb1c70d243b02d
tree2226508c05a30b6a0e92c568817b89b6d5ab1636
parenta24f1c8f7f093d98a8856e47bb190a1016457414
v3d: fix indirect BO allocation for uniforms

We were always ensuring a minimum size of 4 bytes for uniforms
for the case where we don't have any, to account for hardware pre-fetching
of the uniform stream, however, pre-fetching could also lead to to out
of bounds reads when have read the last uniform in the stream, so we
probably want to have the extra 4 bytes to prevent the kernel from
observing invalid memory accesses when the uniform stream sits right at
the end of a page.

This seems to fix MMU exceptions reported with a Linux 5.4 kernel.

Credit goes to Phil Elwell for identifying the problem and narrowing
it down to memory accesses in the uniform stream.

Reported-by: Phil Elwell <phil@raspberrypi.org>
Tested-by: Phil Elwell <phil@raspberrypi.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/drivers/v3d/v3d_uniforms.c