Skip to contentSkip to conversation

efi: Add dependency on M-mode for RISC-V

PATCH New Sean Anderson 2 participants 7 messages Sep 28, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 efi: Add dependency on M-mode for RISC-V

From section 2.3.7 of the UEFI specification:

Quoted 6 lines

RISC-V UEFI will only be executed in machine mode. The machine mode has the highest privilege and this mode is the only mandatory privilege level for RISC-V platforms; all other privilege levels are optional depending on the platform requirements. Machine mode is the first mode entered at the power-on reset. This level is used in UEFI for low-level access to a hardware platform.

---

 lib/efi_loader/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
lib/efi_loader/Kconfig +2 -0
index bad1a29ba8..2197c84bf3 100644
@@ -10,6 +10,8 @@ config EFI_LOADER
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
 	depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
+	# RISC-V UEFI must run in machine mode
+	depends on !RISCV || RISCV_M_MODE
 	default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
 	select LIB_UUID
 	select HAVE_BLOCK_DEVICE
Signature · 1 line
2.28.0
#1 lore raw

PATCH 2/2 efi: Fix typo in documentation

There is an extra space.

---

 lib/efi_selftest/efi_selftest_set_virtual_address_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_selftest/efi_selftest_set_virtual_address_map.c +1 -1
index a4e5a50f63..b097a81136 100644
@@ -23,7 +23,7 @@ static u32 notify_call_count;
 static bool convert_pointer_failed;
 
 /**
- * notify () - notification function
+ * notify() - notification function
  *
  * This function is called when the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event
  * occurs. The correct output of ConvertPointer() is checked.
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/2 efi: Fix typo in documentation

Quoted 14 lines · Sean Anderson

There is an extra space.

---

 lib/efi_selftest/efi_selftest_set_virtual_address_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_selftest/efi_selftest_set_virtual_address_map.c +0 -0
index a4e5a50f63..b097a81136 100644

lib/efi_selftest/efi_selftest_set_virtual_address_map.c static u32 notify_call_count; · line 29

Quoted 8 lines
lib/efi_selftest/efi_selftest_set_virtual_address_map.c +1 -1
@@ -23,7 +23,7 @@ static u32 notify_call_count;
 static bool convert_pointer_failed;
 
 /**
- * notify () - notification function
+ * notify() - notification function
  *
  * This function is called when the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event
  * occurs. The correct output of ConvertPointer() is checked.
#3 lore raw

PATCH 1/2 efi: Add dependency on M-mode for RISC-V

In reply to Sean Anderson
Quoted 21 lines · Sean Anderson
Quoted 8 lines

From section 2.3.7 of the UEFI specification:

RISC-V UEFI will only be executed in machine mode. The machine mode has the highest privilege and this mode is the only mandatory privilege level for RISC-V platforms; all other privilege levels are optional depending on the platform requirements. Machine mode is the first mode entered at the power-on reset. This level is used in UEFI for low-level access to a hardware platform.

---

 lib/efi_loader/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
lib/efi_loader/Kconfig +0 -0
index bad1a29ba8..2197c84bf3 100644

lib/efi_loader/Kconfig config EFI_LOADER · line 17

Quoted 8 lines
lib/efi_loader/Kconfig +2 -0
@@ -10,6 +10,8 @@ config EFI_LOADER
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
 	depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
+	# RISC-V UEFI must run in machine mode
+	depends on !RISCV || RISCV_M_MODE
 	default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
 	select LIB_UUID
 	select HAVE_BLOCK_DEVICE

Hello Sean,

the specification is wrong. A change request has been made to correct the specification. We should not change U-Boot here.

See the discussion in this thread:
https://lists.linaro.org/pipermail/boot-architecture/2020-September/001481.html

Best regards

Heinrich

#4 lore raw

PATCH 1/2 efi: Add dependency on M-mode for RISC-V

Quoted 36 lines · Heinrich Schuchardt
Quoted 21 lines · Sean Anderson
Quoted 8 lines

From section 2.3.7 of the UEFI specification:

RISC-V UEFI will only be executed in machine mode. The machine mode has the highest privilege and this mode is the only mandatory privilege level for RISC-V platforms; all other privilege levels are optional depending on the platform requirements. Machine mode is the first mode entered at the power-on reset. This level is used in UEFI for low-level access to a hardware platform.

---

 lib/efi_loader/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
lib/efi_loader/Kconfig +0 -0
index bad1a29ba8..2197c84bf3 100644

lib/efi_loader/Kconfig config EFI_LOADER · line 17

Quoted 8 lines
lib/efi_loader/Kconfig +2 -0
@@ -10,6 +10,8 @@ config EFI_LOADER
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
 	depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
+	# RISC-V UEFI must run in machine mode
+	depends on !RISCV || RISCV_M_MODE
 	default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
 	select LIB_UUID
 	select HAVE_BLOCK_DEVICE

Hello Sean,

the specification is wrong. A change request has been made to correct the specification. We should not change U-Boot here.

Quoted 7 lines

See the discussion in this thread:
https://lists.linaro.org/pipermail/boot-architecture/2020-September/001481.html

Best regards

Heinrich

Thanks for linking that. I'm glad some of these issues are being addressed. However, I am concerned about your suggestion

Quoted 2 lines

* Don't trust the values of tp and gp when entered from the payloads world.

Because tp *must* be trusted in S-Mode...

Of course, all this could be averted by adding an sbi_get_mhartid function...

--Sean

#5 lore raw

PATCH 1/2 efi: Add dependency on M-mode for RISC-V

Quoted 45 lines · Sean Anderson
Quoted 36 lines · Heinrich Schuchardt
Quoted 21 lines · Sean Anderson
Quoted 8 lines

From section 2.3.7 of the UEFI specification:

RISC-V UEFI will only be executed in machine mode. The machine mode has the highest privilege and this mode is the only mandatory privilege level for RISC-V platforms; all other privilege levels are optional depending on the platform requirements. Machine mode is the first mode entered at the power-on reset. This level is used in UEFI for low-level access to a hardware platform.

---

 lib/efi_loader/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
lib/efi_loader/Kconfig +0 -0
index bad1a29ba8..2197c84bf3 100644

lib/efi_loader/Kconfig config EFI_LOADER · line 17

Quoted 8 lines
lib/efi_loader/Kconfig +2 -0
@@ -10,6 +10,8 @@ config EFI_LOADER
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
 	depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
+	# RISC-V UEFI must run in machine mode
+	depends on !RISCV || RISCV_M_MODE
 	default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
 	select LIB_UUID
 	select HAVE_BLOCK_DEVICE

Hello Sean,

the specification is wrong. A change request has been made to correct the specification. We should not change U-Boot here.

Quoted 7 lines

See the discussion in this thread:
https://lists.linaro.org/pipermail/boot-architecture/2020-September/001481.html

Best regards

Heinrich

Quoted 8 lines

Thanks for linking that. I'm glad some of these issues are being addressed. However, I am concerned about your suggestion

Quoted 2 lines

* Don't trust the values of tp and gp when entered from the payloads world.

Because tp *must* be trusted in S-Mode...

Of course, all this could be averted by adding an sbi_get_mhartid function...

I thought only the secondary hart uses tp in U-Boot.

Best regards

Heinrich

#6 lore raw

PATCH 1/2 efi: Add dependency on M-mode for RISC-V

Quoted 53 lines · Heinrich Schuchardt
Quoted 52 lines · Sean Anderson
Quoted 36 lines · Heinrich Schuchardt
Quoted 21 lines · Sean Anderson
Quoted 8 lines

From section 2.3.7 of the UEFI specification:

RISC-V UEFI will only be executed in machine mode. The machine mode has the highest privilege and this mode is the only mandatory privilege level for RISC-V platforms; all other privilege levels are optional depending on the platform requirements. Machine mode is the first mode entered at the power-on reset. This level is used in UEFI for low-level access to a hardware platform.

---

 lib/efi_loader/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
lib/efi_loader/Kconfig +0 -0
index bad1a29ba8..2197c84bf3 100644

lib/efi_loader/Kconfig config EFI_LOADER · line 17

Quoted 8 lines
lib/efi_loader/Kconfig +2 -0
@@ -10,6 +10,8 @@ config EFI_LOADER
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
 	depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
+	# RISC-V UEFI must run in machine mode
+	depends on !RISCV || RISCV_M_MODE
 	default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
 	select LIB_UUID
 	select HAVE_BLOCK_DEVICE

Hello Sean,

the specification is wrong. A change request has been made to correct the specification. We should not change U-Boot here.

Quoted 7 lines

See the discussion in this thread:
https://lists.linaro.org/pipermail/boot-architecture/2020-September/001481.html

Best regards

Heinrich

Thanks for linking that. I'm glad some of these issues are being addressed. However, I am concerned about your suggestion

Quoted 2 lines

* Don't trust the values of tp and gp when entered from the payloads world.

Because tp *must* be trusted in S-Mode...

Quoted 8 lines
Quoted 1 line

Of course, all this could be averted by adding an sbi_get_mhartid function...

I thought only the secondary hart uses tp in U-Boot.

Best regards

Heinrich

So UEFI is only ever ran on a single hart? I thought one of the advantages of UEFI was that it could initialize devices in parallel.

--Sean