Skip to contentSkip to conversation

MIPS: Loongson-3: Add some unaligned instructions emulation

PATCH In review Huacai Chen 2 participants 2 messages Apr 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Loongson-3: Add some unaligned instructions emulation

1, Add unaligned gslq, gssq, gslqc1, gssqc1 emulation; 2, Add unaligned gsl{h, w, d}x, gss{h, w, d}x emulation; 3, Add unaligned gslwxc1, gsswxc1, gsldxc1, gssdxc1 emulation.

---
 arch/mips/include/asm/fpu_emulator.h |   2 -
 arch/mips/include/asm/inst.h         | 773 ++++++++++++++++++++++++++++++++++
 arch/mips/include/uapi/asm/inst.h    |  26 ++
 arch/mips/kernel/unaligned.c         | 775 -----------------------------------
 arch/mips/loongson64/cop2-ex.c       | 274 ++++++++++++-
 5 files changed, 1072 insertions(+), 778 deletions(-)
arch/mips/include/asm/fpu_emulator.h +0 -2
index bb7c71f..9c68f9e 100644
@@ -174,8 +174,6 @@ int process_fpemu_return(int sig, void __user *fault_addr,
 			 unsigned long fcr31);
 int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
 		  unsigned long *contpc);
-int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
-		     unsigned long *contpc);
 
 /*
  * Mask the FCSR Cause bits according to the Enable bits, observing
arch/mips/include/asm/inst.h +773 -0

783 lines not on this page · raw message

arch/mips/include/uapi/asm/inst.h +26 -0
index eaa3a80..98f97c8 100644
@@ -989,6 +989,30 @@ struct mm16_r5_format {		/* Load/store from stack pointer format */
 };
 
 /*
+ * Loongson-3 overridden COP2 instruction formats (32-bit length)
+ */
+struct loongson3_lswc2_format {	/* Loongson-3 overridden lwc2/swc2 Load/Store format */
+	__BITFIELD_FIELD(unsigned int opcode : 6,
+	__BITFIELD_FIELD(unsigned int base : 5,
+	__BITFIELD_FIELD(unsigned int rt : 5,
+	__BITFIELD_FIELD(unsigned int fr : 1,
+	__BITFIELD_FIELD(unsigned int offset : 9,
+	__BITFIELD_FIELD(unsigned int ls : 1,
+	__BITFIELD_FIELD(unsigned int rq : 5,
+	;)))))))
+};
+
+struct loongson3_lsdc2_format {	/* Loongson-3 overridden ldc2/sdc2 Load/Store format */
+	__BITFIELD_FIELD(unsigned int opcode : 6,
+	__BITFIELD_FIELD(unsigned int base : 5,
+	__BITFIELD_FIELD(unsigned int rt : 5,
+	__BITFIELD_FIELD(unsigned int index : 5,
+	__BITFIELD_FIELD(unsigned int offset : 8,
+	__BITFIELD_FIELD(unsigned int opcode1 : 3,
+	;))))))
+};
+
+/*
  * MIPS16e instruction formats (16-bit length)
  */
 struct m16e_rr {
@@ -1088,6 +1112,8 @@ union mips_instruction {
 	struct mm16_rb_format mm16_rb_format;
 	struct mm16_r3_format mm16_r3_format;
 	struct mm16_r5_format mm16_r5_format;
+	struct loongson3_lswc2_format loongson3_lswc2_format;
+	struct loongson3_lsdc2_format loongson3_lsdc2_format;
 };
 
 union mips16e_instruction {
arch/mips/kernel/unaligned.c +0 -775

787 lines not on this page · raw message

arch/mips/loongson64/cop2-ex.c +273 -1

299 lines not on this page · raw message

Signature · 1 line
2.7.0
maintainer
#1 lore raw
Quoted 3 lines · On Thu, 9 Apr 2020 17:47:55 +0800 Huacai Chen <[email protected]> wrote:

1, Add unaligned gslq, gssq, gslqc1, gssqc1 emulation; 2, Add unaligned gsl{h, w, d}x, gss{h, w, d}x emulation; 3, Add unaligned gslwxc1, gsswxc1, gsldxc1, gssdxc1 emulation.

Probably you should split your changes into two patches?
The first patch moves load & store helpers to the header and the second one adds emulation in exception handler.

Thanks.

Quoted 4 lines
Quoted 9 lines
---
 arch/mips/include/asm/fpu_emulator.h |   2 -
 arch/mips/include/asm/inst.h         | 773
++++++++++++++++++++++++++++++++++ arch/mips/include/uapi/asm/inst.h
  |  26 ++ arch/mips/kernel/unaligned.c         | 775

----------------------------------- arch/mips/loongson64/cop2-ex.c
| 274 ++++++++++++- 5 files changed, 1072 insertions(+), 778
deletions(-)

--
Jiaxun Yang