[PATCH] ARM: mach-rpc: fix zImage build after recent font-related changes
Helge Deller
deller at kernel.org
Tue May 19 02:11:24 PDT 2026
* Helge Deller <deller at gmx.de>:
> On 5/10/26 04:39, Ethan Nelson-Moore wrote:
> > The text display code used in the Risc PC kernel image decompression
> > code uses arch/arm/boot/compressed/font.c, which includes
> > lib/fonts/font_acorn_8x8.c, which further includes <linux/font.h>.
> >
> > Since commit 97df8960240a ("lib/fonts: Provide helpers for calculating
> > glyph pitch and size") <linux/font.h> contains inline functions that
> > require __do_div64, which is not linked into the ARM kernel
> > decompressor. This makes Risc PC zImages fail to build.
> >
> > Resolve this issue in the least intrusive way possible by preventing
> > the inclusion of <linux/font.h> (and the definition of a struct that
> > relies on it) when the decompressor is being built.
>
> I don't think we really require 64-bit integer support/division in the
> font code, as 32-bit should be sufficient.
> Can't you try to find out where this 64-bit division is done, and fix
> this instead?
Ethan, does this compile-only-tested patch fix the issue?
Maybe only the first hunk is necessary.
Helge
diff --git a/include/linux/font.h b/include/linux/font.h
index 6845f02d739a..c8f3d6ef54c8 100644
--- a/include/linux/font.h
+++ b/include/linux/font.h
@@ -35,7 +35,7 @@ struct console_font;
*/
static inline unsigned int font_glyph_pitch(unsigned int width)
{
- return DIV_ROUND_UP(width, 8);
+ return (width + 7) >> 3;
}
/**
diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c
index f5d5333450a0..5bd7af5f2111 100644
--- a/lib/fonts/fonts.c
+++ b/lib/fonts/fonts.c
@@ -71,24 +71,24 @@ static void font_data_free(font_data_t *fd)
font_data_t *font_data_import(const struct console_font *font, unsigned int vpitch,
u32 (*calc_csum)(u32, const void *, size_t))
{
- unsigned int pitch = console_font_pitch(font);
- unsigned int h = font->height;
- unsigned int charcount = font->charcount;
+ uint8_t pitch = console_font_pitch(font);
+ uint8_t h = font->height;
+ uint16_t charcount = font->charcount;
const unsigned char *data = font->data;
u32 csum = 0;
struct font_data *font_data;
- int size, alloc_size;
+ unsigned long size, alloc_size;
unsigned int i;
font_data_t *fd;
- /* Check for integer overflow in font-size calculation */
- if (check_mul_overflow(h, pitch, &size) ||
- check_mul_overflow(size, charcount, &size))
+ /* size-check user provided font values */
+ if ((pitch != console_font_pitch(font)) ||
+ (h != font->height) ||
+ (charcount != font->charcount))
return ERR_PTR(-EINVAL);
- /* Check for overflow in allocation size calculation */
- if (check_add_overflow(sizeof(*font_data), size, &alloc_size))
- return ERR_PTR(-EINVAL);
+ size = h * pitch;
+ alloc_size = size + sizeof(*font_data);
font_data = kmalloc(alloc_size, GFP_USER);
if (!font_data)
More information about the linux-arm-kernel
mailing list