[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-3.0-testing] Fix negation of unsigned quantities in the Xen x86 emulator.
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 53bb8c0d9639251b61b203b55f9e6b046f8d99d6 # Parent 78a72d42cfc19c06097a92b8d0f824d823813c79 Fix negation of unsigned quantities in the Xen x86 emulator. This fixes the problems left behind by c/s 10171. Again pointed out by Jan Beulich; and again different from his suggested patch. Hopefully this one will be less embarrassing. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> xen-unstable changeset: 10241:2dd8e7c4472897a86cac635b6982fa55f1ab6e07 xen-unstable date: Thu Jun 01 16:31:37 2006 +0100 --- xen/arch/x86/traps.c | 4 ++-- xen/arch/x86/x86_emulate.c | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff -r 78a72d42cfc1 -r 53bb8c0d9639 xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c Thu Jun 01 11:05:13 2006 +0100 +++ b/xen/arch/x86/traps.c Thu Jun 01 16:33:38 2006 +0100 @@ -873,7 +873,7 @@ static int emulate_privileged_op(struct PAGE_FAULT(regs->edi, USER_WRITE_FAULT); break; } - regs->edi += (regs->eflags & EF_DF) ? -(int)op_bytes : op_bytes; + regs->edi += (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes); break; case 0x6e: /* OUTSB */ @@ -899,7 +899,7 @@ static int emulate_privileged_op(struct outl_user((u32)data, (u16)regs->edx, v, regs); break; } - regs->esi += (regs->eflags & EF_DF) ? -(int)op_bytes : op_bytes; + regs->esi += (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes); break; } diff -r 78a72d42cfc1 -r 53bb8c0d9639 xen/arch/x86/x86_emulate.c --- a/xen/arch/x86/x86_emulate.c Thu Jun 01 11:05:13 2006 +0100 +++ b/xen/arch/x86/x86_emulate.c Thu Jun 01 16:33:38 2006 +0100 @@ -379,11 +379,12 @@ do{ __asm__ __volatile__ ( ((reg) & ((1UL << (ad_bytes << 3)) - 1)))) #define register_address_increment(reg, inc) \ do { \ + int _inc = (inc); /* signed type ensures sign extension to long */ \ if ( ad_bytes == sizeof(unsigned long) ) \ - (reg) += (inc); \ + (reg) += _inc; \ else \ (reg) = ((reg) & ~((1UL << (ad_bytes << 3)) - 1)) | \ - (((reg) + (inc)) & ((1UL << (ad_bytes << 3)) - 1)); \ + (((reg) + _inc) & ((1UL << (ad_bytes << 3)) - 1)); \ } while (0) void * @@ -857,7 +858,7 @@ x86_emulate_memop( &dst.val, 8)) != 0 ) goto done; } - register_address_increment(_regs.esp, -(int)dst.bytes); + register_address_increment(_regs.esp, -dst.bytes); if ( (rc = ops->write_std(register_address(_regs.ss, _regs.esp), dst.val, dst.bytes)) != 0 ) goto done; @@ -939,9 +940,9 @@ x86_emulate_memop( goto done; } register_address_increment( - _regs.esi, (_regs.eflags & EFLG_DF) ? -(int)dst.bytes : dst.bytes); + _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); register_address_increment( - _regs.edi, (_regs.eflags & EFLG_DF) ? -(int)dst.bytes : dst.bytes); + _regs.edi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); break; case 0xa6 ... 0xa7: /* cmps */ DPRINTF("Urk! I don't handle CMPS.\n"); @@ -952,7 +953,7 @@ x86_emulate_memop( dst.ptr = (unsigned long *)cr2; dst.val = _regs.eax; register_address_increment( - _regs.edi, (_regs.eflags & EFLG_DF) ? -(int)dst.bytes : dst.bytes); + _regs.edi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); break; case 0xac ... 0xad: /* lods */ dst.type = OP_REG; @@ -961,7 +962,7 @@ x86_emulate_memop( if ( (rc = ops->read_emulated(cr2, &dst.val, dst.bytes)) != 0 ) goto done; register_address_increment( - _regs.esi, (_regs.eflags & EFLG_DF) ? -(int)dst.bytes : dst.bytes); + _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); break; case 0xae ... 0xaf: /* scas */ DPRINTF("Urk! I don't handle SCAS.\n"); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |