Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2001558imm; Thu, 24 May 2018 04:19:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoh3G7rctp8OI5p2H4sz6MZSUKfOOMaKGLXSGyeIwWfErJzo1S2lOLyeSFzEwHPXsbG/s7g X-Received: by 2002:a17:902:42e4:: with SMTP id h91-v6mr6864394pld.27.1527160745817; Thu, 24 May 2018 04:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160745; cv=none; d=google.com; s=arc-20160816; b=C3CVkq8+2gsSm/ew1klM8jAaUVNLULCtErhKoTDXq/sV2VqgBbXVM1HQVd5YhgfSwN h4Ay0nKBSILpf7NcR6wh5QUHSLulIagpDWD1UARpwHrms/cpacMjiWt98iqwNY5ZYZ0z 7yjnwPG5dNDkufd1s9usUFh1U7xTeV6AxqRYByeQ9nboctKPbq4G4jPs08Rxo9IxHBkV 1oKg2YBbomvXlaoB/QlYYYGHv69C5yoiYhlaPJrlI8N5dpv5NB5sdc/xaHU3nxm4i9gA s7Pk7CmO2NwiqhNNtAF3hEBvVEn2N/MrBso7/ytB1ppm65jA3nFhs82Oc6ufTsEcp/5M TEnQ== 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=7bNEAih6Y5oA3SwpXzjnERLsYq5+RCyoQ2QBj+GZGcU=; b=yxCiBojKD89F0wSaJRnZIsujZ+tE7yWGylZmIzho318WeTxNLj0QE2TdzBZASavYQk UT+gtQRx6dHdx5Fu8g9v6S5TPMvrx+fKQmv1c2z4D65lemH2s9ekqnHV/LFsO+Qcp+Wz BCHitnS2fhiWWw7M3g3bu25pSALnFq8EGpvIC+C5jM73Ef8fAwJO8utzReuLs/fbmwJG hrix10nIitZxgmvS1yjmgMvjzUwjqNI1JC+LavDWRkpTyY4bH/68Ivm0nJ4MKgUqzoQu 9y6HzTUXG4chcWn2lMwc97P4CxavG6T5lpUNflABF4ZSgp10ovbTZgCdAk7HbZcKvcKZ wZwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vfN0c9Xz; 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 f9-v6si19734461plo.568.2018.05.24.04.18.51; Thu, 24 May 2018 04:19:05 -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=vfN0c9Xz; 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 S968733AbeEXLSR (ORCPT + 99 others); Thu, 24 May 2018 07:18:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967533AbeEXJxN (ORCPT ); Thu, 24 May 2018 05:53:13 -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 8994A20847; Thu, 24 May 2018 09:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155593; bh=LzEc4gWj+jsXHgwPjW+t+lUoP89mFa5W3dzZ6zBD4FY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vfN0c9Xzyfj1+Fh8x0E1/rEYSV5w5Kpvn3IxUkFCvLIxaR5pDYCbN7jYp358+BXEp 2Vw/gvYqf7PPFiCVuvXeU644Mq6tUtkbl589u4maOmHsdjNjwB5iMRbxfw1ZNnfUP7 Q+eq1ou4iO+d6yMLh++GwyrTQiPstxhx8NoqI3Sg= 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.14 011/165] vmxnet3: use DMA memory barriers where required Date: Thu, 24 May 2018 11:36:57 +0200 Message-Id: <20180524093622.429612346@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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.14-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);