Linux-MIPS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
@ 2020-07-31  4:11 Jiaxun Yang
  0 siblings, 0 replies; 9+ messages in thread
From: Jiaxun Yang @ 2020-07-31  4:11 UTC (permalink / raw)
  To: linux-mips
  Cc: Jiaxun Yang, Thomas Bogendoerfer, Paul Burton, Huacai Chen,
	Zhou Yanjie, Serge Semin, 周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel

Requested by downstream distros, a Kconfig option for default
IEEE754 conformance mode allows them to set their mode to
relaxed by default.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/Kconfig            | 21 +++++++++++++++++++++
 arch/mips/kernel/cpu-probe.c | 12 +++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index f6bb446d30f0..ef5b2a177b1b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2877,6 +2877,27 @@ config MIPS_NR_CPU_NR_MAP
 	default 1024 if MIPS_NR_CPU_NR_MAP_1024
 	default NR_CPUS if !MIPS_NR_CPU_NR_MAP_1024
 
+choice
+	prompt "Default IEEE Std 754 conformance mode"
+	default IEEE754_DEFAULT_STRICT
+	help
+	  Default IEEE Std 754 conformance mode, see ieee754= kernel parameter
+	  for detail.
+
+	config IEEE754_DEFAULT_STRICT
+		bool "Strict"
+
+	config IEEE754_DEFAULT_LEGACY
+		bool "Legacy"
+
+	config IEEE754_DEFAULT_STD2008
+		bool "2008"
+
+	config IEEE754_DEFAULT_RELAXED
+		bool "Relaxed"
+
+endchoice
+
 #
 # Timer Interrupt Frequency Configuration
 #
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index d9e8d39a7289..03adeed58efb 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -157,7 +157,17 @@ static void cpu_set_fpu_2008(struct cpuinfo_mips *c)
  * IEEE 754 conformance mode to use.  Affects the NaN encoding and the
  * ABS.fmt/NEG.fmt execution mode.
  */
