Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
cf64c800
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cf64c800
编写于
6月 12, 2009
作者:
P
Paul Mundt
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'sh/ftrace' of
git://github.com/mfleming/linux-2.6
上级
512626a0
9e28c46b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
30 deletion
+30
-30
arch/sh/kernel/ftrace.c
arch/sh/kernel/ftrace.c
+30
-30
未找到文件。
arch/sh/kernel/ftrace.c
浏览文件 @
cf64c800
/*
* Copyright (C) 2008 Matt Fleming <m
jf@gentoo
.org>
* Copyright (C) 2008 Matt Fleming <m
att@console-pimps
.org>
* Copyright (C) 2008 Paul Mundt <lethal@linux-sh.org>
*
* Code for replacing ftrace calls with jumps.
...
...
@@ -19,30 +19,37 @@
#include <asm/ftrace.h>
#include <asm/cacheflush.h>
static
unsigned
char
ftrace_nop
[]
=
{
0x09
,
0x00
,
/* nop */
0x09
,
0x00
,
/* nop */
};
static
unsigned
char
ftrace_replaced_code
[
MCOUNT_INSN_SIZE
];
unsigned
char
*
ftrace_nop_replace
(
void
)
static
unsigned
char
ftrace_nop
[
4
];
/*
* If we're trying to nop out a call to a function, we instead
* place a call to the address after the memory table.
*
* 8c011060 <a>:
* 8c011060: 02 d1 mov.l 8c01106c <a+0xc>,r1
* 8c011062: 22 4f sts.l pr,@-r15
* 8c011064: 02 c7 mova 8c011070 <a+0x10>,r0
* 8c011066: 2b 41 jmp @r1
* 8c011068: 2a 40 lds r0,pr
* 8c01106a: 09 00 nop
* 8c01106c: 68 24 .word 0x2468 <--- ip
* 8c01106e: 1d 8c .word 0x8c1d
* 8c011070: 26 4f lds.l @r15+,pr <--- ip + MCOUNT_INSN_SIZE
*
* We write 0x8c011070 to 0x8c01106c so that on entry to a() we branch
* past the _mcount call and continue executing code like normal.
*/
static
unsigned
char
*
ftrace_nop_replace
(
unsigned
long
ip
)
{
__raw_writel
(
ip
+
MCOUNT_INSN_SIZE
,
ftrace_nop
);
return
ftrace_nop
;
}
static
int
is_sh_nop
(
unsigned
char
*
ip
)
{
return
strncmp
(
ip
,
ftrace_nop
,
sizeof
(
ftrace_nop
));
}
unsigned
char
*
ftrace_call_replace
(
unsigned
long
ip
,
unsigned
long
addr
)
static
unsigned
char
*
ftrace_call_replace
(
unsigned
long
ip
,
unsigned
long
addr
)
{
/* Place the address in the memory table. */
if
(
addr
==
CALLER_ADDR
)
__raw_writel
(
addr
+
MCOUNT_INSN_OFFSET
,
ftrace_replaced_code
);
else
__raw_writel
(
addr
,
ftrace_replaced_code
);
__raw_writel
(
addr
,
ftrace_replaced_code
);
/*
* No locking needed, this must be called via kstop_machine
...
...
@@ -51,7 +58,7 @@ unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
return
ftrace_replaced_code
;
}
int
ftrace_modify_code
(
unsigned
long
ip
,
unsigned
char
*
old_code
,
static
int
ftrace_modify_code
(
unsigned
long
ip
,
unsigned
char
*
old_code
,
unsigned
char
*
new_code
)
{
unsigned
char
replaced
[
MCOUNT_INSN_SIZE
];
...
...
@@ -66,13 +73,6 @@ int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
* kstop_machine, or before SMP starts.
*/
/*
* If we're trying to nop out a call to a function, we instead
* place a call to the address after the memory table.
*/
if
(
is_sh_nop
(
new_code
)
==
0
)
__raw_writel
(
ip
+
MCOUNT_INSN_SIZE
,
(
unsigned
long
)
new_code
);
/* read the text we want to modify */
if
(
probe_kernel_read
(
replaced
,
(
void
*
)
ip
,
MCOUNT_INSN_SIZE
))
return
-
EFAULT
;
...
...
@@ -92,13 +92,13 @@ int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
int
ftrace_update_ftrace_func
(
ftrace_func_t
func
)
{
unsigned
long
ip
=
(
unsigned
long
)(
&
ftrace_call
);
unsigned
long
ip
=
(
unsigned
long
)(
&
ftrace_call
)
+
MCOUNT_INSN_OFFSET
;
unsigned
char
old
[
MCOUNT_INSN_SIZE
],
*
new
;
memcpy
(
old
,
(
unsigned
char
*
)
(
ip
+
MCOUNT_INSN_OFFSET
)
,
MCOUNT_INSN_SIZE
);
memcpy
(
old
,
(
unsigned
char
*
)
ip
,
MCOUNT_INSN_SIZE
);
new
=
ftrace_call_replace
(
ip
,
(
unsigned
long
)
func
);
return
ftrace_modify_code
(
ip
+
MCOUNT_INSN_OFFSET
,
old
,
new
);
return
ftrace_modify_code
(
ip
,
old
,
new
);
}
int
ftrace_make_nop
(
struct
module
*
mod
,
...
...
@@ -108,7 +108,7 @@ int ftrace_make_nop(struct module *mod,
unsigned
long
ip
=
rec
->
ip
;
old
=
ftrace_call_replace
(
ip
,
addr
);
new
=
ftrace_nop_replace
();
new
=
ftrace_nop_replace
(
ip
);
return
ftrace_modify_code
(
rec
->
ip
,
old
,
new
);
}
...
...
@@ -118,7 +118,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
unsigned
char
*
new
,
*
old
;
unsigned
long
ip
=
rec
->
ip
;
old
=
ftrace_nop_replace
();
old
=
ftrace_nop_replace
(
ip
);
new
=
ftrace_call_replace
(
ip
,
addr
);
return
ftrace_modify_code
(
rec
->
ip
,
old
,
new
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录