Received: by 10.223.185.116 with SMTP id b49csp5964117wrg; Wed, 7 Mar 2018 22:47:20 -0800 (PST) X-Google-Smtp-Source: AG47ELs/g4QIt6TLB5lTch2ufAd7Y/b1r2gjxKNJBG6IKVvO9fyXQdbDXT2o7rJGvkrPqcZeSrAn X-Received: by 10.99.125.22 with SMTP id y22mr20353240pgc.125.1520491640089; Wed, 07 Mar 2018 22:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520491640; cv=none; d=google.com; s=arc-20160816; b=uDF9otudyO9CfPIdJ9Wz9mz1Ezko6SIZ/KATTDYa0Rgm36xJsOlK3yh+dQ/rpQrKSa XN4AwzasiWK5PmTEk1ON1bq5VLmJs+kJyQhKSUc+yw/5mKFTU7AmLPXFqS6dh56ERxMg nMBEvrNRn9cuietKAJYR035N606oAjv6PEJGh7peWuOWuJX6CMm+KuuDVBXnzPxz5G9T icD95eI/PBtrgNUiU6ili8C6rdy4Xo93kUxUhhNlCb7thdQeoX3kym83v+Oe/IuWuUKS yjWEf12+WTp00UjT2v4GxQxyR8nuNQJcBKvAwHv0CqCIiy/vAA7m/pUFOi4hpjbq2j7A ba7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=YYEF5EsCrj8cW1Zoro8dQF3W0fiAVPuK5Jx6FezVbEw=; b=dlqRcUlq8H3zZXsL50s/EsyLNfISAie+M8Fg1G3zfv1jshIZtW7tW2VYO5HqrM2247 gGeBTUApz5W/z4tWpDM38TooqKIAXIyRpnz91z9vNF9Vcm/Lf+6DoovsUZWtpV9IfRnD cmsCa03twO/StbdNCxXdITD7UNavn12qdfC5Hu6KdL+Fsgwg5D/PAJ6TimaQnQNREiu9 cD1nnZjDZIc1OSu6ZTY/ndmBHSS+pSnADkDe/1YY1iKlOb6K9ogp2h625fpJx02RJfO7 w29+V/7jpbqpgG+PsgYblPf3bg1uV7S041L5UNHXsfy5YAxb69D5Nh4cwLZH/bY6+Kjl Fdyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hgK/dJcS; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a44-v6si13359824pli.533.2018.03.07.22.47.05; Wed, 07 Mar 2018 22:47:20 -0800 (PST) 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=@microsoft.com header.s=selector1 header.b=hgK/dJcS; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935268AbeCHE62 (ORCPT + 99 others); Wed, 7 Mar 2018 23:58:28 -0500 Received: from mail-sn1nam01on0120.outbound.protection.outlook.com ([104.47.32.120]:33969 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965040AbeCHE6L (ORCPT ); Wed, 7 Mar 2018 23:58:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YYEF5EsCrj8cW1Zoro8dQF3W0fiAVPuK5Jx6FezVbEw=; b=hgK/dJcSHQM6+5y+19abafq3B7IHZTjZJ8fbGUTvCKr6zc2MbK00d+amyKFdzyG+AQS0V6wPyzesHbqdHaCXoIAtdUYiJrifl43VzMCNL91qrhgdO8JMH1hW8qdwy6NfKQBHJTbrVnZyN4OKRiw6KNIWIEH76joo+GN8v71jNkM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0888.namprd21.prod.outlook.com (52.132.132.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:58:06 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:58:06 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Haiyang Zhang , Stephen Hemminger , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 10/67] hv_netvsc: Fix the receive buffer size limit Thread-Topic: [PATCH AUTOSEL for 4.14 10/67] hv_netvsc: Fix the receive buffer size limit Thread-Index: AQHTtpn5t0FHs5gbF0G4TDTUa93nHg== Date: Thu, 8 Mar 2018 04:57:35 +0000 Message-ID: <20180308045641.7814-10-alexander.levin@microsoft.com> References: <20180308045641.7814-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045641.7814-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0888;7:HJzAQbasdVvZzQRP4/uJPdzHNwp+w0/jfVaYxAKpCFIiiPqH43VCxlElvQXz3zhEgxMpW/qZh3LEte/Yq4aOlNafSu2bPBkprVE+bu7wewmbgZgj/SAoVQWBlItN5QhY/YIZOgVKP9kPA8b/USoZlgdco2I8geLtfpoHSk/a5JKvTbPj8SWkfCcOGfNcd8//gsxnVVugC/HlwFa6pjUysa7cthiYjLTHiUEWujwdbSE8bXG5PNYjC5sJM3uf33gn;20:YkjbIznGiTAba9u7aILI/e31o/D9ov7mXpeyZHhvHUQ1NwtFizU5yYj6ArJwPgnnsG//RnATsLHLNn5AYMrXabT9ZyZMpC3DVyg2Gi7ZDiy2g/rJr6RRra9G42G3VkO8fKfNRaZdOJWrgfHh2YCigeyGT2yCcVH6wxyLhxKHMsE= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 54590cda-511e-4454-7e42-08d584b12e6c x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0888; x-ms-traffictypediagnostic: DM5PR2101MB0888: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0888;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0888; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(346002)(376002)(39380400002)(396003)(189003)(199004)(6116002)(99286004)(2950100002)(6512007)(6666003)(10290500003)(36756003)(5660300001)(106356001)(1076002)(22452003)(3846002)(97736004)(316002)(53936002)(68736007)(105586002)(4326008)(25786009)(54906003)(478600001)(2501003)(186003)(66066001)(76176011)(3280700002)(86362001)(14454004)(2900100001)(5250100002)(110136005)(305945005)(7736002)(72206003)(3660700001)(6436002)(2906002)(26005)(6486002)(10090500001)(8676002)(81156014)(107886003)(81166006)(86612001)(6506007)(59450400001)(8936002)(102836004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0888;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: iJWzU+uy+cE3SROnXeQwlHBK4LCchfVMoYg4WuMORd8yDD+/lYK8v9J0ifhywSyExK7OGnfNkFM+kVOq8p7u4Rw1z8JJQGs5E0bYQyG9gwnNZCo83wZqvQNt9Uspa1+MUBhPUYcuScH/CM6VsL+2veowqb4tHkt5p6FVznrmxNMqmg82UrA28ofINt6+cAMjDgs9TaEoEEGKwo/0iPjjNcy59MBUYiPVMLVNP1XRiXpPdDJAeoXjjHU+7rX6RTIrZbuLR6TlJv91ecqb9icyqo/7NmWmL7JBpKgOqLp968V5pEpQBvqOTSne6fQR5tryxLVtx2KdXTuKdgmS9R552g== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54590cda-511e-4454-7e42-08d584b12e6c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:57:35.7437 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0888 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haiyang Zhang [ Upstream commit 11b2b653102571ac791885324371d9a1a17b900e ] The max should be 31 MB on host with NVSP version > 2. On legacy hosts (NVSP version <=3D2) only 15 MB receive buffer is allowed, otherwise the buffer request will be rejected by the host, resulting vNIC not coming up. The NVSP version is only available after negotiation. So, we add the limit checking for legacy hosts in netvsc_init_buf(). Fixes: 5023a6db73196 ("netvsc: increase default receive buffer size") Signed-off-by: Haiyang Zhang Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/hyperv/hyperv_net.h | 6 ++++-- drivers/net/hyperv/netvsc.c | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_ne= t.h index 5176be76ca7d..04e9852ab804 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -635,9 +635,11 @@ struct nvsp_message { #define NETVSC_MTU 65535 #define NETVSC_MTU_MIN ETH_MIN_MTU =20 -#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */ -#define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15) /* 15MB */ +/* Max buffer sizes allowed by a host */ +#define NETVSC_RECEIVE_BUFFER_SIZE (1024 * 1024 * 31) /* 31MB */ +#define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024 * 1024 * 15) /* 15MB */ #define NETVSC_SEND_BUFFER_SIZE (1024 * 1024 * 15) /* 15MB */ + #define NETVSC_INVALID_INDEX -1 =20 #define NETVSC_SEND_SECTION_SIZE 6144 diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 8d5077fb0492..a6bafcf55776 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -262,6 +262,11 @@ static int netvsc_init_buf(struct hv_device *device, buf_size =3D device_info->recv_sections * device_info->recv_section_size; buf_size =3D roundup(buf_size, PAGE_SIZE); =20 + /* Legacy hosts only allow smaller receive buffer */ + if (net_device->nvsp_version <=3D NVSP_PROTOCOL_VERSION_2) + buf_size =3D min_t(unsigned int, buf_size, + NETVSC_RECEIVE_BUFFER_SIZE_LEGACY); + net_device->recv_buf =3D vzalloc(buf_size); if (!net_device->recv_buf) { netdev_err(ndev, --=20 2.14.1