Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp458981pxb; Tue, 12 Apr 2022 05:57:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRfRGwWgjL1LZFhmkIw51IMuvsWnePJhjPglCeD8kt/uJifauqukv6RJLG0JRINrcMwHpt X-Received: by 2002:a17:90b:3889:b0:1c6:408b:6b0f with SMTP id mu9-20020a17090b388900b001c6408b6b0fmr4823690pjb.43.1649768264550; Tue, 12 Apr 2022 05:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649768264; cv=none; d=google.com; s=arc-20160816; b=i5p5KR+JX9Y0viIno/RFG5NUBokc6WGkcfx0zplt+y6wnrdd6NnyN/107UKtDQfbcM 3tYDuE6OlA6wPkhrC+wmtetl4yMf6bJ/TIkfGxsPlzwt+sAKw1w+XaBp9RtkZG7I+Tw3 v4PJb7Z7Q4LbsJFKp0sKlfU3DNpRv60OMHuLLtmyRdPMPY0HspbFbMlS2TfJ0F7QGGTa IC7haAUOxFPAPz0tmuwrVwX7NA9PrCn+zN8fLKWvnGNaLFtCxVldsMEWyx/Sb0KaZe8G NrPfFv6t3l/5F2bOTczsn7c+yAoPzv9Ck4wC6sneRjh6CFQnTqaUx/X+fw5g0Pu/cIBH EOYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=hYNVq0t1WrkTI/K6D/l/f7tQTRIta/302c+AVM0dqpk=; b=GBk4/cGS3wpM40nFKwyFT2kuOn57VR4to0DLQBiubjn9nZajKMxkkOtAwlR8s8S3/x OHj+hE5/cbS4bWO8gWAdy8MO6B6mJKSLGtMuRBeT7xlxEZKx80drN31dMgKKjiRcUyoK 0V/i/FFIrJCcq1OZiWzn5lU6Xr+IVLCXg4IN8JBfhWZ3FfAaZNQx1iSKgBS49LP3VCip LRkj3MyeoxMraMk0ZhL/Y5KqU5xVRH8bkNU2OqRotWc/YBv9R2rdLm9InF+GAIkC3rNL TSY4ByViVvQkm8NNMTuPfFvg7OJ04TbobckKCxSrP/ME0xiJaA3S1cChCxAMUZFFxy2z WZ8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ZYe/bbLU"; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a63d511000000b003821d42cbe2si1783922pgg.588.2022.04.12.05.57.21; Tue, 12 Apr 2022 05:57:44 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b="ZYe/bbLU"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350176AbiDKVYS (ORCPT + 99 others); Mon, 11 Apr 2022 17:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350114AbiDKVYH (ORCPT ); Mon, 11 Apr 2022 17:24:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3E85D2FE61 for ; Mon, 11 Apr 2022 14:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649712111; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=hYNVq0t1WrkTI/K6D/l/f7tQTRIta/302c+AVM0dqpk=; b=ZYe/bbLU88HwXDOCYm4mM+BkBNYSN6PSHWLQGjB4Mgv5zTq1TMT9nBduLGXE3E/WhwJSTE V5byJjfE+rzXm3a25L7z/F74XOJMwfrDb63V9tmlDjXm+BeLzwZgsB1Ef/ERCWYdzAJfK+ n5V7vzPETcAiP0WLRQcvITA/F3FAd80= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-137-PCLCKfmRMeisw7VBMB77DA-1; Mon, 11 Apr 2022 17:21:48 -0400 X-MC-Unique: PCLCKfmRMeisw7VBMB77DA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 824D4185A7BA; Mon, 11 Apr 2022 21:21:47 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6192E40CF914; Mon, 11 Apr 2022 21:21:46 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 23BLLg5f2961636 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 11 Apr 2022 23:21:42 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 23BLLe6o2961635; Mon, 11 Apr 2022 23:21:40 +0200 Date: Mon, 11 Apr 2022 23:21:40 +0200 From: Jakub Jelinek To: Sergei Trofimovich Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Joe Perches , linux-kbuild@vger.kernel.org, Segher Boessenkool , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski Subject: Re: gcc inserts __builtin_popcount, causes 'modpost: "__popcountdi2" ... amdgpu.ko] undefined' Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Mon, Apr 11, 2022 at 10:08:15PM +0100, Sergei Trofimovich wrote: > Current linux-5.17.1 on fresh gcc-12 fails to build with errors like: > > ERROR: modpost: "__popcountdi2" [drivers/net/ethernet/broadcom/bnx2x/bnx2x.ko] undefined! > ERROR: modpost: "__popcountdi2" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! > > It is occasionally seen by others on previous gcc versions as well: > > https://lkml.org/lkml/2021/7/11/261 > https://lkml.org/lkml/2018/10/24/403 > > '__popcountdi2' are inserted by gcc for code like the following > from 'drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c': > > static inline enum mod_hdcp_status validate_bksv(struct mod_hdcp *hdcp) > { > uint64_t n = 0; > uint8_t count = 0; > u8 bksv[sizeof(n)] = { }; > > memcpy(bksv, hdcp->auth.msg.hdcp1.bksv, sizeof(hdcp->auth.msg.hdcp1.bksv)); > n = *(uint64_t *)bksv; > > /* Here gcc inserts 'count = __builtin_popcount(n);' */ > while (n) { > count++; > n &= (n - 1); > } > > return (count == 20) ? MOD_HDCP_STATUS_SUCCESS : > MOD_HDCP_STATUS_HDCP1_INVALID_BKSV; > } > > Note that gcc can insert it regardless of -mno-* options. Just FYI, this has been added in GCC 9 for https://gcc.gnu.org/PR82479 If the kernel implements its own __popcount?i2, it can perhaps with runtime patching use hw instructions when those are available and fallback to the generic version. Jakub