Exit early when invalid read happens
In this way, the target register won't be overwritten
This commit is contained in:
parent
e5756b79f8
commit
3ea7857be3
@ -1484,6 +1484,11 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,
|
||||
if (mr == NULL) {
|
||||
uc->invalid_error = UC_ERR_MAP;
|
||||
cpu_exit(uc->cpu);
|
||||
// XXX(@lazymio): We have to exit early so that the target register won't be overwritten
|
||||
// because qemu might generate tcg code like:
|
||||
// qemu_ld_i64 x0,x1,leq,8 sync: 0 dead: 0 1
|
||||
// where we don't have a change to recover x0 value
|
||||
cpu_loop_exit(uc->cpu);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -1491,6 +1496,8 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,
|
||||
uc->invalid_error = error_code;
|
||||
// printf("***** Invalid fetch (unmapped memory) at " TARGET_FMT_lx "\n", addr);
|
||||
cpu_exit(uc->cpu);
|
||||
// See comments above
|
||||
cpu_loop_exit(uc->cpu);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1533,6 +1540,8 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,
|
||||
uc->invalid_error = UC_ERR_READ_PROT;
|
||||
// printf("***** Invalid memory read (non-readable) at " TARGET_FMT_lx "\n", addr);
|
||||
cpu_exit(uc->cpu);
|
||||
// See comments above
|
||||
cpu_loop_exit(uc->cpu);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1561,6 +1570,8 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,
|
||||
uc->invalid_error = UC_ERR_FETCH_PROT;
|
||||
// printf("***** Invalid fetch (non-executable) at " TARGET_FMT_lx "\n", addr);
|
||||
cpu_exit(uc->cpu);
|
||||
// See comments above
|
||||
cpu_loop_exit(uc->cpu);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ static void test_arm64_block_invalid_mem_read_write_sync(void)
|
||||
OK(uc_reg_read(uc, UC_ARM64_REG_X1, &r_x1));
|
||||
|
||||
TEST_CHECK(r_pc == code_start + 8);
|
||||
// TEST_CHECK(r_x0 == 1); // Unfortunately this can't be guarantee-ed
|
||||
TEST_CHECK(r_x0 == 1);
|
||||
TEST_CHECK(r_x1 == 2);
|
||||
|
||||
OK(uc_close(uc));
|
||||
|
Loading…
x
Reference in New Issue
Block a user