Home
last modified time | relevance | path

Searched refs:insn (Results 1 – 12 of 12) sorted by relevance

/DragonOS/kernel/crates/rbpf/tests/
H A Dassembler.rs16 fn insn(opc: u8, dst: u8, src: u8, off: i16, imm: i32) -> ebpf::Insn { in insn() function
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()
[all …]
H A Ddisassembler.rs16 let insn = to_insn_vec(&asm); localVariable
17 let reasm = insn
/DragonOS/kernel/crates/rbpf/src/
H A Ddisassembler.rs19 fn alu_imm_str(name: &str, insn: &ebpf::Insn) -> String { in alu_imm_str()
20 format!("{name} r{}, {:#x}", insn.dst, insn.imm) in alu_imm_str()
24 fn alu_reg_str(name: &str, insn: &ebpf::Insn) -> String { in alu_reg_str()
25 format!("{name} r{}, r{}", insn.dst, insn.src) in alu_reg_str()
29 fn byteswap_str(name: &str, insn: &ebpf::Insn) -> String { in byteswap_str()
30 match insn.imm { in byteswap_str()
34 format!("{name}{} r{}", insn.imm, insn.dst) in byteswap_str()
38 fn ld_st_imm_str(name: &str, insn: &ebpf::Insn) -> String { in ld_st_imm_str()
39 if insn.off >= 0 { in ld_st_imm_str()
40 format!("{name} [r{}+{:#x}], {:#x}", insn.dst, insn.off, insn.imm) in ld_st_imm_str()
[all …]
H A Dcranelift.rs253 let insn = ebpf::get_insn(prog, insn_ptr); in translate_program() localVariable
269 match insn.opc { in translate_program()
282 let ty = match insn.opc { in translate_program()
294 .iconst(self.isa.pointer_type(), insn.imm as u32 as i64); in translate_program()
298 let is_ind = (insn.opc & BPF_IND) != 0; in translate_program()
300 let src_reg = self.insn_src(bcx, &insn); in translate_program()
315 self.set_dst(bcx, &insn, ext); in translate_program()
321 let imm = (((insn.imm as u32) as u64) + ((next_insn.imm as u64) << 32)) as i64; in translate_program()
323 self.set_dst(bcx, &insn, iconst); in translate_program()
328 let ty = match insn.opc { in translate_program()
[all …]
H A Dinterpreter.rs77 fn do_jump(insn_ptr: &mut usize, insn: &Insn) { in do_jump()
78 *insn_ptr = (*insn_ptr as i16 + insn.off) as usize; in do_jump()
133 let insn = ebpf::get_insn(prog, insn_ptr); in execute_program() localVariable
135 let _dst = insn.dst as usize; in execute_program()
136 let _src = insn.src as usize; in execute_program()
138 match insn.opc { in execute_program()
145 let x = (mem.as_ptr() as u64 + (insn.imm as u32) as u64) as *const u8; in execute_program()
152 let x = (mem.as_ptr() as u64 + (insn.imm as u32) as u64) as *const u16; in execute_program()
159 let x = (mem.as_ptr() as u64 + (insn.imm as u32) as u64) as *const u32; in execute_program()
165 log::info!("executing LD_ABS_DW, set reg[{}] to {:#x}", _dst, insn.imm); in execute_program()
[all …]
H A Djit.rs538 let insn = ebpf::get_insn(prog, insn_ptr); in jit_compile() localVariable
542 let dst = map_register(insn.dst); in jit_compile()
543 let src = map_register(insn.src); in jit_compile()
544 let target_pc = insn_ptr as isize + insn.off as isize + 1; in jit_compile()
546 match insn.opc { in jit_compile()
549 ebpf::LD_ABS_B => self.emit_load(mem, OperandSize::S8, R10, RAX, insn.imm), in jit_compile()
550 ebpf::LD_ABS_H => self.emit_load(mem, OperandSize::S16, R10, RAX, insn.imm), in jit_compile()
551 ebpf::LD_ABS_W => self.emit_load(mem, OperandSize::S32, R10, RAX, insn.imm), in jit_compile()
552 ebpf::LD_ABS_DW => self.emit_load(mem, OperandSize::S64, R10, RAX, insn.imm), in jit_compile()
556 self.emit_load(mem, OperandSize::S8, R11, RAX, insn.imm); // ld R0, mem[src+imm] in jit_compile()
[all …]
H A Dassembler.rs154 fn insn(opc: u8, dst: i64, src: i64, off: i64, imm: i64) -> Result<Insn, String> { in insn() function
190 (AluBinary, Register(dst), Register(src), Nil) => insn(opc | ebpf::BPF_X, dst, src, 0, 0), in encode()
191 (AluBinary, Register(dst), Integer(imm), Nil) => insn(opc | ebpf::BPF_K, dst, 0, 0, imm), in encode()
192 (AluUnary, Register(dst), Nil, Nil) => insn(opc, dst, 0, 0, 0), in encode()
193 (LoadAbs, Integer(imm), Nil, Nil) => insn(opc, 0, 0, 0, imm), in encode()
194 (LoadInd, Register(src), Integer(imm), Nil) => insn(opc, 0, src, 0, imm), in encode()
196 | (StoreReg, Memory(dst, off), Register(src), Nil) => insn(opc, dst, src, off, 0), in encode()
197 (StoreImm, Memory(dst, off), Integer(imm), Nil) => insn(opc, dst, 0, off, imm), in encode()
198 (NoOperand, Nil, Nil, Nil) => insn(opc, 0, 0, 0, 0), in encode()
199 (JumpUnconditional, Integer(off), Nil, Nil) => insn(opc, 0, 0, off, 0), in encode()
[all …]
H A Dverifier.rs56 fn check_imm_endian(insn: &ebpf::Insn, insn_ptr: usize) -> Result<(), Error> { in check_imm_endian()
57 match insn.imm { in check_imm_endian()
77 let insn = ebpf::get_insn(prog, insn_ptr); in check_jmp_offset() localVariable
78 if insn.off == -1 { in check_jmp_offset()
82 let dst_insn_ptr = insn_ptr as isize + 1 + insn.off as isize; in check_jmp_offset()
99 fn check_registers(insn: &ebpf::Insn, store: bool, insn_ptr: usize) -> Result<(), Error> { in check_registers()
100 if insn.src > 10 { in check_registers()
104 match (insn.dst, store) { in check_registers()
118 let insn = ebpf::get_insn(prog, insn_ptr); in check() localVariable
121 match insn.opc { in check()
[all …]
H A Dinsn_builder.rs184 insn: Insn { in mov_internal()
199 insn: Insn { in swap_bytes()
236 insn: Insn { in load_internal()
262 insn: Insn { in store_internal()
283 insn: Insn { in jump_conditional()
297 insn: Insn { in call()
311 insn: Insn { in exit()
338 insn: Insn, field
359 &mut self.insn in get_insn_mut()
363 &self.insn in get_insn()
[all …]
H A Debpf.rs630 let insn = get_insn(prog, insn_ptr); in to_insn_vec() localVariable
631 res.push(insn); in to_insn_vec()
/DragonOS/kernel/crates/rbpf/examples/
H A Dto_json.rs29 for insn in insns { in to_json()
31 "opc" => format!("{:#x}", insn.opc), // => insn.opc, in to_json()
32 "dst" => format!("{:#x}", insn.dst), // => insn.dst, in to_json()
33 "src" => format!("{:#x}", insn.src), // => insn.src, in to_json()
34 "off" => format!("{:#x}", insn.off), // => insn.off, in to_json()
42 "imm" => format!("{:#x}", insn.imm as i32), // => insn.imm, in to_json()
43 "desc" => insn.desc in to_json()
/DragonOS/kernel/src/bpf/prog/
H A Dverifier.rs45 let mut insn = fmt_insn[index].clone(); in relocation() localVariable
46 if insn.opc == ebpf::LD_DW_IMM { in relocation()
50 let map_fd = insn.imm as usize; in relocation()
51 let src_reg = insn.src; in relocation()
104 insn.imm = ptr as i32; in relocation()
106 fmt_insn[index] = insn; in relocation()