Skip to contentSkip to conversation

Drivers: hv: Miscellaneous fixes

PATCH New [email protected] 1 participant 3 messages Sep 22, 2017

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

cover Drivers: hv: Miscellaneous fixes

From: "K. Y. Srinivasan" <[email protected]>

Miscellaneous fixes. Greg, please apply these to 4.14-final.

Dexuan Cui (1):
vmbus: don't acquire the mutex in vmbus_hvsock_device_unregister()

Olaf Hering (1):
Drivers: hv: fcopy: restore correct transfer length

 drivers/hv/channel_mgmt.c | 4 ----
 drivers/hv/hv_fcopy.c     | 4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/2 vmbus: don't acquire the mutex in vmbus_hvsock_device_unregister()

From: Dexuan Cui <[email protected]>

Due to commit 54a66265d675 ("Drivers: hv: vmbus: Fix rescind handling"), we need this patch to resolve the below deadlock:

after we get the mutex in vmbus_hvsock_device_unregister() and call vmbus_device_unregister() -> device_unregister() -> ... -> device_release() -> vmbus_device_release(), we'll get a deadlock, because vmbus_device_release() tries to get the same mutex.

Cc K. Y. Srinivasan <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc [email protected] (4.13 and above)
---
 drivers/hv/channel_mgmt.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/hv/channel_mgmt.c +0 -4
index 968af173c4c1..624d815745e4 100644
@@ -945,14 +945,10 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 
 void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
 {
-	mutex_lock(&vmbus_connection.channel_mutex);
-
 	BUG_ON(!is_hvsock_channel(channel));
 
 	channel->rescind = true;
 	vmbus_device_unregister(channel->device_obj);
-
-	mutex_unlock(&vmbus_connection.channel_mutex);
 }
 EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister);
 
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/2 Drivers: hv: fcopy: restore correct transfer length

From: Olaf Hering <[email protected]>

Till recently the expected length of bytes read by the daemon did depend on the context. It was either hv_start_fcopy or hv_do_fcopy. The daemon had a buffer size of two pages, which was much larger than needed.

Now the expected length of bytes read by the
daemon changed slightly. For START_FILE_COPY it is still the size of hv_start_fcopy. But for WRITE_TO_FILE and the other operations it is as large as the buffer that arrived via vmbus. In case of WRITE_TO_FILE that is slightly larger than a struct hv_do_fcopy. Since the buffer in the daemon was still larger everything was fine.

Currently, the daemon reads only what is actually needed. The new buffer layout is as large as a struct hv_do_fcopy, for the WRITE_TO_FILE operation. Since the kernel expects a slightly larger size, hvt_op_read will return -EINVAL because the daemon will read slightly less than expected. Address this by restoring the expected buffer size in case of WRITE_TO_FILE.

Fixes 'c7e490fc23eb ("Drivers: hv: fcopy: convert to hv_utils_transport")'
Fixes '3f2baa8a7d2e ("Tools: hv: update buffer handling in hv_fcopy_daemon")'
---
 drivers/hv/hv_fcopy.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hv/hv_fcopy.c +4 -0
index daa75bd41f86..2364281d8593 100644
@@ -170,6 +170,10 @@ static void fcopy_send_data(struct work_struct *dummy)
 		out_src = smsg_out;
 		break;
 
+	case WRITE_TO_FILE:
+		out_src = fcopy_transaction.fcopy_msg;
+		out_len = sizeof(struct hv_do_fcopy);
+		break;
 	default:
 		out_src = fcopy_transaction.fcopy_msg;
 		out_len = fcopy_transaction.recv_len;
Signature · 1 line
2.14.1