Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
39f21ee5
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看板
提交
39f21ee5
编写于
8月 18, 2010
作者:
A
Avi Kivity
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
KVM: x86 emulator: consolidate immediate decode into a function
Signed-off-by:
N
Avi Kivity
<
avi@redhat.com
>
上级
48bb5d3c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
64 addition
and
45 deletion
+64
-45
arch/x86/kvm/emulate.c
arch/x86/kvm/emulate.c
+64
-45
未找到文件。
arch/x86/kvm/emulate.c
浏览文件 @
39f21ee5
...
...
@@ -2541,6 +2541,55 @@ static struct opcode twobyte_table[256] = {
#undef GD
#undef I
static
unsigned
imm_size
(
struct
decode_cache
*
c
)
{
unsigned
size
;
size
=
(
c
->
d
&
ByteOp
)
?
1
:
c
->
op_bytes
;
if
(
size
==
8
)
size
=
4
;
return
size
;
}
static
int
decode_imm
(
struct
x86_emulate_ctxt
*
ctxt
,
struct
operand
*
op
,
unsigned
size
,
bool
sign_extension
)
{
struct
decode_cache
*
c
=
&
ctxt
->
decode
;
struct
x86_emulate_ops
*
ops
=
ctxt
->
ops
;
int
rc
=
X86EMUL_CONTINUE
;
op
->
type
=
OP_IMM
;
op
->
bytes
=
size
;
op
->
addr
.
mem
=
c
->
eip
;
/* NB. Immediates are sign-extended as necessary. */
switch
(
op
->
bytes
)
{
case
1
:
op
->
val
=
insn_fetch
(
s8
,
1
,
c
->
eip
);
break
;
case
2
:
op
->
val
=
insn_fetch
(
s16
,
2
,
c
->
eip
);
break
;
case
4
:
op
->
val
=
insn_fetch
(
s32
,
4
,
c
->
eip
);
break
;
}
if
(
!
sign_extension
)
{
switch
(
op
->
bytes
)
{
case
1
:
op
->
val
&=
0xff
;
break
;
case
2
:
op
->
val
&=
0xffff
;
break
;
case
4
:
op
->
val
&=
0xffffffff
;
break
;
}
}
done:
return
rc
;
}
int
x86_decode_insn
(
struct
x86_emulate_ctxt
*
ctxt
)
{
...
...
@@ -2730,52 +2779,19 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt)
c
->
src
=
memop
;
break
;
case
SrcImmU16
:
c
->
src
.
bytes
=
2
;
goto
srcimm
;
case
SrcImm
:
case
SrcImmU
:
c
->
src
.
bytes
=
(
c
->
d
&
ByteOp
)
?
1
:
c
->
op_bytes
;
if
(
c
->
src
.
bytes
==
8
)
c
->
src
.
bytes
=
4
;
srcimm:
c
->
src
.
type
=
OP_IMM
;
c
->
src
.
addr
.
mem
=
c
->
eip
;
/* NB. Immediates are sign-extended as necessary. */
switch
(
c
->
src
.
bytes
)
{
case
1
:
c
->
src
.
val
=
insn_fetch
(
s8
,
1
,
c
->
eip
);
break
;
case
2
:
c
->
src
.
val
=
insn_fetch
(
s16
,
2
,
c
->
eip
);
rc
=
decode_imm
(
ctxt
,
&
c
->
src
,
2
,
false
);
break
;
case
4
:
c
->
src
.
val
=
insn_fetch
(
s32
,
4
,
c
->
eip
);
break
;
}
if
((
c
->
d
&
SrcMask
)
==
SrcImmU
||
(
c
->
d
&
SrcMask
)
==
SrcImmU16
)
{
switch
(
c
->
src
.
bytes
)
{
case
1
:
c
->
src
.
val
&=
0xff
;
break
;
case
2
:
c
->
src
.
val
&=
0xffff
;
break
;
case
4
:
c
->
src
.
val
&=
0xffffffff
;
case
SrcImm
:
rc
=
decode_imm
(
ctxt
,
&
c
->
src
,
imm_size
(
c
),
true
);
break
;
}
}
case
SrcImmU
:
rc
=
decode_imm
(
ctxt
,
&
c
->
src
,
imm_size
(
c
),
false
);
break
;
case
SrcImmByte
:
rc
=
decode_imm
(
ctxt
,
&
c
->
src
,
1
,
true
);
break
;
case
SrcImmUByte
:
c
->
src
.
type
=
OP_IMM
;
c
->
src
.
addr
.
mem
=
c
->
eip
;
c
->
src
.
bytes
=
1
;
if
((
c
->
d
&
SrcMask
)
==
SrcImmByte
)
c
->
src
.
val
=
insn_fetch
(
s8
,
1
,
c
->
eip
);
else
c
->
src
.
val
=
insn_fetch
(
u8
,
1
,
c
->
eip
);
rc
=
decode_imm
(
ctxt
,
&
c
->
src
,
1
,
false
);
break
;
case
SrcAcc
:
c
->
src
.
type
=
OP_REG
;
...
...
@@ -2807,6 +2823,9 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt)
break
;
}
if
(
rc
!=
X86EMUL_CONTINUE
)
goto
done
;
/*
* Decode and fetch the second source operand: register, memory
* or immediate.
...
...
@@ -2819,10 +2838,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt)
c
->
src2
.
val
=
c
->
regs
[
VCPU_REGS_RCX
]
&
0x8
;
break
;
case
Src2ImmByte
:
c
->
src2
.
type
=
OP_IMM
;
c
->
src2
.
addr
.
mem
=
c
->
eip
;
c
->
src2
.
bytes
=
1
;
c
->
src2
.
val
=
insn_fetch
(
u8
,
1
,
c
->
eip
);
rc
=
decode_imm
(
ctxt
,
&
c
->
src2
,
1
,
true
);
break
;
case
Src2One
:
c
->
src2
.
bytes
=
1
;
...
...
@@ -2830,6 +2846,9 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt)
break
;
}
if
(
rc
!=
X86EMUL_CONTINUE
)
goto
done
;
/* Decode and fetch the destination operand: register or memory. */
switch
(
c
->
d
&
DstMask
)
{
case
DstReg
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录