Skip to contentSkip to conversation

bpf, docs: Clarify PC use in instruction-set.rst

PATCH Applied Dave Thaler 3 participants 3 messages Apr 27, 2024 – Apr 29, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 bpf, docs: Clarify PC use in instruction-set.rst

This patch elaborates on the use of PC by expanding the PC acronym, explaining the units, and the relative position to which the offset applies.

v1->v2: reword per feedback from Alexei

v2->v3: reword per feedback from David Vernet

---
 Documentation/bpf/standardization/instruction-set.rst | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/bpf/standardization/instruction-set.rst +6 -0
index b44bdacd0..997560aba 100644
@@ -469,6 +469,12 @@ JSLT      0xc    any      PC += offset if dst < src          signed
 JSLE      0xd    any      PC += offset if dst <= src         signed
 ========  =====  =======  =================================  ===================================================
 
+where 'PC' denotes the program counter, and the offset to increment by
+is in units of 64-bit instructions relative to the instruction following
+the jump instruction.  Thus 'PC += 1' skips execution of the next
+instruction if it's a basic instruction or results in undefined behavior
+if the next instruction is a 128-bit wide instruction.
+
 The BPF program needs to store the return value into register R0 before doing an
 ``EXIT``.
 
Signature · 1 line
2.40.1
reviewer Reviewed-by on v3 1/1
#1 lore raw
Quoted 9 lines · Dave Thaler

This patch elaborates on the use of PC by expanding the PC acronym, explaining the units, and the relative position to which the offset applies.

v1->v2: reword per feedback from Alexei

v2->v3: reword per feedback from David Vernet

Quoted 28 lines
---
 Documentation/bpf/standardization/instruction-set.rst | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/bpf/standardization/instruction-set.rst +6 -0
index b44bdacd0..997560aba 100644
@@ -469,6 +469,12 @@ JSLT      0xc    any      PC += offset if dst < src          signed
 JSLE      0xd    any      PC += offset if dst <= src         signed
 ========  =====  =======  =================================  ===================================================
 
+where 'PC' denotes the program counter, and the offset to increment by
+is in units of 64-bit instructions relative to the instruction following
+the jump instruction.  Thus 'PC += 1' skips execution of the next
+instruction if it's a basic instruction or results in undefined behavior
+if the next instruction is a 128-bit wide instruction.
+
 The BPF program needs to store the return value into register R0 before doing an
 ``EXIT``.
 
Signature · 6 lines
2.40.1

-- 
Bpf mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/bpf
#2 lore raw
In reply to Dave Thaler
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Quoted 9 lines · On Fri, 26 Apr 2024 16:11:26 -0700 you wrote:

This patch elaborates on the use of PC by expanding the PC acronym, explaining the units, and the relative position to which the offset applies.

v1->v2: reword per feedback from Alexei

v2->v3: reword per feedback from David Vernet

[...]

Here is the summary with links:
- [bpf-next,v3] bpf, docs: Clarify PC use in instruction-set.rst

    https://git.kernel.org/bpf/bpf-next/c/07801a24e2f1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html