[PATCH 0/5] hw/display/cirrus_vga: fix four BitBLT bugs seen with old guest drivers

Christian Quante posted 5 patches 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261018050643.9288-1-christian@quante.one
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
MAINTAINERS               |   1 +
hw/display/cirrus_vga.c   |  74 ++++++---
tests/qtest/cirrus-test.c | 317 ++++++++++++++++++++++++++++++++++++++
tests/qtest/meson.build   |   1 +
4 files changed, 374 insertions(+), 19 deletions(-)
create mode 100644 tests/qtest/cirrus-test.c
[PATCH 0/5] hw/display/cirrus_vga: fix four BitBLT bugs seen with old guest drivers
Posted by Christian Quante 1 month ago
These patches fix four bugs in the BitBLT engine of the Cirrus
emulation.  Three of them garble or hide the text of old guest drivers
that draw text with the engine; patch 1 breaks 8x8 pattern fills, for
example the edges of selected icon titles.

Patch 1 fixes a regression since v2.9.0: pattern copies from video
memory always start with pattern line 0, and a monochrome pattern can
be read from the wrong address.
Patch 2 fixes the source pitch of color expansion with DWORD granularity
(GR33 bit 0), which is wrong since the BitBLT code was written.
Patch 3 is for KVM only: the writes that start a BitBLT (GR2A with
autostart, and GR31) must not be coalesced.  The other BitBLT registers
at 0xb8000 stay coalesced, so a BitBLT that the guest programs through
these registers costs 12.8 us instead of 8.1 us (26.0 us if none of
the 256 bytes is coalesced).
Patch 4 fixes a regression since v2.8.0: a color expansion from video
memory with a source pitch of 0 is dropped, although the source pitch
has no meaning for it.
Patch 5 adds a qtest for the BitBLT engine, with test cases for patches
1, 2 and 4.  Patch 3 only matters with KVM, which qtest cannot check.

Tests, each with QEMU master (a19f59a72d) and with the patches:

 - Installer of SuSE Linux 7.0 (XFree86 3.3.6), -vga cirrus, text of
   the language selection:

                      TCG           KVM
     master           mostly dots   X server hangs, most text missing
     patches 1+2      correct       X server hangs
     patches 1-4      correct       correct

   This is GitLab issue #988.  Issue #1211 (closed) reports the same
   symptom for various Linux distributions of that time; its workaround
   is the XFree86 options "no_bitblt" and "sw_cursor".  I have not
   tested those.

 - OS/2 2.1 with IBM's CL-GD5436/46 display driver (version 1.14),
   cirrus-vga: with master, selected icon titles have a dotted edge;
   with patch 1 they are solid.

 - Windows NT 4.0 (without service pack and with SP6a) with its Cirrus
   display driver, cirrus-vga, TCG: the desktop, a selected icon, a
   console window and the output of dir are pixel-identical with and
   without the patches.  In my runs (I traced the BitBLTs), its driver
   did not use the paths that patches 1, 2 and 4 fix, so this is only a
   check for regressions.  Patch 3 matters only with KVM, and this guest
   does not boot with KVM here, neither with master nor with the patches
   (STOP 0x0000000A in ntoskrnl.exe).

 - The new cirrus-test (patch 5): with the series, all five test cases
   pass.  With patch 1 reverted, the two pattern tests fail; with patch
   2 reverted, the DWORD test fails; with patch 4 reverted, the source
   pitch test fails; with all of them reverted, these four fail.  The
   fifth test (source beyond the end of video memory) passes on master
   too, and fails if the bounds check of patch 4 is removed.

checkpatch.pl is clean, and display-vga-test passes after each patch.

Christian Quante (5):
  hw/display/cirrus_vga: keep the first pattern line of pattern copies
  hw/display/cirrus_vga: fix the source pitch for DWORD granularity
  hw/display/cirrus_vga: do not coalesce the writes that start a BitBLT
  hw/display/cirrus_vga: allow a zero source pitch for color expansion
  tests/qtest: add tests for the Cirrus BitBLT engine

 MAINTAINERS               |   1 +
 hw/display/cirrus_vga.c   |  74 ++++++---
 tests/qtest/cirrus-test.c | 317 ++++++++++++++++++++++++++++++++++++++
 tests/qtest/meson.build   |   1 +
 4 files changed, 374 insertions(+), 19 deletions(-)
 create mode 100644 tests/qtest/cirrus-test.c

-- 
2.53.0