Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1104687pxb; Thu, 21 Oct 2021 16:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWbDSBhkzhZKM0hoalUWknQhO+pCQHjXJlk6/0LDQ7AZWRHFNNkeJavwIeDQrSz/TcBUV7 X-Received: by 2002:a63:1406:: with SMTP id u6mr6606524pgl.106.1634857319290; Thu, 21 Oct 2021 16:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634857319; cv=none; d=google.com; s=arc-20160816; b=jphFIz9dS7Wsd6e1cbjn72G0DDQ4/AzqFh4DMoBIDt3BRLI0MwipFXKFX854ezN/is sC9CD3jAU9MEuXtrWn1xQEfMYUn8Fbd8pQUTJHS6j6xQr6vTLXzmVWWrnx4XucxBkZ0q N6wAdjMUEMJEqr2EMFBK+kYWgjn6kCRH2rgBs6O7+K+o9pFq1MTfk+Ye3lpDIqC7NMvm wC7nI3KbgeFqyO0uxh5Pby7nyOPLu0vZgHfaGmZqrFvT12vNJzYAgwvVIYSOuDK5d+Oq jcyvQ94D0knpw3VoPKInwm5VMlyBMk0lKObiVJRpvcuzLIggN5E5fLEbl//YajeOQ/SN ++kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:subject:cc:to :from:date; bh=fMHOB1pDfSIC9/i1nMX1f7O1luByEEcUg2pKj0tavbo=; b=rYfAsV62pjKUefS2xaPHEFmWCd5pSzdzKWccGnGwyVTKW5NE3HFyNkCb3DyZNVtNs3 frMtAGT31F/zTJD0VDlpm0liMNUy2Fp0fVGwzhd9wFpYYhvLnCMF4BrEfp5ebWdEAM5d oB0hBmbMR7V3KkAYIl0B7Bu92vJpCFpcxBRiZWH/sHe6/dGwf9DsF1s7pzd46x8oy3ep 1T0/l7FHIiwX5iMj6mvJBhDRZkd9r4qeArML/dhfHn+YA9oruDJ3WBjwUXTOnjms8imV v+leWMUU+MmltuFHpOWPUFKZZYfVWJi3mJKlg5riaeQjDTt20OcxxPYepoEUDddW3ERV yiSg== ARC-Authentication-Results: i=1; mx.google.com; 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 x22si302619pgj.320.2021.10.21.16.01.37; Thu, 21 Oct 2021 16:01:59 -0700 (PDT) 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; 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 S231542AbhJUXAr (ORCPT + 99 others); Thu, 21 Oct 2021 19:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232060AbhJUXAq (ORCPT ); Thu, 21 Oct 2021 19:00:46 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 10172C061764; Thu, 21 Oct 2021 15:58:26 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 4427692009C; Fri, 22 Oct 2021 00:58:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 3581692009B; Fri, 22 Oct 2021 00:58:23 +0200 (CEST) Date: Fri, 22 Oct 2021 00:58:23 +0200 (CEST) From: "Maciej W. Rozycki" To: Thomas Bogendoerfer cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] MIPS: Fix assembly error from MIPSr2 code used within MIPS_ISA_ARCH_LEVEL Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix assembly errors like: {standard input}: Assembler messages: {standard input}:287: Error: opcode not supported on this processor: mips3 (mips3) `dins $10,$7,32,32' {standard input}:680: Error: opcode not supported on this processor: mips3 (mips3) `dins $10,$7,32,32' {standard input}:1274: Error: opcode not supported on this processor: mips3 (mips3) `dins $12,$9,32,32' {standard input}:2175: Error: opcode not supported on this processor: mips3 (mips3) `dins $10,$7,32,32' make[1]: *** [scripts/Makefile.build:277: mm/highmem.o] Error 1 with code produced from `__cmpxchg64' for MIPS64r2 CPU configurations using CONFIG_32BIT and CONFIG_PHYS_ADDR_T_64BIT. This is due to MIPS_ISA_ARCH_LEVEL downgrading the assembly architecture to `r4000' i.e. MIPS III for MIPS64r2 configurations, while there is a block of code containing a DINS MIPS64r2 instruction conditionalized on MIPS_ISA_REV >= 2 within the scope of the downgrade. The assembly architecture override code pattern has been put there for LL/SC instructions, so that code compiles for configurations that select a processor to build for that does not support these instructions while still providing run-time support for processors that do, dynamically switched by non-constant `cpu_has_llsc'. It went in with linux-mips.org commit aac8aa7717a2 ("Enable a suitable ISA for the assembler around ll/sc so that code builds even for processors that don't support the instructions. Plus minor formatting fixes.") back in 2005. Fix the problem by wrapping these instructions along with the adjacent SYNC instructions only, following the practice established with commit cfd54de3b0e4 ("MIPS: Avoid move psuedo-instruction whilst using MIPS_ISA_LEVEL") and commit 378ed6f0e3c5 ("MIPS: Avoid using .set mips0 to restore ISA"). Strictly speaking the SYNC instructions do not have to be wrapped as they are only used as a Loongson3 erratum workaround, so they will be enabled in the assembler by default, but do this so as to keep code consistent with other places. Reported-by: kernel test robot Signed-off-by: Maciej W. Rozycki Fixes: c7e2d71dda7a ("MIPS: Fix set_pte() for Netlogic XLR using cmpxchg64()") Cc: stable@vger.kernel.org # v5.1+ --- So it's turned out I was right after all with v1, just did not correctly remember the reason for the arrangement with an ISA override around LL/SC, actually made by myself back in 2005. Therefore here is a minor update to v1 only, which was actually right except for a cosmetic issue around SYNC. And as I have thought major decluttering is due here. What seemed a good idea back in 2005 has never materialised and I think we don't really want to support dynamic `cpu_has_llsc' anymore in 2021. But let's leave it for another occasion and fix the build error at hand only. Changes from v1: - Keep __SYNC references under MIPS_ISA_ARCH_LEVEL. - Expand change description. --- arch/mips/include/asm/cmpxchg.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) linux-mips-cmpxchg64-isa-arch-level.diff Index: linux-test/arch/mips/include/asm/cmpxchg.h =================================================================== --- linux-test.orig/arch/mips/include/asm/cmpxchg.h +++ linux-test/arch/mips/include/asm/cmpxchg.h @@ -249,6 +249,7 @@ static inline unsigned long __cmpxchg64( /* Load 64 bits from ptr */ " " __SYNC(full, loongson3_war) " \n" "1: lld %L0, %3 # __cmpxchg64 \n" + " .set pop \n" /* * Split the 64 bit value we loaded into the 2 registers that hold the * ret variable. @@ -276,12 +277,14 @@ static inline unsigned long __cmpxchg64( " or %L1, %L1, $at \n" " .set at \n" # endif + " .set push \n" + " .set " MIPS_ISA_ARCH_LEVEL " \n" /* Attempt to store new at ptr */ " scd %L1, %2 \n" /* If we failed, loop! */ "\t" __SC_BEQZ "%L1, 1b \n" - " .set pop \n" "2: " __SYNC(full, loongson3_war) " \n" + " .set pop \n" : "=&r"(ret), "=&r"(tmp), "=" GCC_OFF_SMALL_ASM() (*(unsigned long long *)ptr)