[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xen/arm: p2m: Use a whitelist rather than blacklist in get_page_from_gfn
commit ca8e5ddaa416983dd2b5840cb86eb768b8ebf8e9 Author: Julien Grall <julien.grall@xxxxxxx> AuthorDate: Thu Jul 28 15:20:07 2016 +0100 Commit: Stefano Stabellini <sstabellini@xxxxxxxxxx> CommitDate: Thu Jul 28 17:41:35 2016 -0700 xen/arm: p2m: Use a whitelist rather than blacklist in get_page_from_gfn Currently, the check in get_page_from_gfn is using a blacklist. This is very fragile because we may forgot to update the check when a new p2m type is added. To avoid any possible issue, use a whitelist. All type backed by a RAM page can could potential be valid. The check is borrowed from x86. Note with this change, it is not possible anymore to retrieve a page when the p2m type is p2m_iommu_map_*. This is fine because they are special mappings for direct mapping workaround and the associated GFN should be used at all by callers of get_page_from_gfn. Signed-off-by: Julien Grall <julien.grall@xxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- xen/include/asm-arm/p2m.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 3091c04..78d37ab 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -104,9 +104,16 @@ typedef enum { #define P2M_RAM_TYPES (p2m_to_mask(p2m_ram_rw) | \ p2m_to_mask(p2m_ram_ro)) +/* Grant mapping types, which map to a real frame in another VM */ +#define P2M_GRANT_TYPES (p2m_to_mask(p2m_grant_map_rw) | \ + p2m_to_mask(p2m_grant_map_ro)) + /* Useful predicates */ #define p2m_is_ram(_t) (p2m_to_mask(_t) & P2M_RAM_TYPES) #define p2m_is_foreign(_t) (p2m_to_mask(_t) & p2m_to_mask(p2m_map_foreign)) +#define p2m_is_any_ram(_t) (p2m_to_mask(_t) & \ + (P2M_RAM_TYPES | P2M_GRANT_TYPES | \ + p2m_to_mask(p2m_map_foreign))) static inline void p2m_mem_access_emulate_check(struct vcpu *v, @@ -224,7 +231,7 @@ static inline struct page_info *get_page_from_gfn( if (t) *t = p2mt; - if ( p2mt == p2m_invalid || p2mt == p2m_mmio_direct ) + if ( !p2m_is_any_ram(p2mt) ) return NULL; if ( !mfn_valid(mfn) ) -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |