Some of the code test sequences (e.g. push_es) clobber ES. That causes trouble for future rep string instructions. So save and restore ES around the test code sequence in exec_in_big_real_mode. Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx> --- x86/realmode.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/x86/realmode.c b/x86/realmode.c index 5dbc2aa..629a221 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -164,7 +164,10 @@ static void exec_in_big_real_mode(struct insn_desc *insn) "and $-2, %[tmp] \n\t" "mov %[tmp], %%cr0 \n\t" - "pushw %[save]+36; popfw \n\t" + /* Save ES, because it is clobbered by some tests. */ + "pushw %%es \n\t" + + "pushw %[save]+36; popfw \n\t" "xchg %%eax, %[save]+0 \n\t" "xchg %%ebx, %[save]+4 \n\t" "xchg %%ecx, %[save]+8 \n\t" @@ -190,6 +193,9 @@ static void exec_in_big_real_mode(struct insn_desc *insn) "pushfl \n\t" "popl %[save]+36 \n\t" + /* Restore ES for future rep string operations. */ + "popw %%es \n\t" + /* Restore DF for the harness code */ "cld\n\t" "xor %[tmp], %[tmp] \n\t" @@ -1312,10 +1318,8 @@ static void test_lds_lss(void) outregs.eax == (unsigned long)desc.address && outregs.ebx == desc.sel); - MK_INSN(les, "push %es\n\t" - "les (%ebx), %eax\n\t" - "mov %es, %ebx\n\t" - "pop %es\n\t"); + MK_INSN(les, "les (%ebx), %eax\n\t" + "mov %es, %ebx\n\t"); exec_in_big_real_mode(&insn_les); report("les", R_AX | R_BX, outregs.eax == (unsigned long)desc.address && -- 2.24.0.rc1.363.gb1bccd3e3d-goog