From 9a09aebec20ff749e43dd0c3b514294e13612e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Wed, 20 Sep 2023 20:15:29 +0200 Subject: [PATCH] Adds coverage for syscalls in test_code_length_estimate(). (#519) --- src/jit.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/jit.rs b/src/jit.rs index 663a14ed..267ac1ff 100644 --- a/src/jit.rs +++ b/src/jit.rs @@ -1708,19 +1708,24 @@ mod tests { assert!(empty_program_machine_code_length <= MAX_EMPTY_PROGRAM_MACHINE_CODE_LENGTH); for mut opcode in 0x00..=0xFF { - let immediate = match opcode { - 0x85 | 0x8D => 8, + let (registers, immediate) = match opcode { + 0x85 | 0x8D => (0x88, 8), 0x86 => { // Put external function calls on a separate loop iteration opcode = 0x85; - 0x91020CDD + (0x00, 0x91020CDD) } - 0xD4 | 0xDC => 16, - _ => 0xFFFFFFFF, + 0x87 => { + // Put invalid function calls on a separate loop iteration + opcode = 0x85; + (0x88, 0x91020CDD) + } + 0xD4 | 0xDC => (0x88, 16), + _ => (0x88, 0xFFFFFFFF), }; for pc in 0..INSTRUCTION_COUNT { prog[pc * ebpf::INSN_SIZE] = opcode; - prog[pc * ebpf::INSN_SIZE + 1] = 0x88; + prog[pc * ebpf::INSN_SIZE + 1] = registers; prog[pc * ebpf::INSN_SIZE + 2] = 0xFF; prog[pc * ebpf::INSN_SIZE + 3] = 0xFF; LittleEndian::write_u32(&mut prog[pc * ebpf::INSN_SIZE + 4..], immediate);