ia64/xen-unstable

changeset 3909:33aa4ad8f9d3

bitkeeper revision 1.1236.1.10 (421da0d32W6mm78NfqVauwQT_ZO1dQ)

[PATCH] mmio_addr.patch

Use 1:1 page table to figure out if a particular physical address belongs
to MMIO range or not.

Signed-off-by: Xin B Li <xin.b.li@intel.com>
Signed-off-by: Chengyuan Li <chengyuan.li@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>

Index: trunk/tools/libxc/xc_vmx_build.c
===================================================================
author arun.sharma@intel.com[kaf24]
date Thu Feb 24 09:39:31 2005 +0000 (2005-02-24)
parents 71408f3fa741
children 185d934d0b74
files tools/libxc/xc_vmx_build.c xen/arch/x86/vmx.c xen/include/asm-x86/shadow.h xen/include/asm-x86/vmx_platform.h
line diff
     1.1 --- a/tools/libxc/xc_vmx_build.c	Thu Feb 24 09:39:21 2005 +0000
     1.2 +++ b/tools/libxc/xc_vmx_build.c	Thu Feb 24 09:39:31 2005 +0000
     1.3 @@ -108,6 +108,44 @@ static void build_e820map(struct mem_map
     1.4      mem_mapp->nr_map = nr_map;
     1.5  }
     1.6  
     1.7 +static void zap_mmio_range(int xc_handle, u32 dom,
     1.8 +                            l2_pgentry_t *vl2tab,
     1.9 +                            unsigned long mmio_range_start,
    1.10 +                            unsigned long mmio_range_size)
    1.11 +{
    1.12 +    unsigned long mmio_addr;
    1.13 +    unsigned long mmio_range_end = mmio_range_start + mmio_range_size;
    1.14 +    unsigned long vl2e;
    1.15 +    l1_pgentry_t *vl1tab;
    1.16 +
    1.17 +    mmio_addr = mmio_range_start & PAGE_MASK;
    1.18 +    for (; mmio_addr < mmio_range_end; mmio_addr += PAGE_SIZE) {
    1.19 +        vl2e = vl2tab[l2_table_offset(mmio_addr)];
    1.20 +        vl1tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
    1.21 +                                PROT_READ|PROT_WRITE, vl2e >> PAGE_SHIFT);
    1.22 +        vl1tab[l1_table_offset(mmio_addr)] = 0;
    1.23 +        munmap(vl1tab, PAGE_SIZE);
    1.24 +    }
    1.25 +}
    1.26 +
    1.27 +static void zap_mmio_ranges(int xc_handle, u32 dom,
    1.28 +                            unsigned long l2tab,
    1.29 +                            struct mem_map *mem_mapp)
    1.30 +{
    1.31 +    int i;
    1.32 +    l2_pgentry_t *vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
    1.33 +                                                PROT_READ|PROT_WRITE,
    1.34 +                                                l2tab >> PAGE_SHIFT);
    1.35 +    for (i = 0; i < mem_mapp->nr_map; i++) {
    1.36 +        if ((mem_mapp->map[i].type == E820_IO)
    1.37 +          && (mem_mapp->map[i].caching_attr == MEMMAP_UC))
    1.38 +            zap_mmio_range(xc_handle, dom,
    1.39 +                            vl2tab, mem_mapp->map[i].addr,
    1.40 +                            mem_mapp->map[i].size);
    1.41 +    }
    1.42 +    munmap(vl2tab, PAGE_SIZE);
    1.43 +}
    1.44 +
    1.45  static int setup_guest(int xc_handle,
    1.46                           u32 dom, int memsize,
    1.47                           char *image, unsigned long image_size,
    1.48 @@ -355,6 +393,7 @@ static int setup_guest(int xc_handle,
    1.49  
    1.50      /* memsize is in megabytes */
    1.51      build_e820map(mem_mapp, memsize << 20);
    1.52 +    zap_mmio_ranges(xc_handle, dom, l2tab, mem_mapp);
    1.53      boot_paramsp->e820_map_nr = mem_mapp->nr_map;
    1.54      for (i=0; i<mem_mapp->nr_map; i++) {
    1.55          boot_paramsp->e820_map[i].addr = mem_mapp->map[i].addr; 
     2.1 --- a/xen/arch/x86/vmx.c	Thu Feb 24 09:39:21 2005 +0000
     2.2 +++ b/xen/arch/x86/vmx.c	Thu Feb 24 09:39:31 2005 +0000
     2.3 @@ -135,6 +135,7 @@ static int vmx_do_page_fault(unsigned lo
     2.4              return 0;
     2.5      gpa = (gpte & PAGE_MASK) + (va & ~PAGE_MASK);
     2.6  
     2.7 +    /* Use 1:1 page table to identify MMIO address space */
     2.8      if (mmio_space(gpa))
     2.9          handle_mmio(va, gpa);
    2.10  
     3.1 --- a/xen/include/asm-x86/shadow.h	Thu Feb 24 09:39:21 2005 +0000
     3.2 +++ b/xen/include/asm-x86/shadow.h	Thu Feb 24 09:39:31 2005 +0000
     3.3 @@ -279,7 +279,8 @@ static inline void l1pte_propagate_from_
     3.4      unsigned long old_spte = spte;
     3.5  #endif
     3.6  
     3.7 -    if ( shadow_mode_external(d) && mmio_space(gpte & 0xFFFFF000) ) {
     3.8 +    /* Use 1:1 page table to identify MMIO address space */
     3.9 +    if ( shadow_mode_external(d) && mmio_space(gpte) ) {
    3.10          *spte_p = 0;
    3.11          return;
    3.12      }
     4.1 --- a/xen/include/asm-x86/vmx_platform.h	Thu Feb 24 09:39:21 2005 +0000
     4.2 +++ b/xen/include/asm-x86/vmx_platform.h	Thu Feb 24 09:39:31 2005 +0000
     4.3 @@ -68,8 +68,6 @@ struct instruction {
     4.4      __u32   flags; //
     4.5  };
     4.6  
     4.7 -#define VGA_SPACE_START   0xA0000
     4.8 -#define VGA_SPACE_END     0xC0000
     4.9  #define MAX_INST_LEN      32
    4.10  
    4.11  struct mi_per_cpu_info
    4.12 @@ -89,12 +87,6 @@ struct virutal_platform_def {
    4.13  extern void handle_mmio(unsigned long, unsigned long);
    4.14  extern int vmx_setup_platform(struct exec_domain *, execution_context_t *);
    4.15  
    4.16 -static inline int mmio_space(unsigned long gpa)
    4.17 -{
    4.18 -    if (gpa >= VGA_SPACE_START && gpa < VGA_SPACE_END) {
    4.19 -        return 1;
    4.20 -    }
    4.21 -    return 0;
    4.22 -}
    4.23 +#define mmio_space(gpa) (!phys_to_machine_mapping((gpa) >> PAGE_SHIFT))
    4.24  
    4.25  #endif