direct-io.hg

changeset 13398:120d882a4d8e

[HVM] i8254: Fix bogus use of current

The function pit_load_count incorrectly references current for
determining whether the channel number is zero. This breaks
when starting a new guest because current points to dom0.

The fix is to explicitly pass the address for verification.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
author kfraser@localhost.localdomain
date Wed Jan 17 15:03:27 2007 +0000 (2007-01-17)
parents 9fa13c7ebf8a
children 8690e3448971
files xen/arch/x86/hvm/i8254.c
line diff
     1.1 --- a/xen/arch/x86/hvm/i8254.c	Wed Jan 17 14:58:53 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/i8254.c	Wed Jan 17 15:03:27 2007 +0000
     1.3 @@ -182,11 +182,9 @@ void pit_time_fired(struct vcpu *v, void
     1.4      s->count_load_time = hvm_get_guest_time(v);
     1.5  }
     1.6  
     1.7 -static inline void pit_load_count(PITChannelState *s, int val)
     1.8 +static inline void pit_load_count(PITChannelState *s, int channel, int val)
     1.9  {
    1.10      u32 period;
    1.11 -    PITChannelState *ch0 =
    1.12 -        &current->domain->arch.hvm_domain.pl_time.vpit.channels[0];
    1.13  
    1.14      if (val == 0)
    1.15          val = 0x10000;
    1.16 @@ -194,7 +192,7 @@ static inline void pit_load_count(PITCha
    1.17      s->count = val;
    1.18      period = DIV_ROUND((val * 1000000000ULL), PIT_FREQ);
    1.19  
    1.20 -    if (s != ch0)
    1.21 +    if (channel != 0)
    1.22          return;
    1.23  
    1.24  #ifdef DEBUG_PIT
    1.25 @@ -282,17 +280,17 @@ static void pit_ioport_write(void *opaqu
    1.26          switch(s->write_state) {
    1.27          default:
    1.28          case RW_STATE_LSB:
    1.29 -            pit_load_count(s, val);
    1.30 +            pit_load_count(s, addr, val);
    1.31              break;
    1.32          case RW_STATE_MSB:
    1.33 -            pit_load_count(s, val << 8);
    1.34 +            pit_load_count(s, addr, val << 8);
    1.35              break;
    1.36          case RW_STATE_WORD0:
    1.37              s->write_latch = val;
    1.38              s->write_state = RW_STATE_WORD1;
    1.39              break;
    1.40          case RW_STATE_WORD1:
    1.41 -            pit_load_count(s, s->write_latch | (val << 8));
    1.42 +            pit_load_count(s, addr, s->write_latch | (val << 8));
    1.43              s->write_state = RW_STATE_WORD0;
    1.44              break;
    1.45          }
    1.46 @@ -369,7 +367,7 @@ static void pit_reset(void *opaque)
    1.47          destroy_periodic_time(&s->pt);
    1.48          s->mode = 0xff; /* the init mode */
    1.49          s->gate = (i != 2);
    1.50 -        pit_load_count(s, 0);
    1.51 +        pit_load_count(s, i, 0);
    1.52      }
    1.53  }
    1.54