ia64/xen-unstable

changeset 19023:6d040d138e8f

hvmloader: MTRR UC type covers the pci regions only.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 09 13:00:10 2009 +0000 (2009-01-09)
parents b84345ee0d41
children 1dfc48a8c361
files tools/firmware/hvmloader/cacheattr.c
line diff
     1.1 --- a/tools/firmware/hvmloader/cacheattr.c	Fri Jan 09 12:41:25 2009 +0000
     1.2 +++ b/tools/firmware/hvmloader/cacheattr.c	Fri Jan 09 13:00:10 2009 +0000
     1.3 @@ -88,13 +88,25 @@ void cacheattr_init(void)
     1.4      nr_var_ranges = (uint8_t)mtrr_cap;
     1.5      if ( nr_var_ranges != 0 )
     1.6      {
     1.7 -        /* A single UC range covering PCI space. */
     1.8 -        /* pci_mem_start must be of the binary form 1....10....0 */
     1.9 -        BUG_ON(~(pci_mem_start | (pci_mem_start - 1)));
    1.10 -        wrmsr(MSR_MTRRphysBase(0), pci_mem_start);
    1.11 -        wrmsr(MSR_MTRRphysMask(0),
    1.12 -              ((uint64_t)(int32_t)pci_mem_start & addr_mask) | (1u << 11));
    1.13 -        printf("var MTRRs ... ");
    1.14 +        unsigned long base = pci_mem_start, size;
    1.15 +        int i;
    1.16 +
    1.17 +        for ( i = 0; (base != pci_mem_end) && (i < nr_var_ranges); i++ )
    1.18 +        {
    1.19 +            size = PAGE_SIZE;
    1.20 +            while ( !(base & size) )
    1.21 +                size <<= 1;
    1.22 +            while ( ((base + size) < base) || ((base + size) > pci_mem_end) )
    1.23 +                size >>= 1;
    1.24 +
    1.25 +            wrmsr(MSR_MTRRphysBase(i), base);
    1.26 +            wrmsr(MSR_MTRRphysMask(i),
    1.27 +                  (~(uint64_t)(size-1) & addr_mask) | (1u << 11));
    1.28 +
    1.29 +            base += size;
    1.30 +        }
    1.31 +
    1.32 +        printf("var MTRRs [%d/%d] ... ", i, nr_var_ranges);
    1.33      }
    1.34  
    1.35      wrmsr(MSR_MTRRdefType, mtrr_def);