soc: qcom: secure_buffer: add API page_accessible

Add page_accessible to check if page is secure or not. It is used
to avoid EL2 fault for dumping memory region.

Change-Id: If71a810997fc97722722339a25839249bd05d9e2
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
This commit is contained in:
Zhenhua Huang 2020-07-22 16:57:08 +08:00 • committed by Gerrit - the friendly Code Review server
commit 724d27beef
2 changed files with 16 additions and 0 deletions

View file

@ -161,6 +161,16 @@ static inline void set_each_page_of_sg(struct sg_table *table, u64 flag)
}
#define SECURE_PAGE_MAGIC 0xEEEEEEEE
int page_accessible(unsigned long pfn)
{
struct page *page = pfn_to_page(pfn);
if (page->private == SECURE_PAGE_MAGIC)
return 0;
else
return 1;
}
/*
* When -EADDRNOTAVAIL is returned the memory may no longer be in
* a usable state and should no longer be accessed by the HLOS.

View file

@ -54,6 +54,7 @@ int hyp_assign_phys(phys_addr_t addr, u64 size,
int *dest_vmids, int *dest_perms, int dest_nelems);
const char *msm_secure_vmid_to_string(int secure_vmid);
u32 msm_secure_get_vmid_perms(u32 vmid);
int page_accessible(unsigned long pfn);
#else
static inline int hyp_assign_table(struct sg_table *table,
u32 *source_vm_list, int source_nelems,
@ -79,5 +80,10 @@ static inline u32 msm_secure_get_vmid_perms(u32 vmid)
{
return 0;
}
static inline int page_accessible(unsigned long pfn)
{
return 1;
}
#endif
#endif