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=-15.9 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,USER_AGENT_SANE_2 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 D6F7CC433B4 for ; Mon, 10 May 2021 08:57:53 +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 46AF560FE8 for ; Mon, 10 May 2021 08:57:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46AF560FE8 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: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NDkqEcJewCjMWdkiYiDt50eY5B0Is0MFIf6RoETevRg=; b=T/hH31U0Xv83eXy3ZlX0DsOvk +QwprREUJTwB9vHYOL8Cco0x0fbpLKsldQnK8cI2T/wRPvNIEW3unwRKBWA8QFTDD1xoZFjp5Lmb+ X9qnYLvM8FazoWB/w4rgtNfmn47kyhh7NoDCvtC5j9Tl3YlnixcGrA2PxtuQwrdqTwsqvGCmadwKR KFSkzaLeZk/pIyfBlzr8BMeqfyoT/OSHWGRw2tO+mZE/ZpPnLRkWPZ/CEdYXFACKojWm/1ohcsxLj Z535fSIwBD05SYT3/WG8q7Bh98UyoGckGf9AjlNl3VFg9iq3K9n0Y2yEoS0H/8u/eE4cgd6W30UEI D7H95cRCQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lg1hi-00Dgvg-Tp; Mon, 10 May 2021 08:55:55 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lg1hM-00DgtJ-7G for linux-arm-kernel@desiato.infradead.org; Mon, 10 May 2021 08:55:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-ID:Content-Description; bh=jM/3a1uX1TnPqRfjr9JsK5QJI3jmKSRxhCJe3HBXMng=; b=mD2W5wBchFBfiED7SVKO1W7Znn Ce+6E6TyueybjkH5TRVZl/WTa8ySKdxqF7yzDJ8b2ZIe39wuXPQaejy/6NG3xHSGF0dYiES1KCJxP VWGbkS01+e4KEU2CLcQcNs1TfnbKod5Vg0vJ6WHSqaQIptKp5lSluUByUJM4dvK0tPGfKz0UJ/MQK hXlDGARZGePBbxIC+lEWrGqIbfxE4Gtup6meGE+jQrTD9DYH36hzRM0sIv26qSkXRBW91ByjUDBU2 hCH3OqYVMrsaTHYaXxwnu7PK4pFpn5qTxOn9o4e2xjAweYiXYvz98UUrZZzkwvQ8877FezuVzfpav genb8Z4w==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lg1hJ-008Qxm-1E for linux-arm-kernel@lists.infradead.org; Mon, 10 May 2021 08:55:30 +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 9B211106F; Mon, 10 May 2021 01:55:26 -0700 (PDT) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B52783F73B; Mon, 10 May 2021 01:55:25 -0700 (PDT) Date: Mon, 10 May 2021 09:54:41 +0100 From: Andre Przywara To: Jaxson Han Cc: Mark Rutland , "linux-arm-kernel@lists.infradead.org" , Wei Chen Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64 Message-ID: <20210510095441.55191875@slackpad.fritz.box> In-Reply-To: References: <20210420072438.183086-1-jaxson.han@arm.com> <20210420072438.183086-6-jaxson.han@arm.com> <20210426133546.65ee1ad6@slackpad.fritz.box> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_015529_217175_81C0476C X-CRM114-Status: GOOD ( 43.68 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 10 May 2021 02:13:45 +0000 Jaxson Han wrote: > Hi Andre, > > Since GCC 11 has been released and GCC 11 supports the ' -march=armv8-r', > we got a problem when compile the boot-wrapper with ' -march=armv8-r': > | ../git/arch/aarch64/boot.S:71: Error: selected processor does not support system register name 'scr_el3' > | ../git/arch/aarch64/boot.S:73: Error: selected processor does not support system register name 'cptr_el3' > | ../git/arch/aarch64/boot.S:84: Error: selected processor does not support system register name 'mdcr_el3' > | ../git/arch/aarch64/boot.S:90: Error: selected processor does not support system register name 'cptr_el3' > | ../git/arch/aarch64/boot.S:92: Error: selected processor does not support system register name 'cptr_el3' > | ../git/arch/aarch64/boot.S:194: Error: selected processor does not support system register name 'elr_el3' > | ../git/arch/aarch64/boot.S:195: Error: selected processor does not support system register name 'spsr_el3' > > It seems we may need some #if macro to disable all _el3 registers, but it will > break our auto-detection (users should add more compile/build parameter). > So, may I ask your suggestions? :) Why do you need that in the first place? I think your version worked without it? At least Ubuntu's 9.3.0 compiled it just fine. Or does GCC 11 complain about some v8-r specific registers and you need to add this armv8-r to let them pass, sacrificing all EL3 registers on the way? One solution could be to move all accesses to v8-r registers into a separate file, and only assemble/compile this with the v8-r switch. But this sounds like some serious plumbing in the code base. What you could try as well is to use this "s3_0_c12_c12_5" like system register encoding style (this example is for ICC_SRE_EL1). The kernel uses this trick to avoid dependencies on gas knowing about all (new) system register names. Not sure if that is enough to trick gas into accepting it? Hope that helps. Cheers, Andre > > Cheers, > Jaxson > > > -----Original Message----- > > From: Jaxson Han > > Sent: Wednesday, April 28, 2021 11:44 AM > > To: Andre Przywara > > Cc: Mark Rutland ; linux-arm- > > kernel@lists.infradead.org; Wei Chen > > Subject: RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for > > Armv8-R AArch64 > > > > Hi Andre, > > > > > -----Original Message----- > > > From: Andre Przywara > > > Sent: Monday, April 26, 2021 8:36 PM > > > To: Jaxson Han > > > Cc: Mark Rutland ; linux-arm- > > > kernel@lists.infradead.org; Wei Chen > > > Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code > > > for Armv8-R AArch64 > > > > > > On Tue, 20 Apr 2021 15:24:38 +0800 > > > Jaxson Han wrote: > > > > > > Hi, > > > > > > > The Armv8-R AArch64 profile does not support the EL3 exception level. > > > > The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU > > > > at EL1, which allows to run off-the-shelf Linux. However EL2 only > > > > supports a PMSA, which is not supported by Linux, so we need to drop > > > > into EL1 before entering the kernel. > > > > > > > > The boot sequence is: > > > > If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL > > > > before entering the kernel. > > > > If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf (Armv8-R aarch64), > > > > then goto Armv8-R AArch64 initialisation and drop to EL1 before > > > > entering the kernel. > > > > Else, no initialisation and keep the current EL before entering the > > > > kernel. > > > > > > > > Signed-off-by: Jaxson Han > > > > --- > > > > arch/aarch64/boot.S | 51 > > > > +++++++++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 51 insertions(+) > > > > > > > > diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S index > > > > f7dbf3f..6961a2a 100644 > > > > --- a/arch/aarch64/boot.S > > > > +++ b/arch/aarch64/boot.S > > > > @@ -25,16 +25,22 @@ _start: > > > > * Boot sequence > > > > * If CurrentEL == EL3, then goto EL3 initialisation and drop to > > > > * lower EL before entering the kernel. > > > > + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf, then goto > > > > + * Armv8-R AArch64 initialisation and drop to EL1 before > > > > + * entering the kernel. > > > > * Else, no initialisation and keep the current EL before > > > > * entering the kernel. > > > > */ > > > > mrs x0, CurrentEL > > > > cmp x0, #CURRENTEL_EL3 > > > > beq el3_init > > > > + cmp x0, #CURRENTEL_EL2 > > > > + beq el2_init > > > > > > nitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt > > > for > > > EL1 and b.eq for EL2 code. Saves you an extra cmp here. > > > > Exactly, I will. Thanks! > > > > > > > > > /* > > > > * We stay in the current EL for entering the kernel > > > > */ > > > > +keep_el: > > > > mov w0, #1 > > > > ldr x1, =flag_keep_el > > > > str w0, [x1] > > > > @@ -112,6 +118,43 @@ el3_init: > > > > str w0, [x1] > > > > b el_max_init > > > > > > > > + /* > > > > + * EL2 Armv8-R AArch64 initialisation > > > > + */ > > > > +el2_init: > > > > + /* Detect Armv8-R AArch64 */ > > > > + mrs x1, id_aa64mmfr0_el1 > > > > + ubfx x1, x1, #48, #4 // MSA > > > > + /* 0xf means Armv8-R AArch64 */ > > > > + cmp x1, 0xf > > > > + bne keep_el > > > > > > Don't we need to also check bits[55:52], to have at least 0b0010? > > > IIUC the support for VMSA in EL1&0 is optional, and should be checked > > > before we proceed? VTCR_EL2[31] can only be set in the 0b0010 case. > > > > Yes, it should be checked, I will add it. > > > > > > > > > + > > > > + mrs x0, midr_el1 > > > > + msr vpidr_el2, x0 > > > > + > > > > + mrs x0, mpidr_el1 > > > > + msr vmpidr_el2, x0 > > > > + > > > > + mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64 > > > support > > > > + msr vtcr_el2, x0 > > > > + > > > > + /* Enable pointer authentication if present */ > > > > + mrs x1, id_aa64isar1_el1 > > > > + ldr x2, =(((0xff) << 24) | (0xff << 4)) > > > > > > Each feature only holds four bits, so the mask you shift should be 0xf. > > > > Yes, I will fix. > > > > > > > > > + and x1, x1, x2 > > > > + cbz x1, 1f > > > > + > > > > + mrs x0, hcr_el2 > > > > > > Shouldn't we force HCR_EL2, instead of modifying it? Just to make sure > > > nothing unexpected traps into EL2, which we don't handle very well? > > > So basically just set bit 31 (RES1), plus those two bits on top, if > > > needed. But I also wonder about FIEN[47] and EnSCXT[53] ... > > > > Right, we should force to set HCR_EL2. The API and APK is needed. > > And I will also check if we need the FIEN[47] and EnSCXT[53]. > > > > Thanks, > > Jaxson > > > > > > > > > > > Rest looks alright. > > > > > > Cheers, > > > Andre > > > > > > > + orr x0, x0, #(1 << 40) // AP key enable > > > > + orr x0, x0, #(1 << 41) // AP insn enable > > > > + msr hcr_el2, x0 > > > > + > > > > +1: isb > > > > + mov w0, #SPSR_KERNEL_EL1 > > > > + ldr x1, =spsr_to_elx > > > > + str w0, [x1] > > > > + b el_max_init > > > > + > > > > el_max_init: > > > > ldr x0, =CNTFRQ > > > > msr cntfrq_el0, x0 > > > > @@ -169,10 +212,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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel