Merge tag 'nds32-for-linux-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/greentime/linux

Pull nds32 fixes from Greentime Hu:

 - fix warning for math-emu

 - fix nds32 fpu exception handling

 - fix nds32 fpu emulation implementation

* tag 'nds32-for-linux-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/greentime/linux:
  nds32: add new emulations for floating point instruction
  nds32: Avoid IEX status being incorrectly modified
  math-emu: Use statement expressions to fix Wshift-count-overflow warning
This commit is contained in:
Linus Torvalds
2019-06-03 10:23:41 -07:00
26 changed files with 464 additions and 66 deletions

View File

@@ -14,7 +14,7 @@ const struct fpu_struct init_fpuregs = {
.fd_regs = {[0 ... 31] = sNAN64},
.fpcsr = FPCSR_INIT,
#if IS_ENABLED(CONFIG_SUPPORT_DENORMAL_ARITHMETIC)
.UDF_trap = 0
.UDF_IEX_trap = 0
#endif
};
@@ -178,7 +178,7 @@ inline void do_fpu_context_switch(struct pt_regs *regs)
/* First time FPU user. */
load_fpu(&init_fpuregs);
#if IS_ENABLED(CONFIG_SUPPORT_DENORMAL_ARITHMETIC)
current->thread.fpu.UDF_trap = init_fpuregs.UDF_trap;
current->thread.fpu.UDF_IEX_trap = init_fpuregs.UDF_IEX_trap;
#endif
set_used_math();
}
@@ -206,7 +206,7 @@ inline void handle_fpu_exception(struct pt_regs *regs)
unsigned int fpcsr;
int si_code = 0, si_signo = SIGFPE;
#if IS_ENABLED(CONFIG_SUPPORT_DENORMAL_ARITHMETIC)
unsigned long redo_except = FPCSR_mskDNIT|FPCSR_mskUDFT;
unsigned long redo_except = FPCSR_mskDNIT|FPCSR_mskUDFT|FPCSR_mskIEXT;
#else
unsigned long redo_except = FPCSR_mskDNIT;
#endif
@@ -215,21 +215,18 @@ inline void handle_fpu_exception(struct pt_regs *regs)
fpcsr = current->thread.fpu.fpcsr;
if (fpcsr & redo_except) {
#if IS_ENABLED(CONFIG_SUPPORT_DENORMAL_ARITHMETIC)
if (fpcsr & FPCSR_mskUDFT)
current->thread.fpu.fpcsr &= ~FPCSR_mskIEX;
#endif
si_signo = do_fpuemu(regs, &current->thread.fpu);
fpcsr = current->thread.fpu.fpcsr;
if (!si_signo)
if (!si_signo) {
current->thread.fpu.fpcsr &= ~(redo_except);
goto done;
}
} else if (fpcsr & FPCSR_mskRIT) {
if (!user_mode(regs))
do_exit(SIGILL);
si_signo = SIGILL;
}
switch (si_signo) {
case SIGFPE:
fill_sigfpe_signo(fpcsr, &si_code);

View File

@@ -6,8 +6,8 @@
#include <asm/cachectl.h>
#include <asm/proc-fns.h>
#include <asm/udftrap.h>
#include <asm/fpu.h>
#include <asm/fp_udfiex_crtl.h>
SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
unsigned long, prot, unsigned long, flags,
@@ -51,31 +51,33 @@ SYSCALL_DEFINE3(cacheflush, unsigned int, start, unsigned int, end, int, cache)
return 0;
}
SYSCALL_DEFINE1(udftrap, int, option)
SYSCALL_DEFINE2(fp_udfiex_crtl, unsigned int, cmd, unsigned int, act)
{
#if IS_ENABLED(CONFIG_SUPPORT_DENORMAL_ARITHMETIC)
int old_udftrap;
int old_udf_iex;
if (!used_math()) {
load_fpu(&init_fpuregs);
current->thread.fpu.UDF_trap = init_fpuregs.UDF_trap;
current->thread.fpu.UDF_IEX_trap = init_fpuregs.UDF_IEX_trap;
set_used_math();
}
old_udftrap = current->thread.fpu.UDF_trap;
switch (option) {
case DISABLE_UDFTRAP:
current->thread.fpu.UDF_trap = 0;
old_udf_iex = current->thread.fpu.UDF_IEX_trap;
act &= (FPCSR_mskUDFE | FPCSR_mskIEXE);
switch (cmd) {
case DISABLE_UDF_IEX_TRAP:
current->thread.fpu.UDF_IEX_trap &= ~act;
break;
case ENABLE_UDFTRAP:
current->thread.fpu.UDF_trap = FPCSR_mskUDFE;
case ENABLE_UDF_IEX_TRAP:
current->thread.fpu.UDF_IEX_trap |= act;
break;
case GET_UDFTRAP:
case GET_UDF_IEX_TRAP:
break;
default:
return -EINVAL;
}
return old_udftrap;
return old_udf_iex;
#else
return -ENOTSUPP;
#endif