Bcc: Compiling and loading eBPF programs not possible after LLVM /clang upgrade

Created on 10 Apr 2018  Â·  2Comments  Â·  Source: iovisor/bcc

Hi,

until a few days ago everything on my system was working. Now I cannot load eBPF programs anymore because I get the error message below. I updates the following things:

  • kernel upgrade (but with my old kernel, 4.16.0-rc4+ it does not work either now),
  • NIC driver (which is not involved up to this point)
  • probably clang / LLVM by entering "apt get update" and "apt get upgrade"

bcc version: (0.5.0-300.git.5d23500)
Linux kernel: 4.16.0+
OS: Ubuntu 17.10
clang version 7.0.0- (trunk)

In file included from /virtual/main.c:2:
In file included from /lib/modules/4.16.0+/build/include/linux/blkdev.h:5:
In file included from /lib/modules/4.16.0+/build/include/linux/sched.h:14:
In file included from /lib/modules/4.16.0+/build/include/linux/pid.h:5:
In file included from /lib/modules/4.16.0+/build/include/linux/rculist.h:11:
In file included from /lib/modules/4.16.0+/build/include/linux/rcupdate.h:40:
In file included from /lib/modules/4.16.0+/build/include/linux/preempt.h:81:
In file included from /lib/modules/4.16.0+/build/arch/x86/include/asm/preempt.h:7:
In file included from /lib/modules/4.16.0+/build/include/linux/thread_info.h:38:
In file included from /lib/modules/4.16.0+/build/arch/x86/include/asm/thread_info.h:53:
/lib/modules/4.16.0+/build/arch/x86/include/asm/cpufeature.h:150:2: error: expected '(' after 'asm'
asm_volatile_goto("1: jmp 6fn"
^
/lib/modules/4.16.0+/build/include/linux/compiler-gcc.h:296:42: note: expanded from macro 'asm_volatile_goto'

define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)

                                     ^

1 error generated.

Most helpful comment

This is a known issue for latest linux. The reason is that
clang does not support asm goto.

It is introduced by the following commit:
commit d0266046ad54e0c964941364cd82a0d0478ce286
Author: Peter Zijlstra peterz@infradead.org
Date: Mon Mar 19 16:41:26 2018 +0100

x86: Remove FAST_FEATURE_TESTS

Since we want to rely on static branches to avoid speculation, remove
any possible fallback code for static_cpu_has.

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]

You can use the following workaround:
diff --git a/arch/x86/include/asm/cpufeature.h
b/arch/x86/include/asm/cpufeature.h
index b27da96..71e02c4 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -140,6 +140,7 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c,
unsigned int bit);

#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)

