From patchwork Mon Oct 24 11:29:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp423510wru; Mon, 24 Oct 2022 05:25:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40fPQAuQUWSs74Xn8SwL1YqrWgo/PfECmEx8zfYYi9rF7T0i8gr+pV4xV3d1hePBrM6SsP X-Received: by 2002:a17:906:fe0b:b0:787:f1d3:2105 with SMTP id wy11-20020a170906fe0b00b00787f1d32105mr27314727ejb.83.1666614308407; Mon, 24 Oct 2022 05:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614308; cv=none; d=google.com; s=arc-20160816; b=K/gWCDj2M2RWFORNA9CIoSvVZ0awDQjcZFOxn6gpXZDM7DKmFicWaUJQWjI++iTfSw KKHInXht+j6aE+wx2S3EqZPcqbXaR6TbwmCyz9FLh9qlDJvkVdEAcMNfAAFlXm2O5zf+ 9FdhCMgzFnprzNEQ2iqteUUJ4Pj/sNkdiVK+aOIA+CHaVAaOYtl1MorNX7UW9tbUXoND i1jdUd/cNktyFDtC8xBD9P+UMFXxAyiB9DQ0mbCjfFNtdadIeEjliuZYu3YCQBnBYi70 a7Z4Nj6XuhmWEHkpsEntsKlO8pVGnAURHwdfAQW+h6hnziJs74i3onjCuOOmjKorZ8BL uDFQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yayZkZ63CJJ1lumb5nhRqdevCm3NFHt6DlcRGMG+6d0=; b=zqnbZEglxAiGn0uFDm+tkPr6AB1z3ZA9Bg5jm/XbNcPiM4mKghF9Qqk9niXK0qHrkp wggI5HuVxEj+B2qP9Uay+g/Yo7HTJyjMA1Tcd4pSq32IH/xhoUotLG3zant14uSNa22y CIwkW2l+jmWH6ETOE3ofqaSAlLhJBJjgOOOEbhkeOFoBIxw0GG2LQ3z8oDyWDSxnVybR EbM4FFgAoq5OnrCpJxdRO3T/mjKqtKzxfmnzk037p51aHs5AdMaTXTEx8uL8toJeltkV Au5a6rHaPMznbqqVez7dXYp0gu6VLqnQSa4LRe/mrJ5TCeJsLT4SJs3lQnjOGE/zxz+Z PfCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tg6pVeBZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xa8-20020a170906fd8800b0079dccbbf0c0si9330003ejb.146.2022.10.24.05.24.43; Mon, 24 Oct 2022 05:25:08 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tg6pVeBZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233436AbiJXMXT (ORCPT + 99 others); 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 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747571765209578467?= X-GMAIL-MSGID: =?utf-8?q?1747571765209578467?= 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 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. 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 = c endif -KBUILD_AFLAGS += -march=$(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 := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei) +ifeq ($(toolchain-need-zicsr-zifencei),y) + KBUILD_ARCH_ZISCR_ZIFENCEI = _zicsr_zifencei +endif + +KBUILD_AFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)fd$(KBUILD_ARCH_C)$(KBUILD_ARCH_ZISCR_ZIFENCEI) -KBUILD_CFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)$(KBUILD_ARCH_C) +KBUILD_CFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)$(KBUILD_ARCH_C)$(KBUILD_ARCH_ZISCR_ZIFENCEI) KBUILD_CFLAGS += -mno-save-restore KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)