Bug 1618958 - clang -target bpf generates unknown opcode 8d
Summary: clang -target bpf generates unknown opcode 8d
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: clang
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tom Stellard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-08-18 20:00 UTC by Stanislav Kozina
Modified: 2018-09-26 17:09 UTC (History)
6 users (show)

Fixed In Version: llvm-7.0.0-0.13.rc3.fc30
Clone Of:
Environment:
Last Closed: 2018-09-26 17:09:39 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Testing source code file (2.74 KB, text/x-csrc)
2018-08-18 20:00 UTC, Stanislav Kozina
no flags Details


Links
System ID Private Priority Status Summary Last Updated
LLVM 38643 0 P RESOLVED BPF: Assertion faliure at BPFAsmBackend.cpp:73: Assertion `Value == 0' failed 2021-01-25 09:50:10 UTC

Description Stanislav Kozina 2018-08-18 20:00:17 UTC
Created attachment 1476812 [details]
Testing source code file

Description of problem:

clang -target bpf generates unknown opcode 8d.
It doesn't generate this opcode when run with -O2.

Version-Release number of selected component (if applicable):

clang-6.0.1-1.fc28.x86_64
kernel-4.16.12-300.fc28.x86_64

How reproducible: 100%

Steps to reproduce:

Compile attached C source code file using:
$ clang -target bpf -c -o kprobes_kern.o kprobes_kern.c

Then use bpf_load.c from Linux source code tree to load it. BPF in-kernel verifier declines to load this file with following error:

# ./kprobes 
bpf_load_program() err=Invalid argument
unknown opcode 8d
unknown opcode 8d

This problem goes away when the same code is compiled with -O2.

Comment 1 Tom Stellard 2018-08-28 18:12:48 UTC
Upstream has fixed this by emitting an error message rather than producing illegal code.  The backend can't always handle the LLVM IR produced at -O0, so don't expect -O0 to work and use -O2 instead.

Comment 2 Tom Stellard 2018-09-26 17:09:39 UTC
Fixed in rawhide by llvm-7.0.0-0.13.rc3.fc30.


Note You need to log in before you can comment on or make changes to this bug.