Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5534704pxb; Wed, 26 Jan 2022 14:22:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHBnlXbKVtI40nt2hhzYTiEPgDNlhJOtqxYfjxB8TGSB6gWQOk5RFDRn94mzspOiDRaC6k X-Received: by 2002:aa7:d541:: with SMTP id u1mr1027057edr.388.1643235778964; Wed, 26 Jan 2022 14:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643235778; cv=none; d=google.com; s=arc-20160816; b=t+fGzfVNfL+aRmfEJzZFCuSXQ4YNymLyizQVLKUqZHE+0NPhoffHFpxD4G2EDRonLy bRnTduq/qSz/i46ABOZGeYFFia5lTzt0JQDB7aeqJkzJJQeN/ZwcBfEgeopUK1LIz5ya HL/+iNwN2Q1MRCFTo3YzPO/cpa7jv7LLM9CNtY+RSxkXyhM4Mtj5okdXx/n5iygJrpL9 X6XvhXmc66aUdZqjtwf5nd7YTW3D+WC5pkCMqhR6032D7deGCW1E+UlfG4dGcPiSotCZ ykVhqSpln/8u2dT0VY1UQfk30mTiS2H8HRu722dyN53bnrm8zb6/4FSz0nHv4cytCMkF ni6Q== 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:dkim-signature; bh=JcMDygQ3jwximp20F0L2sMP6dOWvpxTtwX9dpTRf13o=; b=Di6s70FFz1E/nFJZaoobPVmvsFivVPD0YXXYhQRWYJasmZg79nZHGPuUr34B7CyOyG IDYVTp51ylajQDqwshkiuvG4y+P/WjIzS0yD2ug0btAueFeq4id8KpFCDerLcNDgC2G+ AoWjnfhljv9Aj6Y9CrswMna57YmXhPFrEVhy7pUrNlPaorN4u2gM11koAzD5hRzxJmaL Keh8HYUXYRhSvuSSmPFiLnuSKVpYd61oBVSur/MFDDed9mrsmhygjlBIMH5szOLU3WVt MGk+xaM3tVMDuAIqksPqRJDheDYySnHN6sthpTMRov5Mi9f0p0U5rhpAo/G5u4Pczedj w5ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aurel32.net header.s=202004.hall header.b=FgHcbTeJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sa21si308843ejc.979.2022.01.26.14.22.33; Wed, 26 Jan 2022 14:22:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aurel32.net header.s=202004.hall header.b=FgHcbTeJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243627AbiAZRPO (ORCPT + 99 others); Wed, 26 Jan 2022 12:15:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233073AbiAZRPM (ORCPT ); Wed, 26 Jan 2022 12:15:12 -0500 Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B66C06161C for ; Wed, 26 Jan 2022 09:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Content-Type:From:Reply-To:Subject:Content-ID: Content-Description:In-Reply-To:References:X-Debbugs-Cc; bh=JcMDygQ3jwximp20F0L2sMP6dOWvpxTtwX9dpTRf13o=; b=FgHcbTeJt+uvUQR6oh7qwpxdYX 1mpfNXVC0gmKsHHP2B1yg368NoThRObuLXqxuTsbPF4W+OKfIMecSSYu/RJYBBk2TzT8ibhWgybsA NsKhDbpRmmL7KvxDQ7A7qlOfeGEKTdp0X0JNyGswv3KgbWdbLDl0P7xzzfj2aRCcG3dYYGtn59DDV c7WxPdrkOJWgoFEkyfqNdxgh2GC6W9vg00PNC6MCfjCdMDjDcT9rbGg7HyOA7g7DnebDsi4vr6JGn sqmPBPmpRrEa2twe0/A+fUU4UuXWAOyeKrT1IZDSLk5Bm00r7aSRLg48AI1OWKfK1HkNWZiX1Kqw7 fThuM5Hg==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nClsx-00Gm2K-NS; Wed, 26 Jan 2022 18:15:07 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.95) (envelope-from ) id 1nClsx-005cI1-6x; Wed, 26 Jan 2022 18:15:07 +0100 From: Aurelien Jarno To: linux-kernel@vger.kernel.org Cc: Aurelien Jarno , stable@vger.kernel.org, Kito Cheng , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE) Subject: [PATCH] riscv: fix build with binutils 2.38 Date: Wed, 26 Jan 2022 18:14:42 +0100 Message-Id: <20220126171442.1338740-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 messages: <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01' <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01' <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01' <>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized 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. Cc: stable@vger.kernel.org # 4.15+ Cc: Kito Cheng Signed-off-by: Aurelien Jarno --- arch/riscv/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 8a107ed18b0d..7d81102cffd4 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -50,6 +50,12 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)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 := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei) +riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei + KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) KBUILD_AFLAGS += -march=$(riscv-march-y) -- 2.34.1