aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include/uapi/linux/bpf.h
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2018-12-01 00:08:14 -0500
committerAlexei Starovoitov <ast@kernel.org>2018-12-01 00:38:48 -0500
commite9ee9efc0d176512cdce9d27ff8549d7ffa2bfcd (patch)
tree94b32bfcaa32c3538810330370ed7cd4b07e15e4 /tools/include/uapi/linux/bpf.h
parent88945f460603ad8909b556c67a9229bb23188d41 (diff)
bpf: Add BPF_F_ANY_ALIGNMENT.
Often we want to write tests cases that check things like bad context offset accesses. And one way to do this is to use an odd offset on, for example, a 32-bit load. This unfortunately triggers the alignment checks first on platforms that do not set CONFIG_EFFICIENT_UNALIGNED_ACCESS. So the test case see the alignment failure rather than what it was testing for. It is often not completely possible to respect the original intention of the test, or even test the same exact thing, while solving the alignment issue. Another option could have been to check the alignment after the context and other validations are performed by the verifier, but that is a non-trivial change to the verifier. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/include/uapi/linux/bpf.h')
-rw-r--r--tools/include/uapi/linux/bpf.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 597afdbc1ab9..8050caea7495 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -232,6 +232,20 @@ enum bpf_attach_type {
232 */ 232 */
233#define BPF_F_STRICT_ALIGNMENT (1U << 0) 233#define BPF_F_STRICT_ALIGNMENT (1U << 0)
234 234
235/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the
236 * verifier will allow any alignment whatsoever. On platforms
237 * with strict alignment requirements for loads ands stores (such
238 * as sparc and mips) the verifier validates that all loads and
239 * stores provably follow this requirement. This flag turns that
240 * checking and enforcement off.
241 *
242 * It is mostly used for testing when we want to validate the
243 * context and memory access aspects of the verifier, but because
244 * of an unaligned access the alignment check would trigger before
245 * the one we are interested in.
246 */
247#define BPF_F_ANY_ALIGNMENT (1U << 1)
248
235/* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */ 249/* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */
236#define BPF_PSEUDO_MAP_FD 1 250#define BPF_PSEUDO_MAP_FD 1
237 251