Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
28ecfd7a
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
28ecfd7a
编写于
8月 26, 2013
作者:
A
Andreas Färber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cpu: Move icount_decr field from CPU_COMMON to CPUState
Signed-off-by:
N
Andreas Färber
<
afaerber@suse.de
>
上级
efee7340
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
40 addition
and
38 deletion
+40
-38
cpu-exec.c
cpu-exec.c
+2
-2
cpus.c
cpus.c
+6
-7
include/exec/cpu-defs.h
include/exec/cpu-defs.h
+0
-20
include/exec/gen-icount.h
include/exec/gen-icount.h
+4
-2
include/qom/cpu.h
include/qom/cpu.h
+19
-0
qom/cpu.c
qom/cpu.c
+1
-0
translate-all.c
translate-all.c
+8
-7
未找到文件。
cpu-exec.c
浏览文件 @
28ecfd7a
...
...
@@ -649,7 +649,7 @@ int cpu_exec(CPUArchState *env)
/* Instruction counter expired. */
int
insns_left
;
tb
=
(
TranslationBlock
*
)(
next_tb
&
~
TB_EXIT_MASK
);
insns_left
=
env
->
icount_decr
.
u32
;
insns_left
=
cpu
->
icount_decr
.
u32
;
if
(
cpu
->
icount_extra
&&
insns_left
>=
0
)
{
/* Refill decrementer and continue execution. */
cpu
->
icount_extra
+=
insns_left
;
...
...
@@ -659,7 +659,7 @@ int cpu_exec(CPUArchState *env)
insns_left
=
cpu
->
icount_extra
;
}
cpu
->
icount_extra
-=
insns_left
;
env
->
icount_decr
.
u16
.
low
=
insns_left
;
cpu
->
icount_decr
.
u16
.
low
=
insns_left
;
}
else
{
if
(
insns_left
>
0
)
{
/* Execute remaining instructions. */
...
...
cpus.c
浏览文件 @
28ecfd7a
...
...
@@ -139,11 +139,10 @@ static int64_t cpu_get_icount_locked(void)
icount
=
qemu_icount
;
if
(
cpu
)
{
CPUArchState
*
env
=
cpu
->
env_ptr
;
if
(
!
cpu_can_do_io
(
cpu
))
{
fprintf
(
stderr
,
"Bad clock read
\n
"
);
}
icount
-=
(
env
->
icount_decr
.
u16
.
low
+
cpu
->
icount_extra
);
icount
-=
(
cpu
->
icount_decr
.
u16
.
low
+
cpu
->
icount_extra
);
}
return
qemu_icount_bias
+
(
icount
<<
icount_time_shift
);
}
...
...
@@ -1249,8 +1248,8 @@ static int tcg_cpu_exec(CPUArchState *env)
int64_t
count
;
int64_t
deadline
;
int
decr
;
qemu_icount
-=
(
env
->
icount_decr
.
u16
.
low
+
cpu
->
icount_extra
);
env
->
icount_decr
.
u16
.
low
=
0
;
qemu_icount
-=
(
cpu
->
icount_decr
.
u16
.
low
+
cpu
->
icount_extra
);
cpu
->
icount_decr
.
u16
.
low
=
0
;
cpu
->
icount_extra
=
0
;
deadline
=
qemu_clock_deadline_ns_all
(
QEMU_CLOCK_VIRTUAL
);
...
...
@@ -1267,7 +1266,7 @@ static int tcg_cpu_exec(CPUArchState *env)
qemu_icount
+=
count
;
decr
=
(
count
>
0xffff
)
?
0xffff
:
count
;
count
-=
decr
;
env
->
icount_decr
.
u16
.
low
=
decr
;
cpu
->
icount_decr
.
u16
.
low
=
decr
;
cpu
->
icount_extra
=
count
;
}
ret
=
cpu_exec
(
env
);
...
...
@@ -1277,8 +1276,8 @@ static int tcg_cpu_exec(CPUArchState *env)
if
(
use_icount
)
{
/* Fold pending instructions back into the
instruction counter, and clear the interrupt flag. */
qemu_icount
-=
(
env
->
icount_decr
.
u16
.
low
+
cpu
->
icount_extra
);
env
->
icount_decr
.
u32
=
0
;
qemu_icount
-=
(
cpu
->
icount_decr
.
u16
.
low
+
cpu
->
icount_extra
);
cpu
->
icount_decr
.
u32
=
0
;
cpu
->
icount_extra
=
0
;
}
return
ret
;
...
...
include/exec/cpu-defs.h
浏览文件 @
28ecfd7a
...
...
@@ -118,18 +118,6 @@ QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));
#endif
#ifdef HOST_WORDS_BIGENDIAN
typedef
struct
icount_decr_u16
{
uint16_t
high
;
uint16_t
low
;
}
icount_decr_u16
;
#else
typedef
struct
icount_decr_u16
{
uint16_t
low
;
uint16_t
high
;
}
icount_decr_u16
;
#endif
typedef
struct
CPUBreakpoint
{
target_ulong
pc
;
int
flags
;
/* BP_* */
...
...
@@ -149,14 +137,6 @@ typedef struct CPUWatchpoint {
CPU_COMMON_TLB \
struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \
\
/* Number of cycles left, with interrupt flag in high bit. \
This allows a single read-compare-cbranch-write sequence to test \
for both decrementer underflow and exceptions. */
\
union { \
uint32_t u32; \
icount_decr_u16 u16; \
} icount_decr; \
\
/* from this point: preserved by CPU reset */
\
/* ice debug support */
\
QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \
...
...
include/exec/gen-icount.h
浏览文件 @
28ecfd7a
...
...
@@ -26,13 +26,15 @@ static inline void gen_tb_start(void)
icount_label
=
gen_new_label
();
count
=
tcg_temp_local_new_i32
();
tcg_gen_ld_i32
(
count
,
cpu_env
,
offsetof
(
CPUArchState
,
icount_decr
.
u32
));
tcg_gen_ld_i32
(
count
,
cpu_env
,
-
ENV_OFFSET
+
offsetof
(
CPUState
,
icount_decr
.
u32
));
/* This is a horrid hack to allow fixing up the value later. */
icount_arg
=
tcg_ctx
.
gen_opparam_ptr
+
1
;
tcg_gen_subi_i32
(
count
,
count
,
0xdeadbeef
);
tcg_gen_brcondi_i32
(
TCG_COND_LT
,
count
,
0
,
icount_label
);
tcg_gen_st16_i32
(
count
,
cpu_env
,
offsetof
(
CPUArchState
,
icount_decr
.
u16
.
low
));
tcg_gen_st16_i32
(
count
,
cpu_env
,
-
ENV_OFFSET
+
offsetof
(
CPUState
,
icount_decr
.
u16
.
low
));
tcg_temp_free_i32
(
count
);
}
...
...
include/qom/cpu.h
浏览文件 @
28ecfd7a
...
...
@@ -138,6 +138,18 @@ typedef struct CPUClass {
const
char
*
gdb_core_xml_file
;
}
CPUClass
;
#ifdef HOST_WORDS_BIGENDIAN
typedef
struct
icount_decr_u16
{
uint16_t
high
;
uint16_t
low
;
}
icount_decr_u16
;
#else
typedef
struct
icount_decr_u16
{
uint16_t
low
;
uint16_t
high
;
}
icount_decr_u16
;
#endif
struct
KVMState
;
struct
kvm_run
;
...
...
@@ -158,6 +170,9 @@ struct kvm_run;
* CPU and return to its top level loop.
* @singlestep_enabled: Flags for single-stepping.
* @icount_extra: Instructions until next timer event.
* @icount_decr: Number of cycles left, with interrupt flag in high bit.
* This allows a single read-compare-cbranch-write sequence to test
* for both decrementer underflow and exceptions.
* @can_do_io: Nonzero if memory-mapped IO is safe.
* @env_ptr: Pointer to subclass-specific CPUArchState field.
* @current_tb: Currently executing TB.
...
...
@@ -223,6 +238,10 @@ struct CPUState {
/* TODO Move common fields from CPUArchState here. */
int
cpu_index
;
/* used by alpha TCG */
uint32_t
halted
;
/* used by alpha, cris, ppc TCG */
union
{
uint32_t
u32
;
icount_decr_u16
u16
;
}
icount_decr
;
uint32_t
can_do_io
;
};
...
...
qom/cpu.c
浏览文件 @
28ecfd7a
...
...
@@ -242,6 +242,7 @@ static void cpu_common_reset(CPUState *cpu)
cpu
->
mem_io_pc
=
0
;
cpu
->
mem_io_vaddr
=
0
;
cpu
->
icount_extra
=
0
;
cpu
->
icount_decr
.
u32
=
0
;
cpu
->
can_do_io
=
0
;
}
...
...
translate-all.c
浏览文件 @
28ecfd7a
...
...
@@ -217,7 +217,7 @@ static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,
if
(
use_icount
)
{
/* Reset the cycle counter to the start of the block. */
env
->
icount_decr
.
u16
.
low
+=
tb
->
icount
;
cpu
->
icount_decr
.
u16
.
low
+=
tb
->
icount
;
/* Clear the IO flag. */
cpu
->
can_do_io
=
0
;
}
...
...
@@ -242,7 +242,7 @@ static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,
while
(
s
->
gen_opc_instr_start
[
j
]
==
0
)
{
j
--
;
}
env
->
icount_decr
.
u16
.
low
-=
s
->
gen_opc_icount
[
j
];
cpu
->
icount_decr
.
u16
.
low
-=
s
->
gen_opc_icount
[
j
];
restore_state_to_opc
(
env
,
tb
,
j
);
...
...
@@ -1409,7 +1409,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask)
}
if
(
use_icount
)
{
env
->
icount_decr
.
u16
.
high
=
0xffff
;
cpu
->
icount_decr
.
u16
.
high
=
0xffff
;
if
(
!
cpu_can_do_io
(
cpu
)
&&
(
mask
&
~
old_mask
)
!=
0
)
{
cpu_abort
(
env
,
"Raised interrupt while not in I/O function"
);
...
...
@@ -1425,6 +1425,7 @@ CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
must be at the end of the TB */
void
cpu_io_recompile
(
CPUArchState
*
env
,
uintptr_t
retaddr
)
{
CPUState
*
cpu
=
ENV_GET_CPU
(
env
);
TranslationBlock
*
tb
;
uint32_t
n
,
cflags
;
target_ulong
pc
,
cs_base
;
...
...
@@ -1435,11 +1436,11 @@ void cpu_io_recompile(CPUArchState *env, uintptr_t retaddr)
cpu_abort
(
env
,
"cpu_io_recompile: could not find TB for pc=%p"
,
(
void
*
)
retaddr
);
}
n
=
env
->
icount_decr
.
u16
.
low
+
tb
->
icount
;
n
=
cpu
->
icount_decr
.
u16
.
low
+
tb
->
icount
;
cpu_restore_state_from_tb
(
tb
,
env
,
retaddr
);
/* Calculate how many instructions had been executed before the fault
occurred. */
n
=
n
-
env
->
icount_decr
.
u16
.
low
;
n
=
n
-
cpu
->
icount_decr
.
u16
.
low
;
/* Generate a new TB ending on the I/O insn. */
n
++
;
/* On MIPS and SH, delay slot instructions can only be restarted if
...
...
@@ -1449,14 +1450,14 @@ void cpu_io_recompile(CPUArchState *env, uintptr_t retaddr)
#if defined(TARGET_MIPS)
if
((
env
->
hflags
&
MIPS_HFLAG_BMASK
)
!=
0
&&
n
>
1
)
{
env
->
active_tc
.
PC
-=
4
;
env
->
icount_decr
.
u16
.
low
++
;
cpu
->
icount_decr
.
u16
.
low
++
;
env
->
hflags
&=
~
MIPS_HFLAG_BMASK
;
}
#elif defined(TARGET_SH4)
if
((
env
->
flags
&
((
DELAY_SLOT
|
DELAY_SLOT_CONDITIONAL
)))
!=
0
&&
n
>
1
)
{
env
->
pc
-=
2
;
env
->
icount_decr
.
u16
.
low
++
;
cpu
->
icount_decr
.
u16
.
low
++
;
env
->
flags
&=
~
(
DELAY_SLOT
|
DELAY_SLOT_CONDITIONAL
);
}
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录