Skip to contentSkip to conversation

ramfb: simple boot framebuffer, no legacy vga

PATCH Superseded Gerd Hoffmann 3 participants 25 messages Mar 23, 2018 – Jun 6, 2018

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover ramfb: simple boot framebuffer, no legacy vga

Hi,

Ok folks, here is a experimental patch series for a legacy free boot framebuffer. If you want play with it I recommend getting the bits from

https://www.kraxel.org/cgit/qemu/log/?h=sirius/ramfb

because they come with an updated seabios and a new vgabios rom and an experimental OVMF build.

Functional overview
-------------------

The boot framebuffer is expected to be configured by the firmware, so it uses fw_cfg as interface. Initialization goes as follows:

(1) Check whenever etc/ramfb is present.
(2) Allocate framebuffer from RAM.
(3) Fill struct RAMFBCfg, write it to etc/ramfb.

Done. You can write stuff to the framebuffer now, and it should appear automagically on the screen.

Note that this isn't very efficient because it does a full display update on each refresh. No dirty tracking. Dirty tracking would have to be active for the whole ram slot, so that wouldn't be very efficient either. So it is *really* intended to be only active for a short time at boot, before the guest loaded the drivers for the real display hardware.

Firmware support -- seabios
---------------------------

seavgabios is able to emulate vga text mode on top of a framebuffer, for coreboot native graphics initialialization. Which works fine for everything which writes text using the vgabios interface (basically everyhing which works with sgabios).

So I hacked that up to work with ramfb. Right now it's proof-of-concept code with too much cut+paste, so it will clearly need a bunch of cleanups if this approach turns out to be workable. Look here:

https://www.kraxe.org/cgit/seabios/log/?h=ramfb

Firmware support -- edk2
------------------------

There is a EFI driver too. Likewise a hackish proof-of-concept thing, clearly not in a mergeable state, but good enough for playing. Note that the build disables QemuVideoDxe and VirtoGpu drivers, so ramfb is the only supported display. Code is here:

https://github.com/kraxel/edk2/commits/ramfb

Firmware blob is in pc-bios/OVMF-ramfb.fd, to be used with -bios.

So, how to play?
----------------

There is ramfb-testdev. Standalone device, for testing purposes. Also can listen on vga ports and logs any access, so we can see the bad boys. Use "qemu -vga none -device ramfb-testdev". Add "vgalog=on" to watch guests accessing vga registers.

There is virtio-ramfb. Simliar to virtio-vga, but using ramfb instead of adding vga compatibility. Shows how you can wire up ramfb support to some display device. Unlike virtio-vga it should work fine on arm. Use "qemu -vga none -device virtio-ramfb" for this one.

Tried to add qxl-ramfb, for windows guest tests, but that doesn't work yet. Don't use, unless you want help debugging ;)

There is virtio-pci-ramfb, which provides boot display support to vgpu devices.

In general using UEFI works better than BIOS, because guests don't expect legacy vga being present then.

What works?
-----------

Both windows and linux UEFI guests handle the ramfb GOP just fine.

BIOS boot loaders for linux all use vgabios calls for text mode, so they show up just fine. Also ipxe, seabios itself of course. So you can boot up your linux guest. vesafb works too.

What doesn't work?
------------------

vgacon (direct vga hardware access). Linux boots just fine nevertheless, the only effect is that you don't see any boot messages until the drm driver loads.

Windows in BIOS mode. Boot logo shows up just fine. But at some point windows does lots of vga register accesses (even though it sets the video mode via vesa bios interface) and appears to be unhappy that things don't work as expected because there is no vga hardware emulation.

Known issues
------------

Handover from ramfb-backed efifb to the native linux driver is tricky. Usually efifb gets kicked out when the native driver loads because of overlapping ressources. With efifb being in RAM instead of using a GPU PCI bar this doesn't happen though, so you'll end up with two framebuffer devices.

In case vgaarb classifies the GPU as primary display device fbcon will switch all VTs over to the framebuffer device of the real GPU, so there isn't a noticable difference. Otherwise you'll end up with a non-visible fbcon, because it continues to run on ramfb whereas qemu switched over to the GPU because the native linux driver initialized the display.

xorg/wayland will show up on the GPU in any case because they prefer drm over fbdev, so they wouldn't run on efifb.

Not tested yet
--------------

ARM.

ramfb -> gpu handover with windows guests (only ramfb-testdev so far).

enjoy,
Gerd

Gerd Hoffmann (7):
[testing] update bios, add vgabios-ramfb
[testing] add ovmf build with ramfb support
hw/display: add ramfb, a simple boot framebuffer living in guest ram hw/display: add ramfb-testdev
hw/display: add virtio-ramfb
hw/vfio/display: add ramfb support
[wip] hw/display: add qxl-ramfb

 hw/display/qxl.h              |   2 +
 include/hw/display/ramfb.h    |   8 +++
 include/hw/vfio/vfio-common.h |   2 +
 hw/display/qxl.c              |  47 +++++++++++--
 hw/display/ramfb-testdev.c    |  96 +++++++++++++++++++++++++++
 hw/display/ramfb.c            |  95 +++++++++++++++++++++++++++
 hw/display/virtio-ramfb.c     | 149 ++++++++++++++++++++++++++++++++++++++++++
 hw/vfio/display.c             |  10 +++
 hw/vfio/pci.c                 |  15 +++++
 ui/spice-display.c            |   6 ++
 hw/display/Makefile.objs      |   5 +-
 pc-bios/OVMF-ramfb.fd         | Bin 0 -> 2097152 bytes
 pc-bios/bios-256k.bin         | Bin 262144 -> 262144 bytes
 pc-bios/bios.bin              | Bin 131072 -> 131072 bytes
 pc-bios/vgabios-ramfb.bin     | Bin 0 -> 28160 bytes
 15 files changed, 430 insertions(+), 5 deletions(-)
 create mode 100644 include/hw/display/ramfb.h
 create mode 100644 hw/display/ramfb-testdev.c
 create mode 100644 hw/display/ramfb.c
 create mode 100644 hw/display/virtio-ramfb.c
 create mode 100644 pc-bios/OVMF-ramfb.fd
 create mode 100644 pc-bios/vgabios-ramfb.bin
Signature · 1 line
2.9.3
#1 lore raw

PATCH v2 1/7 update bios, add vgabios-ramfb

source code: https://www.kraxe.org/cgit/seabios/log/?h=ramfb

---
 pc-bios/bios-256k.bin     | Bin 262144 -> 262144 bytes
 pc-bios/bios.bin          | Bin 131072 -> 131072 bytes
 pc-bios/vgabios-ramfb.bin | Bin 0 -> 28160 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/vgabios-ramfb.bin
pc-bios/bios-256k.bin binary +0 -0
index 0061dc99288bee61e60e31d1e24a52b97b0c5fb6..3d279529d6106c8577f4d205cc8d3c532e5f8431 100644
GIT binary patch
pc-bios/bios.bin binary +0 -0
index 69bb8635ae36e95f3b066ae16ff9d44e8a3665ba..7cb8849f44d37535bf6a07d780fbfd9aa0e3b69e 100644
GIT binary patch
pc-bios/vgabios-ramfb.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..131f96b70e56d089f7fd941b1b81bc0f1aeaaab1
GIT binary patch
Signature · 1 line
2.9.3
#2 lore raw

PATCH v2 2/7 add ovmf build with ramfb support

In reply to Gerd Hoffmann

source code: https://github.com/kraxel/edk2/commits/ramfb

---
 pc-bios/OVMF-ramfb.fd | Bin 0 -> 2097152 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/OVMF-ramfb.fd
pc-bios/OVMF-ramfb.fd new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..84d9c4576b6543e2836d14b7dc8650b51473fc34
GIT binary patch
Signature · 1 line
2.9.3
#3 lore raw

PATCH v2 3/7 hw/display: add ramfb, a simple boot framebuffer living in guest ram

In reply to Gerd Hoffmann

The boot framebuffer is expected to be configured by the firmware, so it uses fw_cfg as interface. Initialization goes as follows:

(1) Check whenever etc/ramfb is present.
(2) Allocate framebuffer from RAM.
(3) Fill struct RAMFBCfg, write it to etc/ramfb.

Done. You can write stuff to the framebuffer now, and it should appear automagically on the screen.

Note that this isn't very efficient because it does a full display update on each refresh. No dirty tracking. Dirty tracking would have to be active for the whole ram slot, so that wouldn't be very efficient either. So it is *really* intended to be only active for a short time at boot, before the guest loaded the drivers for the real display hardware.

This is the ramfb core code. Some windup is needed for display devices which want have a ramfb boot display.

---
 include/hw/display/ramfb.h |  8 ++++
 hw/display/ramfb.c         | 95 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/display/Makefile.objs   |  2 +
 3 files changed, 105 insertions(+)
 create mode 100644 include/hw/display/ramfb.h
 create mode 100644 hw/display/ramfb.c
include/hw/display/ramfb.h new file +8 -0
new file mode 100644
index 0000000000..f3a772e99e
@@ -0,0 +1,8 @@
+#ifndef RAMFB_H
+#define RAMFB_H
+
+typedef struct RAMFBState RAMFBState;
+void ramfb_display_update(QemuConsole *con, RAMFBState *s);
+RAMFBState *ramfb_setup(Error **errp);
+
+#endif /* RAMFB_H */
hw/display/ramfb.c new file +95 -0

