xcp-1.6-updates/xen-4.1.hg

changeset 23233:637eaa1421d1

p2m: query/modify p2mt with p2m_lock held

Query and update the p2mt in set_mmio_p2m_entry, clear_mmio_p2m_entry
and set_shared_p2m_entry with the p2m_lock held.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
xen-unstable changeset: 23908:88b6e08b8aa8
xen-unstable date: Thu Oct 06 14:15:43 2011 +0100
author Olaf Hering <olaf@aepfle.de>
date Wed Mar 07 07:59:58 2012 +0000 (2012-03-07)
parents 7ee4016eeb9f
children a43a31a97603
files xen/arch/x86/mm/p2m.c
line diff
     1.1 --- a/xen/arch/x86/mm/p2m.c	Wed Mar 07 07:55:10 2012 +0000
     1.2 +++ b/xen/arch/x86/mm/p2m.c	Wed Mar 07 07:59:58 2012 +0000
     1.3 @@ -2752,9 +2752,11 @@ set_mmio_p2m_entry(struct p2m_domain *p2
     1.4      if ( !paging_mode_translate(p2m->domain) )
     1.5          return 0;
     1.6  
     1.7 +    p2m_lock(p2m);
     1.8      omfn = gfn_to_mfn_query(p2m, gfn, &ot);
     1.9      if ( p2m_is_grant(ot) )
    1.10      {
    1.11 +        p2m_unlock(p2m);
    1.12          domain_crash(p2m->domain);
    1.13          return 0;
    1.14      }
    1.15 @@ -2765,7 +2767,6 @@ set_mmio_p2m_entry(struct p2m_domain *p2
    1.16      }
    1.17  
    1.18      P2M_DEBUG("set mmio %lx %lx\n", gfn, mfn_x(mfn));
    1.19 -    p2m_lock(p2m);
    1.20      rc = set_p2m_entry(p2m, gfn, mfn, 0, p2m_mmio_direct, p2m->default_access);
    1.21      audit_p2m(p2m, 1);
    1.22      p2m_unlock(p2m);
    1.23 @@ -2786,18 +2787,20 @@ clear_mmio_p2m_entry(struct p2m_domain *
    1.24      if ( !paging_mode_translate(p2m->domain) )
    1.25          return 0;
    1.26  
    1.27 -    mfn = gfn_to_mfn(p2m, gfn, &t);
    1.28 +    p2m_lock(p2m);
    1.29 +    mfn = gfn_to_mfn_query(p2m, gfn, &t);
    1.30  
    1.31      /* Do not use mfn_valid() here as it will usually fail for MMIO pages. */
    1.32      if ( (INVALID_MFN == mfn_x(mfn)) || (t != p2m_mmio_direct) )
    1.33      {
    1.34          gdprintk(XENLOG_ERR,
    1.35              "clear_mmio_p2m_entry: gfn_to_mfn failed! gfn=%08lx\n", gfn);
    1.36 -        return 0;
    1.37 +        goto out;
    1.38      }
    1.39 -    p2m_lock(p2m);
    1.40      rc = set_p2m_entry(p2m, gfn, _mfn(INVALID_MFN), 0, p2m_invalid, p2m->default_access);
    1.41      audit_p2m(p2m, 1);
    1.42 +
    1.43 +out:
    1.44      p2m_unlock(p2m);
    1.45  
    1.46      return rc;
    1.47 @@ -2814,6 +2817,8 @@ set_shared_p2m_entry(struct p2m_domain *
    1.48      if ( !paging_mode_translate(p2m->domain) )
    1.49          return 0;
    1.50  
    1.51 +    if ( need_lock ) 
    1.52 +        p2m_lock(p2m);
    1.53      omfn = gfn_to_mfn_query(p2m, gfn, &ot);
    1.54      /* At the moment we only allow p2m change if gfn has already been made
    1.55       * sharable first */
    1.56 @@ -2823,8 +2828,6 @@ set_shared_p2m_entry(struct p2m_domain *
    1.57      set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
    1.58  
    1.59      P2M_DEBUG("set shared %lx %lx\n", gfn, mfn_x(mfn));
    1.60 -    if ( need_lock ) 
    1.61 -        p2m_lock(p2m);
    1.62      rc = set_p2m_entry(p2m, gfn, mfn, 0, p2m_ram_shared, p2m->default_access);
    1.63      if ( need_lock ) 
    1.64          p2m_unlock(p2m);