From df1088e16fbb50cc1a764faac607fd0596ca5699 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Sun, 15 Sep 2024 15:48:38 +0200 Subject: [PATCH] pan/cs: Make sure we don't overflow the chunk capacity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit assert that a block is no bigger than a chunk allocated by ::alloc_buffer(). Signed-off-by: Boris Brezillon Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Louis-Francis Ratté-Boulianne Part-of: --- src/panfrost/lib/genxml/cs_builder.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/panfrost/lib/genxml/cs_builder.h b/src/panfrost/lib/genxml/cs_builder.h index d197091367e..6d5c601815a 100644 --- a/src/panfrost/lib/genxml/cs_builder.h +++ b/src/panfrost/lib/genxml/cs_builder.h @@ -452,6 +452,9 @@ cs_alloc_ins(struct cs_builder *b, uint32_t num_instrs) } } + /* Make sure the instruction sequence fits in a single chunk. */ + assert(b->cur_chunk.buffer.capacity >= num_instrs); + /* If the current chunk runs out of space, allocate a new one and jump to it. * We actually do this a few instructions before running out, because the * sequence to jump to a new queue takes multiple instructions.