bootconfig: Move BOOTCONFIG_FOOTER_SIZE to include/linux/bootconfig.h

BOOTCONFIG_FOOTER_SIZE was defined locally in tools/bootconfig/main.c.
Move it to include/linux/bootconfig.h so that it can be shared with
the kernel and user-space tools. Also, use it in init/main.c instead
of the hardcoded (BOOTCONFIG_MAGIC_LEN + 8) expression when checking
the initrd size.

Link: https://lore.kernel.org/all/178913601321.248794.4786502771058559887.stgit@devnote2/

Suggested-by: Sang-Heon Jeon <ekffu200098@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Sang-Heon Jeon <ekffu200098@gmail.com>
This commit is contained in:
Masami Hiramatsu (Google) 2026-09-11 23:13:33 +09:00
parent e84e60da22
commit 677f83795f
3 changed files with 5 additions and 5 deletions

View File

@ -27,6 +27,10 @@ bool __init cmdline_has_extra_options(void);
#define BOOTCONFIG_ALIGN (1 << BOOTCONFIG_ALIGN_SHIFT)
#define BOOTCONFIG_ALIGN_MASK (BOOTCONFIG_ALIGN - 1)
/* Bootconfig footer is [size][csum][BOOTCONFIG_MAGIC]. */
#define BOOTCONFIG_FOOTER_SIZE \
(sizeof(uint32_t) * 2 + BOOTCONFIG_MAGIC_LEN)
/**
* xbc_calc_checksum() - Calculate checksum of bootconfig
* @data: Bootconfig data.

View File

@ -278,7 +278,7 @@ static void * __init get_boot_config_from_initrd(size_t *_size)
int i;
if (!initrd_end || initrd_end < initrd_start ||
initrd_end - initrd_start < BOOTCONFIG_MAGIC_LEN + 8)
initrd_end - initrd_start < BOOTCONFIG_FOOTER_SIZE)
return NULL;
data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN;

View File

@ -17,10 +17,6 @@
#define pr_err(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
/* Bootconfig footer is [size][csum][BOOTCONFIG_MAGIC]. */
#define BOOTCONFIG_FOOTER_SIZE \
(sizeof(uint32_t) * 2 + BOOTCONFIG_MAGIC_LEN)
static void show_xbc_error(const char *data, const char *msg, int pos)
{
int lin = 1, col, i;