linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
	maz@kernel.org, linux@armlinux.org.uk,
	linux-arm-kernel@lists.infradead.org, xypron.glpk@gmx.de
Subject: [PATCH v2 2/2] efi/arm: libstub: print boot mode and MMU state at boot
Date: Sun,  7 Jun 2020 15:58:34 +0200	[thread overview]
Message-ID: <20200607135834.898294-3-ardb@kernel.org> (raw)
In-Reply-To: <20200607135834.898294-1-ardb@kernel.org>

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 --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;
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      parent reply	other threads:[~2020-06-07 13:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-07 13:58 [PATCH v2 0/2] efi/arm: deal with HYP mode boot Ard Biesheuvel
2020-06-07 13:58 ` [PATCH v2 1/2] efi/arm: decompressor: deal with HYP mode boot gracefully Ard Biesheuvel
2020-06-07 17:24   ` Heinrich Schuchardt
2020-06-07 23:08     ` Ard Biesheuvel
2020-06-08  3:49       ` Chen-Yu Tsai
2020-06-08 10:46       ` Heinrich Schuchardt
2020-06-08 10:59         ` Ard Biesheuvel
2020-06-09  7:58         ` Ard Biesheuvel
2020-06-11 22:18           ` Ard Biesheuvel
2020-06-11 22:38             ` Russell King - ARM Linux admin
2020-06-11 22:39               ` Ard Biesheuvel
2020-06-11 22:43                 ` Russell King - ARM Linux admin
2020-06-11 23:17                   ` Ard Biesheuvel
2020-06-07 13:58 ` Ard Biesheuvel [this message]

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=20200607135834.898294-3-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maz@kernel.org \
    --cc=xypron.glpk@gmx.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;
as well as URLs for NNTP newsgroup(s).