ia64/xen-unstable

changeset 16528:6d879bb3f6f0

x86_emulate: EFLAGS.PF only reflects least-significant byte of result,
so even_parity() can return to its original prototype.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 05 10:34:15 2007 +0000 (2007-12-05)
parents e39931a314c8
children 0974e59dd744
files xen/arch/x86/x86_emulate.c
line diff
     1.1 --- a/xen/arch/x86/x86_emulate.c	Wed Dec 05 10:00:42 2007 +0000
     1.2 +++ b/xen/arch/x86/x86_emulate.c	Wed Dec 05 10:34:15 2007 +0000
     1.3 @@ -508,11 +508,14 @@ do {                                    
     1.4      }                                                                   \
     1.5  })
     1.6  
     1.7 -/* Given longword has even parity (even number of 1s)? */
     1.8 -static int even_parity(unsigned long v)
     1.9 +/*
    1.10 + * Given byte has even parity (even number of 1s)? SDM Vol. 1 Sec. 3.4.3.1,
    1.11 + * "Status Flags": EFLAGS.PF reflects parity of least-sig. byte of result only.
    1.12 + */
    1.13 +static int even_parity(uint8_t v)
    1.14  {
    1.15 -    asm ( "test %0,%0; setp %b0" : "=a" (v) : "0" (v) );
    1.16 -    return (uint8_t)v;
    1.17 +    asm ( "test %b0,%b0; setp %b0" : "=a" (v) : "0" (v) );
    1.18 +    return v;
    1.19  }
    1.20  
    1.21  /* Update address held in a register, based on addressing mode. */
    1.22 @@ -1915,7 +1918,7 @@ x86_emulate(
    1.23          _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF);
    1.24          _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0;
    1.25          _regs.eflags |= (( int8_t)_regs.eax <  0) ? EFLG_SF : 0;
    1.26 -        _regs.eflags |= even_parity((uint8_t)_regs.eax) ? EFLG_PF : 0;
    1.27 +        _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0;
    1.28          break;
    1.29      }
    1.30  
    1.31 @@ -1939,7 +1942,7 @@ x86_emulate(
    1.32          _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF);
    1.33          _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0;
    1.34          _regs.eflags |= (( int8_t)_regs.eax <  0) ? EFLG_SF : 0;
    1.35 -        _regs.eflags |= even_parity((uint8_t)_regs.eax) ? EFLG_PF : 0;
    1.36 +        _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0;
    1.37          break;
    1.38      }
    1.39  
    1.40 @@ -2405,7 +2408,7 @@ x86_emulate(
    1.41          _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF);
    1.42          _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0;
    1.43          _regs.eflags |= (( int8_t)_regs.eax <  0) ? EFLG_SF : 0;
    1.44 -        _regs.eflags |= even_parity((uint8_t)_regs.eax) ? EFLG_PF : 0;
    1.45 +        _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0;
    1.46          break;
    1.47      }
    1.48  
    1.49 @@ -2417,7 +2420,7 @@ x86_emulate(
    1.50          _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF);
    1.51          _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0;
    1.52          _regs.eflags |= (( int8_t)_regs.eax <  0) ? EFLG_SF : 0;
    1.53 -        _regs.eflags |= even_parity((uint8_t)_regs.eax) ? EFLG_PF : 0;
    1.54 +        _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0;
    1.55          break;
    1.56      }
    1.57