Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1677184pxu; Sun, 6 Dec 2020 03:44:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyllVoFGJTEiXUU5iRdAqhH8I62D1pKU/89Yvky4dfbY5tdUDWtlPlXwIvv7RZVXU/Vpgcr X-Received: by 2002:a50:9310:: with SMTP id m16mr11062568eda.94.1607255065240; Sun, 06 Dec 2020 03:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607255065; cv=none; d=google.com; s=arc-20160816; b=d8mW0JHCVobsryTZp2xvZjUyYIObtZDASSpGw3RZIoVXRCx7323tQC36CEI8KkYk/0 F4suSdyMyzUMD69ygX5Qwnlz8DETqbyNXjw/6MEwy0AGD8NHRAUpwavwrCTm4By8WE3h mQD/np+tOMmNu7QrAp/l6g7gnKfOSnhX25WWaEov/IXrxxqRYPkuZSE9DqKG46RnVld7 QKAxnhyrnXrdKWcNYpPI2naw6t4wCaJNsaKi57GdYfExBn1INaAsMEhfySt2rqZXHO4m OO8/1BfC2Xxs5/AepE+bxZAnbVGvJPmtWARUa6Zdq5AYCf/0cIrSEVnuEFzne1mnoRrQ 96Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=TCVL4SOfh1kKw1MZAF7whVaEDTWdNryNUT/PYdWAfmE=; b=WBenuD4vtMLbr8udqbYpR6iXNd8fAiHCo3sO1KXDDgq0U+utA9l9bdlp3o/nQ3mDEf uMhUYJ7l1KSAT8/sOgkoA8d52gLNHQlSxnT6eDuFzIp7c3OftfS937Z8RsHA4P8Qi51b x37skfixEGGzM3r5uKHxKpdhV796uv+uaXw2NegrUqfR1IGX45gPtqxAY8NIv2DdiGA9 Og/c5eHaAkwzfJVfbOPBGfBqLCEoRosINR9GaHKF32hA+fQdFs/erBkvPMGYqj8fG2ku +KJZV9CtmFd2Vk2P3jZhKj79wrbjY/FP2znf6QqVtWh+BdEXy6gqF8UtS5Vu9yTOp3l0 cKRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si4907096ejh.137.2020.12.06.03.44.02; Sun, 06 Dec 2020 03:44:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727982AbgLFLj0 (ORCPT + 99 others); Sun, 6 Dec 2020 06:39:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:35896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727953AbgLFLjZ (ORCPT ); Sun, 6 Dec 2020 06:39:25 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Falcon , "David S. Miller" Subject: [PATCH 4.14 10/20] ibmvnic: Ensure that SCRQ entry reads are correctly ordered Date: Sun, 6 Dec 2020 12:17:13 +0100 Message-Id: <20201206111556.055765049@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206111555.569713359@linuxfoundation.org> References: <20201206111555.569713359@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Falcon [ Upstream commit b71ec952234610b4f90ef17a2fdcb124d5320070 ] Ensure that received Subordinate Command-Response Queue (SCRQ) entries are properly read in order by the driver. These queues are used in the ibmvnic device to process RX buffer and TX completion descriptors. dma_rmb barriers have been added after checking for a pending descriptor to ensure the correct descriptor entry is checked and after reading the SCRQ descriptor to ensure the entire descriptor is read before processing. Fixes: 032c5e82847a ("Driver for IBM System i/p VNIC protocol") Signed-off-by: Thomas Falcon Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/ibm/ibmvnic.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -1658,6 +1658,12 @@ restart_poll: if (!pending_scrq(adapter, adapter->rx_scrq[scrq_num])) break; + /* The queue entry at the current index is peeked at above + * to determine that there is a valid descriptor awaiting + * processing. We want to be sure that the current slot + * holds a valid descriptor before reading its contents. + */ + dma_rmb(); next = ibmvnic_next_scrq(adapter, adapter->rx_scrq[scrq_num]); rx_buff = (struct ibmvnic_rx_buff *)be64_to_cpu(next-> @@ -2177,6 +2183,13 @@ restart_loop: while (pending_scrq(adapter, scrq)) { unsigned int pool = scrq->pool_index; + /* The queue entry at the current index is peeked at above + * to determine that there is a valid descriptor awaiting + * processing. We want to be sure that the current slot + * holds a valid descriptor before reading its contents. + */ + dma_rmb(); + next = ibmvnic_next_scrq(adapter, scrq); for (i = 0; i < next->tx_comp.num_comps; i++) { if (next->tx_comp.rcs[i]) { @@ -2530,6 +2543,11 @@ static union sub_crq *ibmvnic_next_scrq( } spin_unlock_irqrestore(&scrq->lock, flags); + /* Ensure that the entire buffer descriptor has been + * loaded before reading its contents + */ + dma_rmb(); + return entry; }