Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1912720imm; Thu, 24 May 2018 02:49:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZruJa2tC4YjOuEMhGft4B+hrY77uheLrDY2YzaFLvW3es4wn6fpVMIREv/M9IXal3RjmMFm X-Received: by 2002:a63:2547:: with SMTP id l68-v6mr5444713pgl.40.1527155368158; Thu, 24 May 2018 02:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155368; cv=none; d=google.com; s=arc-20160816; b=odnul5Zbx79j1lhYSz/Lg7vp2uyE9JqypThNpeAkt4hnF6uNg3bKptV+qUw6FHtVfQ XivSrtOO/a8ReduE11AVMWtITvb1fmPQbrHCUHBrW0nE23nnvIyOAnkjmP+yx+2pIcMb 0XAEmLCi53gwTOMWT6b5AMJMxOdjgDLpdZC/eBp4B8/GDbz/VKLvBk7fkl6og08Z8JQr yE+Du9pms+IMdLqhsFr2iTvOLrMrbjVvChCDTffjc1kpHZ5MA9mzvA7AvBDQ2Bz521dD 5pLpJbwKwXqi1oFYlSRxHFCevS4xs6BKO2JP7BGKXBIke7ERg/NdD09yB8W5N6gE7eqO j9oA== 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=RDx3IwX/U7so677XeXbiUTCL5eYtpGxRbjku6s5hNks=; b=fJrWeZ+B2VHq80SJqze2kDyN4X1S2VRqHXNdGsnyzEJenjwob/ikpbbhz5V8mMoJRX mbN5chPfv3IRUycxZVyK5DPR1alfuPl/UsodJ1CCBh09Itp7GE9w95caQ8QS/Tui5G8K zTcrNfJbFsaV+sIQd+QdVxn8dpuLt8V2CFN5Lykha5Gi1xPc1EuiW2tJaITmp9445jt3 j0niDigKStS66TRWcwe48oBYRJ0KPsPmouiW63hg9k6LoVWeMGiQMIg/++Azj6WmUeKL qedfUhS30sPrSDvMP4ba1sn5CL3M6Wr6i9iB1CKSZlB/2yfdhQxnB2ioAuy8HgZrFaEZ Acjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YdHXJ1fS; 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 w25-v6si16207535pgv.526.2018.05.24.02.49.13; Thu, 24 May 2018 02:49:28 -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=YdHXJ1fS; 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 S967168AbeEXJsE (ORCPT + 99 others); Thu, 24 May 2018 05:48:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:32776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967147AbeEXJr6 (ORCPT ); Thu, 24 May 2018 05:47:58 -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 37E5120847; Thu, 24 May 2018 09:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155277; bh=puWzu80nlCkoJkoMlpHYlKtx74jNRbEcKTNS3g9i0bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdHXJ1fShTEdBZFSW5b3JsxKNamjPVaka1l1g8TeDnNZnCdre/hOoIO187/WmrPFS Obgk4XuCz5B3E9g8buIQssvoMKW8exLCbh0P0UHZQo2ndsfOUTlTAs5juEHlZLW6Hz giwOYr0hHWFM0DdWauYgq3MoBbKrPfcgzFT7h/sE= 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.9 07/96] vmxnet3: use DMA memory barriers where required Date: Thu, 24 May 2018 11:37:50 +0200 Message-Id: <20180524093606.038682285@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) --- 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); @@ -1099,6 +1104,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); @@ -1286,6 +1296,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; @@ -1515,6 +1531,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);