ion: msm: Add support for querying the security state of heaps

ION clients may want to know about the security state of a heap
prior to allocating from it, so expose an interface for querying
the security state of a heap.

Change-Id: Ibf832792ffbc81b5b96b8ddbc507db5418a47928
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
This commit is contained in:
Isaac J. Manjarres 2020-01-23 21:55:49 -08:00
commit 878cf94a7a
2 changed files with 21 additions and 1 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/err.h>
@ -229,6 +229,19 @@ struct device *msm_ion_heap_device_by_id(int heap_id)
}
EXPORT_SYMBOL(msm_ion_heap_device_by_id);
bool msm_ion_heap_is_secure(int heap_id)
{
struct ion_heap *heap = ion_heap_by_id(heap_id);
if (IS_ERR(heap) || !(heap->type == ION_HEAP_TYPE_SECURE_CARVEOUT ||
heap->type == ION_HEAP_TYPE_SYSTEM_SECURE ||
heap->type == ION_HEAP_TYPE_HYP_CMA))
return false;
return true;
}
EXPORT_SYMBOL(msm_ion_heap_is_secure);
int msm_ion_heap_prefetch(int heap_id, struct ion_prefetch_region *regions,
int nr_regions)
{

View file

@ -37,6 +37,8 @@ int msm_ion_heap_drain(int heap_id, struct ion_prefetch_region *regions,
int get_ion_flags(u32 vmid);
bool msm_ion_heap_is_secure(int heap_id);
#else
static inline struct device *msm_ion_heap_device_by_id(int heap_id)
@ -74,5 +76,10 @@ static inline int get_ion_flags(u32 vmid)
return -EINVAL;
}
static inline bool msm_ion_heap_is_secure(int heap_id)
{
return false;
}
#endif /* CONFIG_ION_MSM_HEAPS */
#endif /* _MSM_ION_H */