95 lines not on this page · raw message

hw/display/Makefile.objs +2 -0
index 3c7c75b94d..fae17fd5ea 100644
@@ -1,3 +1,5 @@
+common-obj-y += ramfb.o
+
 common-obj-$(CONFIG_ADS7846) += ads7846.o
 common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
 common-obj-$(CONFIG_G364FB) += g364fb.o
Signature · 1 line
2.9.3
#4 lore raw

PATCH v2 4/7 hw/display: add ramfb-testdev

In reply to Gerd Hoffmann

Standalone device using ramfb. Intended for testing only. Offers optional logging of vga port access, for debugging purposes.

---
 hw/display/ramfb-testdev.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/display/Makefile.objs   |  1 +
 2 files changed, 97 insertions(+)
 create mode 100644 hw/display/ramfb-testdev.c
hw/display/ramfb-testdev.c new file +96 -0
new file mode 100644
index 0000000000..1e65cf4957
@@ -0,0 +1,96 @@
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/loader.h"
+#include "hw/isa/isa.h"
+#include "hw/display/ramfb.h"
+#include "ui/console.h"
+#include "sysemu/sysemu.h"
+
+#define TYPE_RAMFB "ramfb-testdev"
+#define RAMFB(obj) OBJECT_CHECK(ISARAMFBState, (obj), TYPE_RAMFB)
+
+typedef struct ISARAMFBState {
+    ISADevice parent_obj;
+    QemuConsole *con;
+    RAMFBState *state;
+    PortioList vga_port_list;
+    bool vgalog;
+} ISARAMFBState;
+
+/* log vga port activity, for trouble-shooting purposes */
+static uint32_t vga_log_read(void *opaque, uint32_t addr)
+{
+    fprintf(stderr, "%s: port 0x%x\n", __func__, addr);
+    return -1;
+}
+
+static void vga_log_write(void *opaque, uint32_t addr, uint32_t val)
+{
+    fprintf(stderr, "%s: port 0x%x, value 0x%x\n", __func__, addr, val);
+}
+
+static const MemoryRegionPortio vga_portio_list[] = {
+    { 0x04,  2, 1, .read = vga_log_read, .write = vga_log_write }, /* 3b4 */
+    { 0x0a,  1, 1, .read = vga_log_read, .write = vga_log_write }, /* 3ba */
+    { 0x10, 16, 1, .read = vga_log_read, .write = vga_log_write }, /* 3c0 */
+    { 0x24,  2, 1, .read = vga_log_read, .write = vga_log_write }, /* 3d4 */
+    { 0x2a,  1, 1, .read = vga_log_read, .write = vga_log_write }, /* 3da */
+    PORTIO_END_OF_LIST(),
+};
+
+static void display_update_wrapper(void *dev)
+{
+    ISARAMFBState *ramfb = RAMFB(dev);
+
+    if (0 /* native driver active */) {
+        /* non-test device would run native display update here */;
+    } else {
+        ramfb_display_update(ramfb->con, ramfb->state);
+    }
+}
+
+static const GraphicHwOps wrapper_ops = {
+    .gfx_update = display_update_wrapper,
+};
+
+static void ramfb_realizefn(DeviceState *dev, Error **errp)
+{
+    ISARAMFBState *ramfb = RAMFB(dev);
+
+    ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
+    ramfb->state = ramfb_setup(errp);
+
+    if (ramfb->vgalog) {
+        isa_register_portio_list(ISA_DEVICE(dev), &ramfb->vga_port_list,
+                                 0x3b0, vga_portio_list, NULL, "log-vga");
+    }
+}
+
+static Property ramfb_properties[] = {
+    DEFINE_PROP_BOOL("vgalog", struct ISARAMFBState, vgalog, false),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void ramfb_class_initfn(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
+    dc->realize = ramfb_realizefn;
+    dc->props = ramfb_properties;
+    dc->desc = "ram framebuffer test device";
+}
+
+static const TypeInfo ramfb_info = {
+    .name          = TYPE_RAMFB,
+    .parent        = TYPE_ISA_DEVICE,
+    .instance_size = sizeof(ISARAMFBState),
+    .class_init    = ramfb_class_initfn,
+};
+
+static void ramfb_register_types(void)
+{
+    type_register_static(&ramfb_info);
+}
+
+type_init(ramfb_register_types)
hw/display/Makefile.objs +1 -0
index fae17fd5ea..07d2f48782 100644
@@ -1,4 +1,5 @@
 common-obj-y += ramfb.o
+common-obj-$(CONFIG_VGA_ISA) += ramfb-testdev.o
 
 common-obj-$(CONFIG_ADS7846) += ads7846.o
 common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
Signature · 1 line
2.9.3
#5 lore raw

PATCH v2 5/7 hw/display: add virtio-ramfb

In reply to Gerd Hoffmann

Like virtio-vga, but using ramfb instead of legacy vga.

---
 hw/display/virtio-ramfb.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/display/Makefile.objs  |   2 +-
 2 files changed, 150 insertions(+), 1 deletion(-)
 create mode 100644 hw/display/virtio-ramfb.c
hw/display/virtio-ramfb.c new file +149 -0
new file mode 100644
index 0000000000..7611c16d39
@@ -0,0 +1,149 @@
+#include "qemu/osdep.h"
+#include "hw/hw.h"
+#include "hw/pci/pci.h"
+#include "ui/console.h"
+#include "hw/virtio/virtio-pci.h"
+#include "hw/display/ramfb.h"
+#include "qapi/error.h"
+
+/*
+ * virtio-vga: This extends VirtioPCIProxy.
+ */
+#define TYPE_VIRTIO_RAMFB "virtio-ramfb"
+#define VIRTIO_RAMFB(obj) \
+        OBJECT_CHECK(VirtIORAMFB, (obj), TYPE_VIRTIO_RAMFB)
+
+typedef struct VirtIORAMFB {
+    VirtIOPCIProxy parent_obj;
+    VirtIOGPU      vdev;
+    RAMFBState     *ramfb;
+} VirtIORAMFB;
+
+static void virtio_ramfb_invalidate_display(void *opaque)
+{
+    VirtIORAMFB *vramfb = opaque;
+
+    if (vramfb->vdev.enable) {
+        virtio_gpu_ops.invalidate(&vramfb->vdev);
+    }
+}
+
+static void virtio_ramfb_update_display(void *opaque)
+{
+    VirtIORAMFB *vramfb = opaque;
+    VirtIOGPU *g = &vramfb->vdev;
+
+    if (vramfb->vdev.enable) {
+        virtio_gpu_ops.gfx_update(&vramfb->vdev);
+    } else {
+        ramfb_display_update(g->scanout[0].con, vramfb->ramfb);
+    }
+}
+
+static int virtio_ramfb_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
+{
+    VirtIORAMFB *vramfb = opaque;
+
+    if (virtio_gpu_ops.ui_info) {
+        return virtio_gpu_ops.ui_info(&vramfb->vdev, idx, info);
+    }
+    return -1;
+}
+
+static void virtio_ramfb_gl_block(void *opaque, bool block)
+{
+    VirtIORAMFB *vramfb = opaque;
+
+    if (virtio_gpu_ops.gl_block) {
+        virtio_gpu_ops.gl_block(&vramfb->vdev, block);
+    }
+}
+
+static const GraphicHwOps virtio_ramfb_ops = {
+    .invalidate = virtio_ramfb_invalidate_display,
+    .gfx_update = virtio_ramfb_update_display,
+    .ui_info = virtio_ramfb_ui_info,
+    .gl_block = virtio_ramfb_gl_block,
+};
+
+static const VMStateDescription vmstate_virtio_ramfb = {
+    .name = "virtio-ramfb",
+    .version_id = 2,
+    .minimum_version_id = 2,
+    .fields = (VMStateField[]) {
+        /* no pci stuff here, saving the virtio device will handle that */
+        /* FIXME */
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+/* RAMFB device wrapper around PCI device around virtio GPU */
+static void virtio_ramfb_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+    VirtIORAMFB *vramfb = VIRTIO_RAMFB(vpci_dev);
+    VirtIOGPU *g = &vramfb->vdev;
+    Error *err = NULL;
+    int i;
+
+    /* init virtio bits */
+    qdev_set_parent_bus(DEVICE(g), BUS(&vpci_dev->bus));
+    virtio_pci_force_virtio_1(vpci_dev);
+    object_property_set_bool(OBJECT(g), true, "realized", &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
+
+    /* add stdramfb mmio regions */
+    vramfb->ramfb = ramfb_setup(errp);
+    graphic_console_set_hwops(g->scanout[0].con, &virtio_ramfb_ops, vramfb);
+
+    for (i = 0; i < g->conf.max_outputs; i++) {
+        object_property_set_link(OBJECT(g->scanout[i].con),
+                                 OBJECT(vpci_dev),
+                                 "device", errp);
+    }
+}
+
+static Property virtio_ramfb_properties[] = {
+    DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_ramfb_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+    PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+
+    set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
+    dc->props = virtio_ramfb_properties;
+    dc->vmsd = &vmstate_virtio_ramfb;
+    dc->hotpluggable = false;
+
+    k->realize = virtio_ramfb_realize;
+    pcidev_k->class_id = PCI_CLASS_DISPLAY_OTHER;
+}
+
+static void virtio_ramfb_inst_initfn(Object *obj)
+{
+    VirtIORAMFB *dev = VIRTIO_RAMFB(obj);
+
+    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+                                TYPE_VIRTIO_GPU);
+}
+
+static TypeInfo virtio_ramfb_info = {
+    .name          = TYPE_VIRTIO_RAMFB,
+    .parent        = TYPE_VIRTIO_PCI,
+    .instance_size = sizeof(struct VirtIORAMFB),
+    .instance_init = virtio_ramfb_inst_initfn,
+    .class_init    = virtio_ramfb_class_init,
+};
+
+static void virtio_ramfb_register_types(void)
+{
+    type_register_static(&virtio_ramfb_info);
+}
+
+type_init(virtio_ramfb_register_types)
hw/display/Makefile.objs +1 -1
index 07d2f48782..e71d9d2ca6 100644
@@ -37,7 +37,7 @@ obj-$(CONFIG_VGA) += vga.o
 common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o
 
 obj-$(CONFIG_VIRTIO) += virtio-gpu.o virtio-gpu-3d.o
-obj-$(CONFIG_VIRTIO_PCI) += virtio-gpu-pci.o
+obj-$(CONFIG_VIRTIO_PCI) += virtio-gpu-pci.o virtio-ramfb.o
 obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
 virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
 virtio-gpu.o-libs += $(VIRGL_LIBS)
Signature · 1 line
2.9.3
#6 lore raw

PATCH v2 6/7 hw/vfio/display: add ramfb support

In reply to Gerd Hoffmann

So we have a boot display when using a vgpu as primary display.

Use vfio-pci-ramfb instead of vfio-pci to enable it.

---
 include/hw/vfio/vfio-common.h |  2 ++
 hw/vfio/display.c             | 10 ++++++++++
 hw/vfio/pci.c                 | 15 +++++++++++++++
 3 files changed, 27 insertions(+)
include/hw/vfio/vfio-common.h +2 -0
index d9360148e6..c8841a75c0 100644
@@ -27,6 +27,7 @@
 #include "qemu/queue.h"
 #include "qemu/notify.h"
 #include "ui/console.h"
+#include "hw/display/ramfb.h"
 #ifdef CONFIG_LINUX
 #include <linux/vfio.h>
 #endif
@@ -153,6 +154,7 @@ typedef struct VFIODMABuf {
 
 typedef struct VFIODisplay {
     QemuConsole *con;
+    RAMFBState *ramfb;
     struct {
         VFIORegion buffer;
         DisplaySurface *surface;
hw/vfio/display.c +10 -0
index 7d727ce910..b172fd408a 100644
@@ -124,6 +124,9 @@ static void vfio_display_dmabuf_update(void *opaque)
 
     primary = vfio_display_get_dmabuf(vdev, DRM_PLANE_TYPE_PRIMARY);
     if (primary == NULL) {
+        if (dpy->ramfb) {
+            ramfb_display_update(dpy->con, dpy->ramfb);
+        }
         return;
     }
 
@@ -181,6 +184,8 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp)
     vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
                                           &vfio_display_dmabuf_ops,
                                           vdev);
+    if (strcmp(object_get_typename(OBJECT(vdev)), "vfio-pci-ramfb") == 0)
+        vdev->dpy->ramfb = ramfb_setup(errp);
     return 0;
 }
 
@@ -217,6 +222,9 @@ static void vfio_display_region_update(void *opaque)
         return;
     }
     if (!plane.drm_format || !plane.size) {
+        if (dpy->ramfb) {
+            ramfb_display_update(dpy->con, dpy->ramfb);
+        }
         return;
     }
     format = qemu_drm_format_to_pixman(plane.drm_format);
@@ -289,6 +297,8 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp)
     vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
                                           &vfio_display_region_ops,
                                           vdev);
