From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Sang-Heon Jeon <ekffu200098@gmail.com>
Subject: [PATCH v2 4/4] bootconfig: Move BOOTCONFIG_FOOTER_SIZE to include/linux/bootconfig.h
Date: Fri, 11 Sep 2026 23:13:33 +0900 [thread overview]
Message-ID: <178913601321.248794.4786502771058559887.stgit@devnote2> (raw)
In-Reply-To: <178913597653.248794.1237187523153227751.stgit@devnote2>
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 <ekffu200098@gmail.com>
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;
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;
next prev parent reply other threads:[~2026-09-11 14:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 14:12 [PATCH v2 0/4] bootconfig: Reject unexpected data after null character and cleanups Masami Hiramatsu (Google)
2026-09-11 14:13 ` [PATCH v2 1/4] bootconfig: Reject unexpected data after null character Masami Hiramatsu (Google)
2026-09-11 14:13 ` [PATCH v2 2/4] tools/bootconfig: Consolidate xbc_init() to error message wrapper Masami Hiramatsu (Google)
2026-09-12 14:07 ` Sang-Heon Jeon
2026-09-11 14:13 ` [PATCH v2 3/4] bootconfig: Skip internal tree sanity checks in kernel Masami Hiramatsu (Google)
2026-09-11 14:13 ` Masami Hiramatsu (Google) [this message]
2026-09-12 14:08 ` [PATCH v2 4/4] bootconfig: Move BOOTCONFIG_FOOTER_SIZE to include/linux/bootconfig.h Sang-Heon Jeon
2026-09-11 22:59 ` [PATCH v2 0/4] bootconfig: Reject unexpected data after null character and cleanups Andrew Morton
2026-09-12 13:48 ` Masami Hiramatsu
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=178913601321.248794.4786502771058559887.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ekffu200098@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®