Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4764643rwo; Tue, 25 Jul 2023 10:32:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlGz7vQx6qH796GM9f3hVVCjABBq+30JZ+Bv3F9bLelVPZ0TbKjjCIN90bCh3zlARanTlzWj X-Received: by 2002:a17:902:e74c:b0:1bb:c8fa:4be6 with SMTP id p12-20020a170902e74c00b001bbc8fa4be6mr411656plf.15.1690306354836; Tue, 25 Jul 2023 10:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690306354; cv=none; d=google.com; s=arc-20160816; b=lhxQpatxCtdtNlCkFZhp8JTOZEauBKn1U2PFS7gTstLAS777m98wqwvjcvlQn4yLL3 CSm0jTR0C+cGxI1s/PGLzlZ1ZwhQZIOhXm4Nrup1YFJdV5P9zvTA4SBmuuqmAUBWkf1H kRmZlLjLreiswt1DFpsYZAYRgI29Q5XG1+dbdU4C39Ltix7kpQO4MWMwdN8KoO0/A/ze wIr4KzZXcsbR2aTnTB3EDxnah1mQX2rOv6HONtzLe3L502+r4xrMj5pve9N5k9KCKfyo BkrAAEMlXTDjw3+g/08G/qkrVBDkoB2e+fpGYSsATa17un+6CEjxEYeR9v59jCjhbS/F x+rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=B6Gg/21DUj8BBHXtj4uV34ViHfpFw01nxRnk0GddDOA=; fh=X28CbmCDXWpGIs2JcUgHbSOYclQzv0sRlsRCnijt628=; b=YaXbx7qlUwQQe6cCmhdVfaHeFKpFJQGj9pba7oImwguIFDiUH2QpW4H3VqLeu92UmZ eNinCRPxFRIGKgd/swQJct8wjvLJmUvg/h4gncZ9AGagzN+0CkdJkaV+O/jnY0ooIZ5t Ind8ifPyPJtksSe7c1zvbnJoECf/y8gaOfpKoNGjtoUvh0OOQrrq8pX8aBILra/6ftdj bDlqHWCxVL5qpVTLCbB61O/TNZCB8xLgnbrHHw4hj5ZvTiCgve9DqztQqPlo7Eyqn34C oKg1yRSjxBRKYS5MxL4EstEK+JHAq9vIP/VWuevzabQqvghRVwHMRLphz93Q2zwwgsG1 QThQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a170902c94500b001b9e9fa3a38si12401420pla.646.2023.07.25.10.32.04; Tue, 25 Jul 2023 10:32:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231270AbjGYRM3 (ORCPT + 99 others); Tue, 25 Jul 2023 13:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229938AbjGYRMZ (ORCPT ); Tue, 25 Jul 2023 13:12:25 -0400 X-Greylist: delayed 434 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 25 Jul 2023 10:12:23 PDT Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE52F19AF for ; Tue, 25 Jul 2023 10:12:23 -0700 (PDT) Received: from xmz-huawei.. (unknown [114.249.159.178]) by APP-05 (Coremail) with SMTP id zQCowADnbuuXAMBkSR2gDg--.49620S2; Wed, 26 Jul 2023 01:04:24 +0800 (CST) From: Mingzheng Xing To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: Bin Meng , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Mingzheng Xing Subject: [PATCH] riscv: Handle zicsr/zifencei issue between gcc and binutils Date: Wed, 26 Jul 2023 01:04:05 +0800 Message-Id: <20230725170405.251011-1-xingmingzheng@iscas.ac.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowADnbuuXAMBkSR2gDg--.49620S2 X-Coremail-Antispam: 1UD129KBjvJXoWxCr1DWw4UWFy3tr1UXryftFb_yoW5Xw1Dpa 9xAFn5Crs5X3yxC34rA34UWr1YvrZ5K3yagr17Gw15urs3Za4kKrWvvw4IqFyDAFZ7Kw4U Zr1fuasYgwn8XaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkE14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r 4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFyl IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j 6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHU DUUUUU= X-Originating-IP: [114.249.159.178] X-CM-SenderInfo: 50lqwzhlqj6xxhqjqxpvfd2hldfou0/1tbiBwIDCmS-00lwhgAAs7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When compiling the kernel with the toolchain composed of GCC >= 12.1.0 and binutils < 2.38, default ISA spec used when building binutils and GCC, the following build failure will appear because the CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI is not turned on. (i.e, gcc-12.1.0 and binutils-2.36, or gcc-12.3.0 and binutils-2.37, use default ISA spec.) CC arch/riscv/kernel/vdso/vgettimeofday.o <>/arch/riscv/include/asm/vdso/gettimeofday.h: Assembler messages: <>/arch/riscv/include/asm/vdso/gettimeofday.h:79: Error: unrecognized opcode `csrr a5,0xc01' Binutils has updated the default ISA spec version, and the community has responded well to this[1][2][3], but it appears that this is not over yet. We also need to consider the situation of binutils < 2.38 but GCC >= 12.1.0, since the combination between different versions of GCC and binutils is not unique, which is to some extent flexible. GCC release 12.1.0 updated the default ISA spec version in GCC commit[4]. For more information, please refer to: commit 6df2a016c0c8 ("riscv: fix build with binutils 2.38") commit e89c2e815e76 ("riscv: Handle zicsr/zifencei issues between clang and binutils") [1]: https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/aE1ZeHHCYf4 [2]: https://lore.kernel.org/all/20230308220842.1231003-1-conor@kernel.org [3]: https://lore.kernel.org/all/20230223220546.52879-1-conor@kernel.org [4]: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=98416dbb0a62579d4a7a4a76bab51b5b52fec2cd Signed-off-by: Mingzheng Xing --- arch/riscv/Kconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 4c07b9189c86..b49cea30f6cc 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -570,11 +570,15 @@ config TOOLCHAIN_HAS_ZIHINTPAUSE config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI def_bool y # https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc - depends on AS_IS_GNU && AS_VERSION >= 23800 + # https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=98416dbb0a62579d4a7a4a76bab51b5b52fec2cd + depends on CC_IS_GCC && GCC_VERSION >= 120100 || \ + AS_IS_GNU && AS_VERSION >= 23800 help Newer binutils versions default to ISA spec version 20191213 which moves some instructions from the I extension to the Zicsr and Zifencei extensions. + Similarly, GCC release 12.1.0 has changed the default ISA spec version to + 20191213, so the above situation requires this option to be enabled. config TOOLCHAIN_NEEDS_OLD_ISA_SPEC def_bool y -- 2.34.1