-static enum { STRICT, LEGACY, STD2008, RELAXED } ieee754 = STRICT;
+enum ieee754_mode { STRICT, LEGACY, STD2008, RELAXED };
+
+#if defined(CONFIG_IEEE754_DEFAULT_STRICT)
+static enum ieee754_mode ieee754 = STRICT;
+#elif defined(CONFIG_IEEE754_DEFAULT_LEGACY)
+static enum ieee754_mode ieee754 = LEGACY;
+#elif defined(CONFIG_IEEE754_DEFAULT_STD2008)
+static enum ieee754_mode ieee754 = STD2008;
+#elif defined(CONFIG_IEEE754_DEFAULT_RELAXED)
+static enum ieee754_mode ieee754 = RELAXED;
+#endif
 
 /*
  * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes
-- 
2.28.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
  2020-08-03  9:01     ` Jiaxun Yang
  2020-08-05 19:30       ` Maciej W. Rozycki
@ 2020-08-05 20:49       ` Zhou Yanjie
  1 sibling, 0 replies; 9+ messages in thread
From: Zhou Yanjie @ 2020-08-05 20:49 UTC (permalink / raw)
  To: Jiaxun Yang, Maciej W. Rozycki, Serge Semin
  Cc: Serge Semin, linux-mips, Thomas Bogendoerfer, Paul Burton,
	Huacai Chen, Zhou Yanjie, 周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel, Maciej W. Rozycki


在 2020/8/3 下午5:01, Jiaxun Yang 写道:
>
>
> 在 2020/8/3 上午5:46, Maciej W. Rozycki 写道:
>> On Fri, 31 Jul 2020, Serge Semin wrote:
>>
>>>> Requested by downstream distros, a Kconfig option for default
>>>> IEEE754 conformance mode allows them to set their mode to
>>>> relaxed by default.
>>> That's what should have been here in the first place. Thanks!
>>   Well, originally plans were there to have NaN interlinking implemented
>> and no such mess or desire for hacks like one here would result.  Cf.:
>>
>> <https://gcc.gnu.org/ml/gcc/2015-11/msg00068.html>,
>> <https://gcc.gnu.org/ml/gcc/2016-05/msg00137.html>,
>>
>> and then:
>>
>> <https://lkml.org/lkml/2015/11/16/386>,
>> <https://sourceware.org/ml/libc-alpha/2015-11/msg00485.html>,
>> <https://sourceware.org/ml/binutils/2015-11/msg00170.html>,
>> <https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03241.html>.
>>
>> You could well pick this work up and complete it if you like. Final
>> conclusions for further work were made here:
>>
>> <https://gcc.gnu.org/ml/gcc/2016-11/msg00027.html>,
>> <https://gcc.gnu.org/ml/gcc/2017-08/msg00260.html>,
>> <https://gcc.gnu.org/ml/gcc/2017-10/msg00142.html>.
>>
>>   In the relaxed mode math programs may produce wrong results unless you
>> rebuild all your software for the correct NaN mode for the hardware used
>
> Unfortunately most of the hardware guys didn't understood the 
> difficulty here.
> They decided to implement their hardware (P5600 & LS3A4000) as NaN2008 
> only.
>

All SoCs based on Ingenic XBurst2 CPU core are also NaN2008 only.


> I was thinking about let Kernel drop SIGFPE exception was caused by 
> mismatched NaN,
> as most applications don't rely on signaling NaN, but it is still a 
> dirty hack. Not a good
> idea in general.
>
> Thanks.
>
> - Jiaxun
>
>> (in which case you don't need the relaxed setting in the first place).
>
>>
>>    Maciej

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
  2020-08-03  9:01     ` Jiaxun Yang
@ 2020-08-05 19:30       ` Maciej W. Rozycki
  2020-08-05 20:49       ` Zhou Yanjie
  1 sibling, 0 replies; 9+ messages in thread
From: Maciej W. Rozycki @ 2020-08-05 19:30 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: Serge Semin, Serge Semin, linux-mips, Thomas Bogendoerfer,
	Paul Burton, Huacai Chen, Zhou Yanjie,
	周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel, Maciej W. Rozycki

On Mon, 3 Aug 2020, Jiaxun Yang wrote:

> >   Well, originally plans were there to have NaN interlinking implemented
> > and no such mess or desire for hacks like one here would result.  Cf.:
> >
> > <https://gcc.gnu.org/ml/gcc/2015-11/msg00068.html>,
> > <https://gcc.gnu.org/ml/gcc/2016-05/msg00137.html>,
> >
> > and then:
> >
> > <https://lkml.org/lkml/2015/11/16/386>,
> > <https://sourceware.org/ml/libc-alpha/2015-11/msg00485.html>,
> > <https://sourceware.org/ml/binutils/2015-11/msg00170.html>,
> > <https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03241.html>.
> >
> > You could well pick this work up and complete it if you like.  Final
> > conclusions for further work were made here:
> >
> > <https://gcc.gnu.org/ml/gcc/2016-11/msg00027.html>,
> > <https://gcc.gnu.org/ml/gcc/2017-08/msg00260.html>,
> > <https://gcc.gnu.org/ml/gcc/2017-10/msg00142.html>.
> >
> >   In the relaxed mode math programs may produce wrong results unless you
> > rebuild all your software for the correct NaN mode for the hardware used
> 
> Unfortunately most of the hardware guys didn't understood the difficulty 
> here.
> They decided to implement their hardware (P5600 & LS3A4000) as NaN2008 only.

 Sadly we (the software group) have lost the battle with the hardware 
group for the architecture to have FCSR.NAN2008 at least optionally 
writable, and the feature was subsequently removed from R5 on, along with 
the writability of FCSR.ABS2008 and the FCSR.MAC2008 bit altogether.

 Still R3 did permit those bits to be r/w (check rev. 3.50 of the 
architecture spec), which is why I implemented them as such in our FP 
emulation and also QEMU (although I need to note that a competing QEMU 
implementation was pushed upstream behind my back, which I believe wasn't 
as complete as mine, so this part may or may not have been implemented).

> I was thinking about let Kernel drop SIGFPE exception was caused by 
> mismatched NaN,
> as most applications don't rely on signaling NaN, but it is still a 
> dirty hack. Not a good
> idea in general.

 I think you cannot reliably send SIGFPE, because hardware does not trap 
on what it considers a qNaN.

 The interlinking effort was there to let individual pieces of software 
that have various requirements for NaNs, or do not use FP at all, to use a 
set of rules for possibly being allowed to run on incompatible hardware or 
loaded together by the dynamic loader.  For example there was a mode 
specified where all NaNs were silently treated as qNaNs regardless of the 
hardware interpretation of a specific encoding.

 I maintain this is the way to move forward, and if you are serious about 
keeping the architecture alive, then I strongly recommend to upstream the 
implementation, possibly based on my patches previously published, 
although as indicated in the discussion referred there have been design 
issues observed, which mean a certain amount of rework will be required, 
first on the spec, and then the implementation.

 FWIW,

  Maciej

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
  2020-08-02 21:46   ` Maciej W. Rozycki
@ 2020-08-03  9:01     ` Jiaxun Yang
  2020-08-05 19:30       ` Maciej W. Rozycki
  2020-08-05 20:49       ` Zhou Yanjie
  0 siblings, 2 replies; 9+ messages in thread
From: Jiaxun Yang @ 2020-08-03  9:01 UTC (permalink / raw)
  To: Maciej W. Rozycki, Serge Semin
  Cc: Serge Semin, linux-mips, Thomas Bogendoerfer, Paul Burton,
	Huacai Chen, Zhou Yanjie, 周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel, Maciej W. Rozycki



在 2020/8/3 上午5:46, Maciej W. Rozycki 写道:
> On Fri, 31 Jul 2020, Serge Semin wrote:
>
>>> Requested by downstream distros, a Kconfig option for default
>>> IEEE754 conformance mode allows them to set their mode to
>>> relaxed by default.
>> That's what should have been here in the first place. Thanks!
>   Well, originally plans were there to have NaN interlinking implemented
> and no such mess or desire for hacks like one here would result.  Cf.:
>
> <https://gcc.gnu.org/ml/gcc/2015-11/msg00068.html>,
> <https://gcc.gnu.org/ml/gcc/2016-05/msg00137.html>,
>
> and then:
>
> <https://lkml.org/lkml/2015/11/16/386>,
> <https://sourceware.org/ml/libc-alpha/2015-11/msg00485.html>,
> <https://sourceware.org/ml/binutils/2015-11/msg00170.html>,
> <https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03241.html>.
>
> You could well pick this work up and complete it if you like.  Final
> conclusions for further work were made here:
>
> <https://gcc.gnu.org/ml/gcc/2016-11/msg00027.html>,
> <https://gcc.gnu.org/ml/gcc/2017-08/msg00260.html>,
> <https://gcc.gnu.org/ml/gcc/2017-10/msg00142.html>.
>
>   In the relaxed mode math programs may produce wrong results unless you
> rebuild all your software for the correct NaN mode for the hardware used

Unfortunately most of the hardware guys didn't understood the difficulty 
here.
They decided to implement their hardware (P5600 & LS3A4000) as NaN2008 only.

I was thinking about let Kernel drop SIGFPE exception was caused by 
mismatched NaN,
as most applications don't rely on signaling NaN, but it is still a 
dirty hack. Not a good
idea in general.

Thanks.

- Jiaxun

> (in which case you don't need the relaxed setting in the first place).

>
>    Maciej

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
  2020-07-31  6:17 ` Serge Semin
  2020-07-31  6:54   ` Huacai Chen
@ 2020-08-02 21:46   ` Maciej W. Rozycki
  2020-08-03  9:01     ` Jiaxun Yang
  1 sibling, 1 reply; 9+ messages in thread
From: Maciej W. Rozycki @ 2020-08-02 21:46 UTC (permalink / raw)
  To: Serge Semin
  Cc: Jiaxun Yang, Serge Semin, linux-mips, Thomas Bogendoerfer,
	Paul Burton, Huacai Chen, Zhou Yanjie,
	周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel, Maciej W. Rozycki

On Fri, 31 Jul 2020, Serge Semin wrote:

> > Requested by downstream distros, a Kconfig option for default
> > IEEE754 conformance mode allows them to set their mode to
> > relaxed by default.
> 
> That's what should have been here in the first place. Thanks!

 Well, originally plans were there to have NaN interlinking implemented 
and no such mess or desire for hacks like one here would result.  Cf.:

<https://gcc.gnu.org/ml/gcc/2015-11/msg00068.html>,
<https://gcc.gnu.org/ml/gcc/2016-05/msg00137.html>,

and then:

<https://lkml.org/lkml/2015/11/16/386>,
<https://sourceware.org/ml/libc-alpha/2015-11/msg00485.html>,
<https://sourceware.org/ml/binutils/2015-11/msg00170.html>,
<https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03241.html>.

You could well pick this work up and complete it if you like.  Final 
conclusions for further work were made here:

<https://gcc.gnu.org/ml/gcc/2016-11/msg00027.html>,
<https://gcc.gnu.org/ml/gcc/2017-08/msg00260.html>,
<https://gcc.gnu.org/ml/gcc/2017-10/msg00142.html>.

 In the relaxed mode math programs may produce wrong results unless you 
rebuild all your software for the correct NaN mode for the hardware used 
(in which case you don't need the relaxed setting in the first place).

  Maciej

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
  2020-07-31  4:10 Jiaxun Yang
  2020-07-31  6:17 ` Serge Semin
@ 2020-07-31  8:33 ` WANG Xuerui
  1 sibling, 0 replies; 9+ messages in thread
From: WANG Xuerui @ 2020-07-31  8:33 UTC (permalink / raw)
  To: Jiaxun Yang, linux-mips
  Cc: Thomas Bogendoerfer, Paul Burton, Huacai Chen, Serge Semin,
	Zhou Yanjie, 周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel

Hi Jiaxun,

Nice catch! Only one minor nit. Otherwise:

Reviewed-by: WANG Xuerui <git@xen0n.name>


On 2020/7/31 12:10, Jiaxun Yang wrote:
> Requested by downstream distros, a Kconfig option for default
> IEEE754 conformance mode allows them to set their mode to
> relaxed by default.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  arch/mips/Kconfig            | 21 +++++++++++++++++++++
>  arch/mips/kernel/cpu-probe.c | 12 +++++++++++-
>  2 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index f6bb446d30f0..ef5b2a177b1b 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -2877,6 +2877,27 @@ config MIPS_NR_CPU_NR_MAP
>  	default 1024 if MIPS_NR_CPU_NR_MAP_1024
>  	default NR_CPUS if !MIPS_NR_CPU_NR_MAP_1024
>  
> +choice
> +	prompt "Default IEEE Std 754 conformance mode"
> +	default IEEE754_DEFAULT_STRICT
> +	help
> +	  Default IEEE Std 754 conformance mode, see ieee754= kernel parameter
> +	  for detail.

Here and the title, "IEEE Std 754" can be just "IEEE 754". I don't
remember seeing the "IEEE Std 754" phrase anywhere.

I suggest the following help message:

"Sets the default IEEE 754 conformance mode, same as overriding the
default value for the ieee754= kernel parameter. See the kernel
parameter for details."

> +
> +	config IEEE754_DEFAULT_STRICT
> +		bool "Strict"
> +
> +	config IEEE754_DEFAULT_LEGACY
> +		bool "Legacy"
> +
> +	config IEEE754_DEFAULT_STD2008
> +		bool "2008"
> +
> +	config IEEE754_DEFAULT_RELAXED
> +		bool "Relaxed"
> +
> +endchoice
> +
>  #
>  # Timer Interrupt Frequency Configuration
>  #
> diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
> index d9e8d39a7289..03adeed58efb 100644
> --- a/arch/mips/kernel/cpu-probe.c
> +++ b/arch/mips/kernel/cpu-probe.c
> @@ -157,7 +157,17 @@ static void cpu_set_fpu_2008(struct cpuinfo_mips *c)
>   * IEEE 754 conformance mode to use.  Affects the NaN encoding and the
>   * ABS.fmt/NEG.fmt execution mode.
>   */
> -static enum { STRICT, LEGACY, STD2008, RELAXED } ieee754 = STRICT;
> +enum ieee754_mode { STRICT, LEGACY, STD2008, RELAXED };
> +
> +#if defined(CONFIG_IEEE754_DEFAULT_STRICT)
> +static enum ieee754_mode ieee754 = STRICT;
> +#elif defined(CONFIG_IEEE754_DEFAULT_LEGACY)
> +static enum ieee754_mode ieee754 = LEGACY;
> +#elif defined(CONFIG_IEEE754_DEFAULT_STD2008)
> +static enum ieee754_mode ieee754 = STD2008;
> +#elif defined(CONFIG_IEEE754_DEFAULT_RELAXED)
> +static enum ieee754_mode ieee754 = RELAXED;
> +#endif
>  
>  /*
>   * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
  2020-07-31  6:17 ` Serge Semin
@ 2020-07-31  6:54   ` Huacai Chen
  2020-08-02 21:46   ` Maciej W. Rozycki
  1 sibling, 0 replies; 9+ messages in thread
From: Huacai Chen @ 2020-07-31  6:54 UTC (permalink / raw)
  To: Serge Semin
  Cc: Jiaxun Yang, Serge Semin, open list:MIPS, Thomas Bogendoerfer,
	Paul Burton, Zhou Yanjie, 周琰杰 (Zhou Yanjie),
	Liangliang Huang, LKML

Reviewed-by: Huacai Chen <chenhc@lemote.com>

On Fri, Jul 31, 2020 at 2:18 PM Serge Semin
<Sergey.Semin@baikalelectronics.ru> wrote:
>
> On Fri, Jul 31, 2020 at 12:10:16PM +0800, Jiaxun Yang wrote:
> > Requested by downstream distros, a Kconfig option for default
> > IEEE754 conformance mode allows them to set their mode to
> > relaxed by default.
>
> That's what should have been here in the first place. Thanks!
> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
>
> >
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > ---
> >  arch/mips/Kconfig            | 21 +++++++++++++++++++++
> >  arch/mips/kernel/cpu-probe.c | 12 +++++++++++-
> >  2 files changed, 32 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > index f6bb446d30f0..ef5b2a177b1b 100644
> > --- a/arch/mips/Kconfig
> > +++ b/arch/mips/Kconfig
> > @@ -2877,6 +2877,27 @@ config MIPS_NR_CPU_NR_MAP
> >       default 1024 if MIPS_NR_CPU_NR_MAP_1024
> >       default NR_CPUS if !MIPS_NR_CPU_NR_MAP_1024
> >
> > +choice
> > +     prompt "Default IEEE Std 754 conformance mode"
> > +     default IEEE754_DEFAULT_STRICT
> > +     help
> > +       Default IEEE Std 754 conformance mode, see ieee754= kernel parameter
> > +       for detail.
> > +
> > +     config IEEE754_DEFAULT_STRICT
> > +             bool "Strict"
> > +
> > +     config IEEE754_DEFAULT_LEGACY
> > +             bool "Legacy"
> > +
> > +     config IEEE754_DEFAULT_STD2008
> > +             bool "2008"
> > +
> > +     config IEEE754_DEFAULT_RELAXED
> > +             bool "Relaxed"
> > +
> > +endchoice
> > +
> >  #
> >  # Timer Interrupt Frequency Configuration
> >  #
> > diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
> > index d9e8d39a7289..03adeed58efb 100644
> > --- a/arch/mips/kernel/cpu-probe.c
> > +++ b/arch/mips/kernel/cpu-probe.c
> > @@ -157,7 +157,17 @@ static void cpu_set_fpu_2008(struct cpuinfo_mips *c)
> >   * IEEE 754 conformance mode to use.  Affects the NaN encoding and the
> >   * ABS.fmt/NEG.fmt execution mode.
> >   */
> > -static enum { STRICT, LEGACY, STD2008, RELAXED } ieee754 = STRICT;
> > +enum ieee754_mode { STRICT, LEGACY, STD2008, RELAXED };
> > +
> > +#if defined(CONFIG_IEEE754_DEFAULT_STRICT)
> > +static enum ieee754_mode ieee754 = STRICT;
> > +#elif defined(CONFIG_IEEE754_DEFAULT_LEGACY)
> > +static enum ieee754_mode ieee754 = LEGACY;
> > +#elif defined(CONFIG_IEEE754_DEFAULT_STD2008)
> > +static enum ieee754_mode ieee754 = STD2008;
> > +#elif defined(CONFIG_IEEE754_DEFAULT_RELAXED)
> > +static enum ieee754_mode ieee754 = RELAXED;
> > +#endif
> >
> >  /*
> >   * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes
> > --
> > 2.28.0
> >

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
  2020-07-31  4:10 Jiaxun Yang
@ 2020-07-31  6:17 ` Serge Semin
  2020-07-31  6:54   ` Huacai Chen
  2020-08-02 21:46   ` Maciej W. Rozycki
  2020-07-31  8:33 ` WANG Xuerui
  1 sibling, 2 replies; 9+ messages in thread
From: Serge Semin @ 2020-07-31  6:17 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: Serge Semin, linux-mips, Thomas Bogendoerfer, Paul Burton,
	Huacai Chen, Zhou Yanjie, 周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel

On Fri, Jul 31, 2020 at 12:10:16PM +0800, Jiaxun Yang wrote:
> Requested by downstream distros, a Kconfig option for default
> IEEE754 conformance mode allows them to set their mode to
> relaxed by default.

That's what should have been here in the first place. Thanks!
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>

> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  arch/mips/Kconfig            | 21 +++++++++++++++++++++
>  arch/mips/kernel/cpu-probe.c | 12 +++++++++++-
>  2 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index f6bb446d30f0..ef5b2a177b1b 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -2877,6 +2877,27 @@ config MIPS_NR_CPU_NR_MAP
>  	default 1024 if MIPS_NR_CPU_NR_MAP_1024
>  	default NR_CPUS if !MIPS_NR_CPU_NR_MAP_1024
>  
> +choice
> +	prompt "Default IEEE Std 754 conformance mode"
> +	default IEEE754_DEFAULT_STRICT
> +	help
> +	  Default IEEE Std 754 conformance mode, see ieee754= kernel parameter
> +	  for detail.
> +
> +	config IEEE754_DEFAULT_STRICT
> +		bool "Strict"
> +
> +	config IEEE754_DEFAULT_LEGACY
> +		bool "Legacy"
> +
> +	config IEEE754_DEFAULT_STD2008
> +		bool "2008"
> +
> +	config IEEE754_DEFAULT_RELAXED
> +		bool "Relaxed"
> +
> +endchoice
> +
>  #
>  # Timer Interrupt Frequency Configuration
>  #
> diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
> index d9e8d39a7289..03adeed58efb 100644
> --- a/arch/mips/kernel/cpu-probe.c
> +++ b/arch/mips/kernel/cpu-probe.c
> @@ -157,7 +157,17 @@ static void cpu_set_fpu_2008(struct cpuinfo_mips *c)
>   * IEEE 754 conformance mode to use.  Affects the NaN encoding and the
>   * ABS.fmt/NEG.fmt execution mode.
>   */
> -static enum { STRICT, LEGACY, STD2008, RELAXED } ieee754 = STRICT;
> +enum ieee754_mode { STRICT, LEGACY, STD2008, RELAXED };
> +
> +#if defined(CONFIG_IEEE754_DEFAULT_STRICT)
> +static enum ieee754_mode ieee754 = STRICT;
> +#elif defined(CONFIG_IEEE754_DEFAULT_LEGACY)
> +static enum ieee754_mode ieee754 = LEGACY;
> +#elif defined(CONFIG_IEEE754_DEFAULT_STD2008)
> +static enum ieee754_mode ieee754 = STD2008;
> +#elif defined(CONFIG_IEEE754_DEFAULT_RELAXED)
> +static enum ieee754_mode ieee754 = RELAXED;
> +#endif
>  
>  /*
>   * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes
> -- 
> 2.28.0
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode
@ 2020-07-31  4:10 Jiaxun Yang
  2020-07-31  6:17 ` Serge Semin
  2020-07-31  8:33 ` WANG Xuerui
  0 siblings, 2 replies; 9+ messages in thread
From: Jiaxun Yang @ 2020-07-31  4:10 UTC (permalink / raw)
  To: linux-mips
  Cc: Jiaxun Yang, Thomas Bogendoerfer, Paul Burton, Huacai Chen,
	Serge Semin, Zhou Yanjie, 周琰杰 (Zhou Yanjie),
	Liangliang Huang, linux-kernel

Requested by downstream distros, a Kconfig option for default
IEEE754 conformance mode allows them to set their mode to
relaxed by default.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/Kconfig            | 21 +++++++++++++++++++++
 arch/mips/kernel/cpu-probe.c | 12 +++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index f6bb446d30f0..ef5b2a177b1b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2877,6 +2877,27 @@ config MIPS_NR_CPU_NR_MAP
 	default 1024 if MIPS_NR_CPU_NR_MAP_1024
 	default NR_CPUS if !MIPS_NR_CPU_NR_MAP_1024
 
+choice
+	prompt "Default IEEE Std 754 conformance mode"
+	default IEEE754_DEFAULT_STRICT
+	help
+	  Default IEEE Std 754 conformance mode, see ieee754= kernel parameter
+	  for detail.
+
+	config IEEE754_DEFAULT_STRICT
+		bool "Strict"
+
+	config IEEE754_DEFAULT_LEGACY
+		bool "Legacy"
+
+	config IEEE754_DEFAULT_STD2008
+		bool "2008"
+
+	config IEEE754_DEFAULT_RELAXED
+		bool "Relaxed"
+
+endchoice
+
 #
 # Timer Interrupt Frequency Configuration
 #
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index d9e8d39a7289..03adeed58efb 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -157,7 +157,17 @@ static void cpu_set_fpu_2008(struct cpuinfo_mips *c)
  * IEEE 754 conformance mode to use.  Affects the NaN encoding and the
  * ABS.fmt/NEG.fmt execution mode.
  */
