Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
5818dee5
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,发现更多精彩内容 >>
提交
5818dee5
编写于
1月 10, 2012
作者:
E
Edgar E. Iglesias
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
microblaze: Emulate the hw stackprotector
Signed-off-by:
N
Edgar E. Iglesias
<
edgar.iglesias@gmail.com
>
上级
48b5e96f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
0 deletion
+48
-0
target-microblaze/cpu.h
target-microblaze/cpu.h
+3
-0
target-microblaze/helper.h
target-microblaze/helper.h
+1
-0
target-microblaze/op_helper.c
target-microblaze/op_helper.c
+11
-0
target-microblaze/translate.c
target-microblaze/translate.c
+33
-0
未找到文件。
target-microblaze/cpu.h
浏览文件 @
5818dee5
...
...
@@ -93,6 +93,7 @@ struct CPUMBState;
#define ESR_EC_DIVZERO 5
#define ESR_EC_FPU 6
#define ESR_EC_PRIVINSN 7
#define ESR_EC_STACKPROT 7
/* Same as PRIVINSN. */
#define ESR_EC_DATA_STORAGE 8
#define ESR_EC_INSN_STORAGE 9
#define ESR_EC_DATA_TLB 10
...
...
@@ -235,6 +236,8 @@ typedef struct CPUMBState {
uint32_t
regs
[
33
];
uint32_t
sregs
[
24
];
float_status
fp_status
;
/* Stack protectors. Yes, it's a hw feature. */
uint32_t
slr
,
shr
;
/* Internal flags. */
#define IMM_FLAG 4
...
...
target-microblaze/helper.h
浏览文件 @
5818dee5
...
...
@@ -33,6 +33,7 @@ DEF_HELPER_2(mmu_write, void, i32, i32)
#endif
DEF_HELPER_4
(
memalign
,
void
,
i32
,
i32
,
i32
,
i32
)
DEF_HELPER_1
(
stackprot
,
void
,
i32
)
DEF_HELPER_2
(
get
,
i32
,
i32
,
i32
)
DEF_HELPER_3
(
put
,
void
,
i32
,
i32
,
i32
)
...
...
target-microblaze/op_helper.c
浏览文件 @
5818dee5
...
...
@@ -483,6 +483,17 @@ void helper_memalign(uint32_t addr, uint32_t dr, uint32_t wr, uint32_t mask)
}
}
void
helper_stackprot
(
uint32_t
addr
)
{
if
(
addr
<
env
->
slr
||
addr
>
env
->
shr
)
{
qemu_log
(
"Stack protector violation at %x %x %x
\n
"
,
addr
,
env
->
slr
,
env
->
shr
);
env
->
sregs
[
SR_EAR
]
=
addr
;
env
->
sregs
[
SR_ESR
]
=
ESR_EC_STACKPROT
;
helper_raise_exception
(
EXCP_HW_EXCP
);
}
}
#if !defined(CONFIG_USER_ONLY)
/* Writes/reads to the MMU's special regs end up here. */
uint32_t
helper_mmu_read
(
uint32_t
rn
)
...
...
target-microblaze/translate.c
浏览文件 @
5818dee5
...
...
@@ -526,6 +526,12 @@ static void dec_msr(DisasContext *dc)
case
0x7
:
tcg_gen_andi_tl
(
cpu_SR
[
SR_FSR
],
cpu_R
[
dc
->
ra
],
31
);
break
;
case
0x800
:
tcg_gen_st_tl
(
cpu_R
[
dc
->
ra
],
cpu_env
,
offsetof
(
CPUState
,
slr
));
break
;
case
0x802
:
tcg_gen_st_tl
(
cpu_R
[
dc
->
ra
],
cpu_env
,
offsetof
(
CPUState
,
shr
));
break
;
default:
cpu_abort
(
dc
->
env
,
"unknown mts reg %x
\n
"
,
sr
);
break
;
...
...
@@ -552,6 +558,12 @@ static void dec_msr(DisasContext *dc)
case
0xb
:
tcg_gen_mov_tl
(
cpu_R
[
dc
->
rd
],
cpu_SR
[
SR_BTR
]);
break
;
case
0x800
:
tcg_gen_ld_tl
(
cpu_R
[
dc
->
rd
],
cpu_env
,
offsetof
(
CPUState
,
slr
));
break
;
case
0x802
:
tcg_gen_ld_tl
(
cpu_R
[
dc
->
rd
],
cpu_env
,
offsetof
(
CPUState
,
shr
));
break
;
case
0x2000
:
case
0x2001
:
case
0x2002
:
...
...
@@ -864,6 +876,13 @@ static inline void gen_load(DisasContext *dc, TCGv dst, TCGv addr,
static
inline
TCGv
*
compute_ldst_addr
(
DisasContext
*
dc
,
TCGv
*
t
)
{
unsigned
int
extimm
=
dc
->
tb_flags
&
IMM_FLAG
;
/* Should be set to one if r1 is used by loadstores. */
int
stackprot
=
0
;
/* All load/stores use ra. */
if
(
dc
->
ra
==
1
)
{
stackprot
=
1
;
}
/* Treat the common cases first. */
if
(
!
dc
->
type_b
)
{
...
...
@@ -874,8 +893,16 @@ static inline TCGv *compute_ldst_addr(DisasContext *dc, TCGv *t)
return
&
cpu_R
[
dc
->
ra
];
}
if
(
dc
->
rb
==
1
)
{
stackprot
=
1
;
}
*
t
=
tcg_temp_new
();
tcg_gen_add_tl
(
*
t
,
cpu_R
[
dc
->
ra
],
cpu_R
[
dc
->
rb
]);
if
(
stackprot
)
{
gen_helper_stackprot
(
*
t
);
}
return
t
;
}
/* Immediate. */
...
...
@@ -891,6 +918,9 @@ static inline TCGv *compute_ldst_addr(DisasContext *dc, TCGv *t)
tcg_gen_add_tl
(
*
t
,
cpu_R
[
dc
->
ra
],
*
(
dec_alu_op_b
(
dc
)));
}
if
(
stackprot
)
{
gen_helper_stackprot
(
*
t
);
}
return
t
;
}
...
...
@@ -1917,6 +1947,9 @@ void cpu_reset (CPUState *env)
memset
(
env
,
0
,
offsetof
(
CPUMBState
,
breakpoints
));
tlb_flush
(
env
,
1
);
/* Disable stack protector. */
env
->
shr
=
~
0
;
env
->
pvr
.
regs
[
0
]
=
PVR0_PVR_FULL_MASK
\
|
PVR0_USE_BARREL_MASK
\
|
PVR0_USE_DIV_MASK
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录