[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/2] x86emul: consolidate string insn address increments
Move the looking at EFLAGS.DF into the macro, rendering all call sites more readable. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -716,8 +716,10 @@ do { (reg) = ((reg) & ~((1UL << (_width << 3)) - 1)) | \ (((reg) + _inc) & ((1UL << (_width << 3)) - 1)); \ } while (0) -#define register_address_increment(reg, inc) \ - _register_address_increment((reg), (inc), ad_bytes) +#define register_address_increment(reg, inc) \ + _register_address_increment(reg, \ + _regs.eflags & EFLG_DF ? -(inc) : (inc), \ + ad_bytes) #define sp_pre_dec(dec) ({ \ _register_address_increment(_regs.esp, -(dec), ctxt->sp_size/8); \ @@ -2942,9 +2944,7 @@ x86_emulate( dst.type = OP_MEM; nr_reps = 1; } - register_address_increment( - _regs.edi, - nr_reps * ((_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes)); + register_address_increment(_regs.edi, nr_reps * dst.bytes); put_rep_prefix(nr_reps); break; } @@ -2973,9 +2973,7 @@ x86_emulate( goto done; nr_reps = 1; } - register_address_increment( - _regs.esi, - nr_reps * ((_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes)); + register_address_increment(_regs.esi, nr_reps * dst.bytes); put_rep_prefix(nr_reps); break; } @@ -3213,12 +3211,8 @@ x86_emulate( dst.type = OP_MEM; nr_reps = 1; } - register_address_increment( - _regs.esi, - nr_reps * ((_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes)); - register_address_increment( - _regs.edi, - nr_reps * ((_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes)); + register_address_increment(_regs.esi, nr_reps * dst.bytes); + register_address_increment(_regs.edi, nr_reps * dst.bytes); put_rep_prefix(nr_reps); break; } @@ -3233,10 +3227,8 @@ x86_emulate( (rc = read_ulong(x86_seg_es, truncate_ea(_regs.edi), &src.val, src.bytes, ctxt, ops)) ) goto done; - register_address_increment( - _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); - register_address_increment( - _regs.edi, (_regs.eflags & EFLG_DF) ? -src.bytes : src.bytes); + register_address_increment(_regs.esi, dst.bytes); + register_address_increment(_regs.edi, src.bytes); put_rep_prefix(1); /* cmp: dst - src ==> src=*%%edi,dst=*%%esi ==> *%%esi - *%%edi */ emulate_2op_SrcV("cmp", src, dst, _regs.eflags); @@ -3263,9 +3255,7 @@ x86_emulate( } else if ( rc != X86EMUL_OKAY ) goto done; - register_address_increment( - _regs.edi, - nr_reps * ((_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes)); + register_address_increment(_regs.edi, nr_reps * dst.bytes); put_rep_prefix(nr_reps); break; } @@ -3275,8 +3265,7 @@ x86_emulate( if ( (rc = read_ulong(ea.mem.seg, truncate_ea(_regs.esi), &dst.val, dst.bytes, ctxt, ops)) != 0 ) goto done; - register_address_increment( - _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); + register_address_increment(_regs.esi, dst.bytes); put_rep_prefix(1); break; @@ -3287,8 +3276,7 @@ x86_emulate( if ( (rc = read_ulong(x86_seg_es, truncate_ea(_regs.edi), &dst.val, src.bytes, ctxt, ops)) != 0 ) goto done; - register_address_increment( - _regs.edi, (_regs.eflags & EFLG_DF) ? -src.bytes : src.bytes); + register_address_increment(_regs.edi, src.bytes); put_rep_prefix(1); /* cmp: %%eax - *%%edi ==> src=%%eax,dst=*%%edi ==> src - dst */ dst.bytes = src.bytes; Attachment:
x86emul-string-address-increment.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |