pvr: Add stricter type checking in pvr_csb_pack().
authorKarmjit Mahil <Karmjit.Mahil@imgtec.com>
Mon, 14 Mar 2022 11:46:54 +0000 (11:46 +0000)
committerMarge Bot <emma+marge@anholt.net>
Mon, 4 Apr 2022 03:40:48 +0000 (03:40 +0000)
commite5439bf4aa6ce69d323a0eb5108404d8e2a6ee18
treeb1798f7aebd04399a2a321339e6ba4378bc93049
parentc4650cbdb002ee9df699bb389fdf7aa8c907f010
pvr: Add stricter type checking in pvr_csb_pack().

Since the packing functions generated by csbgen use a void pointer
for the buffer in which to pack, it's possible to easily write out
of bounds. This commits attempts to reduce the chances by
having the pack macro check that the pointer passed points to an
element sized equally to the state word being packed. Catching
these errors earlier.

As can be seen in this commit, there already was a case of this:
"pds_ctrl". The word size is meant to be 64 bits but the pointer
was pointing to a 32 bit field.

Although it's fine for the word size to be smaller than the
storage pointed to by the pointer, this is not allowed just to
be extra careful.

Signed-off-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15687>
src/imagination/vulkan/pvr_csb.h
src/imagination/vulkan/pvr_job_context.c
src/imagination/vulkan/winsys/pvr_winsys.h
src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_render.c