[PATCH bpf-next 1/3] bpf/tests: Make max jump tests constant blinding compatible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Constant blinding may expand instructions that make use of immediate
values into multiple, resulting in preceding jump instructions to get a
bigger target offset. The "max jump" tests specifically attempt to test
the biggest possible jump offset, requiring to take special care about
the final (after blinding) offset while crafting the input program.

To make these tests independent of constant blinding's instruction
expansion, use a register-only operation to load R0 with the intended
value.

This fixes the "Long conditional jump" tests with enabled blinding.

Fixes: f1517eb790f9 ("bpf/tests: Expand branch conversion JIT test")
Cc: Johan Almbladh <johan.almbladh@xxxxxxxxxxxxxxxxx>
Signed-off-by: Mathias Krause <minipli@xxxxxxxxxxxxxx>
---
 lib/test_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index fa5edd6ef7f7..c1140bab280d 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -491,7 +491,7 @@ static int __bpf_fill_max_jmp(struct bpf_test *self, int jmp, int imm)
 	i = __bpf_ld_imm64(insns, R1, 0x0123456789abcdefULL);
 	insns[i++] = BPF_ALU64_IMM(BPF_MOV, R0, 1);
 	insns[i++] = BPF_JMP_IMM(jmp, R0, imm, S16_MAX);
-	insns[i++] = BPF_ALU64_IMM(BPF_MOV, R0, 2);
+	insns[i++] = BPF_ALU64_REG(BPF_ADD, R0, R0);
 	insns[i++] = BPF_EXIT_INSN();
 
 	while (i < len - 1) {
-- 
2.30.2





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux