Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp491432pxb; Wed, 3 Mar 2021 08:09:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEY9nXufY1A64yyYuyX6ZOoPlHB4zJwBIFi9xwiSxAvpfAKqbUgY7Jid7MUrbcl7ARSyEK X-Received: by 2002:a17:906:9152:: with SMTP id y18mr26639695ejw.19.1614787797347; Wed, 03 Mar 2021 08:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614787797; cv=none; d=google.com; s=arc-20160816; b=Y6Jjb95GNNBq8WCAU2ruzMsvPJhPrsAODEY6HjWjpr5gwm44LMd1fEZHh74ApLmS9r XWtOgHYbDAi8ywsvSwqj0x/lmJ4VMA9UGrvAP+n1eOgvawU0fVs2Y1X7js1nh3rhrKNe HzuMnB2Q4JPwOaN5GXlYwoXkqzqUa0ChuOzU6Vx+P5XizC7Y58+0QFIrm0xJxP92gZL7 YdbFkVyolCUi1OnsIo+DKMX/b+VoeNXgialhWj1V8SOyIHx2o+SPtv5iLSJwD7vaAe6Z cV/MQrmUYUlUrMik77uJfglnakmSUEWYDGreiNLbJJdiSczOnC4HyNxrpdqkG0cEXSns SpWg== 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=sZ5bLG9I2OldPKlcbuaoU7sJ0OXFMwFPBwZqN9tdWoc=; b=1ETeX4Dh1jv9PkRZ4elDp8s2he1oj6X0oLtQ3pedbR9Ula8u3kDpstvVX9G9BlJFt6 iWup2FRushpd7MmGKljT75RpdW552pn15mZ9G1Ee5J/vjAcKexcTklqJU8uO9xrdKUmR q1R+pjqwkY+2ZpBadACAMBZI3QLXFT+bO6s6lOmHjlFrgzjt8Wg+Rxi+ahtS6aCPNFJq D72VKm+EfBjlSkxXvd+eZdQjEU8AvNUtr/01oDJUHMtnRn0dA9UIAmEAnP/DCPIoH2bD ketExZbq6TOQ/3KhbhtnNxPj55HvCBtrpA+9UWLYqU0jy9Cx08B4doEa3H+nQieAKQ5r cZhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y8P14yAw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si4876844ejn.699.2021.03.03.08.04.30; Wed, 03 Mar 2021 08:09:57 -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=@linuxfoundation.org header.s=korg header.b=y8P14yAw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346275AbhCAXkj (ORCPT + 99 others); Mon, 1 Mar 2021 18:40:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:57190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239378AbhCASIg (ORCPT ); Mon, 1 Mar 2021 13:08:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 702D46523E; Mon, 1 Mar 2021 17:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619579; bh=8tTmOVdS1/PkhguOWQ0gRjVoSUMEQ+s3z+eGgd/9ks8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y8P14yAwzLcNlyOAw9YkTkceNkf8qtuJBwDnNcKiV3D3pfJ7kYk2KNz80FWFNK14o lYYBjuLpyJEZL+teZ+8tRtNVCXIfgICdquqTKuqcdHeN9F6m0zNA1h7R/gPIDPjjmF /7TZWczZ63AuPXrMoDsKsjPbL2o9PcnGYFxHHO9o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YunQiang Su , Aurelien Jarno , Thomas Bogendoerfer Subject: [PATCH 5.10 506/663] MIPS: Support binutils configured with --enable-mips-fix-loongson3-llsc=yes Date: Mon, 1 Mar 2021 17:12:34 +0100 Message-Id: <20210301161206.877659270@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aurelien Jarno commit 5373ae67c3aad1ab306cc722b5a80b831eb4d4d1 upstream. >From version 2.35, binutils can be configured with --enable-mips-fix-loongson3-llsc=yes, which means it defaults to -mfix-loongson3-llsc. This breaks labels which might then point at the wrong instruction. The workaround to explicitly pass -mno-fix-loongson3-llsc has been added in Linux version 5.1, but is only enabled when building a Loongson 64 kernel. As vendors might use a common toolchain for building Loongson and non-Loongson kernels, just move that workaround to arch/mips/Makefile. At the same time update the comments to reflect the current status. Cc: stable@vger.kernel.org # 5.1+ Cc: YunQiang Su Signed-off-by: Aurelien Jarno Signed-off-by: Thomas Bogendoerfer Signed-off-by: Greg Kroah-Hartman --- arch/mips/Makefile | 19 +++++++++++++++++++ arch/mips/loongson64/Platform | 22 ---------------------- 2 files changed, 19 insertions(+), 22 deletions(-) --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -136,6 +136,25 @@ cflags-$(CONFIG_SB1XXX_CORELIS) += $(cal # cflags-y += -fno-stack-check +# binutils from v2.35 when built with --enable-mips-fix-loongson3-llsc=yes, +# supports an -mfix-loongson3-llsc flag which emits a sync prior to each ll +# instruction to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h +# for a description). +# +# We disable this in order to prevent the assembler meddling with the +# instruction that labels refer to, ie. if we label an ll instruction: +# +# 1: ll v0, 0(a0) +# +# ...then with the assembler fix applied the label may actually point at a sync +# instruction inserted by the assembler, and if we were using the label in an +# exception table the table would no longer contain the address of the ll +# instruction. +# +# Avoid this by explicitly disabling that assembler behaviour. +# +cflags-y += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) + # # CPU-dependent compiler/assembler options for optimization. # --- a/arch/mips/loongson64/Platform +++ b/arch/mips/loongson64/Platform @@ -6,28 +6,6 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap # -# Some versions of binutils, not currently mainline as of 2019/02/04, support -# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction -# to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h for a -# description). -# -# We disable this in order to prevent the assembler meddling with the -# instruction that labels refer to, ie. if we label an ll instruction: -# -# 1: ll v0, 0(a0) -# -# ...then with the assembler fix applied the label may actually point at a sync -# instruction inserted by the assembler, and if we were using the label in an -# exception table the table would no longer contain the address of the ll -# instruction. -# -# Avoid this by explicitly disabling that assembler behaviour. If upstream -# binutils does not merge support for the flag then we can revisit & remove -# this later - for now it ensures vendor toolchains don't cause problems. -# -cflags-$(CONFIG_CPU_LOONGSON64) += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) - -# # binutils from v2.25 on and gcc starting from v4.9.0 treat -march=loongson3a # as MIPS64 R2; older versions as just R1. This leaves the possibility open # that GCC might generate R2 code for -march=loongson3a which then is rejected