From: Palmer Dabbelt Date: Tue, 23 Oct 2018 00:38:26 +0000 (-0700) Subject: riscv: Add support to no-FPU systems X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4e4101cfefd382176b05356c5ef112561ae10384;p=linux.git riscv: Add support to no-FPU systems 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 --- 4e4101cfefd382176b05356c5ef112561ae10384 diff --cc arch/riscv/Kconfig index 6c8329beb9368,a63f9dbb47060..4198759f67987 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@@ -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" diff --cc arch/riscv/Makefile index 33700e4bfc3bc,901770fc9bd2c..d10146197533a --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@@ -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 diff --cc arch/riscv/kernel/cpufeature.c index 652d102ffa06d,46942e6352668..5493f32287047 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@@ -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 }