# \[PATCH\] hv\_utils: Set the maximum packet size for VSS driver to the length of the receive buffer

- Subsystems: Hyper-V/Azure CORE AND DRIVERS, THE REST
- Maintainers: Haiyang Zhang, Wei Liu, Dexuan Cui, Linus Torvalds
- Status: LANDED (9d68cd9120e4 · 2021-08-25 19:03)
- Landed in mainline as 9d68cd9120e4 on 2021-08-25.
- List: linux-hyperv
- 3 messages, 3 authors
- Page: https://ratatoskr.run/linux-hyperv/2021/08/1488680/t

## \[PATCH\] hv\_utils: Set the maximum packet size for VSS driver to the length of the receive buffer

- From: Vitaly Kuznetsov \<vkuznets@redhat.com\>
- Date: 2021-08-25 13:39:09 
- Message: https://ratatoskr.run/linux-hyperv/2021/08/1488680.md

```text
Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out
of the ring buffer") introduced a notion of maximum packet size and for
KVM and FCOPY drivers set it to the length of the receive buffer. VSS
driver wasn't updated, this means that the maximum packet size is now
VMBUS_DEFAULT_MAX_PKT_SIZE (4k). Apparently, this is not enough. I'm
observing a packet of 6304 bytes which is being truncated to 4096. When
VSS driver tries to read next packet from ring buffer it starts from the
wrong offset and receives garbage.

Set the maximum packet size to 'HV_HYP_PAGE_SIZE * 2' in VSS driver. This
matches the length of the receive buffer and is in line with other utils
drivers.

Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 drivers/hv/hv_snapshot.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
index 2267bd4c3472..6018b9d1b1fb 100644
--- a/drivers/hv/hv_snapshot.c
+++ b/drivers/hv/hv_snapshot.c
@@ -375,6 +375,7 @@ hv_vss_init(struct hv_util_service *srv)
 	}
 	recv_buffer = srv->recv_buffer;
 	vss_transaction.recv_channel = srv->channel;
+	vss_transaction.recv_channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
 
 	/*
 	 * When this driver loads, the user level daemon that
-- 
2.31.1

```

## RE: \[PATCH\] hv\_utils: Set the maximum packet size for VSS driver to the length of the receive buffer

- From: Michael Kelley \<hidden\>
- Date: 2021-08-25 18:33:29 
- Message: https://ratatoskr.run/linux-hyperv/2021/08/1489018.md

```text
From: Vitaly Kuznetsov <vkuznets@redhat.com> Sent: Wednesday, August 25, 2021 6:39 AM
> 
> Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out
> of the ring buffer") introduced a notion of maximum packet size and for
> KVM and FCOPY drivers set it to the length of the receive buffer. VSS
> driver wasn't updated, this means that the maximum packet size is now
> VMBUS_DEFAULT_MAX_PKT_SIZE (4k). Apparently, this is not enough. I'm
> observing a packet of 6304 bytes which is being truncated to 4096. When
> VSS driver tries to read next packet from ring buffer it starts from the
> wrong offset and receives garbage.
> 
> Set the maximum packet size to 'HV_HYP_PAGE_SIZE * 2' in VSS driver. This
> matches the length of the receive buffer and is in line with other utils
> drivers.
> 
> Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  drivers/hv/hv_snapshot.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
> index 2267bd4c3472..6018b9d1b1fb 100644
> --- a/drivers/hv/hv_snapshot.c
> +++ b/drivers/hv/hv_snapshot.c
> @@ -375,6 +375,7 @@ hv_vss_init(struct hv_util_service *srv)
>  	}
>  	recv_buffer = srv->recv_buffer;
>  	vss_transaction.recv_channel = srv->channel;
> +	vss_transaction.recv_channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
> 
>  	/*
>  	 * When this driver loads, the user level daemon that
> --
> 2.31.1

Reviewed-by: Michael Kelley <redacted>
```

## Re: \[PATCH\] hv\_utils: Set the maximum packet size for VSS driver to the length of the receive buffer

- From: Wei Liu \<wei.liu@kernel.org\>
- Date: 2021-08-25 19:02:23 
- Message: https://ratatoskr.run/linux-hyperv/2021/08/1489031.md

```text
On Wed, Aug 25, 2021 at 06:33:10PM +0000, Michael Kelley wrote:
> From: Vitaly Kuznetsov <vkuznets@redhat.com> Sent: Wednesday, August 25, 2021 6:39 AM
> > 
> > Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out
> > of the ring buffer") introduced a notion of maximum packet size and for
> > KVM and FCOPY drivers set it to the length of the receive buffer. VSS
> > driver wasn't updated, this means that the maximum packet size is now
> > VMBUS_DEFAULT_MAX_PKT_SIZE (4k). Apparently, this is not enough. I'm
> > observing a packet of 6304 bytes which is being truncated to 4096. When
> > VSS driver tries to read next packet from ring buffer it starts from the
> > wrong offset and receives garbage.
> > 
> > Set the maximum packet size to 'HV_HYP_PAGE_SIZE * 2' in VSS driver. This
> > matches the length of the receive buffer and is in line with other utils
> > drivers.
> > 
> > Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
> > Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
[...]
> 
> Reviewed-by: Michael Kelley <redacted>

Given we're really close to the merge window I'm going to apply this to
hyperv-next.

Wei.
```
