Skip to contentSkip to conversation

remoteproc: k3-r5: Build fixes and security improvements

PATCH In review Philippe Schenker 3 participants 11 messages Nov 11, 2025 – Nov 18, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover remoteproc: k3-r5: Build fixes and security improvements

From: Philippe Schenker <[email protected]>

This series fixes compilation errors when building for R5 cores and addresses a security issue where authenticated images were not being used correctly.

Patch 1: Cosmetic removal of duplicate code

Patches 2-3: Fix build errors caused by type mismatches between function signatures and the types used in R5 builds.

Patches 4-5: fix a bug where ti_secure_image_post_process() relocates images during authentication, but callers were still using the original unverified addresses.

Patch 6: Implements is_running operation to allow querying R5F core status.

Changes in v3:
- Implemented Andrew's suggestion to assign size before casting for memory safety.
- Added Anshul's Reviewed-by, thanks!

Changes in v2:
- Made sure there are no build-warnings caused by this series.

Philippe Schenker (6):
arm: dts: k3-am642-evm: Remove duplicate node
remoteproc: k3-r5: cast size to size_t6dd
soc: ti: pruss: Fix size ptr type in probe
mach-k3: security: Propagate verified image addr
remoteproc: k3-r5: Use verified image address
remoteproc: k3-r5: Implement is_running operation

 arch/arm/dts/k3-am642-evm-u-boot.dtsi |  4 ----
 arch/arm/mach-k3/security.c           |  2 ++
 drivers/remoteproc/ti_k3_r5f_rproc.c  | 26 +++++++++++++++++++++++---
 drivers/soc/ti/pruss.c                |  2 +-
 4 files changed, 26 insertions(+), 8 deletions(-)
Signature · 4 lines
2.51.2

base-commit: 6b27b6886945a9351fcea8c9acf9418844f46670
branch: am64x-various-fixes__master
#1 lore raw

PATCH v3 1/6 arm: dts: k3-am642-evm: Remove duplicate node

From: Philippe Schenker <[email protected]>

The device tree contained a duplicate DT node 'main_mmc1_pins_default', which was already defined a few lines below. This patch removes the redundant entry.

---

Changes in v3:
- Add Anshul's Reviewed-by, thanks!

 arch/arm/dts/k3-am642-evm-u-boot.dtsi | 4 ----
 1 file changed, 4 deletions(-)
arch/arm/dts/k3-am642-evm-u-boot.dtsi +0 -4
index 705b3baa81cf..6469f43fca81 100644
@@ -19,10 +19,6 @@
 	dr_mode="peripheral";
 };
 
-&main_mmc1_pins_default {
-	bootph-all;
-};
-
 &sdhci0 {
 	bootph-all;
 };
Signature · 1 line
2.51.2
#2 lore raw

PATCH v3 2/6 remoteproc: k3-r5: cast size to size_t6dd

In reply to Philippe Schenker

From: Philippe Schenker <[email protected]>

When compiling for R5 core with CONFIG_REMOTEPROC_TI_K3_R5F, passing 'size' (ulong) to ti_secure_image_post_process() caused a type mismatch compiler error.

On platforms where ulong and size_t differ in size, directly casting could lead to out-of-bounds memory access. Fix by introducing a size_t temporary variable, passing it to the function, and writing back the potentially modified value for use in subsequent calls.

---

Changes in v3:
- Assign size to a variable of type size_t before casting to make sure no memory is accessed out-of-bounds on any circumstance.
- Change this commit title and message accordingly.

Changes in v2:
- Added Andrew's Acked-by

 drivers/remoteproc/ti_k3_r5f_rproc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/remoteproc/ti_k3_r5f_rproc.c +4 -1
index c738607c1092..48ebdaf06931 100644
@@ -315,6 +315,7 @@ static int k3_r5f_load(struct udevice *dev, ulong addr, ulong size)
 	bool mem_auto_init;
 	void *image_addr = (void *)addr;
 	int ret;
+	size_t size_img;
 
 	dev_dbg(dev, "%s addr = 0x%lx, size = 0x%lx\n", __func__, addr, size);
 
@@ -341,7 +342,9 @@ static int k3_r5f_load(struct udevice *dev, ulong addr, ulong size)
 
 	k3_r5f_init_tcm_memories(core, mem_auto_init);
 
