mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
pvr: fix invalid read reported by valgrind
pvr_gpu_upload() can't be used in the case of pvr_gpu_upload_usc() as it expects
the source and destination buffers to be the same size. This isn't the case
because pvr_gpu_upload_usc() adds some padding bytes to the size passed in by
the caller.
Fixes: 547a10f870 ("pvr: switch pvr_cmd_buffer_alloc_mem to use pvr_bo_suballoc")
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23185>
This commit is contained in:
parent
a7beb9974e
commit
9b7faa7d96
1 changed files with 18 additions and 6 deletions
|
|
@ -2562,18 +2562,30 @@ VkResult pvr_gpu_upload_usc(struct pvr_device *device,
|
|||
uint64_t code_alignment,
|
||||
struct pvr_suballoc_bo **const pvr_bo_out)
|
||||
{
|
||||
struct pvr_suballoc_bo *suballoc_bo = NULL;
|
||||
VkResult result;
|
||||
void *map;
|
||||
|
||||
assert(code_size > 0);
|
||||
|
||||
/* The USC will prefetch the next instruction, so over allocate by 1
|
||||
* instruction to prevent reading off the end of a page into a potentially
|
||||
* unallocated page.
|
||||
*/
|
||||
return pvr_gpu_upload(device,
|
||||
device->heaps.usc_heap,
|
||||
code,
|
||||
code_size + ROGUE_MAX_INSTR_BYTES,
|
||||
code_alignment,
|
||||
pvr_bo_out);
|
||||
result = pvr_bo_suballoc(&device->suballoc_usc,
|
||||
code_size + ROGUE_MAX_INSTR_BYTES,
|
||||
code_alignment,
|
||||
false,
|
||||
&suballoc_bo);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
map = pvr_bo_suballoc_get_map_addr(suballoc_bo);
|
||||
memcpy(map, code, code_size);
|
||||
|
||||
*pvr_bo_out = suballoc_bo;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue