Re: [RFC PATCH v3 16/37] bpf tools: Collect eBPF programs from their own sections

Alexei Starovoitov
2015-05-18T18:32:13Z

On 5/18/15 5:47 AM, Wangnan (F) wrote:
>
>
>>> + prog->insns_cnt = size / sizeof(struct bpf_insn);
>>> + memcpy(prog->insns, data,
>>> + prog->insns_cnt * sizeof(struct bpf_insn));
>> Doesn't the data need to be swapped?
>>
>> Thanks,
>> Namhyung
>>
>
> I'm not very sure, since they are instructions. Byte order of
> instructions and byte order of data
> are not always same. Think about ARM. Therefore another choice is to
> swap them in kernel,
> keep user-kernel interface clean.
>
> Alexei Starovoitov, do you think we should use uniformed instruction
> byte order in both big and little
> endian kernel on user-kernel interface, or let userspace feed swapped
> instructions to kernel if
> endianess is not match?

see my reply to the other patch. endianness is the job of llvm.
Let's fix it there.