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,URIBL_BLOCKED, 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 5DD0AC433B4 for ; Tue, 11 May 2021 12:03:20 +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 B05B06186A for ; Tue, 11 May 2021 12:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B05B06186A 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=kK1OEvfeGCLzc8gM8+LMS4srcEwnDl93dYL1vqZwU/k=; b=rCBFLZ3X2A5f0mzo7lTNrY+Ys UjJJd0nwaWHG5iICQvwsq9a2XF00V7OiRu3XMLVa/5Uu2rrHQYr3CvGwS0xGLhh+NL7eLZOviJi8E jrK3jrWNE3navN/o6J9trjSzlIPXREpn6GNPFrAsU4ZxEgDGZ0VzaULfjSPKVC3nWdVT+Z/rCd8oJ vx+rAYaOYTDDX1/ncXzHge48nd/cliQgYStLzdd1549Ydo1WibZJ6u/Vw0zxFY4ZO5H2TJRUTombE kiIFRdZXNPinIiso9Huo63/UDE4KPW2acOzElONCiu1VHqRCMgFT1wBv9ijMov1o44tAj3rJCxWBa I6UnS2aEg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgR5G-00HGr4-Hl; Tue, 11 May 2021 12:01:56 +0000 Received: from [2607:7c80:54:e::133] (helo=bombadil.infradead.org) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgNKE-00GYRu-I2 for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 08:01:09 +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=pHddQyTa2AIPDmzUqk/P3CW858h+0Nz3QiOgYSvejtU=; b=t/iAkLkNj6F8zL5TOsoHaXcQyD I43/B3YFF5ajdyTwzSEoVtYV5bEd4Rgeoi9vdijVXYCdswqOY+2XjOKertbOH7+x0QFzXO97PG/K1 uhq2bRC31WEYGhbb19nxay9kv4ZEeF74M9ntxoRu7NF+pXaJ0Gg6J0yVYzFtr5Z5Es632bDe2b7vG NgdR+nQC6J3SdByALwmF1Qk7Q0jVkTEHFI/gqyJEfj84u+cZcVDOti4Crl7bfid31lq1EishemGA3 /KbYuWxeWUZmkVcp6CmW37VwvSt7riFJ+kcNNJoDmaWcJvOqQQvOJKazLQ/Eue224Xcn4TOwaPnXc d/SJ6tnQ==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgNK9-009NZ1-DO for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 08:01:03 +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 B78041688; Tue, 11 May 2021 01:00:51 -0700 (PDT) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0BEC3F73B; Tue, 11 May 2021 01:00:50 -0700 (PDT) Date: Tue, 11 May 2021 08:59:57 +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: <20210511085957.3b0094c7@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> <20210510095441.55191875@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-20210511_010101_690742_028F0C48 X-CRM114-Status: GOOD ( 58.95 ) /bin/ln: failed to access 'reaver_cache/texts/20210511_010101_690742_028F0C48': No such file or directory X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_010101_690742_028F0C48 X-CRM114-Status: GOOD ( 55.20 ) 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 Tue, 11 May 2021 02:03:32 +0000 Jaxson Han wrote: Hi, > > -----Original Message----- > > From: Andre Przywara > > Sent: Monday, May 10, 2021 4:55 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 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? > > The problem comes from AIS yocto-bsp team. The reason they need this, I think, > may be that they want to test this new option for v8-r since GCC 11 supports > v8-r. Anyway, the current version works well. And I agree it's neither > necessary nor first priority to solve this problem for boot-wrapper. But I think > it's worth to discuss with you and see your suggestions :) Well, but each software package sets the stage for the compiler options it can or cannot accept. And since the boot-wrapper is still foremost a v8-A software, just compiling it with v8-r (or any other random switch) won't work. So it's just not valid to use that switch there - it's the task of the Makefile to set compiler options, any user choices have no guarantee of working anyway. And out of curiosity: what did you expect from using that option? > > 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. > > Yes, it helps! Based on this, we could easily evaluate the efforts:) Did you change the EL3 registers this way? Was there any effect on the code? Cheers, Andre > > > > 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