mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] bootm: replace CONFIG_BOOTM_FORCE_SIGNED_IMAGES with helper
Date: Mon, 23 Oct 2023 18:27:47 +0200	[thread overview]
Message-ID: <20231023162748.533468-1-a.fatoum@pengutronix.de> (raw)

In preparation for allowing even CONFIG_BOOTM_FORCE_SIGNED_IMAGES=n
configurations to force boot of only signed images, replace direct
use of IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES) with a helper that
queries a static variable that can be forced at runtime in a follow-up
commit.

No functional change.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/lib32/bootm.c |  2 +-
 common/bootm.c         | 11 +++++++++--
 include/bootm.h        |  2 ++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index e814593dce43..aeb873a3a723 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -294,7 +294,7 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem,
 	}
 
 	if (IS_ENABLED(CONFIG_BOOTM_OPTEE)) {
-		if (data->tee_file && !IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+		if (data->tee_file && !bootm_signed_images_are_forced()) {
 			ret = bootm_load_tee_from_file(data);
 			if (ret)
 				return ret;
diff --git a/common/bootm.c b/common/bootm.c
index 2469d4344188..dd5f26dd83e2 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -85,6 +85,13 @@ static const char * const bootm_verify_names[] = {
 	[BOOTM_VERIFY_SIGNATURE] = "signature",
 };
 
+static bool force_signed_images = IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES);
+
+bool bootm_signed_images_are_forced(void)
+{
+	return force_signed_images;
+}
+
 static int uimage_part_num(const char *partname)
 {
 	if (!partname)
@@ -690,7 +697,7 @@ int bootm_boot(struct bootm_data *bootm_data)
 		goto err_out;
 	}
 
-	if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+	if (bootm_signed_images_are_forced()) {
 		data->verify = BOOTM_VERIFY_SIGNATURE;
 
 		/*
@@ -953,7 +960,7 @@ static int bootm_init(void)
 		globalvar_add_simple("bootm.initrd.loadaddr", NULL);
 	}
 
-	if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES))
+	if (bootm_signed_images_are_forced())
 		bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
 
 	globalvar_add_simple_int("bootm.verbose", &bootm_verbosity, "%u");
diff --git a/include/bootm.h b/include/bootm.h
index ee2b574521db..25308d43a30e 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -147,6 +147,8 @@ int bootm_get_os_size(struct image_data *data);
 enum bootm_verify bootm_get_verify_mode(void);
 void bootm_set_verify_mode(enum bootm_verify mode);
 
+bool bootm_signed_images_are_forced(void);
+
 #define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1)
 
 void *booti_load_image(struct image_data *data, phys_addr_t *oftree);
-- 
2.39.2




             reply	other threads:[~2023-10-23 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 16:27 Ahmad Fatoum [this message]
2023-10-23 16:27 ` [PATCH 2/2] bootm: add support for dynamically forcing signature verification Ahmad Fatoum

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=20231023162748.533468-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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