cpu-exec: Purge all uses of ENV_GET_CPU()

Remove un-needed usages of ENV_GET_CPU() by converting the APIs to use
CPUState pointers and retrieving the env_ptr as minimally needed.

Scripted conversion for target-* change:

for I in target-*/cpu.h; do
sed -i \
's/\(^int cpu_[^_]*_exec(\)[^ ][^ ]* \*s);$/\1CPUState *cpu);/' \
$I;
done

Backports commit ea3e9847408131abc840240bd61e892d28459452 from qemu
This commit is contained in:
Peter Crosthwaite 2018-02-14 14:59:56 -05:00 committed by Lioncash
parent 9e23308b66
commit e51f8c9f6f
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
7 changed files with 25 additions and 25 deletions

View file

@ -28,10 +28,10 @@
#include "uc_priv.h"
static tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr);
static TranslationBlock *tb_find_slow(CPUArchState *env, target_ulong pc,
static TranslationBlock *tb_find_slow(CPUState *cpu, target_ulong pc,
target_ulong cs_base, uint64_t flags);
static TranslationBlock *tb_find_fast(CPUArchState *env);
static void cpu_handle_debug_exception(CPUArchState *env);
static TranslationBlock *tb_find_fast(CPUState *cpu);
static void cpu_handle_debug_exception(CPUState *cpu);
void cpu_loop_exit(CPUState *cpu)
{
@ -55,9 +55,9 @@ void cpu_resume_from_signal(CPUState *cpu, void *puc)
/* main execution loop */
int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
int cpu_exec(struct uc_struct *uc, CPUState *cpu)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUArchState *env = cpu->env_ptr;
TCGContext *tcg_ctx = env->uc->tcg_ctx;
CPUClass *cc = CPU_GET_CLASS(uc, cpu);
#ifdef TARGET_I386
@ -116,7 +116,7 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
/* exit request from the cpu execution loop */
ret = cpu->exception_index;
if (ret == EXCP_DEBUG) {
cpu_handle_debug_exception(env);
cpu_handle_debug_exception(cpu);
}
break;
} else {
@ -211,7 +211,7 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
cpu->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(cpu);
}
tb = tb_find_fast(env); // qq
tb = tb_find_fast(cpu); // UNICORN
if (!tb) { // invalid TB due to invalid code?
uc->invalid_error = UC_ERR_FETCH_UNMAPPED;
ret = EXCP_HLT;
@ -243,7 +243,7 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
if (likely(!cpu->exit_request)) {
tc_ptr = tb->tc_ptr;
/* execute the generated code */
next_tb = cpu_tb_exec(cpu, tc_ptr); // qq
next_tb = cpu_tb_exec(cpu, tc_ptr); // UNICORN
switch (next_tb & TB_EXIT_MASK) {
case TB_EXIT_REQUESTED:
@ -335,10 +335,12 @@ static tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr)
return next_tb;
}
static TranslationBlock *tb_find_slow(CPUArchState *env, target_ulong pc,
target_ulong cs_base, uint64_t flags) // qq
static TranslationBlock *tb_find_slow(CPUState *cpu,
target_ulong pc,
target_ulong cs_base,
uint64_t flags)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUArchState *env = (CPUArchState *)cpu->env_ptr;
TCGContext *tcg_ctx = env->uc->tcg_ctx;
TranslationBlock *tb, **ptb1;
unsigned int h;
@ -394,9 +396,9 @@ found:
return tb;
}
static TranslationBlock *tb_find_fast(CPUArchState *env) // qq
static TranslationBlock *tb_find_fast(CPUState *cpu)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUArchState *env = (CPUArchState *)cpu->env_ptr;
TranslationBlock *tb;
target_ulong cs_base, pc;
int flags;
@ -408,15 +410,14 @@ static TranslationBlock *tb_find_fast(CPUArchState *env) // qq
tb = cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
tb->flags != flags)) {
tb = tb_find_slow(env, pc, cs_base, flags); // qq
tb = tb_find_slow(cpu, pc, cs_base, flags); // qq
}
return tb;
}
static void cpu_handle_debug_exception(CPUArchState *env)
static void cpu_handle_debug_exception(CPUState *cpu)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUClass *cc = CPU_GET_CLASS(env->uc, cpu);
CPUClass *cc = CPU_GET_CLASS(cpu->uc, cpu);
CPUWatchpoint *wp;
if (!cpu->watchpoint_hit) {

View file

@ -117,8 +117,7 @@ static int qemu_tcg_init_vcpu(CPUState *cpu)
static int tcg_cpu_exec(struct uc_struct *uc, CPUState *cpu)
{
CPUArchState *env = cpu->env_ptr;
return cpu_exec(uc, env);
return cpu_exec(uc, cpu);
}
static bool tcg_exec_all(struct uc_struct* uc)

View file

@ -507,7 +507,7 @@ typedef struct CPUARMState {
#include "cpu-qom.h"
ARMCPU *cpu_arm_init(struct uc_struct *uc, const char *cpu_model);
int cpu_arm_exec(struct uc_struct *uc, CPUARMState *s);
int cpu_arm_exec(struct uc_struct *uc, CPUState *cpu);
uint32_t do_arm_semihosting(CPUARMState *env);
void aarch64_sync_32_to_64(CPUARMState *env);
void aarch64_sync_64_to_32(CPUARMState *env);

View file

@ -980,7 +980,7 @@ typedef struct CPUX86State {
#include "cpu-qom.h"
X86CPU *cpu_x86_create(struct uc_struct *uc, const char *cpu_model, Error **errp);
int cpu_x86_exec(struct uc_struct *uc, CPUX86State *s);
int cpu_x86_exec(struct uc_struct *uc, CPUState *cpu);
void x86_cpudef_setup(void);
int cpu_x86_support_mca_broadcast(CPUX86State *env);

View file

@ -121,7 +121,7 @@ typedef struct CPUM68KState {
void m68k_tcg_init(struct uc_struct *uc);
M68kCPU *cpu_m68k_init(struct uc_struct *uc, const char *cpu_model);
int cpu_m68k_exec(struct uc_struct *uc, CPUM68KState *s);
int cpu_m68k_exec(struct uc_struct *uc, CPUState *cpu);
/* you can call this signal handler from your SIGBUS and SIGSEGV
signal handlers to inform the virtual CPU of exceptions. non zero
is returned if the signal was handled by the virtual CPU. */

View file

@ -752,7 +752,7 @@ enum {
*/
#define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0
int cpu_mips_exec(struct uc_struct *uc, CPUMIPSState *s);
int cpu_mips_exec(struct uc_struct *uc, CPUState *cpu);
void mips_tcg_init(struct uc_struct *uc);
MIPSCPU *cpu_mips_init(struct uc_struct *uc, const char *cpu_model);
int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);

View file

@ -542,7 +542,7 @@ int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
void gen_intermediate_code_init(CPUSPARCState *env);
/* cpu-exec.c */
int cpu_sparc_exec(struct uc_struct *uc, CPUSPARCState *s);
int cpu_sparc_exec(struct uc_struct *uc, CPUState *cpu);
/* win_helper.c */
target_ulong cpu_get_psr(CPUSPARCState *env1);