Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5776525pxb; Mon, 14 Feb 2022 07:22:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzB+eWp42rA9m/7VVqAmgrJ+kjseHw99fJ1AP5ePExGsUOUgit6z8gJUq/47RWAxaer9UAI X-Received: by 2002:a17:90b:38c7:: with SMTP id nn7mr207631pjb.124.1644852173164; Mon, 14 Feb 2022 07:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644852173; cv=none; d=google.com; s=arc-20160816; b=YbqbKPJMbtu9cTuEJmLgcqxKHvpIKCeS46OQmzx8O9RezboSEORaOA3AT+rOIHyosF gkCj9CU1/c0qSqJhzSljyw+HDkP0M4N64rd3QH3cyq1MW3ImpSJ6a+R80UKxEFxGQ4nq 3qxvm7neeE5aSkwMqgoUhZqt245k9LOBKp+Njixlsm/m/LdIZ28G8Rc444ambSAiwzaG /9QKdR4Hm7/+8lT4inxC6A8LnJ1tqEWYfaVt2R1hyXtxKEhwt4vRRAPuWkFTqW3xUKMX 4lRPer8ibH7IDCzsEghKUlqL41mwzwYDF4aN9w1a9TgNZk+KADreyd5qbXdJbrdtidKD ZHpw== 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:dkim-signature; bh=TPaEmBmi7m1S4uLDzDFBzXfoCH7ErnEoSBtaavlX664=; b=uX6fxqRnTEUZGq7F0G7mLPnmdoeSJZOz8hKSse2UY82eUxRXZL7m51od2OBGpJzj6r DD7m15nCGgIUirMrEAezry7Q7CpdEVGWPRN+20DkU2BhsZT9Qarusj2ixl/owxPApQkC jNgyDoB1H0P8m4Ai+48xoO8UX8GVnFNKOv1lO8VrkveFMiaoEAFSQy2GTYH22hnOTtEn ypflBqn3wum8W396Hbf6wIRg8t2Y+GA5YR0uw8EROEp+hx1Km4gf+PU/oqlM0/72OI27 WuIvYyBtnUSuJ6H3R+9dfNQ1fQp1N4iH8ulB5/48/75CbBAQu2ZVw/wfnvAAdnjQ9YDR r2tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x3oZ0njq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k193si2595014pfd.334.2022.02.14.07.22.36; Mon, 14 Feb 2022 07:22:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x3oZ0njq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245644AbiBNJxs (ORCPT + 99 others); Mon, 14 Feb 2022 04:53:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245733AbiBNJun (ORCPT ); Mon, 14 Feb 2022 04:50:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84CFA654AB; Mon, 14 Feb 2022 01:41:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 429CBB80DC4; Mon, 14 Feb 2022 09:41:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 515C5C340F5; Mon, 14 Feb 2022 09:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831694; bh=CaxhALpc6Zc6fQlasirVdZIPuHf7qdsIgFDj1qvhJsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x3oZ0njqDaxt5ZBiCUi1rCem98tBHCvq4UPN68T89GqKPpwpvZVrx3Gtf1e1ubqPP +OH2Xkf6tFKF8JkjGaRI7Q/Y82BtMF7zikZCD5Q5cMavd+0FmuVwL/oXgnRHYbsL6a CotNt5n4f8qQpvXtk2Y9b4DW5+g3ZBf02hDZuPQg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Samuel Mendoza-Jonas , Konrad Jankowski , Tony Nguyen , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 064/116] ixgbevf: Require large buffers for build_skb on 82599VF Date: Mon, 14 Feb 2022 10:26:03 +0100 Message-Id: <20220214092500.961810621@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Samuel Mendoza-Jonas [ Upstream commit fe68195daf34d5dddacd3f93dd3eafc4beca3a0e ] >From 4.17 onwards the ixgbevf driver uses build_skb() to build an skb around new data in the page buffer shared with the ixgbe PF. This uses either a 2K or 3K buffer, and offsets the DMA mapping by NET_SKB_PAD + NET_IP_ALIGN. When using a smaller buffer RXDCTL is set to ensure the PF does not write a full 2K bytes into the buffer, which is actually 2K minus the offset. However on the 82599 virtual function, the RXDCTL mechanism is not available. The driver attempts to work around this by using the SET_LPE mailbox method to lower the maximm frame size, but the ixgbe PF driver ignores this in order to keep the PF and all VFs in sync[0]. This means the PF will write up to the full 2K set in SRRCTL, causing it to write NET_SKB_PAD + NET_IP_ALIGN bytes past the end of the buffer. With 4K pages split into two buffers, this means it either writes NET_SKB_PAD + NET_IP_ALIGN bytes past the first buffer (and into the second), or NET_SKB_PAD + NET_IP_ALIGN bytes past the end of the DMA mapping. Avoid this by only enabling build_skb when using "large" buffers (3K). These are placed in each half of an order-1 page, preventing the PF from writing past the end of the mapping. [0]: Technically it only ever raises the max frame size, see ixgbe_set_vf_lpe() in ixgbe_sriov.c Fixes: f15c5ba5b6cd ("ixgbevf: add support for using order 1 pages to receive large frames") Signed-off-by: Samuel Mendoza-Jonas Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index a7d0a459969a2..2d6ac61d7a3e6 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -1992,14 +1992,15 @@ static void ixgbevf_set_rx_buffer_len(struct ixgbevf_adapter *adapter, if (adapter->flags & IXGBEVF_FLAGS_LEGACY_RX) return; - set_ring_build_skb_enabled(rx_ring); + if (PAGE_SIZE < 8192) + if (max_frame > IXGBEVF_MAX_FRAME_BUILD_SKB) + set_ring_uses_large_buffer(rx_ring); - if (PAGE_SIZE < 8192) { - if (max_frame <= IXGBEVF_MAX_FRAME_BUILD_SKB) - return; + /* 82599 can't rely on RXDCTL.RLPML to restrict the size of the frame */ + if (adapter->hw.mac.type == ixgbe_mac_82599_vf && !ring_uses_large_buffer(rx_ring)) + return; - set_ring_uses_large_buffer(rx_ring); - } + set_ring_build_skb_enabled(rx_ring); } /** -- 2.34.1