hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/mips/kernel/ftrace.c
....@@ -37,10 +37,6 @@
3737 ftrace_modify_all_code(command);
3838 }
3939
40
-#endif
41
-
42
-#ifdef CONFIG_DYNAMIC_FTRACE
43
-
4440 #define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */
4541 #define ADDR_MASK 0x03ffffff /* op_code|addr : 31...26|25 ....0 */
4642 #define JUMP_RANGE_MASK ((1UL << 28) - 1)
....@@ -86,7 +82,7 @@
8682 return -EFAULT;
8783
8884 old_fs = get_fs();
89
- set_fs(get_ds());
85
+ set_fs(KERNEL_DS);
9086 flush_icache_range(ip, ip + 8);
9187 set_fs(old_fs);
9288
....@@ -111,7 +107,7 @@
111107
112108 ip -= 4;
113109 old_fs = get_fs();
114
- set_fs(get_ds());
110
+ set_fs(KERNEL_DS);
115111 flush_icache_range(ip, ip + 8);
116112 set_fs(old_fs);
117113
....@@ -135,7 +131,7 @@
135131 return -EFAULT;
136132
137133 old_fs = get_fs();
138
- set_fs(get_ds());
134
+ set_fs(KERNEL_DS);
139135 flush_icache_range(ip, ip + 8);
140136 set_fs(old_fs);
141137
....@@ -333,20 +329,21 @@
333329 return;
334330
335331 /*
336
- * "parent_ra_addr" is the stack address saved the return address of
337
- * the caller of _mcount.
332
+ * "parent_ra_addr" is the stack address where the return address of
333
+ * the caller of _mcount is saved.
338334 *
339
- * if the gcc < 4.5, a leaf function does not save the return address
340
- * in the stack address, so, we "emulate" one in _mcount's stack space,
341
- * and hijack it directly, but for a non-leaf function, it save the
342
- * return address to the its own stack space, we can not hijack it
343
- * directly, but need to find the real stack address,
344
- * ftrace_get_parent_addr() does it!
335
+ * If gcc < 4.5, a leaf function does not save the return address
336
+ * in the stack address, so we "emulate" one in _mcount's stack space,
337
+ * and hijack it directly.
338
+ * For a non-leaf function, it does save the return address to its own
339
+ * stack space, so we can not hijack it directly, but need to find the
340
+ * real stack address, which is done by ftrace_get_parent_addr().
345341 *
346
- * if gcc>= 4.5, with the new -mmcount-ra-address option, for a
342
+ * If gcc >= 4.5, with the new -mmcount-ra-address option, for a
347343 * non-leaf function, the location of the return address will be saved
348
- * to $12 for us, and for a leaf function, only put a zero into $12. we
349
- * do it in ftrace_graph_caller of mcount.S.
344
+ * to $12 for us.
345
+ * For a leaf function, it just puts a zero into $12, so we handle
346
+ * it in ftrace_graph_caller() of mcount.S.
350347 */
351348
352349 /* old_parent_ra = *parent_ra_addr; */
....@@ -400,13 +397,13 @@
400397 unsigned long __init arch_syscall_addr(int nr)
401398 {
402399 #ifdef CONFIG_MIPS32_N32
403
- if (nr >= __NR_N32_Linux && nr <= __NR_N32_Linux + __NR_N32_Linux_syscalls)
400
+ if (nr >= __NR_N32_Linux && nr < __NR_N32_Linux + __NR_N32_Linux_syscalls)
404401 return (unsigned long)sysn32_call_table[nr - __NR_N32_Linux];
405402 #endif
406
- if (nr >= __NR_64_Linux && nr <= __NR_64_Linux + __NR_64_Linux_syscalls)
403
+ if (nr >= __NR_64_Linux && nr < __NR_64_Linux + __NR_64_Linux_syscalls)
407404 return (unsigned long)sys_call_table[nr - __NR_64_Linux];
408405 #ifdef CONFIG_MIPS32_O32
409
- if (nr >= __NR_O32_Linux && nr <= __NR_O32_Linux + __NR_O32_Linux_syscalls)
406
+ if (nr >= __NR_O32_Linux && nr < __NR_O32_Linux + __NR_O32_Linux_syscalls)
410407 return (unsigned long)sys32_call_table[nr - __NR_O32_Linux];
411408 #endif
412409