Skip to content

Commit 96d9d1f

Browse files
Riatreliuw
authored andcommitted
Drivers: hv: balloon: account for vmbus packet header in max_pkt_size
Commit adae1e9 ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer") introduced a notion of maximum packet size in vmbus channel and used that size to initialize a buffer holding all incoming packet along with their vmbus packet header. hv_balloon uses the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches its maximum message size, however vmbus_open expects this size to also include vmbus packet header. This leads to 4096 bytes dm_unballoon_request messages being truncated to 4080 bytes. When the driver tries to read next packet it starts from a wrong read_index, receives garbage and prints a lot of "Unhandled message: type: <garbage>" in dmesg. Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for the header. Fixes: adae1e9 ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer") Suggested-by: Michael Kelley (LINUX) <mikelley@microsoft.com> Suggested-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com> Signed-off-by: Yanming Liu <yanminglr@gmail.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com> Link: https://lore.kernel.org/r/20220119202052.3006981-1-yanminglr@gmail.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent e783362 commit 96d9d1f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/hv/hv_balloon.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,13 @@ static int balloon_connect_vsp(struct hv_device *dev)
16601660
unsigned long t;
16611661
int ret;
16621662

1663+
/*
1664+
* max_pkt_size should be large enough for one vmbus packet header plus
1665+
* our receive buffer size. Hyper-V sends messages up to
1666+
* HV_HYP_PAGE_SIZE bytes long on balloon channel.
1667+
*/
1668+
dev->channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
1669+
16631670
ret = vmbus_open(dev->channel, dm_ring_size, dm_ring_size, NULL, 0,
16641671
balloon_onchannelcallback, dev);
16651672
if (ret)

0 commit comments

Comments
 (0)