mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Cc: Marco Felsch <m.felsch@pengutronix.de>
Subject: [PATCH 22/23] pbl: add support to disable/remove the /secure-chosen/stdout-path
Date: Mon, 10 Nov 2025 21:35:02 +0100	[thread overview]
Message-ID: <20251110-v2025-09-0-topic-optee-of-handling-v1-22-8f0625ac5471@pengutronix.de> (raw)
In-Reply-To: <20251110-v2025-09-0-topic-optee-of-handling-v1-0-8f0625ac5471@pengutronix.de>

Add helpers to disable the /secure-chosen/stdout-path property from a
FDT to keep the secure-OS silent. This is useful to keep the console on
for development purpose and off for the release case. For the later
case, the board code also needs to ensure that no /chosen/stdout-path
exsits, else the secure-OS may fallback to this node.

The API is very specific to make clear that only the
/secure-chosen/stdout-path is patched on demand.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 include/pbl.h |  4 ++++
 pbl/console.c | 18 ++++++++++++++++++
 pbl/fdt.c     | 26 ++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/include/pbl.h b/include/pbl.h
index 0961b6b91e585a59a3e8facb1af261857cb6f57e..7e64a9d200ade522ebeb6394c730b608abc6d2bf 100644
--- a/include/pbl.h
+++ b/include/pbl.h
@@ -17,6 +17,9 @@ extern unsigned long free_mem_end_ptr;
 void pbl_barebox_uncompress(void *dest, void *compressed_start, unsigned int len);
 int pbl_dtbz_uncompress(void *dest, void *compressed_start, unsigned long len);
 
+void pbl_set_disable_secure_chosen_stdout(void);
+int pbl_disable_secure_chosen_stdout(void);
+
 void fdt_find_mem(const void *fdt, unsigned long *membase, unsigned long *memsize);
 int fdt_fixup_mem(void *fdt, unsigned long membase[], unsigned long memsize[], size_t num);
 
@@ -34,6 +37,7 @@ int fdt_copy_node(const void *src_fdt, void *dest_fdt, const char *path,
 int pbl_barebox_verify(const void *compressed_start, unsigned int len,
 		       const void *hash, unsigned int hash_len);
 int pbl_load_fdt(const void *fdt, void *dest, int destsize);
+int fdt_remove_secure_chosen_stdout(void *fdt);
 
 #endif
 
diff --git a/pbl/console.c b/pbl/console.c
index 66652320149db5cdb9d365c5b05a9ac0903935d2..b3f2ac60b5e23b487c0d098d5c2ac5c3f2c8acdc 100644
--- a/pbl/console.c
+++ b/pbl/console.c
@@ -4,6 +4,7 @@
 #include <debug_ll.h>
 #include <asm/sections.h>
 #include <linux/err.h>
+#include <pbl.h>
 
 /*
  * Put these in the data section so that they survive the clearing of the
@@ -12,6 +13,23 @@
 static __attribute__ ((section(".data"))) ulong putc_offset;
 static __attribute__ ((section(".data"))) void *putc_ctx;
 
+/*
+ * No special segment handling required, since the value doesn't need to survive.
+ * The secure-os is loaded only once very early. Therefore this variable is
+ * checked only once too.
+ */
+static int disable_secure_chosen_stdout;
+
+void pbl_set_disable_secure_chosen_stdout(void)
+{
+	disable_secure_chosen_stdout = 1;
+}
+
+int pbl_disable_secure_chosen_stdout(void)
+{
+	return disable_secure_chosen_stdout;
+}
+
 /**
  * pbl_set_putc() - setup UART used for PBL console
  * @putc: The putc function.
diff --git a/pbl/fdt.c b/pbl/fdt.c
index fa61c3c71298a2e036e0d324c09d452d8f0f7bbe..d8160e4a09867aab91dc89de5dc7b00dd08a4155 100644
--- a/pbl/fdt.c
+++ b/pbl/fdt.c
@@ -342,3 +342,29 @@ int fdt_copy_node(const void *src_fdt, void *dest_fdt, const char *path,
 
 	return _fdt_copy_node(src_fdt, src_node, dest_fdt, dest_node);
 }
+
+int fdt_remove_secure_chosen_stdout(void *fdt)
+{
+	int sec_chosen;
+	int ret;
+
+	if (!fdt)
+		return 0;
+
+	sec_chosen = fdt_path_offset(fdt, "/secure-chosen");
+	/* No secure-chosen node found, nothing to do */
+	if (sec_chosen < 0)
+		return 0;
+
+	ret = fdt_delprop(fdt, sec_chosen, "stdout-path");
+	if (ret) {
+		if (ret == -FDT_ERR_NOTFOUND)
+			return 0;
+
+		pr_warn("Failed to delete /secure-chosen/stdout-path with:%s\n",
+			fdt_strerror(ret));
+		return -EINVAL;
+	}
+
+	return 0;
+}

