Skip to content

Commit

Permalink
core: pager: use icache_inv_user_range()
Browse files Browse the repository at this point in the history
Prior to this patch the entire icache was invalidated when icache
invalidations was needed, even if it only was for a single page. This
was needed to reach a stable state with regards to paging user TAs.

With this patch a new function, icache_inv_user_range(), is used to
invalidate pages used by user TAs and icache_inv_range() is used instead
to invalidate kernel mode pages.

Signed-off-by: Jens Wiklander <[email protected]>
  • Loading branch information
jenswi-linaro committed May 13, 2019
1 parent 18ba97b commit 227c51a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions core/arch/arm/mm/tee_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <kernel/tee_ta_manager.h>
#include <kernel/thread.h>
#include <kernel/tlb_helpers.h>
#include <kernel/cache_helpers.h>
#include <mm/core_memprot.h>
#include <mm/fobj.h>
#include <mm/tee_mm.h>
Expand Down Expand Up @@ -950,7 +951,7 @@ bool tee_pager_set_uta_area_attr(struct user_ta_ctx *utc, vaddr_t base,

cache_op_inner(DCACHE_AREA_CLEAN, va,
SMALL_PAGE_SIZE);
cache_op_inner(ICACHE_INVALIDATE, NULL, 0);
icache_inv_user_range(va, SMALL_PAGE_SIZE);
}
}

Expand Down Expand Up @@ -1250,6 +1251,7 @@ bool tee_pager_handle_fault(struct abort_info *ai)
vaddr_t page_va = ai->va & ~SMALL_PAGE_MASK;
uint32_t exceptions;
bool ret;
bool clean_user_cache = false;

#ifdef TEE_PAGER_DEBUG_PRINT
abort_print(ai);
Expand All @@ -1273,11 +1275,13 @@ bool tee_pager_handle_fault(struct abort_info *ai)
/* check if the access is valid */
if (abort_is_user_exception(ai)) {
area = find_uta_area(ai->va);

clean_user_cache = true;
} else {
area = find_area(&tee_pager_area_head, ai->va);
if (!area)
if (!area) {
area = find_uta_area(ai->va);
clean_user_cache = true;
}
}
if (!area || !area->pgt) {
ret = false;
Expand Down Expand Up @@ -1365,7 +1369,12 @@ bool tee_pager_handle_fault(struct abort_info *ai)
*/
cache_op_inner(DCACHE_AREA_CLEAN, (void *)page_va,
SMALL_PAGE_SIZE);
cache_op_inner(ICACHE_INVALIDATE, NULL, 0);
if (clean_user_cache)
icache_inv_user_range((void *)page_va,
SMALL_PAGE_SIZE);
else
icache_inv_range((void *)page_va,
SMALL_PAGE_SIZE);

/* Set the final mapping */
area_set_entry(area, tblidx, pa, attr);
Expand Down

0 comments on commit 227c51a

Please sign in to comment.