<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Invalid data in error state"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=107691#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Invalid data in error state"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=107691">bug 107691</a>
              from <span class="vcard"><a class="email" href="mailto:chris@chris-wilson.co.uk" title="Chris Wilson <chris@chris-wilson.co.uk>"> <span class="fn">Chris Wilson</span></a>
</span></b>
        <pre>Reproduced using

import { gem, gem_ioctls } from '../lib/i915/gem-ioctls.js';
import { drm } from '../lib/drm.js';
const ioctl = igt.os.ioctl;
const print = igt.toy.print;

const i915 = drm.cards()[0];

var fd;
fd = igt.os.open(drm.sysfs(i915) + '/' + 'error');
igt.os.write(fd, Uint32Array.of(0));
igt.os.close(fd);

const reloc_sz = gem_ioctls.s_execbuf_reloc.__pack_size__;
const reloc = new ArrayBuffer(2 * reloc_sz);

const batch = gem.create(i915, 4096);
let cs = new Uint32Array(gem.mmap(i915, batch, 4096, 1));
gem.set_domain(i915, batch, 0x80, 0x80);

cs[0] = 0x20 << 23 | 2;
ioctl.pack(new DataView(reloc, 0, reloc_sz), gem_ioctls.s_execbuf_reloc,
           new Map([
             [ "target_handle", batch ],
             [ "delta", 4096 - 4 ],
             [ "offset", 4 ],
           ]));
cs[1] = 4096 - 4;
cs[2] = 0;
cs[3] = 1;
cs[16] = 0x5 << 23;
cs[17] = 0x31 << 23 | 1 << 8 | 1;
ioctl.pack(new DataView(reloc, reloc_sz, reloc_sz), gem_ioctls.s_execbuf_reloc,
           new Map([
             [ "target_handle", batch ],
             [ "delta", 64 ],
             [ "offset", 4 * 17 ],
           ]));
cs[18] = 64;
cs[19] = 0;

const handle = gem.create(i915, 4096 * 65536);
let data = new Uint32Array(gem.mmap(i915, handle, 4096 * 65536));
for (let page = 0; page < 65536; page++) {
  for (let x = 0; x < 4096/4; x++) {
    data[page * 4096/4 + x] = page << 16 | x;
  }
}

const sz = gem_ioctls.s_execbuf_object.__pack_size__;
const objects = new ArrayBuffer(sz * 2);
ioctl.pack(new DataView(objects, 0, sz),
           gem_ioctls.s_execbuf_object,
           new Map([
             [ "handle", handle ],
             [ "flags", 1 << 7 ],
           ]));
ioctl.pack(new DataView(objects, sz, sz),
           gem_ioctls.s_execbuf_object,
           new Map([
             [ "handle", batch ],
             [ "relocation_count", 2 ],
             [ "relocs_ptr", reloc ],
           ]));
gem.execbuf(i915,
            ioctl.pack(undefined, gem_ioctls.s_execbuf,
                       new Map([
                         [ "buffers_ptr", objects],
                         [ "buffer_count", 2 ]
                       ])));

igt.assert(gem.busy(i915, batch));
while (!cs[1023] && gem.busy(i915, batch))
  ;

fd = igt.os.open(drm.debugfs(i915) + '/' + 'i915_wedged');
igt.os.write(fd, Uint32Array.of(0xffffffff));
igt.os.close(fd);

fd = igt.os.open(drm.sysfs(i915) + '/' + 'error');
const re = /--- user =/;
let line;
do {
  line = igt.os.readLine(fd)
} while (line && !re.test(line));
let error = igt.os.readLine(fd);
igt.os.close(fd);

let out = igt.ascii85.decode(error, error[0] == ':', 1);
for (var page = 0; page < 65536; page++) {
  let a = new Uint32Array(out, 4096*page, 4096/4);
  for (var i = 0; i < 4096/4; i++) {
    if (a[i] != page << 16 | i) {
      print(`Error detected on page:${page}, byte:${4*i}`);
      print(new Uint32Array(out, 4096*page + 4*(i&-32), 64));
      exit(1);
    }
  }
}

For science!</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>