diff options
author | Nickhu <nickhu@andestech.com> | 2018-05-02 22:15:56 -0400 |
---|---|---|
committer | Greentime Hu <greentime@andestech.com> | 2018-05-23 01:26:22 -0400 |
commit | 1613de8a785d21b3aac73d2a2e640b66d514393b (patch) | |
tree | 0fcdfcff3e72c84871b202c5ef4a132a5ae5cbe7 | |
parent | b3a75846a5cfbea137e2810b2bf9407141e70feb (diff) |
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: Nickhu <nickhu@andestech.com>
Reviewed-by: Greentime Hu <greentime@andestech.com>
Signed-off-by: Greentime Hu <greentime@andestech.com>
-rw-r--r-- | arch/nds32/mm/alignment.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/nds32/mm/alignment.c b/arch/nds32/mm/alignment.c index e515f6f3d247..e1aed9dc692d 100644 --- a/arch/nds32/mm/alignment.c +++ b/arch/nds32/mm/alignment.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #define RA(inst) (((inst) >> 15) & 0x1FUL) | 19 | #define RA(inst) (((inst) >> 15) & 0x1FUL) |
20 | #define RB(inst) (((inst) >> 10) & 0x1FUL) | 20 | #define RB(inst) (((inst) >> 10) & 0x1FUL) |
21 | #define SV(inst) (((inst) >> 8) & 0x3UL) | 21 | #define SV(inst) (((inst) >> 8) & 0x3UL) |
22 | #define IMM(inst) (((inst) >> 0) & 0x3FFFUL) | 22 | #define IMM(inst) (((inst) >> 0) & 0x7FFFUL) |
23 | 23 | ||
24 | #define RA3(inst) (((inst) >> 3) & 0x7UL) | 24 | #define RA3(inst) (((inst) >> 3) & 0x7UL) |
25 | #define RT3(inst) (((inst) >> 6) & 0x7UL) | 25 | #define RT3(inst) (((inst) >> 6) & 0x7UL) |
@@ -28,6 +28,9 @@ | |||
28 | #define RA5(inst) (((inst) >> 0) & 0x1FUL) | 28 | #define RA5(inst) (((inst) >> 0) & 0x1FUL) |
29 | #define RT4(inst) (((inst) >> 5) & 0xFUL) | 29 | #define RT4(inst) (((inst) >> 5) & 0xFUL) |
30 | 30 | ||
31 | #define GET_IMMSVAL(imm_value) \ | ||
32 | (((imm_value >> 14) & 0x1) ? (imm_value - 0x8000) : imm_value) | ||
33 | |||
31 | #define __get8_data(val,addr,err) \ | 34 | #define __get8_data(val,addr,err) \ |
32 | __asm__( \ | 35 | __asm__( \ |
33 | "1: lbi.bi %1, [%2], #1\n" \ | 36 | "1: lbi.bi %1, [%2], #1\n" \ |
@@ -467,7 +470,7 @@ static inline int do_32(unsigned long inst, struct pt_regs *regs) | |||
467 | } | 470 | } |
468 | 471 | ||
469 | if (imm) | 472 | if (imm) |
470 | shift = IMM(inst) * len; | 473 | shift = GET_IMMSVAL(IMM(inst)) * len; |
471 | else | 474 | else |
472 | shift = *idx_to_addr(regs, RB(inst)) << SV(inst); | 475 | shift = *idx_to_addr(regs, RB(inst)) << SV(inst); |
473 | 476 | ||