Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@kernel.org>
To: Ethan Nelson-Moore <enelsonmoore@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-fbdev@vger.kernel.org, Russell King <linux@armlinux.org.uk>
Subject: Re: [PATCH] ARM: mach-rpc: fix zImage build after recent font-related changes
Date: Tue, 19 May 2026 11:11:24 +0200	[thread overview]
Message-ID: <agwpPFGkN3zHKdCj@carbonx1> (raw)
In-Reply-To: <d0bb399f-1285-495b-babe-8bae608729e8@gmx.de>

* Helge Deller <deller@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)


  reply	other threads:[~2026-05-19  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-10  2:39 [PATCH] ARM: mach-rpc: fix zImage build after recent font-related changes Ethan Nelson-Moore
2026-05-19  6:56 ` Helge Deller
2026-05-19  9:11   ` Helge Deller [this message]
2026-05-20  4:49     ` Ethan Nelson-Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=agwpPFGkN3zHKdCj@carbonx1 \
    --to=deller@kernel.org \
    --cc=enelsonmoore@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox