On Wed, Nov 13, 2019 at 9:20 AM Ilya Leoshkevich <iii@xxxxxxxxxxxxx> wrote: > > Currently passing alignment greater than 4 to bpf_jit_binary_alloc does > not work: in such cases it aligns only to 4 bytes. > > However, this is required on s390, where 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 an arbitrary power-of-2 > alignment from bpf_jit_binary_alloc by allocating extra padding bytes > and aligning the resulting pointer rather than the start offset. > > An alternative would be to simply increase the alignment of > bpf_binary_header.image to 8, but this would increase the risk of > wasting a page on arches that don't need it, and would also be > insufficient in case someone needs e.g. 16-byte alignment in the > future. > > Signed-off-by: Ilya Leoshkevich <iii@xxxxxxxxxxxxx> Maybe we can just make it 8 byte aligned for all architectures? #define BPF_IMAGE_ALIGNMENT 8