drm/i915/gvt: Fix incorrect check of enabled bits in mask registers
authorColin Xu <colin.xu@intel.com>
Mon, 1 Jun 2020 03:07:21 +0000 (11:07 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Wed, 17 Jun 2020 04:36:01 +0000 (12:36 +0800)
commitfc1e3aa0337c76b620726e205372073c234616ab
treefb34e4a91c9abe9770b5405d4ad6f972c6fdf190
parentfccd0f7cf4d532674d727c7f204f038456675dee
drm/i915/gvt: Fix incorrect check of enabled bits in mask registers

Using _MASKED_BIT_ENABLE macro to set mask register bits is straight
forward and not likely to go wrong. However when checking which bit(s)
is(are) enabled, simply bitwise AND value and _MASKED_BIT_ENABLE() won't
output expected result. Suppose the register write is disabling bit 1
by setting 0xFFFF0000, however "& _MASKED_BIT_ENABLE(1)" outputs
0x00010000, and the non-zero check will pass which cause the old code
consider the new value set as an enabling operation.

We found guest set 0x80008000 on boot, and set 0xffff8000 during resume.
Both are legal settings but old code will block latter and force vgpu
enter fail-safe mode.

Introduce two new macro and make proper masked bit check in mmio handler:
IS_MASKED_BITS_ENABLED()
IS_MASKED_BITS_DISABLED()

V2: Rebase.

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Colin Xu <colin.xu@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20200601030721.17129-1-colin.xu@intel.com
drivers/gpu/drm/i915/gvt/handlers.c
drivers/gpu/drm/i915/gvt/mmio_context.h
drivers/gpu/drm/i915/gvt/reg.h