Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a75db7c0 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge changes If907a0ba,I661f8ca8,Ibcddbafe into msm-next

* changes:
  msm: secure_buffer: Add helper function to convert VMIDs into strings
  msm: secure_buffer: Ensure shared buffers are cache-aligned
  msm: Add secure vmid for msa
parents 33bfb9f0 6ab54ff4
Loading
Loading
Loading
Loading
+51 −4
Original line number Diff line number Diff line
@@ -276,6 +276,7 @@ int hyp_assign_table(struct sg_table *table,
	struct info_list *info_list = NULL;
	struct dest_info_list *dest_info_list = NULL;
	struct scm_desc desc = {0};
	u32 *source_vm_copy;

	info_list = get_info_list_from_table(table);
	if (!info_list)
@@ -288,10 +289,23 @@ int hyp_assign_table(struct sg_table *table,
		goto err1;
	}

	/*
	 * We can only pass cache-aligned sizes to hypervisor, so we need
	 * to kmalloc and memcpy the source_vm_list here.
	 */
	source_vm_copy = kmalloc_array(
		source_nelems, sizeof(*source_vm_copy), GFP_KERNEL);
	if (!source_vm_copy) {
		ret = -ENOMEM;
		goto err2;
	}
	memcpy(source_vm_copy, source_vm_list,
	       sizeof(*source_vm_list) * source_nelems);

	desc.args[0] = virt_to_phys(info_list->list_head);
	desc.args[1] = info_list->list_size;
	desc.args[2] = virt_to_phys(source_vm_list);
	desc.args[3] = sizeof(*source_vm_list) * source_nelems;
	desc.args[2] = virt_to_phys(source_vm_copy);
	desc.args[3] = sizeof(*source_vm_copy) * source_nelems;
	desc.args[4] = virt_to_phys(dest_info_list->dest_info);
	desc.args[5] = dest_info_list->list_size;
	desc.args[6] = 0;
@@ -299,7 +313,7 @@ int hyp_assign_table(struct sg_table *table,
	desc.arginfo = SCM_ARGS(7, SCM_RO, SCM_VAL, SCM_RO, SCM_VAL, SCM_RO,
				SCM_VAL, SCM_VAL);

	dmac_flush_range(source_vm_list, source_vm_list + source_nelems);
	dmac_flush_range(source_vm_copy, source_vm_copy + source_nelems);
	dmac_flush_range(info_list->list_head, info_list->list_head +
		(info_list->list_size / sizeof(*info_list->list_head)));
	dmac_flush_range(dest_info_list->dest_info, dest_info_list->dest_info +
@@ -312,8 +326,9 @@ int hyp_assign_table(struct sg_table *table,
		pr_info("%s: Failed to assign memory protection, ret = %d\n",
			__func__, ret);

	kfree(source_vm_copy);
err2:
	destroy_dest_info_list(dest_info_list);

err1:
	destroy_info_list(info_list);
	return ret;
@@ -348,6 +363,38 @@ int hyp_assign_phys(phys_addr_t addr, u64 size, u32 *source_vm_list,
	return ret;
}

const char *msm_secure_vmid_to_string(int secure_vmid)
{
	switch (secure_vmid) {
	case VMID_HLOS:
		return "VMID_HLOS";
	case VMID_CP_TOUCH:
		return "VMID_CP_TOUCH";
	case VMID_CP_BITSTREAM:
		return "VMID_CP_BITSTREAM";
	case VMID_CP_PIXEL:
		return "VMID_CP_PIXEL";
	case VMID_CP_NON_PIXEL:
		return "VMID_CP_NON_PIXEL";
	case VMID_CP_CAMERA:
		return "VMID_CP_CAMERA";
	case VMID_HLOS_FREE:
		return "VMID_HLOS_FREE";
	case VMID_MSS_MSA:
		return "VMID_MSS_MSA";
	case VMID_MSS_NONMSA:
		return "VMID_MSS_NONMSA";
	case VMID_CP_SEC_DISPLAY:
		return "VMID_CP_SEC_DISPLAY";
	case VMID_CP_APP:
		return "VMID_CP_APP";
	case VMID_INVAL:
		return "VMID_INVAL";
	default:
		return "Unknown VMID";
	}
}

#define MAKE_CP_VERSION(major, minor, patch) \
	(((major & 0x3FF) << 22) | ((minor & 0x3FF) << 12) | (patch & 0xFFF))

+10 −0
Original line number Diff line number Diff line
@@ -23,10 +23,15 @@
#define VMID_CP_NON_PIXEL 0xB
#define VMID_CP_CAMERA 0xD
#define VMID_HLOS_FREE 0xE
#define VMID_MSS_MSA 0xF
#define VMID_MSS_NONMSA 0x10
#define VMID_CP_SEC_DISPLAY 0x11
#define VMID_CP_APP 0x12
#define VMID_INVAL -1
/*
 * if you add a secure VMID here make sure you update
 * msm_secure_vmid_to_string
 */

#define PERM_READ                       0x4
#define PERM_WRITE                      0x2
@@ -43,6 +48,7 @@ int hyp_assign_phys(phys_addr_t addr, u64 size,
			u32 *source_vmlist, int source_nelems,
			int *dest_vmids, int *dest_perms, int dest_nelems);
bool msm_secure_v2_is_supported(void);
const char *msm_secure_vmid_to_string(int secure_vmid);
#else
static inline int msm_secure_table(struct sg_table *table)
{
@@ -71,5 +77,9 @@ static inline bool msm_secure_v2_is_supported(void)
{
	return false;
}
const char *msm_secure_vmid_to_string(int secure_vmid)
{
	return "N/A";
}
#endif
#endif