summaryrefslogtreecommitdiffstats
path: root/arch/nds32/include
diff options
context:
space:
mode:
authorVincent Chen <vincentc@andestech.com>2019-05-19 21:21:12 -0400
committerGreentime Hu <greentime@andestech.com>2019-05-31 03:23:26 -0400
commited32949e0acb73e7bc054bb02e0453d4d561ceda (patch)
treef582241cdd3450e01fe6d1cf508a3e3a8211c675 /arch/nds32/include
parent8183db10db6377ac58ad048a4c827425a614695c (diff)
nds32: Avoid IEX status being incorrectly modified
In order for kernel to capture each denormalized output, the UDF trapping enable bit is always raised in $fpcsr. Because underflow case will issue not an underflow exception but also an inexact exception, it causes that the IEX, IEX cumulative exception, flag in $fpcsr to be raised in each denormalized output handling. To make the emulation transparent to the user, the emulator needs to clear the IEX flag in $fpcsr if the result is a denormalized number. However, if the IEX flag has been raised before this floating point emulation, this cleanup may be incorrect. To avoid the IEX flags in $fpcsr be raised in each denormalized output handling, the IEX trap shall be always enabled. Signed-off-by: Vincent Chen <vincentc@andestech.com> Acked-by: Greentime Hu <greentime@andestech.com> Signed-off-by: Greentime Hu <greentime@andestech.com>
Diffstat (limited to 'arch/nds32/include')
-rw-r--r--arch/nds32/include/asm/bitfield.h2
-rw-r--r--arch/nds32/include/asm/fpu.h2
-rw-r--r--arch/nds32/include/asm/syscalls.h2
-rw-r--r--arch/nds32/include/uapi/asm/fp_udfiex_crtl.h16
-rw-r--r--arch/nds32/include/uapi/asm/sigcontext.h24
-rw-r--r--arch/nds32/include/uapi/asm/udftrap.h13
-rw-r--r--arch/nds32/include/uapi/asm/unistd.h4
7 files changed, 38 insertions, 25 deletions
diff --git a/arch/nds32/include/asm/bitfield.h b/arch/nds32/include/asm/bitfield.h
index e75212c76b20..b02a58e71f80 100644
--- a/arch/nds32/include/asm/bitfield.h
+++ b/arch/nds32/include/asm/bitfield.h
@@ -937,7 +937,7 @@
937#define FPCSR_mskDNIT ( 0x1 << FPCSR_offDNIT ) 937#define FPCSR_mskDNIT ( 0x1 << FPCSR_offDNIT )
938#define FPCSR_mskRIT ( 0x1 << FPCSR_offRIT ) 938#define FPCSR_mskRIT ( 0x1 << FPCSR_offRIT )
939#define FPCSR_mskALL (FPCSR_mskIVO | FPCSR_mskDBZ | FPCSR_mskOVF | FPCSR_mskUDF | FPCSR_mskIEX) 939#define FPCSR_mskALL (FPCSR_mskIVO | FPCSR_mskDBZ | FPCSR_mskOVF | FPCSR_mskUDF | FPCSR_mskIEX)
940#define FPCSR_mskALLE_NO_UDFE (FPCSR_mskIVOE | FPCSR_mskDBZE | FPCSR_mskOVFE | FPCSR_mskIEXE) 940#define FPCSR_mskALLE_NO_UDF_IEXE (FPCSR_mskIVOE | FPCSR_mskDBZE | FPCSR_mskOVFE)
941#define FPCSR_mskALLE (FPCSR_mskIVOE | FPCSR_mskDBZE | FPCSR_mskOVFE | FPCSR_mskUDFE | FPCSR_mskIEXE) 941#define FPCSR_mskALLE (FPCSR_mskIVOE | FPCSR_mskDBZE | FPCSR_mskOVFE | FPCSR_mskUDFE | FPCSR_mskIEXE)
942#define FPCSR_mskALLT (FPCSR_mskIVOT | FPCSR_mskDBZT | FPCSR_mskOVFT | FPCSR_mskUDFT | FPCSR_mskIEXT |FPCSR_mskDNIT | FPCSR_mskRIT) 942#define FPCSR_mskALLT (FPCSR_mskIVOT | FPCSR_mskDBZT | FPCSR_mskOVFT | FPCSR_mskUDFT | FPCSR_mskIEXT |FPCSR_mskDNIT | FPCSR_mskRIT)
943 943
diff --git a/arch/nds32/include/asm/fpu.h b/arch/nds32/include/asm/fpu.h
index 019f1bcfc5ee..8294ed4aaa2c 100644
--- a/arch/nds32/include/asm/fpu.h
+++ b/arch/nds32/include/asm/fpu.h
@@ -36,7 +36,7 @@ extern int do_fpuemu(struct pt_regs *regs, struct fpu_struct *fpu);
36 * enabled by default and kerenl will re-execute it by fpu emulator 36 * enabled by default and kerenl will re-execute it by fpu emulator
37 * when getting underflow exception. 37 * when getting underflow exception.
38 */ 38 */
39#define FPCSR_INIT FPCSR_mskUDFE 39#define FPCSR_INIT (FPCSR_mskUDFE | FPCSR_mskIEXE)
40#else 40#else
41#define FPCSR_INIT 0x0UL 41#define FPCSR_INIT 0x0UL
42#endif 42#endif
diff --git a/arch/nds32/include/asm/syscalls.h b/arch/nds32/include/asm/syscalls.h
index f3b16f602cb5..4e7216082a67 100644
--- a/arch/nds32/include/asm/syscalls.h
+++ b/arch/nds32/include/asm/syscalls.h
@@ -7,7 +7,7 @@
7asmlinkage long sys_cacheflush(unsigned long addr, unsigned long len, unsigned int op); 7asmlinkage long sys_cacheflush(unsigned long addr, unsigned long len, unsigned int op);
8asmlinkage long sys_fadvise64_64_wrapper(int fd, int advice, loff_t offset, loff_t len); 8asmlinkage long sys_fadvise64_64_wrapper(int fd, int advice, loff_t offset, loff_t len);
9asmlinkage long sys_rt_sigreturn_wrapper(void); 9asmlinkage long sys_rt_sigreturn_wrapper(void);
10asmlinkage long sys_udftrap(int option); 10asmlinkage long sys_fp_udfiex_crtl(int cmd, int act);
11 11
12#include <asm-generic/syscalls.h> 12#include <asm-generic/syscalls.h>
13 13
diff --git a/arch/nds32/include/uapi/asm/fp_udfiex_crtl.h b/arch/nds32/include/uapi/asm/fp_udfiex_crtl.h
new file mode 100644
index 000000000000..d54a5d6c6538
--- /dev/null
+++ b/arch/nds32/include/uapi/asm/fp_udfiex_crtl.h
@@ -0,0 +1,16 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (C) 2005-2019 Andes Technology Corporation */
3#ifndef _FP_UDF_IEX_CRTL_H
4#define _FP_UDF_IEX_CRTL_H
5
6/*
7 * The cmd list of sys_fp_udfiex_crtl()
8 */
9/* Disable UDF or IEX trap based on the content of parameter act */
10#define DISABLE_UDF_IEX_TRAP 0
11/* Enable UDF or IEX trap based on the content of parameter act */
12#define ENABLE_UDF_IEX_TRAP 1
13/* Get current status of UDF and IEX trap */
14#define GET_UDF_IEX_TRAP 2
15
16#endif /* _FP_UDF_IEX_CRTL_H */
diff --git a/arch/nds32/include/uapi/asm/sigcontext.h b/arch/nds32/include/uapi/asm/sigcontext.h
index 628ff6b75825..dc89af7ddcc3 100644
--- a/arch/nds32/include/uapi/asm/sigcontext.h
+++ b/arch/nds32/include/uapi/asm/sigcontext.h
@@ -13,14 +13,24 @@ struct fpu_struct {
13 unsigned long long fd_regs[32]; 13 unsigned long long fd_regs[32];
14 unsigned long fpcsr; 14 unsigned long fpcsr;
15 /* 15 /*
16 * UDF_trap is used to recognize whether underflow trap is enabled 16 * When CONFIG_SUPPORT_DENORMAL_ARITHMETIC is defined, kernel prevents
17 * or not. When UDF_trap == 1, this process will be traped and then 17 * hardware from treating the denormalized output as an underflow case
18 * get a SIGFPE signal when encountering an underflow exception. 18 * and rounding it to a normal number. Hence kernel enables the UDF and
19 * UDF_trap is only modified through setfputrap syscall. Therefore, 19 * IEX trap in the fpcsr register to step in the calculation.
20 * UDF_trap needn't be saved or loaded to context in each context 20 * However, the UDF and IEX trap enable bit in $fpcsr also lose
21 * switch. 21 * their use.
22 *
23 * UDF_IEX_trap replaces the feature of UDF and IEX trap enable bit in
24 * $fpcsr to control the trap of underflow and inexact. The bit filed
25 * of UDF_IEX_trap is the same as $fpcsr, 10th bit is used to enable UDF
26 * exception trapping and 11th bit is used to enable IEX exception
27 * trapping.
28 *
29 * UDF_IEX_trap is only modified through fp_udfiex_crtl syscall.
30 * Therefore, UDF_IEX_trap needn't be saved and restored in each
31 * context switch.
22 */ 32 */
23 unsigned long UDF_trap; 33 unsigned long UDF_IEX_trap;
24}; 34};
25 35
26struct zol_struct { 36struct zol_struct {
diff --git a/arch/nds32/include/uapi/asm/udftrap.h b/arch/nds32/include/uapi/asm/udftrap.h
deleted file mode 100644
index 433f79d679c0..000000000000
--- a/arch/nds32/include/uapi/asm/udftrap.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (C) 2005-2018 Andes Technology Corporation */
3#ifndef _ASM_SETFPUTRAP
4#define _ASM_SETFPUTRAP
5
6/*
7 * Options for setfputrap system call
8 */
9#define DISABLE_UDFTRAP 0 /* disable underflow exception trap */
10#define ENABLE_UDFTRAP 1 /* enable undeflos exception trap */
11#define GET_UDFTRAP 2 /* only get undeflos exception trap status */
12
13#endif /* _ASM_CACHECTL */
diff --git a/arch/nds32/include/uapi/asm/unistd.h b/arch/nds32/include/uapi/asm/unistd.h
index c691735017ed..a0b2f7b9c0f2 100644
--- a/arch/nds32/include/uapi/asm/unistd.h
+++ b/arch/nds32/include/uapi/asm/unistd.h
@@ -11,6 +11,6 @@
11 11
12/* Additional NDS32 specific syscalls. */ 12/* Additional NDS32 specific syscalls. */
13#define __NR_cacheflush (__NR_arch_specific_syscall) 13#define __NR_cacheflush (__NR_arch_specific_syscall)
14#define __NR_udftrap (__NR_arch_specific_syscall + 1) 14#define __NR_fp_udfiex_crtl (__NR_arch_specific_syscall + 1)
15__SYSCALL(__NR_cacheflush, sys_cacheflush) 15__SYSCALL(__NR_cacheflush, sys_cacheflush)
16__SYSCALL(__NR_udftrap, sys_udftrap) 16__SYSCALL(__NR_fp_udfiex_crtl, sys_fp_udfiex_crtl)