Skip to content

Fix crash when adding a second ISA VGA device

Thomas Huth qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 1 replyIn review
  2. v13 patches 8 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3hw/display/cirrus_vga: Clean up indentation in pci_cirrus_vga_realize()hw/display/cirrus_vga.c+29 -280 replies
2/3hw/display: Allow vga_common_init() to return errorshw/display/ati.c hw/display/cirrus_vga.c hw/display/cirrus_vga_isa.c +8 more+42 -131 reply
3/3hw/display/vga: Report a proper error when adding a 2nd ISA VGAhw/display/vga.c+6 -00 replies

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchPhilippe Mathieu-Daudé
1/3R-b
2/3R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] Fix crash when adding a second ISA VGA device

QEMU currently abort()s if the user tries to add a second ISA VGA device, for example:

$ ./qemu-system-x86_64 -device isa-vga -device isa-vga
RAMBlock "vga.vram" already registered, abort!
Aborted (core dumped)
$ ./qemu-system-x86_64 -device isa-cirrus-vga -device isa-cirrus-vga
RAMBlock "vga.vram" already registered, abort!
Aborted (core dumped)

Such a crash should never happen just because of giving bad parameters at the command line, we should give a proper error message instead and exit gracefully.

Note: There have been previous attempts to fix this problem, but the first committed solution had bad side effects and got reverted
(https://gitlab.com/qemu-project/qemu/-/issues/733). There was another idea to fix it by QOM'ifying the related devices (see the commits around 23f6e3b11be74abae), but after having another close look at the problem, I think this doesn't work either: For getting unique names in the vmstate_register_ram() function, the devices need to return unique names from the qdev_get_dev_path() function, and those ISA VGA devices don't support that there (unlike PCI, ISA devices don't have a slot id ... they could be distinguished by their I/O port base address, but all the ISA VGA cards currently use the same address there, so that doesn't work either). ==> So the very original idea of checking for the availability of the "vga.vram" memory region still seems the only usable approach to me right now. While the original patch by Jose R. Ziviani only fixed the issue for the isa-vga device, I'm taking a more general approach now by adding the fix in the vga_common_init() function, so that it works for the isa-cirrus-vga device, too.

v2: Rework error handling in 2nd patch, vga_common_init() returns bool now

Thomas Huth (3):
hw/display/cirrus_vga: Clean up indentation in
pci_cirrus_vga_realize()
hw/display: Allow vga_common_init() to return errors hw/display/vga: Report a proper error when adding a 2nd ISA VGA

 hw/display/vga_int.h        |  2 +-
 hw/display/ati.c            |  4 ++-
 hw/display/cirrus_vga.c     | 59 +++++++++++++++++++------------------
 hw/display/cirrus_vga_isa.c |  4 ++-
 hw/display/qxl.c            |  6 +++-
 hw/display/vga-isa.c        |  5 +++-
 hw/display/vga-mmio.c       |  5 +++-
 hw/display/vga-pci.c        |  8 +++--
 hw/display/vga.c            | 17 +++++++++--
 hw/display/virtio-vga.c     |  4 ++-
 hw/display/vmware_vga.c     |  2 +-
 11 files changed, 76 insertions(+), 40 deletions(-)
Signature · 1 line
2.27.0