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

Commit 1451a116 authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

haven: Add support for the MEM_ACCEPTED notification



It's useful for other virtual machines (VMs) to know if another
VM has successfully received a resource that was shared with it
(e.g. state tracking can be controlled better with this sort of
information). Add support for the MEM_ACCEPTED notification, which
clients can use to notify the VM that owns the resource that was
shared with it that it has accepted the resource and is using it.
Also, add support in the mem-notifier driver to forward the
MEM_ACCEPTED notification to clients.

Change-Id: I05b9f1d37906d7c2aa729b97df2f8ceb78b560bd
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent 38b1718d
Loading
Loading
Loading
Loading
+2 −2
Original line number 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);

	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);
	if (rc)
		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);

	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);
	if (rc) {
		pr_err("Failed to notify mem lend to hypervisor rc:%d\n", rc);
+2 −2
Original line number 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);

	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);
	if (rc)
		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);

	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);
	if (rc) {
		pr_err("Failed to notify mem lend to hypervisor rc:%d\n", rc);
+9 −3
Original line number 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,
							void *msg)
{
	return action == HH_RM_NOTIF_MEM_SHARED ?
		((struct hh_rm_notif_mem_shared_payload *)msg)->mem_info_tag :
	if (action == HH_RM_NOTIF_MEM_SHARED)
		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;

	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,
@@ -107,7 +112,8 @@ static int hh_mem_notifier_call(struct notifier_block *nb, unsigned long action,
	void *data;

	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;

	tag = hh_mem_notifier_get_tag(action, msg);
+9 −0
Original line number 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;
		}
		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:
		if (recv_buff_size < sizeof(*hdr) +
			sizeof(struct hh_rm_notif_vm_console_chars)) {
+12 −9
Original line number 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_LEND_VALID_FLAGS HH_RM_MEM_LEND_SANITIZE
#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];

@@ -1214,9 +1215,9 @@ EXPORT_SYMBOL(hh_rm_mem_lend);
 * out
 * @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
 * @mem_info_tag: A 32-bit value that is attached to the MEM_SHARED/MEM_RELEASED
 *                notifications to aid in distinguishing different resources
 *                from one another.
 * @mem_info_tag: A 32-bit value that is attached to the
 *                MEM_SHARED/MEM_RELEASED/MEM_ACCEPTED notifications to aid in
 *                distinguishing different resources from one another.
 * @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
 *             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;

	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->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;

	if (flags & HH_RM_MEM_NOTIFY_RECIPIENT) {
	if (flags & HH_RM_MEM_NOTIFY_RECIPIENT_SHARED) {
		n_vmid_entries = vmid_desc->n_vmid_entries;
		req_vmid_desc_size = offsetof(struct hh_notify_vmid_desc,
					      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->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->n_vmid_entries = n_vmid_entries;
		for (i = 0; i < n_vmid_entries; i++)
Loading