[bug report] drm/i915/gvt: vGPU command scanner

Dan Carpenter dan.carpenter at oracle.com
Thu Oct 20 11:45:17 UTC 2016


Hello Zhi Wang,

The patch be1da7070aea: "drm/i915/gvt: vGPU command scanner" from May
3, 2016, leads to the following static checker warning:

	drivers/gpu/drm/i915/gvt/cmd_parser.c:1420 cmd_handler_mi_op_2f()
	warn: shift has higher precedence than mask

drivers/gpu/drm/i915/gvt/cmd_parser.c
  1417  static int cmd_handler_mi_op_2f(struct parser_exec_state *s)
  1418  {
  1419          int gmadr_bytes = s->vgpu->gvt->device_info.gmadr_bytes_in_cmd;
  1420          int op_size = ((1 << (cmd_val(s, 0) & GENMASK(20, 19) >> 19)) *
  1421                          sizeof(u32));

The size calculation is wrong but I've got no idea what the fix is.

  1422          unsigned long gma, gma_high;
  1423          int ret = 0;
  1424  
  1425          if (!(cmd_val(s, 0) & (1 << 22)))
  1426                  return ret;
  1427  
  1428          gma = cmd_val(s, 1) & GENMASK(31, 2);
  1429          if (gmadr_bytes == 8) {
  1430                  gma_high = cmd_val(s, 2) & GENMASK(15, 0);
  1431                  gma = (gma_high << 32) | gma;
  1432          }
  1433          ret = cmd_address_audit(s, gma, op_size, false);
  1434          return ret;
  1435  }

regards,
dan carpenter


More information about the dri-devel mailing list