Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Align kernel load address to 64KB

KEXEC needs the new kernel's load address to be aligned on a page
boundary (see sanity_check_segment_list()), but on MIPS the default
vmlinuz load address is only explicitly aligned to 16 bytes.

Since the largest PAGE_SIZE supported by MIPS kernels is 64KB, increase
the alignment calculated by calc_vmlinuz_load_addr to 64KB.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Patchwork: https://patchwork.linux-mips.org/patch/21131/
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <james.hogan@mips.com>
Cc: Steven J . Hill <Steven.Hill@cavium.com>
Cc: linux-mips@linux-mips.org
Cc: Fuxin Zhang <zhangfx@lemote.com>
Cc: Zhangjin Wu <wuzhangjin@gmail.com>
Cc: <stable@vger.kernel.org> # 2.6.36+

authored by

Huacai Chen and committed by
Paul Burton
bec0de4c 92aa0718

+4 -3
+4 -3
arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
··· 13 13 #include <stdint.h> 14 14 #include <stdio.h> 15 15 #include <stdlib.h> 16 + #include "../../../../include/linux/sizes.h" 16 17 17 18 int main(int argc, char *argv[]) 18 19 { ··· 46 45 vmlinuz_load_addr = vmlinux_load_addr + vmlinux_size; 47 46 48 47 /* 49 - * Align with 16 bytes: "greater than that used for any standard data 50 - * types by a MIPS compiler." -- See MIPS Run Linux (Second Edition). 48 + * Align with 64KB: KEXEC needs load sections to be aligned to PAGE_SIZE, 49 + * which may be as large as 64KB depending on the kernel configuration. 51 50 */ 52 51 53 - vmlinuz_load_addr += (16 - vmlinux_size % 16); 52 + vmlinuz_load_addr += (SZ_64K - vmlinux_size % SZ_64K); 54 53 55 54 printf("0x%llx\n", vmlinuz_load_addr); 56 55