Skip to content

Commit df0f9a6

Browse files
captain5050Thomas Gleixner
authored andcommitted
parisc: Inline a type punning version of get_unaligned_le32()
Reading the byte/char output_len with get_unaligned_le32() can trigger compiler warnings due to the size read. Avoid these warnings by using type punning. This avoids issues when switching get_unaligned_t() to __builtin_memcpy(). Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20251016205126.2882625-2-irogers@google.com
1 parent 7158fc5 commit df0f9a6

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • arch/parisc/boot/compressed

arch/parisc/boot/compressed/misc.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,19 @@ static void parse_elf(void *output)
278278
free(phdrs);
279279
}
280280

281+
/*
282+
* The regular get_unaligned_le32 uses __builtin_memcpy which can trigger
283+
* warnings when reading a byte/char output_len as an integer, as the size of a
284+
* char is less than that of an integer. Use type punning and the packed
285+
* attribute, which requires -fno-strict-aliasing, to work around the problem.
286+
*/
287+
static u32 punned_get_unaligned_le32(const void *p)
288+
{
289+
const struct { __le32 x; } __packed * __get_pptr = p;
290+
291+
return le32_to_cpu(__get_pptr->x);
292+
}
293+
281294
asmlinkage unsigned long __visible decompress_kernel(unsigned int started_wide,
282295
unsigned int command_line,
283296
const unsigned int rd_start,
@@ -309,7 +322,7 @@ asmlinkage unsigned long __visible decompress_kernel(unsigned int started_wide,
309322
* leave 2 MB for the stack.
310323
*/
311324
vmlinux_addr = (unsigned long) &_ebss + 2*1024*1024;
312-
vmlinux_len = get_unaligned_le32(&output_len);
325+
vmlinux_len = punned_get_unaligned_le32(&output_len);
313326
output = (char *) vmlinux_addr;
314327

315328
/*

0 commit comments

Comments
 (0)