ia64/xen-unstable

changeset 8095:9971d8d1f631

Allow __gpfn_to_mfn() to automatically deal with translated domains != current.

Renamed gpfn_to_mfn_foreign() to get_mfn_from_pfn_foreign(), making it more
consistent with get_mfn_from_pfn().
author Michael.Fetterman@cl.cam.ac.uk
date Mon Nov 28 15:09:44 2005 +0100 (2005-11-28)
parents af3e4a594e4c
children 48aaa39eaa7e
files xen/arch/x86/shadow32.c xen/arch/x86/shadow_public.c xen/common/grant_table.c xen/include/asm-x86/shadow.h xen/include/xen/perfc_defn.h
line diff
     1.1 --- a/xen/arch/x86/shadow32.c	Wed Nov 23 14:56:43 2005 +0100
     1.2 +++ b/xen/arch/x86/shadow32.c	Mon Nov 28 15:09:44 2005 +0100
     1.3 @@ -1423,7 +1423,7 @@ int shadow_mode_control(struct domain *d
     1.4  }
     1.5  
     1.6  unsigned long
     1.7 -gpfn_to_mfn_foreign(struct domain *d, unsigned long gpfn)
     1.8 +get_mfn_from_pfn_foreign(struct domain *d, unsigned long gpfn)
     1.9  {
    1.10      unsigned long va, tabpfn;
    1.11      l1_pgentry_t *l1, l1e;
    1.12 @@ -1431,7 +1431,7 @@ gpfn_to_mfn_foreign(struct domain *d, un
    1.13  
    1.14      ASSERT(shadow_mode_translate(d));
    1.15  
    1.16 -    perfc_incrc(gpfn_to_mfn_foreign);
    1.17 +    perfc_incrc(get_mfn_from_pfn_foreign);
    1.18  
    1.19      va = gpfn << PAGE_SHIFT;
    1.20      tabpfn = pagetable_get_pfn(d->arch.phys_table);
     2.1 --- a/xen/arch/x86/shadow_public.c	Wed Nov 23 14:56:43 2005 +0100
     2.2 +++ b/xen/arch/x86/shadow_public.c	Mon Nov 28 15:09:44 2005 +0100
     2.3 @@ -1607,7 +1607,7 @@ remove_shadow(struct domain *d, unsigned
     2.4  }
     2.5  
     2.6  unsigned long
     2.7 -gpfn_to_mfn_foreign(struct domain *d, unsigned long gpfn)
     2.8 +get_mfn_from_pfn_foreign(struct domain *d, unsigned long gpfn)
     2.9  {
    2.10      unsigned long va, tabpfn;
    2.11      l1_pgentry_t *l1, l1e;
    2.12 @@ -1615,7 +1615,7 @@ gpfn_to_mfn_foreign(struct domain *d, un
    2.13  
    2.14      ASSERT(shadow_mode_translate(d));
    2.15  
    2.16 -    perfc_incrc(gpfn_to_mfn_foreign);
    2.17 +    perfc_incrc(get_mfn_from_pfn_foreign);
    2.18  
    2.19      va = gpfn << PAGE_SHIFT;
    2.20      tabpfn = pagetable_get_pfn(d->arch.phys_table);
     3.1 --- a/xen/common/grant_table.c	Wed Nov 23 14:56:43 2005 +0100
     3.2 +++ b/xen/common/grant_table.c	Mon Nov 28 15:09:44 2005 +0100
     3.3 @@ -234,7 +234,7 @@ static int
     3.4  
     3.5          /* rmb(); */ /* not on x86 */
     3.6  
     3.7 -        frame = __gpfn_to_mfn_foreign(rd, sha->frame);
     3.8 +        frame = __gpfn_to_mfn(rd, sha->frame);
     3.9  
    3.10          if ( unlikely(!pfn_valid(frame)) ||
    3.11               unlikely(!((dev_hst_ro_flags & GNTMAP_readonly) ?
     4.1 --- a/xen/include/asm-x86/shadow.h	Wed Nov 23 14:56:43 2005 +0100
     4.2 +++ b/xen/include/asm-x86/shadow.h	Mon Nov 28 15:09:44 2005 +0100
     4.3 @@ -285,22 +285,19 @@ static inline void shadow_mode_disable(s
     4.4  
     4.5  #define __mfn_to_gpfn(_d, mfn)                         \
     4.6      ( (shadow_mode_translate(_d))                      \
     4.7 -      ? get_pfn_from_mfn(mfn)                                   \
     4.8 +      ? get_pfn_from_mfn(mfn)                          \
     4.9        : (mfn) )
    4.10  
    4.11  #define __gpfn_to_mfn(_d, gpfn)                        \
    4.12      ({                                                 \
    4.13 -        (shadow_mode_translate(_d))                    \
    4.14 -        ? get_mfn_from_pfn(gpfn)                \
    4.15 +        unlikely(shadow_mode_translate(_d))            \
    4.16 +        ? (likely(current->domain == (_d))             \
    4.17 +           ? get_mfn_from_pfn(gpfn)                    \
    4.18 +           : get_mfn_from_pfn_foreign(_d, gpfn))       \
    4.19          : (gpfn);                                      \
    4.20      })
    4.21  
    4.22 -#define __gpfn_to_mfn_foreign(_d, gpfn)                \
    4.23 -    ( (shadow_mode_translate(_d))                      \
    4.24 -      ? gpfn_to_mfn_foreign(_d, gpfn)                  \
    4.25 -      : (gpfn) )
    4.26 -
    4.27 -extern unsigned long gpfn_to_mfn_foreign(
    4.28 +extern unsigned long get_mfn_from_pfn_foreign(
    4.29      struct domain *d, unsigned long gpfn);
    4.30  
    4.31  /************************************************************************/
    4.32 @@ -871,18 +868,7 @@ static inline void hl2e_propagate_from_g
    4.33  
    4.34      if ( l2e_get_flags(gpde) & _PAGE_PRESENT )
    4.35      {
    4.36 -        if ( unlikely((current->domain != d) && !shadow_mode_external(d)) )
    4.37 -        {
    4.38 -            // Can't use __gpfn_to_mfn() if we don't have one of this domain's
    4.39 -            // page tables currently installed.
    4.40 -            // This isn't common -- it only happens during shadow mode setup
    4.41 -            // and mode changes.
    4.42 -            //
    4.43 -            mfn = gpfn_to_mfn_foreign(d, pfn);
    4.44 -        }
    4.45 -        else
    4.46 -            mfn = __gpfn_to_mfn(d, pfn);
    4.47 -
    4.48 +        mfn = __gpfn_to_mfn(d, pfn);
    4.49          if ( VALID_MFN(mfn) && (mfn < max_page) )
    4.50              hl2e = l1e_from_pfn(mfn, __PAGE_HYPERVISOR);
    4.51      }
     5.1 --- a/xen/include/xen/perfc_defn.h	Wed Nov 23 14:56:43 2005 +0100
     5.2 +++ b/xen/include/xen/perfc_defn.h	Mon Nov 28 15:09:44 2005 +0100
     5.3 @@ -114,7 +114,7 @@ PERFCOUNTER_CPU(shadow_get_page_fail,   
     5.4  PERFCOUNTER_CPU(validate_hl2e_calls,    "calls to validate_hl2e_change")
     5.5  PERFCOUNTER_CPU(validate_hl2e_changes,  "validate_hl2e makes changes")
     5.6  PERFCOUNTER_CPU(exception_fixed,        "pre-exception fixed")
     5.7 -PERFCOUNTER_CPU(gpfn_to_mfn_foreign,    "calls to gpfn_to_mfn_foreign")
     5.8 +PERFCOUNTER_CPU(get_mfn_from_pfn_foreign, "calls to get_mfn_from_pfn_foreign")
     5.9  PERFCOUNTER_CPU(remove_all_access,      "calls to remove_all_access")
    5.10  PERFCOUNTER_CPU(remove_write_access,    "calls to remove_write_access")
    5.11  PERFCOUNTER_CPU(remove_write_access_easy, "easy outs of remove_write_access")