From patchwork Thu Jul 29 15:20:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 12408987 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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 EC94CC4338F for ; Thu, 29 Jul 2021 15:26:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD9E660F22 for ; Thu, 29 Jul 2021 15:26:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AD9E660F22 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J0QdAywZ2j35O6x9y3bg3s1ZaCZq94G+O6FV4G38qTw=; b=dL+5a4sKhZySkh sJEC2IAJHtAmvOp4Z5XsR5Rx6ErOlaLUgYi55sHxKq7UfKarYJlHrM0KC6RBbDLUscizMAsOficGU 2N9wrSnxC9AOePYt5r4XUV9MDFzEtXWPN7B0G7AXVRS3sQ2l9MAFMrKprAN5iqMbTWCbphG1g83FP H3fzJqLGoGy+tv3xE5vpAFb8rvzSu8Itnv8xHlRDcYjcAWOdbiNgHQlPWddcGxYkwGVxsUBYkodX2 X5hZ+cze19nNhSW953tq5U3KiSbbLxiJA2QBrxAt/2RzoQaR6F5SlrJbX7HAbsoFNLDPTLQ3SXzFC tmt3KvAQB6nzyEXzFdZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m97se-004hBn-Ui; Thu, 29 Jul 2021 15:23:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m97qI-004gZV-OQ for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 15:21:09 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 298D4106F; Thu, 29 Jul 2021 08:21:02 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5DB893F73D; Thu, 29 Jul 2021 08:21:01 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: Andre.Przywara@arm.com, Jaxson.Han@arm.com, mark.rutland@arm.com, Wei.Chen@arm.com Subject: [boot-wrapper PATCH 04/12] Remove `flag_no_el3` Date: Thu, 29 Jul 2021 16:20:42 +0100 Message-Id: <20210729152050.23635-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210729152050.23635-1-mark.rutland@arm.com> References: <20210729152050.23635-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_082102_928346_1DB4774A X-CRM114-Status: UNSURE ( 9.30 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We set `flag_no_el3` when not booted at EL3 / monitor mode, and subsequently we use this to determine whether we need to drop exception level before entering Linux. As this can be derived from CurrentEL or CPSR, the flag itself is redundant, and we can defer the check until we're about to enter Linux. In future this will allow more logic to be converted into C, where it will be easier to handle architectural variants. Signed-off-by: Mark Rutland --- arch/aarch32/boot.S | 14 +++----------- arch/aarch64/boot.S | 13 ++----------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/arch/aarch32/boot.S b/arch/aarch32/boot.S index 2a85ad5..0bd1ca2 100644 --- a/arch/aarch32/boot.S +++ b/arch/aarch32/boot.S @@ -31,9 +31,6 @@ ENTRY(_start) cmp r0, #PSR_HYP bne _switch_monitor - mov r0, #1 - ldr r1, =flag_no_el3 - str r0, [r1] b start_no_el3 _switch_monitor: @@ -89,9 +86,9 @@ ENTRY(jump_kernel) ldr lr, [r5], #4 ldm r5, {r0 - r2} - ldr r4, =flag_no_el3 - ldr r4, [r4] - cmp r4, #1 + mrs r4, cpsr + and r4, #PSR_MODE_MASK + cmp r4, #PSR_MON bxeq lr @ no EL3 ldr r4, =SPSR_KERNEL @@ -113,8 +110,3 @@ boot_vectors: b . b . b . - - .section .data - .align 2 -flag_no_el3: - .long 0 diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S index 37759ce..fae0188 100644 --- a/arch/aarch64/boot.S +++ b/arch/aarch64/boot.S @@ -28,10 +28,6 @@ _start: cmp x0, #CURRENTEL_EL3 b.eq 1f - mov w0, #1 - ldr x1, =flag_no_el3 - str w0, [x1] - b start_no_el3 1: mov x0, #0x30 // RES1 @@ -140,8 +136,8 @@ jump_kernel: bl find_logical_id bl setup_stack // Reset stack pointer - ldr w0, flag_no_el3 - cmp w0, #0 // Prepare Z flag + mrs x0, CurrentEl + cmp w0, #CURRENTEL_EL3 // Prepare Z flag mov x0, x20 mov x1, x21 @@ -164,8 +160,3 @@ jump_kernel: eret .ltorg - - .data - .align 3 -flag_no_el3: - .long 0