From 01497f5e882bdcd72d9cda8f57f2b3367abccd35 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Tue, 14 Apr 2020 22:12:52 -0700 Subject: [PATCH] haven: Align APIs and structures to account for the mem_info tag The memory information tag is meant to be used in conjunction with the memory notification interfaces to associate a label or tag with a memory parcel. This memory information tag is meant to be used for distinguishing between different memory resources that can be transferred between Virtual Machines (VMs). Change-Id: I6856284430ce5a78461c203904695aed25868706 Signed-off-by: Isaac J. Manjarres --- drivers/virt/haven/hh_rm_drv_private.h | 1 + drivers/virt/haven/hh_rm_iface.c | 5 +++++ include/linux/haven/hh_rm_drv.h | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/virt/haven/hh_rm_drv_private.h b/drivers/virt/haven/hh_rm_drv_private.h index a59b551eebbd..afd06daed0ba 100644 --- a/drivers/virt/haven/hh_rm_drv_private.h +++ b/drivers/virt/haven/hh_rm_drv_private.h @@ -274,6 +274,7 @@ struct hh_mem_notify_req_payload { hh_memparcel_handle_t memparcel_handle; u32 flags:8; u32 reserved1:24; + hh_label_t mem_info_tag; } __packed; /* End Message ID headers */ diff --git a/drivers/virt/haven/hh_rm_iface.c b/drivers/virt/haven/hh_rm_iface.c index 5abfea564f50..6a13fd955f4a 100644 --- a/drivers/virt/haven/hh_rm_iface.c +++ b/drivers/virt/haven/hh_rm_iface.c @@ -1206,6 +1206,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. * @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 @@ -1215,6 +1218,7 @@ EXPORT_SYMBOL(hh_rm_mem_lend); * returned. */ int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags, + hh_label_t mem_info_tag, struct hh_notify_vmid_desc *vmid_desc) { struct hh_mem_notify_req_payload *req_payload_hdr; @@ -1246,6 +1250,7 @@ int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags, req_payload_hdr = req_buf; req_payload_hdr->memparcel_handle = handle; req_payload_hdr->flags = flags; + req_payload_hdr->mem_info_tag = mem_info_tag; if (flags & HH_RM_MEM_NOTIFY_RECIPIENT) { dst_vmid_desc = req_buf + sizeof(*req_payload_hdr); diff --git a/include/linux/haven/hh_rm_drv.h b/include/linux/haven/hh_rm_drv.h index 37386ca41ed2..861b5e15956e 100644 --- a/include/linux/haven/hh_rm_drv.h +++ b/include/linux/haven/hh_rm_drv.h @@ -55,6 +55,7 @@ struct hh_rm_notif_mem_shared_payload { u16 owner_vmid; u16 reserved2; u32 label; + hh_label_t mem_info_tag; /* TODO: How to arrange multiple variable length struct arrays? */ } __packed; @@ -78,6 +79,7 @@ struct hh_rm_notif_mem_released_payload { u32 mem_handle; u16 participant_vmid; u16 reserved; + hh_label_t mem_info_tag; } __packed; struct hh_acl_entry { @@ -217,6 +219,7 @@ int hh_rm_mem_lend(u8 mem_type, u8 flags, hh_label_t label, struct hh_mem_attr_desc *mem_attr_desc, hh_memparcel_handle_t *handle); int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags, + hh_label_t mem_info_tag, struct hh_notify_vmid_desc *vmid_desc); #else /* RM client register notifications APIs */ @@ -342,7 +345,8 @@ static inline int hh_rm_mem_lend(u8 mem_type, u8 flags, hh_label_t label, } static inline int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags, - struct hh_notify_vmid_desc *vmid_desc) + hh_label_t mem_info_tag, + struct hh_notify_vmid_desc *vmid_desc) { return -EINVAL; }