@@ -1860,57 +1860,34 @@ st: if (is_imm8(insn->off))
18601860static void save_regs (const struct btf_func_model * m , u8 * * prog , int nr_regs ,
18611861 int stack_size )
18621862{
1863- int i , j , arg_size ;
1864- bool next_same_struct = false;
1863+ int i ;
18651864
18661865 /* Store function arguments to stack.
18671866 * For a function that accepts two pointers the sequence will be:
18681867 * mov QWORD PTR [rbp-0x10],rdi
18691868 * mov QWORD PTR [rbp-0x8],rsi
18701869 */
1871- for (i = 0 , j = 0 ; i < min (nr_regs , 6 ); i ++ ) {
1872- /* The arg_size is at most 16 bytes, enforced by the verifier. */
1873- arg_size = m -> arg_size [j ];
1874- if (arg_size > 8 ) {
1875- arg_size = 8 ;
1876- next_same_struct = !next_same_struct ;
1877- }
1878-
1879- emit_stx (prog , bytes_to_bpf_size (arg_size ),
1880- BPF_REG_FP ,
1870+ for (i = 0 ; i < min (nr_regs , 6 ); i ++ )
1871+ emit_stx (prog , BPF_DW , BPF_REG_FP ,
18811872 i == 5 ? X86_REG_R9 : BPF_REG_1 + i ,
18821873 - (stack_size - i * 8 ));
1883-
1884- j = next_same_struct ? j : j + 1 ;
1885- }
18861874}
18871875
18881876static void restore_regs (const struct btf_func_model * m , u8 * * prog , int nr_regs ,
18891877 int stack_size )
18901878{
1891- int i , j , arg_size ;
1892- bool next_same_struct = false;
1879+ int i ;
18931880
18941881 /* Restore function arguments from stack.
18951882 * For a function that accepts two pointers the sequence will be:
18961883 * EMIT4(0x48, 0x8B, 0x7D, 0xF0); mov rdi,QWORD PTR [rbp-0x10]
18971884 * EMIT4(0x48, 0x8B, 0x75, 0xF8); mov rsi,QWORD PTR [rbp-0x8]
18981885 */
1899- for (i = 0 , j = 0 ; i < min (nr_regs , 6 ); i ++ ) {
1900- /* The arg_size is at most 16 bytes, enforced by the verifier. */
1901- arg_size = m -> arg_size [j ];
1902- if (arg_size > 8 ) {
1903- arg_size = 8 ;
1904- next_same_struct = !next_same_struct ;
1905- }
1906-
1907- emit_ldx (prog , bytes_to_bpf_size (arg_size ),
1886+ for (i = 0 ; i < min (nr_regs , 6 ); i ++ )
1887+ emit_ldx (prog , BPF_DW ,
19081888 i == 5 ? X86_REG_R9 : BPF_REG_1 + i ,
19091889 BPF_REG_FP ,
19101890 - (stack_size - i * 8 ));
1911-
1912- j = next_same_struct ? j : j + 1 ;
1913- }
19141891}
19151892
19161893static int invoke_bpf_prog (const struct btf_func_model * m , u8 * * pprog ,
0 commit comments