Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 878cf94a authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

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: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent f1efdc30
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
// 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)
{
+7 −0
Original line number Diff line number Diff line
@@ -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 */