Thread (10 messages) flat view 10 messages, 3 authors, 10d ago

Re: [PATCH v2 4/4] bootconfig: Move BOOTCONFIG_FOOTER_SIZE to include/linux/bootconfig.h

From: Sang-Heon Jeon <hidden>
Date: 2026-09-12 14:08:16
Also in: lkml

On Fri, Sep 11, 2026 at 11:13 PM Masami Hiramatsu (Google)
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

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.

Suggested-by: Sang-Heon Jeon <redacted>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 Changes in v2:
  - Newly added.
---
 include/linux/bootconfig.h |    4 ++++
 init/main.c                |    2 +-
 tools/bootconfig/main.c    |    4 ----
 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h
index deda507500da..6f23ec11baab 100644
--- a/include/linux/bootconfig.h
+++ b/include/linux/bootconfig.h
@@ -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.
diff --git a/init/main.c b/init/main.c
index 16749bb7a219..37168bd68126 100644
--- a/init/main.c
+++ b/init/main.c
@@ -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;
Cool!
quoted hunk ↗ jump to hunk
        data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN;
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index 652e491b9c33..d4aa96da970e 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -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;
Thank you :)

Reviewed-by: Sang-Heon Jeon <redacted>

Best regards,
Sang-Heon Jeon
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help