From patchwork Sun Jul 10 07:56:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 12912411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1ED09CCA479 for ; Sun, 10 Jul 2022 07:57:15 +0000 (UTC) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=QWxDCEcfBsTSQAksBJi4nDNqb/2X6tGgfDb4nyar4hs=; b=bCxdd3Ay+YOkkx PeCU8QVius1dA5d+pBTlZXIHDGRM1fA1hUMt8ynqrRxbhRKt44V272twi1Rxdp8xLhH16hJxx0HcB elvutTQ1sYATCHrvKhB/iYH0+1ZK70wNsmus8ScmU/JANaL4ewaipfwzqvqvUpofhavxDg4XtHiOh RyEwFRIP6dVRLVHIn+wUg4vh9DNghQySnS8nXSBRbujSRRVSwKTspEw68u6oOZLqFJB9E0UUkmrbf f+mpDFSzO9tMWd6OWFQfbJX0c7WvxqggZGE4Bo7FZGAdfjC5EzvXjk8xQ8T8MiANTEvxl3h5WSh0I tRkLS1va3cqOG1cLmJDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oARoN-00B3yN-Jx; Sun, 10 Jul 2022 07:57:03 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oARoL-00B3t4-5H for linux-riscv@lists.infradead.org; Sun, 10 Jul 2022 07:57:02 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7569A61147; Sun, 10 Jul 2022 07:56:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACB07C341CA; Sun, 10 Jul 2022 07:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657439818; bh=ERlRQJe95a6urK9nivFv22oXlGKUPv4TRBBlVhNKljA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fzkocnHruRU2ZIP+aw1h65j+1/HZiziY/bVyP5gS69zzQEZKt/QHcv1lhEHRUWaYk XB06K805rwDis22GMjhgrOgAnwFjCD+HZ4e6BQL6hhp9uUZUrPZOjVE53d/LMoJzo0 s1az9AKq+H6B7GByTGk0piXBYfyFNoUHIicIy0ho7+osKG7Z4jMkOaoA9nh0txs+n7 qK8eor0cFDU1yDIkR0AJ10aCOWARJZZdXYUbhbXUNUn7VCOOUgJGTd1MEIK9x0llsX +Vqk4G/7tfeelXcwJPFrkF5aXoklFxJoEH1KATrtVKI2Tix1qUDyGBM/z7+EPDxjMH W6+dALKpEIxyQ== From: guoren@kernel.org To: palmer@rivosinc.com, heiko@sntech.de, hch@infradead.org Cc: linux-riscv@lists.infradead.org, Guo Ren , Guo Ren Subject: [RFC PATCH V2 2/4] riscv: Cleanup ERRATA_THEAD_PBMT for rv32 svpbmt compile Date: Sun, 10 Jul 2022 03:56:42 -0400 Message-Id: <20220710075644.738455-3-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220710075644.738455-1-guoren@kernel.org> References: <20220710075644.738455-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_005701_283050_04466DF3 X-CRM114-Status: GOOD ( 11.60 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Guo Ren Make compile cleaner and don't reference the THEAD_PBMT data struct when CONFIG_ERRATA_THEAD_PBMT=y. Next, we could cleanly make svpbmt to support rv32. When current CONFIG_ERRATA_THEAD_PBMT is active in the alternative section added to the build. I.e. that translates to: .if IS_ENABLED(CONFIG_ERRATA_THEAD_PBMT) .pushsection .alternative, "a" ... But, above can't affect the below: ... "I"(prot##_THEAD >> ALT_THEAD_PBMT_SHIFT), ... "I"(ALT_THEAD_PBMT_SHIFT)) CONFIG_ERRATA_THEAD_PBMT is not clean enough, compiler still process the "I"(prot##_THEAD >> ALT_THEAD_PBMT_SHIFT)" & "I"(ALT_THEAD_PBMT_SHIFT). Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Heiko Stübner --- arch/riscv/include/asm/errata_list.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h index 416ead0f9a65..47175d91773d 100644 --- a/arch/riscv/include/asm/errata_list.h +++ b/arch/riscv/include/asm/errata_list.h @@ -47,6 +47,8 @@ asm(ALTERNATIVE("sfence.vma %0", "sfence.vma", SIFIVE_VENDOR_ID, \ * in the default case. */ #define ALT_SVPBMT_SHIFT 61 + +#ifdef CONFIG_ERRATA_THEAD_PBMT #define ALT_THEAD_PBMT_SHIFT 59 #define ALT_SVPBMT(_val, prot) \ asm(ALTERNATIVE_2("li %0, 0\t\nnop", \ @@ -60,7 +62,6 @@ asm(ALTERNATIVE_2("li %0, 0\t\nnop", \ "I"(ALT_SVPBMT_SHIFT), \ "I"(ALT_THEAD_PBMT_SHIFT)) -#ifdef CONFIG_ERRATA_THEAD_PBMT /* * IO/NOCACHE memory types are handled together with svpbmt, * so on T-Head chips, check if no other memory type is set, @@ -90,6 +91,14 @@ asm volatile(ALTERNATIVE( \ "I"(ALT_THEAD_PBMT_SHIFT) \ : "t3") #else +#define ALT_SVPBMT(_val, prot) \ +asm(ALTERNATIVE("li %0, 0\t\nnop", \ + "li %0, %1\t\nslli %0,%0,%2", 0, \ + CPUFEATURE_SVPBMT, CONFIG_RISCV_ISA_SVPBMT) \ + : "=r"(_val) \ + : "I"(prot##_SVPBMT >> ALT_SVPBMT_SHIFT), \ + "I"(ALT_SVPBMT_SHIFT)) + #define ALT_THEAD_PMA(_val) #endif