x86/video: Preserve the default VGA fallback for legacy modes
Subsystems (3)
PATCH v2 1/1 x86/video: Preserve the default VGA fallback for legacy modes
Commit 596b3678326d ("x86/video: Only fall back to vga_default_device() without screen info") made video_is_primary_device() rely exclusively on screen_info resources whenever any are available.
However, screen_info_resources() also returns legacy I/O and memory ranges for VGA text modes. These ranges are not PCI BARs, so pci_find_resource() does not find them and the default VGA fallback is skipped. As a result, no device is primary in VGA text mode.
On a SeaBIOS QEMU guest with bochs and VKMS, the boot VGA (bochs) loses its DRM boot_display attribute. VKMS registers fb0 and bochs registers fb1. VKMS is not a PCI device, so it is not primary either. With no primary device, fbcon keeps the console on fb0 and never remaps it to bochs. This can be checked with:
cat /sys/class/drm/card1/boot_display
stty -F /dev/tty1 size
Without the fix, boot_display is missing and tty1 is 48 rows by 128 columns. With it, boot_display contains 1 and tty1 is 50 rows by 160 columns. VKMS only makes the console part visible. Without VKMS, tty1 has the same size with and without the fix, but boot_display is still missing without it.
Use resource-based selection only for linear framebuffers. Fall back to vga_default_device() for legacy display modes, while keeping EFI and VESA framebuffer ownership authoritative.
---
Changes in v2:
- Explain in the commit message why no device is primary in text mode and what VKMS shows (Boris, Thomas).
- Add the Reviewed-by tags. No code change.
- v1: https://lore.kernel.org/all/[email protected]/
arch/x86/video/video-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/video/video-common.c +1 -1
@@ -45,7 +45,7 @@ bool video_is_primary_device(struct device *dev)#ifdef CONFIG_SCREEN_INFO numres =screen_info_resources (si, res,ARRAY_SIZE (res)); -if (numres >0 ) { +if (numres >0 &&__screen_info_has_lfb (screen_info_video_type (si))) {for (i =0 ; i < numres; ++i) {if (!(res[i].flags &IORESOURCE_MEM ))continue ;
base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 15 lines
Commit
596b3678326d("x86/video: Only fall back tovga_default_device()without screen info") madevideo_is_primary_device()rely exclusively onscreen_inforesources whenever any are available.However,
screen_info_resources()also returns legacy I/O and memory ranges for VGA text modes. These ranges are not PCI BARs, sopci_find_resource()does not find them and the default VGA fallback is skipped. As a result, no device is primary in VGA text mode.On a SeaBIOS QEMU guest with bochs and VKMS, the boot VGA (bochs) loses its DRM
boot_displayattribute. VKMS registers fb0 and bochs registers fb1. VKMS is not a PCI device, so it is not primary either. With no primary device, fbcon keeps the console on fb0 and never remaps it to bochs. This can be checked with:
Quoted 6 lines
[ ... ]Fixes 596b3678326d ("x86/video: Only fall back to vga_default_device() without screen info")Reviewed-by Mario Limonciello (AMD) <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Signed-off-by Hengyu Liang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
The following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 3b4c98b47ba7c3c57bcf54fb85f54a854622041c Gitweb: https://git.kernel.org/tip/3b4c98b47ba7c3c57bcf54fb85f54a854622041c Author: Hengyu Liang <[email protected]> AuthorDate: Mon, 02 Nov 2026 22:16:30 -05:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 12 Nov 2026 20:01:18 -08:00
x86/video: Preserve the default VGA fallback for legacy modes
Commit
596b3678326d ("x86/video: Only fall back to vga_default_device() without screen info")
made video_is_primary_device() rely exclusively on screen_info resources whenever any are available.
However, screen_info_resources() also returns legacy I/O and memory ranges for VGA text modes. These ranges are not PCI BARs, so pci_find_resource() does not find them and the default VGA fallback is skipped. As a result, no device is primary in VGA text mode.
On a SeaBIOS QEMU guest with bochs and VKMS, the boot VGA (bochs) loses its DRM boot_display attribute. VKMS registers fb0 and bochs registers fb1. VKMS is not a PCI device, so it is not primary either. With no primary device, fbcon keeps the console on fb0 and never remaps it to bochs. This can be checked with:
cat /sys/class/drm/card1/boot_display
stty -F /dev/tty1 size
Without the fix, boot_display is missing and tty1 is 48 rows by 128 columns. With it, boot_display contains 1 and tty1 is 50 rows by 160 columns. VKMS only makes the console part visible. Without VKMS, tty1 has the same size with and without the fix, but boot_display is still missing without it.
Use resource-based selection only for linear framebuffers. Fall back to vga_default_device() for legacy display modes, while keeping EFI and VESA framebuffer ownership authoritative.
--- arch/x86/video/video-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/video/video-common.c +1 -1
@@ -45,7 +45,7 @@ bool video_is_primary_device(struct device *dev)#ifdef CONFIG_SCREEN_INFO numres =screen_info_resources (si, res,ARRAY_SIZE (res)); -if (numres >0 ) { +if (numres >0 &&__screen_info_has_lfb (screen_info_video_type (si))) {for (i =0 ; i < numres; ++i) {if (!(res[i].flags &IORESOURCE_MEM ))continue ;