Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
140754bc
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
140754bc
编写于
8月 22, 2008
作者:
A
Avi Kivity
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
KVM: MMU: Convert direct maps to use the generic shadow walker
Signed-off-by:
N
Avi Kivity
<
avi@qumranet.com
>
上级
3d000db5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
38 deletion
+55
-38
arch/x86/kvm/mmu.c
arch/x86/kvm/mmu.c
+55
-38
未找到文件。
arch/x86/kvm/mmu.c
浏览文件 @
140754bc
...
...
@@ -1260,49 +1260,66 @@ static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
{
}
static
int
__direct_map
(
struct
kvm_vcpu
*
vcpu
,
gpa_t
v
,
int
write
,
int
largepage
,
gfn_t
gfn
,
pfn_t
pfn
)
{
hpa_t
table_addr
=
vcpu
->
arch
.
mmu
.
root_hpa
;
int
pt_write
=
0
;
int
level
=
vcpu
->
arch
.
mmu
.
shadow_root_level
;
for
(;
;
level
--
)
{
u32
index
=
PT64_INDEX
(
v
,
level
);
u64
*
table
;
struct
direct_shadow_walk
{
struct
kvm_shadow_walk
walker
;
pfn_t
pfn
;
int
write
;
int
largepage
;
int
pt_write
;
};
ASSERT
(
VALID_PAGE
(
table_addr
));
table
=
__va
(
table_addr
);
static
int
direct_map_entry
(
struct
kvm_shadow_walk
*
_walk
,
struct
kvm_vcpu
*
vcpu
,
gva_t
addr
,
u64
*
sptep
,
int
level
)
{
struct
direct_shadow_walk
*
walk
=
container_of
(
_walk
,
struct
direct_shadow_walk
,
walker
);
struct
kvm_mmu_page
*
sp
;
gfn_t
pseudo_gfn
;
gfn_t
gfn
=
addr
>>
PAGE_SHIFT
;
if
(
level
==
PT_PAGE_TABLE_LEVEL
||
(
walk
->
largepage
&&
level
==
PT_DIRECTORY_LEVEL
))
{
mmu_set_spte
(
vcpu
,
sptep
,
ACC_ALL
,
ACC_ALL
,
0
,
walk
->
write
,
1
,
&
walk
->
pt_write
,
walk
->
largepage
,
gfn
,
walk
->
pfn
,
false
);
return
1
;
}
if
(
level
==
1
||
(
largepage
&&
level
==
2
))
{
mmu_set_spte
(
vcpu
,
&
table
[
index
],
ACC_ALL
,
ACC_ALL
,
0
,
write
,
1
,
&
pt_write
,
largepage
,
gfn
,
pfn
,
false
);
return
pt_write
;
if
(
*
sptep
==
shadow_trap_nonpresent_pte
)
{
pseudo_gfn
=
(
addr
&
PT64_DIR_BASE_ADDR_MASK
)
>>
PAGE_SHIFT
;
sp
=
kvm_mmu_get_page
(
vcpu
,
pseudo_gfn
,
addr
,
level
-
1
,
1
,
ACC_ALL
,
sptep
);
if
(
!
sp
)
{
pgprintk
(
"nonpaging_map: ENOMEM
\n
"
);
kvm_release_pfn_clean
(
walk
->
pfn
);
return
-
ENOMEM
;
}
if
(
table
[
index
]
==
shadow_trap_nonpresent_pte
)
{
struct
kvm_mmu_page
*
new_table
;
gfn_t
pseudo_gfn
;
pseudo_gfn
=
(
v
&
PT64_DIR_BASE_ADDR_MASK
)
>>
PAGE_SHIFT
;
new_table
=
kvm_mmu_get_page
(
vcpu
,
pseudo_gfn
,
v
,
level
-
1
,
1
,
ACC_ALL
,
&
table
[
index
]);
if
(
!
new_table
)
{
pgprintk
(
"nonpaging_map: ENOMEM
\n
"
);
kvm_release_pfn_clean
(
pfn
);
return
-
ENOMEM
;
}
set_shadow_pte
(
&
table
[
index
],
__pa
(
new_table
->
spt
)
|
PT_PRESENT_MASK
|
PT_WRITABLE_MASK
|
shadow_user_mask
|
shadow_x_mask
);
}
table_addr
=
table
[
index
]
&
PT64_BASE_ADDR_MASK
;
set_shadow_pte
(
sptep
,
__pa
(
sp
->
spt
)
|
PT_PRESENT_MASK
|
PT_WRITABLE_MASK
|
shadow_user_mask
|
shadow_x_mask
);
}
return
0
;
}
static
int
__direct_map
(
struct
kvm_vcpu
*
vcpu
,
gpa_t
v
,
int
write
,
int
largepage
,
gfn_t
gfn
,
pfn_t
pfn
)
{
int
r
;
struct
direct_shadow_walk
walker
=
{
.
walker
=
{
.
entry
=
direct_map_entry
,
},
.
pfn
=
pfn
,
.
largepage
=
largepage
,
.
write
=
write
,
.
pt_write
=
0
,
};
r
=
walk_shadow
(
&
walker
.
walker
,
vcpu
,
(
gva_t
)
gfn
<<
PAGE_SHIFT
);
if
(
r
<
0
)
return
r
;
return
walker
.
pt_write
;
}
static
int
nonpaging_map
(
struct
kvm_vcpu
*
vcpu
,
gva_t
v
,
int
write
,
gfn_t
gfn
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录