direct-io.hg

changeset 15460:b8e8061c5a98

[XEN] Fix p2m->shadow callback to pass the mfn being written to
as well as the pointer and contents. This was being calculated but
got disconnected from its use when the p2m and shadow functions were
separated.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Tue Jul 03 14:57:59 2007 +0100 (2007-07-03)
parents 842e085dbb77
children 0528bc25c404
files xen/arch/x86/mm/hap/hap.c xen/arch/x86/mm/p2m.c xen/arch/x86/mm/shadow/common.c xen/arch/x86/mm/shadow/private.h xen/include/asm-x86/paging.h
line diff
     1.1 --- a/xen/arch/x86/mm/hap/hap.c	Tue Jul 03 13:44:04 2007 +0100
     1.2 +++ b/xen/arch/x86/mm/hap/hap.c	Tue Jul 03 14:57:59 2007 +0100
     1.3 @@ -672,7 +672,7 @@ static void p2m_install_entry_in_monitor
     1.4  
     1.5  void 
     1.6  hap_write_p2m_entry(struct vcpu *v, unsigned long gfn, l1_pgentry_t *p,
     1.7 -                    l1_pgentry_t new, unsigned int level)
     1.8 +                    mfn_t table_mfn, l1_pgentry_t new, unsigned int level)
     1.9  {
    1.10      hap_lock(v->domain);
    1.11  
     2.1 --- a/xen/arch/x86/mm/p2m.c	Tue Jul 03 13:44:04 2007 +0100
     2.2 +++ b/xen/arch/x86/mm/p2m.c	Tue Jul 03 14:57:59 2007 +0100
     2.3 @@ -146,17 +146,20 @@ p2m_next_level(struct domain *d, mfn_t *
     2.4  
     2.5          switch ( type ) {
     2.6          case PGT_l3_page_table:
     2.7 -            paging_write_p2m_entry(d, gfn, p2m_entry, new_entry, 4);
     2.8 +            paging_write_p2m_entry(d, gfn, 
     2.9 +                                   p2m_entry, *table_mfn, new_entry, 4);
    2.10              break;
    2.11          case PGT_l2_page_table:
    2.12  #if CONFIG_PAGING_LEVELS == 3
    2.13              /* for PAE mode, PDPE only has PCD/PWT/P bits available */
    2.14              new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)), _PAGE_PRESENT);
    2.15  #endif
    2.16 -            paging_write_p2m_entry(d, gfn, p2m_entry, new_entry, 3);
    2.17 +            paging_write_p2m_entry(d, gfn, 
    2.18 +                                   p2m_entry, *table_mfn, new_entry, 3);
    2.19              break;
    2.20          case PGT_l1_page_table:
    2.21 -            paging_write_p2m_entry(d, gfn, p2m_entry, new_entry, 2);
    2.22 +            paging_write_p2m_entry(d, gfn, 
    2.23 +                                   p2m_entry, *table_mfn, new_entry, 2);
    2.24              break;
    2.25          default:
    2.26              BUG();
    2.27 @@ -222,7 +225,7 @@ set_p2m_entry(struct domain *d, unsigned
    2.28          entry_content = l1e_empty();
    2.29  
    2.30      /* level 1 entry */
    2.31 -    paging_write_p2m_entry(d, gfn, p2m_entry, entry_content, 1);
    2.32 +    paging_write_p2m_entry(d, gfn, p2m_entry, table_mfn, entry_content, 1);
    2.33  
    2.34      /* Success */
    2.35      rv = 1;
    2.36 @@ -707,6 +710,7 @@ void p2m_set_flags_global(struct domain 
    2.37      l1_pgentry_t l1e_content;
    2.38      l1_pgentry_t *l1e;
    2.39      l2_pgentry_t *l2e;
    2.40 +    mfn_t l1mfn;
    2.41      int i1, i2;
    2.42  #if CONFIG_PAGING_LEVELS >= 3
    2.43      l3_pgentry_t *l3e;
    2.44 @@ -741,7 +745,7 @@ void p2m_set_flags_global(struct domain 
    2.45  	{
    2.46  	    continue;
    2.47  	}
    2.48 -	l3e = map_domain_page(mfn_x(_mfn(l4e_get_pfn(l4e[i4]))));
    2.49 +	l3e = map_domain_page(l4e_get_pfn(l4e[i4]));
    2.50  #endif /* now at levels 3 or 4... */
    2.51  	for ( i3 = 0; 
    2.52  	      i3 < ((CONFIG_PAGING_LEVELS==4) ? L3_PAGETABLE_ENTRIES : 8); 
    2.53 @@ -751,7 +755,7 @@ void p2m_set_flags_global(struct domain 
    2.54  	    {
    2.55  		continue;
    2.56  	    }
    2.57 -	    l2e = map_domain_page(mfn_x(_mfn(l3e_get_pfn(l3e[i3]))));
    2.58 +	    l2e = map_domain_page(l3e_get_pfn(l3e[i3]));
    2.59  #endif /* all levels... */
    2.60  	    for ( i2 = 0; i2 < L2_PAGETABLE_ENTRIES; i2++ )
    2.61  	    {
    2.62 @@ -759,7 +763,9 @@ void p2m_set_flags_global(struct domain 
    2.63  		{
    2.64  		    continue;
    2.65  		}
    2.66 -		l1e = map_domain_page(mfn_x(_mfn(l2e_get_pfn(l2e[i2]))));
    2.67 +
    2.68 +                l1mfn = _mfn(l2e_get_pfn(l2e[i2]));
    2.69 +		l1e = map_domain_page(mfn_x(l1mfn));
    2.70  		
    2.71  		for ( i1 = 0; i1 < L1_PAGETABLE_ENTRIES; i1++, gfn++ )
    2.72  		{
    2.73 @@ -769,7 +775,8 @@ void p2m_set_flags_global(struct domain 
    2.74  		    gfn = get_gpfn_from_mfn(mfn);
    2.75  		    /* create a new 1le entry using l1e_flags */
    2.76  		    l1e_content = l1e_from_pfn(mfn, l1e_flags);
    2.77 -		    paging_write_p2m_entry(d, gfn, &l1e[i1], l1e_content, 1);
    2.78 +		    paging_write_p2m_entry(d, gfn, &l1e[i1], 
    2.79 +                                           l1mfn, l1e_content, 1);
    2.80  		}
    2.81  		unmap_domain_page(l1e);
    2.82  	    }
     3.1 --- a/xen/arch/x86/mm/shadow/common.c	Tue Jul 03 13:44:04 2007 +0100
     3.2 +++ b/xen/arch/x86/mm/shadow/common.c	Tue Jul 03 14:57:59 2007 +0100
     3.3 @@ -2733,11 +2733,11 @@ static int shadow_test_disable(struct do
     3.4   * shadow processing jobs.
     3.5   */
     3.6  void
     3.7 -shadow_write_p2m_entry(struct vcpu *v, unsigned long gfn, l1_pgentry_t *p, 
     3.8 +shadow_write_p2m_entry(struct vcpu *v, unsigned long gfn, 
     3.9 +                       l1_pgentry_t *p, mfn_t table_mfn, 
    3.10                         l1_pgentry_t new, unsigned int level)
    3.11  {
    3.12      struct domain *d = v->domain;
    3.13 -    mfn_t table_mfn = pagetable_get_mfn(d->arch.phys_table);
    3.14      mfn_t mfn;
    3.15      
    3.16      shadow_lock(d);
     4.1 --- a/xen/arch/x86/mm/shadow/private.h	Tue Jul 03 13:44:04 2007 +0100
     4.2 +++ b/xen/arch/x86/mm/shadow/private.h	Tue Jul 03 14:57:59 2007 +0100
     4.3 @@ -392,8 +392,8 @@ void shadow_free_p2m_page(struct domain 
     4.4  
     4.5  /* Functions that atomically write PT/P2M entries and update state */
     4.6  void shadow_write_p2m_entry(struct vcpu *v, unsigned long gfn, 
     4.7 -                            l1_pgentry_t *p, l1_pgentry_t new, 
     4.8 -                            unsigned int level);
     4.9 +                            l1_pgentry_t *p, mfn_t table_mfn,
    4.10 +                            l1_pgentry_t new, unsigned int level);
    4.11  int shadow_write_guest_entry(struct vcpu *v, intpte_t *p,
    4.12                               intpte_t new, mfn_t gmfn);
    4.13  int shadow_cmpxchg_guest_entry(struct vcpu *v, intpte_t *p,
     5.1 --- a/xen/include/asm-x86/paging.h	Tue Jul 03 13:44:04 2007 +0100
     5.2 +++ b/xen/include/asm-x86/paging.h	Tue Jul 03 14:57:59 2007 +0100
     5.3 @@ -122,7 +122,8 @@ struct paging_mode {
     5.4      void          (*update_cr3            )(struct vcpu *v, int do_locking);
     5.5      void          (*update_paging_modes   )(struct vcpu *v);
     5.6      void          (*write_p2m_entry       )(struct vcpu *v, unsigned long gfn,
     5.7 -                                            l1_pgentry_t *p, l1_pgentry_t new, 
     5.8 +                                            l1_pgentry_t *p, mfn_t table_mfn, 
     5.9 +                                            l1_pgentry_t new, 
    5.10                                              unsigned int level);
    5.11      int           (*write_guest_entry     )(struct vcpu *v, intpte_t *p,
    5.12                                              intpte_t new, mfn_t gmfn);
    5.13 @@ -291,17 +292,22 @@ static inline void safe_write_pte(l1_pge
    5.14  }
    5.15  
    5.16  /* Atomically write a P2M entry and update the paging-assistance state 
    5.17 - * appropriately. */
    5.18 + * appropriately. 
    5.19 + * Arguments: the domain in question, the GFN whose mapping is being updated, 
    5.20 + * a pointer to the entry to be written, the MFN in which the entry resides, 
    5.21 + * the new contents of the entry, and the level in the p2m tree at which 
    5.22 + * we are writing. */
    5.23  static inline void paging_write_p2m_entry(struct domain *d, unsigned long gfn, 
    5.24 -                                          l1_pgentry_t *p, l1_pgentry_t new, 
    5.25 -                                          unsigned int level)
    5.26 +                                          l1_pgentry_t *p, mfn_t table_mfn,
    5.27 +                                          l1_pgentry_t new, unsigned int level)
    5.28  {
    5.29      struct vcpu *v = current;
    5.30      if ( v->domain != d )
    5.31          v = d->vcpu[0];
    5.32      if ( likely(v && paging_mode_enabled(d) && v->arch.paging.mode != NULL) )
    5.33      {
    5.34 -        return v->arch.paging.mode->write_p2m_entry(v, gfn, p, new, level);
    5.35 +        return v->arch.paging.mode->write_p2m_entry(v, gfn, p, table_mfn,
    5.36 +                                                    new, level);
    5.37      }
    5.38      else 
    5.39          safe_write_pte(p, new);