From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3209717C79; Wed, 5 Feb 2025 15:10:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738768216; cv=none; b=LCZoiL7yfAwtTf56WcpeKi5CNFAmd1Iun4QDghi/ldy9u+pPzf5d2bN630Xm9/9n8M4OYd2E4nSbT5lqaadTVz+MM6dUBTqPYDqh3onP/WKd8LANAsuZR+olRyI2R06xmgZ+aKp3mbTVmerw7m/yORUov1C+ltGe7HtDYN3AV/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738768216; c=relaxed/simple; bh=Y4leX5e5knHuZYgz8/Eh3F6r+Xs5ghrsGboWIMO/KCk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hEHjL52FuJxEAbceOh/XFz1VoMF+OWVaNJLGYFpyD5U63SUOLO+CQWSze44QGaVT8bSI6C/SG/3HNK+oY0D0KgCcJLVT/UDN5jtO13+EItuu4D8hjMypAfvMqKr0Ix5cwvnnJo8plFsptCPbQfpl7elZxyuDsg+e+5Epp/UouE0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Tvx9kJ1c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Tvx9kJ1c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90AC3C4CED1; Wed, 5 Feb 2025 15:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738768216; bh=Y4leX5e5knHuZYgz8/Eh3F6r+Xs5ghrsGboWIMO/KCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tvx9kJ1cE0Uxe8SmGnXPKzSJzDwzIZ6d0afDOsFsdJf0TaCsOiOuHj5RxpqWJOhrB xPVSPODfdFAkVgOsgsH5NMOVsflHIWO7NUTUo8MgM7eG5NLMIiBbWF0OsMzkbLbGcp YcJZpoG/6+5pnMMcGxdPtHnCKQ8DBDGQeVJCpGNY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Przemek Kitszel , Sridhar Samudrala , Lance Richardson , Emil Tantilov , Krishneil Singh , Tony Nguyen , Sasha Levin Subject: [PATCH 6.13 513/623] idpf: add read memory barrier when checking descriptor done bit Date: Wed, 5 Feb 2025 14:44:15 +0100 Message-ID: <20250205134515.852458286@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205134456.221272033@linuxfoundation.org> References: <20250205134456.221272033@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Emil Tantilov [ Upstream commit 396f0165672c6a74d7379027d344b83b5f05948c ] Add read memory barrier to ensure the order of operations when accessing control queue descriptors. Specifically, we want to avoid cases where loads can be reordered: 1. Load #1 is dispatched to read descriptor flags. 2. Load #2 is dispatched to read some other field from the descriptor. 3. Load #2 completes, accessing memory/cache at a point in time when the DD flag is zero. 4. NIC DMA overwrites the descriptor, now the DD flag is one. 5. Any fields loaded before step 4 are now inconsistent with the actual descriptor state. Add read memory barrier between steps 1 and 2, so that load #2 is not executed until load #1 has completed. Fixes: 8077c727561a ("idpf: add controlq init and reset checks") Reviewed-by: Przemek Kitszel Reviewed-by: Sridhar Samudrala Suggested-by: Lance Richardson Signed-off-by: Emil Tantilov Tested-by: Krishneil Singh Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/idpf/idpf_controlq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/intel/idpf/idpf_controlq.c b/drivers/net/ethernet/intel/idpf/idpf_controlq.c index 4849590a5591f..b28991dd18703 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_controlq.c +++ b/drivers/net/ethernet/intel/idpf/idpf_controlq.c @@ -376,6 +376,9 @@ int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count, if (!(le16_to_cpu(desc->flags) & IDPF_CTLQ_FLAG_DD)) break; + /* Ensure no other fields are read until DD flag is checked */ + dma_rmb(); + /* strip off FW internal code */ desc_err = le16_to_cpu(desc->ret_val) & 0xff; @@ -563,6 +566,9 @@ int idpf_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, if (!(flags & IDPF_CTLQ_FLAG_DD)) break; + /* Ensure no other fields are read until DD flag is checked */ + dma_rmb(); + q_msg[i].vmvf_type = (flags & (IDPF_CTLQ_FLAG_FTYPE_VM | IDPF_CTLQ_FLAG_FTYPE_PF)) >> -- 2.39.5