summaryrefslogtreecommitdiffstats
path: root/arch/riscv/kernel/signal.c
diff options
context:
space:
mode:
authorAlan Kao <alankao@andestech.com>2018-10-09 04:18:34 +0200
committerPalmer Dabbelt <palmer@sifive.com>2018-10-23 02:02:23 +0200
commit9411ec60c23d868124d9c1b1d491937aebe07afa (patch)
treeb099a760ac5b284dd79281ded728e35ec30d2e77 /arch/riscv/kernel/signal.c
parentAllow to disable FPU support (diff)
downloadlinux-9411ec60c23d868124d9c1b1d491937aebe07afa.tar.xz
linux-9411ec60c23d868124d9c1b1d491937aebe07afa.zip
Auto-detect whether a FPU exists
We expect that a kernel with CONFIG_FPU=y can still support no-FPU machines. To do so, the kernel should first examine the existence of a FPU, then do nothing if a FPU does exist; otherwise, it should disable/bypass all FPU-related functions. In this patch, a new global variable, has_fpu, is created and determined when parsing the hardware capability from device tree during booting. This variable is used in those FPU-related functions. Signed-off-by: Alan Kao <alankao@andestech.com> Cc: Greentime Hu <greentime@andestech.com> Cc: Vincent Chen <vincentc@andestech.com> Cc: Zong Li <zong@andestech.com> Cc: Nick Hu <nickhu@andestech.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Diffstat (limited to 'arch/riscv/kernel/signal.c')
-rw-r--r--arch/riscv/kernel/signal.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 2450b824d799..f9b5e7e352ef 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -98,7 +98,8 @@ static long restore_sigcontext(struct pt_regs *regs,
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_from_user(regs, &sc->sc_regs, sizeof(sc->sc_regs));
/* Restore the floating-point state. */
- err |= restore_fp_state(regs, &sc->sc_fpregs);
+ if (has_fpu)
+ err |= restore_fp_state(regs, &sc->sc_fpregs);
return err;
}
@@ -150,7 +151,8 @@ static long setup_sigcontext(struct rt_sigframe __user *frame,
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_to_user(&sc->sc_regs, regs, sizeof(sc->sc_regs));
/* Save the floating-point state. */
- err |= save_fp_state(regs, &sc->sc_fpregs);
+ if (has_fpu)
+ err |= save_fp_state(regs, &sc->sc_fpregs);
return err;
}