All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [PATCH 0/3] Fix crash when adding a second ISA VGA device
Date: Wed, 16 Mar 2022 14:23:59 +0100	[thread overview]
Message-ID: <20220316132402.1190346-1-thuth@redhat.com> (raw)

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.

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/ati.c            |  7 ++++-
 hw/display/cirrus_vga.c     | 62 ++++++++++++++++++++-----------------
 hw/display/cirrus_vga_isa.c |  7 ++++-
 hw/display/qxl.c            |  6 +++-
 hw/display/vga-isa.c        |  9 +++++-
 hw/display/vga-mmio.c       |  8 ++++-
 hw/display/vga-pci.c        | 15 +++++++--
 hw/display/vga.c            | 15 +++++++--
 hw/display/vga_int.h        |  2 +-
 hw/display/virtio-vga.c     |  7 ++++-
 hw/display/vmware_vga.c     |  2 +-
 11 files changed, 100 insertions(+), 40 deletions(-)

-- 
2.27.0



             reply	other threads:[~2022-03-16 13:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 13:23 Thomas Huth [this message]
2022-03-16 13:24 ` [PATCH 1/3] hw/display/cirrus_vga: Clean up indentation in pci_cirrus_vga_realize() Thomas Huth
2022-03-16 13:33   ` Philippe Mathieu-Daudé
2022-03-16 13:24 ` [PATCH 2/3] hw/display: Allow vga_common_init() to return errors Thomas Huth
2022-03-16 13:32   ` Philippe Mathieu-Daudé
2022-03-16 13:39     ` Thomas Huth
2022-03-16 14:16       ` Markus Armbruster
2022-03-16 17:05         ` Thomas Huth
2022-03-17  7:40           ` Markus Armbruster
2022-03-17 12:32             ` Thomas Huth
2022-03-17 13:29               ` Markus Armbruster
2022-03-16 13:24 ` [PATCH 3/3] hw/display/vga: Report a proper error when adding a 2nd ISA VGA Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220316132402.1190346-1-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=philippe.mathieu.daude@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.