Skip to contentSkip to conversation

riscv: Fix the PAUSE Opcode for MIPS P8700.

PATCH Superseded Aleksandar Rikalo 2 participants 3 messages Dec 18, 2024 – Dec 27, 2024 RISC-V

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Fix the PAUSE Opcode for MIPS P8700.

From: Raj Vishwanathan4 <[email protected]>

The riscv MIPS P8700 uses a different opcode for PAUSE.
It is a ‘hint’ encoding of the SLLI instruction, with rd=0, rs1=0 and imm=5. It will behave as a NOP instruction if no additional behavior beyond that of SLLI is implemented.

---
 arch/riscv/Kconfig                | 12 ++++++++++++
 arch/riscv/include/asm/insn-def.h |  5 +++++
 2 files changed, 17 insertions(+)
arch/riscv/Kconfig +12 -0
index d4a7ca0388c0..07a77fa0a014 100644
@@ -716,6 +716,18 @@ config RISCV_ISA_ZACAS
 
 	  If you don't know what to do here, say Y.
 
+config RISCV_MIPS_P8700_PAUSE_OPCODE_FIX
+	bool "Fix the PAUSE Opcode for MIPS P8700"
+	default n
+	help
+	   The RISCV MIPS P8700 uses a different opcode for PAUSE.
+	   It is a 'hint' encoding of the SLLI instruction,
+	   with rd=0, rs1=0 and imm=5. It will behave as a NOP
+	   instruction if no additional behavior beyond that of
+	   SLLI is implemented.
+
+	   If you are not using the P8700 processor, say n.
+
 config TOOLCHAIN_HAS_ZBB
 	bool
 	default y
arch/riscv/include/asm/insn-def.h +5 -0
index 9a913010cdd9..793eedde3516 100644
@@ -196,7 +196,12 @@
 	INSN_I(OPCODE_MISC_MEM, FUNC3(2), __RD(0),		\
 	       RS1(base), SIMM12(4))
 
+#ifndef CONFIG_RISCV_MIPS_P8700_PAUSE_OPCODE_FIX
 #define RISCV_PAUSE	".4byte 0x100000f"
+#else
+#define RISCV_PAUSE	".4byte 0x00501013"
+#endif
+
 #define ZAWRS_WRS_NTO	".4byte 0x00d00073"
 #define ZAWRS_WRS_STO	".4byte 0x01d00073"
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 43 lines · Aleksandar Rikalo

From: Raj Vishwanathan4 <[email protected]>

The riscv MIPS P8700 uses a different opcode for PAUSE.
It is a ‘hint’ encoding of the SLLI instruction, with rd=0, rs1=0 and imm=5. It will behave as a NOP instruction if no additional behavior beyond that of SLLI is implemented.

---
 arch/riscv/Kconfig                | 12 ++++++++++++
 arch/riscv/include/asm/insn-def.h |  5 +++++
 2 files changed, 17 insertions(+)
arch/riscv/Kconfig +12 -0
index d4a7ca0388c0..07a77fa0a014 100644
@@ -716,6 +716,18 @@ config RISCV_ISA_ZACAS
 
 	  If you don't know what to do here, say Y.
 
+config RISCV_MIPS_P8700_PAUSE_OPCODE_FIX
+	bool "Fix the PAUSE Opcode for MIPS P8700"
+	default n
+	help
+	   The RISCV MIPS P8700 uses a different opcode for PAUSE.
+	   It is a 'hint' encoding of the SLLI instruction,
+	   with rd=0, rs1=0 and imm=5. It will behave as a NOP
+	   instruction if no additional behavior beyond that of
+	   SLLI is implemented.
+
+	   If you are not using the P8700 processor, say n.
+
 config TOOLCHAIN_HAS_ZBB
 	bool
 	default y
arch/riscv/include/asm/insn-def.h +0 -0
index 9a913010cdd9..793eedde3516 100644
@@ -196,7 +196,12 @@
 	INSN_I(OPCODE_MISC_MEM, FUNC3(2), __RD(0),		\

arch/riscv/include/asm/insn-def.h line 206

Quoted 10 lines
arch/riscv/include/asm/insn-def.h +5 -0
 	       RS1(base), SIMM12(4))
 
+#ifndef CONFIG_RISCV_MIPS_P8700_PAUSE_OPCODE_FIX
 #define RISCV_PAUSE	".4byte 0x100000f"
+#else
+#define RISCV_PAUSE	".4byte 0x00501013"
+#endif
+
 #define ZAWRS_WRS_NTO	".4byte 0x00d00073"
 #define ZAWRS_WRS_STO	".4byte 0x01d00073"

This means that a kernel that's built for MIPS P8700 won't do the right thing on other platforms, i.e. single platform builds. That's not the right approach.

It would make more sense to treat this as an errata with boot time patchup.

-Olof

#2 lore raw
Quoted 17 lines · Olof Johansson
Quoted 7 lines · Aleksandar Rikalo

From: Raj Vishwanathan4 <[email protected]>

The riscv MIPS P8700 uses a different opcode for PAUSE.
It is a ‘hint’ encoding of the SLLI instruction, with rd=0, rs1=0 and imm=5. It will behave as a NOP instruction if no additional behavior beyond that of SLLI is implemented.

Quoted 7 lines
---
 arch/riscv/Kconfig                | 12 ++++++++++++
 arch/riscv/include/asm/insn-def.h |  5 +++++
 2 files changed, 17 insertions(+)
Quoted 8 lines

This means that a kernel that's built for MIPS P8700 won't do the right thing on other platforms, i.e. single platform builds. That's not the right approach.

It would make more sense to treat this as an errata with boot time patchup.

-Olof

We did it that way in version 2. Please see:
https://lore.kernel.org/linux-riscv/[email protected]

-- Aleksandar