Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2002693imm; Thu, 24 May 2018 04:20:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqmzowLhZDGCzslNnd49zEsEkeJd1kVcjcFvwfkri9gBOoC3b1QTWhwhZpJ9UPG3faOdfH6 X-Received: by 2002:a17:902:8a81:: with SMTP id p1-v6mr7110806plo.33.1527160821345; Thu, 24 May 2018 04:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160821; cv=none; d=google.com; s=arc-20160816; b=ImhqnKyzGiLPgvkcsnGQEkMCjDFUff8e7uLNyNvH3LSHryXHiCm0C4QVR/Zsjh5Imj SyJBlJgnZstSUFUQkk2lfe6PfniY2OWKMnyLJYxhZpMzlAJ0t1vqBNJi8AlhTWqt5uSE trg3xRbn1g/D3jbPBoMFx7JSBXccDcBG2MzZe5U6cdGqeKzC2RCoyKg3AFbQvL1czVLd Ufo0RzL6aNW1PT46f2SqLSn8ezlzWqdBMJ0dba2Fv+oOFsA7XHje+IYII6JpTqVakiDK SPE1gy18MUcUf5Y1pUPw3uvt3Dz7/PpVMEbmQE2/0VY278c7pJyVt5nvi8AZoE8EqI6m h+qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=XbN0Jx9TFOhw3fcVg08VOkNIv1J4h6J3CQksERoUxVk=; b=gBvikzQs1eyi8g1jt5+l7ELlLL2Iwq0Ls0Qpz0BFJqh0dbEb3mjqlEbs1YJSs/BJ/P doOo9mZySQ+bmaXcrsbyZpOHRUus3LOMDoow+VpmQUOIFAvGnbxds/fIbU6ywiuByA59 v6dStLCcVs672bXbl/+w7id2pdEfSacWZBR1KIzwZDLlYk3s4ldX6QQTzqX0yDS0Itnq 6F4fTWEODJtKiKUYIrNYiod8GuR9ApV0Zn3sW7N8gbKO1tS25r+/Rsx7TQZy3C33b3Eh AUEmJMGpCRjrKT4tken/bAwTHic20mh7GvJyUb+Bqk8a3RLcb35Iz5d7e4zCoDJdUpBd j6jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WPCVEgCG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si20960912plc.543.2018.05.24.04.20.06; Thu, 24 May 2018 04:20:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WPCVEgCG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967934AbeEXJwt (ORCPT + 99 others); Thu, 24 May 2018 05:52:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:53482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967615AbeEXJwo (ORCPT ); Thu, 24 May 2018 05:52:44 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0C2B620890; Thu, 24 May 2018 09:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155563; bh=LpNlyY9jWItr+Z/AIipA+v7megpALFA72rnMaEb9ovI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WPCVEgCGmfVjkNeV+OkO2ePptG7zKmwXIFU+ssVGAL4y3qvCkZVDs5k4fPcsERp51 NZ+MTr8FuefBWKuU2iPcBvL1g0kyA29SPAeS3awrM9HIjzOi/logxPfgkZzP5QJ1Ep ZSRYOwiQ+W8drgy3Lhu0pBZ5mR0ZiqBBUISUGkko= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mohammed Gamal , "David S. Miller" Subject: [PATCH 4.14 033/165] hv_netvsc: Ensure correct teardown message sequence order Date: Thu, 24 May 2018 11:37:19 +0200 Message-Id: <20180524093623.316542446@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mohammed Gamal [ Commit a56d99d714665591fed8527b90eef21530ea61e0 upstream. ] Prior to commit 0cf737808ae7 ("hv_netvsc: netvsc_teardown_gpadl() split") the call sequence in netvsc_device_remove() was as follows (as implemented in netvsc_destroy_buf()): 1- Send NVSP_MSG1_TYPE_REVOKE_RECV_BUF message 2- Teardown receive buffer GPADL 3- Send NVSP_MSG1_TYPE_REVOKE_SEND_BUF message 4- Teardown send buffer GPADL 5- Close vmbus This didn't work for WS2016 hosts. Commit 0cf737808ae7 ("hv_netvsc: netvsc_teardown_gpadl() split") rearranged the teardown sequence as follows: 1- Send NVSP_MSG1_TYPE_REVOKE_RECV_BUF message 2- Send NVSP_MSG1_TYPE_REVOKE_SEND_BUF message 3- Close vmbus 4- Teardown receive buffer GPADL 5- Teardown send buffer GPADL That worked well for WS2016 hosts, but it prevented guests on older hosts from shutting down after changing network settings. Commit 0ef58b0a05c1 ("hv_netvsc: change GPAD teardown order on older versions") ensured the following message sequence for older hosts 1- Send NVSP_MSG1_TYPE_REVOKE_RECV_BUF message 2- Send NVSP_MSG1_TYPE_REVOKE_SEND_BUF message 3- Teardown receive buffer GPADL 4- Teardown send buffer GPADL 5- Close vmbus However, with this sequence calling `ip link set eth0 mtu 1000` hangs and the process becomes uninterruptible. On futher analysis it turns out that on tearing down the receive buffer GPADL the kernel is waiting indefinitely in vmbus_teardown_gpadl() for a completion to be signaled. Here is a snippet of where this occurs: int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle) { struct vmbus_channel_gpadl_teardown *msg; struct vmbus_channel_msginfo *info; unsigned long flags; int ret; info = kmalloc(sizeof(*info) + sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL); if (!info) return -ENOMEM; init_completion(&info->waitevent); info->waiting_channel = channel; [....] ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown), true); if (ret) goto post_msg_err; wait_for_completion(&info->waitevent); [....] } The completion is signaled from vmbus_ongpadl_torndown(), which gets called when the corresponding message is received from the host, which apparently never happens in that case. This patch works around the issue by restoring the first mentioned message sequence for older hosts Fixes: 0ef58b0a05c1 ("hv_netvsc: change GPAD teardown order on older versions") Signed-off-by: Mohammed Gamal Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/hyperv/netvsc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -571,8 +571,17 @@ void netvsc_device_remove(struct hv_devi = rtnl_dereference(net_device_ctx->nvdev); int i; + /* + * Revoke receive buffer. If host is pre-Win2016 then tear down + * receive buffer GPADL. Do the same for send buffer. + */ netvsc_revoke_recv_buf(device, net_device); + if (vmbus_proto_version < VERSION_WIN10) + netvsc_teardown_recv_gpadl(device, net_device); + netvsc_revoke_send_buf(device, net_device); + if (vmbus_proto_version < VERSION_WIN10) + netvsc_teardown_send_gpadl(device, net_device); RCU_INIT_POINTER(net_device_ctx->nvdev, NULL); @@ -586,15 +595,13 @@ void netvsc_device_remove(struct hv_devi */ netdev_dbg(ndev, "net device safe to remove\n"); - /* older versions require that buffer be revoked before close */ - if (vmbus_proto_version < VERSION_WIN10) { - netvsc_teardown_recv_gpadl(device, net_device); - netvsc_teardown_send_gpadl(device, net_device); - } - /* Now, we can close the channel safely */ vmbus_close(device->channel); + /* + * If host is Win2016 or higher then we do the GPADL tear down + * here after VMBus is closed. + */ if (vmbus_proto_version >= VERSION_WIN10) { netvsc_teardown_recv_gpadl(device, net_device); netvsc_teardown_send_gpadl(device, net_device);