History

bpf: Support doubleword alignment in bpf_jit_binary_alloc

Currently passing alignment greater than 4 to bpf_jit_binary_alloc does not work: in such cases it silently aligns only to 4 bytes. On s390, in order to load a constant from memory in a large (>512k) BPF program, one must use lgrl instruction, whose memory operand must be aligned on an 8-byte boundary. This patch makes it possible to request 8-byte alignment from bpf_jit_binary_alloc, and also makes it issue a warning when an unsupported alignment is requested.

Ilya Leoshkevich committed 7 years ago

Commit b7b3fc81 parent e47a1792 files · +8 −2Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/filter.h+4−2
@@ -515,10 +515,12 @@ struct sock_fprog_kern { · 514 unmodified lines
515515 struct sock_filter *filter;
516516 };
517517
518+/* Some arches need doubleword alignment for their instructions and/or data */
519+#define BPF_IMAGE_ALIGNMENT 8
520+
518521 struct bpf_binary_header {
519522 u32 pages;
520− /* Some arches need word alignment for their instructions */
521− u8 image[] __aligned(4);
523+ u8 image[] __aligned(BPF_IMAGE_ALIGNMENT);
522524 };
523525
524526 struct bpf_prog {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t