On 1/16/24 5:56 PM, dthaler1968@xxxxxxxxxxxxxx wrote:
Yonghong Song <yonghong.song@xxxxxxxxx> wrote:
Is there any semantic difference between the following two instructions?
{.opcode = BPF_ALU64 | BPF_MOV | BPF_K, .offset = 0, .imm = -1}
This is supported. Sign extension of -1 will be put into ALU64 reg.
{.opcode = BPF_ALU64 | BPF_MOVSX | BPF_K, .offset = 32, .imm = -1}
This is not supported. BPF_MOVSX only supports register extension.
We should make it clear in the doc.
Is that limitation a Linux-specific implementation statement? (i.e., put into
linux-notes.txt)
Or that the meaning is undefined for all runtimes and could be used
for some other purpose in the future? (i.e., put into instruction-set.rst)
For now I'll interpret it as the latter.
You are right. The
{.opcode = BPF_ALU64 | BPF_MOVSX | BPF_K, .offset = 32, .imm = -1}
is not supported by bpf ISA. Currently, it will be an illegal encoding
from kernel perspective.