bpf, docs: Clarify PC use in instruction-set.rst
Subsystems (3)
PATCH 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.
--- Documentation/bpf/standardization/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/bpf/standardization/instruction-set.rst +5 -0
@@ -469,6 +469,11 @@ 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' results in the next instruction +to execute being two 64-bit instructions later. + The BPF program needs to store the return value into register R0 before doing an ``EXIT``.
Signature · 1 line
2.40.1
Quoted 15 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.
Signed-off-by Dave Thaler <[email protected]>--- Documentation/bpf/standardization/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)Documentation/bpf/standardization/instruction-set.rst +0
-0
Documentation/bpf/standardization/instruction-set.rst JSLT 0xc any PC += offset if dst < src signed · line 475
Quoted 7 lines
Documentation/bpf/standardization/instruction-set.rst +4
-0@@ -469,6 +469,11 @@ 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' results in the next instruction +to execute being two 64-bit instructions later.
The last part is confusing.
"two 64-bit instructions later"
I'm struggling to understand that.
Maybe say that 'PC += 1' skips execution of the next insn?
Quoted 31 lines
-----Original Message-----
From: Alexei Starovoitov <[email protected]>
Sent: Friday, April 26, 2024 12:22 PM
To: Dave Thaler <[email protected]>
Cc: bpf <[email protected]>; [email protected]; Dave Thaler <[email protected]>
Subject: Re: [PATCH bpf-next] bpf, docs: Clarify PC use ininstruction-set.rstDocumentation/bpf/standardization/instruction-set.rst JSLT 0xc any PC += offset if dst < src
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.
Signed-off-by Dave Thaler <[email protected]>--- Documentation/bpf/standardization/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)Documentation/bpf/standardization/instruction-set.rst +0
-0@@ -469,6 +469,11 @@ JSLT 0xc any PC += offset if dst < srcsigned
Quoted 4 lines
Documentation/bpf/standardization/instruction-set.rst +0
-0JSLE 0xd any PC += offset if dst <= src signed ======== ===== ======= ====================================================================================
Quoted 9 lines
Documentation/bpf/standardization/instruction-set.rst
Quoted 4 lines
Documentation/bpf/standardization/instruction-set.rst +4
-0+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' results in the next +instruction to execute being two 64-bit instructions later.The last part is confusing.
"two 64-bit instructions later"
I'm struggling to understand that.
Maybe say that 'PC += 1' skips execution of the next insn?
If the next instruction is a 64-bit immediate instruction that spans 128 bits, do you need PC += 1 or PC += 2 to skip it? I assumed you'd need PC += 2, in which case "PC += 1" would not skip execution of "the next instruction" but would try to jump into mid instruction, and fail verification.
Hence my attempt at "64-bit instruction" wording.
Alternate wording suggestions welcome.
Dave
Quoted 42 lines · On Fri, Apr 26, 2024 at 12:30 PM <[email protected]> wrote:
Quoted 32 lines
-----Original Message-----
From: Alexei Starovoitov <[email protected]>
Sent: Friday, April 26, 2024 12:22 PM
To: Dave Thaler <[email protected]>
Cc: bpf <[email protected]>; [email protected]; Dave Thaler <[email protected]>
Subject: Re: [PATCH bpf-next] bpf, docs: Clarify PC use ininstruction-set.rstDocumentation/bpf/standardization/instruction-set.rst JSLT 0xc any PC += offset if dst < src
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.
Signed-off-by Dave Thaler <[email protected]>--- Documentation/bpf/standardization/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)Documentation/bpf/standardization/instruction-set.rst +0
-0@@ -469,6 +469,11 @@ JSLT 0xc any PC += offset if dst < srcsigned
Quoted 4 lines
Documentation/bpf/standardization/instruction-set.rst +0
-0JSLE 0xd any PC += offset if dst <= src signed ======== ===== ======= ====================================================================================
Quoted 9 lines
Documentation/bpf/standardization/instruction-set.rst
Quoted 4 lines
Documentation/bpf/standardization/instruction-set.rst +4
-0+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' results in the next +instruction to execute being two 64-bit instructions later.The last part is confusing.
"two 64-bit instructions later"
I'm struggling to understand that.
Maybe say that 'PC += 1' skips execution of the next insn?
Quoted 5 lines
If the next instruction is a 64-bit immediate instruction that spans 128 bits, do you need PC += 1 or PC += 2 to skip it? I assumed you'd need PC += 2, in which case "PC += 1" would not skip execution of "the next instruction" but would try to jump into mid instruction, and fail verification.
Correct.
Quoted 3 lines
Hence my attempt at "64-bit instruction" wording.
Alternate wording suggestions welcome.
This "jump in the middle" issue is not obvious at all from "two 64-bit instructions" part.
Say that PC +=1 skips execution of the next insn if it's a 64-bit insn and fails verification if the next insn is 128-bit.