Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
NEMU
提交
b74d6c2d
N
NEMU
项目概览
OpenXiangShan
/
NEMU
11 个月 前同步成功
通知
7
Star
171
Fork
67
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NEMU
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b74d6c2d
编写于
11月 24, 2018
作者:
Z
Zihao Yu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
monitor,diff-test: add "attach" and "detach" for DiffTest
* they can be used to enable/disable DiffTest during run time
上级
22d7ad05
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
98 addition
and
3 deletion
+98
-3
include/memory/memory.h
include/memory/memory.h
+1
-0
src/cpu/exec/exec.c
src/cpu/exec/exec.c
+1
-1
src/cpu/reg.c
src/cpu/reg.c
+8
-0
src/memory/memory.c
src/memory/memory.c
+0
-2
src/monitor/debug/ui.c
src/monitor/debug/ui.c
+31
-0
src/monitor/diff-test/diff-test.c
src/monitor/diff-test/diff-test.c
+57
-0
未找到文件。
include/memory/memory.h
浏览文件 @
b74d6c2d
...
...
@@ -3,6 +3,7 @@
#include "common.h"
#define PMEM_SIZE (128 * 1024 * 1024)
extern
uint8_t
pmem
[];
/* convert the guest physical address in the guest program to host virtual address in NEMU */
...
...
src/cpu/exec/exec.c
浏览文件 @
b74d6c2d
...
...
@@ -178,7 +178,7 @@ make_group(gp7,
/* 0x90 */
EMPTY
,
EMPTY
,
EMPTY
,
IDEXW
(
setcc_E
,
setcc
,
1
),
/* 0x94 */
IDEXW
(
setcc_E
,
setcc
,
1
),
IDEXW
(
setcc_E
,
setcc
,
1
),
IDEXW
(
setcc_E
,
setcc
,
1
),
EMPTY
,
/* 0x98 */
EMPTY
,
EMPTY
,
EMPTY
,
EMPTY
,
/* 0x9c */
EMPTY
,
EMPTY
,
EMPTY
,
IDEXW
(
setcc_E
,
setcc
,
1
),
/* 0x9c */
EMPTY
,
EMPTY
,
IDEXW
(
setcc_E
,
setcc
,
1
)
,
IDEXW
(
setcc_E
,
setcc
,
1
),
/* 0xa0 */
EMPTY
,
EMPTY
,
EMPTY
,
EMPTY
,
/* 0xa4 */
IDEX
(
Ib_G2E
,
shld
),
IDEX
(
cl_G2E
,
shld
),
EMPTY
,
EMPTY
,
/* 0xa8 */
EMPTY
,
EMPTY
,
EMPTY
,
EMPTY
,
...
...
src/cpu/reg.c
浏览文件 @
b74d6c2d
...
...
@@ -41,3 +41,11 @@ void reg_test() {
assert
(
eip_sample
==
cpu
.
eip
);
}
void
display_reg
()
{
int
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
printf
(
"%s: 0x%08x
\n
"
,
regsl
[
i
],
cpu
.
gpr
[
i
].
_32
);
}
printf
(
"eip: 0x%08x
\n
"
,
cpu
.
eip
);
}
src/memory/memory.c
浏览文件 @
b74d6c2d
...
...
@@ -2,8 +2,6 @@
#include "device/mmio.h"
#include "memory/mmu.h"
#define PMEM_SIZE (128 * 1024 * 1024)
#define pmem_rw(addr, type) *(type *)({\
Assert(addr < PMEM_SIZE, "physical address(0x%08x) is out of bound", addr); \
guest_to_host(addr); \
...
...
src/monitor/debug/ui.c
浏览文件 @
b74d6c2d
...
...
@@ -32,12 +32,40 @@ static int cmd_c(char *args) {
return
0
;
}
static
int
cmd_si
(
char
*
args
)
{
/* extract the first argument */
char
*
arg
=
strtok
(
NULL
,
" "
);
if
(
arg
==
NULL
)
{
/* no argument given */
cpu_exec
(
1
);
}
else
{
int
n
=
strtol
(
arg
,
NULL
,
10
);
printf
(
"si %d
\n
"
,
n
);
cpu_exec
(
n
);
}
return
0
;
}
static
int
cmd_q
(
char
*
args
)
{
return
-
1
;
}
static
int
cmd_help
(
char
*
args
);
void
difftest_detach
();
void
difftest_attach
();
static
int
cmd_detach
(
char
*
args
)
{
difftest_detach
();
return
0
;
}
static
int
cmd_attach
(
char
*
args
)
{
difftest_attach
();
return
0
;
}
static
struct
{
char
*
name
;
char
*
description
;
...
...
@@ -45,6 +73,9 @@ static struct {
}
cmd_table
[]
=
{
{
"help"
,
"Display informations about all supported commands"
,
cmd_help
},
{
"c"
,
"Continue the execution of the program"
,
cmd_c
},
{
"si"
,
"step"
,
cmd_si
},
{
"detach"
,
"detach diff test"
,
cmd_detach
},
{
"attach"
,
"attach diff test"
,
cmd_attach
},
{
"q"
,
"Exit NEMU"
,
cmd_q
},
/* TODO: Add more commands */
...
...
src/monitor/diff-test/diff-test.c
浏览文件 @
b74d6c2d
...
...
@@ -12,6 +12,7 @@ static void (*ref_difftest_exec)(uint64_t n);
static
bool
is_skip_ref
;
static
bool
is_skip_dut
;
static
uint32_t
eflags_skip_mask
;
static
bool
is_detach
;
void
difftest_skip_ref
()
{
is_skip_ref
=
true
;
}
void
difftest_skip_dut
()
{
is_skip_dut
=
true
;
}
...
...
@@ -78,6 +79,8 @@ void init_difftest(char *ref_so_file, long img_size) {
void
difftest_step
(
uint32_t
eip
)
{
CPU_state
ref_r
;
if
(
is_detach
)
return
;
if
(
is_skip_dut
)
{
is_skip_dut
=
false
;
return
;
...
...
@@ -121,3 +124,57 @@ void difftest_step(uint32_t eip) {
eflags_skip_mask
=
0
;
}
}
void
difftest_detach
()
{
is_detach
=
true
;
}
void
difftest_attach
()
{
#ifndef DIFF_TEST
return
;
#endif
is_detach
=
false
;
is_skip_ref
=
false
;
is_skip_dut
=
false
;
// first copy the image
ref_difftest_memcpy_from_dut
(
ENTRY_START
,
guest_to_host
(
ENTRY_START
),
PMEM_SIZE
-
ENTRY_START
);
// then set some special registers
uint8_t
code
[]
=
{
// we put this code at 0x7e00
0xb8
,
0x00
,
0x00
,
0x00
,
0x00
,
// mov $0x0, %eax
0x0f
,
0x22
,
0xd8
,
// mov %eax, %cr3
0xb8
,
0x00
,
0x00
,
0x00
,
0x00
,
// mov $0x0, %eax
0x0f
,
0x22
,
0xc0
,
// mov %eax, %cr0
0x0f
,
0x01
,
0x1d
,
0x40
,
0x7e
,
0x00
,
0x00
,
// lidtl (0x7e40)
};
uint8_t
idtdesc
[
6
];
*
(
uint32_t
*
)(
code
+
1
)
=
cpu
.
cr3
.
val
;
*
(
uint32_t
*
)(
code
+
9
)
=
cpu
.
cr0
.
val
;
idtdesc
[
0
]
=
cpu
.
idtr
.
limit
&
0xff
;
idtdesc
[
1
]
=
cpu
.
idtr
.
limit
>>
8
;
*
(
uint32_t
*
)(
idtdesc
+
2
)
=
cpu
.
idtr
.
base
;
assert
(
sizeof
(
code
)
<
0x40
);
ref_difftest_memcpy_from_dut
(
0x7e00
,
code
,
sizeof
(
code
));
ref_difftest_memcpy_from_dut
(
0x7e40
,
idtdesc
,
sizeof
(
idtdesc
));
CPU_state
r
=
cpu
;
r
.
eip
=
0x7e00
;
ref_difftest_setregs
(
&
r
);
ref_difftest_exec
(
5
);
//rtl_computer_eflags(&cpu.eflags);
cpu
.
eflags
=
(
cpu
.
OF
<<
EFLAGS_BIT_OF
)
|
(
cpu
.
CF
<<
EFLAGS_BIT_CF
)
|
(
cpu
.
IF
<<
EFLAGS_BIT_IF
)
|
(
cpu
.
SF
<<
EFLAGS_BIT_SF
)
|
(
cpu
.
CF
<<
EFLAGS_BIT_CF
);
ref_difftest_setregs
(
&
cpu
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录