riscv: Add support to no-FPU systems
authorPalmer Dabbelt <palmer@sifive.com>
Tue, 23 Oct 2018 00:38:26 +0000 (17:38 -0700)
committerPalmer Dabbelt <palmer@sifive.com>
Tue, 23 Oct 2018 00:38:26 +0000 (17:38 -0700)
This patchset adds an option, CONFIG_FPU, to enable/disable floating-
point support within the kernel.  The kernel's new behavior will be as
follows:

* with CONFIG_FPU=y
  All FPU codes are reserved.  If no FPU is found during booting, a
  global flag will be set, and those functions will be bypassed with
  condition check to that flag.

* with CONFIG_FPU=n
  No floating-point instructions in kernel and all related settings
  are excluded.

Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
1  2 
arch/riscv/Kconfig
arch/riscv/Makefile
arch/riscv/kernel/cpufeature.c

@@@ -210,9 -208,18 +210,18 @@@ config RISCV_BASE_PM
  
  endmenu
  
+ config FPU
+       bool "FPU support"
+       default y
+       help
+         Say N here if you want to disable all floating-point related procedure
+         in the kernel.
+         If you don't know what to do here, say Y.
  endmenu
  
 -menu "Kernel type"
 +menu "Kernel features"
  
  source "kernel/Kconfig.hz"
  
@@@ -25,8 -25,9 +25,7 @@@ ifeq ($(CONFIG_ARCH_RV64I),y
  
        KBUILD_CFLAGS += -mabi=lp64
        KBUILD_AFLAGS += -mabi=lp64
 -      
 -      KBUILD_CFLAGS   += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
  
-       KBUILD_MARCH = rv64im
        KBUILD_LDFLAGS += -melf64lriscv
  else
        BITS := 32
@@@ -57,12 -60,10 +60,17 @@@ void riscv_fill_hwcap(void
        for (i = 0; i < strlen(isa); ++i)
                elf_hwcap |= isa2hwcap[(unsigned char)(isa[i])];
  
 +      /* We don't support systems with F but without D, so mask those out
 +       * here. */
 +      if ((elf_hwcap & COMPAT_HWCAP_ISA_F) && !(elf_hwcap & COMPAT_HWCAP_ISA_D)) {
 +              pr_info("This kernel does not support systems with F but not D");
 +              elf_hwcap &= ~COMPAT_HWCAP_ISA_F;
 +      }
 +
        pr_info("elf_hwcap is 0x%lx", elf_hwcap);
+ #ifdef CONFIG_FPU
+       if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D))
+               has_fpu = true;
+ #endif
  }