-	ti_secure_image_post_process(&image_addr, &size);
+	size_img = size;
+	ti_secure_image_post_process(&image_addr, &size_img);
+	size = size_img;
 
 	ret = rproc_elf_load_image(dev, addr, size);
 	if (ret < 0) {
Signature · 1 line
2.51.2
#3 lore raw

PATCH v3 3/6 soc: ti: pruss: Fix size ptr type in probe

In reply to Philippe Schenker

From: Philippe Schenker <[email protected]>

When compiling for R5 with CONFIG_TI_PRUSS enabled, the pruss_probe() function passed a u64* to ofnode_get_addr_size_index(), which expects an fdt_size_t*. This caused a compiler error about incompatible pointer types.

Cast the size pointer to fdt_size_t* to match the function signature.

---

(no changes since v1)

 drivers/soc/ti/pruss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/ti/pruss.c +1 -1
index e3bb2ede554a..4bc0ff8c2c17 100644
@@ -163,7 +163,7 @@ static int pruss_probe(struct udevice *dev)
 	for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
 		idx = ofnode_stringlist_search(memories, "reg-names", mem_names[i]);
 		priv->mem_regions[i].pa = ofnode_get_addr_size_index(memories, idx,
-						       (u64 *)&priv->mem_regions[i].size);
+						       (fdt_size_t *)&priv->mem_regions[i].size);
 	}
 
 	sub_node = ofnode_find_subnode(node, "cfg");
Signature · 1 line
2.51.2
#4 lore raw

PATCH v3 4/6 mach-k3: security: Propagate verified image addr

In reply to Philippe Schenker

From: Philippe Schenker <[email protected]>

The ti_secure_image_check() function may relocate the image during authentication, updating image_addr to point to the verified location. The caller was not updated with this new address, causing it to reference the original unverified location.

Update p_image with the verified image address after authentication to ensure subsequent operations use the correct location.

---

(no changes since v2)

Changes in v2:
- Fixed pointer cast warning by using uintptr_t intermediate cast. The direct cast from u64 to pointer caused a -Wint-to-pointer-cast warning on 32-bit ARM R5 targets. Using (uintptr_t) as intermediate cast is safer and architecture-aware, ensuring proper handling on both 32-bit and 64-bit targets.

 arch/arm/mach-k3/security.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-k3/security.c +2 -0
index 3468a370a455..c7017bba99ab 100644
@@ -119,6 +119,8 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size)
 	 */
 	*p_size = image_size;
 
