mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
broadcom/compiler: Add explicit NOP instruction at page boundaries
The QPU prefetches the next instruction during shader execution. If the shader assembly size perfectly aligns with a page boundary, the prefetching mechanism reads past the compiled boundary, leading to an MMU error. This commit insert an explicit NOP instruction at the end of the shader and increases the qpu_inst_count by one when the instruction count exactly hits a page boundary. This ensures we don't fall off the end of the last executable instruction page and into invalid memory. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40983>
This commit is contained in:
parent
864ccf6cf5
commit
a8c7a25fb1
1 changed files with 10 additions and 0 deletions
|
|
@ -479,6 +479,16 @@ v3d_vir_to_qpu(struct v3d_compile *c, struct qpu_reg *temp_registers)
|
|||
|
||||
v3d_qpu_schedule_instructions(c);
|
||||
|
||||
/* If the shader ends exactly on a page boundary, append a trailing
|
||||
* NOP so the QPU's instruction prefetcher can't read past the last
|
||||
* real instruction into an unmapped page.
|
||||
*/
|
||||
if (c->qpu_inst_count * sizeof(*c->qpu_insts) % c->devinfo->page_size == 0) {
|
||||
struct qinst *inst = vir_nop();
|
||||
list_addtail(&inst->link, &vir_exit_block(c)->instructions);
|
||||
c->qpu_inst_count++;
|
||||
}
|
||||
|
||||
c->qpu_insts = rzalloc_array(c, uint64_t, c->qpu_inst_count);
|
||||
int i = 0;
|
||||
vir_for_each_inst_inorder(inst, c) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue