Skip to content

Commit

Permalink
core: bugfix core_mmu_user_mapping_is_active()
Browse files Browse the repository at this point in the history
Fixes race in both v7 and lpae versions of
core_mmu_user_mapping_is_active() by temporarily disabling interrupts.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU v8)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
jenswi-linaro committed Sep 4, 2017
1 parent 2c750ba commit 8d11aa4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/arch/arm/mm/core_mmu_lpae.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,14 @@ void core_mmu_get_user_va_range(vaddr_t *base, size_t *size)

bool core_mmu_user_mapping_is_active(void)
{
bool ret;
uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_ALL);

assert(user_va_idx != -1);
return !!l1_xlation_table[get_core_pos()][user_va_idx];
ret = l1_xlation_table[get_core_pos()][user_va_idx];
thread_unmask_exceptions(exceptions);

return ret;
}

#ifdef ARM32
Expand Down
8 changes: 7 additions & 1 deletion core/arch/arm/mm/core_mmu_v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,13 @@ void core_mmu_set_user_map(struct core_mmu_user_map *map)

bool core_mmu_user_mapping_is_active(void)
{
return read_ttbr0() != read_ttbr1();
bool ret;
uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_ALL);

ret = read_ttbr0() != read_ttbr1();
thread_unmask_exceptions(exceptions);

return ret;
}

static void print_mmap_area(const struct tee_mmap_region *mm __maybe_unused,
Expand Down

0 comments on commit 8d11aa4

Please sign in to comment.