* [PATCH 0/8] MIPS: Aggregate build fixes
@ 2024-02-02 18:21 Jiaxun Yang
2024-02-02 18:21 ` [PATCH 1/8] MIPS: Probe toolchain support of -msym32 Jiaxun Yang
` (9 more replies)
0 siblings, 10 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang, Guenter Roeck
Hi all,
This series is a collection of build fixes that have been lying
at my local trees for a while, some of them are for Clang built
linux and others are for some wiredo configurations.
Please review.
Thanks
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
Jiaxun Yang (8):
MIPS: Probe toolchain support of -msym32
MIPS: Remove cc-option checks for -march=octeon
MIPS: Fallback CPU -march flag to ISA level if unsupported
MIPS: BMIPS: Drop unnecessary assembler flag
MIPS: Loongson64: test for -march=loongson3a cflag
MIPS: Limit MIPS_MT_SMP support by ISA reversion
MIPS: Implement microMIPS MT ASE helpers
MIPS: mipsregs: Set proper ISA level for virt extensions
arch/mips/Kconfig | 3 +-
arch/mips/Makefile | 46 ++++---
arch/mips/include/asm/asmmacro.h | 22 ++--
arch/mips/include/asm/mipsmtregs.h | 256 ++++++++++++++++++++++---------------
arch/mips/include/asm/mipsregs.h | 22 +++-
arch/mips/kernel/vpe-mt.c | 4 +-
6 files changed, 211 insertions(+), 142 deletions(-)
---
base-commit: 076d56d74f17e625b3d63cf4743b3d7d02180379
change-id: 20240202-llvm-msym32-6392d410f650
Best regards,
--
Jiaxun Yang <jiaxun.yang@flygoat.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/8] MIPS: Probe toolchain support of -msym32
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-02-02 18:21 ` [PATCH 2/8] MIPS: Remove cc-option checks for -march=octeon Jiaxun Yang
` (8 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang
msym32 is not supported by LLVM toolchain.
Workaround by probe toolchain support of msym32 for KBUILD_SYM32
feature.
Link: https://github.com/ClangBuiltLinux/linux/issues/1544
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index f49807e1f19b..0888074f4dfe 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -299,7 +299,7 @@ drivers-$(CONFIG_PCI) += arch/mips/pci/
ifdef CONFIG_64BIT
ifndef KBUILD_SYM32
ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0)
- KBUILD_SYM32 = y
+ KBUILD_SYM32 = $(call cc-option-yn, -msym32)
endif
endif
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/8] MIPS: Remove cc-option checks for -march=octeon
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
2024-02-02 18:21 ` [PATCH 1/8] MIPS: Probe toolchain support of -msym32 Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-02-02 18:21 ` [PATCH 3/8] MIPS: Fallback CPU -march flag to ISA level if unsupported Jiaxun Yang
` (7 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang
Nowadays our minimal supported GCC/Clang all support -march=octeon.
Remove cc-option checks to simplify code.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
v0: https://lore.kernel.org/all/20230414080701.15503-6-jiaxun.yang@flygoat.com/
---
arch/mips/Makefile | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 0888074f4dfe..daa569ca4372 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -174,10 +174,7 @@ cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mdmx)
cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mips3d)
cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \
-Wa,--trap
-cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += $(call cc-option,-march=octeon) -Wa,--trap
-ifeq (,$(findstring march=octeon, $(cflags-$(CONFIG_CPU_CAVIUM_OCTEON))))
-cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon
-endif
+cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -march=octeon -Wa,--trap
cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
cflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,-mips32 -Wa,--trap
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/8] MIPS: Fallback CPU -march flag to ISA level if unsupported
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
2024-02-02 18:21 ` [PATCH 1/8] MIPS: Probe toolchain support of -msym32 Jiaxun Yang
2024-02-02 18:21 ` [PATCH 2/8] MIPS: Remove cc-option checks for -march=octeon Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-02-02 18:21 ` [PATCH 4/8] MIPS: BMIPS: Drop unnecessary assembler flag Jiaxun Yang
` (6 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang
LLVM does not implement some of -march options. However those options
are not mandatory for kernel to build for those CPUs.
Fallback -march CFLAG to ISA level if unsupported by toolchain so
we can get those kernel to build with LLVM.
Link: https://github.com/ClangBuiltLinux/linux/issues/1544
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
v0: https://lore.kernel.org/all/20230414080701.15503-7-jiaxun.yang@flygoat.com/
v1: Fix SB1 arch level to mips64
---
arch/mips/Makefile | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index daa569ca4372..91470931a5b8 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -148,10 +148,10 @@ cflags-y += $(call cc-option,-Wa$(comma)-mno-fix-loongson3-llsc,)
#
# CPU-dependent compiler/assembler options for optimization.
#
-cflags-$(CONFIG_CPU_R3000) += -march=r3000
-cflags-$(CONFIG_CPU_R4300) += -march=r4300 -Wa,--trap
-cflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap
-cflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap
+cflags-$(CONFIG_CPU_R3000) += $(call cc-option,-march=r3000,-march=mips1)
+cflags-$(CONFIG_CPU_R4300) += $(call cc-option,-march=r4300,-march=mips3) -Wa,--trap
+cflags-$(CONFIG_CPU_R4X00) += $(call cc-option,-march=r4600,-march=mips3) -Wa,--trap
+cflags-$(CONFIG_CPU_TX49XX) += $(call cc-option,-march=r4600,-march=mips3) -Wa,--trap
cflags-$(CONFIG_CPU_MIPS32_R1) += -march=mips32 -Wa,--trap
cflags-$(CONFIG_CPU_MIPS32_R2) += -march=mips32r2 -Wa,--trap
cflags-$(CONFIG_CPU_MIPS32_R5) += -march=mips32r5 -Wa,--trap -modd-spreg
@@ -160,26 +160,30 @@ cflags-$(CONFIG_CPU_MIPS64_R1) += -march=mips64 -Wa,--trap
cflags-$(CONFIG_CPU_MIPS64_R2) += -march=mips64r2 -Wa,--trap
cflags-$(CONFIG_CPU_MIPS64_R5) += -march=mips64r5 -Wa,--trap
cflags-$(CONFIG_CPU_MIPS64_R6) += -march=mips64r6 -Wa,--trap
-cflags-$(CONFIG_CPU_P5600) += -march=p5600 -Wa,--trap -modd-spreg
-cflags-$(CONFIG_CPU_R5000) += -march=r5000 -Wa,--trap
-cflags-$(CONFIG_CPU_R5500) += $(call cc-option,-march=r5500,-march=r5000) \
+cflags-$(CONFIG_CPU_P5600) += $(call cc-option,-march=p5600,-march=mips32r5) \
+ -Wa,--trap -modd-spreg
+cflags-$(CONFIG_CPU_R5000) += $(call cc-option,-march=r5000,-march=mips4) \
-Wa,--trap
-cflags-$(CONFIG_CPU_NEVADA) += $(call cc-option,-march=rm5200,-march=r5000) \
+cflags-$(CONFIG_CPU_R5500) += $(call cc-option,-march=r5500,-march=mips4) \
-Wa,--trap
-cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \
+cflags-$(CONFIG_CPU_NEVADA) += $(call cc-option,-march=rm5200,-march=mips4) \
-Wa,--trap
-cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \
+cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=mips4) \
+ -Wa,--trap
+cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=mips64) \
-Wa,--trap
cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mdmx)
cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mips3d)
-cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \
+cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=mips4) \
-Wa,--trap
cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -march=octeon -Wa,--trap
cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
cflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,-mips32 -Wa,--trap
-cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap
-cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap
+cflags-$(CONFIG_CPU_LOONGSON2E) += \
+ $(call cc-option,-march=loongson2e,-march=mips3) -Wa,--trap
+cflags-$(CONFIG_CPU_LOONGSON2F) += \
+ $(call cc-option,-march=loongson2f,-march=mips3) -Wa,--trap
# Some -march= flags enable MMI instructions, and GCC complains about that
# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi)
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/8] MIPS: BMIPS: Drop unnecessary assembler flag
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
` (2 preceding siblings ...)
2024-02-02 18:21 ` [PATCH 3/8] MIPS: Fallback CPU -march flag to ISA level if unsupported Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-02-02 18:21 ` [PATCH 5/8] MIPS: Loongson64: test for -march=loongson3a cflag Jiaxun Yang
` (5 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang
Nowadays GCC will always pass -march flag to gas, so there
is no need to pass another mips32 flag to assembler.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 91470931a5b8..5a078c5487d6 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -170,7 +170,7 @@ cflags-$(CONFIG_CPU_NEVADA) += $(call cc-option,-march=rm5200,-march=mips4) \
-Wa,--trap
cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=mips4) \
-Wa,--trap
-cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=mips64) \
+cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=mips64r1) \
-Wa,--trap
cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mdmx)
cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mips3d)
@@ -178,7 +178,7 @@ cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=mips4) \
-Wa,--trap
cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -march=octeon -Wa,--trap
cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
-cflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,-mips32 -Wa,--trap
+cflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,--trap
cflags-$(CONFIG_CPU_LOONGSON2E) += \
$(call cc-option,-march=loongson2e,-march=mips3) -Wa,--trap
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/8] MIPS: Loongson64: test for -march=loongson3a cflag
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
` (3 preceding siblings ...)
2024-02-02 18:21 ` [PATCH 4/8] MIPS: BMIPS: Drop unnecessary assembler flag Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-02-02 18:21 ` [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion Jiaxun Yang
` (4 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang
Currently march flag is hardcoded to loongson3a for GCC and
mips64r2 for clang.
We can actually test it to simplify the code.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/Makefile | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 5a078c5487d6..80aecba24892 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -187,11 +187,8 @@ cflags-$(CONFIG_CPU_LOONGSON2F) += \
# Some -march= flags enable MMI instructions, and GCC complains about that
# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi)
-ifdef CONFIG_CPU_LOONGSON64
-cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap
-cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a
-cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2
-endif
+cflags-$(CONFIG_CPU_LOONGSON64) += \
+ $(call cc-option,-march=loongson3a,-march=mips64r2) -Wa,--trap
cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-mno-loongson-mmi)
cflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,)
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
` (4 preceding siblings ...)
2024-02-02 18:21 ` [PATCH 5/8] MIPS: Loongson64: test for -march=loongson3a cflag Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-05-14 21:38 ` Maciej W. Rozycki
2024-02-02 18:21 ` [PATCH 7/8] MIPS: Implement microMIPS MT ASE helpers Jiaxun Yang
` (3 subsequent siblings)
9 siblings, 1 reply; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang, Guenter Roeck
MIPS MT ASE is only available on ISA between Release 1 and Release 5.
Add ISA level dependency to Kconfig to fix build.
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
v0: https://lore.kernel.org/all/20230414080701.15503-8-jiaxun.yang@flygoat.com/
---
arch/mips/Kconfig | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 797ae590ebdb..c44358a6d93e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2171,7 +2171,8 @@ config CPU_R4K_CACHE_TLB
config MIPS_MT_SMP
bool "MIPS MT SMP support (1 TC on each available VPE)"
default y
- depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS
+ depends on TARGET_ISA_REV > 0 && TARGET_ISA_REV < 6
+ depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MICROMIPS
select CPU_MIPSR2_IRQ_VI
select CPU_MIPSR2_IRQ_EI
select SYNC_R4K
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 7/8] MIPS: Implement microMIPS MT ASE helpers
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
` (5 preceding siblings ...)
2024-02-02 18:21 ` [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-02-02 18:21 ` [PATCH 8/8] MIPS: mipsregs: Set proper ISA level for virt extensions Jiaxun Yang
` (2 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang
Implement various microMIPS MT ASE helpers accroading to:
MIPS® Architecture for Programmers
Volume IV-f: The MIPS® MT Module for the microMIPS32™ Architecture
Fixes build error:
{standard input}:2616: Error: branch to a symbol in another ISA mode
This make MT ASE available on microMIPS as well.
Boot tested on M5150 with microMIPS enabled on M5150.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
v1: MTTGPR takes register name as rt
---
arch/mips/include/asm/asmmacro.h | 22 ++--
arch/mips/include/asm/mipsmtregs.h | 256 ++++++++++++++++++++++---------------
arch/mips/include/asm/mipsregs.h | 9 ++
arch/mips/kernel/vpe-mt.c | 4 +-
4 files changed, 179 insertions(+), 112 deletions(-)
diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
index 067a635d3bc8..18c2ae58cdf3 100644
--- a/arch/mips/include/asm/asmmacro.h
+++ b/arch/mips/include/asm/asmmacro.h
@@ -216,27 +216,33 @@
* Temporary until all gas have MT ASE support
*/
.macro DMT reg=0
- .word 0x41600bc1 | (\reg << 16)
+ insn_if_mips 0x41600bc1 | (\reg << 16)
+ insn32_if_mm 0x0000057C | (\reg << 21)
.endm
.macro EMT reg=0
- .word 0x41600be1 | (\reg << 16)
+ insn_if_mips 0x41600be1 | (\reg << 16)
+ insn32_if_mm 0x0000257C | (\reg << 21)
.endm
.macro DVPE reg=0
- .word 0x41600001 | (\reg << 16)
+ insn_if_mips 0x41600001 | (\reg << 16)
+ insn32_if_mm 0x0000157C | (\reg << 21)
.endm
.macro EVPE reg=0
- .word 0x41600021 | (\reg << 16)
+ insn_if_mips 0x41600021 | (\reg << 16)
+ insn32_if_mm 0x0000357C | (\reg << 21)
.endm
- .macro MFTR rt=0, rd=0, u=0, sel=0
- .word 0x41000000 | (\rt << 16) | (\rd << 11) | (\u << 5) | (\sel)
+ .macro MFTR rs=0, rt=0, u=0, sel=0
+ insn_if_mips 0x41000000 | (\rt << 16) | (\rs << 11) | (\u << 5) | (\sel)
+ insn32_if_mm 0x0000000E | (\rt << 21) | (\rs << 16) | (\u << 10) | (\sel << 4)
.endm
- .macro MTTR rt=0, rd=0, u=0, sel=0
- .word 0x41800000 | (\rt << 16) | (\rd << 11) | (\u << 5) | (\sel)
+ .macro MTTR rt=0, rs=0, u=0, sel=0
+ insn_if_mips 0x41800000 | (\rt << 16) | (\rs << 11) | (\u << 5) | (\sel)
+ insn32_if_mm 0x00000006 | (\rt << 21) | (\rs << 16) | (\u << 10) | (\sel << 4)
.endm
#ifdef TOOLCHAIN_SUPPORTS_MSA
diff --git a/arch/mips/include/asm/mipsmtregs.h b/arch/mips/include/asm/mipsmtregs.h
index a8d67c2f4f7b..30e86861c206 100644
--- a/arch/mips/include/asm/mipsmtregs.h
+++ b/arch/mips/include/asm/mipsmtregs.h
@@ -189,19 +189,24 @@ static inline unsigned core_nvpes(void)
return ((conf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) + 1;
}
+#define _ASM_SET_DVPE \
+ _ASM_MACRO_1R(dvpe, rt, \
+ _ASM_INSN_IF_MIPS(0x41600001 | __rt << 16) \
+ _ASM_INSN32_IF_MM(0x0000157C | __rt << 21))
+#define _ASM_UNSET_DVPE ".purgem dvpe\n\t"
+
static inline unsigned int dvpe(void)
{
int res = 0;
__asm__ __volatile__(
- " .set push \n"
- " .set noreorder \n"
- " .set noat \n"
- " .set mips32r2 \n"
- " .word 0x41610001 # dvpe $1 \n"
- " move %0, $1 \n"
- " ehb \n"
- " .set pop \n"
+ " .set push \n"
+ " .set "MIPS_ISA_LEVEL" \n"
+ _ASM_SET_DVPE
+ " dvpe %0 \n"
+ " ehb \n"
+ _ASM_UNSET_DVPE
+ " .set pop \n"
: "=r" (res));
instruction_hazard();
@@ -209,16 +214,22 @@ static inline unsigned int dvpe(void)
return res;
}
+#define _ASM_SET_EVPE \
+ _ASM_MACRO_1R(evpe, rt, \
+ _ASM_INSN_IF_MIPS(0x41600021 | __rt << 16) \
+ _ASM_INSN32_IF_MM(0x0000357C | __rt << 21))
+#define _ASM_UNSET_EVPE ".purgem evpe\n\t"
+
static inline void __raw_evpe(void)
{
__asm__ __volatile__(
- " .set push \n"
- " .set noreorder \n"
- " .set noat \n"
- " .set mips32r2 \n"
- " .word 0x41600021 # evpe \n"
- " ehb \n"
- " .set pop \n");
+ " .set push \n"
+ " .set "MIPS_ISA_LEVEL" \n"
+ _ASM_SET_EVPE
+ " evpe $0 \n"
+ " ehb \n"
+ _ASM_UNSET_EVPE
+ " .set pop \n");
}
/* Enable virtual processor execution if previous suggested it should be.
@@ -232,18 +243,24 @@ static inline void evpe(int previous)
__raw_evpe();
}
+#define _ASM_SET_DMT \
+ _ASM_MACRO_1R(dmt, rt, \
+ _ASM_INSN_IF_MIPS(0x41600bc1 | __rt << 16) \
+ _ASM_INSN32_IF_MM(0x0000057C | __rt << 21))
+#define _ASM_UNSET_DMT ".purgem dmt\n\t"
+
static inline unsigned int dmt(void)
{
int res;
__asm__ __volatile__(
- " .set push \n"
- " .set mips32r2 \n"
- " .set noat \n"
- " .word 0x41610BC1 # dmt $1 \n"
- " ehb \n"
- " move %0, $1 \n"
- " .set pop \n"
+ " .set push \n"
+ " .set "MIPS_ISA_LEVEL" \n"
+ _ASM_SET_DMT
+ " dmt %0 \n"
+ " ehb \n"
+ _ASM_UNSET_DMT
+ " .set pop \n"
: "=r" (res));
instruction_hazard();
@@ -251,14 +268,21 @@ static inline unsigned int dmt(void)
return res;
}
+#define _ASM_SET_EMT \
+ _ASM_MACRO_1R(emt, rt, \
+ _ASM_INSN_IF_MIPS(0x41600be1 | __rt << 16) \
+ _ASM_INSN32_IF_MM(0x0000257C | __rt << 21))
+#define _ASM_UNSET_EMT ".purgem emt\n\t"
+
static inline void __raw_emt(void)
{
__asm__ __volatile__(
- " .set push \n"
- " .set noreorder \n"
- " .set mips32r2 \n"
- " .word 0x41600be1 # emt \n"
- " ehb \n"
+ " .set push \n"
+ " .set "MIPS_ISA_LEVEL" \n"
+ _ASM_SET_EMT
+ " emt $0 \n"
+ _ASM_UNSET_EMT
+ " ehb \n"
" .set pop");
}
@@ -276,41 +300,55 @@ static inline void emt(int previous)
static inline void ehb(void)
{
__asm__ __volatile__(
- " .set push \n"
- " .set mips32r2 \n"
- " ehb \n"
- " .set pop \n");
+ " .set push \n"
+ " .set "MIPS_ISA_LEVEL" \n"
+ " ehb \n"
+ " .set pop \n");
}
-#define mftc0(rt,sel) \
+#define _ASM_SET_MFTC0 \
+ _ASM_MACRO_2R_1S(mftc0, rs, rt, sel, \
+ _ASM_INSN_IF_MIPS(0x41000000 | __rt << 16 | \
+ __rs << 11 | \\sel) \
+ _ASM_INSN32_IF_MM(0x0000000E | __rt << 21 | \
+ __rs << 16 | \\sel << 4))
+#define _ASM_UNSET_MFTC0 ".purgem mftc0\n\t"
+
+#define mftc0(rt, sel) \
({ \
- unsigned long __res; \
+ unsigned long __res; \
\
__asm__ __volatile__( \
- " .set push \n" \
- " .set mips32r2 \n" \
- " .set noat \n" \
- " # mftc0 $1, $" #rt ", " #sel " \n" \
- " .word 0x41000800 | (" #rt " << 16) | " #sel " \n" \
- " move %0, $1 \n" \
- " .set pop \n" \
+ " .set push \n" \
+ " .set "MIPS_ISA_LEVEL" \n" \
+ _ASM_SET_MFTC0 \
+ " mftc0 $1, " #rt ", " #sel " \n" \
+ _ASM_UNSET_MFTC0 \
+ " .set pop \n" \
: "=r" (__res)); \
\
__res; \
})
+#define _ASM_SET_MFTGPR \
+ _ASM_MACRO_2R(mftgpr, rs, rt, \
+ _ASM_INSN_IF_MIPS(0x41000020 | __rt << 16 | \
+ __rs << 11) \
+ _ASM_INSN32_IF_MM(0x0000040E | __rt << 21 | \
+ __rs << 16))
+#define _ASM_UNSET_MFTGPR ".purgem mftgpr\n\t"
+
#define mftgpr(rt) \
({ \
unsigned long __res; \
\
__asm__ __volatile__( \
- " .set push \n" \
- " .set noat \n" \
- " .set mips32r2 \n" \
- " # mftgpr $1," #rt " \n" \
- " .word 0x41000820 | (" #rt " << 16) \n" \
- " move %0, $1 \n" \
- " .set pop \n" \
+ " .set push \n" \
+ " .set "MIPS_ISA_LEVEL" \n" \
+ _ASM_SET_MFTGPR \
+ " mftgpr %0," #rt " \n" \
+ _ASM_UNSET_MFTGPR \
+ " .set pop \n" \
: "=r" (__res)); \
\
__res; \
@@ -321,35 +359,49 @@ static inline void ehb(void)
unsigned long __res; \
\
__asm__ __volatile__( \
- " mftr %0, " #rt ", " #u ", " #sel " \n" \
+ " mftr %0, " #rt ", " #u ", " #sel " \n" \
: "=r" (__res)); \
\
__res; \
})
-#define mttgpr(rd,v) \
+#define _ASM_SET_MTTGPR \
+ _ASM_MACRO_2R(mttgpr, rt, rs, \
+ _ASM_INSN_IF_MIPS(0x41800020 | __rt << 16 | \
+ __rs << 11) \
+ _ASM_INSN32_IF_MM(0x00000406 | __rt << 21 | \
+ __rs << 16))
+#define _ASM_UNSET_MTTGPR ".purgem mttgpr\n\t"
+
+#define mttgpr(rs, v) \
do { \
__asm__ __volatile__( \
- " .set push \n" \
- " .set mips32r2 \n" \
- " .set noat \n" \
- " move $1, %0 \n" \
- " # mttgpr $1, " #rd " \n" \
- " .word 0x41810020 | (" #rd " << 11) \n" \
- " .set pop \n" \
+ " .set push \n" \
+ " .set "MIPS_ISA_LEVEL" \n" \
+ _ASM_SET_MTTGPR \
+ " mttgpr %0, " #rs " \n" \
+ _ASM_UNSET_MTTGPR \
+ " .set pop \n" \
: : "r" (v)); \
} while (0)
-#define mttc0(rd, sel, v) \
+#define _ASM_SET_MTTC0 \
+ _ASM_MACRO_2R_1S(mttc0, rt, rs, sel, \
+ _ASM_INSN_IF_MIPS(0x41800000 | __rt << 16 | \
+ __rs << 11 | \\sel) \
+ _ASM_INSN32_IF_MM(0x0000040E | __rt << 21 | \
+ __rs << 16 | \\sel << 4))
+#define _ASM_UNSET_MTTC0 ".purgem mttc0\n\t"
+
+#define mttc0(rs, sel, v) \
({ \
__asm__ __volatile__( \
- " .set push \n" \
- " .set mips32r2 \n" \
- " .set noat \n" \
- " move $1, %0 \n" \
- " # mttc0 %0," #rd ", " #sel " \n" \
- " .word 0x41810000 | (" #rd " << 11) | " #sel " \n" \
- " .set pop \n" \
+ " .set push \n" \
+ " .set "MIPS_ISA_LEVEL" \n" \
+ _ASM_SET_MTTC0 \
+ " mttc0 %0," #rs ", " #sel " \n" \
+ _ASM_UNSET_MTTC0 \
+ " .set pop \n" \
: \
: "r" (v)); \
})
@@ -371,49 +423,49 @@ do { \
/* you *must* set the target tc (settc) before trying to use these */
-#define read_vpe_c0_vpecontrol() mftc0(1, 1)
-#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val)
-#define read_vpe_c0_vpeconf0() mftc0(1, 2)
-#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
-#define read_vpe_c0_vpeconf1() mftc0(1, 3)
-#define write_vpe_c0_vpeconf1(val) mttc0(1, 3, val)
-#define read_vpe_c0_count() mftc0(9, 0)
-#define write_vpe_c0_count(val) mttc0(9, 0, val)
-#define read_vpe_c0_status() mftc0(12, 0)
-#define write_vpe_c0_status(val) mttc0(12, 0, val)
-#define read_vpe_c0_cause() mftc0(13, 0)
-#define write_vpe_c0_cause(val) mttc0(13, 0, val)
-#define read_vpe_c0_config() mftc0(16, 0)
-#define write_vpe_c0_config(val) mttc0(16, 0, val)
-#define read_vpe_c0_config1() mftc0(16, 1)
-#define write_vpe_c0_config1(val) mttc0(16, 1, val)
-#define read_vpe_c0_config7() mftc0(16, 7)
-#define write_vpe_c0_config7(val) mttc0(16, 7, val)
-#define read_vpe_c0_ebase() mftc0(15, 1)
-#define write_vpe_c0_ebase(val) mttc0(15, 1, val)
-#define write_vpe_c0_compare(val) mttc0(11, 0, val)
-#define read_vpe_c0_badvaddr() mftc0(8, 0)
-#define read_vpe_c0_epc() mftc0(14, 0)
-#define write_vpe_c0_epc(val) mttc0(14, 0, val)
+#define read_vpe_c0_vpecontrol() mftc0($1, 1)
+#define write_vpe_c0_vpecontrol(val) mttc0($1, 1, val)
+#define read_vpe_c0_vpeconf0() mftc0($1, 2)
+#define write_vpe_c0_vpeconf0(val) mttc0($1, 2, val)
+#define read_vpe_c0_vpeconf1() mftc0($1, 3)
+#define write_vpe_c0_vpeconf1(val) mttc0($1, 3, val)
+#define read_vpe_c0_count() mftc0($9, 0)
+#define write_vpe_c0_count(val) mttc0($9, 0, val)
+#define read_vpe_c0_status() mftc0($12, 0)
+#define write_vpe_c0_status(val) mttc0($12, 0, val)
+#define read_vpe_c0_cause() mftc0($13, 0)
+#define write_vpe_c0_cause(val) mttc0($13, 0, val)
+#define read_vpe_c0_config() mftc0($16, 0)
+#define write_vpe_c0_config(val) mttc0($16, 0, val)
+#define read_vpe_c0_config1() mftc0($16, 1)
+#define write_vpe_c0_config1(val) mttc0($16, 1, val)
+#define read_vpe_c0_config7() mftc0($16, 7)
+#define write_vpe_c0_config7(val) mttc0($16, 7, val)
+#define read_vpe_c0_ebase() mftc0($15, 1)
+#define write_vpe_c0_ebase(val) mttc0($15, 1, val)
+#define write_vpe_c0_compare(val) mttc0($11, 0, val)
+#define read_vpe_c0_badvaddr() mftc0($8, 0)
+#define read_vpe_c0_epc() mftc0($14, 0)
+#define write_vpe_c0_epc(val) mttc0($14, 0, val)
/* TC */
-#define read_tc_c0_tcstatus() mftc0(2, 1)
-#define write_tc_c0_tcstatus(val) mttc0(2, 1, val)
-#define read_tc_c0_tcbind() mftc0(2, 2)
-#define write_tc_c0_tcbind(val) mttc0(2, 2, val)
-#define read_tc_c0_tcrestart() mftc0(2, 3)
-#define write_tc_c0_tcrestart(val) mttc0(2, 3, val)
-#define read_tc_c0_tchalt() mftc0(2, 4)
-#define write_tc_c0_tchalt(val) mttc0(2, 4, val)
-#define read_tc_c0_tccontext() mftc0(2, 5)
-#define write_tc_c0_tccontext(val) mttc0(2, 5, val)
+#define read_tc_c0_tcstatus() mftc0($2, 1)
+#define write_tc_c0_tcstatus(val) mttc0($2, 1, val)
+#define read_tc_c0_tcbind() mftc0($2, 2)
+#define write_tc_c0_tcbind(val) mttc0($2, 2, val)
+#define read_tc_c0_tcrestart() mftc0($2, 3)
+#define write_tc_c0_tcrestart(val) mttc0($2, 3, val)
+#define read_tc_c0_tchalt() mftc0($2, 4)
+#define write_tc_c0_tchalt(val) mttc0($2, 4, val)
+#define read_tc_c0_tccontext() mftc0($2, 5)
+#define write_tc_c0_tccontext(val) mttc0($2, 5, val)
/* GPR */
-#define read_tc_gpr_sp() mftgpr(29)
-#define write_tc_gpr_sp(val) mttgpr(29, val)
-#define read_tc_gpr_gp() mftgpr(28)
-#define write_tc_gpr_gp(val) mttgpr(28, val)
+#define read_tc_gpr_sp() mftgpr($29)
+#define write_tc_gpr_sp(val) mttgpr($29, val)
+#define read_tc_gpr_gp() mftgpr($28)
+#define write_tc_gpr_gp(val) mttgpr($28, val)
__BUILD_SET_C0(mvpcontrol)
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index ec58cb76d076..dfb268f8aef8 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -1307,6 +1307,15 @@ static inline int mm_insn_16bit(u16 insn)
* the ENC encodings.
*/
+/* Instructions with 1 register operand */
+#define _ASM_MACRO_1R(OP, R1, ENC) \
+ ".macro " #OP " " #R1 "\n\t" \
+ _ASM_SET_PARSE_R \
+ "parse_r __" #R1 ", \\" #R1 "\n\t" \
+ ENC \
+ _ASM_UNSET_PARSE_R \
+ ".endm\n\t"
+
/* Instructions with 1 register operand & 1 immediate operand */
#define _ASM_MACRO_1R1I(OP, R1, I2, ENC) \
".macro " #OP " " #R1 ", " #I2 "\n\t" \
diff --git a/arch/mips/kernel/vpe-mt.c b/arch/mips/kernel/vpe-mt.c
index 667bc75f6420..84124ac2d2a5 100644
--- a/arch/mips/kernel/vpe-mt.c
+++ b/arch/mips/kernel/vpe-mt.c
@@ -95,8 +95,8 @@ int vpe_run(struct vpe *v)
* We don't pass the memsize here, so VPE programs need to be
* compiled with DFLT_STACK_SIZE and DFLT_HEAP_SIZE defined.
*/
- mttgpr(7, 0);
- mttgpr(6, v->ntcs);
+ mttgpr($7, 0);
+ mttgpr($6, v->ntcs);
/* set up VPE1 */
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 8/8] MIPS: mipsregs: Set proper ISA level for virt extensions
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
` (6 preceding siblings ...)
2024-02-02 18:21 ` [PATCH 7/8] MIPS: Implement microMIPS MT ASE helpers Jiaxun Yang
@ 2024-02-02 18:21 ` Jiaxun Yang
2024-02-20 18:26 ` [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
2024-02-23 9:18 ` Thomas Bogendoerfer
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-02 18:21 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Jiaxun Yang
c994a3ec7ecc ("MIPS: set mips32r5 for virt extensions") setted
some instructions in virt extensions to ISA level mips32r5.
However TLB related vz instructions was leftover, also this
shouldn't be done to a R5 or R6 kernel buid.
Reorg macros to set ISA level as needed when _ASM_SET_VIRT
is called.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/include/asm/mipsregs.h | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index dfb268f8aef8..6e97811fa936 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -2087,7 +2087,14 @@ do { \
_ASM_INSN_IF_MIPS(0x4200000c) \
_ASM_INSN32_IF_MM(0x0000517c)
#else /* !TOOLCHAIN_SUPPORTS_VIRT */
-#define _ASM_SET_VIRT ".set\tvirt\n\t"
+#if MIPS_ISA_REV >= 5
+#define _ASM_SET_VIRT_ISA
+#elif defined(CONFIG_64BIT)
+#define _ASM_SET_VIRT_ISA ".set\tmips64r5\n\t"
+#else
+#define _ASM_SET_VIRT_ISA ".set\tmips32r5\n\t"
+#endif
+#define _ASM_SET_VIRT _ASM_SET_VIRT_ISA ".set\tvirt\n\t"
#define _ASM_SET_MFGC0 _ASM_SET_VIRT
#define _ASM_SET_DMFGC0 _ASM_SET_VIRT
#define _ASM_SET_MTGC0 _ASM_SET_VIRT
@@ -2108,7 +2115,6 @@ do { \
({ int __res; \
__asm__ __volatile__( \
".set\tpush\n\t" \
- ".set\tmips32r5\n\t" \
_ASM_SET_MFGC0 \
"mfgc0\t%0, " #source ", %1\n\t" \
_ASM_UNSET_MFGC0 \
@@ -2122,7 +2128,6 @@ do { \
({ unsigned long long __res; \
__asm__ __volatile__( \
".set\tpush\n\t" \
- ".set\tmips64r5\n\t" \
_ASM_SET_DMFGC0 \
"dmfgc0\t%0, " #source ", %1\n\t" \
_ASM_UNSET_DMFGC0 \
@@ -2136,7 +2141,6 @@ do { \
do { \
__asm__ __volatile__( \
".set\tpush\n\t" \
- ".set\tmips32r5\n\t" \
_ASM_SET_MTGC0 \
"mtgc0\t%z0, " #register ", %1\n\t" \
_ASM_UNSET_MTGC0 \
@@ -2149,7 +2153,6 @@ do { \
do { \
__asm__ __volatile__( \
".set\tpush\n\t" \
- ".set\tmips64r5\n\t" \
_ASM_SET_DMTGC0 \
"dmtgc0\t%z0, " #register ", %1\n\t" \
_ASM_UNSET_DMTGC0 \
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 0/8] MIPS: Aggregate build fixes
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
` (7 preceding siblings ...)
2024-02-02 18:21 ` [PATCH 8/8] MIPS: mipsregs: Set proper ISA level for virt extensions Jiaxun Yang
@ 2024-02-20 18:26 ` Jiaxun Yang
2024-02-23 9:18 ` Thomas Bogendoerfer
9 siblings, 0 replies; 16+ messages in thread
From: Jiaxun Yang @ 2024-02-20 18:26 UTC (permalink / raw)
To: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: linux-mips, linux-kernel, llvm, Guenter Roeck
在 2024/2/2 18:21, Jiaxun Yang 写道:
> Hi all,
>
> This series is a collection of build fixes that have been lying
> at my local trees for a while, some of them are for Clang built
> linux and others are for some wiredo configurations.
A gentle ping on this series :-)
Thanks
- Jiaxun
>
> Please review.
>
> Thanks
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> Jiaxun Yang (8):
> MIPS: Probe toolchain support of -msym32
> MIPS: Remove cc-option checks for -march=octeon
> MIPS: Fallback CPU -march flag to ISA level if unsupported
> MIPS: BMIPS: Drop unnecessary assembler flag
> MIPS: Loongson64: test for -march=loongson3a cflag
> MIPS: Limit MIPS_MT_SMP support by ISA reversion
> MIPS: Implement microMIPS MT ASE helpers
> MIPS: mipsregs: Set proper ISA level for virt extensions
>
> arch/mips/Kconfig | 3 +-
> arch/mips/Makefile | 46 ++++---
> arch/mips/include/asm/asmmacro.h | 22 ++--
> arch/mips/include/asm/mipsmtregs.h | 256 ++++++++++++++++++++++---------------
> arch/mips/include/asm/mipsregs.h | 22 +++-
> arch/mips/kernel/vpe-mt.c | 4 +-
> 6 files changed, 211 insertions(+), 142 deletions(-)
> ---
> base-commit: 076d56d74f17e625b3d63cf4743b3d7d02180379
> change-id: 20240202-llvm-msym32-6392d410f650
>
> Best regards,
--
---
Jiaxun Yang
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/8] MIPS: Aggregate build fixes
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
` (8 preceding siblings ...)
2024-02-20 18:26 ` [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
@ 2024-02-23 9:18 ` Thomas Bogendoerfer
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Bogendoerfer @ 2024-02-23 9:18 UTC (permalink / raw)
To: Jiaxun Yang
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-mips, linux-kernel, llvm, Guenter Roeck
On Fri, Feb 02, 2024 at 06:21:39PM +0000, Jiaxun Yang wrote:
> Hi all,
>
> This series is a collection of build fixes that have been lying
> at my local trees for a while, some of them are for Clang built
> linux and others are for some wiredo configurations.
>
> Please review.
>
> Thanks
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> Jiaxun Yang (8):
> MIPS: Probe toolchain support of -msym32
> MIPS: Remove cc-option checks for -march=octeon
> MIPS: Fallback CPU -march flag to ISA level if unsupported
> MIPS: BMIPS: Drop unnecessary assembler flag
> MIPS: Loongson64: test for -march=loongson3a cflag
> MIPS: Limit MIPS_MT_SMP support by ISA reversion
> MIPS: Implement microMIPS MT ASE helpers
> MIPS: mipsregs: Set proper ISA level for virt extensions
>
> arch/mips/Kconfig | 3 +-
> arch/mips/Makefile | 46 ++++---
> arch/mips/include/asm/asmmacro.h | 22 ++--
> arch/mips/include/asm/mipsmtregs.h | 256 ++++++++++++++++++++++---------------
> arch/mips/include/asm/mipsregs.h | 22 +++-
> arch/mips/kernel/vpe-mt.c | 4 +-
> 6 files changed, 211 insertions(+), 142 deletions(-)
> ---
> base-commit: 076d56d74f17e625b3d63cf4743b3d7d02180379
> change-id: 20240202-llvm-msym32-6392d410f650
applied to mips-next.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion
2024-02-02 18:21 ` [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion Jiaxun Yang
@ 2024-05-14 21:38 ` Maciej W. Rozycki
2024-05-14 23:39 ` Jiaxun Yang
0 siblings, 1 reply; 16+ messages in thread
From: Maciej W. Rozycki @ 2024-05-14 21:38 UTC (permalink / raw)
To: Jiaxun Yang
Cc: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-mips, linux-kernel, llvm,
Guenter Roeck
On Fri, 2 Feb 2024, Jiaxun Yang wrote:
> MIPS MT ASE is only available on ISA between Release 1 and Release 5.
R2+ only actually, as also evident from Kconfig...
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -2171,7 +2171,8 @@ config CPU_R4K_CACHE_TLB
> config MIPS_MT_SMP
> bool "MIPS MT SMP support (1 TC on each available VPE)"
> default y
> - depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS
> + depends on TARGET_ISA_REV > 0 && TARGET_ISA_REV < 6
> + depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MICROMIPS
> select CPU_MIPSR2_IRQ_VI
> select CPU_MIPSR2_IRQ_EI
^^^^^^
... here. I wish people looked beyond the line they change, sigh...
Maciej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion
2024-05-14 21:38 ` Maciej W. Rozycki
@ 2024-05-14 23:39 ` Jiaxun Yang
2024-05-15 13:43 ` Maciej W. Rozycki
0 siblings, 1 reply; 16+ messages in thread
From: Jiaxun Yang @ 2024-05-14 23:39 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-mips, linux-kernel, llvm,
Guenter Roeck
在2024年5月14日五月 下午10:38,Maciej W. Rozycki写道:
> On Fri, 2 Feb 2024, Jiaxun Yang wrote:
>
>> MIPS MT ASE is only available on ISA between Release 1 and Release 5.
>
> R2+ only actually, as also evident from Kconfig...
Hi Maciej,
Long time no see :-)
There is nothing stopping us to run R1 kernel on R2 hardware, given that
those features are all detected at boot time. I understand MT was introduced
at 34K which is R2.
I tested booting R1 kernel with MT on 1004Kc.
I believe we should give users flexibility on enjoying optional features
on kernel targeting lower ISA Rev.
>
>> --- a/arch/mips/Kconfig
>> +++ b/arch/mips/Kconfig
>> @@ -2171,7 +2171,8 @@ config CPU_R4K_CACHE_TLB
>> config MIPS_MT_SMP
>> bool "MIPS MT SMP support (1 TC on each available VPE)"
>> default y
>> - depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS
>> + depends on TARGET_ISA_REV > 0 && TARGET_ISA_REV < 6
>> + depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MICROMIPS
>> select CPU_MIPSR2_IRQ_VI
>> select CPU_MIPSR2_IRQ_EI
> ^^^^^^
> ... here. I wish people looked beyond the line they change, sigh...
Both features (VI and VEIC) are probed at boot time. Selecting
them doesn't necessarily mean that CPU has those functions.
Thanks
- Jiaxun
>
> Maciej
--
- Jiaxun
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion
2024-05-14 23:39 ` Jiaxun Yang
@ 2024-05-15 13:43 ` Maciej W. Rozycki
2024-05-15 21:26 ` Jiaxun Yang
0 siblings, 1 reply; 16+ messages in thread
From: Maciej W. Rozycki @ 2024-05-15 13:43 UTC (permalink / raw)
To: Jiaxun Yang
Cc: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-mips, linux-kernel, llvm,
Guenter Roeck
On Wed, 15 May 2024, Jiaxun Yang wrote:
> >> MIPS MT ASE is only available on ISA between Release 1 and Release 5.
> >
> > R2+ only actually, as also evident from Kconfig...
>
> Hi Maciej,
>
> Long time no see :-)
It's not so easy to get rid of me. ;)
> There is nothing stopping us to run R1 kernel on R2 hardware, given that
> those features are all detected at boot time. I understand MT was introduced
> at 34K which is R2.
We can certainly choose to support R2 features at run time with R1 kernel
configurations, but it's not what the change description says (left quoted
above for reference). And the MT ASE, indeed first implemented with the
34K (for which I was a member of the product development team back at MIPS
UK), is not a part of the R1 ISA specification set.
> >> --- a/arch/mips/Kconfig
> >> +++ b/arch/mips/Kconfig
> >> @@ -2171,7 +2171,8 @@ config CPU_R4K_CACHE_TLB
> >> config MIPS_MT_SMP
> >> bool "MIPS MT SMP support (1 TC on each available VPE)"
> >> default y
> >> - depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS
> >> + depends on TARGET_ISA_REV > 0 && TARGET_ISA_REV < 6
> >> + depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MICROMIPS
> >> select CPU_MIPSR2_IRQ_VI
> >> select CPU_MIPSR2_IRQ_EI
> > ^^^^^^
> > ... here. I wish people looked beyond the line they change, sigh...
>
> Both features (VI and VEIC) are probed at boot time. Selecting
> them doesn't necessarily mean that CPU has those functions.
Both are optional for R2+, so necessarily they need to be probed for, but
they are not available in R1. The reverse dependency set here is another
indication that the MT ASE is an R2+ feature.
Maciej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion
2024-05-15 13:43 ` Maciej W. Rozycki
@ 2024-05-15 21:26 ` Jiaxun Yang
2024-05-16 22:44 ` Maciej W. Rozycki
0 siblings, 1 reply; 16+ messages in thread
From: Jiaxun Yang @ 2024-05-15 21:26 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-mips, linux-kernel, llvm,
Guenter Roeck
在2024年5月15日五月 下午2:43,Maciej W. Rozycki写道:
> On Wed, 15 May 2024, Jiaxun Yang wrote:
>
>> >> MIPS MT ASE is only available on ISA between Release 1 and Release 5.
>> >
>> > R2+ only actually, as also evident from Kconfig...
>>
>> Hi Maciej,
>>
>> Long time no see :-)
>
> It's not so easy to get rid of me. ;)
>
>> There is nothing stopping us to run R1 kernel on R2 hardware, given that
>> those features are all detected at boot time. I understand MT was introduced
>> at 34K which is R2.
>
> We can certainly choose to support R2 features at run time with R1 kernel
> configurations, but it's not what the change description says (left quoted
> above for reference). And the MT ASE, indeed first implemented with the
> 34K (for which I was a member of the product development team back at MIPS
> UK), is not a part of the R1 ISA specification set.
>
Good to know!
The motivation behind this patch is to workaround some randconfig failures
that combines MT with early ISA release.
They are not trivial to fix, so I just ban them in Kconfig. I was a little bit
reluctant to admit that in commit message.
Anyway, thanks for bringing that up.
--
- Jiaxun
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion
2024-05-15 21:26 ` Jiaxun Yang
@ 2024-05-16 22:44 ` Maciej W. Rozycki
0 siblings, 0 replies; 16+ messages in thread
From: Maciej W. Rozycki @ 2024-05-16 22:44 UTC (permalink / raw)
To: Jiaxun Yang
Cc: Thomas Bogendoerfer, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-mips, linux-kernel, llvm,
Guenter Roeck
On Wed, 15 May 2024, Jiaxun Yang wrote:
> >> There is nothing stopping us to run R1 kernel on R2 hardware, given that
> >> those features are all detected at boot time. I understand MT was introduced
> >> at 34K which is R2.
> >
> > We can certainly choose to support R2 features at run time with R1 kernel
> > configurations, but it's not what the change description says (left quoted
> > above for reference). And the MT ASE, indeed first implemented with the
> > 34K (for which I was a member of the product development team back at MIPS
> > UK), is not a part of the R1 ISA specification set.
> >
> Good to know!
>
> The motivation behind this patch is to workaround some randconfig failures
> that combines MT with early ISA release.
I'd say it's an actual fix rather than just a workaround.
Originally intention was with the MIPS port that eventually we would
support a generic kernel configuration, such as original x86 Linux has
always had or the Alpha port has at one point gained, where you can have
respectively an i486 (or previously even i386) or EV4 CPU kernel binary
that runs everywhere, even on the most recent hardware available.
With the MIPS platform fragmentation it has proved too much of an effort
for the engineering resources we've had available and consequently never
happened. This is why we have retained numerous abstractions intended to
switch between handlers at boot time (and had even more in the past).
From R1 onwards the privileged architecture has become more uniform and
therefore easier to handle between ISA revisions and/or implementations
and the choice of the CPU to build for has become more of a balance
between backwards compatibility and optimisation stemming from a richer
architecture and FWIW I fully support striving to make an R1 kernel binary
run with any R1-R5 hardware. It can be especially useful with platforms
that have swappable CPU modules available at different ISA levels.
> They are not trivial to fix, so I just ban them in Kconfig. I was a little bit
> reluctant to admit that in commit message.
Please always state your genuine motivation in change descriptions. It
lets reviewers understand what a change is about and if there is any
concern about the description itself, then it can always be adjusted in
the review if needed.
Maciej
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-05-16 22:45 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 18:21 [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
2024-02-02 18:21 ` [PATCH 1/8] MIPS: Probe toolchain support of -msym32 Jiaxun Yang
2024-02-02 18:21 ` [PATCH 2/8] MIPS: Remove cc-option checks for -march=octeon Jiaxun Yang
2024-02-02 18:21 ` [PATCH 3/8] MIPS: Fallback CPU -march flag to ISA level if unsupported Jiaxun Yang
2024-02-02 18:21 ` [PATCH 4/8] MIPS: BMIPS: Drop unnecessary assembler flag Jiaxun Yang
2024-02-02 18:21 ` [PATCH 5/8] MIPS: Loongson64: test for -march=loongson3a cflag Jiaxun Yang
2024-02-02 18:21 ` [PATCH 6/8] MIPS: Limit MIPS_MT_SMP support by ISA reversion Jiaxun Yang
2024-05-14 21:38 ` Maciej W. Rozycki
2024-05-14 23:39 ` Jiaxun Yang
2024-05-15 13:43 ` Maciej W. Rozycki
2024-05-15 21:26 ` Jiaxun Yang
2024-05-16 22:44 ` Maciej W. Rozycki
2024-02-02 18:21 ` [PATCH 7/8] MIPS: Implement microMIPS MT ASE helpers Jiaxun Yang
2024-02-02 18:21 ` [PATCH 8/8] MIPS: mipsregs: Set proper ISA level for virt extensions Jiaxun Yang
2024-02-20 18:26 ` [PATCH 0/8] MIPS: Aggregate build fixes Jiaxun Yang
2024-02-23 9:18 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).