-static enum { STRICT, LEGACY, STD2008, RELAXED } ieee754 = STRICT;
+enum ieee754_mode { STRICT, LEGACY, STD2008, RELAXED };
+
+#if defined(CONFIG_IEEE754_DEFAULT_STRICT)
+static enum ieee754_mode ieee754 = STRICT;
+#elif defined(CONFIG_IEEE754_DEFAULT_LEGACY)
+static enum ieee754_mode ieee754 = LEGACY;
+#elif defined(CONFIG_IEEE754_DEFAULT_STD2008)
+static enum ieee754_mode ieee754 = STD2008;
+#elif defined(CONFIG_IEEE754_DEFAULT_RELAXED)
+static enum ieee754_mode ieee754 = RELAXED;
+#endif
 
 /*
  * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes
-- 
2.28.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31  4:11 [PATCH] MIPS: Provide Kconfig option for default IEEE754 conformance mode Jiaxun Yang
  -- strict thread matches above, loose matches on Subject: below --
2020-07-31  4:10 Jiaxun Yang
2020-07-31  6:17 ` Serge Semin
2020-07-31  6:54   ` Huacai Chen
2020-08-02 21:46   ` Maciej W. Rozycki
2020-08-03  9:01     ` Jiaxun Yang
2020-08-05 19:30       ` Maciej W. Rozycki
2020-08-05 20:49       ` Zhou Yanjie
2020-07-31  8:33 ` WANG Xuerui

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org
	public-inbox-index linux-mips

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git