Skip to contentSkip to conversation

Encoding of V4 32-bit JA

DISCUSSION Jose E. Marchesi 3 participants 7 messages Jul 21, 2023 – Jul 24, 2023 BPF

lore
Share & tools
lore
#0 lore raw

Hi Yonghong.

This is from the v4 instructions proposal:

    ========  =====  =========================  ============
    code      value  description                notes
    ========  =====  =========================  ============
    BPF_JA    0x00   PC += imm                  BPF_JMP32 only

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.

maintainer
#1 lore raw
Quoted 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

#2 lore raw
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 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.

Quoted 7 lines

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

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

maintainer
#3 lore raw
Quoted 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 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.

Quoted 7 lines

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

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

#4 lore raw
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 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.

Quoted 7 lines

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

Makes 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

#5 lore raw
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 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.

Quoted 7 lines

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

Makes 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

#6 lore raw
In reply to Eduard Zingerman
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 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.

Quoted 7 lines

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

Makes 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.

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