diff mbox series

[v2,2/2] efi/arm: libstub: print boot mode and MMU state at boot

Message ID 20200607135834.898294-3-ardb@kernel.org
State New
Headers show
Series efi/arm: deal with HYP mode boot | expand

Commit Message

Ard Biesheuvel June 7, 2020, 1:58 p.m. UTC
On 32-bit ARM, we may boot at HYP mode, or with the MMU and caches off
(or both), even though the EFI spec actually does not support this.
Take note of this in the EFI stub diagnostic output so that we can
easily see whether this is the case or not.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/libstub/arm32-stub.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
index 40243f524556..659aaa5003a2 100644
--- a/drivers/firmware/efi/libstub/arm32-stub.c
+++ b/drivers/firmware/efi/libstub/arm32-stub.c
@@ -9,8 +9,19 @@ 
 
 efi_status_t check_platform_features(void)
 {
+	u32 cpsr, sctlr;
 	int block;
 
+	asm("mrs %0, cpsr" : "=r"(cpsr));
+	if ((cpsr & MODE_MASK) == HYP_MODE)
+		asm("mrc p15, 4, %0, c1, c0, 0" : "=r"(sctlr));
+	else
+		asm("mrc p15, 0, %0, c1, c0, 0" : "=r"(sctlr));
+
+	efi_info("Running in %s mode with MMU %sabled\n",
+		 ((cpsr & MODE_MASK) == HYP_MODE) ? "HYP" : "SVC",
+		 (sctlr & 1) ? "en" : "dis");
+
 	/* non-LPAE kernels can run anywhere */
 	if (!IS_ENABLED(CONFIG_ARM_LPAE))
 		return EFI_SUCCESS;