panfrost: Fix uniform_count on Midgard
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 17 Feb 2021 20:36:13 +0000 (15:36 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 18 Feb 2021 16:06:36 +0000 (16:06 +0000)
commitc6ed8bf77cb8b78f98ff4924816ee052a9aa2c7b
treef1df3f962605f19250f3d507c34d80e4ba8cc111
parent0fc146e7da4885684751ef62444ba653712574f9
panfrost: Fix uniform_count on Midgard

The compiler ABI specifies push uniforms at a 4-byte granularity (like
Bifrost), but Midgard require a 16-byte granularity. As such if the
number of pushed words is not a multiple of 4, there is a buffer overrun
at shader load time. Ordinarily this is inaccessible so the garbage is
ignored.

However, there was a great deal of confusion around the `uniform_cutoff`
variable. In some cases (such a full glmark2 run on a 64-bit processor),
the push uniforms would be at the end of a BO and the overrun would
cause a page fault.

Remove uniform_cutoff entirely and work with count directly to avoid
faulting, and round the count up to be defensive.

Closes: #4289
Fixes: ed810eb0a0c ("panfrost: Don't truncate uniform_count")
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Robin Murphy <robin.murphy@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9109>
src/panfrost/lib/pan_shader.h
src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_ra.c
src/panfrost/midgard/mir_promote_uniforms.c
src/panfrost/util/pan_ir.h