FAILED: patch "[PATCH] hv_netvsc: Fix race between VF offering and VF association" failed to apply to 5.4-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Possible dependencies:
365e1ececb29 ("hv_netvsc: Fix race between VF offering and VF association message from host") d0922bf79817 ("hv_netvsc: Add error handling while switching data path")34b06a2eee44 ("hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove")8b31f8c982b7 ("hv_netvsc: Wait for completion on request SWITCH_DATA_PATH")4d18fcc95f50 ("hv_netvsc: Use vmbus_requestor to generate transaction IDs for VMBus hardening") e8b7db38449a ("Drivers: hv: vmbus: Add vmbus_requestor data structure for VMBus hardening") 4907a43da831 ("Merge tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 365e1ececb2905f94cc10a5817c5b644a32a3ae2 Mon Sep 17 00:00:00 2001
From: Gaurav Kohli <[email protected]>
Date: Wed, 5 Oct 2022 22:52:59 -0700
Subject: [PATCH] hv_netvsc: Fix race between VF offering and VF association
message from host
During vm boot, there might be possibility that vf registration call comes before the vf association from host to vm.
And this might break netvsc vf path, To prevent the same block vf registration until vf bind message comes from host.
drivers/net/hyperv/hyperv_net.h +2 -1
@@ -1051,7 +1051,8 @@ struct net_device_context {u32 vf_alloc;/* Serial number of the VF to team with */ u32 vf_serial; - +/* completion variable to confirm vf association */ +struct completion vf_add;/* Is the current data path through the VF NIC? */ bool data_path_is_vf;
drivers/net/hyperv/netvsc.c +4 -0
@@ -1580,6 +1580,10 @@ static void netvsc_send_vf(struct net_device *ndev, net_device_ctx->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated; net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial; + +if (net_device_ctx->vf_alloc) +complete (&net_device_ctx->vf_add); +netdev_info (ndev,"VF slot %u %s\n" , net_device_ctx->vf_serial, net_device_ctx->vf_alloc ?"added" :"removed" );
drivers/net/hyperv/netvsc_drv.c +19 -0
@@ -2313,6 +2313,18 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev) } +/* Fallback path to check synthetic vf with +* help of mac addr +*/ +list_for_each_entry (ndev_ctx, &netvsc_dev_list, list) { + ndev =hv_get_drvdata (ndev_ctx->device_ctx); +if (ether_addr_equal (vf_netdev->perm_addr, ndev->perm_addr)) { +netdev_notice (vf_netdev, +"falling back to mac addr based matching\n" ); +return ndev; + } + } +netdev_notice (vf_netdev,"no netdev found for vf serial:%u\n" , serial);return NULL ;
@@ -2409,6 +2421,11 @@ static int netvsc_vf_changed(struct net_device *vf_netdev, unsigned long event)if (net_device_ctx->data_path_is_vf == vf_is_up)return NOTIFY_OK ; +if (vf_is_up && !net_device_ctx->vf_alloc) { +netdev_info (ndev,"Waiting for the VF association from host\n" ); +wait_for_completion (&net_device_ctx->vf_add); + } + ret =netvsc_switch_datapath (ndev, vf_is_up);if (ret) {
@@ -2440,6 +2457,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)netvsc_vf_setxdp (vf_netdev,NULL ); +reinit_completion (&net_device_ctx->vf_add);netdev_rx_handler_unregister (vf_netdev);netdev_upper_dev_unlink (vf_netdev, ndev);RCU_INIT_POINTER (net_device_ctx->vf_netdev,NULL );
@@ -2479,6 +2497,7 @@ static int netvsc_probe(struct hv_device *dev,INIT_DELAYED_WORK (&net_device_ctx->dwork, netvsc_link_change); +init_completion (&net_device_ctx->vf_add);spin_lock_init (&net_device_ctx->lock);INIT_LIST_HEAD (&net_device_ctx->reconfig_events);INIT_DELAYED_WORK (&net_device_ctx->vf_takeover, netvsc_vf_setup);