Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libtcg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton
libtcg
Commits
bab456f1
Commit
bab456f1
authored
1 year ago
by
Anton
Browse files
Options
Downloads
Patches
Plain Diff
Initialize tb more carefully
parent
44e5a763
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libtcg/libtcg.c
+20
-12
20 additions, 12 deletions
libtcg/libtcg.c
with
20 additions
and
12 deletions
libtcg/libtcg.c
+
20
−
12
View file @
bab456f1
...
...
@@ -17,6 +17,8 @@
#include
"qemu.h"
#include
"qemu/osdep.h"
#include
"cpu.h"
#include
"cpu-param.h"
#include
"tcg/insn-start-words.h"
#include
"disas/disas.h"
#include
"exec/exec-all.h"
#include
"exec/translator.h"
...
...
@@ -178,9 +180,6 @@ LibTcgInstructionList libtcg_translate(LibTcgContext *context,
};
context
->
cpu
->
opaque
=
&
region
;
/* Needed to initialize fields in `tcg_ctx` */
tcg_func_start
(
tcg_ctx
);
vaddr
pc
;
uint64_t
cs_base
;
uint32_t
flags
;
...
...
@@ -210,21 +209,30 @@ LibTcgInstructionList libtcg_translate(LibTcgContext *context,
}
cflags
|=
CF_NO_GOTO_TB
;
/*
* Initialize backend fields to avoid
* triggering asserts in tcg_func_start
* */
tcg_ctx
->
addr_type
=
TARGET_LONG_BITS
==
32
?
TCG_TYPE_I32
:
TCG_TYPE_I64
;
tcg_ctx
->
insn_start_words
=
TARGET_INSN_START_WORDS
;
/* Needed to initialize fields in `tcg_ctx` */
tcg_func_start
(
tcg_ctx
);
/*
* Set `max_insns` to the number of bytes in the buffer
* so we don't have to worry about it being too small.
*/
int
max_insns
=
size
;
TranslationBlock
tb
=
{
.
pc
=
pc
,
.
cs_base
=
cs_base
,
.
max_pc
=
virtual_address
+
size
,
.
flags
=
flags
,
.
cflags
=
cflags
,
};
TranslationBlock
*
tb
=
tcg_tb_alloc
(
tcg_ctx
);
tb
->
pc
=
pc
;
tb
->
cs_base
=
cs_base
;
tb
->
max_pc
=
virtual_address
+
size
;
tb
->
flags
=
flags
;
tb
->
cflags
=
cflags
;
void
*
host_pc
=
NULL
;
gen_intermediate_code
(
context
->
cpu
,
&
tb
,
&
max_insns
,
pc
,
host_pc
);
gen_intermediate_code
(
context
->
cpu
,
tb
,
&
max_insns
,
pc
,
host_pc
);
LibTcgInstructionList
instruction_list
=
{
.
list
=
context
->
desc
.
mem_alloc
(
sizeof
(
LibTcgInstruction
)
*
tcg_ctx
->
nb_ops
),
...
...
@@ -237,7 +245,7 @@ LibTcgInstructionList libtcg_translate(LibTcgContext *context,
.
labels
=
context
->
desc
.
mem_alloc
(
sizeof
(
LibTcgLabel
)
*
(
tcg_ctx
->
nb_labels
)),
.
label_count
=
0
,
.
size_in_bytes
=
tb
.
size
,
.
size_in_bytes
=
tb
->
size
,
};
assert
(
instruction_list
.
list
!=
NULL
&&
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment