target/i386/emulate: cleanups
cover target/i386/emulate: cleanups
These are some improvements to the x86 emulator that I wrote but have no way of testing (right now).
I tried to place them in order of importance so that, if something breaks, it is possible to commit a subset. I tried to compile the resulting code on Linux but I have not run it.
Patch 1 is just to fix warnings on Linux.
Patch 2 is the most important, as it fixes some real horrors in the code.
Patch 3 makes flags handling use algorithms somewhat similar to TCG. It should fix issues with 64-bit ALU operations, but it's also the one where it's more likely to have a mistake.
Patch 4 is comparatively trivial, though I cannot exclude any screwups.
It should be possible to test this with both HVF and Hyper-V.
Paolo
Paolo Bonzini (4):
target/i386/emulate: fix target_ulong format strings target/i386/emulate: stop overloading decode->op[N].ptr target/i386/emulate: mostly rewrite flags handling target/i386: remove lflags
target/i386/cpu.h | 6 - target/i386/emulate/x86_decode.h | 9 +- target/i386/emulate/x86_emu.h | 8 +- target/i386/emulate/x86_flags.h | 12 +- target/i386/emulate/x86_decode.c | 76 ++++++------ target/i386/emulate/x86_emu.c | 125 +++++++++---------- target/i386/emulate/x86_flags.c | 198 +++++++++++++------------------ 7 files changed, 197 insertions(+), 237 deletions(-)
Signature · 1 line
2.49.0
PATCH 1/4 target/i386/emulate: fix target_ulong format strings
Do not assume that TARGET_FMT_lx is %llx.
--- target/i386/emulate/x86_decode.c | 2 +- target/i386/emulate/x86_emu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
target/i386/emulate/x86_decode.c +1 -1
@@ -26,7 +26,7 @@static void decode_invalid (CPUX86State *env,struct x86_decode *decode) { -printf ("%llx: failed to decode instruction " , env->eip); +printf (TARGET_FMT_lx": failed to decode instruction " , env->eip);for (int i =0 ; i < decode->opcode_len; i++) {printf ("%x " , decode->opcode[i]); }
target/i386/emulate/x86_emu.c +1 -1
@@ -1241,7 +1241,7 @@ static void init_cmd_handler(void)bool exec_instruction (CPUX86State *env,struct x86_decode *ins) {if (!_cmd_handler[ins->cmd].handler) { -printf ("Unimplemented handler (%llx) for %d (%x %x) \n" , env->eip, +printf ("Unimplemented handler (" TARGET_FMT_lx") for %d (%x %x) \n" , env->eip, ins->cmd, ins->opcode[0 ], ins->opcode_len >1 ? ins->opcode[1 ] :0 ); env->eip += ins->len;
Signature · 1 line
2.49.0
PATCH 2/4 target/i386/emulate: stop overloading decode->op[N].ptr
In reply to Paolo Bonzinidecode->op[N].ptr can contain either a host pointer (!) in CPUState or a guest virtual address. Pass the whole struct to read_val_ext and write_val_ext, so that it can decide the contents based on the operand type.
--- target/i386/emulate/x86_decode.h | 9 ++- target/i386/emulate/x86_emu.h | 8 +-- target/i386/emulate/x86_decode.c | 74 +++++++++---------- target/i386/emulate/x86_emu.c | 119 ++++++++++++++++--------------- 4 files changed, 109 insertions(+), 101 deletions(-)
target/i386/emulate/x86_decode.h +6 -3
@@ -266,7 +266,10 @@ typedef struct x86_decode_op {int reg;target_ulong val; -target_ulong ptr; +union { +target_ulong addr; +void *regptr; + }; } x86_decode_op; typedef struct x86_decode {
@@ -301,8 +304,8 @@ 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 rex_present, -int is_extended,int size); +void *get_reg_ref (CPUX86State *env,int reg,int rex_present, +int is_extended,int size);target_ulong get_reg_val (CPUX86State *env,int reg,int rex_present,int is_extended,int size); void calc_modrm_operand(CPUX86State *env, struct x86_decode *decode,
target/i386/emulate/x86_emu.h +4 -4
@@ -42,11 +42,11 @@ void x86_emul_raise_exception(CPUX86State *env, int exception_index, int error_ctarget_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 (CPUX86State *env,target_ulong ptr,target_ulong val,int size); +target_ulong read_val_from_reg (void *reg_ptr,int size); +void write_val_to_reg (void *reg_ptr,target_ulong val,int size); +void write_val_ext (CPUX86State *env,struct x86_decode_op *decode,target_ulong val,int size);uint8_t *read_mmio (CPUX86State *env,target_ulong ptr,int bytes); -target_ulong read_val_ext (CPUX86State *env,target_ulong ptr,int size); +target_ulong read_val_ext (CPUX86State *env,struct x86_decode_op *decode,int size);void exec_movzx (CPUX86State *env,struct x86_decode *decode);void exec_shl (CPUX86State *env,struct x86_decode *decode);
target/i386/emulate/x86_decode.c +37 -37
194 lines not on this page · raw message
target/i386/emulate/x86_emu.c +62 -57
360 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH 2/4] target/i386/emulate: stop overloading decode->op[N].ptr
Quoted 30 lines · Paolo Bonzini
decode->op[N].ptr can contain either a host pointer (!) in CPUState or a guest virtual address. Pass the whole struct to
read_val_extandwrite_val_ext, so that it can decide the contents based on the operand type.Signed-off-by Paolo Bonzini <[email protected]>---
target/i386/emulate/x86_decode.h | 9 ++- target/i386/emulate/x86_emu.h | 8 +-- target/i386/emulate/x86_decode.c | 74 +++++++++---------- target/i386/emulate/x86_emu.c | 119 ++++++++++++++++--------------- 4 files changed, 109 insertions(+), 101 deletions(-)target/i386/emulate/x86_decode.h +4
-1@@ -266,7 +266,10 @@ typedef struct x86_decode_op {int reg;target_ulong val; -target_ulong ptr; +union { +target_ulong addr; +void *regptr; + }; } x86_decode_op; typedef struct x86_decode {
target/i386/emulate/x86_decode.h uint64_t sign(uint64_t val, int size); · line 308
Quoted 7 lines
target/i386/emulate/x86_decode.h +2
-2@@ -301,8 +304,8 @@ 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 rex_present, -int is_extended,int size); +void *get_reg_ref (CPUX86State *env,int reg,int rex_present, +int is_extended,int size);
Stray space after *, checkpatch should have cought it.
Regards,
BALATON Zoltan
Re: [PATCH 2/4] target/i386/emulate: stop overloading decode->op[N].ptr
In reply to Paolo BonziniHi Paolo,
Quoted 18 lines · Paolo Bonzini
decode->op[N].ptr can contain either a host pointer (!) in CPUState or a guest virtual address. Pass the whole struct to
read_val_extandwrite_val_ext, so that it can decide the contents based on the operand type.Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/emulate/x86_decode.h | 9 ++- target/i386/emulate/x86_emu.h | 8 +-- target/i386/emulate/x86_decode.c | 74 +++++++++---------- target/i386/emulate/x86_emu.c | 119 ++++++++++++++++--------------- 4 files changed, 109 insertions(+), 101 deletions(-)target/i386/emulate/x86_decode.h +0
-0
target/i386/emulate/x86_decode.h typedef struct x86_decode_op { · line 270
Quoted 6 lines
target/i386/emulate/x86_decode.h +2
-1@@ -266,7 +266,10 @@ typedef struct x86_decode_op {int reg;target_ulong val; -target_ulong ptr; +union { +target_ulong addr;
Prefer 'vaddr' type for "guest virtual address".
Quoted 3 lines
target/i386/emulate/x86_decode.h +2
-0+void *regptr; + }; } x86_decode_op;
Re: [PATCH 2/4] target/i386/emulate: stop overloading decode->op[N].ptr
Quoted 16 lines · Philippe Mathieu-Daudé
Hi Paolo,
Quoted 13 lines · Paolo Bonzini
decode->op[N].ptr can contain either a host pointer (!) in CPUState or a guest virtual address. Pass the whole struct to
read_val_extandwrite_val_ext, so that it can decide the contents based on the operand type.Signed-off-by Paolo Bonzini <[email protected]>---
target/i386/emulate/x86_decode.h| 9 ++- target/i386/emulate/x86_emu.h | 8 +--target/i386/emulate/x86_decode.c| 74 +++++++++---------- target/i386/emulate/x86_emu.c | 119 ++++++++++++++++---------------4 files changed, 109 insertions(+), 101 deletions(-)
Quoted 12 lines
target/i386/emulate/x86_decode.h typedef struct x86_decode_op { · line 269
Quoted 10 lines
target/i386/emulate/x86_decode.h +2
-1@@ -266,7 +266,10 @@ typedef struct x86_decode_op { int reg; target_ulong val; - target_ulong ptr; + union { + target_ulong addr;Prefer 'vaddr' type for "guest virtual address".
That would be a semantic change which I really want to avoid in this series.
I don't think target_long/target_ulong is a big blocker towards single-binary anyway. The trick is to confine it to target/, making it essentially a #define. That is, let target/* include one of two new headers target_long_32.h and target_long_64.h. See lore.kernel.org/r/[email protected] as well.
For the same reason I think target_long_bits() is a step in the wrong direction.
Paolo
Re: [PATCH 2/4] target/i386/emulate: stop overloading decode->op[N].ptr
Quoted 29 lines · Paolo Bonzini
Quoted 16 lines · Philippe Mathieu-Daudé
Hi Paolo,
Quoted 13 lines · Paolo Bonzini
decode->op[N].ptr can contain either a host pointer (!) in CPUState or a guest virtual address. Pass the whole struct to
read_val_extandwrite_val_ext, so that it can decide the contents based on the operand type.Signed-off-by Paolo Bonzini <[email protected]>---
target/i386/emulate/x86_decode.h| 9 ++- target/i386/emulate/x86_emu.h | 8 +--target/i386/emulate/x86_decode.c| 74 +++++++++---------- target/i386/emulate/x86_emu.c | 119 ++++++++++++++++---------------4 files changed, 109 insertions(+), 101 deletions(-)Quoted 12 lines
target/i386/emulate/x86_decode.h typedef struct x86_decode_op { · line 269
Quoted 10 lines
target/i386/emulate/x86_decode.h +2
-1@@ -266,7 +266,10 @@ typedef struct x86_decode_op { int reg; target_ulong val; - target_ulong ptr; + union { + target_ulong addr;Prefer 'vaddr' type for "guest virtual address".
Quoted 3 lines
That would be a semantic change which I really want to avoid in this series.
I don't think target_long/target_ulong is a big blocker towards single- binary anyway. The trick is to confine it to target/, making it essentially a #define. That is, let target/* include one of two new headers
target_long_32.hand target_long_64.h. See lore.kernel.org/ r/[email protected] as well.
Yes, I have this tagged to understand and address. Maybe Pierrick already understood the issue (similar mention from Richard? [1]) and is addressing it, see [2].
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 2 lines
For the same reason I think
target_long_bits()is a step in the wrong direction.
Re: [PATCH 2/4] target/i386/emulate: stop overloading decode->op[N].ptr
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 5 lines
I don't think target_long/target_ulong is a big blocker towards single- binary anyway. The trick is to confine it to target/, making it essentially a #define. That is, let target/* include one of two new headers
target_long_32.handtarget_long_64.h. See lore.kernel.org/ r/[email protected] as well.Yes, I have this tagged to understand and address. Maybe Pierrick already understood the issue (similar mention from Richard? [1]) and is addressing it, see [2].
Those are different. TCGv_vaddr is able to store a *host* pointer, i.e. a host uintptr_t. But target_long/target_ulong are already completely absent from tcg/ (there are a couple appearances in include/tcg), so I'm proposing to remove them completely and leave them as just macros.
Please give me a shout once the target-arm/ series lands, I can look into this further.
Paolo
Re: [PATCH 2/4] target/i386/emulate: stop overloading decode->op[N].ptr
Quoted 8 lines · Paolo Bonzini
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines
I don't think target_long/target_ulong is a big blocker towards single- binary anyway. The trick is to confine it to target/, making it essentially a #define. That is, let target/* include one of two new headers
target_long_32.handtarget_long_64.h. See lore.kernel.org/ r/[email protected] as well.
In an ideal world, it should be eliminated completely.
The root problem is that it creates variation of symbols/types, which obviously can't be unified later when we mix targets together. Of course, it's a paradigm shift, as QEMU traditionally was written with the "per target" approach in mind.
From this perspective, the only place where it could eventually survive is within static functions or types private to a compilation unit, only if this compilation unit is private to a unique target architecture (TARGET_AARCH64 only for instance).
But in this case, it's much more easy to get rid of it and replace with it the real type directly. So I don't see any good reason to keep it anywhere.
Our solution here is to "widen" the concerned definitions, using vaddr or uint64_t for target_ulong (vaddr is possible only for addresses, because we removed 64 bits guests support on 32 bits hosts - I hope it won't bite us later). For target_long, it's more tricky, as sign extension matters.
The problem is that it will necessarily break some stable interfaces, which were expecting a uint32_t before, but I think it's a necessary change to do at some point. But it can be done slowly and on a per target basis.
Quoted 10 lines
Quoted 3 lines
Yes, I have this tagged to understand and address. Maybe Pierrick already understood the issue (similar mention from Richard? [1]) and is addressing it, see [2].
Those are different.
TCGv_vaddris able to store a *host* pointer, i.e. a hostuintptr_t. But target_long/target_ulong are already completely absent from tcg/ (there are a couple appearances ininclude/tcg), so I'm proposing to remove them completely and leave them as just macros.
From what I understood, the original meaning is that vaddr can contain a *guest* pointer, and not a *host* pointer. Since 64 bits targets have been disabled for 32 bits hosts, vaddr definition was changed to uintptr_t, where it was uint64_t before. [1]
[1] https://gitlab.com/qemu-project/qemu/-/commit/a70af12addd9060fdf8f3dbd42b42e3072c3914f
Quoted 3 lines
Please give me a shout once the target-arm/ series lands, I can look into this further.
The current series is mostly complete, and focused on low hanging fruits. The one remaining are a bit harder, and/or have external dependencies, but I didn't see anything impossible so far.
Luckily, we didn't have a lot of target_ulong in Arm related structs, so it's pretty easy to change. Some other architectures (especially the ones using them in cpu.h) will be harder.
Quoted 2 lines
Paolo
Re: [PATCH 2/4] target/i386/emulate: stop overloading decode->op[N].ptr
In reply to Paolo BonziniQuoted 8 lines · Paolo Bonzini
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines
I don't think target_long/target_ulong is a big blocker towards single- binary anyway. The trick is to confine it to target/, making it essentially a #define. That is, let target/* include one of two new headers
target_long_32.handtarget_long_64.h. See lore.kernel.org/ r/[email protected] as well.
Quoted 6 lines
Quoted 3 lines
Yes, I have this tagged to understand and address. Maybe Pierrick already understood the issue (similar mention from Richard? [1]) and is addressing it, see [2].
Those are different.
TCGv_vaddris able to store a *host* pointer, i.e. a hostuintptr_t.
No, vaddr is about a guest pointer.
The state of affairs is slightly confusing because once we dropped 64-bit guests from 32-bit hosts, we subsequently made the simplifying assumption that a host pointer is never smaller than a guest pointer. Thus exec/vaddr.h has typedef uintptr_t vaddr.
Quoted 4 lines
But target_long/target_ulong are already
completely absent from tcg/ (there are a couple appearances ininclude/tcg), so I'm proposing to remove them completely and leave them as just macros.
The "problem" with target_long in target/arch/ occurs when target/arch/ is built twice, e.g. i386 vs x86_64, arm vs aarch64, etc.
We want to build these once. For the most part this already works, e.g. qemu-system-x86_64 running 32-bit cpus just fine. That relies on the wider value of target_long, so we can avoid ambiguity by using a different type. In this case, if we really do want to represent a guest virtual address, then "vaddr" is the best type to use.
r~
PATCH 3/4 target/i386/emulate: mostly rewrite flags handling
In reply to Paolo BonziniWhile Bochs's algorithms are pretty solid, there are small opportunities to improve them or to make their logic more similar to TCG's handling of condition codes.
- use a single bit for the difference between bits 0..7 of result and PF. This is useful because "set only ZF" is not a common case.
- place SD in the same place as SF
- move CF and PO at bits 62 and 63 when target_ulong is 64-bits wide, so that 64-bit ALU operations need fewer shifts
- use rotates to move CF and AF from auxbits to their eflags position
--- target/i386/emulate/x86_flags.h | 12 +- target/i386/emulate/x86_emu.c | 4 +- target/i386/emulate/x86_flags.c | 197 ++++++++++++++------------------ 3 files changed, 86 insertions(+), 127 deletions(-)
target/i386/emulate/x86_flags.h +1 -11
@@ -28,20 +28,10 @@void lflags_to_rflags (CPUX86State *env);void rflags_to_lflags (CPUX86State *env); -bool get_PF (CPUX86State *env); -void set_PF (CPUX86State *env,bool val);bool get_CF (CPUX86State *env);void set_CF (CPUX86State *env,bool val); -bool get_AF (CPUX86State *env); -void set_AF (CPUX86State *env,bool val); -bool get_ZF (CPUX86State *env); -void set_ZF (CPUX86State *env,bool val); -bool get_SF (CPUX86State *env); -void set_SF (CPUX86State *env,bool val); -bool get_OF (CPUX86State *env); -void set_OF (CPUX86State *env,bool val); -void SET_FLAGS_OxxxxC (CPUX86State *env,uint32_t new_of,uint32_t new_cf); +void SET_FLAGS_OxxxxC (CPUX86State *env,bool new_of,bool new_cf);void SET_FLAGS_OSZAPC_SUB32 (CPUX86State *env,uint32_t v1,uint32_t v2,uint32_t diff);
target/i386/emulate/x86_emu.c +2 -2
@@ -474,10 +474,10 @@ static inline void string_rep(CPUX86State *env, struct x86_decode *decode,while (rcx--) {func (env, decode);write_reg (env,R_ECX , rcx, decode->addressing_size); -if ((PREFIX_REP == rep) && !get_ZF (env)) { +if ((PREFIX_REP == rep) && !env->lflags.result) {break ; } -if ((PREFIX_REPN == rep) &&get_ZF (env)) { +if ((PREFIX_REPN == rep) && env->lflags.result) {break ; } }
target/i386/emulate/x86_flags.c +83 -114
262 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH 4/4 target/i386: remove lflags
In reply to Paolo BonziniJust use cc_dst and cc_src for the same purpose.
--- target/i386/cpu.h | 6 ---- target/i386/emulate/x86_emu.c | 4 +-- target/i386/emulate/x86_flags.c | 55 ++++++++++++++++----------------- 3 files changed, 29 insertions(+), 36 deletions(-)
target/i386/cpu.h +0 -6
@@ -1809,11 +1809,6 @@ typedef struct CPUCaches {CPUCacheInfo *l3_cache; } CPUCaches; -typedef struct X86LazyFlags { -target_ulong result; -target_ulong auxbits; -}X86LazyFlags ; - typedef struct CPUArchState { /* standard registers */ target_ulong regs[CPU_NB_REGS];
@@ -2106,7 +2101,6 @@ typedef struct CPUArchState {QemuMutex xen_timers_lock;#endif #if defined(CONFIG_HVF ) -X86LazyFlags lflags;void *emu_mmio_buf;#endif
target/i386/emulate/x86_emu.c +2 -2
@@ -474,10 +474,10 @@ static inline void string_rep(CPUX86State *env, struct x86_decode *decode,while (rcx--) {func (env, decode);write_reg (env,R_ECX , rcx, decode->addressing_size); -if ((PREFIX_REP == rep) && !env->lflags.result) { +if ((PREFIX_REP == rep) && !env->cc_dst) {break ; } -if ((PREFIX_REPN == rep) && env->lflags.result) { +if ((PREFIX_REPN == rep) && env->cc_dst) {break ; } }
target/i386/emulate/x86_flags.c +27 -28
137 lines not on this page · raw message
Signature · 1 line
2.49.0
Quoted 15 lines · Paolo Bonzini
These are some improvements to the x86 emulator that I wrote but have no way of testing (right now).
I tried to place them in order of importance so that, if something breaks, it is possible to commit a subset. I tried to compile the resulting code on Linux but I have not run it.
Patch 1 is just to fix warnings on Linux.
Patch 2 is the most important, as it fixes some real horrors in the code.
Patch 3 makes flags handling use algorithms somewhat similar to TCG. It should fix issues with 64-bit ALU operations, but it's also the one where it's more likely to have a mistake.
Quoted 5 lines
Patch 4 is comparatively trivial, though I cannot exclude any screwups.
It should be possible to test this with both HVF and Hyper-V.
Paolo
FWIW this series builds fine on for x86 HVF.
Thanks,
Wei.
Quoted 19 lines
Paolo Bonzini (4):
target/i386/emulate: fixtarget_ulongformat strings target/i386/emulate: stop overloading decode->op[N].ptr target/i386/emulate: mostly rewrite flags handling target/i386: remove lflagstarget/i386/cpu.h | 6 - target/i386/emulate/x86_decode.h | 9 +- target/i386/emulate/x86_emu.h | 8 +- target/i386/emulate/x86_flags.h | 12 +- target/i386/emulate/x86_decode.c | 76 ++++++------ target/i386/emulate/x86_emu.c | 125 +++++++++---------- target/i386/emulate/x86_flags.c | 198 +++++++++++++------------------ 7 files changed, 197 insertions(+), 237 deletions(-)Signature · 1 line
2.49.0
Il sab 3 mag 2025, 07:39 Wei Liu <[email protected]> ha scritto:
Quoted 2 lines
FWIW this series builds fine on for x86 HVF.
Thanks, can you also test it on either HVF or Hyper-V?
Paolo
Thanks,
Quoted 23 lines
Wei.
Quoted 19 lines
Paolo Bonzini (4):
target/i386/emulate: fixtarget_ulongformat strings target/i386/emulate: stop overloading decode->op[N].ptr target/i386/emulate: mostly rewrite flags handling target/i386: remove lflagstarget/i386/cpu.h | 6 - target/i386/emulate/x86_decode.h | 9 +- target/i386/emulate/x86_emu.h | 8 +- target/i386/emulate/x86_flags.h | 12 +- target/i386/emulate/x86_decode.c | 76 ++++++------ target/i386/emulate/x86_emu.c | 125 +++++++++---------- target/i386/emulate/x86_flags.c | 198 +++++++++++++------------------ 7 files changed, 197 insertions(+), 237 deletions(-)--
2.49.0
Quoted 7 lines · Paolo Bonzini
Il sab 3 mag 2025, 07:39 Wei Liu <[email protected]> ha scritto:
Quoted 2 lines
FWIW this series builds fine on for x86 HVF.
Thanks, can you also test it on either HVF or Hyper-V?
I will leave it to Magnus to test your changes on MSHV.
Wei.
Magnus, can you test this series on MSHV?
Quoted 39 lines · Paolo Bonzini
These are some improvements to the x86 emulator that I wrote but have no way of testing (right now).
I tried to place them in order of importance so that, if something breaks, it is possible to commit a subset. I tried to compile the resulting code on Linux but I have not run it.
Patch 1 is just to fix warnings on Linux.
Patch 2 is the most important, as it fixes some real horrors in the code.
Patch 3 makes flags handling use algorithms somewhat similar to TCG. It should fix issues with 64-bit ALU operations, but it's also the one where it's more likely to have a mistake.
Patch 4 is comparatively trivial, though I cannot exclude any screwups.
It should be possible to test this with both HVF and Hyper-V.
Paolo
Paolo Bonzini (4):
target/i386/emulate: fixtarget_ulongformat strings target/i386/emulate: stop overloading decode->op[N].ptr target/i386/emulate: mostly rewrite flags handling target/i386: remove lflagstarget/i386/cpu.h | 6 - target/i386/emulate/x86_decode.h | 9 +- target/i386/emulate/x86_emu.h | 8 +- target/i386/emulate/x86_flags.h | 12 +- target/i386/emulate/x86_decode.c | 76 ++++++------ target/i386/emulate/x86_emu.c | 125 +++++++++---------- target/i386/emulate/x86_flags.c | 198 +++++++++++++------------------ 7 files changed, 197 insertions(+), 237 deletions(-)Signature · 1 line
2.49.0
Hey Paolo,
I applied your patches to the x86 emulator in our MSHV branch. They compile cleanly (some off this we had changed on our branch already). I also performed some manual testing and didn't spot any regressions with the changes in the emulator.
magnus
already). I also performed some manual testing and didn't spot any regressions with the emulator.
Quoted 42 lines · Wei Liu
Magnus, can you test this series on MSHV?
Quoted 39 lines · Paolo Bonzini
These are some improvements to the x86 emulator that I wrote but have no way of testing (right now).
I tried to place them in order of importance so that, if something breaks, it is possible to commit a subset. I tried to compile the resulting code on Linux but I have not run it.
Patch 1 is just to fix warnings on Linux.
Patch 2 is the most important, as it fixes some real horrors in the code.
Patch 3 makes flags handling use algorithms somewhat similar to TCG. It should fix issues with 64-bit ALU operations, but it's also the one where it's more likely to have a mistake.
Patch 4 is comparatively trivial, though I cannot exclude any screwups.
It should be possible to test this with both HVF and Hyper-V.
Paolo
Paolo Bonzini (4):
target/i386/emulate: fixtarget_ulongformat strings target/i386/emulate: stop overloading decode->op[N].ptr target/i386/emulate: mostly rewrite flags handling target/i386: remove lflagstarget/i386/cpu.h | 6 - target/i386/emulate/x86_decode.h | 9 +- target/i386/emulate/x86_emu.h | 8 +- target/i386/emulate/x86_flags.h | 12 +- target/i386/emulate/x86_decode.c | 76 ++++++------ target/i386/emulate/x86_emu.c | 125 +++++++++---------- target/i386/emulate/x86_flags.c | 198 +++++++++++++------------------ 7 files changed, 197 insertions(+), 237 deletions(-)Signature · 1 line
2.49.0