Mesa (master): intel/aubinator: Trust the packet size in the header for SUBOPCODE_HEADER

Jason Ekstrand jekstrand at kemper.freedesktop.org
Tue Nov 29 00:45:51 UTC 2016


Module: Mesa
Branch: master
Commit: 12f2eae7e7e74c1c3f16fee1f27eec6cfcffe092
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=12f2eae7e7e74c1c3f16fee1f27eec6cfcffe092

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Nov 23 19:26:13 2016 -0800

intel/aubinator: Trust the packet size in the header for SUBOPCODE_HEADER

We were reading from the "comment size" dword and incrementing by that
amount.  This never caused a problem because that field was always zero.
However, experimenting with actual aub file comments indicates, the
simulator seems to include the comment size in the packet size provided in
the header.  We should do the same.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/intel/tools/aubinator.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index fbd8721..abade45 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -993,7 +993,7 @@ static int
 aub_file_decode_batch(struct aub_file *file, struct gen_spec *spec)
 {
    uint32_t *p, h, device, data_type, *new_cursor;
-   int header_length, payload_size, bias;
+   int header_length, bias;
 
    if (file->end - file->cursor < 1)
       return AUB_ITEM_DECODE_NEED_MORE_DATA;
@@ -1016,23 +1016,13 @@ aub_file_decode_batch(struct aub_file *file, struct gen_spec *spec)
       return AUB_ITEM_DECODE_FAILED;
    }
 
-   payload_size = 0;
-   switch (h & 0xffff0000) {
-   case MAKE_HEADER(TYPE_AUB, OPCODE_AUB, SUBOPCODE_HEADER):
-      if (file->end - file->cursor < 12)
-         return AUB_ITEM_DECODE_NEED_MORE_DATA;
-      payload_size = p[12];
-      break;
-   case MAKE_HEADER(TYPE_AUB, OPCODE_AUB, SUBOPCODE_BLOCK):
+   new_cursor = p + header_length + bias;
+   if ((h & 0xffff0000) == MAKE_HEADER(TYPE_AUB, OPCODE_AUB, SUBOPCODE_BLOCK)) {
       if (file->end - file->cursor < 4)
          return AUB_ITEM_DECODE_NEED_MORE_DATA;
-      payload_size = p[4];
-      break;
-   default:
-      break;
+      new_cursor += p[4] / 4;
    }
 
-   new_cursor = p + header_length + bias + payload_size / 4;
    if (new_cursor > file->end)
       return AUB_ITEM_DECODE_NEED_MORE_DATA;
 




More information about the mesa-commit mailing list