* remaining sparc bpf hacks...
@ 2017-05-02 16:04 David Miller
0 siblings, 0 replies; only message in thread
From: David Miller @ 2017-05-02 16:04 UTC (permalink / raw)
To: ast; +Cc: daniel, netdev
So I just have two issues remaining for test_progs to run properly
on sparc. We've discussed them before.
The first is the clang Makefile hack:
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index d8d94b9..2ed63b6 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -35,5 +35,5 @@ CLANG ?= clang
%.o: %.c
$(CLANG) -I../../../include/uapi -I../../../../samples/bpf/ \
- -D__x86_64__ -Wno-compare-distinct-pointer-types \
+ -D__sparc__ -Wno-compare-distinct-pointer-types \
-O2 -target bpf -c $< -o $@
which should be reasonably easy to deal with.
The second is more difficult:
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index c2ff608..bb99677 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -801,8 +801,12 @@ static int check_ptr_alignment(const struct bpf_reg_state *reg,
{
switch (reg->type) {
case PTR_TO_PACKET:
+#if 1
+ return 0;
+#else
return IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ? 0 :
check_pkt_ptr_alignment(reg, off, size);
+#endif
case PTR_TO_MAP_VALUE_ADJ:
return IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ? 0 :
check_val_ptr_alignment(reg, size);
Studying over the verifier yesterday I figure we can add an
"alignment" attribute to registers, and track this.
The packet pointer entering a function starts with a weird "modulo
NET_IP_ALIGN" relative alignment, so we have to take that into
consideration.
Then for operations like shift left and multiply by constants, we can
record a known minimum alignment. The most common case is, of course,
"iph->ihl << 2"
And later when registers with known alignment are added to a packet
pointer, we can constrain the alignment of the destination register.
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-02 16:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-02 16:04 remaining sparc bpf hacks David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).