ia64/xen-unstable

changeset 19283:73c4e6dbbb60

vt-d: Better restrict memory ranges considered to be in Xen

The current implementation of xen_in_range() misses several memory
ranges that are used by the hypervisor and thus shouldn't get mapped
into dom0's VT-d tables. This patch should make the check complete.

This patch is only against x86 because I'm not familiar enough with
IA64 to know how much, if any, of these checks apply there.

Signed-off-by: Joseph Cihula <joseph.cihula@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Mar 06 19:06:30 2009 +0000 (2009-03-06)
parents ec671455fb05
children 7c831b755c78
files xen/arch/x86/setup.c
line diff
     1.1 --- a/xen/arch/x86/setup.c	Fri Mar 06 18:58:41 2009 +0000
     1.2 +++ b/xen/arch/x86/setup.c	Fri Mar 06 19:06:30 2009 +0000
     1.3 @@ -1111,15 +1111,43 @@ void arch_get_xen_caps(xen_capabilities_
     1.4  
     1.5  int xen_in_range(paddr_t start, paddr_t end)
     1.6  {
     1.7 -#if defined(CONFIG_X86_32)
     1.8 -    paddr_t xs = 0;
     1.9 -    paddr_t xe = xenheap_phys_end;
    1.10 -#else
    1.11 -    paddr_t xs = __pa(&_stext);
    1.12 -    paddr_t xe = __pa(&_etext);
    1.13 -#endif
    1.14 +    int i;
    1.15 +    static struct {
    1.16 +        paddr_t s, e;
    1.17 +    } xen_regions[5];
    1.18  
    1.19 -    return (start < xe) && (end > xs);
    1.20 +    /* initialize first time */
    1.21 +    if ( !xen_regions[0].s )
    1.22 +    {
    1.23 +        extern char __init_begin[], __per_cpu_start[], __per_cpu_end[],
    1.24 +                    __bss_start[];
    1.25 +        extern unsigned long allocator_bitmap_end;
    1.26 +
    1.27 +        /* S3 resume code (and other real mode trampoline code) */
    1.28 +        xen_regions[0].s = bootsym_phys(trampoline_start);
    1.29 +        xen_regions[0].e = bootsym_phys(trampoline_end);
    1.30 +        /* hypervisor code + data */
    1.31 +        xen_regions[1].s =__pa(&_stext);
    1.32 +        xen_regions[1].e = __pa(&__init_begin);
    1.33 +        /* per-cpu data */
    1.34 +        xen_regions[2].s = __pa(&__per_cpu_start);
    1.35 +        xen_regions[2].e = __pa(&__per_cpu_end);
    1.36 +        /* bss + boot allocator bitmap */
    1.37 +        xen_regions[3].s = __pa(&__bss_start);
    1.38 +        xen_regions[3].e = allocator_bitmap_end;
    1.39 +        /* frametable */
    1.40 +        xen_regions[4].s = (unsigned long)frame_table;
    1.41 +        xen_regions[4].e = (unsigned long)frame_table +
    1.42 +                           PFN_UP(max_page * sizeof(*frame_table));
    1.43 +    }
    1.44 +
    1.45 +    for ( i = 0; i < ARRAY_SIZE(xen_regions); i++ )
    1.46 +    {
    1.47 +        if ( (start < xen_regions[i].e) && (end > xen_regions[i].s) )
    1.48 +            return 1;
    1.49 +    }
    1.50 +
    1.51 +    return 0;
    1.52  }
    1.53  
    1.54  /*