diff mbox series

[2/5] powerpc64/bpf: jit support for unconditional byte swap

Message ID 20240517075650.248801-3-asavkov@redhat.com (mailing list archive)
State New
Headers show
Series powerpc64/bpf: jit support for cpuv4 instructions | expand

Commit Message

Artem Savkov May 17, 2024, 7:56 a.m. UTC
Add jit support for unconditional byte swap. Tested using BSWAP tests
from test_bpf module.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
 arch/powerpc/net/bpf_jit_comp64.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Hari Bathini May 22, 2024, 11:37 a.m. UTC | #1
On 17/05/24 1:26 pm, Artem Savkov wrote:
> Add jit support for unconditional byte swap. Tested using BSWAP tests
> from test_bpf module.
> 
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> ---
>   arch/powerpc/net/bpf_jit_comp64.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
> index 3071205782b15..97191cf091bbf 100644
> --- a/arch/powerpc/net/bpf_jit_comp64.c
> +++ b/arch/powerpc/net/bpf_jit_comp64.c
> @@ -699,11 +699,12 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
>   		 */
>   		case BPF_ALU | BPF_END | BPF_FROM_LE:
>   		case BPF_ALU | BPF_END | BPF_FROM_BE:

> +		case BPF_ALU64 | BPF_END | BPF_FROM_LE:

A comment here indicating this case does unconditional swap
could improve readability.

Other than this minor nit, the patchset looks good to me.
Also, tested the changes with test_bpf module and selftests.
For the series..

Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>

>   #ifdef __BIG_ENDIAN__
>   			if (BPF_SRC(code) == BPF_FROM_BE)
>   				goto emit_clear;
>   #else /* !__BIG_ENDIAN__ */
> -			if (BPF_SRC(code) == BPF_FROM_LE)
> +			if (BPF_CLASS(code) == BPF_ALU && BPF_SRC(code) == BPF_FROM_LE)
>   				goto emit_clear;
>   #endif
>   			switch (imm) {
diff mbox series

Patch

diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index 3071205782b15..97191cf091bbf 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -699,11 +699,12 @@  int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
 		 */
 		case BPF_ALU | BPF_END | BPF_FROM_LE:
 		case BPF_ALU | BPF_END | BPF_FROM_BE:
+		case BPF_ALU64 | BPF_END | BPF_FROM_LE:
 #ifdef __BIG_ENDIAN__
 			if (BPF_SRC(code) == BPF_FROM_BE)
 				goto emit_clear;
 #else /* !__BIG_ENDIAN__ */
-			if (BPF_SRC(code) == BPF_FROM_LE)
+			if (BPF_CLASS(code) == BPF_ALU && BPF_SRC(code) == BPF_FROM_LE)
 				goto emit_clear;
 #endif
 			switch (imm) {