Merge "ion: Set the page private bit for secure CMA buffers"

This commit is contained in:
Linux Build Service Account 2017-08-03 20:51:28 -07:00 committed by Gerrit - the friendly Code Review server
commit a0a59b7732

View file

@ -237,10 +237,12 @@ void ion_cma_heap_destroy(struct ion_heap *heap)
static void ion_secure_cma_free(struct ion_buffer *buffer)
{
int ret = 0;
int i, ret = 0;
int source_vm;
int dest_vmid;
int dest_perms;
struct sg_table *sgt;
struct scatterlist *sg;
struct ion_cma_buffer_info *info = buffer->priv_virt;
source_vm = get_secure_vmid(buffer->flags);
@ -251,14 +253,17 @@ static void ion_secure_cma_free(struct ion_buffer *buffer)
dest_vmid = VMID_HLOS;
dest_perms = PERM_READ | PERM_WRITE | PERM_EXEC;
ret = hyp_assign_table(info->table, &source_vm, 1,
&dest_vmid, &dest_perms, 1);
sgt = info->table;
ret = hyp_assign_table(sgt, &source_vm, 1, &dest_vmid, &dest_perms, 1);
if (ret) {
pr_err("%s: Not freeing memory since assign failed\n",
__func__);
return;
}
for_each_sg(sgt->sgl, sg, sgt->nents, i)
ClearPagePrivate(sg_page(sgt->sgl));
ion_cma_free(buffer);
}
@ -266,11 +271,13 @@ static int ion_secure_cma_allocate(struct ion_heap *heap,
struct ion_buffer *buffer, unsigned long len,
unsigned long align, unsigned long flags)
{
int ret = 0;
int i, ret = 0;
int source_vm;
int dest_vm;
int dest_perms;
struct ion_cma_buffer_info *info;
struct sg_table *sgt;
struct scatterlist *sg;
source_vm = VMID_HLOS;
dest_vm = get_secure_vmid(flags);
@ -292,12 +299,17 @@ static int ion_secure_cma_allocate(struct ion_heap *heap,
}
info = buffer->priv_virt;
ret = hyp_assign_table(info->table, &source_vm, 1,
&dest_vm, &dest_perms, 1);
sgt = info->table;
ret = hyp_assign_table(sgt, &source_vm, 1, &dest_vm, &dest_perms, 1);
if (ret) {
pr_err("%s: Assign call failed\n", __func__);
goto err;
}
/* Set the private bit to indicate that we've secured this */
for_each_sg(sgt->sgl, sg, sgt->nents, i)
SetPagePrivate(sg_page(sgt->sgl));
return ret;
err: