Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1677217pxu; Sun, 6 Dec 2020 03:44:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUjbQxt64er1i0gv6f8XzpdPGIzzLwZUaXlmKKYpKJPcAP1lwhQphHf3DDEM3qt3jo+y9Q X-Received: by 2002:a50:9ea4:: with SMTP id a33mr12230635edf.70.1607255067948; Sun, 06 Dec 2020 03:44:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607255067; cv=none; d=google.com; s=arc-20160816; b=l2fIJR9ZdNfav04bDz3MIhykUTuyUaukKTtiEfe5SXuQiCEE5jDTX3GndyznvL34X/ DnSZR4GLZkFwSC47gD3IWTTTAz5d9O/9q5mG4V1Tc3C7CF3FiAOUZ6UYaAaXJMKjZmiF tPHUebPSIsE3hzs2QsEEIMm5QiVvGAazdtN7ZIEr7aGQYnm83C41LUQmlKKzEpsHQRS6 PUhDaVbLEeL4p4LEizUqiIsHLLaxxTTpOEoeB2LGYEtmDoIwLNj0/QsHc1s3L9DXtJlE HffAo1/NLjMWMq7RUBup+lroQH/QpDwtQ6z4iO7JOfbEbpmWG/0iRu/pdne7L4RChGnu wD2w== 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=MFEazAVPYwQSN4JN6MBSC4R605glkzu4KwiFPi4b7XQ=; b=UpcXF9lKm403y7fqABXvM8oZuThheQ8J34wDl3CtzkDde+rSTkSICSb1m2YTQSiJgS snvXK4pa3BowBiyBzZXl2l2Z6hN3nHZcWEOtIMTmua9Wha2hVv83WxKIJCIPePicw+xS edrJ4DHyUlEzj1WhikD3CITYEgSMKt4PTtK39xm6FwgOaGGIm03W4O8LLXdS5GyZOKti VjEuXEwG/dggc8NibptXMDshpxBzEjWnF5fT2Ydshj4uWvNUrQo1HNYP9h432imZde13 oKfUSh2NMQ9BAaV7CPO5aqx4OTLUopRCZbNJ92/wabHx+tMav4yR2mlxpH8ad5OTT6g8 tZJw== 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 s10si4603873ejb.154.2020.12.06.03.44.05; Sun, 06 Dec 2020 03:44: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 S1728355AbgLFLkB (ORCPT + 99 others); Sun, 6 Dec 2020 06:40:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:36844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728315AbgLFLkA (ORCPT ); Sun, 6 Dec 2020 06:40:00 -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.19 16/32] ibmvnic: Ensure that SCRQ entry reads are correctly ordered Date: Sun, 6 Dec 2020 12:17:16 +0100 Message-Id: <20201206111556.534444504@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206111555.787862631@linuxfoundation.org> References: <20201206111555.787862631@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 @@ -2162,6 +2162,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-> @@ -2784,6 +2790,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]) { @@ -3180,6 +3193,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; }