Skip to contentSkip to conversation

Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload

PATCH Applied Michael Kelley 4 participants 4 messages Sep 13, 2020 – Sep 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload

vmbus_wait_for_unload() looks for a CHANNELMSG_UNLOAD_RESPONSE message coming from Hyper-V. But if the message isn't found for some reason, the panic path gets hung forever. Add a timeout of 10 seconds to prevent this.

Fixes 415719160de3 ("Drivers: hv: vmbus: avoid scheduling in interrupt context in vmbus_initiate_unload()")
---
 drivers/hv/channel_mgmt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/hv/channel_mgmt.c +5 -2
index 591106c..1d44bb6 100644
@@ -731,7 +731,7 @@ static void vmbus_wait_for_unload(void)
 	void *page_addr;
 	struct hv_message *msg;
 	struct vmbus_channel_message_header *hdr;
-	u32 message_type;
+	u32 message_type, i;
 
 	/*
 	 * CHANNELMSG_UNLOAD_RESPONSE is always delivered to the CPU which was
@@ -741,8 +741,11 @@ static void vmbus_wait_for_unload(void)
 	 * functional and vmbus_unload_response() will complete
 	 * vmbus_connection.unload_event. If not, the last thing we can do is
 	 * read message pages for all CPUs directly.
+	 *
+	 * Wait no more than 10 seconds so that the panic path can't get
+	 * hung forever in case the response message isn't seen.
 	 */
-	while (1) {
+	for (i = 0; i < 1000; i++) {
 		if (completion_done(&vmbus_connection.unload_event))
 			break;
 
Signature · 1 line
1.8.3.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines

From: [email protected] <[email protected]> On Behalf Of Michael Kelley
Sent: Sunday, September 13, 2020 12:47 PM

vmbus_wait_for_unload() looks for a CHANNELMSG_UNLOAD_RESPONSE message
coming from Hyper-V. But if the message isn't found for some reason, the panic path gets hung forever. Add a timeout of 10 seconds to prevent this.

Quoted 3 lines
Fixes 415719160de3 ("Drivers: hv: vmbus: avoid scheduling in interrupt

context in vmbus_initiate_unload()")

maintainer Applied
#2 lore raw
Quoted 10 lines · Dexuan Cui
Quoted 10 lines

From: [email protected] <[email protected]> On Behalf Of Michael Kelley
Sent: Sunday, September 13, 2020 12:47 PM

vmbus_wait_for_unload() looks for a CHANNELMSG_UNLOAD_RESPONSE message
coming from Hyper-V. But if the message isn't found for some reason, the panic path gets hung forever. Add a timeout of 10 seconds to prevent this.

Quoted 5 lines
Quoted 3 lines
Fixes 415719160de3 ("Drivers: hv: vmbus: avoid scheduling in interrupt

context in vmbus_initiate_unload()")

LGTM.

Applied to hyperv-fixes. Thanks.

Wei.

Reviewed-by on v1 1/1
#3 lore raw

Re: ** POTENTIAL FRAUD ALERT - RED HAT ** [PATCH 1/1] Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload

In reply to Michael Kelley
Quoted 4 lines · Michael Kelley

vmbus_wait_for_unload() looks for a CHANNELMSG_UNLOAD_RESPONSE message coming from Hyper-V. But if the message isn't found for some reason, the panic path gets hung forever. Add a timeout of 10 seconds to prevent this.

If I remember correctly, the problem I was observing back then was that if CHANNELMSG_UNLOAD_RESPONSE is not delivered, Hyper-V won't respond to the consequent CHANNELMSG_INITIATE_CONTACT/CHANNELMSG_REQUESTOFFERS (don't remember exactly) so we either hang here or crash in the kdump kernel because we can't find any devices. Maybe the problem was only with some ancient Hyper-V versions or it was fixed.

Quoted 22 lines
Fixes 415719160de3 ("Drivers: hv: vmbus: avoid scheduling in interrupt context in vmbus_initiate_unload()")
---
 drivers/hv/channel_mgmt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/hv/channel_mgmt.c +1 -1
index 591106c..1d44bb6 100644
@@ -731,7 +731,7 @@ static void vmbus_wait_for_unload(void)
 	void *page_addr;
 	struct hv_message *msg;
 	struct vmbus_channel_message_header *hdr;
-	u32 message_type;
+	u32 message_type, i;
 
 	/*
 	 * CHANNELMSG_UNLOAD_RESPONSE is always delivered to the CPU which was
@@ -741,8 +741,11 @@ static void vmbus_wait_for_unload(void)
 	 * functional and vmbus_unload_response() will complete

drivers/hv/channel_mgmt.c static void vmbus_wait_for_unload(void) · line 750

Quoted 10 lines
drivers/hv/channel_mgmt.c +4 -1
 	 * vmbus_connection.unload_event. If not, the last thing we can do is
 	 * read message pages for all CPUs directly.
+	 *
+	 * Wait no more than 10 seconds so that the panic path can't get
+	 * hung forever in case the response message isn't seen.
 	 */
-	while (1) {
+	for (i = 0; i < 1000; i++) {
 		if (completion_done(&vmbus_connection.unload_event))
 			break;

LGTM,

Signature · 1 line
Vitaly