yonghong-song
2f1e6eb6c3
[BPF] Report an warning if certain insn imm operand cannot fit in 32bit ( #142989 )
...
Ihor Solodrai reported a case ([1]) where gcc reports an error but clang
ignores that error and proceeds to generate incorrect code. More
specifically, the problematic code looks like:
if r1 == 0xcafefeeddeadbeef goto <label>
Here, 0xcafefeeddeadbeef needs to be encoded in a 32-bit imm field
of the insns and the 32-bit imm allows sign extenstion to 64-bit imm.
Obviously, 0xcafefeeddeadbeef cannot encode properly.
The compilation failed for gcc with the following error:
Error: immediate out of range, shall fit in 32 bits
Given a 64-bit imm value, converting to the proper 32-bit imm value
must satisfy the following 64-bit patterns:
00000000 00000000 00000000 00000000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
11111111 11111111 11111111 11111111 1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
So if the top 32-bits is 0 or the top 33-bits is 0x1ffffffff, then the 64-bit imm
value can be truncated into proper 32-bit imm. Otherwise, a warning
message, the same as gcc, will be issued. If -Werror is enabled during
compilation, the warning will turn into an error.
[1] https://lore.kernel.org/bpf/70affb12-327b-4882-bd1d-afda8b8c6f56@linux.dev/
2025-06-13 11:58:48 -07:00
..
2025-05-28 14:36:10 -07:00
2025-03-11 11:23:53 -07:00
2025-01-29 16:56:47 +01:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-12-15 11:04:24 -08:00
2025-03-04 09:19:39 -08:00
2025-03-04 09:19:39 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2025-02-05 23:29:02 +07:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2025-01-29 16:56:47 +01:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2025-01-28 15:19:05 -08:00
2025-01-28 15:19:05 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-10-18 09:35:42 +04:00
2024-12-15 11:04:24 -08:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-09-03 07:15:18 -07:00
2024-09-03 07:15:18 -07:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-09-03 07:15:18 -07:00
2024-10-01 14:20:54 -07:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-10-01 14:20:54 -07:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2025-06-13 11:58:48 -07:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00
2024-12-15 11:04:24 -08:00