Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
cb9b6a1b
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cb9b6a1b
编写于
3月 31, 2021
作者:
P
Paolo Bonzini
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'kvm-fix-svm-races' into HEAD
上级
4a98623d
3c346c0c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
12 deletion
+20
-12
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/nested.c
+20
-12
未找到文件。
arch/x86/kvm/svm/nested.c
浏览文件 @
cb9b6a1b
...
...
@@ -272,6 +272,13 @@ static bool nested_vmcb_check_cr3_cr4(struct kvm_vcpu *vcpu,
static
bool
nested_vmcb_valid_sregs
(
struct
kvm_vcpu
*
vcpu
,
struct
vmcb_save_area
*
save
)
{
/*
* FIXME: these should be done after copying the fields,
* to avoid TOC/TOU races. For these save area checks
* the possible damage is limited since kvm_set_cr0 and
* kvm_set_cr4 handle failure; EFER_SVME is an exception
* so it is force-set later in nested_prepare_vmcb_save.
*/
if
(
CC
(
!
(
save
->
efer
&
EFER_SVME
)))
return
false
;
...
...
@@ -291,14 +298,6 @@ static bool nested_vmcb_valid_sregs(struct kvm_vcpu *vcpu,
return
true
;
}
static
bool
nested_vmcb_checks
(
struct
kvm_vcpu
*
vcpu
,
struct
vmcb
*
vmcb12
)
{
if
(
!
nested_vmcb_valid_sregs
(
vcpu
,
&
vmcb12
->
save
))
return
false
;
return
nested_vmcb_check_controls
(
&
vmcb12
->
control
);
}
static
void
nested_load_control_from_vmcb12
(
struct
vcpu_svm
*
svm
,
struct
vmcb_control_area
*
control
)
{
...
...
@@ -449,7 +448,14 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12
}
kvm_set_rflags
(
&
svm
->
vcpu
,
vmcb12
->
save
.
rflags
|
X86_EFLAGS_FIXED
);
svm_set_efer
(
&
svm
->
vcpu
,
vmcb12
->
save
.
efer
);
/*
* Force-set EFER_SVME even though it is checked earlier on the
* VMCB12, because the guest can flip the bit between the check
* and now. Clearing EFER_SVME would call svm_free_nested.
*/
svm_set_efer
(
&
svm
->
vcpu
,
vmcb12
->
save
.
efer
|
EFER_SVME
);
svm_set_cr0
(
&
svm
->
vcpu
,
vmcb12
->
save
.
cr0
);
svm_set_cr4
(
&
svm
->
vcpu
,
vmcb12
->
save
.
cr4
);
...
...
@@ -564,7 +570,6 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa,
WARN_ON
(
svm
->
vmcb
==
svm
->
nested
.
vmcb02
.
ptr
);
nested_svm_copy_common_state
(
svm
->
vmcb01
.
ptr
,
svm
->
nested
.
vmcb02
.
ptr
);
nested_load_control_from_vmcb12
(
svm
,
&
vmcb12
->
control
);
svm_switch_vmcb
(
svm
,
&
svm
->
nested
.
vmcb02
);
nested_vmcb02_prepare_control
(
svm
);
...
...
@@ -614,7 +619,10 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu)
if
(
WARN_ON_ONCE
(
!
svm
->
nested
.
initialized
))
return
-
EINVAL
;
if
(
!
nested_vmcb_checks
(
vcpu
,
vmcb12
))
{
nested_load_control_from_vmcb12
(
svm
,
&
vmcb12
->
control
);
if
(
!
nested_vmcb_valid_sregs
(
vcpu
,
&
vmcb12
->
save
)
||
!
nested_vmcb_check_controls
(
&
svm
->
nested
.
ctl
))
{
vmcb12
->
control
.
exit_code
=
SVM_EXIT_ERR
;
vmcb12
->
control
.
exit_code_hi
=
0
;
vmcb12
->
control
.
exit_info_1
=
0
;
...
...
@@ -1251,7 +1259,7 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
/*
* Processor state contains L2 state. Check that it is
* valid for guest mode (see nested_vmcb_check
s
).
* valid for guest mode (see nested_vmcb_check
_save
).
*/
cr0
=
kvm_read_cr0
(
vcpu
);
if
(((
cr0
&
X86_CR0_CD
)
==
0
)
&&
(
cr0
&
X86_CR0_NW
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录