Page MenuHomeFreeBSD

virtio_gpu: use an X8R8G8B8 resource on big-endian guests
Needs ReviewPublic

Authored by pkubaj on Mon, Sep 28, 9:07 AM.

Details

Reviewers
andrew
tuexen
adrian
Group Reviewers
PowerPC
Summary

The virtio-gpu resource formats are defined by byte order in memory, while vt(4) and the X server (through vt_fb and the fb mmap) write native 32-bit 0x00RRGGBB pixels into the shadow framebuffer. On a big-endian guest such as powerpc64 those pixels land in memory as 00 RR GG BB, which the host interprets under B8G8R8X8 with red and blue swapped and the padding byte taken as blue: white renders yellow and blue renders black.

Request X8R8G8B8 on big-endian guests instead, which is also what the Linux driver does (DRM_FORMAT_HOST_XRGB8888). Little-endian guests are unchanged.

Test Plan

Reproduced on a FreeBSD/powerpc64 (big-endian) 16.0-CURRENT QEMU pseries guest with a virtio-gpu-pci device, using graphics/virtio-gpu-qemu-kmod, whose resource creation code is identical to this driver's: a test program mapped the framebuffer through the console tty and drew red/green/blue/white bars plus a grey ramp. The host-side screenshot (virsh screenshot) showed green/red/black/yellow bars and a black-to-yellow ramp before the change and exact colours after it. The same test on a powerpc64le 15.1 guest renders correctly before and after.

The in-kernel driver itself was compile-tested as a module on powerpc64 and powerpc64le CURRENT (it is not part of GENERIC64), not runtime-tested.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped