From b7de9d8c047daea9e51b06244657659fd9576dee Mon Sep 17 00:00:00 2001 From: Jens Wiklander Date: Fri, 5 May 2023 21:21:55 +0200 Subject: [PATCH] core: remove unused mobj_mm_alloc() Removes the now unused mobj_mm_alloc(), struct mobj_mm, and friends. Signed-off-by: Jens Wiklander Acked-by: Etienne Carriere --- core/arch/arm/kernel/link_dummies_paged.c | 1 - core/include/mm/mobj.h | 3 - core/mm/mobj.c | 99 ----------------------- 3 files changed, 103 deletions(-) diff --git a/core/arch/arm/kernel/link_dummies_paged.c b/core/arch/arm/kernel/link_dummies_paged.c index e0b8d5a248f..d6d65c648fb 100644 --- a/core/arch/arm/kernel/link_dummies_paged.c +++ b/core/arch/arm/kernel/link_dummies_paged.c @@ -44,7 +44,6 @@ __thread_std_smc_entry(uint32_t a0 __unused, uint32_t a1 __unused, const struct mobj_ops mobj_reg_shm_ops __rodata_dummy; const struct mobj_ops mobj_phys_ops __rodata_dummy; const struct mobj_ops mobj_virt_ops __rodata_dummy; -const struct mobj_ops mobj_mm_ops __rodata_dummy; const struct mobj_ops mobj_shm_ops __rodata_dummy; const struct mobj_ops mobj_with_fobj_ops __rodata_dummy; const struct fobj_ops ops_rwp_paged_iv __rodata_dummy; diff --git a/core/include/mm/mobj.h b/core/include/mm/mobj.h index aefdba275c8..3b73b000809 100644 --- a/core/include/mm/mobj.h +++ b/core/include/mm/mobj.h @@ -226,9 +226,6 @@ static inline bool mobj_check_offset_and_len(struct mobj *mobj, size_t offset, end_offs < mobj->size; } -struct mobj *mobj_mm_alloc(struct mobj *mobj_parent, size_t size, - tee_mm_pool_t *pool); - struct mobj *mobj_phys_alloc(paddr_t pa, size_t size, uint32_t cattr, enum buf_is_attr battr); diff --git a/core/mm/mobj.c b/core/mm/mobj.c index 1cf414efe24..afc8176d154 100644 --- a/core/mm/mobj.c +++ b/core/mm/mobj.c @@ -237,105 +237,6 @@ static void mobj_virt_assert_type(struct mobj *mobj __maybe_unused) struct mobj mobj_virt = { .ops = &mobj_virt_ops, .size = SIZE_MAX }; -/* - * mobj_mm implementation - */ - -struct mobj_mm { - tee_mm_entry_t *mm; - struct mobj *parent_mobj; - struct mobj mobj; -}; - -static struct mobj_mm *to_mobj_mm(struct mobj *mobj); - -static size_t mobj_mm_offs(struct mobj *mobj, size_t offs) -{ - tee_mm_entry_t *mm = to_mobj_mm(mobj)->mm; - - return (mm->offset << mm->pool->shift) + offs; -} - -static void *mobj_mm_get_va(struct mobj *mobj, size_t offs, size_t len) -{ - return mobj_get_va(to_mobj_mm(mobj)->parent_mobj, - mobj_mm_offs(mobj, offs), len); -} - - -static TEE_Result mobj_mm_get_pa(struct mobj *mobj, size_t offs, - size_t granule, paddr_t *pa) -{ - return mobj_get_pa(to_mobj_mm(mobj)->parent_mobj, - mobj_mm_offs(mobj, offs), granule, pa); -} -DECLARE_KEEP_PAGER(mobj_mm_get_pa); - -static size_t mobj_mm_get_phys_offs(struct mobj *mobj, size_t granule) -{ - return mobj_get_phys_offs(to_mobj_mm(mobj)->parent_mobj, granule); -} - -static TEE_Result mobj_mm_get_mem_type(struct mobj *mobj, uint32_t *mem_type) -{ - return mobj_get_mem_type(to_mobj_mm(mobj)->parent_mobj, mem_type); -} - -static bool mobj_mm_matches(struct mobj *mobj, enum buf_is_attr attr) -{ - return mobj_matches(to_mobj_mm(mobj)->parent_mobj, attr); -} - -static void mobj_mm_free(struct mobj *mobj) -{ - struct mobj_mm *m = to_mobj_mm(mobj); - - tee_mm_free(m->mm); - free(m); -} - -/* - * Note: this variable is weak just to ease breaking its dependency chain - * when added to the unpaged area. - */ -const struct mobj_ops mobj_mm_ops __weak __relrodata_unpaged("mobj_mm_ops") = { - .get_va = mobj_mm_get_va, - .get_pa = mobj_mm_get_pa, - .get_phys_offs = mobj_mm_get_phys_offs, - .get_mem_type = mobj_mm_get_mem_type, - .matches = mobj_mm_matches, - .free = mobj_mm_free, -}; - -static struct mobj_mm *to_mobj_mm(struct mobj *mobj) -{ - assert(mobj->ops == &mobj_mm_ops); - return container_of(mobj, struct mobj_mm, mobj); -} - -struct mobj *mobj_mm_alloc(struct mobj *mobj_parent, size_t size, - tee_mm_pool_t *pool) -{ - struct mobj_mm *m = calloc(1, sizeof(*m)); - - if (!m) - return NULL; - - m->mm = tee_mm_alloc(pool, size); - if (!m->mm) { - free(m); - return NULL; - } - - m->parent_mobj = mobj_parent; - m->mobj.size = size; - m->mobj.ops = &mobj_mm_ops; - refcount_set(&m->mobj.refc, 1); - - return &m->mobj; -} - - /* * mobj_shm implementation. mobj_shm represents buffer in predefined shm region * - it is physically contiguous.