Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
526b78ad
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 3 年多
通知
13
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
526b78ad
编写于
5月 13, 2010
作者:
A
Avi Kivity
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
KVM: x86: Lock arch specific vcpu ioctls centrally
Signed-off-by:
N
Avi Kivity
<
avi@redhat.com
>
上级
2122ff5e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
2 addition
and
39 deletion
+2
-39
arch/x86/kvm/x86.c
arch/x86/kvm/x86.c
+2
-39
未找到文件。
arch/x86/kvm/x86.c
浏览文件 @
526b78ad
...
...
@@ -1541,16 +1541,12 @@ static int __msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs,
{
int
i
,
idx
;
vcpu_load
(
vcpu
);
idx
=
srcu_read_lock
(
&
vcpu
->
kvm
->
srcu
);
for
(
i
=
0
;
i
<
msrs
->
nmsrs
;
++
i
)
if
(
do_msr
(
vcpu
,
entries
[
i
].
index
,
&
entries
[
i
].
data
))
break
;
srcu_read_unlock
(
&
vcpu
->
kvm
->
srcu
,
idx
);
vcpu_put
(
vcpu
);
return
i
;
}
...
...
@@ -1798,7 +1794,6 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
if
(
copy_from_user
(
cpuid_entries
,
entries
,
cpuid
->
nent
*
sizeof
(
struct
kvm_cpuid_entry
)))
goto
out_free
;
vcpu_load
(
vcpu
);
for
(
i
=
0
;
i
<
cpuid
->
nent
;
i
++
)
{
vcpu
->
arch
.
cpuid_entries
[
i
].
function
=
cpuid_entries
[
i
].
function
;
vcpu
->
arch
.
cpuid_entries
[
i
].
eax
=
cpuid_entries
[
i
].
eax
;
...
...
@@ -1816,7 +1811,6 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
r
=
0
;
kvm_apic_set_version
(
vcpu
);
kvm_x86_ops
->
cpuid_update
(
vcpu
);
vcpu_put
(
vcpu
);
out_free:
vfree
(
cpuid_entries
);
...
...
@@ -1837,11 +1831,9 @@ static int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
if
(
copy_from_user
(
&
vcpu
->
arch
.
cpuid_entries
,
entries
,
cpuid
->
nent
*
sizeof
(
struct
kvm_cpuid_entry2
)))
goto
out
;
vcpu_load
(
vcpu
);
vcpu
->
arch
.
cpuid_nent
=
cpuid
->
nent
;
kvm_apic_set_version
(
vcpu
);
kvm_x86_ops
->
cpuid_update
(
vcpu
);
vcpu_put
(
vcpu
);
return
0
;
out:
...
...
@@ -1854,7 +1846,6 @@ static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
{
int
r
;
vcpu_load
(
vcpu
);
r
=
-
E2BIG
;
if
(
cpuid
->
nent
<
vcpu
->
arch
.
cpuid_nent
)
goto
out
;
...
...
@@ -1866,7 +1857,6 @@ static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
out:
cpuid
->
nent
=
vcpu
->
arch
.
cpuid_nent
;
vcpu_put
(
vcpu
);
return
r
;
}
...
...
@@ -2098,9 +2088,7 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
static
int
kvm_vcpu_ioctl_get_lapic
(
struct
kvm_vcpu
*
vcpu
,
struct
kvm_lapic_state
*
s
)
{
vcpu_load
(
vcpu
);
memcpy
(
s
->
regs
,
vcpu
->
arch
.
apic
->
regs
,
sizeof
*
s
);
vcpu_put
(
vcpu
);
return
0
;
}
...
...
@@ -2108,11 +2096,9 @@ static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu,
static
int
kvm_vcpu_ioctl_set_lapic
(
struct
kvm_vcpu
*
vcpu
,
struct
kvm_lapic_state
*
s
)
{
vcpu_load
(
vcpu
);
memcpy
(
vcpu
->
arch
.
apic
->
regs
,
s
->
regs
,
sizeof
*
s
);
kvm_apic_post_state_restore
(
vcpu
);
update_cr8_intercept
(
vcpu
);
vcpu_put
(
vcpu
);
return
0
;
}
...
...
@@ -2124,20 +2110,15 @@ static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
return
-
EINVAL
;
if
(
irqchip_in_kernel
(
vcpu
->
kvm
))
return
-
ENXIO
;
vcpu_load
(
vcpu
);
kvm_queue_interrupt
(
vcpu
,
irq
->
irq
,
false
);
vcpu_put
(
vcpu
);
return
0
;
}
static
int
kvm_vcpu_ioctl_nmi
(
struct
kvm_vcpu
*
vcpu
)
{
vcpu_load
(
vcpu
);
kvm_inject_nmi
(
vcpu
);
vcpu_put
(
vcpu
);
return
0
;
}
...
...
@@ -2157,7 +2138,6 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
int
r
;
unsigned
bank_num
=
mcg_cap
&
0xff
,
bank
;
vcpu_load
(
vcpu
);
r
=
-
EINVAL
;
if
(
!
bank_num
||
bank_num
>=
KVM_MAX_MCE_BANKS
)
goto
out
;
...
...
@@ -2172,7 +2152,6 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
for
(
bank
=
0
;
bank
<
bank_num
;
bank
++
)
vcpu
->
arch
.
mce_banks
[
bank
*
4
]
=
~
(
u64
)
0
;
out:
vcpu_put
(
vcpu
);
return
r
;
}
...
...
@@ -2230,8 +2209,6 @@ static int kvm_vcpu_ioctl_x86_set_mce(struct kvm_vcpu *vcpu,
static
void
kvm_vcpu_ioctl_x86_get_vcpu_events
(
struct
kvm_vcpu
*
vcpu
,
struct
kvm_vcpu_events
*
events
)
{
vcpu_load
(
vcpu
);
events
->
exception
.
injected
=
vcpu
->
arch
.
exception
.
pending
&&
!
kvm_exception_is_soft
(
vcpu
->
arch
.
exception
.
nr
);
...
...
@@ -2256,8 +2233,6 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
events
->
flags
=
(
KVM_VCPUEVENT_VALID_NMI_PENDING
|
KVM_VCPUEVENT_VALID_SIPI_VECTOR
|
KVM_VCPUEVENT_VALID_SHADOW
);
vcpu_put
(
vcpu
);
}
static
int
kvm_vcpu_ioctl_x86_set_vcpu_events
(
struct
kvm_vcpu
*
vcpu
,
...
...
@@ -2268,8 +2243,6 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
|
KVM_VCPUEVENT_VALID_SHADOW
))
return
-
EINVAL
;
vcpu_load
(
vcpu
);
vcpu
->
arch
.
exception
.
pending
=
events
->
exception
.
injected
;
vcpu
->
arch
.
exception
.
nr
=
events
->
exception
.
nr
;
vcpu
->
arch
.
exception
.
has_error_code
=
events
->
exception
.
has_error_code
;
...
...
@@ -2292,22 +2265,16 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
if
(
events
->
flags
&
KVM_VCPUEVENT_VALID_SIPI_VECTOR
)
vcpu
->
arch
.
sipi_vector
=
events
->
sipi_vector
;
vcpu_put
(
vcpu
);
return
0
;
}
static
void
kvm_vcpu_ioctl_x86_get_debugregs
(
struct
kvm_vcpu
*
vcpu
,
struct
kvm_debugregs
*
dbgregs
)
{
vcpu_load
(
vcpu
);
memcpy
(
dbgregs
->
db
,
vcpu
->
arch
.
db
,
sizeof
(
vcpu
->
arch
.
db
));
dbgregs
->
dr6
=
vcpu
->
arch
.
dr6
;
dbgregs
->
dr7
=
vcpu
->
arch
.
dr7
;
dbgregs
->
flags
=
0
;
vcpu_put
(
vcpu
);
}
static
int
kvm_vcpu_ioctl_x86_set_debugregs
(
struct
kvm_vcpu
*
vcpu
,
...
...
@@ -2316,14 +2283,10 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
if
(
dbgregs
->
flags
)
return
-
EINVAL
;
vcpu_load
(
vcpu
);
memcpy
(
vcpu
->
arch
.
db
,
dbgregs
->
db
,
sizeof
(
vcpu
->
arch
.
db
));
vcpu
->
arch
.
dr6
=
dbgregs
->
dr6
;
vcpu
->
arch
.
dr7
=
dbgregs
->
dr7
;
vcpu_put
(
vcpu
);
return
0
;
}
...
...
@@ -2335,6 +2298,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
int
r
;
struct
kvm_lapic_state
*
lapic
=
NULL
;
vcpu_load
(
vcpu
);
switch
(
ioctl
)
{
case
KVM_GET_LAPIC
:
{
r
=
-
EINVAL
;
...
...
@@ -2481,9 +2445,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
r
=
-
EFAULT
;
if
(
copy_from_user
(
&
mce
,
argp
,
sizeof
mce
))
goto
out
;
vcpu_load
(
vcpu
);
r
=
kvm_vcpu_ioctl_x86_set_mce
(
vcpu
,
&
mce
);
vcpu_put
(
vcpu
);
break
;
}
case
KVM_GET_VCPU_EVENTS
:
{
...
...
@@ -2534,6 +2496,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
r
=
-
EINVAL
;
}
out:
vcpu_put
(
vcpu
);
kfree
(
lapic
);
return
r
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录