target/i386: Update cc_op for SAHF
PATCH 1/1 target/i386: Update cc_op for SAHF
Removing the call to gen_compute_eflags meant we no longer updated cc_op after computing EFLAGS.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3537
--- target/i386/tcg/emit.c.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
target/i386/tcg/emit.c.inc +6 -3
@@ -3768,10 +3768,13 @@ static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) return gen_illegal_opcode(s); } tcg_gen_shri_tl(s->T0, cpu_regs[R_EAX], 8); - gen_neg_setcc(s, JCC_O << 1, cpu_cc_src); - tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O); + gen_neg_setcc(s, JCC_O << 1, s->T1); + tcg_gen_andi_tl(s->T1, s->T1, CC_O); tcg_gen_andi_tl(s->T0, s->T0, CC_S | CC_Z | CC_A | CC_P | CC_C); - tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, s->T0); + tcg_gen_or_tl(s->T0, s->T0, s->T1); + + decode->cc_src = s->T0; + decode->cc_op = CC_OP_EFLAGS; } static void gen_SALC(DisasContext *s, X86DecodedInsn *decode)
Signature · 1 line
2.43.0
Ping.
Quoted 32 lines · Richard Henderson
Removing the call to
gen_compute_eflagsmeant we no longer updatedcc_opafter computing EFLAGS.Fixes da7649c6aeef ("target/i386/tcg: do not compute all flags for SAHF")Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3537
Signed-off-by Richard Henderson <[email protected]>--- target/i386/tcg/emit.c.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)target/i386/tcg/emit.c.inc +6
-3@@ -3768,10 +3768,13 @@ static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) return gen_illegal_opcode(s); } tcg_gen_shri_tl(s->T0, cpu_regs[R_EAX], 8); - gen_neg_setcc(s, JCC_O << 1, cpu_cc_src); - tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O); + gen_neg_setcc(s, JCC_O << 1, s->T1); + tcg_gen_andi_tl(s->T1, s->T1, CC_O); tcg_gen_andi_tl(s->T0, s->T0, CC_S | CC_Z | CC_A | CC_P | CC_C); - tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, s->T0); + tcg_gen_or_tl(s->T0, s->T0, s->T1); + + decode->cc_src = s->T0; + decode->cc_op = CC_OP_EFLAGS; } static void gen_SALC(DisasContext *s, X86DecodedInsn *decode)
Ping 2.
Quoted 32 lines · Richard Henderson
Removing the call to
gen_compute_eflagsmeant we no longer updatedcc_opafter computing EFLAGS.Fixes da7649c6aeef ("target/i386/tcg: do not compute all flags for SAHF")Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3537
Signed-off-by Richard Henderson <[email protected]>--- target/i386/tcg/emit.c.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)target/i386/tcg/emit.c.inc +6
-3@@ -3768,10 +3768,13 @@ static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) return gen_illegal_opcode(s); } tcg_gen_shri_tl(s->T0, cpu_regs[R_EAX], 8); - gen_neg_setcc(s, JCC_O << 1, cpu_cc_src); - tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O); + gen_neg_setcc(s, JCC_O << 1, s->T1); + tcg_gen_andi_tl(s->T1, s->T1, CC_O); tcg_gen_andi_tl(s->T0, s->T0, CC_S | CC_Z | CC_A | CC_P | CC_C); - tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, s->T0); + tcg_gen_or_tl(s->T0, s->T0, s->T1); + + decode->cc_src = s->T0; + decode->cc_op = CC_OP_EFLAGS; } static void gen_SALC(DisasContext *s, X86DecodedInsn *decode)
Ping 3.
Quoted 32 lines · Richard Henderson
Removing the call to
gen_compute_eflagsmeant we no longer updatedcc_opafter computing EFLAGS.Fixes da7649c6aeef ("target/i386/tcg: do not compute all flags for SAHF")Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3537
Signed-off-by Richard Henderson <[email protected]>--- target/i386/tcg/emit.c.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)target/i386/tcg/emit.c.inc +6
-3@@ -3768,10 +3768,13 @@ static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) return gen_illegal_opcode(s); } tcg_gen_shri_tl(s->T0, cpu_regs[R_EAX], 8); - gen_neg_setcc(s, JCC_O << 1, cpu_cc_src); - tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O); + gen_neg_setcc(s, JCC_O << 1, s->T1); + tcg_gen_andi_tl(s->T1, s->T1, CC_O); tcg_gen_andi_tl(s->T0, s->T0, CC_S | CC_Z | CC_A | CC_P | CC_C); - tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, s->T0); + tcg_gen_or_tl(s->T0, s->T0, s->T1); + + decode->cc_src = s->T0; + decode->cc_op = CC_OP_EFLAGS; } static void gen_SALC(DisasContext *s, X86DecodedInsn *decode)
Philippe Mathieu-Daudé
Reviewed-byHi Richard,
(Maybe you didn't Cc'ed enough x86 experts?)
Quoted 1 line · Richard Henderson
Ping 3.
I don't think you are waiting a review from me, but in case it helps to unlock you, I tried to review it but since x86 is not my cup of tea at all I got lost with global registers use. Anyway the overall change looks safe enough and indeed fix the issue reported, so to the best of my x86 knowledge:
Quoted 36 lines · Richard Henderson
Quoted 32 lines
Removing the call to
gen_compute_eflagsmeant we no longer updatedcc_opafter computing EFLAGS.Fixes da7649c6aeef ("target/i386/tcg: do not compute all flags for SAHF")Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3537
Signed-off-by Richard Henderson <[email protected]>---
target/i386/tcg/emit.c.inc | 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)target/i386/tcg/emit.c.inc +6
-3@@ -3768,10 +3768,13 @@ static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) return gen_illegal_opcode(s); } tcg_gen_shri_tl(s->T0, cpu_regs[R_EAX], 8); - gen_neg_setcc(s, JCC_O << 1, cpu_cc_src); - tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O); + gen_neg_setcc(s, JCC_O << 1, s->T1); + tcg_gen_andi_tl(s->T1, s->T1, CC_O); tcg_gen_andi_tl(s->T0, s->T0, CC_S | CC_Z | CC_A | CC_P | CC_C); - tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, s->T0); + tcg_gen_or_tl(s->T0, s->T0, s->T1); + + decode->cc_src = s->T0; + decode->cc_op = CC_OP_EFLAGS; } static void gen_SALC(DisasContext *s, X86DecodedInsn *decode)
Ping 4.
r~
Quoted 32 lines · Richard Henderson
Removing the call to
gen_compute_eflagsmeant we no longer updatedcc_opafter computing EFLAGS.Fixes da7649c6aeef ("target/i386/tcg: do not compute all flags for SAHF")Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3537
Signed-off-by Richard Henderson <[email protected]>--- target/i386/tcg/emit.c.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)target/i386/tcg/emit.c.inc +6
-3@@ -3768,10 +3768,13 @@ static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) return gen_illegal_opcode(s); } tcg_gen_shri_tl(s->T0, cpu_regs[R_EAX], 8); - gen_neg_setcc(s, JCC_O << 1, cpu_cc_src); - tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O); + gen_neg_setcc(s, JCC_O << 1, s->T1); + tcg_gen_andi_tl(s->T1, s->T1, CC_O); tcg_gen_andi_tl(s->T0, s->T0, CC_S | CC_Z | CC_A | CC_P | CC_C); - tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, s->T0); + tcg_gen_or_tl(s->T0, s->T0, s->T1); + + decode->cc_src = s->T0; + decode->cc_op = CC_OP_EFLAGS; } static void gen_SALC(DisasContext *s, X86DecodedInsn *decode)
Am 09.06.26 um 02:28 schrieb Richard Henderson:
Quoted 3 lines
Removing the call to
gen_compute_eflagsmeant we no longer updatedcc_opafter computing EFLAGS.
I ran into this regression with real guests: since the change in v11.0 the PC DOS 7 installer aborts while copying its first file, and Windows 3.1 setup fails the same way (I reported it as #3959, which was closed as a duplicate of #3537).
Tested this patch on top of current master (e1705a25af, v11.1.0-rc2). Both runs used the same script, the same firmware and a freshly created 500 MB disk image: boot the German PC DOS 7 CD, run SETUP to the end, then inspect the resulting image from the host with mtools and finally boot the machine from that image.
master unpatched: SETUP stops with "INSTALLATIONSFEHLER ... Die aufgelistete Datei wurde nicht kopiert. Fehler beim Schreiben --> CHKDSK.COM" [installation error ... the listed file was not copied; error writing CHKDSK.COM]. The image holds three files -- IBMBIO.COM, IBMDOS.COM, COMMAND.COM -- and no \DOS directory. (It does boot into a bare DOS, since those three were written before the installer gave up.)
master + this patch: SETUP runs to completion and reboots the machine by itself. The image holds 157 entries, among them \DOS\CHKDSK.COM -- the file the unpatched run fails on. Booting that image comes up as a fully installed system: CONFIG.SYS and AUTOEXEC.BAT are processed, the drivers load, and VER reports "PC DOS Version 7.00 Revision 1".
Given the Cc: qemu-stable, it would be good to see this in 11.1.