]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
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

index 6c8329beb9368cc4ee16e0cd9b5db3a436ba6612,a63f9dbb470602c8129c0fa172a3dc48144f980f..4198759f6798765eb8d562eec3d1b2de4d23b6da
@@@ -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"
  
index 33700e4bfc3bc70696c6788453c26d367e4ee754,901770fc9bd2c8a4f72ae82447b806b3275414d6..d10146197533affd63c3e7392ccd73a4d7ba2e27
@@@ -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
index 652d102ffa06dfc25fb34eb84852a810cb1be463,46942e63526684c5c32b363058c4eeebbed08fb3..5493f3228704740e913e0d5883d1cca99ba7f645
@@@ -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
  }