Describe stack contents for function calls
Subsystems (2)
cover Describe stack contents for function calls
Although I am sure that it is patently obvious to those smarter than me, I thought it would make sense to add language to the ISA documentation about the contents of the stack, especially with respect to bpf-to-bpf calls.
I hope that this change is helpful.
Sincerely,
Will
Will Hawkins (1):
bpf, docs: Describe stack contents of function calls
Documentation/bpf/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)
Signature · 1 line
2.40.1
PATCH 1/1 bpf, docs: Describe stack contents of function calls
The execution of every function proceeds as if it has access to its own stack space.
--- Documentation/bpf/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/bpf/instruction-set.rst +5 -0
@@ -30,6 +30,11 @@ The eBPF calling convention is defined as: R0 - R5 are scratch registers and eBPF programs needs to spill/fill them if necessary across calls. +Every function invocation proceeds as if it has exclusive access to an +implementation-defined amount of stack space. R10 is a pointer to the byte of +memory with the highest address in that stack space. The contents +of a function invocation's stack space do not persist between invocations. + Instruction encoding ====================
Signature · 1 line
2.40.1
Re: [Bpf] [PATCH 1/1] bpf, docs: Describe stack contents of function calls
Quoted 14 lines · Will Hawkins
The execution of every function proceeds as if it has access to its own stack space.
Signed-off-by Will Hawkins <[email protected]>--- Documentation/bpf/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)Documentation/bpf/instruction-set.rst +0
-0
Documentation/bpf/instruction-set.rst The eBPF calling convention is defined as: · line 36
Quoted 7 lines
Documentation/bpf/instruction-set.rst +4
-0@@ -30,6 +30,11 @@ The eBPF calling convention is defined as: R0 - R5 are scratch registers and eBPF programs needs to spill/fill them if necessary across calls. +Every function invocation proceeds as if it has exclusive access to an +implementation-defined amount of stack space. R10 is a pointer to the byte of +memory with the highest address in that stack space. The contents +of a function invocation's stack space do not persist between invocations.
Such description belongs in a future psABI doc. instruction-set.rst is not a place to describe how registers are used. For example x86-64 JIT maps BPF R10 to RBP.
Yet there is -fomit-frame-pointer.
So we might very well do something like that in the future.
Re: [Bpf] [PATCH 1/1] bpf, docs: Describe stack contents of function calls
Quoted 19 lines · Alexei Starovoitov
Quoted 17 lines · Will Hawkins
The execution of every function proceeds as if it has access to its own stack space.
Signed-off-by Will Hawkins <[email protected]>--- Documentation/bpf/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)Documentation/bpf/instruction-set.rst +0
-0@@ -30,6 +30,11 @@ The eBPF calling convention is defined as: R0 - R5 are scratch registers and eBPF programs needs to spill/fill them if necessary across calls.
Quoted 7 lines
Documentation/bpf/instruction-set.rst The eBPF calling convention is defined as: · line 36
Quoted 4 lines
Documentation/bpf/instruction-set.rst +4
-0+Every function invocation proceeds as if it has exclusive access to an +implementation-defined amount of stack space. R10 is a pointer to the byte of +memory with the highest address in that stack space. The contents +of a function invocation's stack space do not persist between invocations.Such description belongs in a future psABI doc.
instruction-set.rstis not a place to describe how registers are used.
Thank you for the feedback!
How does your comment square with the immediately preceding description in the document that says:
R10: read-only frame pointer to access stack
(among the description of how other registers are used during function calls).
Sorry if I am being dense and/or naive.
Sincerely,
Will
Quoted 3 lines
For example x86-64 JIT maps BPF R10 to RBP.
Yet there is -fomit-frame-pointer.
So we might very well do something like that in the future.
Re: [Bpf] [PATCH 1/1] bpf, docs: Describe stack contents of function calls
Quoted 30 lines · Will Hawkins
Quoted 19 lines · Alexei Starovoitov
Quoted 17 lines · Will Hawkins
The execution of every function proceeds as if it has access to its own stack space.
Signed-off-by Will Hawkins <[email protected]>--- Documentation/bpf/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)Documentation/bpf/instruction-set.rst +0
-0@@ -30,6 +30,11 @@ The eBPF calling convention is defined as: R0 - R5 are scratch registers and eBPF programs needs to spill/fill them if necessary across calls.Quoted 7 lines
Documentation/bpf/instruction-set.rst The eBPF calling convention is defined as: · line 36
Quoted 4 lines
Documentation/bpf/instruction-set.rst +4
-0+Every function invocation proceeds as if it has exclusive access to an +implementation-defined amount of stack space. R10 is a pointer to the byte of +memory with the highest address in that stack space. The contents +of a function invocation's stack space do not persist between invocations.Such description belongs in a future psABI doc.
instruction-set.rstis not a place to describe how registers are used.
Quoted 8 lines
Thank you for the feedback!
How does your comment square with the immediately preceding description in the document that says:
R10: read-only frame pointer to access stack
(among the description of how other registers are used during function calls).
See
https://lore.kernel.org/bpf/CAADnVQ+gLnsOVj9s4zpAP6+U6nFHYm6GVZ1FteRac=ZaJvpfDg@mail.gmail.com/
tldr: it's a mess.
We should remove 'Registers and calling convention' section from instruction-set.rst
Re: [Bpf] [PATCH 1/1] bpf, docs: Describe stack contents of function calls
Quoted 39 lines · Alexei Starovoitov
Quoted 37 lines · Will Hawkins
Quoted 19 lines · Alexei Starovoitov
Quoted 17 lines · Will Hawkins
The execution of every function proceeds as if it has access to its own stack space.
Signed-off-by Will Hawkins <[email protected]>--- Documentation/bpf/instruction-set.rst | 5 +++++ 1 file changed, 5 insertions(+)Documentation/bpf/instruction-set.rst +0
-0@@ -30,6 +30,11 @@ The eBPF calling convention is defined as: R0 - R5 are scratch registers and eBPF programs needs to spill/fill them if necessary across calls.Quoted 7 lines
Documentation/bpf/instruction-set.rst The eBPF calling convention is defined as: · line 36
Quoted 4 lines
Documentation/bpf/instruction-set.rst +4
-0+Every function invocation proceeds as if it has exclusive access to an +implementation-defined amount of stack space. R10 is a pointer to the byte of +memory with the highest address in that stack space. The contents +of a function invocation's stack space do not persist between invocations.Such description belongs in a future psABI doc.
instruction-set.rstis not a place to describe how registers are used.Thank you for the feedback!
How does your comment square with the immediately preceding description in the document that says:
R10: read-only frame pointer to access stack
Quoted 8 lines
Quoted 1 line
(among the description of how other registers are used during function calls).
See
https://lore.kernel.org/bpf/CAADnVQ+gLnsOVj9s4zpAP6+U6nFHYm6GVZ1FteRac=ZaJvpfDg@mail.gmail.com/tldr: it's a mess.
We should remove 'Registers and calling convention' section frominstruction-set.rst
Understood. I am working closely (at least I would like to think that it's closely) with Dave and have been following that thread attentively. I will help with documentation and writing in whatever way I can.
Will