aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hvm/i8254.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-17 15:03:27 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-17 15:03:27 +0000
commit4ff20a30344f24c7a246e6ceb3b631c9876c6a51 (patch)
tree3714f48c6c1dfe6e487c742c1f7a752f1c5f5299 /xen/arch/x86/hvm/i8254.c
parentbba72b94d7ef7a00d278c12e9aed5caae0a62016 (diff)
downloadxen-4ff20a30344f24c7a246e6ceb3b631c9876c6a51.tar.gz
xen-4ff20a30344f24c7a246e6ceb3b631c9876c6a51.tar.bz2
xen-4ff20a30344f24c7a246e6ceb3b631c9876c6a51.zip
[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>
Diffstat (limited to 'xen/arch/x86/hvm/i8254.c')
-rw-r--r--xen/arch/x86/hvm/i8254.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/xen/arch/x86/hvm/i8254.c b/xen/arch/x86/hvm/i8254.c
index a81ae57722..1ab512d2ee 100644
--- a/xen/arch/x86/hvm/i8254.c
+++ b/xen/arch/x86/hvm/i8254.c
@@ -182,11 +182,9 @@ void pit_time_fired(struct vcpu *v, void *priv)
s->count_load_time = hvm_get_guest_time(v);
}
-static inline void pit_load_count(PITChannelState *s, int val)
+static inline void pit_load_count(PITChannelState *s, int channel, int val)
{
u32 period;
- PITChannelState *ch0 =
- &current->domain->arch.hvm_domain.pl_time.vpit.channels[0];
if (val == 0)
val = 0x10000;
@@ -194,7 +192,7 @@ static inline void pit_load_count(PITChannelState *s, int val)
s->count = val;
period = DIV_ROUND((val * 1000000000ULL), PIT_FREQ);
- if (s != ch0)
+ if (channel != 0)
return;
#ifdef DEBUG_PIT
@@ -282,17 +280,17 @@ static void pit_ioport_write(void *opaque, uint32_t addr, uint32_t val)
switch(s->write_state) {
default:
case RW_STATE_LSB:
- pit_load_count(s, val);
+ pit_load_count(s, addr, val);
break;
case RW_STATE_MSB:
- pit_load_count(s, val << 8);
+ pit_load_count(s, addr, val << 8);
break;
case RW_STATE_WORD0:
s->write_latch = val;
s->write_state = RW_STATE_WORD1;
break;
case RW_STATE_WORD1:
- pit_load_count(s, s->write_latch | (val << 8));
+ pit_load_count(s, addr, s->write_latch | (val << 8));
s->write_state = RW_STATE_WORD0;
break;
}
@@ -369,7 +367,7 @@ static void pit_reset(void *opaque)
destroy_periodic_time(&s->pt);
s->mode = 0xff; /* the init mode */
s->gate = (i != 2);
- pit_load_count(s, 0);
+ pit_load_count(s, i, 0);
}
}