* Re: [PATCH] x86/video: Preserve the default VGA fallback for legacy modes
2026-10-29 16:23 [PATCH] x86/video: Preserve the default VGA fallback for legacy modes Hengyu Liang
@ 2026-10-29 16:29 ` sashiko-bot
2026-10-29 19:52 ` Mario Limonciello
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-10-29 16:29 UTC (permalink / raw)
To: Hengyu Liang; +Cc: linux-pci
> 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 the resource
> lookup fails and the default VGA fallback is skipped.
>
> On a SeaBIOS QEMU guest with bochs and VKMS, the boot VGA loses its DRM
> boot_display attribute and fbcon leaves the console on VKMS. 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.
>
> 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.
>
> Fixes: 596b3678326d ("x86/video: Only fall back to vga_default_device() without screen info")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261029162311.3389523-1-hengyul@cs.unc.edu?part=1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] x86/video: Preserve the default VGA fallback for legacy modes
2026-10-29 16:23 [PATCH] x86/video: Preserve the default VGA fallback for legacy modes Hengyu Liang
2026-10-29 16:29 ` sashiko-bot
@ 2026-10-29 19:52 ` Mario Limonciello
2026-10-30 5:33 ` Borislav Petkov
2026-10-30 8:48 ` Thomas Zimmermann
3 siblings, 0 replies; 8+ messages in thread
From: Mario Limonciello @ 2026-10-29 19:52 UTC (permalink / raw)
To: Hengyu Liang, x86
Cc: tzimmermann, aaron.ma, linux-kernel, linux-pci, dri-devel
On 10/29/26 11:23, Hengyu Liang wrote:
> 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 the resource
> lookup fails and the default VGA fallback is skipped.
>
> On a SeaBIOS QEMU guest with bochs and VKMS, the boot VGA loses its DRM
> boot_display attribute and fbcon leaves the console on VKMS. 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.
>
> 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.
>
> Fixes: 596b3678326d ("x86/video: Only fall back to vga_default_device() without screen info")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
> ---
> Tested in QEMU/KVM with identical KASAN configs: SeaBIOS VGA text mode
> (with and without VKMS), VESA, and OVMF with one and two virtual GPUs.
> All 26 guest-only helper checks pass, including EFI/VESA framebuffer
> ownership, missing framebuffer resources, and addresses above 4 GiB.
> Also build-tested x86-32 with/without CONFIG_SCREEN_INFO, and x86-64
> without CONFIG_SCREEN_INFO.
>
> arch/x86/video/video-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
> index 8ed82fff7638..b8f83346dfe8 100644
> --- a/arch/x86/video/video-common.c
> +++ b/arch/x86/video/video-common.c
> @@ -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
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] x86/video: Preserve the default VGA fallback for legacy modes
2026-10-29 16:23 [PATCH] x86/video: Preserve the default VGA fallback for legacy modes Hengyu Liang
2026-10-29 16:29 ` sashiko-bot
2026-10-29 19:52 ` Mario Limonciello
@ 2026-10-30 5:33 ` Borislav Petkov
2026-10-30 8:48 ` Thomas Zimmermann
3 siblings, 0 replies; 8+ messages in thread
From: Borislav Petkov @ 2026-10-30 5:33 UTC (permalink / raw)
To: Hengyu Liang
Cc: x86, mario.limonciello, tzimmermann, aaron.ma, linux-kernel,
linux-pci, dri-devel
On Thu, Oct 29, 2026 at 12:23:11PM -0400, Hengyu Liang wrote:
> 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 the resource
> lookup fails and the default VGA fallback is skipped.
>
> On a SeaBIOS QEMU guest with bochs and VKMS, the boot VGA loses its DRM
> boot_display attribute and fbcon leaves the console on VKMS. 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.
>
> 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.
>
> Fixes: 596b3678326d ("x86/video: Only fall back to vga_default_device() without screen info")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
> ---
> Tested in QEMU/KVM with identical KASAN configs: SeaBIOS VGA text mode
> (with and without VKMS), VESA, and OVMF with one and two virtual GPUs.
> All 26 guest-only helper checks pass, including EFI/VESA framebuffer
> ownership, missing framebuffer resources, and addresses above 4 GiB.
> Also build-tested x86-32 with/without CONFIG_SCREEN_INFO, and x86-64
> without CONFIG_SCREEN_INFO.
>
> arch/x86/video/video-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Queued, thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] x86/video: Preserve the default VGA fallback for legacy modes
2026-10-29 16:23 [PATCH] x86/video: Preserve the default VGA fallback for legacy modes Hengyu Liang
` (2 preceding siblings ...)
2026-10-30 5:33 ` Borislav Petkov
@ 2026-10-30 8:48 ` Thomas Zimmermann
2026-10-30 9:24 ` Hengyu Liang
3 siblings, 1 reply; 8+ messages in thread
From: Thomas Zimmermann @ 2026-10-30 8:48 UTC (permalink / raw)
To: Hengyu Liang, x86
Cc: mario.limonciello, aaron.ma, linux-kernel, linux-pci, dri-devel
Hi
Am 29.10.26 um 17:23 schrieb Hengyu Liang:
> 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 the resource
> lookup fails and the default VGA fallback is skipped.
If the BIOS booted in text mode or VGA graphics mode, the rsp device is
still the primary display device. So the current matching code is not
necessarily incorrect. (But also not necessarily correct either. :)
>
> On a SeaBIOS QEMU guest with bochs and VKMS, the boot VGA loses its DRM
> boot_display attribute and fbcon leaves the console on VKMS. 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.
>
> 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.
>
> Fixes: 596b3678326d ("x86/video: Only fall back to vga_default_device() without screen info")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
> ---
> Tested in QEMU/KVM with identical KASAN configs: SeaBIOS VGA text mode
> (with and without VKMS), VESA, and OVMF with one and two virtual GPUs.
> All 26 guest-only helper checks pass, including EFI/VESA framebuffer
> ownership, missing framebuffer resources, and addresses above 4 GiB.
> Also build-tested x86-32 with/without CONFIG_SCREEN_INFO, and x86-64
> without CONFIG_SCREEN_INFO.
>
> arch/x86/video/video-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
> index 8ed82fff7638..b8f83346dfe8 100644
> --- a/arch/x86/video/video-common.c
> +++ b/arch/x86/video/video-common.c
> @@ -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;
Further below in that code is a call to pci_find_resource(). [1] Why
does it match with vkms? Vkms is not even on a PCI device.
[1]
https://elixir.bootlin.com/linux/v7.3/source/arch/x86/video/video-common.c#L53
Best regards
Thomas
>
> base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] x86/video: Preserve the default VGA fallback for legacy modes
2026-10-30 8:48 ` Thomas Zimmermann
@ 2026-10-30 9:24 ` Hengyu Liang
2026-10-30 10:15 ` Thomas Zimmermann
2026-10-30 18:31 ` Borislav Petkov
0 siblings, 2 replies; 8+ messages in thread
From: Hengyu Liang @ 2026-10-30 9:24 UTC (permalink / raw)
To: tzimmermann
Cc: x86, bp, mario.limonciello, aaron.ma, linux-kernel, linux-pci,
dri-devel
Hi Thomas,
On Fri, Oct 30, 2026 at 09:48:19AM +0100, Thomas Zimmermann wrote:
> Am 29.10.26 um 17:23 schrieb Hengyu Liang:
>> However, screen_info_resources() also returns legacy I/O and memory
>> ranges for VGA text modes. These ranges are not PCI BARs, so the resource
>> lookup fails and the default VGA fallback is skipped.
>
> If the BIOS booted in text mode or VGA graphics mode, the rsp device is
> still the primary display device. So the current matching code is not
> necessarily incorrect. (But also not necessarily correct either. :)
I agree that the device is still the primary display in text mode. The
patch gets that from the vga_default_device() fallback, since the legacy
ranges can't be matched against BARs.
>> diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
>> index 8ed82fff7638..b8f83346dfe8 100644
>> --- a/arch/x86/video/video-common.c
>> +++ b/arch/x86/video/video-common.c
>> @@ -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;
>
> Further below in that code is a call to pci_find_resource(). [1] Why
> does it match with vkms? Vkms is not even on a PCI device.
It doesn't match vkms. As you say, vkms isn't a PCI device, so
video_is_primary_device() returns false for it at the dev_is_pci() check.
The problem is on the bochs side. In text mode, screen_info_resources()
returns the legacy VGA ranges, pci_find_resource() doesn't find them in
the BARs, and the function returns false there as well. So no device is
primary, and fbcon stays on the first registered framebuffer. In this
setup that is vkms (fb0), so the console is never remapped to bochs (fb1).
vkms only makes the console part visible. Without vkms, tty1 has the same
size with and without the patch, but boot_display is still missing without
it.
Thanks,
Hengyu
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] x86/video: Preserve the default VGA fallback for legacy modes
2026-10-30 9:24 ` Hengyu Liang
@ 2026-10-30 10:15 ` Thomas Zimmermann
2026-10-30 18:31 ` Borislav Petkov
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2026-10-30 10:15 UTC (permalink / raw)
To: Hengyu Liang
Cc: x86, bp, mario.limonciello, aaron.ma, linux-kernel, linux-pci,
dri-devel
Hi
Am 30.10.26 um 10:24 schrieb Hengyu Liang:
> Hi Thomas,
>
> On Fri, Oct 30, 2026 at 09:48:19AM +0100, Thomas Zimmermann wrote:
>> Am 29.10.26 um 17:23 schrieb Hengyu Liang:
>>> However, screen_info_resources() also returns legacy I/O and memory
>>> ranges for VGA text modes. These ranges are not PCI BARs, so the resource
>>> lookup fails and the default VGA fallback is skipped.
>> If the BIOS booted in text mode or VGA graphics mode, the rsp device is
>> still the primary display device. So the current matching code is not
>> necessarily incorrect. (But also not necessarily correct either. :)
> I agree that the device is still the primary display in text mode. The
> patch gets that from the vga_default_device() fallback, since the legacy
> ranges can't be matched against BARs.
>
>>> diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
>>> index 8ed82fff7638..b8f83346dfe8 100644
>>> --- a/arch/x86/video/video-common.c
>>> +++ b/arch/x86/video/video-common.c
>>> @@ -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;
>> Further below in that code is a call to pci_find_resource(). [1] Why
>> does it match with vkms? Vkms is not even on a PCI device.
> It doesn't match vkms. As you say, vkms isn't a PCI device, so
> video_is_primary_device() returns false for it at the dev_is_pci() check.
>
> The problem is on the bochs side. In text mode, screen_info_resources()
> returns the legacy VGA ranges, pci_find_resource() doesn't find them in
> the BARs, and the function returns false there as well. So no device is
> primary, and fbcon stays on the first registered framebuffer. In this
> setup that is vkms (fb0), so the console is never remapped to bochs (fb1).
I see. That makes sense. Thanks for clarifying.
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Best regards
Thomas
>
> vkms only makes the console part visible. Without vkms, tty1 has the same
> size with and without the patch, but boot_display is still missing without
> it.
>
> Thanks,
> Hengyu
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] x86/video: Preserve the default VGA fallback for legacy modes
2026-10-30 9:24 ` Hengyu Liang
2026-10-30 10:15 ` Thomas Zimmermann
@ 2026-10-30 18:31 ` Borislav Petkov
1 sibling, 0 replies; 8+ messages in thread
From: Borislav Petkov @ 2026-10-30 18:31 UTC (permalink / raw)
To: Hengyu Liang
Cc: tzimmermann, x86, mario.limonciello, aaron.ma, linux-kernel,
linux-pci, dri-devel
On Fri, Oct 30, 2026 at 05:24:21AM -0400, Hengyu Liang wrote:
> > Further below in that code is a call to pci_find_resource(). [1] Why
> > does it match with vkms? Vkms is not even on a PCI device.
>
> It doesn't match vkms. As you say, vkms isn't a PCI device, so
> video_is_primary_device() returns false for it at the dev_is_pci() check.
>
> The problem is on the bochs side. In text mode, screen_info_resources()
> returns the legacy VGA ranges, pci_find_resource() doesn't find them in
> the BARs, and the function returns false there as well. So no device is
> primary, and fbcon stays on the first registered framebuffer. In this
> setup that is vkms (fb0), so the console is never remapped to bochs (fb1).
>
> vkms only makes the console part visible. Without vkms, tty1 has the same
> size with and without the patch, but boot_display is still missing without
> it.
Please update your commit message with this clarification.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 8+ messages in thread