From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00078.outbound.protection.outlook.com [40.107.0.78]) by dpdk.org (Postfix) with ESMTP id 627435A for ; Fri, 7 Sep 2018 11:51:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rd3nI/INsX+jVGq5LXK/JLkXORbxn90wkA1GGSPradM=; b=Hroo1YbRSQwj8OywzB9euniyk5pNxvFcocpWks8WrbUc8t68/MgIpkwjPaVgdiCR881g1BS7dyC5NSjhXi//Leu1KojCekbZb1ACjwR0G6z1eoNY5nEPJDFbIeRWTi03bknZmaWfkS+/Q8OJdNRHlrHB8CDovhZYGJoLrJrTZFU= Received: from VI1PR08MB3167.eurprd08.prod.outlook.com (52.133.15.142) by VI1PR08MB3069.eurprd08.prod.outlook.com (52.133.15.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.16; Fri, 7 Sep 2018 09:51:00 +0000 Received: from VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::b91d:e285:4647:f3e8]) by VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::b91d:e285:4647:f3e8%2]) with mapi id 15.20.1101.019; Fri, 7 Sep 2018 09:51:00 +0000 From: "Gavin Hu (Arm Technology China)" To: Jiayu Hu , "dev@dpdk.org" CC: "zhihong.wang@intel.com" , "tiwei.bie@intel.com" , "maxime.coquelin@redhat.com" Thread-Topic: [dpdk-dev] [PATCH] vhost: fix corner case for split ring enqueue operation Thread-Index: AQHURnq6RaNFnYMq8EWUHaqP/mPgD6TkkziA Date: Fri, 7 Sep 2018 09:51:00 +0000 Message-ID: References: <1536305094-126439-1-git-send-email-jiayu.hu@intel.com> In-Reply-To: <1536305094-126439-1-git-send-email-jiayu.hu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3069; 6:jwMdzh/+QVGgSpUVgffUZxley8zX+2ijgkpm3EE4LSZdmv4Wi6FGXu+Lgawbd7Okndciz5rNy/VmYU1znraJg5FzT+/Mt4vs88+/EV1vmzFU2CiBgHzpaKbPFVusd7eDj7VnaYHOFKg5DSj34nVUt3qalQCtvx3bC1oND4A2GrhvQY/sE3TZWlHidaVN5ipQYPffzRpqKuK6aHc+37SmW5gHFOJwJzapRMmElfOMkNu9xbl78kcnDG3AqjIkRMd8GuOz0uPZ/yhkc321LSP6xq2cEY1uiz8gQSiGBauihyHQ2jb1G4P6zPzDWlEPXA8K/RElMkJciizhFj6RAMFPXx8U8RBpX2v7yIOpI+RibVq5RADNF9GBg6bzFQhrSBTeFFVrTIxFHhdt5F48Qgozb9tIUa77yz+cbNuidcSjmwt7JvybjJq/kfmWK7aBHyZpLGVzhGWFJ0DYUotkWJfNew==; 5:4fURMMl2tdcM2Xpa7JG3AGS8cMqd4ZbFbyrYqT46NWPFcNnkE901Ssym/oUx0fPTfGsogX0aVGb4xynpqQSEvB0XJf7Zac2gGCBMYHBUnbJG8FzgYY20OImOSsccGrf1T0xmwLgdxKW7qFhMy6wn4+D3ZDEf1eL4fwosSVbrCYU=; 7:y7v0YfrZcjKaDjb27DS+p1P0DUNcU5vKiI9ayXaHycxrB59oYUkwuSozqNeW71vMi56Qw89Mh0yqdEpiWvnSWPB1HcuA7LKJ6GHNQlzVFiln8ZwM4F4HxyWm+hB0JxdVJ9ckMSVgGpmJ0yLvdpZvfmCsmu8I2cKAqEhLgi8Fv4Knl3yrf9ddErwqBDiQVsVOKvOSY5ZF0f3ooLPcp0fntCOJlh0A0I+XVsOMdZabj1J7lb7nhtlLxPzK3bJLEVAi x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 947f51e2-302a-4c14-63c1-08d614a76abd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3069; x-ms-traffictypediagnostic: VI1PR08MB3069: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(103651359005742)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231344)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699050); SRVR:VI1PR08MB3069; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3069; x-forefront-prvs: 07880C4932 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(346002)(376002)(396003)(366004)(40434004)(189003)(13464003)(199004)(6246003)(68736007)(9686003)(86362001)(106356001)(6346003)(55236004)(102836004)(53546011)(6506007)(26005)(55016002)(105586002)(72206003)(14454004)(2900100001)(33656002)(53936002)(486006)(476003)(446003)(11346002)(97736004)(229853002)(6116002)(186003)(2501003)(5660300001)(6436002)(5250100002)(110136005)(305945005)(25786009)(478600001)(99286004)(256004)(54906003)(14444005)(5024004)(316002)(8936002)(4326008)(7696005)(7736002)(74316002)(2906002)(66066001)(81166006)(81156014)(76176011)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3069; H:VI1PR08MB3167.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; x-microsoft-antispam-message-info: T7OUfsLlxYlNRXzIyGPOHhverG3NayK/6SP75Esp/bpB+ggGNt/4t5Yu4qEcCJ1syYTkZqbtjJ/w5638yvJkdprt3pN5GEVGWOzXnosauhzH+Pf/CanDRykKJYHRn/+NTOwObk8YrsTs78JtcY0ny+c+qVM7C5yp/Cv5yQIyYYanzntuTjllze+bNsgQwRw0EpThw+JennJoLNj91sJfGUHduKBy2G7TWYZqBAQep8tqZ4jryI/nVOjsGI0lgvvd8Nh88Sycd4MmW1EErznkNF8u7VfTq+CU/nxZRHqzFXrtaKzQJ7ccVhKWdr3tH7Doa+8YPoBTP+BF0Xqmo9RHFmxycpVHnGa9fIUAiGCgRCU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 947f51e2-302a-4c14-63c1-08d614a76abd X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2018 09:51:00.1457 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3069 Subject: Re: [dpdk-dev] [PATCH] vhost: fix corner case for split ring enqueue operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2018 09:51:01 -0000 This is a good catch for split vring, I advise to change also for packed vr= ing. It also has this issue. > -----Original Message----- > From: dev On Behalf Of Jiayu Hu > Sent: Friday, September 7, 2018 3:25 PM > To: dev@dpdk.org > Cc: zhihong.wang@intel.com; tiwei.bie@intel.com; > maxime.coquelin@redhat.com; Jiayu Hu > Subject: [dpdk-dev] [PATCH] vhost: fix corner case for split ring enqueue > operation > > When perform enqueue operations on the split ring, if the reserved buffer > length from the descriptor table execeeds 65535, the returned length by > fill_vec_buf_split() is overflowed. > This patch is to avoid this corner case. > > Fixes: f689586bc060 ("vhost: shadow used ring update") > > Signed-off-by: Jiayu Hu > --- > lib/librte_vhost/virtio_net.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c index > 99c7afc..9f3c88f 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -122,7 +122,7 @@ flush_shadow_used_ring_split(struct virtio_net *dev, > struct vhost_virtqueue *vq) > > static __rte_always_inline void > update_shadow_used_ring_split(struct vhost_virtqueue *vq, > - uint16_t desc_idx, uint16_t len) > + uint16_t desc_idx, uint32_t len) > { > uint16_t i =3D vq->shadow_used_idx++; > > @@ -329,7 +329,7 @@ static __rte_always_inline int fill_vec_buf_split(st= ruct > virtio_net *dev, struct vhost_virtqueue *vq, > uint32_t avail_idx, uint16_t *vec_idx, > struct buf_vector *buf_vec, uint16_t > *desc_chain_head, > - uint16_t *desc_chain_len, uint8_t perm) > + uint32_t *desc_chain_len, uint8_t perm) > { > uint16_t idx =3D vq->avail->ring[avail_idx & (vq->size - 1)]; > uint16_t vec_id =3D *vec_idx; > @@ -409,7 +409,7 @@ reserve_avail_buf_split(struct virtio_net *dev, struc= t > vhost_virtqueue *vq, > uint16_t max_tries, tries =3D 0; > > uint16_t head_idx =3D 0; > -uint16_t len =3D 0; > +uint32_t len =3D 0; > > *num_buffers =3D 0; > cur_idx =3D vq->last_avail_idx; > @@ -1378,7 +1378,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct > vhost_virtqueue *vq, > > for (i =3D 0; i < count; i++) { > struct buf_vector buf_vec[BUF_VECTOR_MAX]; > -uint16_t head_idx, dummy_len; > +uint16_t head_idx; > +uint32_t dummy_len; > uint16_t nr_vec =3D 0; > int err; > > -- > 2.7.4 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.