ion: Set the page private bit on secure buffers
Set the private page bit on each sg of secure buffers to inform other entities, which import these buffers as an fd, that this memory is secure. Change-Id: I767c26fa1feca7505bbb3293cfdb4e09520496a6 Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
This commit is contained in:
parent
e6051f3f41
commit
aeb2abd83d
1 changed files with 15 additions and 0 deletions
|
@ -52,9 +52,12 @@ static int get_secure_vmid(unsigned long flags)
|
||||||
static void ion_system_secure_heap_free(struct ion_buffer *buffer)
|
static void ion_system_secure_heap_free(struct ion_buffer *buffer)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int i;
|
||||||
u32 source_vm;
|
u32 source_vm;
|
||||||
int dest_vmid;
|
int dest_vmid;
|
||||||
int dest_perms;
|
int dest_perms;
|
||||||
|
struct sg_table *sgt;
|
||||||
|
struct scatterlist *sg;
|
||||||
struct ion_heap *heap = buffer->heap;
|
struct ion_heap *heap = buffer->heap;
|
||||||
struct ion_system_secure_heap *secure_heap = container_of(heap,
|
struct ion_system_secure_heap *secure_heap = container_of(heap,
|
||||||
struct ion_system_secure_heap,
|
struct ion_system_secure_heap,
|
||||||
|
@ -76,6 +79,10 @@ static void ion_system_secure_heap_free(struct ion_buffer *buffer)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sgt = buffer->priv_virt;
|
||||||
|
for_each_sg(sgt->sgl, sg, sgt->nents, i)
|
||||||
|
ClearPagePrivate(sg_page(sg));
|
||||||
|
|
||||||
buffer->heap = secure_heap->sys_heap;
|
buffer->heap = secure_heap->sys_heap;
|
||||||
secure_heap->sys_heap->ops->free(buffer);
|
secure_heap->sys_heap->ops->free(buffer);
|
||||||
}
|
}
|
||||||
|
@ -86,9 +93,12 @@ static int ion_system_secure_heap_allocate(struct ion_heap *heap,
|
||||||
unsigned long flags)
|
unsigned long flags)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int i;
|
||||||
u32 source_vm;
|
u32 source_vm;
|
||||||
int dest_vmid;
|
int dest_vmid;
|
||||||
int dest_perms;
|
int dest_perms;
|
||||||
|
struct sg_table *sgt;
|
||||||
|
struct scatterlist *sg;
|
||||||
struct ion_system_secure_heap *secure_heap = container_of(heap,
|
struct ion_system_secure_heap *secure_heap = container_of(heap,
|
||||||
struct ion_system_secure_heap,
|
struct ion_system_secure_heap,
|
||||||
heap);
|
heap);
|
||||||
|
@ -123,6 +133,11 @@ static int ion_system_secure_heap_allocate(struct ion_heap *heap,
|
||||||
pr_err("%s: Assign call failed\n", __func__);
|
pr_err("%s: Assign call failed\n", __func__);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sgt = buffer->priv_virt;
|
||||||
|
for_each_sg(sgt->sgl, sg, sgt->nents, i)
|
||||||
|
SetPagePrivate(sg_page(sg));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
|
Loading…
Add table
Reference in a new issue