Lines Matching refs:ebpf
10 use rbpf::{assembler::assemble, ebpf};
12 fn asm(src: &str) -> Result<Vec<ebpf::Insn>, String> { in asm()
13 Ok(ebpf::to_insn_vec(&(assemble(src))?)) in asm()
16 fn insn(opc: u8, dst: u8, src: u8, off: i16, imm: i32) -> ebpf::Insn { in insn()
17 ebpf::Insn { in insn()
34 assert_eq!(asm("exit"), Ok(vec![insn(ebpf::EXIT, 0, 0, 0, 0)])); in test_exit()
42 Ok(vec![insn(ebpf::ADD64_REG, 1, 3, 0, 0)]) in test_add64()
46 Ok(vec![insn(ebpf::ADD64_IMM, 1, 0, 0, 5)]) in test_add64()
53 assert_eq!(asm("neg64 r1"), Ok(vec![insn(ebpf::NEG64, 1, 0, 0, 0)])); in test_neg64()
61 Ok(vec![insn(ebpf::LD_W_REG, 1, 2, 5, 0)]) in test_ldxw()
70 Ok(vec![insn(ebpf::ST_W_IMM, 2, 0, 5, 7)]) in test_stw()
79 Ok(vec![insn(ebpf::ST_W_REG, 2, 8, 5, 0)]) in test_stxw()
86 assert_eq!(asm("ja +8"), Ok(vec![insn(ebpf::JA, 0, 0, 8, 0)])); in test_ja()
87 assert_eq!(asm("ja -3"), Ok(vec![insn(ebpf::JA, 0, 0, -3, 0)])); in test_ja()
95 Ok(vec![insn(ebpf::JEQ_IMM, 1, 0, 8, 4)]) in test_jeq()
99 Ok(vec![insn(ebpf::JEQ_REG, 1, 3, 8, 0)]) in test_jeq()
106 assert_eq!(asm("call 300"), Ok(vec![insn(ebpf::CALL, 0, 0, 0, 300)])); in test_call()
112 assert_eq!(asm("be32 r1"), Ok(vec![insn(ebpf::BE, 1, 0, 0, 32)])); in test_be32()
121 insn(ebpf::LD_DW_IMM, 1, 0, 0, 0x5678eeff), in test_lddw()
128 insn(ebpf::LD_DW_IMM, 1, 0, 0, 0xdd33cc44u32 as i32), in test_lddw()
137 assert_eq!(asm("ldabsw 1"), Ok(vec![insn(ebpf::LD_ABS_W, 0, 0, 0, 1)])); in test_ldabsw()
145 Ok(vec![insn(ebpf::LD_IND_W, 0, 1, 0, 2)]) in test_ldindw()
154 Ok(vec![insn(ebpf::LD_DW_REG, 1, 2, 3, 0)]) in test_ldxdw()
163 Ok(vec![insn(ebpf::ST_H_IMM, 1, 0, 2, 3)]) in test_sth()
172 Ok(vec![insn(ebpf::ST_H_REG, 1, 3, 2, 0)]) in test_stxh()
193 insn(ebpf::ADD64_REG, 1, 2, 0, 0), in test_alu_binary()
194 insn(ebpf::SUB64_REG, 1, 2, 0, 0), in test_alu_binary()
195 insn(ebpf::MUL64_REG, 1, 2, 0, 0), in test_alu_binary()
196 insn(ebpf::DIV64_REG, 1, 2, 0, 0), in test_alu_binary()
197 insn(ebpf::OR64_REG, 1, 2, 0, 0), in test_alu_binary()
198 insn(ebpf::AND64_REG, 1, 2, 0, 0), in test_alu_binary()
199 insn(ebpf::LSH64_REG, 1, 2, 0, 0), in test_alu_binary()
200 insn(ebpf::RSH64_REG, 1, 2, 0, 0), in test_alu_binary()
201 insn(ebpf::MOD64_REG, 1, 2, 0, 0), in test_alu_binary()
202 insn(ebpf::XOR64_REG, 1, 2, 0, 0), in test_alu_binary()
203 insn(ebpf::MOV64_REG, 1, 2, 0, 0), in test_alu_binary()
204 insn(ebpf::ARSH64_REG, 1, 2, 0, 0) in test_alu_binary()
222 insn(ebpf::ADD64_IMM, 1, 0, 0, 2), in test_alu_binary()
223 insn(ebpf::SUB64_IMM, 1, 0, 0, 2), in test_alu_binary()
224 insn(ebpf::MUL64_IMM, 1, 0, 0, 2), in test_alu_binary()
225 insn(ebpf::DIV64_IMM, 1, 0, 0, 2), in test_alu_binary()
226 insn(ebpf::OR64_IMM, 1, 0, 0, 2), in test_alu_binary()
227 insn(ebpf::AND64_IMM, 1, 0, 0, 2), in test_alu_binary()
228 insn(ebpf::LSH64_IMM, 1, 0, 0, 2), in test_alu_binary()
229 insn(ebpf::RSH64_IMM, 1, 0, 0, 2), in test_alu_binary()
230 insn(ebpf::MOD64_IMM, 1, 0, 0, 2), in test_alu_binary()
231 insn(ebpf::XOR64_IMM, 1, 0, 0, 2), in test_alu_binary()
232 insn(ebpf::MOV64_IMM, 1, 0, 0, 2), in test_alu_binary()
233 insn(ebpf::ARSH64_IMM, 1, 0, 0, 2) in test_alu_binary()
251 insn(ebpf::ADD64_REG, 1, 2, 0, 0), in test_alu_binary()
252 insn(ebpf::SUB64_REG, 1, 2, 0, 0), in test_alu_binary()
253 insn(ebpf::MUL64_REG, 1, 2, 0, 0), in test_alu_binary()
254 insn(ebpf::DIV64_REG, 1, 2, 0, 0), in test_alu_binary()
255 insn(ebpf::OR64_REG, 1, 2, 0, 0), in test_alu_binary()
256 insn(ebpf::AND64_REG, 1, 2, 0, 0), in test_alu_binary()
257 insn(ebpf::LSH64_REG, 1, 2, 0, 0), in test_alu_binary()
258 insn(ebpf::RSH64_REG, 1, 2, 0, 0), in test_alu_binary()
259 insn(ebpf::MOD64_REG, 1, 2, 0, 0), in test_alu_binary()
260 insn(ebpf::XOR64_REG, 1, 2, 0, 0), in test_alu_binary()
261 insn(ebpf::MOV64_REG, 1, 2, 0, 0), in test_alu_binary()
262 insn(ebpf::ARSH64_REG, 1, 2, 0, 0) in test_alu_binary()
280 insn(ebpf::ADD64_IMM, 1, 0, 0, 2), in test_alu_binary()
281 insn(ebpf::SUB64_IMM, 1, 0, 0, 2), in test_alu_binary()
282 insn(ebpf::MUL64_IMM, 1, 0, 0, 2), in test_alu_binary()
283 insn(ebpf::DIV64_IMM, 1, 0, 0, 2), in test_alu_binary()
284 insn(ebpf::OR64_IMM, 1, 0, 0, 2), in test_alu_binary()
285 insn(ebpf::AND64_IMM, 1, 0, 0, 2), in test_alu_binary()
286 insn(ebpf::LSH64_IMM, 1, 0, 0, 2), in test_alu_binary()
287 insn(ebpf::RSH64_IMM, 1, 0, 0, 2), in test_alu_binary()
288 insn(ebpf::MOD64_IMM, 1, 0, 0, 2), in test_alu_binary()
289 insn(ebpf::XOR64_IMM, 1, 0, 0, 2), in test_alu_binary()
290 insn(ebpf::MOV64_IMM, 1, 0, 0, 2), in test_alu_binary()
291 insn(ebpf::ARSH64_IMM, 1, 0, 0, 2) in test_alu_binary()
309 insn(ebpf::ADD32_REG, 1, 2, 0, 0), in test_alu_binary()
310 insn(ebpf::SUB32_REG, 1, 2, 0, 0), in test_alu_binary()
311 insn(ebpf::MUL32_REG, 1, 2, 0, 0), in test_alu_binary()
312 insn(ebpf::DIV32_REG, 1, 2, 0, 0), in test_alu_binary()
313 insn(ebpf::OR32_REG, 1, 2, 0, 0), in test_alu_binary()
314 insn(ebpf::AND32_REG, 1, 2, 0, 0), in test_alu_binary()
315 insn(ebpf::LSH32_REG, 1, 2, 0, 0), in test_alu_binary()
316 insn(ebpf::RSH32_REG, 1, 2, 0, 0), in test_alu_binary()
317 insn(ebpf::MOD32_REG, 1, 2, 0, 0), in test_alu_binary()
318 insn(ebpf::XOR32_REG, 1, 2, 0, 0), in test_alu_binary()
319 insn(ebpf::MOV32_REG, 1, 2, 0, 0), in test_alu_binary()
320 insn(ebpf::ARSH32_REG, 1, 2, 0, 0) in test_alu_binary()
338 insn(ebpf::ADD32_IMM, 1, 0, 0, 2), in test_alu_binary()
339 insn(ebpf::SUB32_IMM, 1, 0, 0, 2), in test_alu_binary()
340 insn(ebpf::MUL32_IMM, 1, 0, 0, 2), in test_alu_binary()
341 insn(ebpf::DIV32_IMM, 1, 0, 0, 2), in test_alu_binary()
342 insn(ebpf::OR32_IMM, 1, 0, 0, 2), in test_alu_binary()
343 insn(ebpf::AND32_IMM, 1, 0, 0, 2), in test_alu_binary()
344 insn(ebpf::LSH32_IMM, 1, 0, 0, 2), in test_alu_binary()
345 insn(ebpf::RSH32_IMM, 1, 0, 0, 2), in test_alu_binary()
346 insn(ebpf::MOD32_IMM, 1, 0, 0, 2), in test_alu_binary()
347 insn(ebpf::XOR32_IMM, 1, 0, 0, 2), in test_alu_binary()
348 insn(ebpf::MOV32_IMM, 1, 0, 0, 2), in test_alu_binary()
349 insn(ebpf::ARSH32_IMM, 1, 0, 0, 2) in test_alu_binary()
362 insn(ebpf::NEG64, 1, 0, 0, 0), in test_alu_unary()
363 insn(ebpf::NEG64, 1, 0, 0, 0), in test_alu_unary()
364 insn(ebpf::NEG32, 1, 0, 0, 0) in test_alu_unary()
378 insn(ebpf::LD_ABS_W, 0, 0, 0, 1), in test_load_abs()
379 insn(ebpf::LD_ABS_H, 0, 0, 0, 1), in test_load_abs()
380 insn(ebpf::LD_ABS_B, 0, 0, 0, 1), in test_load_abs()
381 insn(ebpf::LD_ABS_DW, 0, 0, 0, 1) in test_load_abs()
395 insn(ebpf::LD_IND_W, 0, 1, 0, 2), in test_load_ind()
396 insn(ebpf::LD_IND_H, 0, 1, 0, 2), in test_load_ind()
397 insn(ebpf::LD_IND_B, 0, 1, 0, 2), in test_load_ind()
398 insn(ebpf::LD_IND_DW, 0, 1, 0, 2) in test_load_ind()
412 insn(ebpf::LD_W_REG, 1, 2, 3, 0), in test_load_reg()
413 insn(ebpf::LD_H_REG, 1, 2, 3, 0), in test_load_reg()
414 insn(ebpf::LD_B_REG, 1, 2, 3, 0), in test_load_reg()
415 insn(ebpf::LD_DW_REG, 1, 2, 3, 0) in test_load_reg()
429 insn(ebpf::ST_W_IMM, 1, 0, 2, 3), in test_store_imm()
430 insn(ebpf::ST_H_IMM, 1, 0, 2, 3), in test_store_imm()
431 insn(ebpf::ST_B_IMM, 1, 0, 2, 3), in test_store_imm()
432 insn(ebpf::ST_DW_IMM, 1, 0, 2, 3) in test_store_imm()
446 insn(ebpf::ST_W_REG, 1, 3, 2, 0), in test_store_reg()
447 insn(ebpf::ST_H_REG, 1, 3, 2, 0), in test_store_reg()
448 insn(ebpf::ST_B_REG, 1, 3, 2, 0), in test_store_reg()
449 insn(ebpf::ST_DW_REG, 1, 3, 2, 0) in test_store_reg()
470 insn(ebpf::JEQ_REG, 1, 2, 3, 0), in test_jump_conditional()
471 insn(ebpf::JGT_REG, 1, 2, 3, 0), in test_jump_conditional()
472 insn(ebpf::JGE_REG, 1, 2, 3, 0), in test_jump_conditional()
473 insn(ebpf::JLT_REG, 1, 2, 3, 0), in test_jump_conditional()
474 insn(ebpf::JLE_REG, 1, 2, 3, 0), in test_jump_conditional()
475 insn(ebpf::JSET_REG, 1, 2, 3, 0), in test_jump_conditional()
476 insn(ebpf::JNE_REG, 1, 2, 3, 0), in test_jump_conditional()
477 insn(ebpf::JSGT_REG, 1, 2, 3, 0), in test_jump_conditional()
478 insn(ebpf::JSGE_REG, 1, 2, 3, 0), in test_jump_conditional()
479 insn(ebpf::JSLT_REG, 1, 2, 3, 0), in test_jump_conditional()
480 insn(ebpf::JSLE_REG, 1, 2, 3, 0) in test_jump_conditional()
497 insn(ebpf::JEQ_IMM, 1, 0, 3, 2), in test_jump_conditional()
498 insn(ebpf::JGT_IMM, 1, 0, 3, 2), in test_jump_conditional()
499 insn(ebpf::JGE_IMM, 1, 0, 3, 2), in test_jump_conditional()
500 insn(ebpf::JLT_IMM, 1, 0, 3, 2), in test_jump_conditional()
501 insn(ebpf::JLE_IMM, 1, 0, 3, 2), in test_jump_conditional()
502 insn(ebpf::JSET_IMM, 1, 0, 3, 2), in test_jump_conditional()
503 insn(ebpf::JNE_IMM, 1, 0, 3, 2), in test_jump_conditional()
504 insn(ebpf::JSGT_IMM, 1, 0, 3, 2), in test_jump_conditional()
505 insn(ebpf::JSGE_IMM, 1, 0, 3, 2), in test_jump_conditional()
506 insn(ebpf::JSLT_IMM, 1, 0, 3, 2), in test_jump_conditional()
507 insn(ebpf::JSLE_IMM, 1, 0, 3, 2) in test_jump_conditional()
524 insn(ebpf::JEQ_REG32, 1, 2, 3, 0), in test_jump_conditional()
525 insn(ebpf::JGT_REG32, 1, 2, 3, 0), in test_jump_conditional()
526 insn(ebpf::JGE_REG32, 1, 2, 3, 0), in test_jump_conditional()
527 insn(ebpf::JLT_REG32, 1, 2, 3, 0), in test_jump_conditional()
528 insn(ebpf::JLE_REG32, 1, 2, 3, 0), in test_jump_conditional()
529 insn(ebpf::JSET_REG32, 1, 2, 3, 0), in test_jump_conditional()
530 insn(ebpf::JNE_REG32, 1, 2, 3, 0), in test_jump_conditional()
531 insn(ebpf::JSGT_REG32, 1, 2, 3, 0), in test_jump_conditional()
532 insn(ebpf::JSGE_REG32, 1, 2, 3, 0), in test_jump_conditional()
533 insn(ebpf::JSLT_REG32, 1, 2, 3, 0), in test_jump_conditional()
534 insn(ebpf::JSLE_REG32, 1, 2, 3, 0) in test_jump_conditional()
551 insn(ebpf::JEQ_IMM32, 1, 0, 3, 2), in test_jump_conditional()
552 insn(ebpf::JGT_IMM32, 1, 0, 3, 2), in test_jump_conditional()
553 insn(ebpf::JGE_IMM32, 1, 0, 3, 2), in test_jump_conditional()
554 insn(ebpf::JLT_IMM32, 1, 0, 3, 2), in test_jump_conditional()
555 insn(ebpf::JLE_IMM32, 1, 0, 3, 2), in test_jump_conditional()
556 insn(ebpf::JSET_IMM32, 1, 0, 3, 2), in test_jump_conditional()
557 insn(ebpf::JNE_IMM32, 1, 0, 3, 2), in test_jump_conditional()
558 insn(ebpf::JSGT_IMM32, 1, 0, 3, 2), in test_jump_conditional()
559 insn(ebpf::JSGE_IMM32, 1, 0, 3, 2), in test_jump_conditional()
560 insn(ebpf::JSLT_IMM32, 1, 0, 3, 2), in test_jump_conditional()
561 insn(ebpf::JSLE_IMM32, 1, 0, 3, 2) in test_jump_conditional()
577 insn(ebpf::BE, 1, 0, 0, 16), in test_endian()
578 insn(ebpf::BE, 1, 0, 0, 32), in test_endian()
579 insn(ebpf::BE, 1, 0, 0, 64), in test_endian()
580 insn(ebpf::LE, 1, 0, 0, 16), in test_endian()
581 insn(ebpf::LE, 1, 0, 0, 32), in test_endian()
582 insn(ebpf::LE, 1, 0, 0, 64) in test_endian()
591 Ok(vec![insn(ebpf::ADD64_IMM, 1, 0, 0, 2147483647)]) in test_large_immediate()
595 Ok(vec![insn(ebpf::ADD64_IMM, 1, 0, 0, -2147483648)]) in test_large_immediate()