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.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 21545C432BE for ; Thu, 26 Aug 2021 11:36:48 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F5F16102A for ; Thu, 26 Aug 2021 11:36:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3F5F16102A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4DAD88081E; Thu, 26 Aug 2021 13:36:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 2545D80ECB; Thu, 26 Aug 2021 13:36:41 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 874A280796 for ; Thu, 26 Aug 2021 13:36:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com 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 22FE21042; Thu, 26 Aug 2021 04:36:35 -0700 (PDT) Received: from [10.1.25.18] (e110479.cambridge.arm.com [10.1.25.18]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E1A03F5A1; Thu, 26 Aug 2021 04:36:32 -0700 (PDT) Subject: Re: [PATCH v2 5/6] arm: Use armv8_switch_to_el1 env to switch to EL1 To: Tom Rini , Michal Simek Cc: Peter Hoyes , u-boot@lists.denx.de, patrick.delaunay@foss.st.com, sjg@chromium.org, diego.sueiro@arm.com, Michael Walle , Priyanka Singh References: <20210819155314.1787973-1-peter.hoyes@arm.com> <20210819155314.1787973-6-peter.hoyes@arm.com> <54bb4bcb-5c77-d5e5-50e2-9699424e8e9a@arm.com> <20210820170554.GF858@bill-the-cat> From: Andre Przywara Message-ID: Date: Thu, 26 Aug 2021 12:36:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210820170554.GF858@bill-the-cat> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 8/20/21 6:05 PM, Tom Rini wrote: > On Fri, Aug 20, 2021 at 05:57:51PM +0100, Andre Przywara wrote: >> On 8/19/21 4:53 PM, Peter Hoyes wrote: Hi, >>> From: Peter Hoyes >>> >>> Use the environment variable armv8_switch_to_el1 to determine whether >>> to switch to EL1 at runtime. This is an alternative to the >>> CONFIG_ARMV8_SWITCH_TO_EL1 compile-time option. >> >> This might be useful outside of the v8-R64 FVP. I cannot find >> CONFIG_ARMV8_SWITCH_TO_EL1 being set anywhere, which makes me wonder how >> this is used? Are there certain custom builds which define this somehow? > > Adding Michal ... Michal, I see that Xilinx Versal and ZynqMP have a commented "define CONFIG_ARMV8_SWITCH_TO_EL1" in their include headers. Can you say what is the use case here? From an architectural point of view it sounds useful to have this feature in general and the dynamic switch-ability on top of that for all ARM64 platforms, but I would first like to understand how this is used with those Xilink platforms. > asking for a Kconfig migration too :) That sounds reasonable. I will have a stab once we agree how to address this feature in general. Cheers, Andre > >> >> In any case forcing "kernel" entry in either EL1 or EL2, and deciding this >> at runtime sounds useful for certain scenarios in general, and be it for >> debugging and testing. So shall we get rid of this compile time option at >> all, or shall this be retained to avoid extra code? >> >>> The environment variable will be ineffective if the ARMV8_MULTIENTRY >>> config is used. >>> >>> This is required by the Armv8r64 architecture, which must be able to >>> boot at S-EL1 for Linux but may need to boot at other ELs for other >>> systems. >>> >>> Signed-off-by: Peter Hoyes >>> --- >>> arch/arm/lib/bootm.c | 40 +++++++++++++++++++++++++--------------- >>> 1 file changed, 25 insertions(+), 15 deletions(-) >>> >>> diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c >>> index f60ee3a7e6..ea9bfe7570 100644 >>> --- a/arch/arm/lib/bootm.c >>> +++ b/arch/arm/lib/bootm.c >>> @@ -317,7 +317,6 @@ __weak void update_os_arch_secondary_cores(uint8_t os_arch) >>> { >>> } >>> -#ifdef CONFIG_ARMV8_SWITCH_TO_EL1 >>> static void switch_to_el1(void) >>> { >>> if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) && >>> @@ -332,7 +331,6 @@ static void switch_to_el1(void) >>> ES_TO_AARCH64); >>> } >>> #endif >>> -#endif >>> /* Subcommand: GO */ >>> static void boot_jump_linux(bootm_headers_t *images, int flag) >>> @@ -359,21 +357,33 @@ static void boot_jump_linux(bootm_headers_t *images, int flag) >>> update_os_arch_secondary_cores(images->os.arch); >>> -#ifdef CONFIG_ARMV8_SWITCH_TO_EL1 >>> - armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0, >>> - (u64)switch_to_el1, ES_TO_AARCH64); >>> +#ifdef CONFIG_ARMV8_MULTIENTRY >>> + int armv8_switch_to_el1 = -1; >>> #else >>> - if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) && >>> - (images->os.arch == IH_ARCH_ARM)) >>> - armv8_switch_to_el2(0, (u64)gd->bd->bi_arch_number, >>> - (u64)images->ft_addr, 0, >>> - (u64)images->ep, >>> - ES_TO_AARCH32); >>> - else >>> - armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0, >>> - images->ep, >>> - ES_TO_AARCH64); >>> + int armv8_switch_to_el1 = env_get_yesno("armv8_switch_to_el1"); >>> #endif >>> +#ifdef CONFIG_ARMV8_SWITCH_TO_EL1 >>> + if (armv8_switch_to_el1 == -1) { >>> + armv8_switch_to_el1 = 1; >>> + } >>> +#endif >>> + if (armv8_switch_to_el1 == 1) { >> >> This looks confusing. Can't we use CONFIG_IS_ENABLED() and override >> armv8_switch_to_el1, then use this one variable to trigger the action? >> >> Cheers, >> Andre >> >>> + armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0, >>> + (u64)switch_to_el1, ES_TO_AARCH64); >>> + } else { >>> + if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) && >>> + (images->os.arch == IH_ARCH_ARM)) >>> + armv8_switch_to_el2(0, >>> + (u64)gd->bd->bi_arch_number, >>> + (u64)images->ft_addr, 0, >>> + (u64)images->ep, >>> + ES_TO_AARCH32); >>> + else >>> + armv8_switch_to_el2((u64)images->ft_addr, >>> + 0, 0, 0, >>> + images->ep, >>> + ES_TO_AARCH64); >>> + } >>> } >>> #else >>> unsigned long machid = gd->bd->bi_arch_number; >>> >> >