From patchwork Sun Jun 7 13:58:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 206302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C655C433E1 for ; Sun, 7 Jun 2020 13:58:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 631C020748 for ; Sun, 7 Jun 2020 13:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591538330; bh=+I7+Y9xcYGUsBj8ke7ISq801A0SS4udp6aU7ow79qpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IXaTC026NS6cdqPHd5SpvqWbx0Zr8oy4aUIW+m4lPrdaJTfdLstDPW7cphPCW5Zwb rWR1wo3YyjXMyvbEW2OQfaj14yMzw1fCLiTJJATeSWEP8tjZj7LlG/vrT3vM0gCvo7 Q6dlyFsxQhW2TI+oeSnDKCftEV78sR6kGztGwt8Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgFGN6u (ORCPT ); Sun, 7 Jun 2020 09:58:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:51912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbgFGN6t (ORCPT ); Sun, 7 Jun 2020 09:58:49 -0400 Received: from dogfood.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 58CDB2075A; Sun, 7 Jun 2020 13:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591538329; bh=+I7+Y9xcYGUsBj8ke7ISq801A0SS4udp6aU7ow79qpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RPI2nsZzJJxKsmNOdP8YnABoKLer0jT2K5waAsthEvMijyLXPBZ8FYHxwwqeleZ3Q uGqfqOA6217NcQnbpHJZobhqqC/LHfoMIyvvUlG1ZCotap4hOwm7i7e9LUtxgb1GTG sEOXeTDkYZjtNSegUIJsL1SRpCexyks2wuAFhoIY= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, maz@kernel.org, linux@armlinux.org.uk, xypron.glpk@gmx.de, Ard Biesheuvel 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 Message-Id: <20200607135834.898294-3-ardb@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200607135834.898294-1-ardb@kernel.org> References: <20200607135834.898294-1-ardb@kernel.org> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.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 --- 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;