mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 21:22:09 -04:00
soc: qcom: secure_buffer: track all hyp based secure pages
To track all secure pages which are not stage 2 mapped to APPS, add a MAGIC in page->private. Change-Id: I4674f74eca95eeb36f004185a5d9cb0d63d558b0 Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
This commit is contained in:
parent
c322899f4a
commit
532b5fece2
1 changed files with 29 additions and 0 deletions
|
|
@ -145,6 +145,22 @@ static int batched_hyp_assign(struct sg_table *table, u32 *source_vmids,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline void set_each_page_of_sg(struct sg_table *table, u64 flag)
|
||||
{
|
||||
struct scatterlist *sg;
|
||||
int npages;
|
||||
int i = 0;
|
||||
|
||||
for_each_sg(table->sgl, sg, table->nents, i) {
|
||||
npages = sg->length / PAGE_SIZE;
|
||||
if (sg->length % PAGE_SIZE)
|
||||
npages++;
|
||||
while (npages--)
|
||||
set_page_private(nth_page(sg_page(sg), npages), flag);
|
||||
}
|
||||
}
|
||||
|
||||
#define SECURE_PAGE_MAGIC 0xEEEEEEEE
|
||||
/*
|
||||
* When -EADDRNOTAVAIL is returned the memory may no longer be in
|
||||
* a usable state and should no longer be accessed by the HLOS.
|
||||
|
|
@ -206,6 +222,19 @@ int hyp_assign_table(struct sg_table *table,
|
|||
ret = batched_hyp_assign(table, source_vm_copy, source_vm_copy_size,
|
||||
dest_vm_copy, dest_vm_copy_size);
|
||||
|
||||
if (!ret) {
|
||||
while (dest_nelems--) {
|
||||
if (dest_vmids[dest_nelems] == VMID_HLOS)
|
||||
break;
|
||||
}
|
||||
|
||||
if (dest_nelems == -1)
|
||||
set_each_page_of_sg(table, SECURE_PAGE_MAGIC);
|
||||
else
|
||||
set_each_page_of_sg(table, 0);
|
||||
}
|
||||
|
||||
|
||||
dma_unmap_single(qcom_secure_buffer_dev, dest_dma_addr,
|
||||
dest_vm_copy_size, DMA_TO_DEVICE);
|
||||
out_free_dest:
|
||||
|
|
|
|||
Loading…
Reference in a new issue