+#if 0
/*

  • Static testing of CPU features. Used the same as boot_cpu_has().
  • These will statically patch the target code for additional
    @@ -195,6 +196,9 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
    boot_cpu_has(bit) :
    _static_cpu_has(bit)
    )
    +#else
    +#define static_cpu_has(bit) boot_cpu_has(bit)
    +#endif

#define cpu_has_bug(c, bit) cpu_has(c, (bit))
#define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))

I will dig into a little more here to see what we can do.

On Tue, Apr 10, 2018 at 5:34 AM, computer5student
notifications@github.com wrote:

Hi,

until a few days ago everything on my system was working. Now I cannot load
eBPF programs anymore because I get the error message below. I updates the
following things:

kernel upgrade (but with my old kernel, 4.16.0-rc4+ it does not work either
now),
NIC driver (which is not involved up to this point)
probably clang / LLVM by entering "apt get update" and "apt get upgrade"

bcc version: (0.5.0-300.git.5d23500)
Linux kernel: 4.16.0+
OS: Ubuntu 17.10
clang version 7.0.0- (trunk)

In file included from /virtual/main.c:2:
In file included from /lib/modules/4.16.0+/build/include/linux/blkdev.h:5:
In file included from /lib/modules/4.16.0+/build/include/linux/sched.h:14:
In file included from /lib/modules/4.16.0+/build/include/linux/pid.h:5:
In file included from /lib/modules/4.16.0+/build/include/linux/rculist.h:11:
In file included from
/lib/modules/4.16.0+/build/include/linux/rcupdate.h:40:
In file included from /lib/modules/4.16.0+/build/include/linux/preempt.h:81:
In file included from
/lib/modules/4.16.0+/build/arch/x86/include/asm/preempt.h:7:
In file included from
/lib/modules/4.16.0+/build/include/linux/thread_info.h:38:
In file included from
/lib/modules/4.16.0+/build/arch/x86/include/asm/thread_info.h:53:
/lib/modules/4.16.0+/build/arch/x86/include/asm/cpufeature.h:150:2: error:
expected '(' after 'asm'
asm_volatile_goto("1: jmp 6fn"
^
/lib/modules/4.16.0+/build/include/linux/compiler-gcc.h:296:42: note:
expanded from macro 'asm_volatile_goto'

define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)

^
1 error generated.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

All 2 comments

This is a known issue for latest linux. The reason is that
clang does not support asm goto.

It is introduced by the following commit:
commit d0266046ad54e0c964941364cd82a0d0478ce286
Author: Peter Zijlstra peterz@infradead.org
Date: Mon Mar 19 16:41:26 2018 +0100

x86: Remove FAST_FEATURE_TESTS

Since we want to rely on static branches to avoid speculation, remove
any possible fallback code for static_cpu_has.

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]

You can use the following workaround:
diff --git a/arch/x86/include/asm/cpufeature.h
b/arch/x86/include/asm/cpufeature.h
index b27da96..71e02c4 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -140,6 +140,7 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c,
unsigned int bit);

#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)

+#if 0
/*

  • Static testing of CPU features. Used the same as boot_cpu_has().
  • These will statically patch the target code for additional
    @@ -195,6 +196,9 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
    boot_cpu_has(bit) :
    _static_cpu_has(bit)
    )
    +#else
    +#define static_cpu_has(bit) boot_cpu_has(bit)
    +#endif

#define cpu_has_bug(c, bit) cpu_has(c, (bit))
#define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))

I will dig into a little more here to see what we can do.

On Tue, Apr 10, 2018 at 5:34 AM, computer5student
notifications@github.com wrote:

Hi,

until a few days ago everything on my system was working. Now I cannot load
eBPF programs anymore because I get the error message below. I updates the
following things:

kernel upgrade (but with my old kernel, 4.16.0-rc4+ it does not work either
now),
NIC driver (which is not involved up to this point)
probably clang / LLVM by entering "apt get update" and "apt get upgrade"

bcc version: (0.5.0-300.git.5d23500)
Linux kernel: 4.16.0+
OS: Ubuntu 17.10
clang version 7.0.0- (trunk)

In file included from /virtual/main.c:2:
In file included from /lib/modules/4.16.0+/build/include/linux/blkdev.h:5:
In file included from /lib/modules/4.16.0+/build/include/linux/sched.h:14:
In file included from /lib/modules/4.16.0+/build/include/linux/pid.h:5:
In file included from /lib/modules/4.16.0+/build/include/linux/rculist.h:11:
In file included from
/lib/modules/4.16.0+/build/include/linux/rcupdate.h:40:
In file included from /lib/modules/4.16.0+/build/include/linux/preempt.h:81:
In file included from
/lib/modules/4.16.0+/build/arch/x86/include/asm/preempt.h:7:
In file included from
/lib/modules/4.16.0+/build/include/linux/thread_info.h:38:
In file included from
/lib/modules/4.16.0+/build/arch/x86/include/asm/thread_info.h:53:
/lib/modules/4.16.0+/build/arch/x86/include/asm/cpufeature.h:150:2: error:
expected '(' after 'asm'
asm_volatile_goto("1: jmp 6fn"
^
/lib/modules/4.16.0+/build/include/linux/compiler-gcc.h:296:42: note:
expanded from macro 'asm_volatile_goto'

define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)

^
1 error generated.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Thank you very much, that indeed fixes the problem.

Was this page helpful?
0 / 5 - 0 ratings