From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AE96C433F5 for ; Thu, 21 Apr 2022 20:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392553AbiDUUuO (ORCPT ); Thu, 21 Apr 2022 16:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392548AbiDUUuK (ORCPT ); Thu, 21 Apr 2022 16:50:10 -0400 Received: from mx-out.tlen.pl (mx-out.tlen.pl [193.222.135.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60C2E4DF75 for ; Thu, 21 Apr 2022 13:47:17 -0700 (PDT) Received: (wp-smtpd smtp.tlen.pl 20653 invoked from network); 21 Apr 2022 22:47:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1650574032; bh=uOC1fW/0uuSbuGCETmD2nbnOBndFlT09OLOf26HRiaM=; h=To:From:Subject:Cc; b=Iv/G25/v63Q81fWXkDU2p/sFBgBPmyoblHSgbQHfXvSNNJOWtatD8hgKUR8jpPtkG 2uahVMDf9nKYTsIbKpW44RjV6zssoUTwqw+7Odi9cEkM7ThKOeiPz9mVWfWYXM5+eI 1CdkDmzCzEwonlRqL/N+ET80S6MoCisc0dRKLLE0= Received: from aafl13.neoplus.adsl.tpnet.pl (HELO [192.168.1.22]) (mat.jonczyk@o2.pl@[83.4.141.13]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 21 Apr 2022 22:47:12 +0200 Message-ID: Date: Thu, 21 Apr 2022 22:47:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-GB To: netdev@vger.kernel.org, "linux-kernel@vger.kernel.org" From: =?UTF-8?Q?Mateusz_Jo=c5=84czyk?= Subject: "mm: uninline copy_overflow()" breaks i386 build in Mellanox MLX4 Cc: David Laight , Andrew Morton , Christophe Leroy , Anshuman Khandual , linux-rdma@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-WP-MailID: 15cac2a73e996b392246ccbfd184ccf8 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000000 [8RPE] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, commit ad7489d5262d ("mm: uninline copy_overflow()") breaks for me a build for i386 in the Mellanox MLX4 driver:         In file included from ./arch/x86/include/asm/preempt.h:7,                          from ./include/linux/preempt.h:78,                          from ./include/linux/percpu.h:6,                          from ./include/linux/context_tracking_state.h:5,                          from ./include/linux/hardirq.h:5,                          from drivers/net/ethernet/mellanox/mlx4/cq.c:37:         In function ‘check_copy_size’,             inlined from ‘copy_to_user’ at ./include/linux/uaccess.h:159:6,             inlined from ‘mlx4_init_user_cqes’ at drivers/net/ethernet/mellanox/mlx4/cq.c:317:9,             inlined from ‘mlx4_cq_alloc’ at drivers/net/ethernet/mellanox/mlx4/cq.c:394:10:         ./include/linux/thread_info.h:228:4: error: call to ‘__bad_copy_from’ declared with attribute error: copy source size is too small           228 |    __bad_copy_from();               |    ^~~~~~~~~~~~~~~~~         make[5]: *** [scripts/Makefile.build:288: drivers/net/ethernet/mellanox/mlx4/cq.o] Błąd 1         make[4]: *** [scripts/Makefile.build:550: drivers/net/ethernet/mellanox/mlx4] Błąd 2         make[3]: *** [scripts/Makefile.build:550: drivers/net/ethernet/mellanox] Błąd 2         make[2]: *** [scripts/Makefile.build:550: drivers/net/ethernet] Błąd 2         make[1]: *** [scripts/Makefile.build:550: drivers/net] Błąd 2 Reverting this commit fixes the build. Disabling Mellanox Ethernet drivers in Kconfig (tested only with also disabling of all Infiniband support) also fixes the build. It appears that uninlining of copy_overflow() causes GCC to analyze the code deeper. The code in mlx4_init_user_cqes, for reference:         static int mlx4_init_user_cqes(void *buf, int entries, int cqe_size)         {                 int entries_per_copy = PAGE_SIZE / cqe_size;                 void *init_ents;                 int err = 0;                 int i;                 init_ents = kmalloc(PAGE_SIZE, GFP_KERNEL);                 // ...                 if (entries_per_copy < entries) {                         // ...                 } else {                         // BUG here                         err = copy_to_user((void __user *)buf, init_ents,                                         array_size(entries, cqe_size)) ?                                 -EFAULT : 0;                 }                 // ...         } My setup: Ubuntu 20.04, gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) I was using lightly modified Kconfig from Debian i386 Linux packages. Greetings, Mateusz Jończyk