initial i386 hvf

This commit is contained in:
espes 2018-09-27 10:37:48 +08:00
parent 09d1d09697
commit 2911dda2dc
6 changed files with 22 additions and 18 deletions

2
configure vendored
View File

@ -220,7 +220,7 @@ supported_hvf_target() {
test "$hvf" = "yes" || return 1
glob "$1" "*-softmmu" || return 1
case "${1%-softmmu}" in
x86_64)
i386|x86_64)
return 0
;;
esac

View File

@ -1687,9 +1687,9 @@ calc_addr:
}
}
target_ulong get_reg_ref(CPUX86State *env, int reg, int is_extended, int rex, int size)
uintptr_t get_reg_ref(CPUX86State *env, int reg, int is_extended, int rex, int size)
{
target_ulong ptr = 0;
uintptr_t ptr = 0;
int which = 0;
if (is_extended) {
@ -1701,15 +1701,15 @@ target_ulong get_reg_ref(CPUX86State *env, int reg, int is_extended, int rex, in
case 1:
if (rex || is_extended || reg < 4) {
which = 1;
ptr = (target_ulong)&RL(env, reg);
ptr = (uintptr_t)&RL(env, reg);
} else {
which = 2;
ptr = (target_ulong)&RH(env, reg - 4);
ptr = (uintptr_t)&RH(env, reg - 4);
}
break;
default:
which = 3;
ptr = (target_ulong)&RRX(env, reg);
ptr = (uintptr_t)&RRX(env, reg);
break;
}
return ptr;

View File

@ -266,7 +266,7 @@ typedef struct x86_decode_op {
int reg;
target_ulong val;
target_ulong ptr;
uintptr_t ptr;
} x86_decode_op;
typedef struct x86_decode {
@ -303,7 +303,7 @@ uint64_t sign(uint64_t val, int size);
uint32_t decode_instruction(CPUX86State *env, struct x86_decode *decode);
target_ulong get_reg_ref(CPUX86State *env, int reg, int is_extended, int rex, int size);
uintptr_t get_reg_ref(CPUX86State *env, int reg, int is_extended, int rex, int size);
target_ulong get_reg_val(CPUX86State *env, int reg, int is_extended, int rex, int size);
void calc_modrm_operand(CPUX86State *env, struct x86_decode *decode,
struct x86_decode_op *op);

View File

@ -128,7 +128,7 @@ void write_reg(CPUX86State *env, int reg, target_ulong val, int size)
}
}
target_ulong read_val_from_reg(target_ulong reg_ptr, int size)
target_ulong read_val_from_reg(uintptr_t reg_ptr, int size)
{
target_ulong val;
@ -151,7 +151,7 @@ target_ulong read_val_from_reg(target_ulong reg_ptr, int size)
return val;
}
void write_val_to_reg(target_ulong reg_ptr, target_ulong val, int size)
void write_val_to_reg(uintptr_t reg_ptr, target_ulong val, int size)
{
switch (size) {
case 1:
@ -171,12 +171,12 @@ void write_val_to_reg(target_ulong reg_ptr, target_ulong val, int size)
}
}
static bool is_host_reg(struct CPUX86State *env, target_ulong ptr)
static bool is_host_reg(struct CPUX86State *env, uintptr_t ptr)
{
return (ptr - (target_ulong)&env->hvf_emul->regs[0]) < sizeof(env->hvf_emul->regs);
}
void write_val_ext(struct CPUX86State *env, target_ulong ptr, target_ulong val, int size)
void write_val_ext(struct CPUX86State *env, uintptr_t ptr, target_ulong val, int size)
{
if (is_host_reg(env, ptr)) {
write_val_to_reg(ptr, val, size);
@ -192,7 +192,7 @@ uint8_t *read_mmio(struct CPUX86State *env, target_ulong ptr, int bytes)
}
target_ulong read_val_ext(struct CPUX86State *env, target_ulong ptr, int size)
target_ulong read_val_ext(struct CPUX86State *env, uintptr_t ptr, int size)
{
target_ulong val;
uint8_t *mmio_ptr;

View File

@ -33,11 +33,11 @@ void simulate_wrmsr(struct CPUState *cpu);
target_ulong read_reg(CPUX86State *env, int reg, int size);
void write_reg(CPUX86State *env, int reg, target_ulong val, int size);
target_ulong read_val_from_reg(target_ulong reg_ptr, int size);
void write_val_to_reg(target_ulong reg_ptr, target_ulong val, int size);
void write_val_ext(struct CPUX86State *env, target_ulong ptr, target_ulong val, int size);
target_ulong read_val_from_reg(uintptr_t reg_ptr, int size);
void write_val_to_reg(uintptr_t reg_ptr, target_ulong val, int size);
void write_val_ext(struct CPUX86State *env, uintptr_t ptr, target_ulong val, int size);
uint8_t *read_mmio(struct CPUX86State *env, target_ulong ptr, int bytes);
target_ulong read_val_ext(struct CPUX86State *env, target_ulong ptr, int size);
target_ulong read_val_ext(struct CPUX86State *env, uintptr_t ptr, int size);
void exec_movzx(struct CPUX86State *env, struct x86_decode *decode);
void exec_shl(struct CPUX86State *env, struct x86_decode *decode);

View File

@ -258,6 +258,7 @@ int hvf_put_registers(CPUState *cpu_state)
wreg(cpu_state->hvf_fd, HV_X86_RSP, env->regs[R_ESP]);
wreg(cpu_state->hvf_fd, HV_X86_RSI, env->regs[R_ESI]);
wreg(cpu_state->hvf_fd, HV_X86_RDI, env->regs[R_EDI]);
#ifdef TARGET_X86_64
wreg(cpu_state->hvf_fd, HV_X86_R8, env->regs[8]);
wreg(cpu_state->hvf_fd, HV_X86_R9, env->regs[9]);
wreg(cpu_state->hvf_fd, HV_X86_R10, env->regs[10]);
@ -266,6 +267,7 @@ int hvf_put_registers(CPUState *cpu_state)
wreg(cpu_state->hvf_fd, HV_X86_R13, env->regs[13]);
wreg(cpu_state->hvf_fd, HV_X86_R14, env->regs[14]);
wreg(cpu_state->hvf_fd, HV_X86_R15, env->regs[15]);
#endif
wreg(cpu_state->hvf_fd, HV_X86_RFLAGS, env->eflags);
wreg(cpu_state->hvf_fd, HV_X86_RIP, env->eip);
@ -302,6 +304,7 @@ int hvf_get_registers(CPUState *cpu_state)
env->regs[R_ESP] = rreg(cpu_state->hvf_fd, HV_X86_RSP);
env->regs[R_ESI] = rreg(cpu_state->hvf_fd, HV_X86_RSI);
env->regs[R_EDI] = rreg(cpu_state->hvf_fd, HV_X86_RDI);
#ifdef TARGET_X86_64
env->regs[8] = rreg(cpu_state->hvf_fd, HV_X86_R8);
env->regs[9] = rreg(cpu_state->hvf_fd, HV_X86_R9);
env->regs[10] = rreg(cpu_state->hvf_fd, HV_X86_R10);
@ -310,7 +313,8 @@ int hvf_get_registers(CPUState *cpu_state)
env->regs[13] = rreg(cpu_state->hvf_fd, HV_X86_R13);
env->regs[14] = rreg(cpu_state->hvf_fd, HV_X86_R14);
env->regs[15] = rreg(cpu_state->hvf_fd, HV_X86_R15);
#endif
env->eflags = rreg(cpu_state->hvf_fd, HV_X86_RFLAGS);
env->eip = rreg(cpu_state->hvf_fd, HV_X86_RIP);