+	*p_image = (void *)(uintptr_t)image_addr;
+
 	/*
 	 * Output notification of successful authentication to re-assure the
 	 * user that the secure code is being processed as expected. However
Signature · 1 line
2.51.2
#5 lore raw

PATCH v3 5/6 remoteproc: k3-r5: Use verified image address

In reply to Philippe Schenker

From: Philippe Schenker <[email protected]>

After ti_secure_image_post_process() authenticates the image, it may relocate it to a different memory location and update image_addr to point to the verified image.

However, rproc_elf_load_image() and rproc_elf_get_boot_addr() were still using the original "addr" parameter, potentially operating on the unverified or stale image location instead of the authenticated image.

Use image_addr (cast to ulong to match function signatures) after authentication to ensure all operations work with the verified image.

---

(no changes since v1)

 drivers/remoteproc/ti_k3_r5f_rproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/ti_k3_r5f_rproc.c +2 -2
index 48ebdaf06931..c6356729e9db 100644
@@ -346,13 +346,13 @@ static int k3_r5f_load(struct udevice *dev, ulong addr, ulong size)
 	ti_secure_image_post_process(&image_addr, &size_img);
 	size = size_img;
 
-	ret = rproc_elf_load_image(dev, addr, size);
+	ret = rproc_elf_load_image(dev, (ulong)image_addr, size);
 	if (ret < 0) {
 		dev_err(dev, "Loading elf failedi %d\n", ret);
 		goto proc_release;
 	}
 
-	boot_vector = rproc_elf_get_boot_addr(dev, addr);
+	boot_vector = rproc_elf_get_boot_addr(dev, (ulong)image_addr);
 
 	dev_dbg(dev, "%s: Boot vector = 0x%llx\n", __func__, boot_vector);
 
Signature · 1 line
2.51.2
#6 lore raw

PATCH v3 6/6 remoteproc: k3-r5: Implement is_running operation

In reply to Philippe Schenker

From: Philippe Schenker <[email protected]>

Add is_running callback to query the R5F core halt status via the TI-SCI processor control API. This allows the remoteproc framework to determine whether the R5F core is currently runnin.

The core is considered running when the PROC_BOOT_CTRL_FLAG_R5_CORE_HALT bit is not set in the control flags.

---

Changes in v3:
- Implemented Andrew's suggestion to assign size before casting for memory safety.
- Added Anshul's Reviewed-by, thanks!

Changes in v2:
- Made sure there are no build-warnings caused by this series.

 drivers/remoteproc/ti_k3_r5f_rproc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/remoteproc/ti_k3_r5f_rproc.c +17 -0
index c6356729e9db..7326f5a4b30b 100644
@@ -573,6 +573,22 @@ static void *k3_r5f_da_to_va(struct udevice *dev, ulong da, ulong size, bool *is
 	return map_physmem(da, size, MAP_NOCACHE);
 }
 
+static int k3_r5f_is_running(struct udevice *dev)
+{
+	struct k3_r5f_core *core = dev_get_priv(dev);
+	u32 cfg, ctrl, sts;
+	u64 boot_vec;
+	int ret;
+
+	dev_dbg(dev, "%s\n", __func__);
+
+	ret = ti_sci_proc_get_status(&core->tsp, &boot_vec, &cfg, &ctrl, &sts);
+	if (ret)
+		return -1;
+
+	return !!(ctrl & PROC_BOOT_CTRL_FLAG_R5_CORE_HALT);
+}
+
 static int k3_r5f_init(struct udevice *dev)
 {
 	return 0;
@@ -590,6 +606,7 @@ static const struct dm_rproc_ops k3_r5f_rproc_ops = {
 	.stop = k3_r5f_stop,
 	.load = k3_r5f_load,
 	.device_to_virt = k3_r5f_da_to_va,
+	.is_running = k3_r5f_is_running,
 };
 
 static int k3_r5f_rproc_configure(struct k3_r5f_core *core)
Signature · 1 line
2.51.2
Reviewed-by on v3 6/6
#7 lore raw

Re: [PATCH v3 6/6] remoteproc: k3-r5: Implement is_running operation

Quoted 30 lines · Philippe Schenker

From: Philippe Schenker <[email protected]>

Add is_running callback to query the R5F core halt status via the TI-SCI processor control API. This allows the remoteproc framework to determine whether the R5F core is currently runnin.

The core is considered running when the PROC_BOOT_CTRL_FLAG_R5_CORE_HALT bit is not set in the control flags.

---

Changes in v3:
- Implemented Andrew's suggestion to assign size before casting for memory safety.
- Added Anshul's Reviewed-by, thanks!

Changes in v2:
- Made sure there are no build-warnings caused by this series.

  drivers/remoteproc/ti_k3_r5f_rproc.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/remoteproc/ti_k3_r5f_rproc.c +0 -0
index c6356729e9db..7326f5a4b30b 100644
@@ -573,6 +573,22 @@ static void *k3_r5f_da_to_va(struct udevice *dev, ulong da, ulong size, bool *is
  	return map_physmem(da, size, MAP_NOCACHE);

drivers/remoteproc/ti_k3_r5f_rproc.c static void *k3_r5f_da_to_va(struct udevice *dev, ulong da, ulong size, bool *is · line 583

Quoted 10 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +8 -0
  }
 
+static int k3_r5f_is_running(struct udevice *dev)
+{
+	struct k3_r5f_core *core = dev_get_priv(dev);
+	u32 cfg, ctrl, sts;
+	u64 boot_vec;
+	int ret;
+
+	dev_dbg(dev, "%s\n", __func__);

This debug statement doesn't do much other than note when the function is called, which can be done with other tracing methods. Either drop it or have it also print something useful like the status of the core (running / not running).

Other than that LGTM,

BTW this function would be the same for all the ti_k3_* rproc drivers, in Linux all these were factored out to common K3 helpers, might be a good refactor for here in U-Boot also..

Quoted 19 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +9 -0
+
+	ret = ti_sci_proc_get_status(&core->tsp, &boot_vec, &cfg, &ctrl, &sts);
+	if (ret)
+		return -1;
+
+	return !!(ctrl & PROC_BOOT_CTRL_FLAG_R5_CORE_HALT);
+}
+
  static int k3_r5f_init(struct udevice *dev)
  {
  	return 0;
@@ -590,6 +606,7 @@ static const struct dm_rproc_ops k3_r5f_rproc_ops = {
  	.stop = k3_r5f_stop,
  	.load = k3_r5f_load,
  	.device_to_virt = k3_r5f_da_to_va,
+	.is_running = k3_r5f_is_running,
  };
 
  static int k3_r5f_rproc_configure(struct k3_r5f_core *core)
#8 lore raw

Re: [PATCH v3 6/6] remoteproc: k3-r5: Implement is_running operation

Quoted 41 lines · Andrew Davis
Quoted 40 lines · Philippe Schenker

From: Philippe Schenker <[email protected]>

Add is_running callback to query the R5F core halt status via the TI-SCI processor control API. This allows the remoteproc framework to determine whether the R5F core is currently runnin.

The core is considered running when the
PROC_BOOT_CTRL_FLAG_R5_CORE_HALT
bit is not set in the control flags.

---

Changes in v3:
- Implemented Andrew's suggestion to assign size before casting for memory safety.
- Added Anshul's Reviewed-by, thanks!

Changes in v2:
- Made sure there are no build-warnings caused by this series.

  drivers/remoteproc/ti_k3_r5f_rproc.c | 17 +++++++++++++++++

  1 file changed, 17 insertions(+)
drivers/remoteproc/ti_k3_r5f_rproc.c +0 -0
index c6356729e9db..7326f5a4b30b 100644
@@ -573,6 +573,22 @@ static void *k3_r5f_da_to_va(struct udevice
 *dev, ulong da, ulong size, bool *is
    return map_physmem(da, size, MAP_NOCACHE);
   }

drivers/remoteproc/ti_k3_r5f_rproc.c +5 -0
+static int k3_r5f_is_running(struct udevice *dev)
+{
+ struct k3_r5f_core *core = dev_get_priv(dev);
+ u32 cfg, ctrl, sts;
+ u64 boot_vec;
Quoted 8 lines
Quoted 3 lines

+ int ret;
+
+ dev_dbg(dev, "%s\n", __func__);

This debug statement doesn't do much other than note when the function is called, which can be done with other tracing methods. Either drop it or have it also print something useful like the status of the core (running / not running).

Hi Andrew, and thanks for also looking at this patch! I actually put that dev_dbg() there to be in line with all the other functions in this file. They all have this.

I'll keep it for consistency with the existing functions, but I agree these could all be cleaned up in a future refactoring patch.

Quoted 8 lines

Other than that LGTM,

BTW this function would be the same for all the ti_k3_* rproc drivers, in Linux all these were factored out to common K3 helpers, might be a good refactor for here in U-Boot also..

Thanks! Good to know, if I touch it again I can refactor those common functions out like on kernel.

Philippe

Quoted 21 lines
Quoted 21 lines

+
+ ret = ti_sci_proc_get_status(&core->tsp, &boot_vec, &cfg, &ctrl, &sts);
+ if (ret)
+ return -1;

drivers/remoteproc/ti_k3_r5f_rproc.c +4 -0
+
+ return !!(ctrl & PROC_BOOT_CTRL_FLAG_R5_CORE_HALT);
+}
+

  static int k3_r5f_init(struct udevice *dev)
  {
   return 0;

drivers/remoteproc/ti_k3_r5f_rproc.c +1 -0
@@ -590,6 +606,7 @@ static const struct dm_rproc_ops
 k3_r5f_rproc_ops = {
    .stop = k3_r5f_stop,
    .load = k3_r5f_load,
    .device_to_virt = k3_r5f_da_to_va,
+ .is_running = k3_r5f_is_running,
   };


  static int k3_r5f_rproc_configure(struct k3_r5f_core *core)

#9 lore raw

Re: [PATCH v3 6/6] remoteproc: k3-r5: Implement is_running operation

Quoted 53 lines · Philippe Schenker
Quoted 36 lines · Andrew Davis
Quoted 35 lines · Philippe Schenker

From: Philippe Schenker <[email protected]>

Add is_running callback to query the R5F core halt status via the TI-SCI processor control API. This allows the remoteproc framework to determine whether the R5F core is currently runnin.

The core is considered running when the
PROC_BOOT_CTRL_FLAG_R5_CORE_HALT
bit is not set in the control flags.

---

Changes in v3:
- Implemented Andrew's suggestion to assign size before casting for memory safety.
- Added Anshul's Reviewed-by, thanks!

Changes in v2:
- Made sure there are no build-warnings caused by this series.

   drivers/remoteproc/ti_k3_r5f_rproc.c | 17 +++++++++++++++++
   1 file changed, 17 insertions(+)
drivers/remoteproc/ti_k3_r5f_rproc.c +0 -0
index c6356729e9db..7326f5a4b30b 100644
@@ -573,6 +573,22 @@ static void *k3_r5f_da_to_va(struct udevice
 *dev, ulong da, ulong size, bool *is
    return map_physmem(da, size, MAP_NOCACHE);
   }
 
Quoted 13 lines

drivers/remoteproc/ti_k3_r5f_rproc.c static void *k3_r5f_da_to_va(struct udevice *dev, ulong da, ulong size, bool *is · line 583

Quoted 8 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +8 -0
+static int k3_r5f_is_running(struct udevice *dev)
+{
+ struct k3_r5f_core *core = dev_get_priv(dev);
+ u32 cfg, ctrl, sts;
+ u64 boot_vec;
+ int ret;
+
+ dev_dbg(dev, "%s\n", __func__);

This debug statement doesn't do much other than note when the function is called, which can be done with other tracing methods. Either drop it or have it also print something useful like the status of the core (running / not running).

Quoted 7 lines

Hi Andrew, and thanks for also looking at this patch! I actually put that dev_dbg() there to be in line with all the other functions in this file. They all have this.

I'll keep it for consistency with the existing functions, but I agree these could all be cleaned up in a future refactoring patch.

Fair enough

Quoted 12 lines
Quoted 8 lines

Other than that LGTM,

BTW this function would be the same for all the ti_k3_* rproc drivers, in Linux all these were factored out to common K3 helpers, might be a good refactor for here in U-Boot also..

Thanks! Good to know, if I touch it again I can refactor those common functions out like on kernel.

No worries, my comment was more a hint to either Beleswar or Hari, I'm not expecting you to cleanup our driver for us :)

Andrew

Quoted 23 lines

Philippe

Quoted 21 lines
Quoted 21 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +8 -0
+
+ ret = ti_sci_proc_get_status(&core->tsp, &boot_vec, &cfg, &ctrl,
 &sts);
+ if (ret)
+ return -1;
+
+ return !!(ctrl & PROC_BOOT_CTRL_FLAG_R5_CORE_HALT);
+}
+
   static int k3_r5f_init(struct udevice *dev)

  {
   return 0;

drivers/remoteproc/ti_k3_r5f_rproc.c +1 -0
@@ -590,6 +606,7 @@ static const struct dm_rproc_ops
 k3_r5f_rproc_ops = {
    .stop = k3_r5f_stop,
    .load = k3_r5f_load,
    .device_to_virt = k3_r5f_da_to_va,
+ .is_running = k3_r5f_is_running,
   };
 

  static int k3_r5f_rproc_configure(struct k3_r5f_core *core)

#10 lore raw
In reply to Philippe Schenker
Quoted 8 lines · Philippe Schenker

From: Philippe Schenker <[email protected]>

This series fixes compilation errors when building for R5 cores and addresses a security issue where authenticated images were not being used correctly.

[...]

Applied to u-boot/next, thanks!

[1/6] arm: dts: k3-am642-evm: Remove duplicate node

      commit: 46e372feb784f533cd92e73f51f90b4fe4d336e5
[2/6] remoteproc: k3-r5: cast size to size_t6dd
      commit: 5d3697b7cf0006fee3fa12966643d605ae0777cc
[3/6] soc: ti: pruss: Fix size ptr type in probe
      commit: 40768f5ed3ef82ac11236cdd2e50cde79b5debe5
[4/6] mach-k3: security: Propagate verified image addr
      commit: fe114f3662c655cae44b45370d6dc4de2055a611
[5/6] remoteproc: k3-r5: Use verified image address
      commit: 3a43fc9016c3c37eefca10ed404c95ac7cecd3dc
[6/6] remoteproc: k3-r5: Implement is_running operation
      commit: 0c192f52cfb8a4b1c29d61750f48e016ba6b978b
Signature · 1 line
Tom