ia64/xen-unstable

changeset 16495:c00f31f27de6

hvm: Fix 2 type mismatches in vlapic.h and hpet.c for 32-bit build Xen

For 32-bit build of Xen:
1) the first mismatch (in hpet_read(), length is 4) makes guest think
the HPET DM is buggy (we return 0 for HPET_CFG.COUNTER_CLK_PERIOD to
guest), so guest wouldn't use HPET at all.
2) the second one: if tmict is 62500000 and timer_divisor is 16
(Fedoar7's installer uses the values at some time), 10 * 62500000 * 16
= 0x2540BE400 -- it's too big to be held in uint32_t.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>=20
author Keir Fraser <keir.fraser@citrix.com>
date Wed Nov 28 13:13:51 2007 +0000 (2007-11-28)
parents c76a9aa12d2e
children 71bfeeb0b321
files xen/arch/x86/hvm/hpet.c xen/arch/x86/hvm/vlapic.c
line diff
     1.1 --- a/xen/arch/x86/hvm/hpet.c	Wed Nov 28 13:04:47 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/hpet.c	Wed Nov 28 13:13:51 2007 +0000
     1.3 @@ -170,7 +170,7 @@ static unsigned long hpet_read(
     1.4  
     1.5      result = val;
     1.6      if ( length != 8 )
     1.7 -        result = (val >> ((addr & 7) * 8)) & ((1UL << (length * 8)) - 1);
     1.8 +        result = (val >> ((addr & 7) * 8)) & ((1ULL << (length * 8)) - 1);
     1.9  
    1.10      spin_unlock(&h->lock);
    1.11  
     2.1 --- a/xen/arch/x86/hvm/vlapic.c	Wed Nov 28 13:04:47 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/vlapic.c	Wed Nov 28 13:13:51 2007 +0000
     2.3 @@ -661,7 +661,8 @@ static void vlapic_write(struct vcpu *v,
     2.4  
     2.5      case APIC_TMICT:
     2.6      {
     2.7 -        uint64_t period = APIC_BUS_CYCLE_NS * (uint32_t)val * vlapic->hw.timer_divisor;
     2.8 +        uint64_t period = (uint64_t)APIC_BUS_CYCLE_NS *
     2.9 +                            (uint32_t)val * vlapic->hw.timer_divisor;
    2.10  
    2.11          vlapic_set_reg(vlapic, APIC_TMICT, val);
    2.12          create_periodic_time(current, &vlapic->pt, period, vlapic->pt.irq,
    2.13 @@ -820,8 +821,10 @@ static void lapic_rearm(struct vlapic *s
    2.14      unsigned long tmict;
    2.15  
    2.16      tmict = vlapic_get_reg(s, APIC_TMICT);
    2.17 -    if (tmict > 0) {
    2.18 -        uint64_t period = APIC_BUS_CYCLE_NS * (uint32_t)tmict * s->hw.timer_divisor;
    2.19 +    if ( tmict > 0 )
    2.20 +    {
    2.21 +        uint64_t period = (uint64_t)APIC_BUS_CYCLE_NS *
    2.22 +                            (uint32_t)tmict * s->hw.timer_divisor;
    2.23          uint32_t lvtt = vlapic_get_reg(s, APIC_LVTT);
    2.24  
    2.25          s->pt.irq = lvtt & APIC_VECTOR_MASK;
    2.26 @@ -830,9 +833,9 @@ static void lapic_rearm(struct vlapic *s
    2.27                               &s->timer_last_update);
    2.28  
    2.29          printk("lapic_load to rearm the actimer:"
    2.30 -                    "bus cycle is %uns, "
    2.31 -                    "saved tmict count %lu, period %"PRIu64"ns, irq=%"PRIu8"\n",
    2.32 -                    APIC_BUS_CYCLE_NS, tmict, period, s->pt.irq);
    2.33 +               "bus cycle is %uns, "
    2.34 +               "saved tmict count %lu, period %"PRIu64"ns, irq=%"PRIu8"\n",
    2.35 +               APIC_BUS_CYCLE_NS, tmict, period, s->pt.irq);
    2.36      }
    2.37  
    2.38      lapic_info(s);