Skip to contentSkip to conversation

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

PATCH Superseded Dave Thaler 2 participants 2 messages Apr 26, 2024

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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

---
 Documentation/bpf/standardization/instruction-set.rst | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/bpf/standardization/instruction-set.rst +6 -0
index b44bdacd0..766f57636 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 and fails verification 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
#1 lore raw
Quoted 16 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

---
 Documentation/bpf/standardization/instruction-set.rst | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/bpf/standardization/instruction-set.rst +0 -0
index b44bdacd0..766f57636 100644

Documentation/bpf/standardization/instruction-set.rst JSLT 0xc any PC += offset if dst < src signed · line 476

Quoted 8 lines
Documentation/bpf/standardization/instruction-set.rst +5 -0
@@ -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 and fails verification if the
+next instruction is a 128-bit wide instruction.

Should we say "results in undefined behavior" rather than "fails verification"? I'm not sure if we should be dictating verifier semantics in the ISA document.

Quoted 11 lines
Documentation/bpf/standardization/instruction-set.rst +1 -0
+
 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