Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp119004pxu; Thu, 10 Dec 2020 20:31:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJywrIQASTn8v5SzD+ZsIHhvz7cBnpJpd2lzbZzzYUWqUM7EochqcrF7Z7z28VoCZkFGVUPE X-Received: by 2002:aa7:c151:: with SMTP id r17mr6745701edp.106.1607661092421; Thu, 10 Dec 2020 20:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607661092; cv=none; d=google.com; s=arc-20160816; b=hslBoR6uWJ+DgkQibdkeHF/3s50TwXjEGownwuANOem9rRm+RZT6XPvofBdgQndxvW jUVDHYYXmbY05i64VAJt/9gOuq/enSXGUXTaom0TdL2oYl1hg1qWmk3WRu/s3NdNW416 Ch3j7JNBEhtFQ5P5+HNTyMJnM+H4t1JPs1DuIRvbpjwgZMdVTOKB2szj2M3/tU1T9+h9 I9pC3ad95q7yraX4B9W/WyNCL54y1l/rhE+i+nYS7aZnU6uJ37fvA6qGZKegJAGnH1p+ FzoRJNucc28v7LK+lWtJwMZ/nB2Vt8c7/F1x2SfgiL6NJFjAgz+XWvb6mu6MmREIwNMb IngA== 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=lFD3diMhx0gV9SOq5spUktrmAt36eqUCd/ghjpkpG2k=; b=h4jC1QxJI528NXpyX+Tfp2C8ZOuqwuP64JKmPz5hp6UhBv7EkzsZSrWLqCErWtWLHa QY2XLFoi6EQLIkwpuI07mteYOshXLCb+FtxojsE+HLXfjekEHJDJFOeMU4i0wyto525p MO39koK3ZULGUEQDXhWQ2uSPmgDCVPV9g6Io/kJyFEnI4m0sIEhISPFsc/4xNivMXgBx EfJ6kc94Osa6xuCBPiYtO6YYFFcqtXmjYTw7TcekhjVSqhdFTKslRyVYcB6Ij7tyjS3C KpFLy7afAze14vlHJp+/MWDzXbAVDWidmBIEjpC+nSDJsMTWsRm238LiA9Jr4m2d8QRh f8eQ== 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 a3si3864347ejx.101.2020.12.10.20.31.09; Thu, 10 Dec 2020 20:31:32 -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 S2390422AbgLJOap (ORCPT + 99 others); Thu, 10 Dec 2020 09:30:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:37838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390235AbgLJO34 (ORCPT ); Thu, 10 Dec 2020 09:29:56 -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.9 06/45] ibmvnic: Ensure that SCRQ entry reads are correctly ordered Date: Thu, 10 Dec 2020 15:26:20 +0100 Message-Id: <20201210142602.677822885@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201210142602.361598591@linuxfoundation.org> References: <20201210142602.361598591@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 @@ -985,6 +985,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-> @@ -1373,6 +1379,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]) { @@ -1707,6 +1720,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; }