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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 DD3F9C4338F for ; Tue, 24 Aug 2021 16:52:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AE99A61183 for ; Tue, 24 Aug 2021 16:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AE99A61183 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bPhm9v1t/3Y4xMcFsP+DNVQ5gS1LQ0ueiYVBvzOG+yM=; b=bA5QOsrr+z7t+9obKOgcxLyAEA k74W7gbwH5rMPs6P8OLVNM0S2YCZZG8pBHRm76dpbGnue5OYPqxPN6+S2yYamZ0TUBbG8yWmK/ai4 DqIVQe6ptEj0YuWUsk31A1SBHtCqjUBoLO1ERnPgLIMjcYlh8OicpRzbhU+rrP2q+GJMczhoV/Pty zZht04TH7AqZnKvPkIV6gQ0yDi2lvVoStFPaEsCT6ann6xh8Mouvdz2lCj5z8nhtWZOtYaAd6RAgg 9STPl+h4svl7xeEgkwFNTj+d+MDNgelXRBVR/J/6znU4HYkHO74LqzXW2zT3YZMBoJnxykik1g7+C WdAU/3og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIZdT-0040Fl-38; Tue, 24 Aug 2021 16:50:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIZdO-0040EN-T9 for linux-arm-kernel@lists.infradead.org; Tue, 24 Aug 2021 16:50:48 +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 7806231B; Tue, 24 Aug 2021 09:50:45 -0700 (PDT) Received: from [10.1.30.13] (e110479.cambridge.arm.com [10.1.30.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B6AB13F766; Tue, 24 Aug 2021 09:50:44 -0700 (PDT) Subject: Re: [boot-wrapper PATCH 3/5] GICv3: initialize without RMW To: Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: alexandru.elisei@arm.com, maz@kernel.org References: <20210824134900.34849-1-mark.rutland@arm.com> <20210824134900.34849-4-mark.rutland@arm.com> From: Andre Przywara Message-ID: <32fc73f9-7eef-d6e2-1f5c-491e330e5b70@arm.com> Date: Tue, 24 Aug 2021 17:50:43 +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: <20210824134900.34849-4-mark.rutland@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210824_095047_083158_BC06DDF6 X-CRM114-Status: GOOD ( 24.66 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 8/24/21 2:48 PM, Mark Rutland wrote: > There's no need to perform an RMW sequence to initialize ICC_SRE_EL3, as > there are no bits that we need to preserve, and generally we should > reset registers to specific values such that RESx bits aren't configured > to UNKNOWN values that could be problematic in future architecture > versions. > > Instead, let's initialize ICC_SRE_EL3 with a constant value. Since the > `DIB` and `DFB` fields are RAO/WI in some configurations and we have no > reason to initialize these to 0, we always initialize these to 1, in > addition to `SRE` and `SRE_Enable`. Indeed, actually the architectural reset value is 0 (bypass enabled), and we seem to be just saved by the fact that the model implements them as RAO/WI. So forcing a value is the right thing to do. > Signed-off-by: Mark Rutland > Cc: Marc Zyngier > Cc: Alexandru Elisei > Cc: Andre Przywara Reviewed-by: Andre Przywara Cheers, Andre > --- > arch/aarch32/include/asm/gic-v3.h | 7 ------- > arch/aarch64/include/asm/gic-v3.h | 7 ------- > common/gic-v3.c | 8 +++----- > 3 files changed, 3 insertions(+), 19 deletions(-) > > diff --git a/arch/aarch32/include/asm/gic-v3.h b/arch/aarch32/include/asm/gic-v3.h > index ec9a327..65f38de 100644 > --- a/arch/aarch32/include/asm/gic-v3.h > +++ b/arch/aarch32/include/asm/gic-v3.h > @@ -9,13 +9,6 @@ > #ifndef __ASM_AARCH32_GICV3_H > #define __ASM_AARCH32_GICV3_H > > -static inline uint32_t gic_read_icc_sre(void) > -{ > - uint32_t val; > - asm volatile ("mrc p15, 6, %0, c12, c12, 5" : "=r" (val)); > - return val; > -} > - > static inline void gic_write_icc_sre(uint32_t val) > { > asm volatile ("mcr p15, 6, %0, c12, c12, 5" : : "r" (val)); > diff --git a/arch/aarch64/include/asm/gic-v3.h b/arch/aarch64/include/asm/gic-v3.h > index e743c02..5b32380 100644 > --- a/arch/aarch64/include/asm/gic-v3.h > +++ b/arch/aarch64/include/asm/gic-v3.h > @@ -15,13 +15,6 @@ > #define ICC_CTLR_EL3 "S3_6_C12_C12_4" > #define ICC_PMR_EL1 "S3_0_C4_C6_0" > > -static inline uint32_t gic_read_icc_sre(void) > -{ > - uint32_t val; > - asm volatile ("mrs %0, " ICC_SRE_EL3 : "=r" (val)); > - return val; > -} > - > static inline void gic_write_icc_sre(uint32_t val) > { > asm volatile ("msr " ICC_SRE_EL3 ", %0" : : "r" (val)); > diff --git a/common/gic-v3.c b/common/gic-v3.c > index 62f9676..6207007 100644 > --- a/common/gic-v3.c > +++ b/common/gic-v3.c > @@ -42,6 +42,8 @@ > #define GICR_TYPER_Last (1 << 4) > > #define ICC_SRE_SRE (1 << 0) > +#define ICC_SRE_DFB (1 << 1) > +#define ICC_SRE_DIB (1 << 2) > #define ICC_SRE_Enable (1 << 3) > > void gic_secure_init_primary(void) > @@ -101,8 +103,6 @@ void gic_secure_init_primary(void) > > void gic_secure_init(void) > { > - uint32_t sre; > - > /* > * If GICv3 is not available, skip initialisation. The OS will probably > * fail with a warning, but this should be easier to debug than a > @@ -114,9 +114,7 @@ void gic_secure_init(void) > if (this_cpu_logical_id() == 0) > gic_secure_init_primary(); > > - sre = gic_read_icc_sre(); > - sre |= ICC_SRE_Enable | ICC_SRE_SRE; > - gic_write_icc_sre(sre); > + gic_write_icc_sre(ICC_SRE_Enable | ICC_SRE_DIB | ICC_SRE_DFB | ICC_SRE_SRE); > isb(); > > gic_write_icc_ctlr(0); > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel