Loading drivers/iommu/arm-smmu.c +26 −11 Original line number Diff line number Diff line Loading @@ -2481,22 +2481,16 @@ static int arm_smmu_prepare_pgtable(void *addr, void *cookie) } static void arm_smmu_prealloc_memory(struct arm_smmu_domain *smmu_domain, struct scatterlist *sgl, int nents, struct list_head *pool) size_t size, struct list_head *pool) { u32 nr = 0; int i; size_t size = 0; struct scatterlist *sg; u32 nr = 0; struct page *page; if ((smmu_domain->attributes & (1 << DOMAIN_ATTR_ATOMIC)) || arm_smmu_has_secure_vmid(smmu_domain)) return; for_each_sg(sgl, sg, nents, i) size += sg->length; /* number of 2nd level pagetable entries */ nr += round_up(size, SZ_1G) >> 30; /* number of 3rd level pagetabel entries */ Loading @@ -2511,16 +2505,32 @@ static void arm_smmu_prealloc_memory(struct arm_smmu_domain *smmu_domain, } } static void arm_smmu_prealloc_memory_sg(struct arm_smmu_domain *smmu_domain, struct scatterlist *sgl, int nents, struct list_head *pool) { int i; size_t size = 0; struct scatterlist *sg; if ((smmu_domain->attributes & (1 << DOMAIN_ATTR_ATOMIC)) || arm_smmu_has_secure_vmid(smmu_domain)) return; for_each_sg(sgl, sg, nents, i) size += sg->length; arm_smmu_prealloc_memory(smmu_domain, size, pool); } static void arm_smmu_release_prealloc_memory( struct arm_smmu_domain *smmu_domain, struct list_head *list) { struct page *page, *tmp; u32 remaining = 0; list_for_each_entry_safe(page, tmp, list, lru) { list_del(&page->lru); __free_pages(page, 0); remaining++; } } Loading Loading @@ -2602,6 +2612,7 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova, unsigned long flags; struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops; LIST_HEAD(nonsecure_pool); if (!ops) return -ENODEV; Loading @@ -2609,15 +2620,19 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova, if (arm_smmu_is_slave_side_secure(smmu_domain)) return msm_secure_smmu_map(domain, iova, paddr, size, prot); arm_smmu_prealloc_memory(smmu_domain, size, &nonsecure_pool); arm_smmu_secure_domain_lock(smmu_domain); spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags); list_splice_init(&nonsecure_pool, &smmu_domain->nonsecure_pool); ret = ops->map(ops, iova, paddr, size, prot); list_splice_init(&smmu_domain->nonsecure_pool, &nonsecure_pool); spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags); arm_smmu_assign_table(smmu_domain); arm_smmu_secure_domain_unlock(smmu_domain); arm_smmu_release_prealloc_memory(smmu_domain, &nonsecure_pool); return ret; } Loading Loading @@ -2695,7 +2710,7 @@ static size_t arm_smmu_map_sg(struct iommu_domain *domain, unsigned long iova, if (arm_smmu_is_slave_side_secure(smmu_domain)) return msm_secure_smmu_map_sg(domain, iova, sg, nents, prot); arm_smmu_prealloc_memory(smmu_domain, sg, nents, &nonsecure_pool); arm_smmu_prealloc_memory_sg(smmu_domain, sg, nents, &nonsecure_pool); arm_smmu_secure_domain_lock(smmu_domain); __saved_iova_start = iova; Loading drivers/staging/android/ion/msm/msm_ion.c +4 −1 Original line number Diff line number Diff line Loading @@ -659,7 +659,8 @@ bool is_secure_vmid_valid(int vmid) vmid == VMID_CP_CAMERA_PREVIEW || vmid == VMID_CP_SPSS_SP || vmid == VMID_CP_SPSS_SP_SHARED || vmid == VMID_CP_SPSS_HLOS_SHARED); vmid == VMID_CP_SPSS_HLOS_SHARED || vmid == VMID_CP_CDSP); } unsigned int count_set_bits(unsigned long val) Loading Loading @@ -709,6 +710,8 @@ int get_secure_vmid(unsigned long flags) return VMID_CP_SPSS_SP_SHARED; if (flags & ION_FLAG_CP_SPSS_HLOS_SHARED) return VMID_CP_SPSS_HLOS_SHARED; if (flags & ION_FLAG_CP_CDSP) return VMID_CP_CDSP; return -EINVAL; } Loading drivers/staging/android/uapi/msm_ion.h +2 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ enum cp_mem_usage { #define ION_FLAG_CP_SEC_DISPLAY ION_BIT(25) #define ION_FLAG_CP_APP ION_BIT(26) #define ION_FLAG_CP_CAMERA_PREVIEW ION_BIT(27) /* ION_FLAG_ALLOW_NON_CONTIG uses ION_BIT(28) */ #define ION_FLAG_CP_CDSP ION_BIT(29) #define ION_FLAG_CP_SPSS_HLOS_SHARED ION_BIT(30) /** Loading include/soc/qcom/secure_buffer.h +2 −1 Original line number Diff line number Diff line /* * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -41,6 +41,7 @@ enum vmid { VMID_CP_CAMERA_PREVIEW = 0x1D, VMID_CP_SPSS_SP_SHARED = 0x22, VMID_CP_SPSS_HLOS_SHARED = 0x24, VMID_CP_CDSP = 0x2A, VMID_LAST, VMID_INVAL = -1 }; Loading Loading
drivers/iommu/arm-smmu.c +26 −11 Original line number Diff line number Diff line Loading @@ -2481,22 +2481,16 @@ static int arm_smmu_prepare_pgtable(void *addr, void *cookie) } static void arm_smmu_prealloc_memory(struct arm_smmu_domain *smmu_domain, struct scatterlist *sgl, int nents, struct list_head *pool) size_t size, struct list_head *pool) { u32 nr = 0; int i; size_t size = 0; struct scatterlist *sg; u32 nr = 0; struct page *page; if ((smmu_domain->attributes & (1 << DOMAIN_ATTR_ATOMIC)) || arm_smmu_has_secure_vmid(smmu_domain)) return; for_each_sg(sgl, sg, nents, i) size += sg->length; /* number of 2nd level pagetable entries */ nr += round_up(size, SZ_1G) >> 30; /* number of 3rd level pagetabel entries */ Loading @@ -2511,16 +2505,32 @@ static void arm_smmu_prealloc_memory(struct arm_smmu_domain *smmu_domain, } } static void arm_smmu_prealloc_memory_sg(struct arm_smmu_domain *smmu_domain, struct scatterlist *sgl, int nents, struct list_head *pool) { int i; size_t size = 0; struct scatterlist *sg; if ((smmu_domain->attributes & (1 << DOMAIN_ATTR_ATOMIC)) || arm_smmu_has_secure_vmid(smmu_domain)) return; for_each_sg(sgl, sg, nents, i) size += sg->length; arm_smmu_prealloc_memory(smmu_domain, size, pool); } static void arm_smmu_release_prealloc_memory( struct arm_smmu_domain *smmu_domain, struct list_head *list) { struct page *page, *tmp; u32 remaining = 0; list_for_each_entry_safe(page, tmp, list, lru) { list_del(&page->lru); __free_pages(page, 0); remaining++; } } Loading Loading @@ -2602,6 +2612,7 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova, unsigned long flags; struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops; LIST_HEAD(nonsecure_pool); if (!ops) return -ENODEV; Loading @@ -2609,15 +2620,19 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova, if (arm_smmu_is_slave_side_secure(smmu_domain)) return msm_secure_smmu_map(domain, iova, paddr, size, prot); arm_smmu_prealloc_memory(smmu_domain, size, &nonsecure_pool); arm_smmu_secure_domain_lock(smmu_domain); spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags); list_splice_init(&nonsecure_pool, &smmu_domain->nonsecure_pool); ret = ops->map(ops, iova, paddr, size, prot); list_splice_init(&smmu_domain->nonsecure_pool, &nonsecure_pool); spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags); arm_smmu_assign_table(smmu_domain); arm_smmu_secure_domain_unlock(smmu_domain); arm_smmu_release_prealloc_memory(smmu_domain, &nonsecure_pool); return ret; } Loading Loading @@ -2695,7 +2710,7 @@ static size_t arm_smmu_map_sg(struct iommu_domain *domain, unsigned long iova, if (arm_smmu_is_slave_side_secure(smmu_domain)) return msm_secure_smmu_map_sg(domain, iova, sg, nents, prot); arm_smmu_prealloc_memory(smmu_domain, sg, nents, &nonsecure_pool); arm_smmu_prealloc_memory_sg(smmu_domain, sg, nents, &nonsecure_pool); arm_smmu_secure_domain_lock(smmu_domain); __saved_iova_start = iova; Loading
drivers/staging/android/ion/msm/msm_ion.c +4 −1 Original line number Diff line number Diff line Loading @@ -659,7 +659,8 @@ bool is_secure_vmid_valid(int vmid) vmid == VMID_CP_CAMERA_PREVIEW || vmid == VMID_CP_SPSS_SP || vmid == VMID_CP_SPSS_SP_SHARED || vmid == VMID_CP_SPSS_HLOS_SHARED); vmid == VMID_CP_SPSS_HLOS_SHARED || vmid == VMID_CP_CDSP); } unsigned int count_set_bits(unsigned long val) Loading Loading @@ -709,6 +710,8 @@ int get_secure_vmid(unsigned long flags) return VMID_CP_SPSS_SP_SHARED; if (flags & ION_FLAG_CP_SPSS_HLOS_SHARED) return VMID_CP_SPSS_HLOS_SHARED; if (flags & ION_FLAG_CP_CDSP) return VMID_CP_CDSP; return -EINVAL; } Loading
drivers/staging/android/uapi/msm_ion.h +2 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ enum cp_mem_usage { #define ION_FLAG_CP_SEC_DISPLAY ION_BIT(25) #define ION_FLAG_CP_APP ION_BIT(26) #define ION_FLAG_CP_CAMERA_PREVIEW ION_BIT(27) /* ION_FLAG_ALLOW_NON_CONTIG uses ION_BIT(28) */ #define ION_FLAG_CP_CDSP ION_BIT(29) #define ION_FLAG_CP_SPSS_HLOS_SHARED ION_BIT(30) /** Loading
include/soc/qcom/secure_buffer.h +2 −1 Original line number Diff line number Diff line /* * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -41,6 +41,7 @@ enum vmid { VMID_CP_CAMERA_PREVIEW = 0x1D, VMID_CP_SPSS_SP_SHARED = 0x22, VMID_CP_SPSS_HLOS_SHARED = 0x24, VMID_CP_CDSP = 0x2A, VMID_LAST, VMID_INVAL = -1 }; Loading