@@ -27,12 +27,21 @@ static u32 unaligned_instructions_user;
2727static u32 unaligned_instructions_kernel ;
2828#endif
2929
30- static inline unsigned long read_fpr (unsigned int idx )
30+ static inline u64 read_fpr (unsigned int idx )
3131{
32+ #ifdef CONFIG_64BIT
3233#define READ_FPR (idx , __value ) \
3334 __asm__ __volatile__("movfr2gr.d %0, $f"#idx"\n\t" : "=r"(__value));
34-
35- unsigned long __value ;
35+ #else
36+ #define READ_FPR (idx , __value ) \
37+ { \
38+ u32 __value_lo, __value_hi; \
39+ __asm__ __volatile__("movfr2gr.s %0, $f"#idx"\n\t" : "=r"(__value_lo)); \
40+ __asm__ __volatile__("movfrh2gr.s %0, $f"#idx"\n\t" : "=r"(__value_hi)); \
41+ __value = (__value_lo | ((u64)__value_hi << 32)); \
42+ }
43+ #endif
44+ u64 __value ;
3645
3746 switch (idx ) {
3847 case 0 :
@@ -138,11 +147,20 @@ static inline unsigned long read_fpr(unsigned int idx)
138147 return __value ;
139148}
140149
141- static inline void write_fpr (unsigned int idx , unsigned long value )
150+ static inline void write_fpr (unsigned int idx , u64 value )
142151{
152+ #ifdef CONFIG_64BIT
143153#define WRITE_FPR (idx , value ) \
144154 __asm__ __volatile__("movgr2fr.d $f"#idx", %0\n\t" :: "r"(value));
145-
155+ #else
156+ #define WRITE_FPR (idx , value ) \
157+ { \
158+ u32 value_lo = value; \
159+ u32 value_hi = value >> 32; \
160+ __asm__ __volatile__("movgr2fr.w $f"#idx", %0\n\t" :: "r"(value_lo)); \
161+ __asm__ __volatile__("movgr2frh.w $f"#idx", %0\n\t" :: "r"(value_hi)); \
162+ }
163+ #endif
146164 switch (idx ) {
147165 case 0 :
148166 WRITE_FPR (0 , value );
@@ -252,7 +270,7 @@ void emulate_load_store_insn(struct pt_regs *regs, void __user *addr, unsigned i
252270 bool sign , write ;
253271 bool user = user_mode (regs );
254272 unsigned int res , size = 0 ;
255- unsigned long value = 0 ;
273+ u64 value = 0 ;
256274 union loongarch_instruction insn ;
257275
258276 perf_sw_event (PERF_COUNT_SW_EMULATION_FAULTS , 1 , regs , 0 );
0 commit comments