-- 
2.47.3




  parent reply	other threads:[~2025-11-10 20:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 20:34 [PATCH 00/23] Improve OP-TEE handling Marco Felsch
2025-11-10 20:34 ` [PATCH 01/23] pbl: compressed-dtb: add missing includes Marco Felsch
2025-11-10 20:34 ` [PATCH 02/23] pbl: fdt: fix fdt_fixup_mem error handling Marco Felsch
2025-11-10 20:34 ` [PATCH 03/23] ARM: atf: add missing includes in atf_common.h Marco Felsch
2025-11-10 20:34 ` [PATCH 04/23] ARM: i.MX8M: add support to pass DT via imx8m{m,n,q,p}_load_and_start_image_via_tfa() Marco Felsch
2025-11-10 20:34 ` [PATCH 05/23] ARM: i.MX8M: cosmetic cleanup Marco Felsch
2025-11-10 20:34 ` [PATCH 06/23] ARM: i.MX8M: move BL32 setup into imx8m_tfa_start_bl31() Marco Felsch
2025-11-10 20:34 ` [PATCH 07/23] ARM: i.MX8M: imx8m_tfa_start_bl31() add support for bl33 and fdt Marco Felsch
2025-11-10 20:34 ` [PATCH 08/23] pbl: decomp: add pbl_dtbz_uncompress helper Marco Felsch
2025-11-10 20:34 ` [PATCH 09/23] pbl: fdt: add pbl_load_fdt helper Marco Felsch
2025-11-10 20:34 ` [PATCH 10/23] ARM: i.MX: scratch: add FDT support Marco Felsch
2025-11-10 20:34 ` [PATCH 11/23] ARM: i.MX8M: esdctl: drop ddrc base from imx8m_ddrc_sdram_size Marco Felsch
2025-11-10 20:34 ` [PATCH 12/23] ARM: i.MX8M: esdctl: export imx8m_ddrc_sdram_size() Marco Felsch
2025-11-10 20:34 ` [PATCH 13/23] ARM: i.MX8M: add support to pass BL3x bl_params Marco Felsch
2025-11-10 20:34 ` [PATCH 14/23] ARM: i.MX: scratch: add OP-TEE FDTO support Marco Felsch
2025-11-10 20:34 ` [PATCH 15/23] pbl: string: add strncmp Marco Felsch
2025-11-10 20:34 ` [PATCH 16/23] pbl: fdt: add fdt_copy_node helper Marco Felsch
2025-11-10 20:34 ` [PATCH 17/23] handoff-data: Add BL32_DT_OVL entry Marco Felsch
2025-11-10 20:34 ` [PATCH 18/23] security: optee: add optee_extract_fdto helper Marco Felsch
2025-11-10 20:34 ` [PATCH 19/23] security: optee: add helpers to apply OP-TEE FDTO Marco Felsch
2025-11-10 20:35 ` [PATCH 20/23] ARM: i.MX8M: Add support to extract OP-TEE provided informations Marco Felsch
2025-11-10 20:35 ` [PATCH 21/23] of: base: register optional OP-TEE overlay Marco Felsch
2025-11-10 20:35 ` Marco Felsch [this message]
2025-11-10 20:35 ` [PATCH 23/23] ARM: i.MX8M: remove /secure-chosen/stdout-path if requested Marco Felsch

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=20251110-v2025-09-0-topic-optee-of-handling-v1-22-8f0625ac5471@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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