Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1678879pxu; Sun, 6 Dec 2020 03:48:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWhx1fkmSM5uo6sY/GIDlcabA4HDNCqEf8sg2EKqA/QyDYLJgd+vus84vk+wqJeESHAaYL X-Received: by 2002:a17:906:7118:: with SMTP id x24mr14865410ejj.333.1607255308002; Sun, 06 Dec 2020 03:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607255307; cv=none; d=google.com; s=arc-20160816; b=pdky3np77AeI3c7mYUA47aMpHZnDPV9eZX2+7w9JvYVRxKfK15iyxI8kbpaP7llHJx y+9D/g4KqABTB+eMl+hk5ROGGMcJwFjIANmZzaPovIrb950JUPjvRtbaVKw7ZKeJZTZF gVclsQub1fCtIbSeLeT8/l+Bmc4GyRpfZpGGNyxQEzXsHsROM3/6PYdJMHP9mOJ87gtQ RsnggrDg7l5c4L5OnbIJZnLgWUSbkrs5wJSskCI+2kPsSSIJkiK1jLexVrqlyE8o9cHi 5gXDzsbC9QU5PSb8GsqmVp/USQLhBcX1wOFjPYIk0X8zxpAlId8OdzaE1SBeDe6IG2Nu aUTA== 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=7IxXM4X6AWlDNcP0zEWAmENo4OUpb2Zj4N6P9FhmoMM=; b=VYa8EwrATpGwQpTl5VMKGz4+8FlTOrFt1yvkatJ+7hG7xVSudHwN4lVAZv4GEsH7NN vBOjFgPAS7vSJHd5NKAzUh5njIFvBhPttpxncY86oL+CP4P/U/2noUINJMU4BD1+ft70 8tT9pLO43SAxfroELV/FldQABtSz42cG0sdkev2NdeRFRkXWatj7ovgi98FTd7QFCvFO sc12bwymazI/I7hJ1uEwxkJ7YjtTLobePo7P7U2nhVdhvrgI3iHzmXNxuWxL+JnOKO20 rXeqkUIHRx92YBsl5DKy77+rmR4s1jZdha1+/ZbVqsUPXS/mIk/a3nMZvXVxfrt+Y/8v yl3A== 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 r10si4685167ejg.233.2020.12.06.03.48.05; Sun, 06 Dec 2020 03:48:27 -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 S1729388AbgLFLoo (ORCPT + 99 others); Sun, 6 Dec 2020 06:44:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:44440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729353AbgLFLog (ORCPT ); Sun, 6 Dec 2020 06:44:36 -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 5.9 20/46] ibmvnic: Ensure that SCRQ entry reads are correctly ordered Date: Sun, 6 Dec 2020 12:17:28 +0100 Message-Id: <20201206111557.433246781@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206111556.455533723@linuxfoundation.org> References: <20201206111556.455533723@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 @@ -2409,6 +2409,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-> @@ -3107,6 +3113,13 @@ restart_loop: unsigned int pool = scrq->pool_index; int num_entries = 0; + /* 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]) { @@ -3507,6 +3520,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; }