Commit 1613de8a authored by Nickhu's avatar Nickhu Committed by Greentime Hu

nds32: Fix the unaligned access handler

If the kernel config 'CONFIG_ALIGNMENT_TRAP' and the file
'/proc/sys/nds32/unaligned_access/enable' are set, the kernel
unaligned access handler does not handle correctly when the
value of immediate field is negative. This commit fixes the
unaligned access handler in kernel.
Signed-off-by: default avatarNickhu <nickhu@andestech.com>
Reviewed-by: default avatarGreentime Hu <greentime@andestech.com>
Signed-off-by: default avatarGreentime Hu <greentime@andestech.com>
parent b3a75846
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define RA(inst) (((inst) >> 15) & 0x1FUL) #define RA(inst) (((inst) >> 15) & 0x1FUL)
#define RB(inst) (((inst) >> 10) & 0x1FUL) #define RB(inst) (((inst) >> 10) & 0x1FUL)
#define SV(inst) (((inst) >> 8) & 0x3UL) #define SV(inst) (((inst) >> 8) & 0x3UL)
#define IMM(inst) (((inst) >> 0) & 0x3FFFUL) #define IMM(inst) (((inst) >> 0) & 0x7FFFUL)
#define RA3(inst) (((inst) >> 3) & 0x7UL) #define RA3(inst) (((inst) >> 3) & 0x7UL)
#define RT3(inst) (((inst) >> 6) & 0x7UL) #define RT3(inst) (((inst) >> 6) & 0x7UL)
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#define RA5(inst) (((inst) >> 0) & 0x1FUL) #define RA5(inst) (((inst) >> 0) & 0x1FUL)
#define RT4(inst) (((inst) >> 5) & 0xFUL) #define RT4(inst) (((inst) >> 5) & 0xFUL)
#define GET_IMMSVAL(imm_value) \
(((imm_value >> 14) & 0x1) ? (imm_value - 0x8000) : imm_value)
#define __get8_data(val,addr,err) \ #define __get8_data(val,addr,err) \
__asm__( \ __asm__( \
"1: lbi.bi %1, [%2], #1\n" \ "1: lbi.bi %1, [%2], #1\n" \
...@@ -467,7 +470,7 @@ static inline int do_32(unsigned long inst, struct pt_regs *regs) ...@@ -467,7 +470,7 @@ static inline int do_32(unsigned long inst, struct pt_regs *regs)
} }
if (imm) if (imm)
shift = IMM(inst) * len; shift = GET_IMMSVAL(IMM(inst)) * len;
else else
shift = *idx_to_addr(regs, RB(inst)) << SV(inst); shift = *idx_to_addr(regs, RB(inst)) << SV(inst);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment