Skip to content

Commit

Permalink
stdvga+bochs-display: add dummy mmio handler
Browse files Browse the repository at this point in the history
The bochs-display mmio bar has some sub-regions with the actual hardware
registers.  What happens when the guest access something outside those
regions depends on the archirecture.  On x86 those reads succeed (and
return 0xff I think).  On risc-v qemu aborts.

This patch adds handlers for the parent region, to make the wanted
behavior explicit and to make things consistent across architectures.

v2:
 - use existing unassigned_io_ops.
 - also cover stdvga.

Cc: Alistair Francis <alistair23@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200309100009.17624-1-kraxel@redhat.com
  • Loading branch information
kraxel committed Mar 16, 2020
1 parent 61c265f commit f872c76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hw/display/bochs-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ static void bochs_display_realize(PCIDevice *dev, Error **errp)
memory_region_init_io(&s->qext, obj, &bochs_display_qext_ops, s,
"qemu extended regs", PCI_VGA_QEXT_SIZE);

memory_region_init(&s->mmio, obj, "bochs-display-mmio",
PCI_VGA_MMIO_SIZE);
memory_region_init_io(&s->mmio, obj, &unassigned_io_ops, NULL,
"bochs-display-mmio", PCI_VGA_MMIO_SIZE);
memory_region_add_subregion(&s->mmio, PCI_VGA_BOCHS_OFFSET, &s->vbe);
memory_region_add_subregion(&s->mmio, PCI_VGA_QEXT_OFFSET, &s->qext);

Expand Down
8 changes: 4 additions & 4 deletions hw/display/vga-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)

/* mmio bar for vga register access */
if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_MMIO)) {
memory_region_init(&d->mmio, NULL, "vga.mmio",
PCI_VGA_MMIO_SIZE);
memory_region_init_io(&d->mmio, OBJECT(dev), &unassigned_io_ops, NULL,
"vga.mmio", PCI_VGA_MMIO_SIZE);

if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
qext = true;
Expand Down Expand Up @@ -285,8 +285,8 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s);

/* mmio bar */
memory_region_init(&d->mmio, OBJECT(dev), "vga.mmio",
PCI_VGA_MMIO_SIZE);
memory_region_init_io(&d->mmio, OBJECT(dev), &unassigned_io_ops, NULL,
"vga.mmio", PCI_VGA_MMIO_SIZE);

if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
qext = true;
Expand Down

0 comments on commit f872c76

Please sign in to comment.