llvm-project/llvm/test
Alexei Starovoitov 56db145164 [bpf] Fix memory offset check for loads and stores
If the offset cannot fit into the instruction, an addition to the
pointer is emitted before the actual access. However, BPF offsets are
16-bit but LLVM considers them to be, for the matter of this check,
to be 32-bit long.

This causes the following program:

int bpf_prog1(void *ign)
{

volatile unsigned long t = 0x8983984739ull;
return *(unsigned long *)((0xffffffff8fff0002ull) + t);

}

To generate the following (wrong) code:

0: 18 01 00 00 39 47 98 83 00 00 00 00 89 00 00 00

r1 = 590618314553ll

2: 7b 1a f8 ff 00 00 00 00 *(u64 *)(r10 - 8) = r1
3: 79 a1 f8 ff 00 00 00 00 r1 = *(u64 *)(r10 - 8)
4: 79 10 02 00 00 00 00 00 r0 = *(u64 *)(r1 + 2)
5: 95 00 00 00 00 00 00 00 exit

Fix it by changing the offset check to 16-bit.

Patch by Nadav Amit <nadav.amit@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Differential Revision: https://reviews.llvm.org/D32055

llvm-svn: 300269
2017-04-13 22:24:13 +00:00
..
Analysis [Analysis] Support bitreverse in -demanded-bits pass 2017-04-13 16:44:25 +00:00
Assembler Allow DataLayout to specify addrspace for allocas. 2017-04-10 22:27:50 +00:00
Bindings
Bitcode Bitcode: Do not create FNENTRYs for aliases of functions. 2017-04-06 19:39:24 +00:00
BugPoint llvm/test/BugPoint/compile-custom.ll: Use %/s for its path not to be mis-escaped. 2017-04-13 11:40:32 +00:00
CodeGen [bpf] Fix memory offset check for loads and stores 2017-04-13 22:24:13 +00:00
DebugInfo [llvm-pdbdump] More advanced class definition dumping. 2017-04-12 23:18:21 +00:00
Examples
ExecutionEngine
Feature [GVNHoist] Re-enable GVNHoist by default 2017-04-11 14:36:30 +00:00
FileCheck [FileCheck] Added --enable-var-scope option to enable scope for regex variables. 2017-03-09 17:59:04 +00:00
Instrumentation [asan] Give global metadata private linkage. 2017-04-11 22:28:13 +00:00
Integer
JitListener
LTO LTO: Pass SF_Executable flag through to InputFile::Symbol 2017-04-13 16:24:14 +00:00
LibDriver
Linker [Linker] Provide callback for internalization 2017-03-13 18:08:11 +00:00
MC [AMDGPU][MC] Added support for several VI-specific opcodes (s_wakeup, etc) 2017-04-12 17:10:07 +00:00
Object [llvm-ar] errors go on stderr and not on stdout. 2017-04-05 14:52:17 +00:00
ObjectYAML Align all scalar numbers to LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR 2017-04-04 06:02:32 +00:00
Other Remove readnone from invariant.group.barrier 2017-04-12 20:45:12 +00:00
SymbolRewriter
TableGen [globalisel][tablegen] Add experimental support for OperandWithDefaultOps, PredicateOperand, and OptionalDefOperand 2017-04-12 08:23:08 +00:00
ThinLTO/X86 llvm-lto2: Move the LTO::run() action behind a subcommand. 2017-04-11 18:12:00 +00:00
Transforms Revert accidentally-committed files in r300252. 2017-04-13 20:31:21 +00:00
Unit
Verifier Verifier: Check some amdgpu calling convention restrictions 2017-04-04 18:43:11 +00:00
YAMLParser
tools [llvm-pdbdump] Recursively dump class layout. 2017-04-13 21:11:00 +00:00
.clang-format
CMakeLists.txt
TestRunner.sh
lit.cfg
lit.site.cfg.in