* [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe
@ 2022-04-26 8:32 Stephen Zhang
2022-04-27 0:40 ` Maciej W. Rozycki
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Zhang @ 2022-04-26 8:32 UTC (permalink / raw)
To: tsbogend, liam.howlett, ebiederm, dbueso, alobakin, f.fainelli
Cc: zhangshida, starzhangzsd, linux-kernel, linux-mips
From: Shida Zhang <zhangshida@kylinos.cn>
handle_fpe gets defined when CONFIG_MIPS_FP_SUPPORT is defined. So add
CONFIG_MIPS_FP_SUPPORT when using handle_fpe.
Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
---
arch/mips/kernel/traps.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 246c6a6b0261..ef9792261f91 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -90,7 +90,9 @@ extern asmlinkage void handle_cpu(void);
extern asmlinkage void handle_ov(void);
extern asmlinkage void handle_tr(void);
extern asmlinkage void handle_msa_fpe(void);
+#ifdef CONFIG_MIPS_FP_SUPPORT
extern asmlinkage void handle_fpe(void);
+#endif
extern asmlinkage void handle_ftlb(void);
extern asmlinkage void handle_gsexc(void);
extern asmlinkage void handle_msa(void);
@@ -2489,8 +2491,10 @@ void __init trap_init(void)
if (board_nmi_handler_setup)
board_nmi_handler_setup();
+#ifdef CONFIG_MIPS_FP_SUPPORT
if (cpu_has_fpu && !cpu_has_nofpuex)
set_except_vector(EXCCODE_FPE, handle_fpe);
+#endif
if (cpu_has_ftlbparex)
set_except_vector(MIPS_EXCCODE_TLBPAR, handle_ftlb);
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe
2022-04-26 8:32 [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe Stephen Zhang
@ 2022-04-27 0:40 ` Maciej W. Rozycki
2022-04-27 1:57 ` Stephen Zhang
0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2022-04-27 0:40 UTC (permalink / raw)
To: Stephen Zhang
Cc: Thomas Bogendoerfer, liam.howlett, ebiederm, dbueso, alobakin,
f.fainelli, zhangshida, linux-kernel, linux-mips
On Tue, 26 Apr 2022, Stephen Zhang wrote:
> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> index 246c6a6b0261..ef9792261f91 100644
> --- a/arch/mips/kernel/traps.c
> +++ b/arch/mips/kernel/traps.c
> @@ -90,7 +90,9 @@ extern asmlinkage void handle_cpu(void);
> extern asmlinkage void handle_ov(void);
> extern asmlinkage void handle_tr(void);
> extern asmlinkage void handle_msa_fpe(void);
> +#ifdef CONFIG_MIPS_FP_SUPPORT
> extern asmlinkage void handle_fpe(void);
> +#endif
No need to conditionalise declarations ever.
> @@ -2489,8 +2491,10 @@ void __init trap_init(void)
> if (board_nmi_handler_setup)
> board_nmi_handler_setup();
>
> +#ifdef CONFIG_MIPS_FP_SUPPORT
> if (cpu_has_fpu && !cpu_has_nofpuex)
> set_except_vector(EXCCODE_FPE, handle_fpe);
> +#endif
No need to conditionalise this either, because `cpu_has_fpu' is forced 0
(in arch/mips/include/asm/cpu-features.h) if !CONFIG_MIPS_FP_SUPPORT. So
this code translates to:
if (0 && !0)
set_except_vector(15, handle_fpe);
in the preprocessor if CONFIG_MIPS_FP_SUPPORT is unset and is optimised
away. Otherwise it should be written as:
if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT) && ...
so as not to clutter C code with #ifdef, as per our coding style.
Maciej
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe
2022-04-27 0:40 ` Maciej W. Rozycki
@ 2022-04-27 1:57 ` Stephen Zhang
2022-04-27 10:57 ` Maciej W. Rozycki
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Zhang @ 2022-04-27 1:57 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Thomas Bogendoerfer, liam.howlett, ebiederm, dbueso, alobakin,
f.fainelli, zhangshida, linux-kernel, linux-mips
Maciej W. Rozycki <macro@orcam.me.uk> 于2022年4月27日周三 08:40写道:
>
> No need to conditionalise this either, because `cpu_has_fpu' is forced 0
> (in arch/mips/include/asm/cpu-features.h) if !CONFIG_MIPS_FP_SUPPORT. So
> this code translates to:
>
> if (0 && !0)
> set_except_vector(15, handle_fpe);
>
> in the preprocessor if CONFIG_MIPS_FP_SUPPORT is unset and is optimised
> away. Otherwise it should be written as:
>
> if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT) && ...
>
> so as not to clutter C code with #ifdef, as per our coding style.
>
> Maciej
Thanks for your comment. Do you mean the following code:
if (0 && !0)
set_except_vector(15, handle_fpe);
will be optimised away if !CONFIG_MIPS_FP_SUPPORT?
But we did get “undefined reference to `handle_fpe” error when compiled with
!CONFIG_MIPS_FP_SUPPORT.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe
2022-04-27 1:57 ` Stephen Zhang
@ 2022-04-27 10:57 ` Maciej W. Rozycki
[not found] ` <CANubcdUPQJcJ=dryJGsnQLhjcTouLUARD-GwCd7UjurUm+-GXg@mail.gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2022-04-27 10:57 UTC (permalink / raw)
To: Stephen Zhang
Cc: Thomas Bogendoerfer, liam.howlett, ebiederm, dbueso, alobakin,
f.fainelli, zhangshida, linux-kernel, linux-mips
On Wed, 27 Apr 2022, Stephen Zhang wrote:
> Thanks for your comment. Do you mean the following code:
>
> if (0 && !0)
> set_except_vector(15, handle_fpe);
>
> will be optimised away if !CONFIG_MIPS_FP_SUPPORT?
Yes. Or more specifically the LHS of the conditional expression will be
0 then, as shown above, and the whole statement will be gone.
> But we did get “undefined reference to `handle_fpe” error when compiled with
> !CONFIG_MIPS_FP_SUPPORT.
Please send me .config causing it and tell me what compiler and version
you have seen this error with. We rely on things being optimised away
heavily throughout the Linux kernel, so this is certainly something to
investigate. I have built such a config just fine, but maybe there's a
bug somewhere my setup does not trigger.
Maciej
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe
[not found] ` <CANubcdUPQJcJ=dryJGsnQLhjcTouLUARD-GwCd7UjurUm+-GXg@mail.gmail.com>
@ 2022-04-28 9:00 ` Maciej W. Rozycki
2022-04-29 3:10 ` Stephen Zhang
0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2022-04-28 9:00 UTC (permalink / raw)
To: Stephen Zhang, Thomas Bogendoerfer, Joshua Kinard
Cc: liam.howlett, ebiederm, dbueso, alobakin, f.fainelli, zhangshida,
linux-kernel, linux-mips
On Thu, 28 Apr 2022, Stephen Zhang wrote:
> > Please send me .config causing it and tell me what compiler and version
> > you have seen this error with. We rely on things being optimised away
> > heavily throughout the Linux kernel, so this is certainly something to
> > investigate. I have built such a config just fine, but maybe there's a
> > bug somewhere my setup does not trigger.
>
> Okay. The compiler we used is:
>
> Compiler gcc
> Compiler version 10
> Compiler string mips-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
> Cross-compile mips-linux-gnu
>
> the commit id of kernel is c00c5e1d157bec0ef0b0b59aa5482eb8dc7e8e49
>
> and the .config file is sent as an attachment.
Thanks.
The bug is in arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h,
which has:
#define cpu_has_fpu 1
(and similarly arch/mips/include/asm/mach-ip30/cpu-feature-overrides.h).
This is not supported, as noted in arch/mips/include/asm/cpu-features.h:
/* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work. */
Perhaps we should explicitly undefine `cpu_has_fpu' if set to 1?
Maciej
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe
2022-04-28 9:00 ` Maciej W. Rozycki
@ 2022-04-29 3:10 ` Stephen Zhang
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Zhang @ 2022-04-29 3:10 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Thomas Bogendoerfer, Joshua Kinard, liam.howlett, ebiederm,
dbueso, alobakin, f.fainelli, zhangshida, linux-kernel,
linux-mips
Maciej W. Rozycki <macro@orcam.me.uk> 于2022年4月28日周四 17:00写道:
>
> On Thu, 28 Apr 2022, Stephen Zhang wrote:
> Thanks.
>
> The bug is in arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h,
> which has:
>
> #define cpu_has_fpu 1
>
> (and similarly arch/mips/include/asm/mach-ip30/cpu-feature-overrides.h).
> This is not supported, as noted in arch/mips/include/asm/cpu-features.h:
>
> /* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work. */
>
> Perhaps we should explicitly undefine `cpu_has_fpu' if set to 1?
>
> Maciej
Thanks for your detailed explanation and suggestion. I will make a v2 patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-29 3:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-26 8:32 [PATCH] arch/mips/kernel/traps: add CONFIG_MIPS_FP_SUPPORT when using handle_fpe Stephen Zhang
2022-04-27 0:40 ` Maciej W. Rozycki
2022-04-27 1:57 ` Stephen Zhang
2022-04-27 10:57 ` Maciej W. Rozycki
[not found] ` <CANubcdUPQJcJ=dryJGsnQLhjcTouLUARD-GwCd7UjurUm+-GXg@mail.gmail.com>
2022-04-28 9:00 ` Maciej W. Rozycki
2022-04-29 3:10 ` Stephen Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox