Setting "orig_video_isVGA" when handing off Linux framebuffer
Benjamin Moody
benjamin.moody at gmail.com
Fri Apr 23 20:46:57 BST 2021
Dear kexec developers,
(Please let me know if there is a better place to discuss this issue.)
In setup_linux_vesafb (arch/i386/x86-linux-setup.c), we find the
following:
struct fb_fix_screeninfo fix;
struct fb_var_screeninfo var;
int fd;
fd = open("/dev/fb0", O_RDONLY);
if (-1 == fd)
return -1;
if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, &fix))
goto out;
if (-1 == ioctl(fd, FBIOGET_VSCREENINFO, &var))
goto out;
if (0 == strcmp(fix.id, "VESA VGA")) {
/* VIDEO_TYPE_VLFB */
real_mode->orig_video_isVGA = 0x23;
} else if (0 == strcmp(fix.id, "EFI VGA")) {
/* VIDEO_TYPE_EFI */
real_mode->orig_video_isVGA = 0x70;
} else if (arch_options.reuse_video_type) {
int err;
off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA);
/* blindly try old boot time video type */
err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
if (err)
goto out;
} else {
real_mode->orig_video_isVGA = 0;
close(fd);
return 0;
}
What is the rationale for this logic? What does the
'orig_video_isVGA' parameter actually mean, what is the difference
between VIDEO_TYPE_EFI and VIDEO_TYPE_VLFB, and why does the kernel
care about it?
I'm asking because in the context of Heads
(https://github.com/osresearch/heads), the framebuffer has been
configured by Linux (not by BIOS or UEFI), and indeed there *is* no
BIOS or UEFI, only coreboot. Thus, 'fix.id' is not "VESA VGA" or "EFI
VGA", but rather "inteldrmfb" or "i915drmfb" or something like that,
and 'get_bootparam' provides nothing useful. As a result,
'orig_video_isVGA' ends up being set to zero, and consequently the
booted kernel either displays nothing or displays garbage.
I realize that not all possible framebuffer formats can be described
by 'struct x86_linux_param_header', and I assume that's the reason for
checking 'fix.id'. However, in this case, the framebuffer *is* a
standard linear format, and if we set 'orig_video_isVGA' to either
0x23 or 0x70, it appears to work correctly.
From my naive perspective, it seems that, rather than checking the
value of 'fix.id', kexec ought to be looking at 'fix.type',
'fix.visual', and perhaps other fields, to determine whether the
framebuffer format is compatible. However, it's not apparent whether
'orig_video_isVGA' should be set to 0x23 or 0x70, since the two seem
to behave identically.
I'm a little unsure about the purpose of the "blindly try old boot
time video type" option but it seems like that's not really relevant
here in any case; the original bootloader has nothing to do with the
current framebuffer.
Benjamin
More information about the kexec
mailing list