From patchwork Fri May 21 10:48:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaxson Han X-Patchwork-Id: 12272913 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.1 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 A8B08C433B4 for ; Fri, 21 May 2021 10:52:17 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 7064F6108D for ; Fri, 21 May 2021 10:52:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7064F6108D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=SVql08ccZ+OZs3TgmcYCYZR++XNNNcRx1mH9xtuBEYI=; b=Wd1w/x0r1UZBy5P977k68q76Ss mA7SmgqPmkkFvsfCQH4L7GgUxyyMN/FzJOiviLDAWff64GLq5ZPIJjHnfMsFh0bdAiz2o+QHIC89U cNXWsbv4wBsJZrIZhc4/dD3X4xn92py1tQdbMSV+Qv1wG/3ttl34hRSn1JjhdKuGV3gEi1bzZzhz+ qQBp79xxeBUhCgaoxz+Uwx/nuLCd2gB4sr521e8pbeoSBiG8sfRGqqZW0rz6Dg5RXX1kTL0YekTwq 1nMKCWMhsYtV2w0JfyIUdYroVYFt3K8pa3EHVNrYbeaTIRFE/wgy3leJ0TeM1BKwp45QuYRKG70fV 5o4JmZBQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk2j6-0050hw-Ro; Fri, 21 May 2021 10:49:56 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk2hw-00509G-6b for linux-arm-kernel@desiato.infradead.org; Fri, 21 May 2021 10:48:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6br5aAQa1ugsDULTZrf+6uLsWtbh1LC9vxZe8CEJ51w=; b=1BhCPU4Q9yWIhafxiOtw8gRNgU 8FXttMaejHo7q+S6jeQIRMUxGZykposSGs4zZKnx9JeUqRjdmNxw0blFGOOEATrSNUL5M6llNCknE WqPaH+SfCAnBp5xmLPErsOAoKVqX03eGczz4uZNTKlkOK24bEbyZs6kcUcC9+iDeVpmM0tAtB9M8O v9ts45ZKkjjhR2ahrkZUcCoG3aXefkZ1XJYbywOxPqKqRH4Bp5Znx069vP6jBigGFKY20ctf+WAcW qh30vj/QvNZmiE9i3r+43t5uE4GNCUBOCIN7goY9PIo6XA+aVJY/iFlF3wte806Ozeb4hwUL9NQ/o I7GPZy1g==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lk2ht-00H3AV-II for linux-arm-kernel@lists.infradead.org; Fri, 21 May 2021 10:48:43 +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 A2BBC150C; Fri, 21 May 2021 03:48:37 -0700 (PDT) Received: from optiplex-7070.shanghai.arm.com (optiplex-7070.shanghai.arm.com [10.169.188.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C3F1D3F73D; Fri, 21 May 2021 03:48:35 -0700 (PDT) From: Jaxson Han To: mark.rutland@arm.com, andre.przywara@arm.com Cc: linux-arm-kernel@lists.infradead.org, wei.chen@arm.com, jaxson.han@arm.com Subject: [boot-wrapper PATCH v2 7/8] aarch64: Prepare for booting with EL2 Date: Fri, 21 May 2021 18:48:06 +0800 Message-Id: <20210521104807.138269-8-jaxson.han@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210521104807.138269-1-jaxson.han@arm.com> References: <20210521104807.138269-1-jaxson.han@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_034841_667211_BA95CACB X-CRM114-Status: UNSURE ( 8.58 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Prepare for allowing boot-wrapper to be entered in EL2. Detect current EL and set the corresponding EL registers. Signed-off-by: Jaxson Han Reviewed-by: Andre Przywara --- arch/aarch64/boot.S | 8 ++++++++ arch/aarch64/utils.S | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S index 5600859..14fd9cf 100644 --- a/arch/aarch64/boot.S +++ b/arch/aarch64/boot.S @@ -183,10 +183,18 @@ jump_kernel: */ bfi x4, x19, #5, #1 + mrs x5, CurrentEL + cmp x5, #CURRENTEL_EL2 + b.eq 1f + msr elr_el3, x19 msr spsr_el3, x4 eret +1: msr elr_el2, x19 + msr spsr_el2, x4 + eret + .ltorg .data diff --git a/arch/aarch64/utils.S b/arch/aarch64/utils.S index ae22ea7..94e9931 100644 --- a/arch/aarch64/utils.S +++ b/arch/aarch64/utils.S @@ -37,10 +37,18 @@ find_logical_id: ret /* - * Setup EL3 vectors + * Setup EL3/EL2 vectors * x0: vector address */ setup_vector: + mrs x1, CurrentEL + cmp x1, #CURRENTEL_EL2 + b.eq 1f + msr VBAR_EL3, x0 isb ret + +1: msr VBAR_EL2, x0 + isb + ret