|
Takashi Iwai |
7ac892 |
From e95e07bab005682d2bf0e26cd0d009b18837abfe Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
7ac892 |
From: "Maciej W. Rozycki" <macro@orcam.me.uk>
|
|
Takashi Iwai |
7ac892 |
Date: Fri, 22 Oct 2021 00:58:23 +0200
|
|
Takashi Iwai |
7ac892 |
Subject: [PATCH] MIPS: Fix assembly error from MIPSr2 code used within MIPS_ISA_ARCH_LEVEL
|
|
Takashi Iwai |
7ac892 |
Git-commit: a923a2676e60683aee46aa4b93c30aff240ac20d
|
|
Takashi Iwai |
7ac892 |
Patch-mainline: v5.16-rc1
|
|
Takashi Iwai |
7ac892 |
References: stable-5.14.19
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
commit a923a2676e60683aee46aa4b93c30aff240ac20d upstream.
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
Fix assembly errors like:
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
{standard input}: Assembler messages:
|
|
Takashi Iwai |
7ac892 |
{standard input}:287: Error: opcode not supported on this processor: mips3 (mips3) `dins $10,$7,32,32'
|
|
Takashi Iwai |
7ac892 |
{standard input}:680: Error: opcode not supported on this processor: mips3 (mips3) `dins $10,$7,32,32'
|
|
Takashi Iwai |
7ac892 |
{standard input}:1274: Error: opcode not supported on this processor: mips3 (mips3) `dins $12,$9,32,32'
|
|
Takashi Iwai |
7ac892 |
{standard input}:2175: Error: opcode not supported on this processor: mips3 (mips3) `dins $10,$7,32,32'
|
|
Takashi Iwai |
7ac892 |
Make[1]: *** [scripts/Makefile.build:277: mm/highmem.o] Error 1
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
with code produced from `__cmpxchg64' for MIPS64r2 CPU configurations
|
|
Takashi Iwai |
7ac892 |
using CONFIG_32BIT and CONFIG_PHYS_ADDR_T_64BIT.
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
This is due to MIPS_ISA_ARCH_LEVEL downgrading the assembly architecture
|
|
Takashi Iwai |
7ac892 |
to `r4000' i.e. MIPS III for MIPS64r2 configurations, while there is a
|
|
Takashi Iwai |
7ac892 |
block of code containing a DINS MIPS64r2 instruction conditionalized on
|
|
Takashi Iwai |
7ac892 |
MIPS_ISA_REV >= 2 within the scope of the downgrade.
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
The assembly architecture override code pattern has been put there for
|
|
Takashi Iwai |
7ac892 |
LL/SC instructions, so that code compiles for configurations that select
|
|
Takashi Iwai |
7ac892 |
a processor to build for that does not support these instructions while
|
|
Takashi Iwai |
7ac892 |
still providing run-time support for processors that do, dynamically
|
|
Takashi Iwai |
7ac892 |
switched by non-constant `cpu_has_llsc'. It went in with linux-mips.org
|
|
Takashi Iwai |
7ac892 |
commit aac8aa7717a2 ("Enable a suitable ISA for the assembler around
|
|
Takashi Iwai |
7ac892 |
ll/sc so that code builds even for processors that don't support the
|
|
Takashi Iwai |
7ac892 |
instructions. Plus minor formatting fixes.") back in 2005.
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
Fix the problem by wrapping these instructions along with the adjacent
|
|
Takashi Iwai |
7ac892 |
SYNC instructions only, following the practice established with commit
|
|
Takashi Iwai |
7ac892 |
cfd54de3b0e4 ("MIPS: Avoid move psuedo-instruction whilst using
|
|
Takashi Iwai |
7ac892 |
MIPS_ISA_LEVEL") and commit 378ed6f0e3c5 ("MIPS: Avoid using .set mips0
|
|
Takashi Iwai |
7ac892 |
to restore ISA"). Strictly speaking the SYNC instructions do not have
|
|
Takashi Iwai |
7ac892 |
to be wrapped as they are only used as a Loongson3 erratum workaround,
|
|
Takashi Iwai |
7ac892 |
so they will be enabled in the assembler by default, but do this so as
|
|
Takashi Iwai |
7ac892 |
to keep code consistent with other places.
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
Reported-by: kernel test robot <lkp@intel.com>
|
|
Takashi Iwai |
7ac892 |
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
|
|
Takashi Iwai |
7ac892 |
Fixes: c7e2d71dda7a ("MIPS: Fix set_pte() for Netlogic XLR using cmpxchg64()")
|
|
Takashi Iwai |
7ac892 |
Cc: stable@vger.kernel.org # v5.1+
|
|
Takashi Iwai |
7ac892 |
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
|
|
Takashi Iwai |
7ac892 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
Takashi Iwai |
7ac892 |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
---
|
|
Takashi Iwai |
7ac892 |
arch/mips/include/asm/cmpxchg.h | 5 ++++-
|
|
Takashi Iwai |
7ac892 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
Takashi Iwai |
7ac892 |
|
|
Takashi Iwai |
7ac892 |
diff --git a/arch/mips/include/asm/cmpxchg.h b/arch/mips/include/asm/cmpxchg.h
|
|
Takashi Iwai |
7ac892 |
index 0b983800f48b..66a8b293fd80 100644
|
|
Takashi Iwai |
7ac892 |
--- a/arch/mips/include/asm/cmpxchg.h
|
|
Takashi Iwai |
7ac892 |
+++ b/arch/mips/include/asm/cmpxchg.h
|
|
Takashi Iwai |
7ac892 |
@@ -249,6 +249,7 @@ static inline unsigned long __cmpxchg64(volatile void *ptr,
|
|
Takashi Iwai |
7ac892 |
/* Load 64 bits from ptr */
|
|
Takashi Iwai |
7ac892 |
" " __SYNC(full, loongson3_war) " \n"
|
|
Takashi Iwai |
7ac892 |
"1: lld %L0, %3 # __cmpxchg64 \n"
|
|
Takashi Iwai |
7ac892 |
+ " .set pop \n"
|
|
Takashi Iwai |
7ac892 |
/*
|
|
Takashi Iwai |
7ac892 |
* Split the 64 bit value we loaded into the 2 registers that hold the
|
|
Takashi Iwai |
7ac892 |
* ret variable.
|
|
Takashi Iwai |
7ac892 |
@@ -276,12 +277,14 @@ static inline unsigned long __cmpxchg64(volatile void *ptr,
|
|
Takashi Iwai |
7ac892 |
" or %L1, %L1, $at \n"
|
|
Takashi Iwai |
7ac892 |
" .set at \n"
|
|
Takashi Iwai |
7ac892 |
# endif
|
|
Takashi Iwai |
7ac892 |
+ " .set push \n"
|
|
Takashi Iwai |
7ac892 |
+ " .set " MIPS_ISA_ARCH_LEVEL " \n"
|
|
Takashi Iwai |
7ac892 |
/* Attempt to store new at ptr */
|
|
Takashi Iwai |
7ac892 |
" scd %L1, %2 \n"
|
|
Takashi Iwai |
7ac892 |
/* If we failed, loop! */
|
|
Takashi Iwai |
7ac892 |
"\t" __SC_BEQZ "%L1, 1b \n"
|
|
Takashi Iwai |
7ac892 |
- " .set pop \n"
|
|
Takashi Iwai |
7ac892 |
"2: " __SYNC(full, loongson3_war) " \n"
|
|
Takashi Iwai |
7ac892 |
+ " .set pop \n"
|
|
Takashi Iwai |
7ac892 |
: "=&r"(ret),
|
|
Takashi Iwai |
7ac892 |
"=&r"(tmp),
|
|
Takashi Iwai |
7ac892 |
"=" GCC_OFF_SMALL_ASM() (*(unsigned long long *)ptr)
|
|
Takashi Iwai |
7ac892 |
--
|
|
Takashi Iwai |
7ac892 |
2.26.2
|
|
Takashi Iwai |
7ac892 |
|