Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1962121imm; Thu, 24 May 2018 03:39:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrfXFIP9n7rGKxQN2zKF3q5Xar2JDj3WkTu3IdnuOK0RemfrORpyl6YMLuKW7UgkwlZ/MIG X-Received: by 2002:a63:b34e:: with SMTP id x14-v6mr5437811pgt.70.1527158384144; Thu, 24 May 2018 03:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158384; cv=none; d=google.com; s=arc-20160816; b=BKqZvJ7EXlX+6g4e7DGGwKjehOEySEhm2BMp4JifHw5XcKzlIy433GakqaFtbTDPcW Wki8/l0ErK9eq6iB5H0H/aKngNobjGsFDyQ/FvGu2bQt83cyqxnimAdvnBRwXVD5MVXn ninODoEzsARcmjUeQP1288pWR7zDettkUeBlo/4Fldz6pbVxeNho+FdhjErl7YvY4Y30 7vucw6krjMMDflpY5dJgESfQdIqlcGNGcsmHnTRgAQIU0IoGNPYgbgmx38twh8pyMfxi QOMvpDFrpDNgVeWcnr2hMlubmPHL7WqJGSzCMa8KFdxe8uSp3aJ2SWe4u0pqdwBeTUwA hJjQ== 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=M1UKdTDKG9u/DDxF2t6Ab9UFFHeB47OTMQ3JCdcA1xU=; b=zFyQFVbxrQWM+1XnRdPYKZHTYCQzFpOv/HYll1CF6srjqpRbpcuiYjSBDe02XK1JEa +LDddHG+Tq9EYryVDWwguj3xMqF4sWPL2426yVIsXOhL0dwap6x9znu3mOwmzM/FOKDd fspSvzZ7MQQ5gJR9m/ZaQW4NbjVeE+EWe/Ibr9iKJkvfKiXdDYzlku4rrj820feMdg8M w27WZd/M9c8DMbzZBX7Sku5kytduICwXIkUM26lbVxGP/eJtdwPLFZVWlQJ8qSGvPnLZ kvmBn8Jfyu2O2t40t9i/xxzscKHL46Url2Ri2N3k8qBWl/yrNDnliRtM/de/QL5cTosq F3yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IiUMOI/E; 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 x61-v6si20483151plb.560.2018.05.24.03.39.29; Thu, 24 May 2018 03:39:44 -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=IiUMOI/E; 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 S1032127AbeEXKht (ORCPT + 99 others); Thu, 24 May 2018 06:37:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:40904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030802AbeEXJ7n (ORCPT ); Thu, 24 May 2018 05:59:43 -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 579E120870; Thu, 24 May 2018 09:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155982; bh=kMU9YNPzXUBv7moauMt5r2tBCrpvLOLPWrSME0ja7Fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IiUMOI/EiDyFFgE5umLH89ZvSP0ggJXELP5aH5Tzu9e0Kq4jZM3EmTalyGI6yj+Q7 TcUcwwBvnnTMPNsGNcRGa0JjZHD3y7M7S5dFOzVffV4TAchEmUBuGMmbm3YSFL4o5I FzvBSvjJ6WWzNu2pz1Yrhraf9IpKBoV1fN1Wo0yk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Regis Duchesne , Ronak Doshi , "David S. Miller" Subject: [PATCH 4.16 021/161] vmxnet3: use DMA memory barriers where required Date: Thu, 24 May 2018 11:37:26 +0200 Message-Id: <20180524093020.868537445@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: "hpreg@vmware.com" [ Upstream commit f3002c1374fb2367c9d8dbb28852791ef90d2bac ] The gen bits must be read first from (resp. written last to) DMA memory. The proper way to enforce this on Linux is to call dma_rmb() (resp. dma_wmb()). Signed-off-by: Regis Duchesne Acked-by: Ronak Doshi Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/vmxnet3/vmxnet3_drv.c | 22 ++++++++++++++++++++++ drivers/net/vmxnet3/vmxnet3_int.h | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -369,6 +369,11 @@ vmxnet3_tq_tx_complete(struct vmxnet3_tx gdesc = tq->comp_ring.base + tq->comp_ring.next2proc; while (VMXNET3_TCD_GET_GEN(&gdesc->tcd) == tq->comp_ring.gen) { + /* Prevent any &gdesc->tcd field from being (speculatively) + * read before (&gdesc->tcd)->gen is read. + */ + dma_rmb(); + completed += vmxnet3_unmap_pkt(VMXNET3_TCD_GET_TXIDX( &gdesc->tcd), tq, adapter->pdev, adapter); @@ -1103,6 +1108,11 @@ vmxnet3_tq_xmit(struct sk_buff *skb, str gdesc->txd.tci = skb_vlan_tag_get(skb); } + /* Ensure that the write to (&gdesc->txd)->gen will be observed after + * all other writes to &gdesc->txd. + */ + dma_wmb(); + /* finally flips the GEN bit of the SOP desc. */ gdesc->dword[2] = cpu_to_le32(le32_to_cpu(gdesc->dword[2]) ^ VMXNET3_TXD_GEN); @@ -1298,6 +1308,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx */ break; } + + /* Prevent any rcd field from being (speculatively) read before + * rcd->gen is read. + */ + dma_rmb(); + BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2 && rcd->rqID != rq->dataRingQid); idx = rcd->rxdIdx; @@ -1528,6 +1544,12 @@ rcd_done: ring->next2comp = idx; num_to_alloc = vmxnet3_cmd_ring_desc_avail(ring); ring = rq->rx_ring + ring_idx; + + /* Ensure that the writes to rxd->gen bits will be observed + * after all other writes to rxd objects. + */ + dma_wmb(); + while (num_to_alloc) { vmxnet3_getRxDesc(rxd, &ring->base[ring->next2fill].rxd, &rxCmdDesc); --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -69,12 +69,12 @@ /* * Version numbers */ -#define VMXNET3_DRIVER_VERSION_STRING "1.4.15.0-k" +#define VMXNET3_DRIVER_VERSION_STRING "1.4.16.0-k" /* Each byte of this 32-bit integer encodes a version number in * VMXNET3_DRIVER_VERSION_STRING. */ -#define VMXNET3_DRIVER_VERSION_NUM 0x01040f00 +#define VMXNET3_DRIVER_VERSION_NUM 0x01041000 #if defined(CONFIG_PCI_MSI) /* RSS only makes sense if MSI-X is supported. */