Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gsplhtlxg
clone-Linux
提交
07420171
C
clone-Linux
项目概览
gsplhtlxg
/
clone-Linux
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
clone-Linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
07420171
编写于
7月 06, 2009
作者:
A
Avi Kivity
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
KVM: MMU: Trace guest pagetable walker
Signed-off-by:
N
Avi Kivity
<
avi@redhat.com
>
上级
dc7e795e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
128 addition
and
3 deletion
+128
-3
arch/x86/kvm/mmu.c
arch/x86/kvm/mmu.c
+3
-0
arch/x86/kvm/mmutrace.h
arch/x86/kvm/mmutrace.h
+117
-0
arch/x86/kvm/paging_tmpl.h
arch/x86/kvm/paging_tmpl.h
+8
-3
未找到文件。
arch/x86/kvm/mmu.c
浏览文件 @
07420171
...
...
@@ -140,6 +140,9 @@ module_param(oos_shadow, bool, 0644);
#define ACC_USER_MASK PT_USER_MASK
#define ACC_ALL (ACC_EXEC_MASK | ACC_WRITE_MASK | ACC_USER_MASK)
#define CREATE_TRACE_POINTS
#include "mmutrace.h"
#define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
struct
kvm_rmap_desc
{
...
...
arch/x86/kvm/mmutrace.h
0 → 100644
浏览文件 @
07420171
#if !defined(_TRACE_KVMMMU_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_KVMMMU_H
#include <linux/tracepoint.h>
#undef TRACE_SYSTEM
#define TRACE_SYSTEM kvmmmu
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE mmutrace
#define kvm_mmu_trace_pferr_flags \
{ PFERR_PRESENT_MASK, "P" }, \
{ PFERR_WRITE_MASK, "W" }, \
{ PFERR_USER_MASK, "U" }, \
{ PFERR_RSVD_MASK, "RSVD" }, \
{ PFERR_FETCH_MASK, "F" }
/*
* A pagetable walk has started
*/
TRACE_EVENT
(
kvm_mmu_pagetable_walk
,
TP_PROTO
(
u64
addr
,
int
write_fault
,
int
user_fault
,
int
fetch_fault
),
TP_ARGS
(
addr
,
write_fault
,
user_fault
,
fetch_fault
),
TP_STRUCT__entry
(
__field
(
__u64
,
addr
)
__field
(
__u32
,
pferr
)
),
TP_fast_assign
(
__entry
->
addr
=
addr
;
__entry
->
pferr
=
(
!!
write_fault
<<
1
)
|
(
!!
user_fault
<<
2
)
|
(
!!
fetch_fault
<<
4
);
),
TP_printk
(
"addr %llx pferr %x %s"
,
__entry
->
addr
,
__entry
->
pferr
,
__print_flags
(
__entry
->
pferr
,
"|"
,
kvm_mmu_trace_pferr_flags
))
);
/* We just walked a paging element */
TRACE_EVENT
(
kvm_mmu_paging_element
,
TP_PROTO
(
u64
pte
,
int
level
),
TP_ARGS
(
pte
,
level
),
TP_STRUCT__entry
(
__field
(
__u64
,
pte
)
__field
(
__u32
,
level
)
),
TP_fast_assign
(
__entry
->
pte
=
pte
;
__entry
->
level
=
level
;
),
TP_printk
(
"pte %llx level %u"
,
__entry
->
pte
,
__entry
->
level
)
);
/* We set a pte accessed bit */
TRACE_EVENT
(
kvm_mmu_set_accessed_bit
,
TP_PROTO
(
unsigned
long
table_gfn
,
unsigned
index
,
unsigned
size
),
TP_ARGS
(
table_gfn
,
index
,
size
),
TP_STRUCT__entry
(
__field
(
__u64
,
gpa
)
),
TP_fast_assign
(
__entry
->
gpa
=
((
u64
)
table_gfn
<<
PAGE_SHIFT
)
+
index
*
size
;
),
TP_printk
(
"gpa %llx"
,
__entry
->
gpa
)
);
/* We set a pte dirty bit */
TRACE_EVENT
(
kvm_mmu_set_dirty_bit
,
TP_PROTO
(
unsigned
long
table_gfn
,
unsigned
index
,
unsigned
size
),
TP_ARGS
(
table_gfn
,
index
,
size
),
TP_STRUCT__entry
(
__field
(
__u64
,
gpa
)
),
TP_fast_assign
(
__entry
->
gpa
=
((
u64
)
table_gfn
<<
PAGE_SHIFT
)
+
index
*
size
;
),
TP_printk
(
"gpa %llx"
,
__entry
->
gpa
)
);
TRACE_EVENT
(
kvm_mmu_walker_error
,
TP_PROTO
(
u32
pferr
),
TP_ARGS
(
pferr
),
TP_STRUCT__entry
(
__field
(
__u32
,
pferr
)
),
TP_fast_assign
(
__entry
->
pferr
=
pferr
;
),
TP_printk
(
"pferr %x %s"
,
__entry
->
pferr
,
__print_flags
(
__entry
->
pferr
,
"|"
,
kvm_mmu_trace_pferr_flags
))
);
#endif
/* _TRACE_KVMMMU_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
arch/x86/kvm/paging_tmpl.h
浏览文件 @
07420171
...
...
@@ -125,13 +125,15 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
gpa_t
pte_gpa
;
int
rsvd_fault
=
0
;
pgprintk
(
"%s: addr %lx
\n
"
,
__func__
,
addr
);
trace_kvm_mmu_pagetable_walk
(
addr
,
write_fault
,
user_fault
,
fetch_fault
);
walk:
walker
->
level
=
vcpu
->
arch
.
mmu
.
root_level
;
pte
=
vcpu
->
arch
.
cr3
;
#if PTTYPE == 64
if
(
!
is_long_mode
(
vcpu
))
{
pte
=
kvm_pdptr_read
(
vcpu
,
(
addr
>>
30
)
&
3
);
trace_kvm_mmu_paging_element
(
pte
,
walker
->
level
);
if
(
!
is_present_gpte
(
pte
))
goto
not_present
;
--
walker
->
level
;
...
...
@@ -150,10 +152,9 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
pte_gpa
+=
index
*
sizeof
(
pt_element_t
);
walker
->
table_gfn
[
walker
->
level
-
1
]
=
table_gfn
;
walker
->
pte_gpa
[
walker
->
level
-
1
]
=
pte_gpa
;
pgprintk
(
"%s: table_gfn[%d] %lx
\n
"
,
__func__
,
walker
->
level
-
1
,
table_gfn
);
kvm_read_guest
(
vcpu
->
kvm
,
pte_gpa
,
&
pte
,
sizeof
(
pte
));
trace_kvm_mmu_paging_element
(
pte
,
walker
->
level
);
if
(
!
is_present_gpte
(
pte
))
goto
not_present
;
...
...
@@ -175,6 +176,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
#endif
if
(
!
(
pte
&
PT_ACCESSED_MASK
))
{
trace_kvm_mmu_set_accessed_bit
(
table_gfn
,
index
,
sizeof
(
pte
));
mark_page_dirty
(
vcpu
->
kvm
,
table_gfn
);
if
(
FNAME
(
cmpxchg_gpte
)(
vcpu
->
kvm
,
table_gfn
,
index
,
pte
,
pte
|
PT_ACCESSED_MASK
))
...
...
@@ -208,6 +211,7 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
if
(
write_fault
&&
!
is_dirty_gpte
(
pte
))
{
bool
ret
;
trace_kvm_mmu_set_dirty_bit
(
table_gfn
,
index
,
sizeof
(
pte
));
mark_page_dirty
(
vcpu
->
kvm
,
table_gfn
);
ret
=
FNAME
(
cmpxchg_gpte
)(
vcpu
->
kvm
,
table_gfn
,
index
,
pte
,
pte
|
PT_DIRTY_MASK
);
...
...
@@ -239,6 +243,7 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
walker
->
error_code
|=
PFERR_FETCH_MASK
;
if
(
rsvd_fault
)
walker
->
error_code
|=
PFERR_RSVD_MASK
;
trace_kvm_mmu_walker_error
(
walker
->
error_code
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录