Bochs Display (Video memory and output emulation)

Bochs Display is a software component of the Bochs emulator that intercepts guest system access to the video buffer and graphics ports, translating them into a raster window on the host, allowing you to see the virtual machine screen without a physical graphics card.

This mechanism is primarily used in debugging and embedded environments where maximum portability is important. It is in demand when developing bootloaders, educational OS kernels, and analyzing low-level code without reliance on hardware accelerators. Bochs Display is also used in systems without a graphical interface, with output redirected via VNC.

Typical Problems

The key limitation is extremely low performance due to software rendering of each frame. Issues often arise with refresh rate synchronization, leading to flickering. Incompatibilities occur with video modes using linear frame buffering (VBE/LFB), as well as artifacts when switching to protected mode without reinitializing the display.

How Bochs Display works

Bochs Display emulates a very simple video adapter, similar to the VGA standard, by interpreting register I/O operations. Each time the guest system accesses video memory or control ports, the emulator intercepts the request, recalculates the address in the host buffer, and updates the corresponding window. Unlike QEMU, which can use KVM with hardware virtualization and OpenGL, Bochs Display performs all work in the main CPU thread without acceleration. Compared to VirtualBox Guest Additions, which uses a paravirtual driver with memory sharing, Bochs uses a purely software fetch-decode-update loop, which gives absolute portability but limits the frame rate to a few hertz. This concept is similar to framebuffer emulation without DMA, where each pixel is calculated by the command interpreter.

Bochs Display functionality

  1. General operating logic. Bochs Display emulates a graphics card at the register and video memory level, completely isolating the guest OS from the physical GPU. The emulation is strictly sequential: each frame is generated by software rendering in the host RAM, without hardware acceleration.
  2. Supported video modes. The emulator supports standard VGA modes (text mode 80×25, graphics modes 320×200, 640×480) and extended VBE modes with color depths up to 32 bits per pixel. The user sets the resolution via configuration parameters, and the guest OS sees a fixed set of video modes.
  3. Video memory organization. The subsystem reserves a linear buffer in the emulator address space of up to 16 MB. Access to this buffer is done through memory-mapped I/O (MMIO). Each write operation to the buffer is immediately interpreted and recalculates the corresponding pixels of the output image.
  4. Hardware synchronization and refresh rate. Bochs Display does not depend on the actual scan rate of the host monitor. The emulator generates virtual vertical and horizontal sync pulses at a fixed frequency (default 60 Hz), managing the VGA status registers to ensure the guest OS driver works correctly.
  5. Frame buffering. The emulation uses a double buffering strategy: the front buffer is displayed on the screen, while the back buffer is filled by guest OS commands. Buffer switching occurs either at the guest request via the VBE register or when a virtual vertical blank occurs. This minimizes partial rendering artifacts.
  6. Palette management for 8-bit modes. For indexed color modes, Bochs Display emulates the Digital-to-Analog Converter (DAC) hardware. The guest OS writes up to 256 entries of 6 bits per RGB component, and the emulator immediately converts them into full-color pixels of the output image.
  7. Debugging interface for the graphics stack. Bochs Display provides a software interface for synchronous dumping of video memory contents and registers. The host system debugger can pause emulation and analyze the current frame pixel by pixel, which is useful for developing low-level graphics drivers.
  8. Text mode handling. In text mode, the emulator does not store a bitmap of characters but dynamically renders fonts from a built-in table. The video buffer contains character codes and attributes (color, blink). On each buffer change, only the changed area of the screen is redrawn.
  9. Configuration via bochsrc. The function is configured with directives: vga_update_interval (sets the frame update frequency in milliseconds), vga_memory (video memory size), and vga_model (choice between Cirrus or standard VGA). These parameters affect performance and compatibility.
  10. Features of Cirrus Logic CL-GD5446 emulation. When the extended model is selected, Bochs Display emulates specific linear address registers and bit block operations. Bit Block Transfers (BitBLT) are performed in software within the emulator loop, correctly handling overlapping memory regions.
  11. Non-volatile memory for VBE. The emulator saves information about the current video mode, linear buffer offset, and screen dimensions in special PCI configuration space registers. On a soft reset of the guest OS, these registers are not cleared, allowing bootloaders to preserve graphical state.
  12. Display interrupt handling. Bochs Display generates a hardware interrupt IRQ9 by default when a vertical blanking interval occurs. The guest OS can enable this option via the VGA control register, which is useful for programs that synchronize drawing with the vertical sync pulse.
  13. State monitoring function. The built-in logging mechanism outputs every write operation to video registers to the debug console, including address, value, and operation type. This allows analyzing the behavior of unknown drivers or malicious code without stopping the entire emulation.
  14. Interaction with network displays. Bochs Display can work in conjunction with the VNC remote protocol via a dedicated socket. In this configuration, the emulator does not create a local window but serializes the video buffer contents into the RFB stream, which is useful for headless server scenarios.
  15. Output image scaling. The host part of Bochs Display can bilinearly interpolate the output frame when scaling by a factor of 2, 3, or 4. This does not affect the state of the emulated registers: the guest OS continues to work at the original resolution, which is critical for testing video drivers.
  16. Rendering speed and optimizations. By default, each virtual line in the frame recalculates all pixels of the row. The optimized fast_vga_update mode caches unchanged blocks of video memory and skips their rendering, reducing host CPU load by up to 40% in static scenarios.
  17. I/O port emulation. Bochs Display correctly handles all VGA ports: 3B0h-3BBh and 3C0h-3DFh. Full support is implemented for the CRT Controller initialization sequence, including Horizontal Total, Vertical Total, and End of Display registers, ensuring compatibility with DOS applications.
  18. Bit-width limitations of operations. The emulator does not support 2D hardware accelerators (fill, scrolling beyond BitBLT). Any large area copy operation turns into a sequential read-modify-write by the main emulation CPU, which severely slows down complex graphics.
  19. Recovery after video mode reset. When receiving a controller reset command from the guest OS, Bochs Display instantly clears the video buffer with zeros, sets text mode 80×25, and resets the DAC palette to the default state. This process takes no longer than one virtual vertical blank cycle.
  20. SMP system compatibility. Bochs Display is thread-safe: all accesses to video registers from different virtual processors are serialized via a mutex at the PCI bus level. With parallel writes to video memory, data integrity is guaranteed, but performance scales linearly with the number of active cores due to locking.