+    if (strcmp(object_get_typename(OBJECT(vdev)), "vfio-pci-ramfb") == 0)
+        vdev->dpy->ramfb = ramfb_setup(errp);
     return 0;
 }
 
hw/vfio/pci.c +15 -0
index b9bc6cd310..7408992388 100644
@@ -3224,9 +3224,24 @@ static const TypeInfo vfio_pci_dev_info = {
     },
 };
 
+static void vfio_pci_ramfb_dev_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->hotpluggable = false;
+}
+
+static const TypeInfo vfio_pci_ramfb_dev_info = {
+    .name = "vfio-pci-ramfb",
+    .parent = "vfio-pci",
+    .instance_size = sizeof(VFIOPCIDevice),
+    .class_init = vfio_pci_ramfb_dev_class_init,
+};
+
 static void register_vfio_pci_dev_type(void)
 {
     type_register_static(&vfio_pci_dev_info);
+    type_register_static(&vfio_pci_ramfb_dev_info);
 }
 
 type_init(register_vfio_pci_dev_type)
Signature · 1 line
2.9.3
#7 lore raw

PATCH v2 7/7 hw/display: add qxl-ramfb

In reply to Gerd Hoffmann

Like qxl-vga, but using ramfb instead of legacy vga.

NOT WORKING YET.

Also: Hackish proof-of-concept, with debug msgs.

---
 hw/display/qxl.h   |  2 ++
 hw/display/qxl.c   | 47 +++++++++++++++++++++++++++++++++++++++++++----
 ui/spice-display.c |  6 ++++++
 3 files changed, 51 insertions(+), 4 deletions(-)
hw/display/qxl.h +2 -0
index 089696ef62..7bfdf429bf 100644
@@ -5,6 +5,7 @@
 
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
+#include "hw/display/ramfb.h"
 #include "vga_int.h"
 #include "qemu/thread.h"
 
