linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] bpf, docs: Correct the example of BPF_XOR
@ 2022-11-29 13:45 Zheng Yejian
  2022-11-29 18:54 ` David Vernet
  2022-12-02 21:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Zheng Yejian @ 2022-11-29 13:45 UTC (permalink / raw)
  To: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, corbet, bpf, linux-doc, linux-kernel
  Cc: zhengyejian1

Refer to description of BPF_XOR, dst_reg should be used but not src_reg
in the examples.

Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
---
 Documentation/bpf/instruction-set.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/bpf/instruction-set.rst b/Documentation/bpf/instruction-set.rst
index 5d798437dad4..e672d5ec6cc7 100644
--- a/Documentation/bpf/instruction-set.rst
+++ b/Documentation/bpf/instruction-set.rst
@@ -122,11 +122,11 @@ BPF_END   0xd0   byte swap operations (see `Byte swap instructions`_ below)
 
 ``BPF_XOR | BPF_K | BPF_ALU`` means::
 
-  src_reg = (u32) src_reg ^ (u32) imm32
+  dst_reg = (u32) dst_reg ^ (u32) imm32
 
 ``BPF_XOR | BPF_K | BPF_ALU64`` means::
 
-  src_reg = src_reg ^ imm32
+  dst_reg = dst_reg ^ imm32
 
 
 Byte swap instructions
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] bpf, docs: Correct the example of BPF_XOR
  2022-11-29 13:45 [PATCH bpf] bpf, docs: Correct the example of BPF_XOR Zheng Yejian
@ 2022-11-29 18:54 ` David Vernet
  2022-11-30  1:17   ` Zheng Yejian
  2022-12-02 21:30 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: David Vernet @ 2022-11-29 18:54 UTC (permalink / raw)
  To: Zheng Yejian
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, corbet, bpf, linux-doc, linux-kernel

On Tue, Nov 29, 2022 at 09:45:58PM +0800, Zheng Yejian wrote:
> Refer to description of BPF_XOR, dst_reg should be used but not src_reg
> in the examples.
> 
> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
> ---
>  Documentation/bpf/instruction-set.rst | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/bpf/instruction-set.rst b/Documentation/bpf/instruction-set.rst
> index 5d798437dad4..e672d5ec6cc7 100644
> --- a/Documentation/bpf/instruction-set.rst
> +++ b/Documentation/bpf/instruction-set.rst
> @@ -122,11 +122,11 @@ BPF_END   0xd0   byte swap operations (see `Byte swap instructions`_ below)
>  
>  ``BPF_XOR | BPF_K | BPF_ALU`` means::
>  
> -  src_reg = (u32) src_reg ^ (u32) imm32
> +  dst_reg = (u32) dst_reg ^ (u32) imm32

Shouldn't this be 

dst_reg = (u32) dst_reg ^ (u32) src_reg

Same idea below for 64 bit

>  
>  ``BPF_XOR | BPF_K | BPF_ALU64`` means::
>  
> -  src_reg = src_reg ^ imm32
> +  dst_reg = dst_reg ^ imm32
>  
>  
>  Byte swap instructions
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] bpf, docs: Correct the example of BPF_XOR
  2022-11-29 18:54 ` David Vernet
@ 2022-11-30  1:17   ` Zheng Yejian
  0 siblings, 0 replies; 4+ messages in thread
From: Zheng Yejian @ 2022-11-30  1:17 UTC (permalink / raw)
  To: David Vernet
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, corbet, bpf, linux-doc, linux-kernel

On 2022/11/30 02:54, David Vernet wrote:
> On Tue, Nov 29, 2022 at 09:45:58PM +0800, Zheng Yejian wrote:
>> Refer to description of BPF_XOR, dst_reg should be used but not src_reg
>> in the examples.
>>
>> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
>> ---
>>   Documentation/bpf/instruction-set.rst | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/bpf/instruction-set.rst b/Documentation/bpf/instruction-set.rst
>> index 5d798437dad4..e672d5ec6cc7 100644
>> --- a/Documentation/bpf/instruction-set.rst
>> +++ b/Documentation/bpf/instruction-set.rst
>> @@ -122,11 +122,11 @@ BPF_END   0xd0   byte swap operations (see `Byte swap instructions`_ below)
>>   
>>   ``BPF_XOR | BPF_K | BPF_ALU`` means::
>>   
>> -  src_reg = (u32) src_reg ^ (u32) imm32
>> +  dst_reg = (u32) dst_reg ^ (u32) imm32
> 
> Shouldn't this be
> 
> dst_reg = (u32) dst_reg ^ (u32) src_reg
> 
> Same idea below for 64 bit

See Chapter 'Instruction classes', BPF_K means "use 32-bit immediate as 
source operand", so it should be 'imm32' instead of 'src_reg'.

> 
>>   
>>   ``BPF_XOR | BPF_K | BPF_ALU64`` means::
>>   
>> -  src_reg = src_reg ^ imm32
>> +  dst_reg = dst_reg ^ imm32
>>   
>>   
>>   Byte swap instructions
>> -- 
>> 2.25.1
>>
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] bpf, docs: Correct the example of BPF_XOR
  2022-11-29 13:45 [PATCH bpf] bpf, docs: Correct the example of BPF_XOR Zheng Yejian
  2022-11-29 18:54 ` David Vernet
@ 2022-12-02 21:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-02 21:30 UTC (permalink / raw)
  To: Zheng Yejian
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, corbet, bpf, linux-doc, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue, 29 Nov 2022 21:45:58 +0800 you wrote:
> Refer to description of BPF_XOR, dst_reg should be used but not src_reg
> in the examples.
> 
> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
> ---
>  Documentation/bpf/instruction-set.rst | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
  - [bpf] bpf, docs: Correct the example of BPF_XOR
    https://git.kernel.org/bpf/bpf-next/c/bc067cacb69c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-02 21:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29 13:45 [PATCH bpf] bpf, docs: Correct the example of BPF_XOR Zheng Yejian
2022-11-29 18:54 ` David Vernet
2022-11-30  1:17   ` Zheng Yejian
2022-12-02 21:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).