Commit 8681db44 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

hv: make "monitor_pages" a "real" pointer array

monitor_pages was a void pointer, containing an unknown number of arrays that
we just "knew" were a child and parent array of a specific size.  Instead of
that implicit knowledge, let's make them a real pointer, allowing us to have
type safety, and a semblance of sane addressing schemes.
Tested-by: default avatar"K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7c55e1d0
...@@ -47,8 +47,8 @@ static void vmbus_setevent(struct vmbus_channel *channel) ...@@ -47,8 +47,8 @@ static void vmbus_setevent(struct vmbus_channel *channel)
(unsigned long *) vmbus_connection.send_int_page + (unsigned long *) vmbus_connection.send_int_page +
(channel->offermsg.child_relid >> 5)); (channel->offermsg.child_relid >> 5));
monitorpage = vmbus_connection.monitor_pages; /* Get the child to parent monitor page */
monitorpage++; /* Get the child to parent monitor page */ monitorpage = vmbus_connection.monitor_pages[1];
sync_set_bit(channel->monitor_bit, sync_set_bit(channel->monitor_bit,
(unsigned long *)&monitorpage->trigger_group (unsigned long *)&monitorpage->trigger_group
...@@ -69,8 +69,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, ...@@ -69,8 +69,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
u8 monitor_group = (u8)channel->offermsg.monitorid / 32; u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
u8 monitor_offset = (u8)channel->offermsg.monitorid % 32; u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages; monitorpage = vmbus_connection.monitor_pages[0];
debuginfo->servermonitor_pending = debuginfo->servermonitor_pending =
monitorpage->trigger_group[monitor_group].pending; monitorpage->trigger_group[monitor_group].pending;
debuginfo->servermonitor_latency = debuginfo->servermonitor_latency =
...@@ -79,8 +78,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, ...@@ -79,8 +78,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
monitorpage->parameter[monitor_group] monitorpage->parameter[monitor_group]
[monitor_offset].connectionid.u.id; [monitor_offset].connectionid.u.id;
monitorpage++; monitorpage = vmbus_connection.monitor_pages[1];
debuginfo->clientmonitor_pending = debuginfo->clientmonitor_pending =
monitorpage->trigger_group[monitor_group].pending; monitorpage->trigger_group[monitor_group].pending;
debuginfo->clientmonitor_latency = debuginfo->clientmonitor_latency =
......
...@@ -76,10 +76,8 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, ...@@ -76,10 +76,8 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo,
msg->header.msgtype = CHANNELMSG_INITIATE_CONTACT; msg->header.msgtype = CHANNELMSG_INITIATE_CONTACT;
msg->vmbus_version_requested = version; msg->vmbus_version_requested = version;
msg->interrupt_page = virt_to_phys(vmbus_connection.int_page); msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages); msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages[0]);
msg->monitor_page2 = virt_to_phys( msg->monitor_page2 = virt_to_phys(vmbus_connection.monitor_pages[1]);
(void *)((unsigned long)vmbus_connection.monitor_pages +
PAGE_SIZE));
/* /*
* Add to list before we send the request since we may * Add to list before we send the request since we may
...@@ -169,9 +167,10 @@ int vmbus_connect(void) ...@@ -169,9 +167,10 @@ int vmbus_connect(void)
* Setup the monitor notification facility. The 1st page for * Setup the monitor notification facility. The 1st page for
* parent->child and the 2nd page for child->parent * parent->child and the 2nd page for child->parent
*/ */
vmbus_connection.monitor_pages = vmbus_connection.monitor_pages[0] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
(void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 1); vmbus_connection.monitor_pages[1] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
if (vmbus_connection.monitor_pages == NULL) { if ((vmbus_connection.monitor_pages[0] == NULL) ||
(vmbus_connection.monitor_pages[1] == NULL)) {
ret = -ENOMEM; ret = -ENOMEM;
goto cleanup; goto cleanup;
} }
...@@ -229,10 +228,10 @@ int vmbus_connect(void) ...@@ -229,10 +228,10 @@ int vmbus_connect(void)
vmbus_connection.int_page = NULL; vmbus_connection.int_page = NULL;
} }
if (vmbus_connection.monitor_pages) { free_pages((unsigned long)vmbus_connection.monitor_pages[0], 1);
free_pages((unsigned long)vmbus_connection.monitor_pages, 1); free_pages((unsigned long)vmbus_connection.monitor_pages[1], 1);
vmbus_connection.monitor_pages = NULL; vmbus_connection.monitor_pages[0] = NULL;
} vmbus_connection.monitor_pages[1] = NULL;
kfree(msginfo); kfree(msginfo);
......
...@@ -612,7 +612,7 @@ struct vmbus_connection { ...@@ -612,7 +612,7 @@ struct vmbus_connection {
* 2 pages - 1st page for parent->child notification and 2nd * 2 pages - 1st page for parent->child notification and 2nd
* is child->parent notification * is child->parent notification
*/ */
void *monitor_pages; struct hv_monitor_page *monitor_pages[2];
struct list_head chn_msg_list; struct list_head chn_msg_list;
spinlock_t channelmsg_lock; spinlock_t channelmsg_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment