Skip to contentSkip to conversation

sandbox_spl: Restrict use of UPL when not enabled

PATCH In review Simon Glass 2 participants 4 messages Sep 25, 2024 – Oct 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sandbox_spl: Restrict use of UPL when not enabled

With sandbox_spl we want to use the file-based boot in CI, so that this flow is tested. The recent UPL change enabled booting via that method, thus overriding the file-based boot.

Correct this by using UPL only when the --upl flag is given.

Fixes 91fde8e1764 ("sandbox: Add an SPL loader for UPL")

---

 arch/sandbox/cpu/spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/sandbox/cpu/spl.c +3 -2
index 1c33a520c64..76638362564 100644
@@ -55,9 +55,10 @@ void board_init_f(ulong flag)
 
 void board_boot_order(u32 *spl_boot_list)
 {
+	struct sandbox_state *state = state_get_current();
+
 	spl_boot_list[0] = BOOT_DEVICE_VBE;
-	spl_boot_list[1] = BOOT_DEVICE_UPL;
-	spl_boot_list[2] = BOOT_DEVICE_BOARD;
+	spl_boot_list[1] = state->upl ? BOOT_DEVICE_UPL : BOOT_DEVICE_BOARD;
 }
 
 static int spl_board_load_file(struct spl_image_info *spl_image,
Signature · 1 line
2.43.0
#1 lore raw
Quoted 18 lines · Simon Glass

With sandbox_spl we want to use the file-based boot in CI, so that this flow is tested. The recent UPL change enabled booting via that method, thus overriding the file-based boot.

Correct this by using UPL only when the --upl flag is given.

Fixes 91fde8e1764 ("sandbox: Add an SPL loader for UPL")

---

  arch/sandbox/cpu/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
arch/sandbox/cpu/spl.c +0 -0
index 1c33a520c64..76638362564 100644

arch/sandbox/cpu/spl.c void board_init_f(ulong flag) · line 61

Quoted 9 lines
arch/sandbox/cpu/spl.c +3 -2
@@ -55,9 +55,10 @@ void board_init_f(ulong flag)
 
  void board_boot_order(u32 *spl_boot_list)
  {
+	struct sandbox_state *state = state_get_current();
+
  	spl_boot_list[0] = BOOT_DEVICE_VBE;
-	spl_boot_list[1] = BOOT_DEVICE_UPL;
-	spl_boot_list[2] = BOOT_DEVICE_BOARD;
+	spl_boot_list[1] = state->upl ? BOOT_DEVICE_UPL : BOOT_DEVICE_BOARD;

Wouldn't the UPL method check if the loaded file is a universal payload, and if not the BOARD method would be executed?

In upl_load_from_image() I am missing a check that the FIT image is really a universal payload, e.g. look at the spec-revision field.

Considering
https://universalpayload.github.io/spec/chapter2-payload-image-format.html#example-fit
it seems a field uniquely identifying universal payloads (in contrast to non-UPL FIT images) is missing in the specification.

Best regards

Heinrich

Quoted 3 lines
arch/sandbox/cpu/spl.c +0 -0
  }
 
  static int spl_board_load_file(struct spl_image_info *spl_image,
#2 lore raw

Hi Heinrich,

Quoted 33 lines · Heinrich Schuchardt
Quoted 18 lines · Simon Glass

With sandbox_spl we want to use the file-based boot in CI, so that this flow is tested. The recent UPL change enabled booting via that method, thus overriding the file-based boot.

Correct this by using UPL only when the --upl flag is given.

Fixes 91fde8e1764 ("sandbox: Add an SPL loader for UPL")

---

  arch/sandbox/cpu/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
arch/sandbox/cpu/spl.c +0 -0
index 1c33a520c64..76638362564 100644

arch/sandbox/cpu/spl.c void board_init_f(ulong flag) · line 61

Quoted 9 lines
arch/sandbox/cpu/spl.c +3 -2
@@ -55,9 +55,10 @@ void board_init_f(ulong flag)
 
  void board_boot_order(u32 *spl_boot_list)
  {
+     struct sandbox_state *state = state_get_current();
+
      spl_boot_list[0] = BOOT_DEVICE_VBE;
-     spl_boot_list[1] = BOOT_DEVICE_UPL;
-     spl_boot_list[2] = BOOT_DEVICE_BOARD;
+     spl_boot_list[1] = state->upl ? BOOT_DEVICE_UPL : BOOT_DEVICE_BOARD;

Wouldn't the UPL method check if the loaded file is a universal payload, and if not the BOARD method would be executed?

Quoted 7 lines

In upl_load_from_image() I am missing a check that the FIT image is really a universal payload, e.g. look at the spec-revision field.

Considering
https://universalpayload.github.io/spec/chapter2-payload-image-format.html#example-fit
it seems a field uniquely identifying universal payloads (in contrast to non-UPL FIT images) is missing in the specification.

Yes, that could be done as a new feature. But this patch is still correct.

Regards,
Simon

#3 lore raw

Hi Heinrich,

Quoted 8 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass

With sandbox_spl we want to use the file-based boot in CI, so that this flow is tested. The recent UPL change enabled booting via that method, thus overriding the file-based boot.

Correct this by using UPL only when the --upl flag is given.

Quoted 7 lines
Quoted 7 lines
Fixes 91fde8e1764 ("sandbox: Add an SPL loader for UPL")

---

  arch/sandbox/cpu/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!