From nobody Wed Sep 3 05:54:09 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8020ECAAA1 for ; Mon, 24 Oct 2022 12:23:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233439AbiJXMXT (ORCPT ); Mon, 24 Oct 2022 08:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233397AbiJXMVd (ORCPT ); Mon, 24 Oct 2022 08:21:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1366A7C1B8; Mon, 24 Oct 2022 04:59:09 -0700 (PDT) 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 F132B612F0; Mon, 24 Oct 2022 11:58:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10B6AC433D7; Mon, 24 Oct 2022 11:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612698; bh=TLs3SwpJp5/ZQA5gaztA1mbGtWqcY3sdRIs2FWng1VI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tg6pVeBZ4O/wQPFhs+oZKKfR1PPmiueyahwLXWO4deDOeCYdTPneAjQsu12YjnaZi CHNTP62DCnqs2qyPBOGxPZTBeVSIlZQESZvm7zKpJDjbGLN1RtKVVq5qDfa3vjjFZ3 8VnzhtHPcu4Yj+xDoXnhGj6EIz9foUBYReFmrF/A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aurelien Jarno , Alexandre Ghiti , Palmer Dabbelt , Conor Dooley Subject: [PATCH 4.19 056/229] riscv: fix build with binutils 2.38 Date: Mon, 24 Oct 2022 13:29:35 +0200 Message-Id: <20221024113000.891820486@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Aurelien Jarno commit 6df2a016c0c8a3d0933ef33dd192ea6606b115e3 upstream. >From version 2.38, binutils default to ISA spec version 20191213. This means that the csr read/write (csrr*/csrw*) instructions and fence.i instruction has separated from the `I` extension, become two standalone extensions: Zicsr and Zifencei. As the kernel uses those instruction, this causes the following build failure: CC arch/riscv/kernel/vdso/vgettimeofday.o <>/arch/riscv/include/asm/vdso/gettimeofday.h: Assembler messag= es: <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unreco= gnized opcode `csrr a5,0xc01' <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unreco= gnized opcode `csrr a5,0xc01' <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unreco= gnized opcode `csrr a5,0xc01' <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unreco= gnized opcode `csrr a5,0xc01' The fix is to specify those extensions explicitely in -march. However as older binutils version do not support this, we first need to detect that. Signed-off-by: Aurelien Jarno Tested-by: Alexandre Ghiti Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman [Conor: converted to the 4.19 style of march string generation] Signed-off-by: Conor Dooley --- arch/riscv/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -49,9 +49,16 @@ ifeq ($(CONFIG_RISCV_ISA_C),y) KBUILD_ARCH_C =3D c endif =20 -KBUILD_AFLAGS +=3D -march=3D$(KBUILD_MARCH)$(KBUILD_ARCH_A)fd$(KBUILD_ARCH= _C) +# Newer binutils versions default to ISA spec version 20191213 which moves= some +# instructions from the I extension to the Zicsr and Zifencei extensions. +toolchain-need-zicsr-zifencei :=3D $(call cc-option-yn, -march=3D$(riscv-m= arch-y)_zicsr_zifencei) +ifeq ($(toolchain-need-zicsr-zifencei),y) + KBUILD_ARCH_ZISCR_ZIFENCEI =3D _zicsr_zifencei +endif + +KBUILD_AFLAGS +=3D -march=3D$(KBUILD_MARCH)$(KBUILD_ARCH_A)fd$(KBUILD_ARCH= _C)$(KBUILD_ARCH_ZISCR_ZIFENCEI) =20 -KBUILD_CFLAGS +=3D -march=3D$(KBUILD_MARCH)$(KBUILD_ARCH_A)$(KBUILD_ARCH_C) +KBUILD_CFLAGS +=3D -march=3D$(KBUILD_MARCH)$(KBUILD_ARCH_A)$(KBUILD_ARCH_C= )$(KBUILD_ARCH_ZISCR_ZIFENCEI) KBUILD_CFLAGS +=3D -mno-save-restore KBUILD_CFLAGS +=3D -DCONFIG_PAGE_OFFSET=3D$(CONFIG_PAGE_OFFSET)