@@ -157,14 +157,13 @@ int traceprobe_split_symbol_offset(char *symbol, long *offset)
157157#define PARAM_MAX_STACK (THREAD_SIZE / sizeof(unsigned long))
158158
159159static int parse_probe_vars (char * arg , const struct fetch_type * t ,
160- struct fetch_insn * code , bool is_return ,
161- bool is_kprobe )
160+ struct fetch_insn * code , unsigned int flags )
162161{
163162 int ret = 0 ;
164163 unsigned long param ;
165164
166165 if (strcmp (arg , "retval" ) == 0 ) {
167- if (is_return )
166+ if (flags & TPARG_FL_RETURN )
168167 code -> op = FETCH_OP_RETVAL ;
169168 else
170169 ret = - EINVAL ;
@@ -173,7 +172,8 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
173172 code -> op = FETCH_OP_STACKP ;
174173 } else if (isdigit (arg [5 ])) {
175174 ret = kstrtoul (arg + 5 , 10 , & param );
176- if (ret || (is_kprobe && param > PARAM_MAX_STACK ))
175+ if (ret || ((flags & TPARG_FL_KERNEL ) &&
176+ param > PARAM_MAX_STACK ))
177177 ret = - EINVAL ;
178178 else {
179179 code -> op = FETCH_OP_STACK ;
@@ -183,6 +183,18 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
183183 ret = - EINVAL ;
184184 } else if (strcmp (arg , "comm" ) == 0 ) {
185185 code -> op = FETCH_OP_COMM ;
186+ #ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API
187+ } else if (((flags & TPARG_FL_MASK ) ==
188+ (TPARG_FL_KERNEL | TPARG_FL_FENTRY )) &&
189+ strncmp (arg , "arg" , 3 ) == 0 ) {
190+ if (!isdigit (arg [3 ]))
191+ return - EINVAL ;
192+ ret = kstrtoul (arg + 3 , 10 , & param );
193+ if (ret || !param || param > PARAM_MAX_STACK )
194+ return - EINVAL ;
195+ code -> op = FETCH_OP_ARG ;
196+ code -> param = (unsigned int )param - 1 ;
197+ #endif
186198 } else
187199 ret = - EINVAL ;
188200
@@ -193,7 +205,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
193205static int
194206parse_probe_arg (char * arg , const struct fetch_type * type ,
195207 struct fetch_insn * * pcode , struct fetch_insn * end ,
196- bool is_return , bool is_kprobe )
208+ unsigned int flags )
197209{
198210 struct fetch_insn * code = * pcode ;
199211 unsigned long param ;
@@ -203,8 +215,7 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
203215
204216 switch (arg [0 ]) {
205217 case '$' :
206- ret = parse_probe_vars (arg + 1 , type , code ,
207- is_return , is_kprobe );
218+ ret = parse_probe_vars (arg + 1 , type , code , flags );
208219 break ;
209220
210221 case '%' : /* named register */
@@ -226,7 +237,7 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
226237 code -> immediate = param ;
227238 } else if (arg [1 ] == '+' ) {
228239 /* kprobes don't support file offsets */
229- if (is_kprobe )
240+ if (flags & TPARG_FL_KERNEL )
230241 return - EINVAL ;
231242
232243 ret = kstrtol (arg + 2 , 0 , & offset );
@@ -237,7 +248,7 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
237248 code -> immediate = (unsigned long )offset ; // imm64?
238249 } else {
239250 /* uprobes don't support symbols */
240- if (!is_kprobe )
251+ if (!( flags & TPARG_FL_KERNEL ) )
241252 return - EINVAL ;
242253
243254 ret = traceprobe_split_symbol_offset (arg + 1 , & offset );
@@ -278,8 +289,7 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
278289 const struct fetch_type * t2 = find_fetch_type (NULL );
279290
280291 * tmp = '\0' ;
281- ret = parse_probe_arg (arg , t2 , & code , end , is_return ,
282- is_kprobe );
292+ ret = parse_probe_arg (arg , t2 , & code , end , flags );
283293 if (ret )
284294 break ;
285295 if (code -> op == FETCH_OP_COMM )
@@ -339,7 +349,7 @@ static int __parse_bitfield_probe_arg(const char *bf,
339349
340350/* String length checking wrapper */
341351int traceprobe_parse_probe_arg (char * arg , ssize_t * size ,
342- struct probe_arg * parg , bool is_return , bool is_kprobe )
352+ struct probe_arg * parg , unsigned int flags )
343353{
344354 struct fetch_insn * code , * scode , * tmp = NULL ;
345355 char * t , * t2 ;
@@ -397,7 +407,7 @@ int traceprobe_parse_probe_arg(char *arg, ssize_t *size,
397407 code [FETCH_INSN_MAX - 1 ].op = FETCH_OP_END ;
398408
399409 ret = parse_probe_arg (arg , parg -> type , & code , & code [FETCH_INSN_MAX - 1 ],
400- is_return , is_kprobe );
410+ flags );
401411 if (ret )
402412 goto fail ;
403413
0 commit comments