ia64/xen-unstable

changeset 15834:453f87d6e7f0

[XSM] correctly located update_va_mapping hook within x86 ifdefs

The following patch addresses the issue where the XSM update_va_mapping
hook was not correctly located inside the x86 ifdefs. Included are
updates for the dummy and flask modules which are also effected by
this issue.

- update_va_mapping ifdef fix for xsm
- update_va_mapping ifdef fix for dummy module
- update_va_mapping ifdef fix for flask module

Signed-off-by: George Coker <gscoker@alpha.ncsc.mil>
author kfraser@localhost.localdomain
date Thu Sep 06 18:04:42 2007 +0100 (2007-09-06)
parents 447db1235adf
children 49b67fdefcd6
files xen/include/xsm/xsm.h xen/xsm/dummy.c xen/xsm/flask/hooks.c
line diff
     1.1 --- a/xen/include/xsm/xsm.h	Thu Sep 06 11:34:38 2007 +0100
     1.2 +++ b/xen/include/xsm/xsm.h	Thu Sep 06 18:04:42 2007 +0100
     1.3 @@ -99,7 +99,6 @@ struct xsm_operations {
     1.4      int (*memory_adjust_reservation) (struct domain *d1, struct domain *d2);
     1.5      int (*memory_stat_reservation) (struct domain *d1, struct domain *d2);
     1.6      int (*memory_pin_page) (struct domain *d, struct page_info *page);
     1.7 -    int (*update_va_mapping) (struct domain *d, l1_pgentry_t pte);
     1.8  
     1.9      int (*console_io) (struct domain *d, int cmd);
    1.10  
    1.11 @@ -135,6 +134,7 @@ struct xsm_operations {
    1.12      int (*domain_memory_map) (struct domain *d);
    1.13      int (*mmu_normal_update) (struct domain *d, intpte_t fpte);
    1.14      int (*mmu_machphys_update) (struct domain *d, unsigned long mfn);
    1.15 +    int (*update_va_mapping) (struct domain *d, l1_pgentry_t pte);
    1.16      int (*add_to_physmap) (struct domain *d1, struct domain *d2);
    1.17  #endif
    1.18  };
    1.19 @@ -366,11 +366,6 @@ static inline int xsm_memory_pin_page(st
    1.20      return xsm_call(memory_pin_page(d, page));
    1.21  }
    1.22  
    1.23 -static inline int xsm_update_va_mapping(struct domain *d, l1_pgentry_t pte)
    1.24 -{
    1.25 -    return xsm_call(update_va_mapping(d, pte));
    1.26 -}
    1.27 -
    1.28  static inline int xsm_console_io (struct domain *d, int cmd)
    1.29  {
    1.30      return xsm_call(console_io(d, cmd));
    1.31 @@ -528,6 +523,11 @@ static inline int xsm_mmu_machphys_updat
    1.32      return xsm_call(mmu_machphys_update(d, mfn));
    1.33  }
    1.34  
    1.35 +static inline int xsm_update_va_mapping(struct domain *d, l1_pgentry_t pte)
    1.36 +{
    1.37 +    return xsm_call(update_va_mapping(d, pte));
    1.38 +}
    1.39 +
    1.40  static inline int xsm_add_to_physmap(struct domain *d1, struct domain *d2)
    1.41  {
    1.42      return xsm_call(add_to_physmap(d1, d2));
     2.1 --- a/xen/xsm/dummy.c	Thu Sep 06 11:34:38 2007 +0100
     2.2 +++ b/xen/xsm/dummy.c	Thu Sep 06 18:04:42 2007 +0100
     2.3 @@ -187,11 +187,6 @@ static int dummy_memory_stat_reservation
     2.4      return 0;
     2.5  }
     2.6  
     2.7 -static int dummy_update_va_mapping (struct domain *d, l1_pgentry_t pte)
     2.8 -{
     2.9 -    return 0;
    2.10 -}
    2.11 -
    2.12  static int dummy_console_io (struct domain *d, int cmd)
    2.13  {
    2.14      return 0;
    2.15 @@ -381,6 +376,11 @@ static int dummy_mmu_machphys_update (st
    2.16      return 0;
    2.17  }
    2.18  
    2.19 +static int dummy_update_va_mapping (struct domain *d, l1_pgentry_t pte)
    2.20 +{
    2.21 +    return 0;
    2.22 +}
    2.23 +
    2.24  static int dummy_add_to_physmap (struct domain *d1, struct domain *d2)
    2.25  {
    2.26      return 0;
    2.27 @@ -448,7 +448,6 @@ void xsm_fixup_ops (struct xsm_operation
    2.28      set_to_dummy_if_null(ops, memory_adjust_reservation);
    2.29      set_to_dummy_if_null(ops, memory_stat_reservation);
    2.30      set_to_dummy_if_null(ops, memory_pin_page);
    2.31 -    set_to_dummy_if_null(ops, update_va_mapping);
    2.32  
    2.33      set_to_dummy_if_null(ops, console_io);
    2.34  
    2.35 @@ -483,6 +482,7 @@ void xsm_fixup_ops (struct xsm_operation
    2.36      set_to_dummy_if_null(ops, domain_memory_map);
    2.37      set_to_dummy_if_null(ops, mmu_normal_update);
    2.38      set_to_dummy_if_null(ops, mmu_machphys_update);
    2.39 +    set_to_dummy_if_null(ops, update_va_mapping);
    2.40      set_to_dummy_if_null(ops, add_to_physmap);
    2.41  #endif
    2.42  }
     3.1 --- a/xen/xsm/flask/hooks.c	Thu Sep 06 11:34:38 2007 +0100
     3.2 +++ b/xen/xsm/flask/hooks.c	Thu Sep 06 18:04:42 2007 +0100
     3.3 @@ -407,27 +407,6 @@ static DEFINE_PER_CPU(struct percpu_mm_i
     3.4   */
     3.5  #define FOREIGNDOM (this_cpu(percpu_mm_info).foreign ?: current->domain)
     3.6  
     3.7 -static int flask_update_va_mapping(struct domain *d, l1_pgentry_t pte)
     3.8 -{
     3.9 -    int rc = 0;
    3.10 -    u32 psid;
    3.11 -    u32 map_perms = MMU__MAP_READ;
    3.12 -    unsigned long mfn;
    3.13 -    struct domain_security_struct *dsec;
    3.14 -
    3.15 -    dsec = d->ssid;
    3.16 -
    3.17 -    mfn = gmfn_to_mfn(FOREIGNDOM, l1e_get_pfn(pte));        
    3.18 -    rc = get_mfn_sid(mfn, &psid);
    3.19 -    if ( rc )
    3.20 -        return rc;
    3.21 -
    3.22 -    if ( l1e_get_flags(pte) & _PAGE_RW )
    3.23 -        map_perms |= MMU__MAP_WRITE;
    3.24 -
    3.25 -    return avc_has_perm(dsec->sid, psid, SECCLASS_MMU, map_perms, NULL);
    3.26 -}
    3.27 -
    3.28  static int flask_console_io(struct domain *d, int cmd)
    3.29  {
    3.30      u32 perm;
    3.31 @@ -1036,6 +1015,27 @@ static int flask_mmu_machphys_update(str
    3.32      return avc_has_perm(dsec->sid, psid, SECCLASS_MMU, MMU__UPDATEMP, NULL);
    3.33  }
    3.34  
    3.35 +static int flask_update_va_mapping(struct domain *d, l1_pgentry_t pte)
    3.36 +{
    3.37 +    int rc = 0;
    3.38 +    u32 psid;
    3.39 +    u32 map_perms = MMU__MAP_READ;
    3.40 +    unsigned long mfn;
    3.41 +    struct domain_security_struct *dsec;
    3.42 +
    3.43 +    dsec = d->ssid;
    3.44 +
    3.45 +    mfn = gmfn_to_mfn(FOREIGNDOM, l1e_get_pfn(pte));        
    3.46 +    rc = get_mfn_sid(mfn, &psid);
    3.47 +    if ( rc )
    3.48 +        return rc;
    3.49 +
    3.50 +    if ( l1e_get_flags(pte) & _PAGE_RW )
    3.51 +        map_perms |= MMU__MAP_WRITE;
    3.52 +
    3.53 +    return avc_has_perm(dsec->sid, psid, SECCLASS_MMU, map_perms, NULL);
    3.54 +}
    3.55 +
    3.56  static int flask_add_to_physmap(struct domain *d1, struct domain *d2)
    3.57  {
    3.58      return domain_has_perm(d1, d2, SECCLASS_MMU, MMU__PHYSMAP);
    3.59 @@ -1090,7 +1090,6 @@ static struct xsm_operations flask_ops =
    3.60      .memory_adjust_reservation = flask_memory_adjust_reservation,
    3.61      .memory_stat_reservation = flask_memory_stat_reservation,
    3.62      .memory_pin_page = flask_memory_pin_page,
    3.63 -    .update_va_mapping = flask_update_va_mapping,
    3.64  
    3.65      .console_io = flask_console_io,
    3.66  
    3.67 @@ -1125,6 +1124,7 @@ static struct xsm_operations flask_ops =
    3.68      .domain_memory_map = flask_domain_memory_map,
    3.69      .mmu_normal_update = flask_mmu_normal_update,
    3.70      .mmu_machphys_update = flask_mmu_machphys_update,
    3.71 +    .update_va_mapping = flask_update_va_mapping,
    3.72      .add_to_physmap = flask_add_to_physmap,
    3.73  #endif
    3.74  };