@@ -31,6 +32,7 @@ enum qxl_mode {
 
 typedef struct PCIQXLDevice {
     PCIDevice          pci;
+    RAMFBState         *ramfb;
     PortioList         vga_port_list;
     SimpleSpiceDisplay ssd;
     int                id;
hw/display/qxl.c +43 -4

88 lines not on this page · raw message

ui/spice-display.c +6 -0
index fe734821dd..c8082b0649 100644
@@ -86,6 +86,9 @@ void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
                                        QXLDevSurfaceCreate *surface,
                                        qxl_async_io async)
 {
+    fprintf(stderr, "%s: %dx%d, %lx, %s\n", __func__,
+            surface->width, surface->height, (unsigned long)surface->mem,
+            (surface->group_id == MEMSLOT_GROUP_HOST) ? "host" : "guest");
     trace_qemu_spice_create_primary_surface(ssd->qxl.id, id, surface, async);
     if (async != QXL_SYNC) {
         spice_qxl_create_primary_surface_async(&ssd->qxl, id, surface,
@@ -310,6 +313,7 @@ void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd)
 {
     QXLDevMemSlot memslot;
 
+    fprintf(stderr, "%s:\n", __func__);
     memset(&memslot, 0, sizeof(memslot));
     memslot.slot_group_id = MEMSLOT_GROUP_HOST;
     memslot.virt_end = ~0;
@@ -343,6 +347,8 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)
     surface.mem        = (uintptr_t)ssd->buf;
     surface.group_id   = MEMSLOT_GROUP_HOST;
 
+    fprintf(stderr, "%s: %dx%d @ %p\n", __func__,
+            surface.width, surface.height, ssd->buf);
     qemu_spice_create_primary_surface(ssd, 0, &surface, QXL_SYNC);
 }
 
Signature · 1 line
2.9.3
#8 lore raw
In reply to Gerd Hoffmann

Adding Ard and Marc, and keeping the context undisturbed for his sake. Comments at the bottom.

Quoted 152 lines · Gerd Hoffmann

Hi,

Ok folks, here is a experimental patch series for a legacy free boot framebuffer. If you want play with it I recommend getting the bits from

https://www.kraxel.org/cgit/qemu/log/?h=sirius/ramfb

because they come with an updated seabios and a new vgabios rom and an experimental OVMF build.

Functional overview
-------------------

The boot framebuffer is expected to be configured by the firmware, so it uses fw_cfg as interface. Initialization goes as follows:

(1) Check whenever etc/ramfb is present.
(2) Allocate framebuffer from RAM.
(3) Fill struct RAMFBCfg, write it to etc/ramfb.

Done. You can write stuff to the framebuffer now, and it should appear automagically on the screen.

Note that this isn't very efficient because it does a full display update on each refresh. No dirty tracking. Dirty tracking would have to be active for the whole ram slot, so that wouldn't be very efficient either. So it is *really* intended to be only active for a short time at boot, before the guest loaded the drivers for the real display hardware.

Firmware support -- seabios
---------------------------

seavgabios is able to emulate vga text mode on top of a framebuffer, for coreboot native graphics initialialization. Which works fine for everything which writes text using the vgabios interface (basically everyhing which works with sgabios).

So I hacked that up to work with ramfb. Right now it's proof-of-concept code with too much cut+paste, so it will clearly need a bunch of cleanups if this approach turns out to be workable. Look here:

https://www.kraxe.org/cgit/seabios/log/?h=ramfb

Firmware support -- edk2
------------------------

There is a EFI driver too. Likewise a hackish proof-of-concept thing, clearly not in a mergeable state, but good enough for playing. Note that the build disables QemuVideoDxe and VirtoGpu drivers, so ramfb is the only supported display. Code is here:

https://github.com/kraxel/edk2/commits/ramfb

Firmware blob is in pc-bios/OVMF-ramfb.fd, to be used with -bios.

So, how to play?
----------------

There is ramfb-testdev. Standalone device, for testing purposes. Also can listen on vga ports and logs any access, so we can see the bad boys. Use "qemu -vga none -device ramfb-testdev". Add "vgalog=on" to watch guests accessing vga registers.

There is virtio-ramfb. Simliar to virtio-vga, but using ramfb instead of adding vga compatibility. Shows how you can wire up ramfb support to some display device. Unlike virtio-vga it should work fine on arm. Use "qemu -vga none -device virtio-ramfb" for this one.

Tried to add qxl-ramfb, for windows guest tests, but that doesn't work yet. Don't use, unless you want help debugging ;)

There is virtio-pci-ramfb, which provides boot display support to vgpu devices.

In general using UEFI works better than BIOS, because guests don't expect legacy vga being present then.

What works?
-----------

Both windows and linux UEFI guests handle the ramfb GOP just fine.

BIOS boot loaders for linux all use vgabios calls for text mode, so they show up just fine. Also ipxe, seabios itself of course. So you can boot up your linux guest. vesafb works too.

What doesn't work?
------------------

vgacon (direct vga hardware access). Linux boots just fine nevertheless, the only effect is that you don't see any boot messages until the drm driver loads.

Windows in BIOS mode. Boot logo shows up just fine. But at some point windows does lots of vga register accesses (even though it sets the video mode via vesa bios interface) and appears to be unhappy that things don't work as expected because there is no vga hardware emulation.

Known issues
------------

Handover from ramfb-backed efifb to the native linux driver is tricky. Usually efifb gets kicked out when the native driver loads because of overlapping ressources. With efifb being in RAM instead of using a GPU PCI bar this doesn't happen though, so you'll end up with two framebuffer devices.

In case vgaarb classifies the GPU as primary display device fbcon will switch all VTs over to the framebuffer device of the real GPU, so there isn't a noticable difference. Otherwise you'll end up with a non-visible fbcon, because it continues to run on ramfb whereas qemu switched over to the GPU because the native linux driver initialized the display.

xorg/wayland will show up on the GPU in any case because they prefer drm over fbdev, so they wouldn't run on efifb.

Not tested yet
--------------

ARM.

ramfb -> gpu handover with windows guests (only ramfb-testdev so far).

enjoy,
Gerd

Gerd Hoffmann (7):
[testing] update bios, add vgabios-ramfb
[testing] add ovmf build with ramfb support
hw/display: add ramfb, a simple boot framebuffer living in guest ram hw/display: add ramfb-testdev
hw/display: add virtio-ramfb
hw/vfio/display: add ramfb support
[wip] hw/display: add qxl-ramfb

 hw/display/qxl.h              |   2 +
 include/hw/display/ramfb.h    |   8 +++
 include/hw/vfio/vfio-common.h |   2 +
 hw/display/qxl.c              |  47 +++++++++++--
 hw/display/ramfb-testdev.c    |  96 +++++++++++++++++++++++++++
 hw/display/ramfb.c            |  95 +++++++++++++++++++++++++++
 hw/display/virtio-ramfb.c     | 149 ++++++++++++++++++++++++++++++++++++++++++
 hw/vfio/display.c             |  10 +++
 hw/vfio/pci.c                 |  15 +++++
 ui/spice-display.c            |   6 ++
 hw/display/Makefile.objs      |   5 +-
 pc-bios/OVMF-ramfb.fd         | Bin 0 -> 2097152 bytes
 pc-bios/bios-256k.bin         | Bin 262144 -> 262144 bytes
 pc-bios/bios.bin              | Bin 131072 -> 131072 bytes
Quoted 9 lines
 pc-bios/vgabios-ramfb.bin     | Bin 0 -> 28160 bytes
 15 files changed, 430 insertions(+), 5 deletions(-)
 create mode 100644 include/hw/display/ramfb.h
 create mode 100644 hw/display/ramfb-testdev.c
 create mode 100644 hw/display/ramfb.c
 create mode 100644 hw/display/virtio-ramfb.c
 create mode 100644 pc-bios/OVMF-ramfb.fd
 create mode 100644 pc-bios/vgabios-ramfb.bin

I believe the only point of this device model (and the associated guest fw driver) is Windows-on-KVM/aarch64.

Would it be possible to make this stuff available for testing to the guy(s) who reported
<https://bugzilla.tianocore.org/show_bug.cgi?id=785>? (Registration in the TianoCore bugzilla is open, and once you log in, you can read email addresses, and/or comment on BZs of course.)

My earlier comments from
<http://mid.mail-archive.com/[email protected]>
apply, to the OVMF driver:

Quoted 7 lines

We should make sure that any device model that combines ramfb with another PCI display device is not matched by the OVMF driver for that PCI display device. IOW, we should use separate PCI IDs or subsystem IDs (I don't recall the details off-hand). I'd like to avoid messing with the current device probing code in OVMF. It just wouldn't be nice if two independent drivers (e.g. VirtioGpuDxe and a supposed "RamFbDxe") bound the two interfaces at the same time.

For example, virtio-vga is already problematic like this (it could be driven by both Virtio10Dxe+VirtioGpuDxe, and QemuVideoDxe), and it had to be hacked around in Virtio10Dxe. So I'm strongly in favor of a device model that clearly looks like one device and one device only to the full set of edk2 drivers, without cross-driver hacks.

(I'm not saying the "combined" device models should be removed, just that they should never be specified on the QEMU command line when the guest runs OVMF or ArmVirtQemu. Unless, of course, the combined device models had separate PCI-level identifiers from the original PCI display devices, so the fw would never be tempted to bind the PCI-based drivers to the combined devices.)

If Ard agrees that this device model & matching edk2 driver are a good thing for Windows-on-KVM/aarch64, I can help clean up QemuRamfbDxe. (It should be a DXE driver; it should start the device path with a VenHw() node; the memory we allocate should be reserved memory, not runtime memory etc...)

I vaguely remember that Ard argued against allocating (reserved) RAM for such purposes, because it is lost for the OS even after the OS switches to the native display driver.

BTW I recently re-read Marc's presentation on this:

http://mid.mail-archive.com/[email protected]
http://events17.linuxfoundation.org/sites/events/files/slides/slides_10.pdf

Has anyone tried the following idea from those: "perform cache maintenance from userspace in QEMU based on the dirty tracking bitmap that it uses for the VGA memory"?

Anyway, again, personally I'm fine with this, and I'm willing to help clean up the edk2 driver, if:
- Ard thinks it's a good thing for Windows-on-KVM/aarch64, and
- the device model stays out of the way of the existing edk2 display drivers (if that is solved with QEMU cmdline restrictions spelled out in documentation, that's fine).

Thanks
Laszlo

#9 lore raw

Hi,

Quoted 2 lines

I believe the only point of this device model (and the associated guest fw driver) is Windows-on-KVM/aarch64.

The other one is vgpu boot display.

And maybe killing vga emulation. Well, at least be able to not use it any more for UEFI guests. It's so much crazy stuff in vga emulation which isn't used by anyone these days (especially on uefi which doesn't even need vga text mode any more), except by guys who try to find holes in qemu for a host escape ...

Quoted 5 lines

Would it be possible to make this stuff available for testing to the guy(s) who reported
<https://bugzilla.tianocore.org/show_bug.cgi?id=785>? (Registration in the TianoCore bugzilla is open, and once you log in, you can read email addresses, and/or comment on BZs of course.)

I plan to look at arm, but that likely will happen after easter holidays (I'm offline next week).

Quoted 8 lines
Quoted 7 lines

We should make sure that any device model that combines ramfb with another PCI display device is not matched by the OVMF driver for that PCI display device. IOW, we should use separate PCI IDs or subsystem IDs (I don't recall the details off-hand). I'd like to avoid messing with the current device probing code in OVMF. It just wouldn't be nice if two independent drivers (e.g. VirtioGpuDxe and a supposed "RamFbDxe") bound the two interfaces at the same time.

Quoted 5 lines

For example, virtio-vga is already problematic like this (it could be driven by both Virtio10Dxe+VirtioGpuDxe, and QemuVideoDxe), and it had to be hacked around in Virtio10Dxe. So I'm strongly in favor of a device model that clearly looks like one device and one device only to the full set of edk2 drivers, without cross-driver hacks.

Yep, that is one of the things which still need to be sorted. The approach of the experimental firmware builds to just disable the QemuVideo and VirtioGpu drivers clearly doesn't fly for anything but the initial testing.

Giving out different IDs to the ramfb-enabled device variants would be one option. Not fully sure whenever that works for virtio-gpu. But given that there are no legacy/transitional virtio-gpu devices I think we are free to change the subsystem ID as we like.

cheers,
Gerd

#10 lore raw
Quoted 6 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

I believe the only point of this device model (and the associated guest fw driver) is Windows-on-KVM/aarch64.

The other one is vgpu boot display.

Interesting. I know nearly nothing about vgpu, but I hoped it'd come with its own UEFI GOP driver in the ROM BAR; similarly to assigned physical GPUs. I thought the oprom would originate from the physical GPU (with the help of the host kernel), out of which the vgpu was carved out.

Is that far-fetched?

Thanks
Laszlo

#11 lore raw
Quoted 11 lines · Laszlo Ersek
Quoted 6 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

I believe the only point of this device model (and the associated guest fw driver) is Windows-on-KVM/aarch64.

The other one is vgpu boot display.

Interesting. I know nearly nothing about vgpu, but I hoped it'd come with its own UEFI GOP driver in the ROM BAR; similarly to assigned physical GPUs.

Well. They don't ...

And even for assigned GPUs it is a PITA. For example the intel rom appears to have the pci slot hardcoded. You have to place the GPU in 00:02.0 (which it has on bare metal), otherwise the rom doesn't work. I would be *very* surprised if the rom is able to handle vgpu devices correctly. Beside that it isn't easy to get the rom in the first place, at least for intel, as it isn't stored in the rom bar but in the firmware flash.

cheers,
Gerd

#12 lore raw
Quoted 15 lines · Gerd Hoffmann
Quoted 11 lines · Laszlo Ersek
Quoted 6 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

I believe the only point of this device model (and the associated guest fw driver) is Windows-on-KVM/aarch64.

The other one is vgpu boot display.

Interesting. I know nearly nothing about vgpu, but I hoped it'd come with its own UEFI GOP driver in the ROM BAR; similarly to assigned physical GPUs.

Well. They don't ...

Quoted 7 lines

And even for assigned GPUs it is a PITA. For example the intel rom appears to have the pci slot hardcoded. You have to place the GPU in 00:02.0 (which it has on bare metal), otherwise the rom doesn't work. I would be *very* surprised if the rom is able to handle vgpu devices correctly. Beside that it isn't easy to get the rom in the first place, at least for intel, as it isn't stored in the rom bar but in the firmware flash.

Sure, IGD assignment is a different animal; I thought vgpu would follow the discrete PCI card assignment case.

Anyway, I just wanted to educate myself on this; thanks! Laszlo

#13 lore raw
In reply to Laszlo Ersek

Hi all,

Quoted 113 lines · Laszlo Ersek

Adding Ard and Marc, and keeping the context undisturbed for his sake. Comments at the bottom.

Quoted 109 lines · Gerd Hoffmann

Hi,

Ok folks, here is a experimental patch series for a legacy free boot framebuffer. If you want play with it I recommend getting the bits from

https://www.kraxel.org/cgit/qemu/log/?h=sirius/ramfb

because they come with an updated seabios and a new vgabios rom and an experimental OVMF build.

Functional overview
-------------------

The boot framebuffer is expected to be configured by the firmware, so it uses fw_cfg as interface. Initialization goes as follows:

(1) Check whenever etc/ramfb is present.
(2) Allocate framebuffer from RAM.
(3) Fill struct RAMFBCfg, write it to etc/ramfb.

Done. You can write stuff to the framebuffer now, and it should appear automagically on the screen.

Note that this isn't very efficient because it does a full display update on each refresh. No dirty tracking. Dirty tracking would have to be active for the whole ram slot, so that wouldn't be very efficient either. So it is *really* intended to be only active for a short time at boot, before the guest loaded the drivers for the real display hardware.

Firmware support -- seabios
---------------------------

seavgabios is able to emulate vga text mode on top of a framebuffer, for coreboot native graphics initialialization. Which works fine for everything which writes text using the vgabios interface (basically everyhing which works with sgabios).

So I hacked that up to work with ramfb. Right now it's proof-of-concept code with too much cut+paste, so it will clearly need a bunch of cleanups if this approach turns out to be workable. Look here:

https://www.kraxe.org/cgit/seabios/log/?h=ramfb

Firmware support -- edk2
------------------------

There is a EFI driver too. Likewise a hackish proof-of-concept thing, clearly not in a mergeable state, but good enough for playing. Note that the build disables QemuVideoDxe and VirtoGpu drivers, so ramfb is the only supported display. Code is here:

https://github.com/kraxel/edk2/commits/ramfb

Firmware blob is in pc-bios/OVMF-ramfb.fd, to be used with -bios.

So, how to play?
----------------

There is ramfb-testdev. Standalone device, for testing purposes. Also can listen on vga ports and logs any access, so we can see the bad boys. Use "qemu -vga none -device ramfb-testdev". Add "vgalog=on" to watch guests accessing vga registers.

There is virtio-ramfb. Simliar to virtio-vga, but using ramfb instead of adding vga compatibility. Shows how you can wire up ramfb support to some display device. Unlike virtio-vga it should work fine on arm. Use "qemu -vga none -device virtio-ramfb" for this one.

Tried to add qxl-ramfb, for windows guest tests, but that doesn't work yet. Don't use, unless you want help debugging ;)

There is virtio-pci-ramfb, which provides boot display support to vgpu devices.

In general using UEFI works better than BIOS, because guests don't expect legacy vga being present then.

What works?
-----------

Both windows and linux UEFI guests handle the ramfb GOP just fine.

BIOS boot loaders for linux all use vgabios calls for text mode, so they show up just fine. Also ipxe, seabios itself of course. So you can boot up your linux guest. vesafb works too.

What doesn't work?
------------------

vgacon (direct vga hardware access). Linux boots just fine nevertheless, the only effect is that you don't see any boot messages until the drm driver loads.

Windows in BIOS mode. Boot logo shows up just fine. But at some point windows does lots of vga register accesses (even though it sets the video mode via vesa bios interface) and appears to be unhappy that things don't work as expected because there is no vga hardware emulation.

Known issues
------------

Handover from ramfb-backed efifb to the native linux driver is tricky. Usually efifb gets kicked out when the native driver loads because of overlapping ressources. With efifb being in RAM instead of using a GPU PCI bar this doesn't happen though, so you'll end up with two framebuffer devices.

This exact issue occurs on actual hardware as well:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1755304

so if anyone has a clue how to address it, I'm all ears.

Quoted 116 lines
Quoted 43 lines

In case vgaarb classifies the GPU as primary display device fbcon will switch all VTs over to the framebuffer device of the real GPU, so there isn't a noticable difference. Otherwise you'll end up with a non-visible fbcon, because it continues to run on ramfb whereas qemu switched over to the GPU because the native linux driver initialized the display.

xorg/wayland will show up on the GPU in any case because they prefer drm over fbdev, so they wouldn't run on efifb.

Not tested yet
--------------

ARM.

ramfb -> gpu handover with windows guests (only ramfb-testdev so far).

enjoy,
Gerd

Gerd Hoffmann (7):
[testing] update bios, add vgabios-ramfb
[testing] add ovmf build with ramfb support
hw/display: add ramfb, a simple boot framebuffer living in guest ram hw/display: add ramfb-testdev
hw/display: add virtio-ramfb
hw/vfio/display: add ramfb support
[wip] hw/display: add qxl-ramfb

 hw/display/qxl.h              |   2 +
 include/hw/display/ramfb.h    |   8 +++
 include/hw/vfio/vfio-common.h |   2 +
 hw/display/qxl.c              |  47 +++++++++++--
 hw/display/ramfb-testdev.c    |  96 +++++++++++++++++++++++++++
 hw/display/ramfb.c            |  95 +++++++++++++++++++++++++++
 hw/display/virtio-ramfb.c     | 149 ++++++++++++++++++++++++++++++++++++++++++
 hw/vfio/display.c             |  10 +++
 hw/vfio/pci.c                 |  15 +++++
 ui/spice-display.c            |   6 ++
 hw/display/Makefile.objs      |   5 +-
 pc-bios/OVMF-ramfb.fd         | Bin 0 -> 2097152 bytes
 pc-bios/bios-256k.bin         | Bin 262144 -> 262144 bytes
 pc-bios/bios.bin              | Bin 131072 -> 131072 bytes
Quoted 9 lines
 pc-bios/vgabios-ramfb.bin     | Bin 0 -> 28160 bytes
 15 files changed, 430 insertions(+), 5 deletions(-)
 create mode 100644 include/hw/display/ramfb.h
 create mode 100644 hw/display/ramfb-testdev.c
 create mode 100644 hw/display/ramfb.c
 create mode 100644 hw/display/virtio-ramfb.c
 create mode 100644 pc-bios/OVMF-ramfb.fd
 create mode 100644 pc-bios/vgabios-ramfb.bin

I believe the only point of this device model (and the associated guest fw driver) is Windows-on-KVM/aarch64.

Would it be possible to make this stuff available for testing to the guy(s) who reported
<https://bugzilla.tianocore.org/show_bug.cgi?id=785>? (Registration in the TianoCore bugzilla is open, and once you log in, you can read email addresses, and/or comment on BZs of course.)

My earlier comments from
<http://mid.mail-archive.com/[email protected]>
apply, to the OVMF driver:

Quoted 7 lines

We should make sure that any device model that combines ramfb with another PCI display device is not matched by the OVMF driver for that PCI display device. IOW, we should use separate PCI IDs or subsystem IDs (I don't recall the details off-hand). I'd like to avoid messing with the current device probing code in OVMF. It just wouldn't be nice if two independent drivers (e.g. VirtioGpuDxe and a supposed "RamFbDxe") bound the two interfaces at the same time.

For example, virtio-vga is already problematic like this (it could be driven by both Virtio10Dxe+VirtioGpuDxe, and QemuVideoDxe), and it had to be hacked around in Virtio10Dxe. So I'm strongly in favor of a device model that clearly looks like one device and one device only to the full set of edk2 drivers, without cross-driver hacks.

(I'm not saying the "combined" device models should be removed, just that they should never be specified on the QEMU command line when the guest runs OVMF or ArmVirtQemu. Unless, of course, the combined device models had separate PCI-level identifiers from the original PCI display devices, so the fw would never be tempted to bind the PCI-based drivers to the combined devices.)

If Ard agrees that this device model & matching edk2 driver are a good thing for Windows-on-KVM/aarch64, I can help clean up QemuRamfbDxe. (It should be a DXE driver; it should start the device path with a VenHw() node; the memory we allocate should be reserved memory, not runtime memory etc...)

I vaguely remember that Ard argued against allocating (reserved) RAM for such purposes, because it is lost for the OS even after the OS switches to the native display driver.

BTW I recently re-read Marc's presentation on this:

http://mid.mail-archive.com/[email protected]
http://events17.linuxfoundation.org/sites/events/files/slides/slides_10.pdf

Has anyone tried the following idea from those: "perform cache maintenance from userspace in QEMU based on the dirty tracking bitmap that it uses for the VGA memory"?

Anyway, again, personally I'm fine with this, and I'm willing to help clean up the edk2 driver, if:
- Ard thinks it's a good thing for Windows-on-KVM/aarch64, and
- the device model stays out of the way of the existing edk2 display drivers (if that is solved with QEMU cmdline restrictions spelled out in documentation, that's fine).

Thanks
Laszlo

#14 lore raw
In reply to Laszlo Ersek

Hi,

Quoted 8 lines
Quoted 7 lines

We should make sure that any device model that combines ramfb with another PCI display device is not matched by the OVMF driver for that PCI display device. IOW, we should use separate PCI IDs or subsystem IDs (I don't recall the details off-hand). I'd like to avoid messing with the current device probing code in OVMF. It just wouldn't be nice if two independent drivers (e.g. VirtioGpuDxe and a supposed "RamFbDxe") bound the two interfaces at the same time.

Quoted 5 lines

For example, virtio-vga is already problematic like this (it could be driven by both Virtio10Dxe+VirtioGpuDxe, and QemuVideoDxe), and it had to be hacked around in Virtio10Dxe. So I'm strongly in favor of a device model that clearly looks like one device and one device only to the full set of edk2 drivers, without cross-driver hacks.

Hmm, trying to figure what we should do here best ...

First, ramfb has absolutely no connection to the "combined" device, other than that the combined devices have a single device only. From the guests point of view there is no difference between

(a) qemu -device virtio-ramfb, and
(b) qemu -device virtio-gpu-pci -device ramfb-testdev

On the host side the difference is that (a) is a single QemuConsole which shows virtio-gpu-pci once activated and ramfb otherwise, and
(b) is two QemuConsoles, so you can see both virtio-gpu-pci and ramfb side-by-side, for debugging purposes.

Second, one usecase is vgpu boot display. When combining ramfb with a (mdev) vgpu qemu can't modify the pci device. Which I think pretty much implies that adding a whitelist of pci devices to ramfb isn't going to fly. It would also have the drawback that -device ramfb-testdev will not work.

So lets do it the other way around? Blacklist devices which QemuVideoDxe and VirtioGpuDxe should *not* bind to? One way would be to just use different pci (subsystem) ids. Problem is that the guest os driver might not bind too then. So something else? Add a pci capability maybe? Other ideas?

cheers,
Gerd

#15 lore raw
Quoted 16 lines · Gerd Hoffmann

Hi,

Quoted 8 lines
Quoted 7 lines

We should make sure that any device model that combines ramfb with another PCI display device is not matched by the OVMF driver for that PCI display device. IOW, we should use separate PCI IDs or subsystem IDs (I don't recall the details off-hand). I'd like to avoid messing with the current device probing code in OVMF. It just wouldn't be nice if two independent drivers (e.g. VirtioGpuDxe and a supposed "RamFbDxe") bound the two interfaces at the same time.

Quoted 5 lines

For example, virtio-vga is already problematic like this (it could be driven by both Virtio10Dxe+VirtioGpuDxe, and QemuVideoDxe), and it had to be hacked around in Virtio10Dxe. So I'm strongly in favor of a device model that clearly looks like one device and one device only to the full set of edk2 drivers, without cross-driver hacks.

Quoted 4 lines

Hmm, trying to figure what we should do here best ...

First, ramfb has absolutely no connection to the "combined" device, other than that the combined devices have a single device only.

I think you mean "... single back-end only">

Quoted 10 lines

From
the guests point of view there is no difference between

(a) qemu -device virtio-ramfb, and
(b) qemu -device virtio-gpu-pci -device ramfb-testdev

On the host side the difference is that (a) is a single QemuConsole which shows virtio-gpu-pci once activated and ramfb otherwise, and
(b) is two QemuConsoles, so you can see both virtio-gpu-pci and ramfb side-by-side, for debugging purposes.

Exactly this "multiple frontends, single backend" connection is the problem. In UEFI, it is possible to establish a priority order between drivers that are all capable of binding the same controller ("handle"), but especially with ramfb + another (PCI) video frontend, it's the "handles" that are different. The "priority mechanism" would have no idea that the drivers cannot peacefully coexist, i.e. it's clueless about the (host side only) competition.

This is a problem because you display something on the one device, and the screen still shows the other, and users complain.

To my understanding, in Linux, special cross-driver hacks exist for this. For example, you boot with efifb (which is not a PCI device), and once an actual PCI display driver is configured, it is considered superior, and it supplants efifb.

On a tangent: on the host side, we already have to entirely separate I/O
consoles: some kind of graphics + emulated keyboard, plus serial. Those are always displayed in parallel -- not in two GUI toolkit windows, mind you, but it's never the case that one permanently "hides" the other. You can switch between them in virt-manager. Or, connect to the emulated serial port from a terminal window that is separate from the main graphics window.

If this was the case with ramfb + something else (i.e., writing to ramfb wouldn't be possible to "read back" for the other firmware driver, from the PCI framebuffer, and one could switch back and forth between ramfb display and PCI display on their desktop), then it would be OK for both firmware drivers to bind. Point is, the two back-ends need not occupy double the screen real estate; it would suffice if one didn't hide the other permanently, and users could switch at will.

Quoted 8 lines

Second, one usecase is vgpu boot display. When combining ramfb with a (mdev) vgpu qemu can't modify the pci device. Which I think pretty much implies that adding a whitelist of pci devices to ramfb isn't going to fly. It would also have the drawback that -device ramfb-testdev will not work.

So lets do it the other way around? Blacklist devices which QemuVideoDxe and VirtioGpuDxe should *not* bind to?

(It's a bit worse than that, actually -- VirtioGpuDxe does not consume EFI_PCI_IO_PROTOCOL, it consumes VIRTIO_DEVICE_PROTOCOL. VIRTIO_DEVICE_PROTOCOL is produced by the various virtio transport drivers we have; in this particular case, that is Virtio10Dxe. And it is Virtio10Dxe that consumes EFI_PCI_IO_PROTOCOL. So the mutual exclusion, for virtio-vga anyway, happens between QemuVideoDxe and Virtio10Dxe, on the controller handle that has a PciIo interface on it.)

Quoted 4 lines

One way would be to
just use different pci (subsystem) ids. Problem is that the guest os driver might not bind too then. So something else? Add a pci capability maybe? Other ideas?

I could imagine an OvmfPkg-specific PCI capability that said, "all PCI drivers in OvmfPkg that could otherwise drive this device, ignore it -- another (platform) driver in OvmfPkg will pick it up instead". This would resolve the competition between ramfb and whatever PCI device; ramfb would always win. (We should add the capability check to OvmfPkg's PCI drivers *no later* than introducing the ramfb driver though, so there be no "window" where both kinds bound.)

(Wrt. updating the PCI ID lists of guest OS drivers -- I guess that too could be viable, at least for Linux. I'm not really certain.)

Thanks
Laszlo

#16 lore raw

Hi,

Resuming an old discussion ...

Quoted 11 lines
Quoted 10 lines

From
the guests point of view there is no difference between

(a) qemu -device virtio-ramfb, and
(b) qemu -device virtio-gpu-pci -device ramfb-testdev

On the host side the difference is that (a) is a single QemuConsole which shows virtio-gpu-pci once activated and ramfb otherwise, and
(b) is two QemuConsoles, so you can see both virtio-gpu-pci and ramfb side-by-side, for debugging purposes.

Quoted 7 lines

Exactly this "multiple frontends, single backend" connection is the problem. In UEFI, it is possible to establish a priority order between drivers that are all capable of binding the same controller ("handle"), but especially with ramfb + another (PCI) video frontend, it's the "handles" that are different. The "priority mechanism" would have no idea that the drivers cannot peacefully coexist, i.e. it's clueless about the (host side only) competition.

Well, virtio-vga and qxl-vga are very simliar. They both are two-in-one devices, with legacy vga frontend and native (qxl/virtio) frontend sharing a single backend. When the guest initialized the native frontend the backend switches over from vga to native.

Quoted 2 lines

This is a problem because you display something on the one device, and the screen still shows the other, and users complain.

In ovmf the console splitter handles this reasonable well, firmware and bootloader simply show up on all outputs. Got the ramfb driver to the point where it joins the party properly.

The early boot phase (efifb active for linux) is more problematic. Only one of the GOPs is used, and it seems whatever GOP was registered first gets used. Try boot a fedora live iso with (a) "-device VGA -device secondary-vga" and (b) "-device secondary-vga -device VGA". efifb shows up on the first device (probably because it also is first in pci scan order). fbcon shows up on the VGA device. So for (b) the boot output switches the display when bochs-drm.ko loads.

Quoted 4 lines

To my understanding, in Linux, special cross-driver hacks exist for this. For example, you boot with efifb (which is not a PCI device), and once an actual PCI display driver is configured, it is considered superior, and it supplants efifb.

Linux does two things here.

First it checks ressource ranges, and if there is a conflict the firmware framebuffer (efifb in ovmf case, but vesafb and others on !x86 platforms are handled simliar) the firmware framebuffer driver is unregistered, only the native framebuffer driver remains active.

Second one device is picked as "primary". Basically linux tries to figure which device was activated by the firmware, to prefer that for fbcon. This is what makes linux switch over in case (b) above, because linux prefers VGA display devices here (-device secondary-vga is PCI_CLASS_DISPLAY_OTHER).

The logic to pick the "primary" display is arch-specific.

Quoted 4 lines

On a tangent: on the host side, we already have to entirely separate I/O
consoles: some kind of graphics + emulated keyboard, plus serial. Those are always displayed in parallel -- not in two GUI toolkit windows, mind you, but it's never the case that one permanently "hides" the other.

Well, try "View / Detach tab" in the gtk ui in case you want them side by side in two windows. SDL2 uses one window per console too.

Quoted 7 lines

If this was the case with ramfb + something else (i.e., writing to ramfb wouldn't be possible to "read back" for the other firmware driver, from the PCI framebuffer, and one could switch back and forth between ramfb display and PCI display on their desktop), then it would be OK for both firmware drivers to bind. Point is, the two back-ends need not occupy double the screen real estate; it would suffice if one didn't hide the other permanently, and users could switch at will.

I think it makes sense for the *-ramfb devices behave simliar to the existing *-vga devices, which are *not* user-switchable between frontends.

Given ovmf has virtio-gpu drivers I'm not sure we need virtio-ramfb at all.

Quoted 3 lines

I could imagine an OvmfPkg-specific PCI capability that said, "all PCI drivers in OvmfPkg that could otherwise drive this device, ignore it -- another (platform) driver in OvmfPkg will pick it up instead".

pci capability for ramfb could be useful (also for linux). I'll keep it in mind for now.

cheers,
Gerd

#17 lore raw
Quoted 23 lines · Gerd Hoffmann

Hi,

Resuming an old discussion ...

Quoted 11 lines
Quoted 10 lines

From
the guests point of view there is no difference between

(a) qemu -device virtio-ramfb, and
(b) qemu -device virtio-gpu-pci -device ramfb-testdev

On the host side the difference is that (a) is a single QemuConsole which shows virtio-gpu-pci once activated and ramfb otherwise, and
(b) is two QemuConsoles, so you can see both virtio-gpu-pci and ramfb side-by-side, for debugging purposes.

Quoted 7 lines

Exactly this "multiple frontends, single backend" connection is the problem. In UEFI, it is possible to establish a priority order between drivers that are all capable of binding the same controller ("handle"), but especially with ramfb + another (PCI) video frontend, it's the "handles" that are different. The "priority mechanism" would have no idea that the drivers cannot peacefully coexist, i.e. it's clueless about the (host side only) competition.

Quoted 4 lines

Well, virtio-vga and qxl-vga are very simliar. They both are two-in-one devices, with legacy vga frontend and native (qxl/virtio) frontend sharing a single backend. When the guest initialized the native frontend the backend switches over from vga to native.

True -- the difference is however, that the firmware doesn't even try to drive the native QXL frontend; it's clueless about it.

IOW, in the (QXL, VGA) two-in-one device, the firmware only sees VGA, because the firmware entirely (globally) ignores the QXL frontend; it has no driver for native QXL.

We couldn't do that for virtio-gpu (we really wanted to drive it for aarch64's sake), so the (virtio-gpu, VGA) two-in-one device required special hacks, to prevent double-binding.

[snip]

Quoted 6 lines
Quoted 3 lines

I could imagine an OvmfPkg-specific PCI capability that said, "all PCI drivers in OvmfPkg that could otherwise drive this device, ignore it -- another (platform) driver in OvmfPkg will pick it up instead".

pci capability for ramfb could be useful (also for linux). I'll keep it in mind for now.

Please do. :)

When you brought up the PCI capability last time in this thread (and I liked it), I realized that scanning for this new (likely "vendor") capability would require me to code up the *third* PCI caplist scanning loop in OVMF.

(Until that point we had implemented two such scans, one in the virtio-1.0 driver, because virtio-1.0 uses vendor capabilities liberally, and the other one in PciHotPlugInitDxe, which looks for the PCI resource reservation hints on bridges, for hotplug purposes.)

After I had added the 2nd such scan (in PciHotPlugInitDxe), Jordan suggested that we should rather use some helper library to save us the manual fiddling with the capability headers and contents.

So, when you brought up PCI capabilities the last time in this thread, the foreseeable "third scan" got stuck in my mind, and it ultimtely spurred me to write that helper library, originally suggested by Jordan. It's been upstream for a week now, and both Virtio10Dxe and PciHotPlugInitDxe have been converted to use it (commit range 4b8552d794e7..5685a243b6f8). (Thank you Ard again for the review.)

If you add the above-suggested

"hands off for platform drivers' sake"

capability in QEMU, I think we'll be able to locate and parse it cleanly in the OVMF PCI drivers that need to honor it.

Thanks!
Laszlo

#18 lore raw

Hi,

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I could imagine an OvmfPkg-specific PCI capability that said, "all PCI drivers in OvmfPkg that could otherwise drive this device, ignore it -- another (platform) driver in OvmfPkg will pick it up instead".

pci capability for ramfb could be useful (also for linux). I'll keep it in mind for now.

Please do. :)

Hmm, well. Virtio 1.0 uses vendor specific capabilities already to define the regions, and they don't have a fixed field saying "this is for virtio". So adding another vendor specific capability for something else on the same device is a bit problematic ...

cheers,
Gerd

#19 lore raw
Quoted 9 lines · Gerd Hoffmann

Hi,

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

I could imagine an OvmfPkg-specific PCI capability that said, "all PCI drivers in OvmfPkg that could otherwise drive this device, ignore it -- another (platform) driver in OvmfPkg will pick it up instead".

pci capability for ramfb could be useful (also for linux). I'll keep it in mind for now.

Quoted 6 lines
Quoted 1 line

Please do. :)

Hmm, well. Virtio 1.0 uses vendor specific capabilities already to define the regions, and they don't have a fixed field saying "this is for virtio". So adding another vendor specific capability for something else on the same device is a bit problematic ...

Can we invent a non-PCI method, e.g. fw_cfg, that tells QemuVideoDxe and Virtio10Dxe not to bind some PCI S/B/D/Fs? Something like:

(1) When the UEFI driver (QemuVideoDxe or Virtio10Dxe) is loaded, it looks up and caches the fw_cfg selector key (from the fw_cfg directory) for the fw_cfg file that exposes what S/B/D/Fs not to bind.

(2) When the UEFI driver is asked by BDS (Boot Device Selection) to state if it supports a specific controller handle, the driver (same as now) first checks if a PciIo protocol interface is available on the handle at all. If so, the driver selects the cached fw_cfg selector.

(3) When the key is selected for the first time ever, QEMU refreshes the contents of the fw_cfg file, with the S/B/D/Fs assigned to the combined devices. The ordering should be fine here, because in step (2), we first open a PciIo protocol interface (before selecting the fw_cfg key), and successfully opening a PciIo interface implies that PciBusDxe has enumerated the PCI(e) hierarchies and has assigned bus numbers to devices. The fw_cfg file would be padded at machine startup to a large enough size so that the regenerated contents fit.

I think this is similar to how ACPI is regenerated in QEMU, to reflect the resources assigned to PCI(e) devices in various AML aperture objects. (IIRC.)

(4) The UEFI driver reads (caches) the selected fw_cfg file into a memory buffer, calls PciIo->GetLocation(), then searches the buffer for a S/B/D/F match. If there's a match, then the driver returns EFI_UNSUPPORTED.

(5) Once the fw_cfg file is read (cached), it could be reused for deciding about further controller binding attempts (involving that driver), without any further fw_cfg traffic (in that driver anyway).

Thanks,
Laszlo

#20 lore raw
Quoted 12 lines · Laszlo Ersek
Quoted 11 lines · Gerd Hoffmann

Hi,

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I could imagine an OvmfPkg-specific PCI capability that said, "all PCI drivers in OvmfPkg that could otherwise drive this device, ignore it -- another (platform) driver in OvmfPkg will pick it up instead".

pci capability for ramfb could be useful (also for linux). I'll keep it in mind for now.

Please do. :)

Quoted 7 lines
Quoted 4 lines

Hmm, well. Virtio 1.0 uses vendor specific capabilities already to define the regions, and they don't have a fixed field saying "this is for virtio". So adding another vendor specific capability for something else on the same device is a bit problematic ...

Can we invent a non-PCI method, e.g. fw_cfg, that tells QemuVideoDxe and Virtio10Dxe not to bind some PCI S/B/D/Fs? Something like:

Well, from edk2 point of view Virtio10Dxe is the only problematic case because there is a is a native driver. For cirrus/stdvga a version with ramfb is rather pointless. A qxl-ramfb device might make sense, but QemuVideoDxe would ignore such a device like it ignores qxl today as it can only handle the vga mode of qxl-vga devices.

Also I'd prefer to provide informations (device foo has ramfb at <addr>) not instructions (please ignore device foo).

Maybe we should for now just scratch the idea of an virtio-ramfb device. Linux doesn't need it, and windows wouldn't use the virtio part of it so a standalone ramfb device would work equally well.

cheers,
Gerd

#21 lore raw
Quoted 18 lines · Gerd Hoffmann
Quoted 17 lines · Laszlo Ersek
Quoted 15 lines · Gerd Hoffmann

Hi,

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I could imagine an OvmfPkg-specific PCI capability that said, "all PCI drivers in OvmfPkg that could otherwise drive this device, ignore it -- another (platform) driver in OvmfPkg will pick it up instead".

pci capability for ramfb could be useful (also for linux). I'll keep it in mind for now.

Please do. :)

Hmm, well. Virtio 1.0 uses vendor specific capabilities already to define the regions, and they don't have a fixed field saying "this is for virtio". So adding another vendor specific capability for something else on the same device is a bit problematic ...

Quoted 6 lines
Quoted 2 lines

Can we invent a non-PCI method, e.g. fw_cfg, that tells QemuVideoDxe and Virtio10Dxe not to bind some PCI S/B/D/Fs? Something like:

Well, from edk2 point of view Virtio10Dxe is the only problematic case because there is a is a native driver. For cirrus/stdvga a version with ramfb is rather pointless.

Good catch; thinko on my part!

Quoted 3 lines

A qxl-ramfb device might make sense, but
QemuVideoDxe would ignore such a device like it ignores qxl today as it can only handle the vga mode of qxl-vga devices.

Indeed.

Quoted 6 lines

Also I'd prefer to provide informations (device foo has ramfb at <addr>) not instructions (please ignore device foo).

Maybe we should for now just scratch the idea of an virtio-ramfb device. Linux doesn't need it, and windows wouldn't use the virtio part of it so a standalone ramfb device would work equally well.

If that works for you, it works for me best!

Thanks!
Laszlo

#22 lore raw

Hi,

Quoted 5 lines
Quoted 3 lines

Maybe we should for now just scratch the idea of an virtio-ramfb device. Linux doesn't need it, and windows wouldn't use the virtio part of it so a standalone ramfb device would work equally well.

If that works for you, it works for me best!

Ok, pushed updated branches.

qemu (including seabios + ovmf blobs):
https://git.kraxel.org/cgit/qemu/log/?h=sirius/ramfb

edk2:
https://github.com/kraxel/edk2/commits/ramfb

seabios:
https://git.kraxel.org/cgit/seabios/log/?h=bochs

What is in there?

qemu:
-device ramfb
standalone ramfb device
-device virtio-ramfb
kept for now for testing, as discussed above no plans to merge this one for now.
-device vfio-pci-ramfb
boot display for vgpu devices.
bochs-display got a vgabios.

seabios:
support for bochs-display + rmafb added. For both of them vga text mode (at vgabios call level) is emulated by seabios inside the guest.

edk2:
QemuRamfbDxe driver, x86 wireup, incomplete arm wireup.

Notes on QemuRamfbDxe:

QemuRamfbDxe registers as VenHw device with a fresh generated uuid. The uuid should probably go to some header file, suggestions where to place it best?

QemuRamfbDxe registers a acpi devpath node for the gop protocol. It's appended to the VenHw path, but looks like that isn't enough to create it as child node of the VenHw device (according to devtree outout). Suggestions how to fix that? Still this is good enough for consplitter to accept the device.

The device path is added to the gPlatformConsole list, so consplitter will pick up the ramfb device even though it isn't a pci display device. The firmware display will show up on ramfb in addition to other display devices (if any). Is that approach ok? If so I'll do that for armvirt too.

thanks and happy playing,

Gerd

#23 lore raw
Quoted 2 lines · Gerd Hoffmann

edk2:
QemuRamfbDxe driver, x86 wireup, incomplete arm wireup.

I'm looking at the patches very cursorily right now:

Quoted 5 lines

Notes on QemuRamfbDxe:

QemuRamfbDxe registers as VenHw device with a fresh generated uuid. The uuid should probably go to some header file, suggestions where to place it best?

(1) Under "OvmfPkg/Include/Guid/". The file "VirtioMmioTransport.h" is a minimal example.

Please review commit 3765e030affb ("OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID", 2015-01-02) in its entirety though, as the OvmfPkg.dec file should be modified as well.

Quoted 5 lines

QemuRamfbDxe registers a acpi devpath node for the gop protocol. It's appended to the VenHw path, but looks like that isn't enough to create it as child node of the VenHw device (according to devtree outout). Suggestions how to fix that? Still this is good enough for consplitter to accept the device.

The UEFI Driver Writer's Guide, and the UEFI spec, treat this extensively, but let's save ourselves some time:

(2) Please flip the MODULE_TYPE of the driver to DXE_DRIVER, from UEFI_DRIVER. (This will also let you drop some of the other patches.)

(3) Try adding the following at the end of QemuRamfbDxe:

VOID *DevicePath;

...

gBS->OpenProtocol (

         RamfbHandle,
         &gEfiDevicePathProtocolGuid,
         &DevicePath,
         gImageHandle,
         GopHandle,
         EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
         );

See also iPXE commit d6817943d187 ("[efi] Install the HII config access protocol on a child of the SNP handle", 2016-07-08), especially the call to efi_child_add().

Quoted 1 line

The device path is added to the gPlatformConsole list,

Good idea.

Two notes on that:

(4) Once you add the venhw GUID as a standalone header file (see (1)), you won't need to duplicate the constants between patches. In "gQemuRamfbDevicePath", you'll be able to use the EFI_GUID structure initializer macro from the header file.

(5) Does it work if you replace ACPI_ADR_DISPLAY_TYPE_VGA with ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL? QemuVideoDxe uses the former, but VirtioGpuDxe uses the latter. Windows has some really obscure requirements dependent on "ACPI display type", if I remember correctly, and "external" looked the most robust when I last checked.

Quoted 3 lines

so consplitter will pick up the ramfb device even though it isn't a pci display device. The firmware display will show up on ramfb in addition to other display devices (if any). Is that approach ok?

Absolutely, that's what we want.

Quoted 1 line

If so I'll do that for armvirt too.

(6) No extra steps should be necessary for ArmVirtPkg; in the PlatformBootManagerBeforeConsole() function [ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c], we have

Quoted 7 lines

//
// Find all display class PCI devices (using the handles from the previous // step), and connect them non-recursively. This should produce a number of // child handles with GOPs on them.
//
FilterAndProcess (&gEfiPciIoProtocolGuid, IsPciDisplay, Connect);

Quoted 5 lines

//
// Now add the device path of all handles with GOP on them to ConOut and // ErrOut.
//
FilterAndProcess (&gEfiGraphicsOutputProtocolGuid, NULL, AddOutput);

The first call does not cover the new device, but that's fine: the new child handle with the GOP instance on it is produced by a DXE_DRIVER in its entry point function -- that is, not by a UEFI driver that follows the UEFI driver model --, hence it need not be connected by platform BDS explicitly. By the time BDS is entered in the first place, the GOP will exist already.

Therefore, the second call will simply pick up the devpath from the new child (GOP) handle automatically, and add it to both ConOut and ErrOut.

Does it not work for you?

Thanks
Laszlo

#24 lore raw

Hi,

Quoted 6 lines
Quoted 3 lines

QemuRamfbDxe registers as VenHw device with a fresh generated uuid. The uuid should probably go to some header file, suggestions where to place it best?

(1) Under "OvmfPkg/Include/Guid/". The file "VirtioMmioTransport.h" is a minimal example.

Ok.

Quoted 4 lines

(4) Once you add the venhw GUID as a standalone header file (see (1)), you won't need to duplicate the constants between patches. In "gQemuRamfbDevicePath", you'll be able to use the EFI_GUID structure initializer macro from the header file.

Sure.

Quoted 5 lines

(5) Does it work if you replace ACPI_ADR_DISPLAY_TYPE_VGA with ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL? QemuVideoDxe uses the former, but VirtioGpuDxe uses the latter. Windows has some really obscure requirements dependent on "ACPI display type", if I remember correctly, and "external" looked the most robust when I last checked.

I'll try.

Quoted 5 lines
Quoted 3 lines

so consplitter will pick up the ramfb device even though it isn't a pci display device. The firmware display will show up on ramfb in addition to other display devices (if any). Is that approach ok?

Absolutely, that's what we want.

Cool.

Quoted 8 lines
Quoted 1 line

If so I'll do that for armvirt too.

(6) No extra steps should be necessary for ArmVirtPkg; in the

Therefore, the second call will simply pick up the devpath from the new child (GOP) handle automatically, and add it to both ConOut and ErrOut.

Does it not work for you?

Didn't test arm at all yet, wanted to get x86 into shape first. I'll have a look as soon as I've fixed all the things listed above on x86.

thanks,
Gerd