Comparison of Bochs Display with alternatives

  • Bochs Display vs QEMU VGA. Bochs Display emulates a simple video mode with software rendering via basic BIOS functions, which is slow but predictable. QEMU VGA uses hardware acceleration (virtio-gpu, SPICE) and host graphics integration, providing high performance for guest OSes. Bochs Display is chosen for OS debugging, QEMU for everyday emulation.
  • VirtIO-GPU (Hardware-accelerated virtual GPU)
  • Bochs Display vs SeaBIOS framebuffer. Bochs Display is implemented as a separate logical screen inside the emulator, controlled via I/O ports, requiring no host video memory. SeaBIOS framebuffer uses a linear buffer with real access to the host frame, which is faster but dependent on BIOS emulation. Bochs Display is more cross-platform and simpler for low-level debugging.
  • Bochs Display vs SDL surface. Bochs Display renders pixels in the emulator RAM, then copies them to the host window through an abstraction layer (X11, Win32), adding delays. SDL surface directly locks a texture and provides hardware blitting, accelerating output. Bochs Display loses in FPS but guarantees strict operation sequencing, important for step-by-step graphics driver debugging.
  • Bochs Display vs Cirrus Logic. Bochs Display supports only basic 16 and 256 color modes without acceleration, ideal for kernel development. Cirrus Logic emulates SVGA with linear addressing and a hardware cursor, needed for older OSes (Windows 9x, QNX). Bochs Display wins in code simplicity, Cirrus in compatibility with real drivers.
  • SVGA (Generation of frame synchronization and raster scan)
  • Bochs Display vs VBE VESA. VBE offers high resolutions up to 1920×1080 via bank switching or a linear buffer, working on top of any VGA. Bochs Display is limited to 640x480x8 bit but does not require VBE support from the guest driver. The choice: VBE for emulating modern bootloaders (GRUB, Limine), Bochs Display for educational kernels with minimal video output.

OS and driver support

Bochs emulates several standard video cards such as Cirrus Logic CL-GD5446, for which built-in drivers exist in Linux, Windows 9x/NT, FreeBSD and other operating systems kernels. It also provides its own VBE interface for transferring the framebuffer to the guest OS without requiring driver modifications, using software rendering via the SDL or Win32 libraries.

Security

Because Bochs implements display logic entirely at the CPU and video memory emulation level within an isolated user process, any errors in emulating video modes or writing directly to the framebuffer cannot lead to malicious code execution on the host. The serialization mechanism for access to video registers eliminates race conditions in multithreading.

Logging

Bochs Display maintains a detailed log of all VGA I/O ports, video mode changes, framebuffer memory operations, and VBE extension calls, with configurable verbosity levels ranging from critical errors to tracing every raster scan line. Output is directed to a debug console or a timestamped file for analyzing video subsystem integrity.

Limitations

Bochs Display emulation is slow due to interpreting every pixel access through the CPU emulator. It lacks hardware 3D acceleration, graphics accelerators are limited to VBE 2.0 without support for modern VRAM paging, and resolution is constrained by the maximum host window size with no support for multi-monitor configurations in the emulated environment.

History and development

The Bochs project began graphics support with minimal VGA emulation in 1994, added Cirrus Logic and video mode debugging in 1998, integrated the SDL backend for cross-platform output by the 2000s, and modern versions from 2020 onward include experimental clipboard support via SPICE and hardware scaling, while maintaining backward compatibility with drivers from the early 1990s.