Encoding of V4 32-bit JA
Hi Yonghong.
This is from the v4 instructions proposal:
======== ===== ========================= ============
code value description notes
======== ===== ========================= ============
BPF_JA 0x00 PC += imm BPF_JMP32 onlyIs this instruction using source 1 instead of 0? Otherwise, it would have exactly the same encoding than the V3< JA instruction. Is that what is intended?
TIA.
Eduard Zingerman
maintainerQuoted 9 lines · Jose E. Marchesi
Hi Yonghong.
This is from the v4 instructions proposal:
======== ===== ========================= ============ code value description notes ======== ===== ========================= ============ BPF_JA 0x00 PC += imm BPF_JMP32 only
Quoted 6 lines
Is this instruction using source 1 instead of 0? Otherwise, it would have exactly the same encoding than the V3< JA instruction. Is that what is intended?
TIA.
Hi Jose,
I think that assumption is that BPF_JMP32 | BPF_JA is currently free:
- documentation [1] implies that only BPF_JMP should be used for BPF_JA (see "notes" column for the first line)
- BPF verifier rejects BPF_JMP32 | BPF_JA
- clang always generates BPF_JMP | BPF_JA
Thanks,
Eduard
[1] https://www.kernel.org/doc/html/latest/bpf/instruction-set.html#jump-instructions
Quoted 18 lines · Jose E. Marchesi
Quoted 9 lines
Hi Yonghong.
This is from the v4 instructions proposal:
======== ===== ========================= ============ code value description notes ======== ===== ========================= ============ BPF_JA 0x00 PC += imm BPF_JMP32 onlyQuoted 6 lines
Is this instruction using source 1 instead of 0? Otherwise, it would have exactly the same encoding than the V3< JA instruction. Is that what is intended?
TIA.
Quoted 7 lines
Hi Jose,
I think that assumption is that
BPF_JMP32 | BPF_JAis currently free:
- documentation [1] implies that onlyBPF_JMPshould be used forBPF_JA(see "notes" column for the first line)
- BPF verifier rejectsBPF_JMP32 | BPF_JA
- clang always generatesBPF_JMP | BPF_JA
Makes sense, thanks for the info.
Do you know the precise pseudo-c assembly syntax to use for this instruction?
Quoted 4 lines
Thanks,
Eduard[1] https://www.kernel.org/doc/html/latest/bpf/instruction-set.html#jump-instructions
Eduard Zingerman
maintainerQuoted 25 lines · Jose E. Marchesi
Quoted 17 lines · Jose E. Marchesi
Quoted 9 lines
Hi Yonghong.
This is from the v4 instructions proposal:
======== ===== ========================= ============ code value description notes ======== ===== ========================= ============ BPF_JA 0x00 PC += imm BPF_JMP32 onlyQuoted 6 lines
Is this instruction using source 1 instead of 0? Otherwise, it would have exactly the same encoding than the V3< JA instruction. Is that what is intended?
TIA.
Quoted 7 lines
Hi Jose,
I think that assumption is that
BPF_JMP32 | BPF_JAis currently free:
- documentation [1] implies that onlyBPF_JMPshould be used forBPF_JA(see "notes" column for the first line)
- BPF verifier rejectsBPF_JMP32 | BPF_JA
- clang always generatesBPF_JMP | BPF_JA
Quoted 4 lines
Makes sense, thanks for the info.
Do you know the precise pseudo-c assembly syntax to use for this instruction?
In [1] Yonghong uses the following form:
gotol +0xcd9b
But it seems to be not specified in the documentation for the patch-set v3.
[1] https://reviews.llvm.org/D144829
Quoted 5 lines
Quoted 5 lines
Thanks,
Eduard[1] https://www.kernel.org/doc/html/latest/bpf/instruction-set.html#jump-instructions
Quoted 29 lines · Jose E. Marchesi
Quoted 27 lines
Quoted 17 lines · Jose E. Marchesi
Quoted 9 lines
Hi Yonghong.
This is from the v4 instructions proposal:
======== ===== ========================= ============ code value description notes ======== ===== ========================= ============ BPF_JA 0x00 PC += imm BPF_JMP32 onlyQuoted 6 lines
Is this instruction using source 1 instead of 0? Otherwise, it would have exactly the same encoding than the V3< JA instruction. Is that what is intended?
TIA.
Quoted 7 lines
Hi Jose,
I think that assumption is that
BPF_JMP32 | BPF_JAis currently free:
- documentation [1] implies that onlyBPF_JMPshould be used forBPF_JA(see "notes" column for the first line)
- BPF verifier rejectsBPF_JMP32 | BPF_JA
- clang always generatesBPF_JMP | BPF_JAMakes sense, thanks for the info.
Quoted 8 lines
Quoted 2 lines
Do you know the precise pseudo-c assembly syntax to use for this instruction?
In [1] Yonghong uses the following form:
gotol +0xcd9b
But it seems to be not specified in the documentation for the patch-set v3.
I will use that syntax in binutils for now.
Quoted 7 lines
[1] https://reviews.llvm.org/D144829
Quoted 5 lines
Quoted 5 lines
Thanks,
Eduard[1] https://www.kernel.org/doc/html/latest/bpf/instruction-set.html#jump-instructions
Quoted 32 lines
Quoted 32 lines · Jose E. Marchesi
Quoted 29 lines
Quoted 17 lines · Jose E. Marchesi
Quoted 9 lines
Hi Yonghong.
This is from the v4 instructions proposal:
======== ===== ========================= ============ code value description notes ======== ===== ========================= ============ BPF_JA 0x00 PC += imm BPF_JMP32 onlyQuoted 6 lines
Is this instruction using source 1 instead of 0? Otherwise, it would have exactly the same encoding than the V3< JA instruction. Is that what is intended?
TIA.
Quoted 7 lines
Hi Jose,
I think that assumption is that
BPF_JMP32 | BPF_JAis currently free:
- documentation [1] implies that onlyBPF_JMPshould be used forBPF_JA(see "notes" column for the first line)
- BPF verifier rejectsBPF_JMP32 | BPF_JA
- clang always generatesBPF_JMP | BPF_JAMakes sense, thanks for the info.
Do you know the precise pseudo-c assembly syntax to use for this instruction?
Quoted 7 lines
Quoted 5 lines
In [1] Yonghong uses the following form:
gotol +0xcd9b
But it seems to be not specified in the documentation for the patch-set v3.
I will use that syntax in binutils for now.
https://sourceware.org/pipermail/binutils/2023-July/128543.html
Now we will make GCC to use that instruction whenever needed, but only with -mcpu=v4 or later:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110781
Quoted 7 lines
Quoted 7 lines
[1] https://reviews.llvm.org/D144829
Quoted 5 lines
Quoted 5 lines
Thanks,
Eduard[1] https://www.kernel.org/doc/html/latest/bpf/instruction-set.html#jump-instructions
Quoted 28 lines · Eduard Zingerman
Quoted 27 lines · Jose E. Marchesi
Quoted 17 lines · Jose E. Marchesi
Quoted 9 lines
Hi Yonghong.
This is from the v4 instructions proposal:
======== ===== ========================= ============ code value description notes ======== ===== ========================= ============ BPF_JA 0x00 PC += imm BPF_JMP32 onlyQuoted 6 lines
Is this instruction using source 1 instead of 0? Otherwise, it would have exactly the same encoding than the V3< JA instruction. Is that what is intended?
TIA.
Quoted 7 lines
Hi Jose,
I think that assumption is that
BPF_JMP32 | BPF_JAis currently free:
- documentation [1] implies that onlyBPF_JMPshould be used forBPF_JA(see "notes" column for the first line)
- BPF verifier rejectsBPF_JMP32 | BPF_JA
- clang always generatesBPF_JMP | BPF_JAMakes sense, thanks for the info.
Quoted 8 lines
Quoted 2 lines
Do you know the precise pseudo-c assembly syntax to use for this instruction?
In [1] Yonghong uses the following form:
gotol +0xcd9bBut it seems to be not specified in the documentation for the patch-set v3.
Thanks Eduard, I will add gotol to the documentation.
Quoted 9 lines
[1] https://reviews.llvm.org/D144829
Quoted 5 lines
Quoted 5 lines
Thanks,
Eduard[1] https://www.kernel.org/doc/html/latest/bpf/instruction-set.html#jump-instructions