Re: [PATCH v2 1/5] nds32: nds32 FPU port

From: Arnd Bergmann
Date: Thu Oct 11 2018 - 03:30:51 EST


On Thu, Oct 11, 2018 at 4:56 AM Vincent Chen <vincentc@xxxxxxxxxxxxx> wrote:
>
> This commit contains basic components for nds32 FPU support such as
> FPU exception handler and context switch for FPU register.
>
> diff --git a/arch/nds32/Kconfig.cpu b/arch/nds32/Kconfig.cpu
> index b8c8984..7ee4e19 100644
> --- a/arch/nds32/Kconfig.cpu
> +++ b/arch/nds32/Kconfig.cpu
> @@ -7,6 +7,28 @@ config CPU_LITTLE_ENDIAN
> bool "Little endian"
> default y
>
> +config FPU
> + bool "FPU support"
> + default n
> + help
> + If FPU ISA is used in user space, this configure shall be Y to make
> + the fpu context switch and fpu exception handler is enabled in kernel.
> + Lazy FPU is the default scheme for fpu context switch. If user wants
> + to disable Lazy FPU scheme, please enable CONFIG_UNLAZY_FPU.
> +
> + If no FPU ISA is used in user space, say N.

There was a long discussion on RISC-V about what happens when
FPU support is enabled or disabled, you may have seen that as well.

Can you confirm that:

a) A kernel with FPU support enabled running on a CPU without an FPU
will behave the same as a kernel without FPU support, and in particular
not crash while trying to access the FPU
b) A kernel with FPU support disabled running on a CPU with an FPU
prevents user space from accessing the FPU, to avoid corrupting
FPU registers during a task switch when a process accidentally contains
FPU access

> +config UNLAZY_FPU
> + bool "Unlazy FPU support"
> + depends on FPU
> + default n
> + help
> + Say Y here to disable lazy FPU scheme. Disable lazy FPU scheme causes
> + some performance loss because the fpu register are loaded and stored
> + in each context switch.
> +
> + For nomal case, say N.

I prefer Kconfig symbols to avoid using negatives, as this easily gets
confusing. Why not do it like

config LAZY_FPU_SWITCHING
bool "Lazy FPU switching"
depends on FPU
default y

Arnd