sh: add missing fpscr_values
Subsystems (4)
PATCH 1/1 sh: add missing fpscr_values
GCC on SuperH for the following program:
int foo(int i)
{
static const void *table[2] = {
[0] = &&label1,
[1] = &&label2,
};
goto *table[i & 1];
label1:
return 1;
label2:
return 2;
}
generates code:
mov.l .L9,r1
mov #1,r0
rts
lds.l @r1+,fpscr.L9:
.long __fpscr_values+4
so kernel has to provide body of fpscr_values just like glibc does
---
kernel modules can hit the same problem, so export it
arch/sh/lib/Makefile | 2 +- arch/sh/lib/fpscr_values.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 arch/sh/lib/fpscr_values.c
arch/sh/lib/Makefile +1 -1
@@ -8,7 +8,7 @@ lib-y = delay.o memmove.o memchr.o \ # Extracted from libgcc obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o + udiv_qrnnd.o fpscr_values.o udivsi3-y := udivsi3_i4i-Os.o
arch/sh/lib/fpscr_values.c new file +4 -0
@@ -0,0 +1,4 @@ +#include <linux/module.h> + +long __fpscr_values[2 ] = {0L ,0x80000L }; +EXPORT_SYMBOL (__fpscr_values);
Signature · 1 line
1.7.9.5
Quoted 22 lines · Alexei Starovoitov
GCC on SuperH for the following program:
int foo(int i){ static const void *table[2] = { [0] = &&label1, [1] = &&label2, }; goto *table[i & 1]; label1: return 1; label2: return 2; } generates code: mov.l .L9,r1 mov #1,r0 rts lds.l @r1+,fpscr.L9:
.long __fpscr_values+4
Quoted 6 lines
so kernel has to provide body of
fpscr_valuesjust like glibc doesFixes bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")Reported-by Fengguang Wu <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>
Quoted 56 lines · Alexei Starovoitov
GCC on SuperH for the following program:
int foo(int i){ static const void *table[2] = { [0] = &&label1, [1] = &&label2, }; goto *table[i & 1]; label1: return 1; label2: return 2; } generates code: mov.l .L9,r1 mov #1,r0 rts lds.l @r1+,fpscr.L9:
.long __fpscr_values+4so kernel has to provide body of
fpscr_valuesjust like glibc doesFixes bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")Reported-by Fengguang Wu <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>---
kernel modules can hit the same problem, so export it
arch/sh/lib/Makefile | 2 +- arch/sh/lib/fpscr_values.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 arch/sh/lib/fpscr_values.carch/sh/lib/Makefile +1
-1@@ -8,7 +8,7 @@ lib-y = delay.o memmove.o memchr.o \ # Extracted from libgcc obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o + udiv_qrnnd.o fpscr_values.o udivsi3-y := udivsi3_i4i-Os.oarch/sh/lib/fpscr_values.c new file +0
-0
arch/sh/lib/fpscr_values.c line 4
Quoted 4 lines
arch/sh/lib/fpscr_values.c new file +4
-0@@ -0,0 +1,4 @@ +#include <linux/module.h> + +long __fpscr_values[2 ] = {0L ,0x80000L }; +EXPORT_SYMBOL (__fpscr_values);
Pardon my ignorance, but according to
http://www.sourceware.org/ml/libc-alpha/2003-06/msg00027.html__fpscr_values is needed for FPU support only.
The kernel is built with -m4-nofpu. If this option is used, gcc doesn't generate the reference to __fpscr_values?
Why do we need symbols for userspace FPU support in the kernel?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 66 lines · Geert Uytterhoeven
Quoted 56 lines · Alexei Starovoitov
GCC on SuperH for the following program:
int foo(int i){ static const void *table[2] = { [0] = &&label1, [1] = &&label2, }; goto *table[i & 1]; label1: return 1; label2: return 2; } generates code: mov.l .L9,r1 mov #1,r0 rts lds.l @r1+,fpscr.L9:
.long __fpscr_values+4so kernel has to provide body of
fpscr_valuesjust like glibc doesFixes bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")Reported-by Fengguang Wu <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>---
kernel modules can hit the same problem, so export it
arch/sh/lib/Makefile | 2 +- arch/sh/lib/fpscr_values.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 arch/sh/lib/fpscr_values.carch/sh/lib/Makefile +1
-1@@ -8,7 +8,7 @@ lib-y = delay.o memmove.o memchr.o \ # Extracted from libgcc obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ - udiv_qrnnd.o + udiv_qrnnd.o fpscr_values.o udivsi3-y := udivsi3_i4i-Os.oarch/sh/lib/fpscr_values.c new file +0
-0arch/sh/lib/fpscr_values.c line 4
Quoted 4 lines
arch/sh/lib/fpscr_values.c new file +4
-0@@ -0,0 +1,4 @@ +#include <linux/module.h> + +long __fpscr_values[2 ] = {0L ,0x80000L }; +EXPORT_SYMBOL (__fpscr_values);Pardon my ignorance, but according to
http://www.sourceware.org/ml/libc-alpha/2003-06/msg00027.html__fpscr_valuesis needed for FPU support only.
Quoted 4 lines
The kernel is built with -m4-nofpu. If this option is used, gcc doesn't generate the reference to
__fpscr_values?Why do we need symbols for userspace FPU support in the kernel?
Ah, so this comes from these build failures in -next:
http://kisskb.ellerman.id.au/kisskb/buildresult/10875446/
http://kisskb.ellerman.id.au/kisskb/buildresult/10875446/
Indeed, SH2A-targets fail when built with a sh4-linux toolchain, as sh4-linux-gcc doesn't understand -m2a-nofpu, so it's left out:
arch/sh/Makefile:
cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \
$(call cc-option,-m2a-nofpu,)Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
David Miller
maintainerFrom: Alexei Starovoitov <[email protected]>
Date: Tue, 1 Apr 2014 19:54:04 -0700
Quoted 19 lines
GCC on SuperH for the following program:
int foo(int i){ static const void *table[2] = { [0] = &&label1, [1] = &&label2, }; goto *table[i & 1]; label1: return 1; label2: return 2; } generates code: mov.l .L9,r1 mov #1,r0 rts lds.l @r1+,fpscr
Quoted 8 lines
.L9:
.long __fpscr_values+4so kernel has to provide body of
fpscr_valuesjust like glibc doesFixes bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")Reported-by Fengguang Wu <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>
You guys really need to just fix the compiler, sorry.
Quoted 25 lines · David Miller
From: Alexei Starovoitov <[email protected]>
Date: Tue, 1 Apr 2014 19:54:04 -0700Quoted 22 lines
GCC on SuperH for the following program:
int foo(int i){ static const void *table[2] = { [0] = &&label1, [1] = &&label2, }; goto *table[i & 1]; label1: return 1; label2: return 2; } generates code: mov.l .L9,r1 mov #1,r0 rts lds.l @r1+,fpscr.L9:
.long __fpscr_values+4
Quoted 7 lines
Quoted 5 lines
so kernel has to provide body of
fpscr_valuesjust like glibc doesFixes bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")Reported-by Fengguang Wu <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>You guys really need to just fix the compiler, sorry.
agree.
To summarize:
according to Kaz:
"For sh2a, configuring gcc with --with-multilib-list=m2a,m2a-nofpu
and specifying -m2a-nofpu during compiling kernel would work."
and as Geert pointed out we already have:arch/sh/Makefile:
cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \
$(call cc-option,-m2a-nofpu,)so no kernel changes needed and gcc just needs to be reconfigured.