From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 96F12A05D3 for ; Wed, 27 Mar 2019 19:30:35 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5418358C4; Wed, 27 Mar 2019 19:30:35 +0100 (CET) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10044.outbound.protection.outlook.com [40.107.1.44]) by dpdk.org (Postfix) with ESMTP id 800E258C4 for ; Wed, 27 Mar 2019 19:30:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8s+YKLcX7++0f8rOFpifk8laIjorNDc3R+fv2tXgX5c=; b=Mrs1C5py7aadveXC+m77ycl0eoyMnXj8GLGEhDV5LwfpjmzTTz6znKGRtidEFegFVumAybFYV1n6WIz2ZJ+jJ48xeexNZE2g3N9AI0vfkGKyeQYW+u/b9ZXiduGC81r87Hr/t6d+q4qNcIVE2BT+vO5VnZd6K7vfOSqk6H38wsQ= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4026.eurprd05.prod.outlook.com (52.134.72.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Wed, 27 Mar 2019 18:30:33 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::6072:43be:7c2d:103a]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::6072:43be:7c2d:103a%3]) with mapi id 15.20.1750.014; Wed, 27 Mar 2019 18:30:33 +0000 From: Yongseok Koh To: Ilya Maximets CC: dpdk stable , Maxime Coquelin Thread-Topic: [PATCH 17.11] net/virtio: add barrier before reading the flags Thread-Index: AQHU2bFGLtT/XQ9Z6kuqSOBwPLad76Yf4u8A Date: Wed, 27 Mar 2019 18:30:33 +0000 Message-ID: <8C42CC9F-1107-4653-9815-5F519BDBDEE7@mellanox.com> References: <20190313152718.17888-1-i.maximets@samsung.com> In-Reply-To: <20190313152718.17888-1-i.maximets@samsung.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5bf89bca-cf8f-4d9a-2f2f-08d6b2e24c74 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB4026; x-ms-traffictypediagnostic: DB3PR0502MB4026: x-microsoft-antispam-prvs: x-forefront-prvs: 0989A7979C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(136003)(366004)(396003)(346002)(199004)(189003)(256004)(6116002)(83716004)(99286004)(11346002)(66066001)(14444005)(476003)(25786009)(6436002)(53936002)(305945005)(6486002)(68736007)(2616005)(82746002)(7736002)(86362001)(316002)(54906003)(6916009)(2906002)(71200400001)(6246003)(446003)(71190400001)(105586002)(8676002)(5660300002)(3846002)(6512007)(8936002)(33656002)(36756003)(81166006)(81156014)(26005)(478600001)(102836004)(106356001)(4326008)(97736004)(14454004)(53546011)(186003)(76176011)(486006)(229853002)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4026; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: rgBxpbD07EMcVTULHxHnhrrhuIxocwyH35IbXinDxnm9DOtE2iD113mFBGHRtEvj4EOsNBVL93sXG6IXIJs8HGqnxy+sZKW3wz+af1CXZ2TWUDcft5O5oXYjYASSwRal8qcsewz+6oIUm2KNGEKAq2e3quWk3P4WEG1evI8SyAcEflDSctP0tYnAnb1GfedcRq22VFfhCQnf0Da1CfeGa53vsfahY/0YVJshEfA4++SEeuPX44gsMHrGzdkZmIsxBv13pQ12UjWsG3DYiiHRmzIHuTY/FjOPxUuyQpxxI+fego8/z6h+eyJ2N6i2eSFRXAuGsBUV0hoYiwMoBezSQvzGzVUP/9NoDbfVCsntnsXbSrjF961Ug9fOtMxkBupF1zKUzY6i5QcD7FPPY6HFw/vRhthltIbEdGxNuWPvdQE= Content-Type: text/plain; charset="us-ascii" Content-ID: <9976D1D62410E542BFC3BAB246ADFC5A@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bf89bca-cf8f-4d9a-2f2f-08d6b2e24c74 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Mar 2019 18:30:33.3789 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4026 Subject: Re: [dpdk-stable] [PATCH 17.11] net/virtio: add barrier before reading the flags X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" > On Mar 13, 2019, at 8:27 AM, Ilya Maximets wrote= : >=20 > [ backported from upstream commit d21d05c7a9c1c49ec927f961c4ab797a598af5c= a ] >=20 > Reading the used->flags could be reordered with avail->idx update. > vhost in kernel disables notifications for the time of packets > receiving, like this: >=20 > 1. disable notify > 2. process packets > 3. enable notify > 4. has more packets ? goto 1 >=20 > In case of reordering, virtio driver could read the flags on > step 2 while notifications disabled and update avail->idx after > the step 4, i.e. vhost will exit the loop on step 4 with > notifications enabled, but virtio will not notify. >=20 > Fixes: c1f86306a026 ("virtio: add new driver") > Cc: stable@dpdk.org >=20 > Reported-by: Shahaf Shuler > Signed-off-by: Ilya Maximets > Reviewed-by: Maxime Coquelin > Acked-by: Michael S. Tsirkin > --- applied to stable/17.11 Thanks, Yongseok > drivers/net/virtio/virtqueue.h | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueu= e.h > index 788d04dfa..6efd4f01c 100644 > --- a/drivers/net/virtio/virtqueue.h > +++ b/drivers/net/virtio/virtqueue.h > @@ -354,6 +354,11 @@ vq_update_avail_ring(struct virtqueue *vq, uint16_t = desc_idx) > static inline int > virtqueue_kick_prepare(struct virtqueue *vq) > { > + /* > + * Ensure updated avail->idx is visible to vhost before reading > + * the used->flags. > + */ > + virtio_mb(); > return !(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY); > } >=20 > --=20 > 2.17.1 >=20