The VSS driver allocates a VMbus receive buffer significantly larger than sizeof(hv_vss_msg), with no explanation. To help prevent future mistakes, add a #define and comment about why this is done. No functional change.
Unified · Split
| @@ -31,6 +31,9 @@ static const int fw_versions[] = { · 30 unmodified lines | |||
| 31 | UTIL_FW_VERSION | 31 | UTIL_FW_VERSION |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | /* See comment with struct hv_vss_msg regarding the max VMbus packet size */ | ||
| 35 | #define VSS_MAX_PKT_SIZE (HV_HYP_PAGE_SIZE * 2) | ||
| 36 | |||
| 34 | /* | 37 | /* |
| 35 | * Timeout values are based on expecations from host | 38 | * Timeout values are based on expecations from host |
| 36 | */ | 39 | */ |
| @@ -298,7 +301,7 @@ void hv_vss_onchannelcallback(void *context) · 261 unmodified lines | |||
| 298 | if (vss_transaction.state > HVUTIL_READY) | 301 | if (vss_transaction.state > HVUTIL_READY) |
| 299 | return; | 302 | return; |
| 300 | 303 | ||
| 301 | if (vmbus_recvpacket(channel, recv_buffer, HV_HYP_PAGE_SIZE * 2, &recvlen, &requestid)) { | 304 | if (vmbus_recvpacket(channel, recv_buffer, VSS_MAX_PKT_SIZE, &recvlen, &requestid)) { |
| 302 | pr_err_ratelimited("VSS request received. Could not read into recv buf\n"); | 305 | pr_err_ratelimited("VSS request received. Could not read into recv buf\n"); |
| 303 | return; | 306 | return; |
| 304 | } | 307 | } |
| @@ -375,7 +378,7 @@ hv_vss_init(struct hv_util_service *srv) · 70 unmodified lines | |||
| 375 | } | 378 | } |
| 376 | recv_buffer = srv->recv_buffer; | 379 | recv_buffer = srv->recv_buffer; |
| 377 | vss_transaction.recv_channel = srv->channel; | 380 | vss_transaction.recv_channel = srv->channel; |
| 378 | vss_transaction.recv_channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2; | 381 | vss_transaction.recv_channel->max_pkt_size = VSS_MAX_PKT_SIZE; |
| 379 | 382 | ||
| 380 | /* | 383 | /* |
| 381 | * When this driver loads, the user level daemon that | 384 | * When this driver loads, the user level daemon that |
| @@ -90,6 +90,17 @@ struct hv_vss_check_dm_info { · 89 unmodified lines | |||
| 90 | __u32 flags; | 90 | __u32 flags; |
| 91 | } __attribute__((packed)); | 91 | } __attribute__((packed)); |
| 92 | 92 | ||
| 93 | /* | ||
| 94 | * struct hv_vss_msg encodes the fields that the Linux VSS | ||
| 95 | * driver accesses. However, FREEZE messages from Hyper-V contain | ||
| 96 | * additional LUN information that Linux doesn't use and are not | ||
| 97 | * represented in struct hv_vss_msg. A received FREEZE message may | ||
| 98 | * be as large as 6,260 bytes, so the driver must allocate at least | ||
| 99 | * that much space, not sizeof(struct hv_vss_msg). Other messages | ||
| 100 | * such as AUTO_RECOVER may be as large as 12,500 bytes. However, | ||
| 101 | * because the Linux VSS driver responds that it doesn't support | ||
| 102 | * auto-recovery, it should not receive such messages. | ||
| 103 | */ | ||
| 93 | struct hv_vss_msg { | 104 | struct hv_vss_msg { |
| 94 | union { | 105 | union { |
| 95 | struct hv_vss_hdr vss_hdr; | 106 | struct hv_vss_hdr vss_hdr; |