]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: coreboot: framebuffer: Avoid invalid zero physical address
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>
Wed, 8 Nov 2023 18:25:13 +0000 (21:25 +0300)
committerTzung-Bi Shih <tzungbi@kernel.org>
Mon, 13 Nov 2023 02:38:32 +0000 (10:38 +0800)
On ARM64 systems coreboot defers framebuffer allocation to its payload,
to be done by a libpayload function call. In this case, coreboot tables
still include a framebuffer entry with display format details, but the
physical address field is set to zero (as in [1], for example).

Unfortunately, this field is not automatically updated when the
framebuffer is initialized through libpayload, citing that doing so
would invalidate checksums over the entire coreboot table [2].

This can be observed on ARM64 Chromebooks with stock firmware. On a
Google Kevin (RK3399), trying to use coreboot framebuffer driver as
built-in to the kernel results in a benign error. But on Google Hana
(MT8173) and Google Cozmo (MT8183) it causes a hang.

When the framebuffer physical address field in the coreboot table is
zero, we have no idea where coreboot initialized a framebuffer, or even
if it did. Instead of trying to set up a framebuffer located at zero,
return ENODEV to indicate that there isn't one.

[1] https://review.coreboot.org/c/coreboot/+/17109
[2] https://review.coreboot.org/c/coreboot/+/8797

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Link: https://lore.kernel.org/r/20231108182625.46563-1-alpernebiyasak@gmail.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
drivers/firmware/google/framebuffer-coreboot.c

index c323a818805cc9a3223394862c82f61b9e4f2c3a..5c84bbebfef85668459e49fcf9cf40c8cfa22b38 100644 (file)
@@ -36,6 +36,9 @@ static int framebuffer_probe(struct coreboot_device *dev)
                .format = NULL,
        };
 
+       if (!fb->physical_address)
+               return -ENODEV;
+
        for (i = 0; i < ARRAY_SIZE(formats); ++i) {
                if (fb->bits_per_pixel     == formats[i].bits_per_pixel &&
                    fb->red_mask_pos       == formats[i].red.offset &&