[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/13] i386: hvf: Drop regs in HVFX86EmulatorState
From: |
Roman Bolshakov |
Subject: |
[PATCH 10/13] i386: hvf: Drop regs in HVFX86EmulatorState |
Date: |
Thu, 28 May 2020 22:37:55 +0300 |
HVFX86EmulatorState carries it's own copy of x86 registers. It can be
dropped in favor of regs in generic CPUX86State.
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
target/i386/hvf/x86.h | 13 +++++++------
target/i386/hvf/x86_emu.c | 18 +++++++++---------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h
index f0d03faff9..6048b5cc74 100644
--- a/target/i386/hvf/x86.h
+++ b/target/i386/hvf/x86.h
@@ -235,13 +235,14 @@ typedef struct lazy_flags {
/* Definition of hvf_x86_state is here */
struct HVFX86EmulatorState {
- struct x86_register regs[16];
struct lazy_flags lflags;
uint8_t mmio_buf[4096];
};
/* useful register access macros */
-#define RRX(cpu, reg) (cpu->hvf_emul->regs[reg].rrx)
+#define x86_reg(cpu, reg) ((x86_register *) &cpu->regs[reg])
+
+#define RRX(cpu, reg) (x86_reg(cpu, reg)->rrx)
#define RAX(cpu) RRX(cpu, R_EAX)
#define RCX(cpu) RRX(cpu, R_ECX)
#define RDX(cpu) RRX(cpu, R_EDX)
@@ -259,7 +260,7 @@ struct HVFX86EmulatorState {
#define R14(cpu) RRX(cpu, R_R14)
#define R15(cpu) RRX(cpu, R_R15)
-#define ERX(cpu, reg) (cpu->hvf_emul->regs[reg].erx)
+#define ERX(cpu, reg) (x86_reg(cpu, reg)->erx)
#define EAX(cpu) ERX(cpu, R_EAX)
#define ECX(cpu) ERX(cpu, R_ECX)
#define EDX(cpu) ERX(cpu, R_EDX)
@@ -269,7 +270,7 @@ struct HVFX86EmulatorState {
#define ESI(cpu) ERX(cpu, R_ESI)
#define EDI(cpu) ERX(cpu, R_EDI)
-#define RX(cpu, reg) (cpu->hvf_emul->regs[reg].rx)
+#define RX(cpu, reg) (x86_reg(cpu, reg)->rx)
#define AX(cpu) RX(cpu, R_EAX)
#define CX(cpu) RX(cpu, R_ECX)
#define DX(cpu) RX(cpu, R_EDX)
@@ -279,13 +280,13 @@ struct HVFX86EmulatorState {
#define SI(cpu) RX(cpu, R_ESI)
#define DI(cpu) RX(cpu, R_EDI)
-#define RL(cpu, reg) (cpu->hvf_emul->regs[reg].lx)
+#define RL(cpu, reg) (x86_reg(cpu, reg)->lx)
#define AL(cpu) RL(cpu, R_EAX)
#define CL(cpu) RL(cpu, R_ECX)
#define DL(cpu) RL(cpu, R_EDX)
#define BL(cpu) RL(cpu, R_EBX)
-#define RH(cpu, reg) (cpu->hvf_emul->regs[reg].hx)
+#define RH(cpu, reg) (x86_reg(cpu, reg)->hx)
#define AH(cpu) RH(cpu, R_EAX)
#define CH(cpu) RH(cpu, R_ECX)
#define DH(cpu) RH(cpu, R_EDX)
diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c
index 04fac64e72..1ad2c30e16 100644
--- a/target/i386/hvf/x86_emu.c
+++ b/target/i386/hvf/x86_emu.c
@@ -95,13 +95,13 @@ target_ulong read_reg(CPUX86State *env, int reg, int size)
{
switch (size) {
case 1:
- return env->hvf_emul->regs[reg].lx;
+ return x86_reg(env, reg)->lx;
case 2:
- return env->hvf_emul->regs[reg].rx;
+ return x86_reg(env, reg)->rx;
case 4:
- return env->hvf_emul->regs[reg].erx;
+ return x86_reg(env, reg)->erx;
case 8:
- return env->hvf_emul->regs[reg].rrx;
+ return x86_reg(env, reg)->rrx;
default:
abort();
}
@@ -112,16 +112,16 @@ void write_reg(CPUX86State *env, int reg, target_ulong
val, int size)
{
switch (size) {
case 1:
- env->hvf_emul->regs[reg].lx = val;
+ x86_reg(env, reg)->lx = val;
break;
case 2:
- env->hvf_emul->regs[reg].rx = val;
+ x86_reg(env, reg)->rx = val;
break;
case 4:
- env->hvf_emul->regs[reg].rrx = (uint32_t)val;
+ x86_reg(env, reg)->rrx = (uint32_t)val;
break;
case 8:
- env->hvf_emul->regs[reg].rrx = val;
+ x86_reg(env, reg)->rrx = val;
break;
default:
abort();
@@ -173,7 +173,7 @@ 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)
{
- return (ptr - (target_ulong)&env->hvf_emul->regs[0]) <
sizeof(env->hvf_emul->regs);
+ return (ptr - (target_ulong)&env->regs[0]) < sizeof(env->regs);
}
void write_val_ext(struct CPUX86State *env, target_ulong ptr, target_ulong
val, int size)
--
2.26.1
- [PATCH 00/13] i386: hvf: Remove HVFX86EmulatorState, Roman Bolshakov, 2020/05/28
- [PATCH 03/13] i386: hvf: Clean stray includes in sysemu, Roman Bolshakov, 2020/05/28
- [PATCH 02/13] i386: hvf: Drop useless declarations in sysemu, Roman Bolshakov, 2020/05/28
- [PATCH 01/13] i386: hvf: Move HVFState definition into hvf, Roman Bolshakov, 2020/05/28
- [PATCH 04/13] i386: hvf: Drop unused variable, Roman Bolshakov, 2020/05/28
- [PATCH 06/13] i386: hvf: Use IP from CPUX86State, Roman Bolshakov, 2020/05/28
- [PATCH 08/13] i386: hvf: Drop rflags from HVFX86EmulatorState, Roman Bolshakov, 2020/05/28
- [PATCH 05/13] i386: hvf: Use ins_len to advance IP, Roman Bolshakov, 2020/05/28
- [PATCH 07/13] i386: hvf: Drop fetch_rip from HVFX86EmulatorState, Roman Bolshakov, 2020/05/28
- [PATCH 10/13] i386: hvf: Drop regs in HVFX86EmulatorState,
Roman Bolshakov <=
- [PATCH 11/13] i386: hvf: Move lazy_flags into CPUX86State, Roman Bolshakov, 2020/05/28
- [PATCH 12/13] i386: hvf: Move mmio_buf into CPUX86State, Roman Bolshakov, 2020/05/28
- [PATCH 09/13] i386: hvf: Drop copy of RFLAGS defines, Roman Bolshakov, 2020/05/28
- [PATCH 13/13] i386: hvf: Drop HVFX86EmulatorState, Roman Bolshakov, 2020/05/28
- Re: [PATCH 00/13] i386: hvf: Remove HVFX86EmulatorState, no-reply, 2020/05/28