From 34a005b728072bd840d60cdf2b1100f209578d1d Mon Sep 17 00:00:00 2001 From: Daniil Tatianin <99danilt@gmail.com> Date: Sun, 29 Nov 2026 23:32:48 +0300 Subject: [PATCH] bios_video_services: filter out unsupported and non-LFB VBE modes VBE 0x4F01 succeeds even for modes that cannot be set in the current hardware configuration, signaling availability through ModeAttributes instead. Because do_set_mode() always requests a linear framebuffer, require the hardware-supported, graphics, and linear-framebuffer bits along with a non-zero framebuffer address before accepting a mode. Signed-off-by: Daniil Tatianin <99danilt@gmail.com> --- loader/arch/x86/bios/bios_video_services.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/loader/arch/x86/bios/bios_video_services.c b/loader/arch/x86/bios/bios_video_services.c index 2ee77b3f..1888ba5f 100644 --- a/loader/arch/x86/bios/bios_video_services.c +++ b/loader/arch/x86/bios/bios_video_services.c @@ -339,6 +339,12 @@ static u16 mode_fb_format( ); } +#define VBE_MODE_ATTR_SUPPORTED (1 << 0) +#define VBE_MODE_ATTR_GRAPHICS (1 << 4) +#define VBE_MODE_ATTR_LINEAR_FB (1 << 7) +#define VBE_MODE_ATTR_REQUIRED \ + (VBE_MODE_ATTR_SUPPORTED | VBE_MODE_ATTR_GRAPHICS | VBE_MODE_ATTR_LINEAR_FB) + static void fetch_all_video_modes(void) { struct super_vga_info vga_info = { 0 }; @@ -369,6 +375,12 @@ static void fetch_all_video_modes(void) if (!fetch_mode_info(mode_id, &info)) continue; + if ((info.attributes & VBE_MODE_ATTR_REQUIRED) != VBE_MODE_ATTR_REQUIRED) + continue; + + if (info.framebuffer_address == 0) + continue; + fb_format = mode_fb_format(&info, mode_id, vesa_detected_major >= 3); if (fb_format == FB_FORMAT_INVALID) continue;