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.5 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_GIT 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 1EDD0C4338F for ; Tue, 24 Aug 2021 13:52:20 +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 E651561245 for ; Tue, 24 Aug 2021 13:52:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E651561245 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-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B1doFd1Xn5gWuKkWjOXUR6vjcLsaie29uHBRCn+iiqU=; b=IxmcYmUNpqAt9K oINoGi+h0QDuO/FOjLSf/uHN1No/VYICl0KWzmYBoX178GyzRfhzdeDtsuja5dqTD8WBz9mYZRgV0 SwenaHcLi8T2lYPII+TE3pSozKPXuScH+22q2I7HjqEiI/RgnNClWoBBvDAE6/o5aDudGaKEU5kWH s1yPg2D4LWr9qazcLtA9yLBS8M/YqcLK9nk89luIINzVdSrDftT+1k0lFppHKMjS0z2uakyCZIdME RKPIWgeI1k5+Ni9VlM704NI5Ys8KHYhtqY3+seIqmhbB7Z8kPE7cMyT0HK3Jp5GN0VRuaRwymUqhH 5XgMdS+2AF3rQkTt2/Pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIWoe-003IuH-06; Tue, 24 Aug 2021 13:50:12 +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 1mIWnt-003IfV-Gf for linux-arm-kernel@lists.infradead.org; Tue, 24 Aug 2021 13:49:28 +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 B42A31435; Tue, 24 Aug 2021 06:49:23 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E96A23F766; Tue, 24 Aug 2021 06:49:22 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: alexandru.elisei@arm.com, andre.przywara@arm.com, mark.rutland@arm.com, maz@kernel.org Subject: [boot-wrapper PATCH 3/5] GICv3: initialize without RMW Date: Tue, 24 Aug 2021 14:48:58 +0100 Message-Id: <20210824134900.34849-4-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210824134900.34849-1-mark.rutland@arm.com> References: <20210824134900.34849-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210824_064925_661192_074B8570 X-CRM114-Status: GOOD ( 13.44 ) 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: , MIME-Version: 1.0 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 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`. Signed-off-by: Mark Rutland Cc: Marc Zyngier Cc: Alexandru Elisei Cc: Andre Przywara --- 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); -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel