From patchwork Wed Oct 16 13:37:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Martin X-Patchwork-Id: 1998088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XTBpw0V59z1xvV for ; Thu, 17 Oct 2024 00:37:28 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1t14DI-0005Q2-GP; Wed, 16 Oct 2024 13:37:20 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1t14DC-0005HF-4s for kernel-team@lists.ubuntu.com; Wed, 16 Oct 2024 13:37:14 +0000 Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8358E3F6B0 for ; Wed, 16 Oct 2024 13:37:13 +0000 (UTC) Received: by mail-io1-f70.google.com with SMTP id ca18e2360f4ac-83542e22fd7so539280439f.0 for ; Wed, 16 Oct 2024 06:37:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729085832; x=1729690632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AlvG1ajzW+lnn+QBwQxXck5ifHYrq5/KijsgVhBOjb8=; b=IWI9n67C4U3yGl+fLRjOH+JaHpxwCLBF7EzehaaPbD1WVKJg5BaRElrQoskSBZCfnS SK16/+qnBTqhT7Ay3VHHmL61hu1p9oHZhF6tyQ1td91Sd5oW2rKYbNoo5pv6zXlYML9C X1nohh8nv+2FkAIPypBA+SQQu11i/av4lTfkdOLy0ReTBlCDXDjo2oiT6EYhH1AcaJVM +reS2sM2Kpj4ElMs16bnWTmI9nfjCopTOvdsohKkqAkRF/nYmJhjKqzChGTF0NM4vhvC ZUg8ucTg5oqHD0+3UoSBOK4WTlQl9kBZGXrmOfPHimaxwGA2RDxmG3R67mFq9aaHeAih g4PQ== X-Gm-Message-State: AOJu0YyR8VlMS8807telZWpHdftGSHVyJAHND3O23Waj0f3qL8asno8z rzJDjsCuTik8AiSpSnRp9HIpqxranCCvzxpWyvGJWCc6v125KBDonXs/lj0qL9r3YHYcslfzRoG ryZ8HYF+6KjaOqL+9j1zpqwhHRzKpioChcpHkZSeG9KtW7BfSzseU5439ckia6YT1FZYF30i2cm n+4Ng4cg5Aiw== X-Received: by 2002:a05:6602:2d93:b0:83a:ac93:f94d with SMTP id ca18e2360f4ac-83aac93f9c9mr40883039f.3.1729085831850; Wed, 16 Oct 2024 06:37:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1uKOoTQt5dR/umxHdeOdZ/6cw9N7hhcGKyujUankHEfBqn5YB6R6PgtZnYSsN+V17QcRFDw== X-Received: by 2002:a05:6602:2d93:b0:83a:ac93:f94d with SMTP id ca18e2360f4ac-83aac93f9c9mr40879239f.3.1729085831444; Wed, 16 Oct 2024 06:37:11 -0700 (PDT) Received: from localhost ([2601:441:8201:e8ff:574d:d195:6f49:7c30]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbec9632a3sm804364173.7.2024.10.16.06.37.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 06:37:11 -0700 (PDT) From: Jacob Martin To: kernel-team@lists.ubuntu.com Subject: [SRU][N:nvidia][PATCH 4/8] net: mana: Fix RX buf alloc_size alignment and atomic op panic Date: Wed, 16 Oct 2024 08:37:02 -0500 Message-ID: <20241016133706.173515-5-jacob.martin@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241016133706.173515-1-jacob.martin@canonical.com> References: <20241016133706.173515-1-jacob.martin@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: https://bugs.launchpad.net/bugs/2084598 The MANA driver's RX buffer alloc_size is passed into napi_build_skb() to create SKB. skb_shinfo(skb) is located at the end of skb, and its alignment is affected by the alloc_size passed into napi_build_skb(). The size needs to be aligned properly for better performance and atomic operations. Otherwise, on ARM64 CPU, for certain MTU settings like 4000, atomic operations may panic on the skb_shinfo(skb)->dataref due to alignment fault. To fix this bug, add proper alignment to the alloc_size calculation. Sample panic info: [ 253.298819] Unable to handle kernel paging request at virtual address ffff000129ba5cce [ 253.300900] Mem abort info: [ 253.301760] ESR = 0x0000000096000021 [ 253.302825] EC = 0x25: DABT (current EL), IL = 32 bits [ 253.304268] SET = 0, FnV = 0 [ 253.305172] EA = 0, S1PTW = 0 [ 253.306103] FSC = 0x21: alignment fault Call trace: __skb_clone+0xfc/0x198 skb_clone+0x78/0xe0 raw6_local_deliver+0xfc/0x228 ip6_protocol_deliver_rcu+0x80/0x500 ip6_input_finish+0x48/0x80 ip6_input+0x48/0xc0 ip6_sublist_rcv_finish+0x50/0x78 ip6_sublist_rcv+0x1cc/0x2b8 ipv6_list_rcv+0x100/0x150 __netif_receive_skb_list_core+0x180/0x220 netif_receive_skb_list_internal+0x198/0x2a8 __napi_poll+0x138/0x250 net_rx_action+0x148/0x330 handle_softirqs+0x12c/0x3a0 Cc: stable@vger.kernel.org Fixes: 80f6215b450e ("net: mana: Add support for jumbo frame") Signed-off-by: Haiyang Zhang Reviewed-by: Long Li Signed-off-by: David S. Miller (cherry-picked from commit 32316f676b4ee87c0404d333d248ccf777f739bc) Signed-off-by: Vinicius Peixoto Acked-by: Thibault Ferrante Acked-by: John Cabaj Signed-off-by: John Cabaj (cherry picked from commit c682b8d0e81462d108d424d0f22097794589f691 noble:linux-azure/master-next) Signed-off-by: Jacob Martin --- drivers/net/ethernet/microsoft/mana/mana_en.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 7ae5abf54016..fd857fd4bc80 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -599,7 +599,11 @@ static void mana_get_rxbuf_cfg(int mtu, u32 *datasize, u32 *alloc_size, else *headroom = XDP_PACKET_HEADROOM; - *alloc_size = mtu + MANA_RXBUF_PAD + *headroom; + *alloc_size = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + *headroom); + + /* Using page pool in this case, so alloc_size is PAGE_SIZE */ + if (*alloc_size < PAGE_SIZE) + *alloc_size = PAGE_SIZE; *datasize = mtu + ETH_HLEN; }