From 2d73e4233339147634b8364b6e702d909bcdae6c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 1 Aug 2024 13:59:01 -0700 Subject: [PATCH] intel/brw: Fix OOB reads when printing instructions post-reg-alloc Post-register allocation, but before brw_fs_lower_vgrfs_to_fixed_grfs, we have registers with the VGRF file but they are actually fixed GRFs. brw_print_instructions_to_file() was seeing VGRFs and trying to access their size, but using bogus register numbers that could be out-of-bound. Detect when we're post-RA and avoid doing this. Reviewed-by: Caio Oliveira Part-of: --- src/intel/compiler/brw_print.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw_print.cpp b/src/intel/compiler/brw_print.cpp index 193411ffe18..76ce06e57d7 100644 --- a/src/intel/compiler/brw_print.cpp +++ b/src/intel/compiler/brw_print.cpp @@ -400,7 +400,7 @@ brw_print_instruction_to_file(const fs_visitor &s, const fs_inst *inst, FILE *fi } if (inst->dst.offset || - (inst->dst.file == VGRF && + (!s.grf_used && inst->dst.file == VGRF && s.alloc.sizes[inst->dst.nr] * REG_SIZE != inst->size_written)) { const unsigned reg_size = (inst->dst.file == UNIFORM ? 4 : REG_SIZE); fprintf(file, "+%d.%d", inst->dst.offset / reg_size, @@ -513,7 +513,7 @@ brw_print_instruction_to_file(const fs_visitor &s, const fs_inst *inst, FILE *fi fprintf(file, ".%d", inst->src[i].subnr / brw_type_size_bytes(inst->src[i].type)); } else if (inst->src[i].offset || - (inst->src[i].file == VGRF && + (!s.grf_used && inst->src[i].file == VGRF && s.alloc.sizes[inst->src[i].nr] * REG_SIZE != inst->size_read(i))) { const unsigned reg_size = (inst->src[i].file == UNIFORM ? 4 : REG_SIZE); fprintf(file, "+%d.%d", inst->src[i].offset / reg_size,