Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp860881pxb; Tue, 1 Feb 2022 11:58:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcLo89Vf/vPhUPhW7229oFD4An1lIBcB/ZFtakCBTphkZm3lfYEGawIu+q1rJKYB4OZ3MV X-Received: by 2002:a17:906:c14d:: with SMTP id dp13mr23684609ejc.188.1643745504783; Tue, 01 Feb 2022 11:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745504; cv=none; d=google.com; s=arc-20160816; b=pAAaN2QORIAMZRWRDgsIprjH0WU81CAeM3nVT1svpC3J2C9dEojEDi9A9LU+OuyHo3 XTf5+cEo3osZmVH1p2wKP2PehO2tyKSwoMnRx+dhN98J3JzF1JpFCWwuAFd4rrGlYI8F NKg5PjyqbKbLc4d4HLNwhViUjfkfvJGnA7o4XngycvpSA9iFYy0GECNeAykAo/o4Fe2U V+sStsKl3Q0ZJOzhD5fqIMTJyRoq15HlCDZ14ZwDghQx5SeQBqASWwVEzHQZVAvUHOpj xOis6VfYM1WXQJ9qLuhSOREw4xEr08oQxjCHwnddTRMojAG5++MT2P+kxVH8hczVBxEu CP1g== 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=GfHfMpXUoD4hAUxOrRdkLi1nFXjlImotOE9H8UUWUTE=; b=eEV/G54FHzqPTiQdYn+KRD0k8Dy7+UPToc/9wv34hpa54mOLar6loxklRptzH5HBTM FbpayCwTSfy5achH63v7As+3ZbK1Yc2dFu0bQbSiwTSauAV+6ousnFjEHbkPZ155BoNB goqsMCuttonu0S1cqGDYHzn5H2+8cQzaMOmuHslXdDN6/gSQMWiZKPqZSL2rt+Q5lGLl q7XI+gGaLaY9KUo7CXaDWkCJPaqfQsDR2a6/uuFK8trWJVgyv9POD6swcOvjiIlsQDen V8szlIMv7LC4dnbp2GwnljPxChZImU5LYcqZFgLxEUTcf+BBrJrAAKq2ctEEJy744esg oSPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BwaQEfch; 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=pass (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 i10si10690794ejd.885.2022.02.01.11.57.58; Tue, 01 Feb 2022 11:58:24 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BwaQEfch; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359054AbiAaLFm (ORCPT + 99 others); Mon, 31 Jan 2022 06:05:42 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:51356 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358534AbiAaLDY (ORCPT ); Mon, 31 Jan 2022 06:03:24 -0500 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 98124B82A59; Mon, 31 Jan 2022 11:03:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD647C340F3; Mon, 31 Jan 2022 11:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627002; bh=/XUiWIQai6L56J/l4Q8HMbWzlCJaHrOsjheH+Cti7XA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BwaQEfchULiD8cE3RT9mvBsmPTFn8Ot9E3KotTBQTlj2P0/AXGbd1Om/BRKxxfufm UCeF9DP748q80rpbi6fDcTatu2jMt3j9sLQFInmaHxxXs7tYQxAJafzJNgWaZuJuuP b8kpn+8U99jqXSOPL7lMMYpMHfXsoqyTWZ2VXRek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sylwester Dziedziuch , Mateusz Palczewski , Maciej Fijalkowski , Kiran Bhandare , Tony Nguyen Subject: [PATCH 5.10 044/100] i40e: Fix queues reservation for XDP Date: Mon, 31 Jan 2022 11:56:05 +0100 Message-Id: <20220131105221.914432799@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105220.424085452@linuxfoundation.org> References: <20220131105220.424085452@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: Sylwester Dziedziuch commit 92947844b8beee988c0ce17082b705c2f75f0742 upstream. When XDP was configured on a system with large number of CPUs and X722 NIC there was a call trace with NULL pointer dereference. i40e 0000:87:00.0: failed to get tracking for 256 queues for VSI 0 err -12 i40e 0000:87:00.0: setup of MAIN VSI failed BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:i40e_xdp+0xea/0x1b0 [i40e] Call Trace: ? i40e_reconfig_rss_queues+0x130/0x130 [i40e] dev_xdp_install+0x61/0xe0 dev_xdp_attach+0x18a/0x4c0 dev_change_xdp_fd+0x1e6/0x220 do_setlink+0x616/0x1030 ? ahci_port_stop+0x80/0x80 ? ata_qc_issue+0x107/0x1e0 ? lock_timer_base+0x61/0x80 ? __mod_timer+0x202/0x380 rtnl_setlink+0xe5/0x170 ? bpf_lsm_binder_transaction+0x10/0x10 ? security_capable+0x36/0x50 rtnetlink_rcv_msg+0x121/0x350 ? rtnl_calcit.isra.0+0x100/0x100 netlink_rcv_skb+0x50/0xf0 netlink_unicast+0x1d3/0x2a0 netlink_sendmsg+0x22a/0x440 sock_sendmsg+0x5e/0x60 __sys_sendto+0xf0/0x160 ? __sys_getsockname+0x7e/0xc0 ? _copy_from_user+0x3c/0x80 ? __sys_setsockopt+0xc8/0x1a0 __x64_sys_sendto+0x20/0x30 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f83fa7a39e0 This was caused by PF queue pile fragmentation due to flow director VSI queue being placed right after main VSI. Because of this main VSI was not able to resize its queue allocation for XDP resulting in no queues allocated for main VSI when XDP was turned on. Fix this by always allocating last queue in PF queue pile for a flow director VSI. Fixes: 41c445ff0f48 ("i40e: main driver core") Fixes: 74608d17fe29 ("i40e: add support for XDP_TX action") Signed-off-by: Sylwester Dziedziuch Signed-off-by: Mateusz Palczewski Reviewed-by: Maciej Fijalkowski Tested-by: Kiran Bhandare Signed-off-by: Tony Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/i40e/i40e_main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -209,6 +209,20 @@ static int i40e_get_lump(struct i40e_pf return -EINVAL; } + /* Allocate last queue in the pile for FDIR VSI queue + * so it doesn't fragment the qp_pile + */ + if (pile == pf->qp_pile && pf->vsi[id]->type == I40E_VSI_FDIR) { + if (pile->list[pile->num_entries - 1] & I40E_PILE_VALID_BIT) { + dev_err(&pf->pdev->dev, + "Cannot allocate queue %d for I40E_VSI_FDIR\n", + pile->num_entries - 1); + return -ENOMEM; + } + pile->list[pile->num_entries - 1] = id | I40E_PILE_VALID_BIT; + return pile->num_entries - 1; + } + i = 0; while (i < pile->num_entries) { /* skip already allocated entries */