[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] xen/arm: Rework lpae_mapping
commit 7e6a733405b4f4221da51b6c4e5a735b8e64ede8 Author: Julien Grall <julien.grall@xxxxxxx> AuthorDate: Mon Jul 16 18:27:03 2018 +0100 Commit: Julien Grall <julien.grall@xxxxxxx> CommitDate: Wed Aug 22 16:33:37 2018 +0100 xen/arm: Rework lpae_mapping Currently, lpae_mapping can only work on entry from any level other than 3. Make it work with any level by extending the prototype to pass the level. At the same time, rename the function to lpae_is_mapping so naming stay consistent accross lpae_* helpers. Signed-off-by: Julien Grall <julien.grall@xxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- xen/arch/arm/p2m.c | 12 +++++++----- xen/include/asm-arm/lpae.h | 13 +++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index ebf74760fa..72a84a33fd 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -241,7 +241,8 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry); * GUEST_TABLE_SUPER_PAGE: The next entry points to a superpage. */ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, - lpae_t **table, unsigned int offset) + unsigned int level, lpae_t **table, + unsigned int offset) { lpae_t *entry; int ret; @@ -260,7 +261,8 @@ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, } /* The function p2m_next_level is never called at the 3rd level */ - if ( lpae_mapping(*entry) ) + ASSERT(level < 3); + if ( lpae_is_mapping(*entry, level) ) return GUEST_TABLE_SUPER_PAGE; mfn = _mfn(entry->p2m.base); @@ -331,7 +333,7 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn, for ( level = P2M_ROOT_LEVEL; level < 3; level++ ) { - rc = p2m_next_level(p2m, true, &table, offsets[level]); + rc = p2m_next_level(p2m, true, level, &table, offsets[level]); if ( rc == GUEST_TABLE_MAP_FAILED ) goto out_unmap; else if ( rc != GUEST_TABLE_NORMAL_PAGE ) @@ -804,7 +806,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * is about to be removed (i.e mfn == INVALID_MFN). */ rc = p2m_next_level(p2m, mfn_eq(smfn, INVALID_MFN), - &table, offsets[level]); + level, &table, offsets[level]); if ( rc == GUEST_TABLE_MAP_FAILED ) { /* @@ -861,7 +863,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, /* then move to the level we want to make real changes */ for ( ; level < target; level++ ) { - rc = p2m_next_level(p2m, true, &table, offsets[level]); + rc = p2m_next_level(p2m, true, level, &table, offsets[level]); /* * The entry should be found and either be a table diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h index b30853e79d..4cf188ff82 100644 --- a/xen/include/asm-arm/lpae.h +++ b/xen/include/asm-arm/lpae.h @@ -134,7 +134,7 @@ static inline bool lpae_valid(lpae_t pte) } /* - * These two can only be used on L0..L2 ptes because L3 mappings set + * This one can only be used on L0..L2 ptes because L3 mappings set * the table bit and therefore these would return the opposite to what * you would expect. */ @@ -143,14 +143,19 @@ static inline bool lpae_table(lpae_t pte) return lpae_valid(pte) && pte.walk.table; } -static inline bool lpae_mapping(lpae_t pte) +static inline bool lpae_is_mapping(lpae_t pte, unsigned int level) { - return lpae_valid(pte) && !pte.walk.table; + if ( !lpae_valid(pte) ) + return false; + else if ( level == 3 ) + return pte.walk.table; + else + return !pte.walk.table; } static inline bool lpae_is_superpage(lpae_t pte, unsigned int level) { - return (level < 3) && lpae_mapping(pte); + return (level < 3) && lpae_is_mapping(pte, level); } static inline bool lpae_is_page(lpae_t pte, unsigned int level) -- generated by git-patchbot for /home/xen/git/xen.git#staging _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |