From mboxrd@z Thu Jan 1 00:00:00 1970 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 0BBE9C432BE for ; Fri, 20 Aug 2021 17:06:08 +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 2E40760EBD for ; Fri, 20 Aug 2021 17:06:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2E40760EBD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.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 D230582C0C; Fri, 20 Aug 2021 19:06:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="AihL9WMh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 467E182D13; Fri, 20 Aug 2021 19:06:03 +0200 (CEST) Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9AC1882999 for ; Fri, 20 Aug 2021 19:05:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x72c.google.com with SMTP id y144so11556709qkb.6 for ; Fri, 20 Aug 2021 10:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5sAgl0MuLFJAz6lBnT7HnxTF6RmXQIRowSIXHNWSjlc=; b=AihL9WMhHOkKlFfUFmYIuad6nEYZr0Sjdb1I9PqCO9jGsLqPEE2/BFU+jIVRECwYcx tIWtm4m4h0pAo5gllm3rPBMGazSSSVVJxQLZ+1BiFOMR+1QKhLa9gPznssRb7u7YE6oF 3HeoE3mO/DTE5JdHSgztSZW2cAmyDU7HUTEXg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=5sAgl0MuLFJAz6lBnT7HnxTF6RmXQIRowSIXHNWSjlc=; b=dOqEja45Fi+A14h8t/ffOvs5RVA1EUglqs6xhFWy22fXccXeByHRwh8rpFvjpmD+yi eVFEF626CiDN+/m8P1bmLs8BMm1IJWN0R4gLXQRXad12xpvmfE6PFoNeY465iQz6LXDH L3+52qKUfcr0S/hQ8F9Po7pfSKxbuFYs4u5qfaZjT2t8NrtCXBH1KlrFE3aekPRs7cLv Q9b7lce4+rUdZeK8LBchfUEoEJGVRcU6wfiNz/Sn/xGVTTqg9He/43BXH9HVS89WvGdo 82A0ImNnyFHoJvX5Ff0KN0KZNC47Z9BNp4KPTfFbTKTQHZ1+gZfoCe1XTV3d8wd+jyGG X+LA== X-Gm-Message-State: AOAM533X7MfW2ORVw/8MwxP0zlcWQISryQBzQzeYo5a/JxHJaX5hyo20 tsha+6SCwexrSdMjHk51xdN5Fg== X-Google-Smtp-Source: ABdhPJyCgzuGayQVmuSTX0szMG7pVDvo5CyNAlrg9f4jOATXEG0qOGvdxZIjP+5Yz5Z0YbhN5pdgkQ== X-Received: by 2002:a05:620a:13cb:: with SMTP id g11mr9776341qkl.332.1629479157347; Fri, 20 Aug 2021 10:05:57 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-4d9f-af8a-0612-bfbb.res6.spectrum.com. [2603:6081:7b01:cbda:4d9f:af8a:612:bfbb]) by smtp.gmail.com with ESMTPSA id v6sm3634812qkp.117.2021.08.20.10.05.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Aug 2021 10:05:56 -0700 (PDT) Date: Fri, 20 Aug 2021 13:05:54 -0400 From: Tom Rini To: Andre Przywara , 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 Subject: Re: [PATCH v2 5/6] arm: Use armv8_switch_to_el1 env to switch to EL1 Message-ID: <20210820170554.GF858@bill-the-cat> References: <20210819155314.1787973-1-peter.hoyes@arm.com> <20210819155314.1787973-6-peter.hoyes@arm.com> <54bb4bcb-5c77-d5e5-50e2-9699424e8e9a@arm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="0+pVStBZ8FBwmyrv" Content-Disposition: inline In-Reply-To: <54bb4bcb-5c77-d5e5-50e2-9699424e8e9a@arm.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.4 (2018-02-28) 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 --0+pVStBZ8FBwmyrv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 20, 2021 at 05:57:51PM +0100, Andre Przywara wrote: > On 8/19/21 4:53 PM, Peter Hoyes wrote: >=20 > Hi, >=20 > > From: Peter Hoyes > >=20 > > 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. >=20 > 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 and asking for a Kconfig migration too :) >=20 > 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? >=20 > > The environment variable will be ineffective if the ARMV8_MULTIENTRY > > config is used. > >=20 > > 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. > >=20 > > Signed-off-by: Peter Hoyes > > --- > > arch/arm/lib/bootm.c | 40 +++++++++++++++++++++++++--------------- > > 1 file changed, 25 insertions(+), 15 deletions(-) > >=20 > > 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 =3D=3D 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 *imag= es, 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 =3D -1; > > #else > > - if ((IH_ARCH_DEFAULT =3D=3D IH_ARCH_ARM64) && > > - (images->os.arch =3D=3D 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 =3D env_get_yesno("armv8_switch_to_el1"); > > #endif > > +#ifdef CONFIG_ARMV8_SWITCH_TO_EL1 > > + if (armv8_switch_to_el1 =3D=3D -1) { > > + armv8_switch_to_el1 =3D 1; > > + } > > +#endif > > + if (armv8_switch_to_el1 =3D=3D 1) { >=20 > 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? >=20 > Cheers, > Andre >=20 > > + armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0, > > + (u64)switch_to_el1, ES_TO_AARCH64); > > + } else { > > + if ((IH_ARCH_DEFAULT =3D=3D IH_ARCH_ARM64) && > > + (images->os.arch =3D=3D 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 =3D gd->bd->bi_arch_number; > >=20 >=20 --=20 Tom --0+pVStBZ8FBwmyrv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmEf4OgACgkQFHw5/5Y0 tyz8dAv9HlHUNBA4z5LRSwRZPtKNpGj4Ui9SuDMbrDOtx6xpWHaZaHrPWFVDp43W Q+yhjYfLpnhJKIlalYt2y7N37aK2qh5xyq6Wr1CTr/dtU3vRBc6XWwAIsecqsfbA qJKotfC6bBJtaoHKmL+0Ip1VnvVv9ZGQ2ExabuS/PvoAsjz6XW1SV9Ph5y4H3rzE ymCN5jHJR+HuAlop41+PGDsGxs1KJsoXX7hXyiz/NzR9EZC2v8O+lDD+y0nsHTYe G/38M13hbT3aG8A+qjqGOtqj9yy6h+e7gG8qEEp9au3eUOAYNkYuAsD9ZwawxcDH iUvdFK8r6Ugi88w+/3INh3TFzpSXW4EW8iYXU/5FtUufI3oVkidkyg5UZHbu+Uo/ cRdsel+Cc3Wu52Ne0pQgJ5pcawv3t1YhXBaq7oan74Jpvsj1PXNtg5qV0uRZ+hXV awCSExJz3nGj+6EScLESJ/SaM/jV2iEyUz6mUkXH1+wrraEN17vGItF4vMZt/0Df /rorn6Wc =kzHP -----END PGP SIGNATURE----- --0+pVStBZ8FBwmyrv--