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

Commit b05a1ae4 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "haven: Add support for the MEM_ACCEPTED notification"

parents 8e7791b3 1451a116
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -438,7 +438,7 @@ static int fts_ts_vm_mem_release(struct fts_ts_data *fts_data)
		pr_err("VM mem release failed: rc=%d\n", rc);
		pr_err("VM mem release failed: rc=%d\n", rc);


	rc = hh_rm_mem_notify(fts_data->vm_info->vm_mem_handle,
	rc = hh_rm_mem_notify(fts_data->vm_info->vm_mem_handle,
				HH_RM_MEM_NOTIFY_OWNER,
				HH_RM_MEM_NOTIFY_OWNER_RELEASED,
				HH_MEM_NOTIFIER_TAG_TOUCH, 0);
				HH_MEM_NOTIFIER_TAG_TOUCH, 0);
	if (rc)
	if (rc)
		pr_err("Failed to notify mem release to PVM: rc=%d\n");
		pr_err("Failed to notify mem release to PVM: rc=%d\n");
@@ -689,7 +689,7 @@ static int fts_ts_vm_mem_lend(struct fts_ts_data *fts_data)


	vmid_desc = fts_ts_vm_get_vmid(trusted_vmid);
	vmid_desc = fts_ts_vm_get_vmid(trusted_vmid);


	rc = hh_rm_mem_notify(mem_handle, HH_RM_MEM_NOTIFY_RECIPIENT,
	rc = hh_rm_mem_notify(mem_handle, HH_RM_MEM_NOTIFY_RECIPIENT_SHARED,
			HH_MEM_NOTIFIER_TAG_TOUCH, vmid_desc);
			HH_MEM_NOTIFIER_TAG_TOUCH, vmid_desc);
	if (rc) {
	if (rc) {
		pr_err("Failed to notify mem lend to hypervisor rc:%d\n", rc);
		pr_err("Failed to notify mem lend to hypervisor rc:%d\n", rc);
+2 −2
Original line number Original line Diff line number Diff line
@@ -462,7 +462,7 @@ static int fts_vm_mem_release(struct fts_ts_info *info)
		pr_err("VM mem release failed: rc=%d\n", rc);
		pr_err("VM mem release failed: rc=%d\n", rc);


	rc = hh_rm_mem_notify(info->vm_info->vm_mem_handle,
	rc = hh_rm_mem_notify(info->vm_info->vm_mem_handle,
				HH_RM_MEM_NOTIFY_OWNER,
				HH_RM_MEM_NOTIFY_OWNER_RELEASED,
				HH_MEM_NOTIFIER_TAG_TOUCH, 0);
				HH_MEM_NOTIFIER_TAG_TOUCH, 0);
	if (rc)
	if (rc)
		pr_err("Failed to notify mem release to PVM: rc=%d\n");
		pr_err("Failed to notify mem release to PVM: rc=%d\n");
@@ -713,7 +713,7 @@ static int fts_vm_mem_lend(struct fts_ts_info *info)


	vmid_desc = fts_vm_get_vmid(trusted_vmid);
	vmid_desc = fts_vm_get_vmid(trusted_vmid);


	rc = hh_rm_mem_notify(mem_handle, HH_RM_MEM_NOTIFY_RECIPIENT,
	rc = hh_rm_mem_notify(mem_handle, HH_RM_MEM_NOTIFY_RECIPIENT_SHARED,
			HH_MEM_NOTIFIER_TAG_TOUCH, vmid_desc);
			HH_MEM_NOTIFIER_TAG_TOUCH, vmid_desc);
	if (rc) {
	if (rc) {
		pr_err("Failed to notify mem lend to hypervisor rc:%d\n", rc);
		pr_err("Failed to notify mem lend to hypervisor rc:%d\n", rc);
+9 −3
Original line number Original line Diff line number Diff line
@@ -93,9 +93,14 @@ EXPORT_SYMBOL(hh_mem_notifier_unregister);
static enum hh_mem_notifier_tag hh_mem_notifier_get_tag(unsigned long action,
static enum hh_mem_notifier_tag hh_mem_notifier_get_tag(unsigned long action,
							void *msg)
							void *msg)
{
{
	return action == HH_RM_NOTIF_MEM_SHARED ?
	if (action == HH_RM_NOTIF_MEM_SHARED)
		((struct hh_rm_notif_mem_shared_payload *)msg)->mem_info_tag :
		return
		((struct hh_rm_notif_mem_shared_payload *)msg)->mem_info_tag;
	else if (action == HH_RM_NOTIF_MEM_RELEASED)
		return
		((struct hh_rm_notif_mem_released_payload *)msg)->mem_info_tag;
		((struct hh_rm_notif_mem_released_payload *)msg)->mem_info_tag;

	return ((struct hh_rm_notif_mem_accepted_payload *)msg)->mem_info_tag;
}
}


static int hh_mem_notifier_call(struct notifier_block *nb, unsigned long action,
static int hh_mem_notifier_call(struct notifier_block *nb, unsigned long action,
@@ -107,7 +112,8 @@ static int hh_mem_notifier_call(struct notifier_block *nb, unsigned long action,
	void *data;
	void *data;


	if ((action != HH_RM_NOTIF_MEM_SHARED) &&
	if ((action != HH_RM_NOTIF_MEM_SHARED) &&
	    (action != HH_RM_NOTIF_MEM_RELEASED))
	    (action != HH_RM_NOTIF_MEM_RELEASED) &&
	    (action != HH_RM_NOTIF_MEM_ACCEPTED))
		return NOTIFY_DONE;
		return NOTIFY_DONE;


	tag = hh_mem_notifier_get_tag(action, msg);
	tag = hh_mem_notifier_get_tag(action, msg);
+9 −0
Original line number Original line Diff line number Diff line
@@ -236,6 +236,15 @@ static int hh_rm_process_notif(void *recv_buff, size_t recv_buff_size)
			goto err;
			goto err;
		}
		}
		break;
		break;
	case HH_RM_NOTIF_MEM_ACCEPTED:
		if (recv_buff_size != sizeof(*hdr) +
			sizeof(struct hh_rm_notif_mem_accepted_payload)) {
			pr_err("%s: Invalid size for MEM_ACCEPTED notif: %u\n",
				__func__, recv_buff_size - sizeof(*hdr));
			ret = -EINVAL;
			goto err;
		}
		break;
	case HH_RM_NOTIF_VM_CONSOLE_CHARS:
	case HH_RM_NOTIF_VM_CONSOLE_CHARS:
		if (recv_buff_size < sizeof(*hdr) +
		if (recv_buff_size < sizeof(*hdr) +
			sizeof(struct hh_rm_notif_vm_console_chars)) {
			sizeof(struct hh_rm_notif_vm_console_chars)) {
+12 −9
Original line number Original line Diff line number Diff line
@@ -22,7 +22,8 @@
#define HH_RM_MEM_SHARE_VALID_FLAGS HH_RM_MEM_SHARE_SANITIZE
#define HH_RM_MEM_SHARE_VALID_FLAGS HH_RM_MEM_SHARE_SANITIZE
#define HH_RM_MEM_LEND_VALID_FLAGS HH_RM_MEM_LEND_SANITIZE
#define HH_RM_MEM_LEND_VALID_FLAGS HH_RM_MEM_LEND_SANITIZE
#define HH_RM_MEM_NOTIFY_VALID_FLAGS\
#define HH_RM_MEM_NOTIFY_VALID_FLAGS\
	(HH_RM_MEM_NOTIFY_RECIPIENT | HH_RM_MEM_NOTIFY_OWNER)
	(HH_RM_MEM_NOTIFY_RECIPIENT_SHARED |\
	 HH_RM_MEM_NOTIFY_OWNER_RELEASED | HH_RM_MEM_NOTIFY_OWNER_ACCEPTED)


static struct hh_vm_property hh_vm_table[HH_VM_MAX];
static struct hh_vm_property hh_vm_table[HH_VM_MAX];


@@ -1214,9 +1215,9 @@ EXPORT_SYMBOL(hh_rm_mem_lend);
 * out
 * out
 * @flags: Flags to determine if the notification is for notifying that memory
 * @flags: Flags to determine if the notification is for notifying that memory
 *         has been shared to another VM, or that a VM has released memory
 *         has been shared to another VM, or that a VM has released memory
 * @mem_info_tag: A 32-bit value that is attached to the MEM_SHARED/MEM_RELEASED
 * @mem_info_tag: A 32-bit value that is attached to the
 *                notifications to aid in distinguishing different resources
 *                MEM_SHARED/MEM_RELEASED/MEM_ACCEPTED notifications to aid in
 *                from one another.
 *                distinguishing different resources from one another.
 * @vmid_desc: A list of VMIDs to notify that memory has been shared with them.
 * @vmid_desc: A list of VMIDs to notify that memory has been shared with them.
 *             This parameter should only be non-NULL if other VMs are being
 *             This parameter should only be non-NULL if other VMs are being
 *             notified (i.e. it is invalid to specify this parameter when the
 *             notified (i.e. it is invalid to specify this parameter when the
@@ -1238,13 +1239,15 @@ int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags,
	int ret = 0, hh_ret;
	int ret = 0, hh_ret;


	if ((flags & ~HH_RM_MEM_NOTIFY_VALID_FLAGS) ||
	if ((flags & ~HH_RM_MEM_NOTIFY_VALID_FLAGS) ||
	    ((flags & HH_RM_MEM_NOTIFY_RECIPIENT) && (!vmid_desc ||
	    ((flags & HH_RM_MEM_NOTIFY_RECIPIENT_SHARED) && (!vmid_desc ||
							     (vmid_desc &&
							     (vmid_desc &&
						!vmid_desc->n_vmid_entries))) ||
						!vmid_desc->n_vmid_entries))) ||
	    ((flags & HH_RM_MEM_NOTIFY_OWNER) && vmid_desc))
	    ((flags & (HH_RM_MEM_NOTIFY_OWNER_RELEASED |
		       HH_RM_MEM_NOTIFY_OWNER_ACCEPTED)) && vmid_desc) ||
	    (hweight8(flags) != 1))
		return -EINVAL;
		return -EINVAL;


	if (flags & HH_RM_MEM_NOTIFY_RECIPIENT) {
	if (flags & HH_RM_MEM_NOTIFY_RECIPIENT_SHARED) {
		n_vmid_entries = vmid_desc->n_vmid_entries;
		n_vmid_entries = vmid_desc->n_vmid_entries;
		req_vmid_desc_size = offsetof(struct hh_notify_vmid_desc,
		req_vmid_desc_size = offsetof(struct hh_notify_vmid_desc,
					      vmid_entries[n_vmid_entries]);
					      vmid_entries[n_vmid_entries]);
@@ -1260,7 +1263,7 @@ int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags,
	req_payload_hdr->flags = flags;
	req_payload_hdr->flags = flags;
	req_payload_hdr->mem_info_tag = mem_info_tag;
	req_payload_hdr->mem_info_tag = mem_info_tag;


	if (flags & HH_RM_MEM_NOTIFY_RECIPIENT) {
	if (flags & HH_RM_MEM_NOTIFY_RECIPIENT_SHARED) {
		dst_vmid_desc = req_buf + sizeof(*req_payload_hdr);
		dst_vmid_desc = req_buf + sizeof(*req_payload_hdr);
		dst_vmid_desc->n_vmid_entries = n_vmid_entries;
		dst_vmid_desc->n_vmid_entries = n_vmid_entries;
		for (i = 0; i < n_vmid_entries; i++)
		for (i = 0; i < n_vmid_entries; i++)
Loading