Skip to content

Commit

Permalink
Merge pull request #9 from ndesh26/qsim_v26
Browse files Browse the repository at this point in the history
fix memop size calculation for i386
  • Loading branch information
pranith committed Mar 11, 2018
2 parents d458dba + 2705b6f commit 11c2cc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions target-i386/mem_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ extern int get_cpuidx(CPUX86State *env);

extern CPUX86State* get_env(int cpu_idx);

static void memop_callback(CPUX86State *env, target_ulong vaddr,
target_ulong size, int type);

/* broken thread support */

#if defined(CONFIG_USER_ONLY)
Expand Down Expand Up @@ -94,7 +97,9 @@ void helper_cmpxchg8b(CPUX86State *env, target_ulong a0)
int eflags;

eflags = cpu_cc_compute_all(env, CC_OP);
memop_callback(env, a0, 8, 0);
d = cpu_ldq_data_ra(env, a0, GETPC());
memop_callback(env, a0, 8, 1);
if (d == (((uint64_t)env->regs[R_EDX] << 32) | (uint32_t)env->regs[R_EAX])) {
cpu_stq_data_ra(env, a0, ((uint64_t)env->regs[R_ECX] << 32)
| (uint32_t)env->regs[R_EBX], GETPC());
Expand All @@ -119,8 +124,10 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0)
raise_exception_ra(env, EXCP0D_GPF, GETPC());
}
eflags = cpu_cc_compute_all(env, CC_OP);
memop_callback(env, a0, 16, 0);
d0 = cpu_ldq_data_ra(env, a0, GETPC());
d1 = cpu_ldq_data_ra(env, a0 + 8, GETPC());
memop_callback(env, a0, 16, 1);
if (d0 == env->regs[R_EAX] && d1 == env->regs[R_EDX]) {
cpu_stq_data_ra(env, a0, env->regs[R_EBX], GETPC());
cpu_stq_data_ra(env, a0 + 8, env->regs[R_ECX], GETPC());
Expand All @@ -141,6 +148,7 @@ void helper_boundw(CPUX86State *env, target_ulong a0, int v)
{
int low, high;

memop_callback(env, a0, 4, 0);
low = cpu_ldsw_data_ra(env, a0, GETPC());
high = cpu_ldsw_data_ra(env, a0 + 2, GETPC());
v = (int16_t)v;
Expand All @@ -156,6 +164,7 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v)
{
int low, high;

memop_callback(env, a0, 8, 0);
low = cpu_ldl_data_ra(env, a0, GETPC());
high = cpu_ldl_data_ra(env, a0 + 4, GETPC());
if (v < low || v > high) {
Expand Down
8 changes: 4 additions & 4 deletions target-i386/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ do { \
hret = tcg_temp_new_i64(); \
tcg_gen_qemu_ld_tl(hret, addr, idx, mop); \
gen_helper_store_callback_pre(cpu_env, addr, \
tcg_const_i32(1 << (idx & MO_SIZE)), data); \
tcg_const_i32(1 << (mop & MO_SIZE)), data); \
} \
tcg_gen_qemu_st_tl(data, addr, idx, mop); \
if (qsim_gen_callbacks) { \
gen_helper_store_callback_post(cpu_env, addr, \
tcg_const_i32(1 << (idx & MO_SIZE)), data); \
tcg_const_i32(1 << (mop & MO_SIZE)), data); \
tcg_temp_free_i64(hret); \
} \
} while (0)
Expand All @@ -148,12 +148,12 @@ do { \
hret = tcg_temp_new_i64(); \
tcg_gen_qemu_ld_tl(hret, addr, idx, mop); \
gen_helper_load_callback_pre(cpu_env, addr, \
tcg_const_i32(1 << (idx & MO_SIZE)), tcg_const_i32(0)); \
tcg_const_i32(1 << (mop & MO_SIZE)), tcg_const_i32(0)); \
} \
tcg_gen_qemu_ld_tl(data, addr, idx, mop); \
if (qsim_gen_callbacks) { \
gen_helper_load_callback_post(cpu_env, addr, \
tcg_const_i32(1 << (idx & MO_SIZE)), tcg_const_i32(0)); \
tcg_const_i32(1 << (mop & MO_SIZE)), tcg_const_i32(0)); \
tcg_temp_free_i64(hret); \
} \
} while (0)
Expand Down

0 comments on commit 11c2cc9

Please sign in to comment.