From patchwork Mon Dec 5 16:31:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064749 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 7CEE2C47089 for ; Mon, 5 Dec 2022 16:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbiLEQcl (ORCPT ); Mon, 5 Dec 2022 11:32:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231961AbiLEQc3 (ORCPT ); Mon, 5 Dec 2022 11:32:29 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9271E1E722; Mon, 5 Dec 2022 08:32:28 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fm0PQ031674; Mon, 5 Dec 2022 16:32:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=a3si6jS6Ox0g5dRLuVXNTk53yxWpnj6BsrmMRA3/7pU=; b=dh7PVIxo06drniWCNfFP8JuBsuCECF2ojveSRAkXDXvJFOlk2r1PDtQu+msrQRItX6BA 5tOJVGuDf9eV0hY/1EJluqUofHsaL5CiOtfRAPZLa4o7IzM0sit1nsUMJ8IKPzGyLZH3 xEUIM8OiWNl/IKtB/8mvIgbWj8mMobgJx/PQaqFRcB6mPTpluk+Wm3IJbG/RQO2Gl3YI yYAjtay5t9ZCcJ7vfSJajoS6RZQ43UZh8GdY+BPYBKpmPf58GTcuFTg+spzyLREbKU56 InbYeWXVomh2mRqnKxxiVc+ADi+zM4aS97kmShTm/58bDATuz3Z6C7Nww9A3tN+AwnmM 2w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7yeqm9uq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:22 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQvi8005358; Mon, 5 Dec 2022 16:32:21 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ucswacx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PpZthtiOr3cxEnnkwP1itT6eLqc7lMlHgY4X3lbesf0D1VH+ZctupwlRWU529LtFEoVetMjkubpv2heLpmwaHjnbW/IjsIIvwyn1MwLekMq5SR56ZeIq6Y4A2ZZlbCFFh5AVxcnx+X/iQjf2DOTjzEeZeM2vQvRkvMs5UURzfZYU0anXCgSNVxeIe2LoUTQvgOJeVGa6chNQ9zbfROT6NvpwYYURrKFzcztBijNwav5kgjaZPsmLCkfbwt1JF3SobHM3NF0BcJAm/3/kp4klZdS7KHD7bhkXKfF7CGApOHNRyKf6celSDass9Ih/E9rzAnt735xuThX90D/QfxaSgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a3si6jS6Ox0g5dRLuVXNTk53yxWpnj6BsrmMRA3/7pU=; b=eFyeFsAnZigMK+BfWcUmuo99Lqf9w5P+7+m0R9OdlFCpBp562HYEwNBQOO4LwX5M6Lr0gHlEHtDlwpwllB7jlEOloBLcwpzCfia6+CzE40IOz8ARuenKTnptZuUtsLWYGHRpza7UO654rKh91Z1fzMO0WKf67Sz53n86u3CSfoWXacm5/Uujg4P/U1eO5YANOMIjDRQ8P72sPC6jgGXMVazhXFbKZ3JJv3OOTkmZ5OFCEioVcWU9i4F3xXujQ199PU9uO1sNe8bD8lRhDPoWxpO8W7I33enTRXG4FqZIwCigBPxuPvjCa6R/gvYRve5V7H1g1sCQlNi+6I+i7Snf8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a3si6jS6Ox0g5dRLuVXNTk53yxWpnj6BsrmMRA3/7pU=; b=tLqHBQ9tdy5gJBtlvYH3NWHgbLVbLSXeRhnoENNeh9wXHStI101CN97tYqWcG8m1NwcwC9N2KMR6DIAdhxiW2r/nNbExhmuz2dlh1FQbLEwmHiGVYACxMFfAFBfW3faTiA+MlQ1EVM/O8ZTX/gJ4pAl+ZHO3IXiWiZPLbYZAlpM= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:19 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:19 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 01/13] kbuild: add modules.builtin.objs Date: Mon, 5 Dec 2022 16:31:45 +0000 Message-Id: <20221205163157.269335-2-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P123CA0183.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::8) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: e7f64cec-8c76-443a-665c-08dad6de4706 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SQklG6dc1LFQLuPFxTKL2mDOHYL63ytM9eLop/m+qav2Zk6RdkcH8cILJvK+lt6hm73MVy+nFgqDWPr8ggItTIRZdOCn+fYCu2eLPQcnfXDZEKcVyE6o0c+uq0h/zYOTQrlS7TXBdC0ya0+X12IX+0vay7Cqj7f0NDHZgU5y9hhFqVjdZ8vPAXCPlK8/N2dRSlHFKIS3bQiUc0Z7GlBJdk7XODlqxpflWJtNHPeqMp3uKoVXwTOqebuEcgxK3NNJbkhrdJtfhEBNFqSQv0IZIoNjIR9Q6Ub9BiLn8SGOQMaDYHNgQeUcNVHyUesTBJIlmPuHwXpyw37KEcKZ0kREuKtSFNoqm6ILLN1Pg6r40+eYfruB3Pxm3BSIdaI66tkW+GYqI2Jec9UjJ1Cc6MEizeaY/G2A0/aAVrUe2dUV3kN8YKwSWnouEn9mM/zK6mpVc8VPjVagc+F7QztBgQcbfQesKH3vrGPch+p2IFdVZVRGxYmRKY4MG8b/tyT2FvTewYrU+BJj9L8Ec9jNkuWJPW2tvcwR1x9IEZvKiEScMxlTlghwQdAITf5wP+qT/Cc+G7UOrl5yXNywE+1UwX1OzUGF5VASBx6CydDW8Hj9Rq8KiTqRKkWvAJWBmQSegw2xYb+UCOUUqP3Gj4xf40jerA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FvsE9OBoLrgsKPHHSwyCRQo2gsGXc4EdVUQNBGjqh2wOeXRQdvQ3D+E0wskbPooIfyQ+jxo48dtNMEjZbVPfQLZuAA54EvvaDg7VqvdwY5A2lgu67UYnRu+ZBinmXC0rFOSVGYD85d4WqagguDg+k1Wc8ANRZUqKtdTIeKpo6/mOY2wNY7/byaIUz2cWqdTYCnKVwyau4k+1ESbM+a6PCoNsIsneDbPWhb9Y+339TE1ksJngJGxvSfSrUKZwzLc8oSggMd+ZYbQVgkHldCZHi7KFkoAV+5DgBLCCk3rlOXhcdnkjJ32JxnOwtAbblLHvdDeI/RlERPemPscorjuxF5sfAf0wkNDRSaS171njfujov1LD6Dqe/l8DNBu08xKcMfw7Zq1nyaLjmhBxqknan13WTjlWz/K3tP7JAtLsLcGVnSOTCG7Q0gMO3lWbZ0QGN6CtM9jpeRzJD884x3U9HBXhv0mUlUcltLH/qjwxSTx/uFuTXR7pEtd7SThNjyufW2CfmB+8TFAcZ3hUJ0OvSEZGFyuU+PB+9KFrJzmJmOb+hxk6sMuY+Lj5Yb9jX594XI3E9cDqCItlYVBSg/RXfHvA8rTAfF4CvscNf1ZKU5uK7BCRKE4nN8xoT6zZ2pDVgyCkI3hXNnYEOzbXYkwtKHCBnnPEJXrLM3eedIyuVCMdw0P113vNObYjRXxaXRN9XJ8z6X91Q/1E6WyAl2gFsYwcq4VG4V5SI1naS9J8IofEESvzVtlag81eNj4b1rtM+JDqj5chKL3DO3loNo7TMhG69E09FhN7WVtdxoESXJuHa0YAvp1W+NQi133iypEyMgkUIzV06shoZH2dCQJyYlWNVtKUwKdXq/qU229qMVJ2CZTTg+2f3fxbk7+O9cL6GJFYsTY0pM36YDgrut/l/D3hUyeTYySwsh8m3ROXCrsp44Dq3gy4/G10ars44Mspam6Ur82ucmbQdjCfi39HB8bgssxovrJQtI+abEf8cZEXov+GK9guv4vE8yx6+oWSAIzwUQu0WFV7bjdJZiXSzk2Mup67KlCTdSx0ugWzh1ukPh9PCtPWPBHy3SSjz0oaS0C51REVnfA9qKU67QsqnpAhRjTZQseTFe75b/H3ujvwwqi1QoEdlv9Fph8rxv6PcDVrtAfJqDiSBRqb9l1BWMw6UyWBR59gS5In3yH3lOONrO0eyNyENbMBb2xO+tIZPz0rItT8kCXVE4YlRvty5NOfmTdd9aT8oGzsOmceVc0PZG3l4lxh90UTWHCerJClixXHqbgvWrGoElMuhJ3Wq6X2eV1pzF+otEq42UpkL8YGDXR3A5TpyXNeXxjau7bnGVSPzkndFBzbqOozcDlPFwbvDkmRfO/lTJ/vQmXYm9+ZdQA2vQWLUD4pnENWEyahNcCLhvz7KU9qg/gpdLe1bPao7tgmF84oEKrzUmdKWuObYk/+qOHsdsj/NamOKNjb89xqdLo1M7CmRFEG/24Ravs254jB7U43Lh/NQJQ1ms7YlaPbidx4cxSo0738QMPnnpfWHKAyEoJYgKjTHl6Vm5cpJfaYwCzEyo3ukQY9s453y+9vDn2VRjx+x8h0EiQbzFb6bYKcafLttXOGvpNzVQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XhcQDf9uM72i37p68lir/b2Kql/eADA7mXn8DHGXdZXj5gxUg6gM/w0Ot652Jlav0JhO+DhrQ9puOKmGIcZVedqGeTPhBD49QlHRaxXB1lc7xwAcnZiylaPzNziIkpUdo5ycvRMDjIfE3uXeYcR6po3S9irRoHStrboezChN8bAAjXbRn7pU0lJ+6uP73xC/RgIWmHw6iVS+PRjIlrnLs5+TRf5C7RmcXcPn4lebk1mqJwcHfNN1RYYgIL68fmovESc1bi/IsPiXJEJy1Xvx+PrRyBNKGsWDY382xivnSRZax4ary0tc/uZ23qFgJF5aZWtt8ac4j3kXjnzg5X2LzEXSxYpWEOLzIKoGKCBuvMHAKWrKR3Kvw5QLWbmxa+EtN5GEmFsNPpt/cJ2neqs4U5HBdXqDBsUmj2h6w+1qzYide4RP1wYjJgJ9j1a4hEGS/05SQm9J5iE4xBtUEvxGgSHj3YR+pdK/i1ptXhorEgVc1ojT7dHW0+7zQZy5x+AwXo1tSgHpS8UqbQubQUx8GPIaJGaaz9XpedtizWUsl0qyioX9sOfkt5jUP6cRyEe1LAThEb46JKwF+mRT5+a8k8kyLcSC+tIH0O8jC5fX2ATLnpPvLB18EgIqYK1eArNI5yhsEFMCPQyIrdXnnBFKbi+RAfUqLBtJCUOLhuFwzuBS9vGoDmU+F3gJ2Tycrfhj3frhLcWqVZjcfJPqmsgPSEQZvUa2q57l7CwbhFKi/z8YGptxG17pjk7G2z9Lzb6drR9SofcllFC1JcYna6p4OOVe9F50ERtQhz390SOVT4nrbMp1h+ffT2mCAXOu9rTYtiI7c0b2MYV5UawoZfbdW/ruQcsDpOY+E/1rH4FCvl1pm8JtwesOBZ7j8wcXsCNIbsbUR6njOMViZX/CL+dMnd+zq/7dIK8YHpr+CriioW/8nVAxveFFPQ3Ytm0sCOh64KObjXM3d6oWlUYKsyBK1i90VqsBmBQr7yS3YbQXwdI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7f64cec-8c76-443a-665c-08dad6de4706 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:19.0750 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qiQQYQvPE1fUvNfGAWWxI/DF9KYoZGpdBfLTfMU9IOeM23Nlwx3Ckcdtig4/gSxdwtIECwPPwhW4TvJAba4B6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050137 X-Proofpoint-GUID: tbTjqoyPlUPrIvri85ZYRlrfji2mRHq_ X-Proofpoint-ORIG-GUID: tbTjqoyPlUPrIvri85ZYRlrfji2mRHq_ Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org From: Luis Chamberlain The file modules.builtin contains all modules that are built into the kernel and this is used by modprobe to not fail when trying to load something builtin. But for tools which want to see which object files come from what modules we want to help them with such a mapping as it is not easy to get this otherwise. We do this by just extending scripts/Makefile.lib with a new variable and define to capture all possible objects, and stuff this into a new modinfo. Note that this doesn't bloat the kernel at all because as you can see in include/asm-generic/vmlinux.lds.h, the .modinfo section is discarded at the link stage. Signed-off-by: Luis Chamberlain Reviewed-by: Nick Alcock --- Notes: v10: new. .gitignore | 2 +- Documentation/dontdiff | 2 +- Documentation/kbuild/kbuild.rst | 5 +++++ Makefile | 10 +++++++--- include/linux/module.h | 4 +++- scripts/Makefile.lib | 5 ++++- scripts/Makefile.vmlinux_o | 15 ++++++++++++++- 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5da004814678..ef8665c64f21 100644 --- a/.gitignore +++ b/.gitignore @@ -67,7 +67,7 @@ modules.order /System.map /Module.markers /modules.builtin -/modules.builtin.modinfo +/modules.builtin.* /modules.nsdeps # diff --git a/Documentation/dontdiff b/Documentation/dontdiff index 352ff53a2306..ed1fbc711f33 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -180,7 +180,7 @@ mkutf8data modpost modules-only.symvers modules.builtin -modules.builtin.modinfo +modules.builtin.* modules.nsdeps modules.order modversions.h* diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index 08f575e6236c..504f31517cb4 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -17,6 +17,11 @@ modules.builtin This file lists all modules that are built into the kernel. This is used by modprobe to not fail when trying to load something builtin. +modules.builtin.objs +----------------------- +This file contains object mapping of modules that are built into the kernel +to their corresponding object files used to build the module. + modules.builtin.modinfo ----------------------- This file contains modinfo from all modules that are built into the kernel. diff --git a/Makefile b/Makefile index ac2ec990422d..93bfaae45396 100644 --- a/Makefile +++ b/Makefile @@ -1228,7 +1228,11 @@ PHONY += vmlinux_o vmlinux_o: vmlinux.a $(KBUILD_VMLINUX_LIBS) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o -vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o +MODULES_BUILTIN := modules.builtin.modinfo +MODULES_BUILTIN += modules.builtin +MODULES_BUILTIN += modules.builtin.objs + +vmlinux.o $(MODULES_BUILTIN): vmlinux_o @: PHONY += vmlinux @@ -1558,7 +1562,7 @@ __modinst_pre: fi @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order @cp -f modules.builtin $(MODLIB)/ - @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ + @cp -f $(objtree)/modules.builtin.* $(MODLIB)/ endif # CONFIG_MODULES @@ -1571,7 +1575,7 @@ endif # CONFIG_MODULES # Directories & files removed with 'make clean' CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ - modules.builtin modules.builtin.modinfo modules.nsdeps \ + modules.builtin modules.builtin.* modules.nsdeps \ compile_commands.json .thinlto-cache rust/test rust/doc \ .vmlinux.objs .vmlinux.export.c diff --git a/include/linux/module.h b/include/linux/module.h index 676614d56c25..8c3bdadc93e6 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -179,7 +179,9 @@ extern void cleanup_module(void); #ifdef MODULE #define MODULE_FILE #else -#define MODULE_FILE MODULE_INFO(file, KBUILD_MODFILE); +#define MODULE_FILE \ + MODULE_INFO(file, KBUILD_MODFILE); \ + MODULE_INFO(objs, KBUILD_MODOBJS); #endif /* diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3aa384cec76b..f7e5a83572fa 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -112,6 +112,8 @@ modname-multi = $(sort $(foreach m,$(multi-obj-ym),\ __modname = $(or $(modname-multi),$(basetarget)) modname = $(subst $(space),:,$(__modname)) +modname-objs = $($(modname)-objs) $($(modname)-y) $($(modname)-Y) +modname-objs-prefixed = $(sort $(strip $(addprefix $(obj)/, $(modname-objs)))) modfile = $(addprefix $(obj)/,$(__modname)) # target with $(obj)/ and its suffix stripped @@ -125,7 +127,8 @@ name-fix = $(call stringify,$(call name-fix-token,$1)) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \ -D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname)) -modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) +modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) \ + -DKBUILD_MODOBJS=$(call stringify,$(modfile).o:$(subst $(space),|,$(modname-objs-prefixed))) _c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \ $(filter-out $(ccflags-remove-y), \ diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 0edfdb40364b..9b4ca83f0695 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only PHONY := __default -__default: vmlinux.o modules.builtin.modinfo modules.builtin +__default: vmlinux.o modules.builtin.modinfo modules.builtin modules.builtin.objs include include/config/auto.conf include $(srctree)/scripts/Kbuild.include @@ -86,6 +86,19 @@ targets += modules.builtin modules.builtin: modules.builtin.modinfo FORCE $(call if_changed,modules_builtin) +# module.builtin.objs +# --------------------------------------------------------------------------- +quiet_cmd_modules_builtin_objs = GEN $@ + cmd_modules_builtin_objs = \ + tr '\0' '\n' < $< | \ + sed -n 's/^[[:alnum:]:_]*\.objs=//p' | \ + tr ' ' '\n' | uniq | sed -e 's|:|: |' -e 's:|: :g' | \ + tr -s ' ' > $@ + +targets += modules.builtin.objs +modules.builtin.objs: modules.builtin.modinfo FORCE + $(call if_changed,modules_builtin_objs) + # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- From patchwork Mon Dec 5 16:31:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064750 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 28AC2C4321E for ; Mon, 5 Dec 2022 16:32:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232272AbiLEQco (ORCPT ); Mon, 5 Dec 2022 11:32:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232055AbiLEQcl (ORCPT ); Mon, 5 Dec 2022 11:32:41 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A06EE1BF; Mon, 5 Dec 2022 08:32:32 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fg6TR031678; Mon, 5 Dec 2022 16:32:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=+PWnuWlUsPw7MWHnPVaAWUa0k6uSZaqwhUEVP7LTtjM=; b=nWklaZz6W6p7kUxmiAgWdOhxPoPKH70+bWh7v9+VA5vH/s7ShkY6YjNWmjghLupPqCp0 n8nDwRtAFFKS63s+RYaBYj5CiMHUV720A49BFBHFntp/caMQvTRAdfCCyAt9WDCMUXI8 L2G0OiCPKE3EG4RywfyuuHao4JRV7lM4rO1LpU2kHednvW036Mr/Z+OLiFOmuZoVvhAU V/lmD8jHsQxQAluGWe+eYNqzV+l/26MLvYWKInL61M5XmvdtTbmH/75wP+3ggtrRXNfV Xlya+4mkA/eXveMH91R6G7WKK5CkxPQDxnAfEs7OP0R5eVEsd7zMKZQZUt8JMW5biIud /g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7yeqm9v2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQwhx018886; Mon, 5 Dec 2022 16:32:26 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3m8u9y57fe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLRGq7cOlqa2IBMnqD9Ia/WoEeE0SbKvv1+BpDxGdBBdMOeMpi+mGIAny1wAU5GfilTol9CYyHVNNYMtFMM7dnHTO4b9R2EHRVtykgZ34gIf4QOjveWHh0aoAEdi4nvEBg+NmTw1yI9iLnAFy3EVy+yt8aeCQ8wat7ADphOYM1w6YG+Y7w/+OvjYxui/BVQv9Mjgl46ibP6Q3bwwRAtyxeOWuw4MVbKt3KZbDLTf7c6Z8BcSwPZwVMbWvtXrBbHaW1zBZGlHUDnQW6n5gnCYqkjn+E/AZWaG6tin4tmFQ2lh4CRhIfe0aN3nKgr6sqMJiebHzDXJL/52MvMfnszfYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+PWnuWlUsPw7MWHnPVaAWUa0k6uSZaqwhUEVP7LTtjM=; b=AedL+9akhWRQbn3fAFImZZ+GbXjzYAdsbWP7Ez6eFHTpcmqOUeW6EKkjLxDLe3leQjDbtrezhzHR1nLlu0eoMTdJTD42qns3Ls0W1R51jdt6axYHIBk++ROv4zbT4y8FSfw5/U2t83262SwFfcis2XP1EqEC4kNPa7ng/pjjOyarxLZ6JP+vBRuOL3MGwDar6oRWEM29I/221XtB+Mum9ZFBshv6tLQq0wRj7Il8TLCM5CYh9gRjQGwz9nwxfcrk7bM3alP+Ug55L07Yt5dycZMXBWTc3maGJUGptm8QqskPuSc4AK1WExgppJrS8JDSXclSFyxGuO3oQ/xrYOIiUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+PWnuWlUsPw7MWHnPVaAWUa0k6uSZaqwhUEVP7LTtjM=; b=NN7ZEPVFcsZ6YgFHT8fNgDwsgBNC1/fCFgvU1NaiR+sIGE+vFqe6yquJxDOs6IeEU364p6Q92hLiMU58t7Z+vB1bQBSDr0ht9lSbJ5AXgQWJUxPdfYLJeLECJa0di/H1IwGaxrTUHn0ZS6LJ3tgKCALgOr3R1zosHvGUZ2cKosI= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:23 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:23 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com, Victor Erminpour Subject: [PATCH v10 02/13] kbuild: bring back tristate.conf Date: Mon, 5 Dec 2022 16:31:46 +0000 Message-Id: <20221205163157.269335-3-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO2P265CA0043.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:61::31) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: fb0e7901-2be8-45d6-cc1f-08dad6de49be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XQPdIko59298SyALpzTvo/kIhL0l5b0VbFN2nQA8leoM/qCxmkAFN7dbbmGLMtRUukvu7QiqL69QQ9jYJGbi/ysjpJlwihDCN2Fpu9IQ37Lz6aieQvOdsq4sH72DkhQgXzR8PkXu7+HNSTRIm4JD75jc0qJcjbC1ZnGgQ0u0+kpctHRH2BZtZ4RzY02NrlODzEc/jUJlZAPQt7swr12939OX3omGuKzQBqEdNY4+soehPZ4Cq73w4CXv377KbawPmpdeZx/byox+griZkbYh7LaGNkuOhlJA9lFU1U3niCQUkZBFM72IlGI8l0d4qhSUcmH3Dw3PepxlObTXrabSaL+ppWiHPkj3HvrRtYxR7aXhxuj1v8iQ9a3qLWygG5ECjmkod4LqSpktNTwgmf//iJ0ecgr5uQa3ui3+m2bEuMJG8aALOJf70aTxCrBIqFaACsVURizKucYK66dlrORJ1NsW8Yjfwm4xv/+j96XpNWTkOPsYdcs6alZDPgDwXCIIN4icvS/uamzLF01JAPRp2rAb+oAGWK81vGJDuzoWqkT1om/eRoZwlbapHmD7MBGmOM9tERr0e63qcc/EQp7937LW8qcU96T6Y9Bzy/kkHkpuAa9EHjyT4ggS96YVlyrAX8qCOoE4VL8GkTTRv6ey3w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JR+i6s30LK0a8QNy5qESuh6f0S5xbQHKIECi44EoFhQQSc7YjL+YhQkB0HOwWUEu4yUdCord6g0P+eyZ8vt9VfbDFHZ7R5crBlIlAWeczXObQ/K/PeWh1VyFmoa5fMNFwMt+m+m0d71fSKHGOktcIYQHKW6ELduHplWP12H+FF4z1okRTJN8WXQoMCINUzcKRnTSMvnVAo1tZdgrI/NoPeM2KNRCu2NWErTa5slPi3fiYjhDUK4CvkONAYdocIacD58XroBfM1qSFke52JZvm5vgl0Ji9DXFHoH6ZO+PvbEWIGVajkNFPVOZcaMSHPKSAqqsFqHDZoo7HwWF3FlAk0hzf+k3r1Q2k81yBibYDclgyy1wNlp2TWd/okgfU7YI0G8BziGbcEfaL7cZh/WGLTLRtEjrLz8G31vs1co2E9F+53NgpNp5LruiWhQlMzeOd3vq1KOnU9KbmthxmUFPMDk8Ev9JVv6TbW8D5pywyEApaH7KshVzX8hy9Pm6JlB5+QSZdASlGXAZ+HCrs0zkQ72CL/J6gUS11Ag4SJ/5IcBdFp0IAYniPQRW7bgpxnCXoyxGMh6M5EtP8rN81pnexjXMuQDF+xi9DCVyUUqDhKACI/DLU0LsGWUyBkRMvyU05q6uvT1wCX5Q5k5nNbGPXBASzIuMU3sPJSHqaAqxUmo8QYyAJVYY36a9fM71w4M3orvtGTBKKGbU9hXKjZjNfDoHoynYiL/561QNSaaj8xXFWnp7gr0b/y/t23a+7oGUhBR25EvSYxFvWefFzpwk6BvOd5Zk/eO6jucssPNblbSUeJUq3JyDgmHoOZpwW4BD9dz1xcpM6xitfHPSZQxw7MFIsK44bj0z6zo0cAlAaPOPs9v6AfmXR3+gFgNZ5u6EsVrtTrX7RgZgKqpUZYs6vGYnqQUzUaj7TpGJo6e++66u7UeMusPto8oJjqIiyJIQZXbbySdsIEOA4I57TlTz+jRdnZuFRE72z0FyMAQWmogyLcccX1VEkoZc+t1jUwsKjp9YAhNO7j8pP5q+Hf3NO/+Z4m1UUOQ9IHsGqp3TxUJhn/PzWwR+4Abd6+I/u6BsJUzpoPb/sv6AmNMTaS+5D/cKcEdPpKAnvsWCoVXKXtywmH5Dlp12YPyQQeWDAeQla1u7NgHsrRS0Dmr2UVr4r2iFrfEGf3S2DTenlTOucsjMoy4UpZPAciE2e8OSq3MJlfAxbThDqj43YrAUx+Cgkp4w5VQ45VuDgjy+dgEyX9lwPtj5RFxJngtG+Fbx2oWO33ReDy84DCDHzMo09E4x+N8zfMa85B0Wq7FeA6o7v8BOyvbFiWG57hvCADO6c39mPfXlQaXVfhjrVt4/CJAJHiR0s23D+I0QNOPZMenEeKZLqwVuLpNyWBg1f7/0q4M9rviHNKiWNqhDRgUQHVHgN/TOuiWXei6Cu6tY9QR2mNzsCq1MnqJD9FsQc6ZR0Nw/rohK0aBZrA3RtH6dRGfFN/ZLbMQIvknmOFccoZHMJaImGl5ciTNf3x9jzpfBTw8BExysBFFw4NaQ+wbE+EfB33LnEmAnjrdn3xyo51Oywj5C+Xr7lzgSO4YPk0/Lr05p6a2IsGnoJvpsAgbvFy3lWA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1kpJMyRKAwz2ZbfhKGQGjyMWXHDu1YtPnb3BxujwCuhFGJLLvJdJZW0qFhiWN8f2wGI4iEYY9nu9se1wyEWHBUIi60GXcVENPGC/OpVPnysVvT1jsVuisG7EWFVJ16l83AZH+IqLBcmonrC5m4izhQW0uorVx5m4Jhv31O6gGCurragq3EHVqykSY5TNnjBi3TU7OAWRcLAItHlv6/zOXnGrCrYn1nO1JM2sbHFEu+C3sIV2Y6Qagy7w/DNyGOUsAq8fEOW0t7H6gpOpJHaq595CDcV0UDFJrir3WCwBd2LO/Ufn0X0B2BcN/IZZZbpjbIt/efvvB/eOhh0Ev71PQg6vgMOqhWP3pTOPgeyp9B5GG85THp60VmM3X87LJA+XdZfsI/JNsTcQrnTE6/VJ4a2mmyt87TzSMOdtMPlc1NoN6gnqEa1OL+G64y5nN5QMV03TxZR6SeE1IfXmO3vl0Wj790aj0G6Q+Kha3annInAgFusX5A8DfeAudWdhAdg5HrlyEhQ/ZMVlZTnqrSUR6OKTshhyqHcuSF93ZGxdXU9yDND7zO46eNlfqgDnAINiSdjwu56yYpq8xVBqufNPt5QKcXbvCL8j53bkqd13cf98VErCi0eZYy+rIEkeH858YQy5OuIlU2RoRBcf1YdNGCiM09jgZFkVmLeCAF5dMC32wKaH4pb6BQz5Zq9Nxetm63Q3laJRjGPSBY3HehBfBpCMfnSDrhZhO6AZARdr3dVbYtxQIh8XAPqXPj2sSVptGUgQpRXaYL7/cWUflYhMeOymcTjRtJFd8JdmMka95U231FPlCxR0jWdeSDHA95SD9qAB6Uh0WgaEfH0s5DY7XE2wZMn7BylcKH4KW6WzghIa6srhVqQRtKfZta9nMmKiH22YWqwHq6yXTQKgs8paZoVx4kEmS7JqAQUT2Yti8ojEkiZOuH8z6aVo9qRcTgo78HO4J9FDJdoIqeLzH0SrXFgvzrhlRsh5n7qT60+Ex58= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb0e7901-2be8-45d6-cc1f-08dad6de49be X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:23.6390 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DVrHTGo7pdm0qngIkyzQ9FOK2G5M8UGQtPX9OcDOQSAxjq8HZ82LJ+s///tHq84K7AZeJ/DWok4sJNHYYHLlfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050137 X-Proofpoint-GUID: yC6XSEQWIfs6IS6wuwLurHjwfCy0aXjT X-Proofpoint-ORIG-GUID: yC6XSEQWIfs6IS6wuwLurHjwfCy0aXjT Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org tristate.conf was dropped because it is not needed to build modules.builtin any more, and doing so avoids one round of recursion through the build tree to build it. But it has one property that can be obtained in no other way in the current tree: it provides a machine-readable record of whether a module is tristate or not. (modules.builtin.objs, just added, uses modinfo, which is recorded in the source files themselves, but it is Kconfig that actually controls whether something can be built as a module.) So bring it back for this purpose. (Thanks to the refactoring in the 5.16 timeframe, this is basically a reimplementation of commit 8b41fc4454e36fbfdbb23f940d023d4dece2de29 rather than a simple reversion.) A verifier that uses it will be added in the next commit. Signed-off-by: Nick Alcock Reviewed-by: Victor Erminpour Reviewed-by: Kris Van Hees --- Notes: v7: rewrite in terms of the new confdata refactoring v8: adjust for changes in 5.17 merge window v10: commit log revised Documentation/kbuild/kconfig.rst | 5 ++++ Makefile | 2 +- scripts/kconfig/confdata.c | 41 +++++++++++++++++++++++++++----- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Documentation/kbuild/kconfig.rst b/Documentation/kbuild/kconfig.rst index 5967c79c3baa..e2c78760d442 100644 --- a/Documentation/kbuild/kconfig.rst +++ b/Documentation/kbuild/kconfig.rst @@ -162,6 +162,11 @@ KCONFIG_AUTOCONFIG This environment variable can be set to specify the path & name of the "auto.conf" file. Its default value is "include/config/auto.conf". +KCONFIG_TRISTATE +---------------- +This environment variable can be set to specify the path & name of the +"tristate.conf" file. Its default value is "include/config/tristate.conf". + KCONFIG_AUTOHEADER ------------------ This environment variable can be set to specify the path & name of the diff --git a/Makefile b/Makefile index 93bfaae45396..248f780cb75b 100644 --- a/Makefile +++ b/Makefile @@ -793,7 +793,7 @@ $(KCONFIG_CONFIG): # # Do not use $(call cmd,...) here. That would suppress prompts from syncconfig, # so you cannot notice that Kconfig is waiting for the user input. -%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h %/generated/rustc_cfg: $(KCONFIG_CONFIG) +%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h %/generated/rustc_cfg %/tristate.conf: $(KCONFIG_CONFIG) $(Q)$(kecho) " SYNC $@" $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig else # !may-sync-config diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index b7c9f1dd5e42..160d12b69957 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -223,6 +223,13 @@ static const char *conf_get_rustccfg_name(void) return name ? name : "include/generated/rustc_cfg"; } +static const char *conf_get_tristate_name(void) +{ + char *name = getenv("KCONFIG_TRISTATE"); + + return name ? name : "include/config/tristate.conf"; +} + static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) { char *p2; @@ -670,8 +677,12 @@ static char *escape_string_value(const char *in) enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE }; +#define PRINT_ESCAPE 0x01 +#define PRINT_UPCASE 0x02 +#define PRINT_TRISTATE_ONLY 0x04 + static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n, - bool escape_string) + int flags) { const char *val; char *escaped = NULL; @@ -679,6 +690,9 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n, if (sym->type == S_UNKNOWN) return; + if (flags & PRINT_TRISTATE_ONLY && sym->type != S_TRISTATE) + return; + val = sym_get_string_value(sym); if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) && @@ -688,29 +702,38 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n, return; } - if (sym->type == S_STRING && escape_string) { + if (sym->type == S_STRING && flags & PRINT_ESCAPE) { escaped = escape_string_value(val); val = escaped; } - fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, val); + if (flags & PRINT_UPCASE) + fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*val)); + else + fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, val); free(escaped); } static void print_symbol_for_dotconfig(FILE *fp, struct symbol *sym) { - __print_symbol(fp, sym, OUTPUT_N_AS_UNSET, true); + __print_symbol(fp, sym, OUTPUT_N_AS_UNSET, PRINT_ESCAPE); } static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym) { - __print_symbol(fp, sym, OUTPUT_N_NONE, false); + __print_symbol(fp, sym, OUTPUT_N_NONE, 0); +} + +static void print_symbol_for_tristate(FILE *fp, struct symbol *sym) +{ + __print_symbol(fp, sym, OUTPUT_N_NONE, PRINT_ESCAPE | PRINT_UPCASE | + PRINT_TRISTATE_ONLY); } void print_symbol_for_listconfig(struct symbol *sym) { - __print_symbol(stdout, sym, OUTPUT_N, true); + __print_symbol(stdout, sym, OUTPUT_N, PRINT_ESCAPE); } static void print_symbol_for_c(FILE *fp, struct symbol *sym) @@ -1207,6 +1230,12 @@ int conf_write_autoconf(int overwrite) if (ret) return ret; + ret = __conf_write_autoconf(conf_get_tristate_name(), + print_symbol_for_tristate, + &comment_style_pound); + if (ret) + return ret; + /* * Create include/config/auto.conf. This must be the last step because * Kbuild has a dependency on auto.conf and this marks the successful From patchwork Mon Dec 5 16:31:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064751 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 A9D42C4321E for ; Mon, 5 Dec 2022 16:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232425AbiLEQcy (ORCPT ); Mon, 5 Dec 2022 11:32:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232180AbiLEQcn (ORCPT ); Mon, 5 Dec 2022 11:32:43 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFAE055B1; Mon, 5 Dec 2022 08:32:36 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5FpmXZ018578; Mon, 5 Dec 2022 16:32:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=LRN8OIYLleP6YrIa2ynS7Nm1cB4VQOU5c/CwRwYqKZ0=; b=d09+82YIV2r7GYeLZRojmnmNqw8lA+Vm+DKfVQONCdm9SDC9GeljaOBYry80JnKdPFzu 5r+7NbZb6ZEzlBfGLeRa6Z7Tv8XYKhf5Ho6wVoHzmzKxhX1rpvt7gGaBLK61ql031BU5 NStWWz/TZww0YB6rsIjyMvlRXQfr6kk/KZyNAWNiwAkm44p1DYVbNtylMkfG8bfKdVE0 wWvL994cXCNLfsfdRBP6faZxkiV8glb8RwfS/gWCQG62nv8hu7Ud6B2kBL2uWbowT1n3 hsCEBRTVCTBYgov8ZqQyUzKi5oqujTbA9lZGyEgvk7jPc5N8hvDyrrD7PEigjF+T9HrO +g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7yb3c9r4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:30 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQvK9009444; Mon, 5 Dec 2022 16:32:30 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ugeda2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iq8nY6/YiI/sMKRAPn9JckWLuVBevy/soo9i/hh5J2aKd9ZjAOVGMRZ7rnUJlVsEn1hN6BK3LnCAxjESQCVjdvHWa8EeWc2E2S0N0uVeGKOGmbUkrQNjcBjBYGIkDt0sJaI9xfW0FZ3/oKu9noEtCaBIUJYF2B3i77BnwCRI9iGgOyMFqlMy78v1dMaGWxlAeuP8VAL5syiFDHP9sFbq5uA5cXFxCEfpUmUWvvgpH6VWiUWKTXEwD2t6ogPMmaUCRHi8rJ2jNj/VYbRTar85pOHyMmZl4rWJgCsN5eicK0qo4Y3aPle2lxTkUyXO+4NgrFe8yBUSdQ0Xl8uG1YE82A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LRN8OIYLleP6YrIa2ynS7Nm1cB4VQOU5c/CwRwYqKZ0=; b=kgjooX6K2MX2kZgLb0fjiAGy0ODDQCUOQSGMesOcD8E/5UGKWZL2sHLEh7ZmIbZ0d7UKYTdKXTW5rJOwrrsUA1NE/P3PnA46OXtVtLIJ4lyw9ozXN8AsWGAM2cWMhuFrHktMUoMmehRgJpKY9czUTUN+ZIGE1zWa8SA8nvvdC31E7WOLCis1/ZarnzecpdT1rWSSAyYlZ73vSzEcQIyKiwVkGpBL3jaD+zNhGArTlZi61MGRMQko83rkUO8djxUL9LQrAkWo9CxrThMhhz0yDA9TrV7nmOnMxZOBbkDJBOkzDbunXgJnmXiMFn6RY611ip36eODJiU3S3jZcpf2ldA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LRN8OIYLleP6YrIa2ynS7Nm1cB4VQOU5c/CwRwYqKZ0=; b=RvuGPWxJ/SQL9odI/wd2BG7hr7ZwGcSE5DBpwE/DdHZ9/tRW8XKjBiUfjmBOXjWLz4e+0xY9xav9htoiYfAoSTU2k+7u5KwBb5UUFsXjyF5E6aNN2WW4EVx9fn5nkvDd7RUZDo1SO8WP4DCZpi4ZRo+Yh7XYDBxM10bUX4Yg5mU= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:27 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:27 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 03/13] kbuild: add tristate checker Date: Mon, 5 Dec 2022 16:31:47 +0000 Message-Id: <20221205163157.269335-4-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P123CA0451.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::6) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: 572f9481-2485-4ea6-34a4-08dad6de4c13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AksKE9AP3j2vWNdLWJpNMPFJ8ANmkf3uHyZyBa49Pa/pREY9fS2NmApOUsGzL1R6GezxlgSzs2R4/r3kjrRian2TqXv6kT7BnwZWmYz7+4Xqbr8WT2Dx95mrF754SetQMEmGZWOmzInmFj6W9yjXt+VXJL8htsjedxYeR8PTMcjXU90fwHKq7Yzq9ebFAmVpQqk+vk/hNy2c87tdxu/89JywEwtqqhtLr5lrjdtrwSvsMMsO1x5qrxGGiUD222W3Hq6KybGQ9CVhH1igccNIMB0cxgrTlWPSZaSj4GBaTTP1NJiKLL5eqOIqhgBIlK0oC++j1YnvnqryTcSshTAU4R6ViJpSMIW37nKvS/jb+iCkn2LoTB0sXRcfe5l5cmKKuuNwJ7CHiKhc3zXnpcGRpesN6mzpOrViCeT9A7qEyVURSriiNrcGSmC7BHVQIQMuIiYdKcOvYTSfLWKTJGY/aCGWJwqtyiaJRlHk0C5Gy0HeRg5s/dakZstlZrZIaXxkye1VImd3hCbs8OF0llbIvzc1yo9LYBjyaQTekZa4BNq8P7IaVlrEYjjAUg0PZiLSk9Z8w3WpATnDvyzuSXGaEGvtNpstFYvpvbzqWJWZ6qjvRQDLFkU651B5wN99knoc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +1LwX+FR5RuhAJpsvDjDuGat8D5K9qzan+A5entO3t4zH+3i6JiJ/rpZNwDLenUzlUN9MteaDU65PJ3olDmvZVPtu0ce5trQu50Ho7sVeAmI3jI1VDV+TMr8r85vEO68qrQnNwoxbWodWTAzHq1Fsd64vNmCRh7gmjwccc1uYsqsZz+6LX1wi9Klnb9Pl3zsVG80XMRV9wk9Lb+vAsKesTR2yhwJxfokqw7iYCCRkOL648lnNWRFQ7SRvdApKCBgrOvxOC9+t6E1XyclvAg7vfmO/NiUuYJrDxM/PiJ8+c8eIHy9/ktMJ7yrxTkddIoo/FCm6BXC3bxa3QbaqRK2tFop0+0vvf4/tS5wcP6wrBKHewteKod8vgxvObOOhGh3Dv5hlL/rTz0V6LEnys8ABPf7GxY3qhuJ8UdMZld7F5xeGw6jRuX5EhgdU7mxsegRqqiwz97tJ6h6IxRVr9z5qvm9osjjFwqpWzUqIEQpVjVNAyWhMwdm8REws8PX5KvWo3dMCkHJfFIqJ/+Qi4VCXVy+cwYBaaKNiBakX+4WHIyJD959wJdm2CoEALYu67wuxkQ9cJhA0JF28G/H5dV0aEiLNG26upu3vWHFnpBWstjcSIj6cOMptLalErw5d40pKBNY3r6T38Lpd0X2oA9c/MkBLN+AVfHXNj+R71Z5aK5mt/ljhI2ZgkoMYwQSSciUZ1EXt6pbikWl5ubDLarDtQNi2b6uLerPH2sF4o3GQ/CwYXD2ylXugIdLVK9IFHud+pJ3A/Noag9NmQ8r5pTYbwzk1zczpS6aCzayqzLKOo+P6Fvp8S3f1+i8Apw1crvcnZVrrbSTZvUYSiTCGYlV3CWjh8agTboouiBWA8/pkXoB3rEMw9DIUgiOcPyaZIGp/flteKhpg4cpJ0rDmoxREd5sVWyH8GExc+JZWvJAUx6Skm/U42QcwL01ALIbGj7+SQ5MfjKzhYTrbxgCJe6caIJvXyLAUuZijbwr1uEPLvSWuDHLIYPUEBSinUuhDLUlojcE4L8CtnfruFXhKQ0yI8/pI9syrhj2Rd74qg4tMIRYfrvrNLPsXQhvyNjEOGUqfxdY3kKiYqSqIcNey2nLb5fw7WwU8/hXYMJhyhbt/br5MhP+ypsexNxc00DNaEg9hEwujd1oIpjq2JMcwcn+cjQU+/FP4/O1lJGRstyywh1EfVnKSKX3h1rzxJ6qt4EH8MPoxqxNe9U2+ayD9IH5nXzS/CHCUb7CLBYrK25+xe7W/pB0EDxy+v3nSpNIilTwgfT+4QaUqZKevoyH7OdM3el6GsbQ0KSqnFOQa4Za02GRvllO9Cs5JDWYv+/tJ4gTGRVOMx1Aj9IoI8xoCsP7kDsVd4CizyNksEwFoI5uCyurGATx8252d86YPMXy7b4jgOQjD7foYYbUauHzozfDSU97reZx/ii9NbuwvX/qIPuuVvrJ1e/gy4FC5wqcU4hOJiVzf4h1kiufLayQ4qWR1t5Jolax+aFPfzHxEvMfEf1Sgqid50uFG2g0vNFPsM2ID6Aw4LaG7FdHnzo7MFisLORcmGBdmuGlvXHcAM8TOki/Syw59niVnLjM3wK9FpO4zqwOuNDTRPezrVgxZ/eS2g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ctFbSl9917EXtN8agEhIv0qVqSvzU/kGY9R3epMr0rRwFCUzR3J4QN24F1FSjbMDDEEacY/qjhRNESPinv65zRogJy80PCiVn+W3YlpcAHV8FLlVaJt/K6VZHuFEh34zXASWQH5BLXbYU2NTJgq3ImAyNn33/4KXyuW0XJ1fmU/RVJTB+q89bw/ASqUBjsZuYlmXQwfX/tBni9Mu9RLoogC2nPIua6NHcvVWUPYS0nWMC7aU4I2xfCONGLEdtgTGuHGWfFPqEuhVwG1Wmak0lt+Xxy4ySz7U9NeMPTKFlObDajjPgRSA6yVPYB8zwn2pB84w1nR33o9cHvBd8Ih3AmezLV213UtIfazG66BeVxpKSn09AgTssbKECxZZWd1i6gxR5GkmTlFT1pjQtrLD5u2U7ae+HOHlM6dRESCojxHutJdX8BKnqZgQi8wpCzJAeRz9pCjVssQrKjN9HQH/KumcFj4c2TBfcm1pyaV23bXDeLIcEZv3gAaLnp7XpAB+L5yq6IgU04PrdBpvX6DlgmVZTxCDsCM5J+wdyU6sc2ReoX2DloNJt8ohZ6ekxXl/GHgZuBP0a0x+ttvZx08lEshY/WSCr1F2FnSg3Tc/TTFDuaLQlz1wxWJHQAuzKMYTEUOSZ97Vbq+3fhbuBnF8KvrDWe6p+XqVAWysBL0jxIh88bSGPQmx3hnODXV5SM8Un6spguMDApzPxS+jrPaKl6oh/ue/5Xw87q5PXiGKNJFz741rRy+53pT222USApDo5h4zlcA/jBw9JRX14bEJclG/j6ej7nULBP/53GLNif9Gt5aKXm/syeRilJVAGSQ3nwwXivDg6k/28A7ljb/Sy9u3ITHWCpVOPhu8VwkZrfQnucN2itK1PWyMh28Fkw/pCp7HLe5ApbvyiPpypSk7I99TRhARCEvQK9MZkFzf/2a6iSsGY3JcI2DjJgPQU+gI4DgWCKacFKBmzAqQHRM8m2C5gqQ2rWhrnljdPORgmbw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 572f9481-2485-4ea6-34a4-08dad6de4c13 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:27.5476 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IVydv0SkuCWL8jD+mSl42OfsfWeqWN7wd7JMSP+DIPITClNomTVJfBIZFd/4CDpAJt/hf0SCyAOKON/tgEmi+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050137 X-Proofpoint-ORIG-GUID: Qo4mhr2BaQisWaGQRxquRwXQMqHSMUaN X-Proofpoint-GUID: Qo4mhr2BaQisWaGQRxquRwXQMqHSMUaN Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org This new check target uses the tristate.conf machinery just added, and modules.builtin.objs, to identify source files that have MODULE_* declarations despite not being modules according to Kconfig. After commit 8b41fc4454e ("kbuild: create modules.builtin without Makefile.modbuiltin or tristate.conf"), all such declarations will cause modprobe to misidentify their containing object file as a module when it is not, which might cause it to spuriously fail when trying to load something that is built in to the kernel. Only source files compiled by the current configuration are checked, so a make allyesconfig is probably a good thing to do before running this: output if you don't do that won't be wrong but will probably be incomplete. Note that it is quite possible for things to be modular on only some architectures, in which case a make allyesconfig build will give false positive reports on other arches. (This is rare, but does apply to e.g. KVM on aarch64.) The checking is done by comparing modules.builtin.obj to a new check-tristates.objs, which is built in a way more or less identical to the way modules.builtin used to be built before commit 8b41fc4454e; the principal difference is that it's only built when running the checker, so doesn't slow down existing builds. This file is similar in structure to modules.builtin.objs, and constructed in a similar way to the way modules.builtin used to be built before commit 8b41fc4454e, via tristate.conf inclusion and recursive concatenation up the tree. Signed-off-by: Nick Alcock --- Notes: v10: adapted from modules_thick.builtin code: adjusted to use modules.builtin.objs, turned into a tristate checker. Top-level Kbuild changes no longer necessary. .gitignore | 1 + Documentation/dontdiff | 1 + Makefile | 23 ++++++++++++++-- scripts/Kbuild.include | 6 ++++ scripts/Makefile.lib | 8 +++++- scripts/check-tristates.mk | 56 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 scripts/check-tristates.mk diff --git a/.gitignore b/.gitignore index ef8665c64f21..75f246e0565f 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ *.zst Module.symvers modules.order +check-tristates.objs # # Top-level generic files diff --git a/Documentation/dontdiff b/Documentation/dontdiff index ed1fbc711f33..17686f59039c 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -183,6 +183,7 @@ modules.builtin modules.builtin.* modules.nsdeps modules.order +check-tristates.objs modversions.h* nconf nconf-cfg diff --git a/Makefile b/Makefile index 248f780cb75b..4d8a4c231cc1 100644 --- a/Makefile +++ b/Makefile @@ -1689,6 +1689,7 @@ help: @echo ' coccicheck - Check with Coccinelle' @echo ' clang-analyzer - Check with clang static analyzer' @echo ' clang-tidy - Check with clang-tidy' + @echo ' tristatecheck - Check for non-tristates with MODULE_ declarations' @echo '' @echo 'Tools:' @echo ' nsdeps - Generate missing symbol namespace dependencies' @@ -2012,7 +2013,7 @@ clean: $(clean-dirs) -o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.asn1.[ch]' \ -o -name '*.symtypes' -o -name 'modules.order' \ - -o -name '.tmp_*' \ + -o -name 'check-tristates.objs' -o -name '.tmp_*' \ -o -name '*.c.[012]*.*' \ -o -name '*.ll' \ -o -name '*.gcno' \ @@ -2082,7 +2083,25 @@ coccicheck: export_report: $(PERL) $(srctree)/scripts/export_report.pl -PHONY += checkstack kernelrelease kernelversion image_name +tristatecheck: SHELL=/bin/bash +tristatecheck: check-tristates.objs modules.builtin.objs + $(Q) for name in $$(comm -23 <(sed 's,:,,' modules.builtin.objs | tr ' ' '\n' | sort -u) \ + <(sed 's,:,,' check-tristates.objs | tr ' ' '\n' | sort -u)); do \ + grep -w $$name modules.builtin.objs | while read -r line; do \ + case $$line in \ + $$name:\ ) printf "%s " "$$line" | sed 's,: ,,';; \ + $$name:\ *) printf "%s " "$$line" | sed 's,^.*: ,,';; \ + *) echo $$name;; \ + esac; \ + done; \ + done | tr ' ' '\n' | sort -u | while read -r name; do \ + test -f $${name%.o}.c && echo $${name%.o}.c; \ + done | xargs grep -l '^ *MODULE_' || true + +check-tristates.objs: $(build-dir) + $(Q)$(MAKE) $(tristatecheck)=$^ tristates-file=$@ + +PHONY += checkstack kernelrelease kernelversion image_name tristatecheck # UML needs a little special treatment here. It wants to use the host # toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 2bc08ace38a3..8042c067312e 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -78,6 +78,12 @@ endef # $(Q)$(MAKE) $(build)=dir build := -f $(srctree)/scripts/Makefile.build obj +### +# Shorthand for $(Q)$(MAKE) -f scripts/check-tristates.mk need-tristates=1 obj= +# Usage: +# $(Q)$(MAKE) $(tristatecheck)=dir +tristatecheck := -f $(srctree)/scripts/check-tristates.mk need-tristates=1 obj + ### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= # Usage: diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index f7e5a83572fa..3bbfa99259cd 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -39,11 +39,17 @@ else obj-m := $(filter-out %/, $(obj-m)) endif -ifdef need-builtin +ifdef need-tristates +subdir-ym := $(sort $(subdir-y) $(subdir-m) \ + $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m) $(obj-Y) $(obj-M)))) obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) else +ifdef need-builtin +obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) +else obj-y := $(filter-out %/, $(obj-y)) endif +endif # Expand $(foo-objs) $(foo-y) etc. by replacing their individuals suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s)))) diff --git a/scripts/check-tristates.mk b/scripts/check-tristates.mk new file mode 100644 index 000000000000..fa9fadb79143 --- /dev/null +++ b/scripts/check-tristates.mk @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: GPL-2.0 +# ========================================================================== +# Generating check-tristates.objs +# ========================================================================== + +src := $(obj) + +PHONY := __tristates +__tristates: + +include include/config/auto.conf +# tristate.conf sets tristate variables to uppercase 'Y' or 'M' +# That way, we get the list of built-in modules in obj-Y +include include/config/tristate.conf + +include scripts/Kbuild.include + +ifdef building_out_of_srctree +# Create output directory if not already present +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) +endif + +# The filename Kbuild has precedence over Makefile +kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) +include $(kbuild-file) + +include scripts/Makefile.lib + +check-tristates-subdirs := $(patsubst %,%/check-tristates.objs, $(subdir-ym)) +check-tristates-target := $(obj)/check-tristates.objs + +__tristates: $(obj)/$(tristates-file) $(subdir-ym) + @: + +$(check-tristates-target): $(subdir-ym) FORCE + $(Q) rm -f $@ + $(Q) $(foreach mod-o, $(filter %.o,$(obj-Y)),\ + printf "%s: " $(addprefix $(obj)/,$(mod-o)) >> $@; \ + printf " %s" $(sort $(strip $(addprefix $(obj)/,$($(mod-o:.o=-objs)) \ + $($(mod-o:.o=-y)) $($(mod-o:.o=-Y))))) >> $@; \ + printf "\n" >> $@; ) \ + cat /dev/null $(check-tristates-subdirs) >> $@; + +PHONY += FORCE + +FORCE: + +# Descending +# --------------------------------------------------------------------------- + +PHONY += $(subdir-ym) +$(subdir-ym): + $(Q)$(MAKE) $(tristatecheck)=$@ tristates-file=$(tristates-file) + +.PHONY: $(PHONY) From patchwork Mon Dec 5 16:31:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064752 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 50613C4332F for ; Mon, 5 Dec 2022 16:33:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232499AbiLEQdL (ORCPT ); Mon, 5 Dec 2022 11:33:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232299AbiLEQcq (ORCPT ); Mon, 5 Dec 2022 11:32:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18A2A47C; Mon, 5 Dec 2022 08:32:39 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fc1ew007848; Mon, 5 Dec 2022 16:32:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=+EJgf+FKhVfVOHEciAku17ISGJp+6CdvI1h63mdLzHA=; b=USpY/yrsGbJPZ4xGN/249Gpnr3foF5R0r9/YbZGHWTDYlkzssnjUsAZcfJngyu1pe7i/ 5hoWfs/acPsHmF9XcCL3ADZ9vkpmHxPuTVzcCGTDD1YdSiAcTlxK5EKAOdKZU4Zjkk5r 0Uz6fDE2APy1A7wAR9rESMBvxMcyW0B7XOA6a9u7c1vog8LZrRY1Xk508pK78Awzy5Uy KV8Uy8IBz5x6OzT4kdJ+gnkxoFuZxSp13abzQiyFah1KYsztf1wbnXlMorraex4PcOQa b8qILs38sG/1rNX7iJb8GyILJ8thAlOZGT9GIJ0OQ5yiyTS19RNtabRstTgisBi9XZ/A ZA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7ybgmbey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:33 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQvuW009447; Mon, 5 Dec 2022 16:32:33 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2040.outbound.protection.outlook.com [104.47.74.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ugeda68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B9xioKqdgoMzOcb6lymtpau2dom5412VnbALqF6Ne7NnrEuyf284x9X90DFhP2IGVusYjjbNgqIhNlj4YnUVJcWbj9zTZpHd0NGpGcQfrnk2Tk+jvy1lKH4fTatVV7l1ZOckMAzTMEAy2K2y2D7dS6ImRGV3wYZ8dAALdwV8e0BXzU4X9kqxNJUGOSi2Mnun7Uon5eFh/mG/HnePTBwgW9bX6xDTUomaMrukvvgrrhCf4y0PAM8FzxYGP+UwhHMeKtuxlw0WO8KYSKgLIz+PK4V+35Y0BtZSVrf/wW6acS/GyqvjqvVYY6SLxLwMvxm/kBLo3+Cb5C/eabxpYR5Tvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+EJgf+FKhVfVOHEciAku17ISGJp+6CdvI1h63mdLzHA=; b=O7RIkh+5bRVVj6xzvWUQMKRVri2BSf6TC0vBWJ/3oTdZv2dTatc6gbtEfXccopott61yDzRnzVrrFrGi9dZjqzmQbTT34JN43MbSl+kviTj69gi8vX6/Yuagk5uvp1x5x0eoll7LMKeivCbIBRwW/7RGUANOP05t2MFfyLON+r7MBe9/eV3xIazVvVg0z66zX0nmluKkeMzqlY/xIjmFesElY7DP+OQmnGVCS9pDyyf/9ciaZBeZwYAvqCcOgFMFpbyDaOnr9lGrYFdJpuYGlV7lv0MyBURSYHBAurEe+I4Hm8d76z2SNiBpkcUk6qPrpT2mNxBtRxq/gCnNs3Fi/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+EJgf+FKhVfVOHEciAku17ISGJp+6CdvI1h63mdLzHA=; b=e+el9rgVUANI9/MJfxikw944nPVcibPchjx1ZCgjhcjPHJD6FFga+vSQO8Iu/6tNAINclv4e/VLQ4vgmO23h3hJEzJ2nu3v5YYU+VeNyQJT7fcfZetXB+pE/3plL6aWDOnwYBY4IaurIj0HMSsGIAfWcfzDlkhb+PUSjCog7mbI= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:31 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:31 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 04/13] kbuild: fix up substitutions in makefiles to allow for tristate checker Date: Mon, 5 Dec 2022 16:31:48 +0000 Message-Id: <20221205163157.269335-5-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LNXP265CA0069.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::33) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: fce2952a-ccdc-480b-9cfc-08dad6de4e54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k1sLyrcH4sN6GthlPrPVZvHbjMWfK1oAw+JoJ5wwxsVgCb/kOzPenXo3Qiu/qhwi3jMMr0meyJG++3Ns5fpXtDnb/ygnlISzDAWiHYS+YkLykoDSUhkXluX2zPufh/H8IspthhPcEMZW3U/2es5LDJA2lond/UbvgRGJx58E20awyQsr6skFJVZ9Dqmht+KsZ+btJs9RlIv7cchAIh6Qm/lse3Qs5trs/lLBNRs3iTQnHAnsqe2TwSKRcU186Jv74PFD63GHoVTa3AOUW3uwFekE7HBlO0qFVIP/Z5yHslngrAoH+wUoqoZmBOFDa4MWRPhkGb5qGQxABKz2GhzCkOM9Qi1nv0kFNWSJUbOJCH6F4Gv+3ujR/b81jAVksNKEO1JEpEtHSx04b9/htVy5DypZ64TvG+YWqR6RREWDz2gl6VcFDIW8xd4sMrr7+JLtk3c1JwI6MThzXJNaK05FI4dA6PHOLgQVLkTyRNlWBksfe8zIFHevwx+rAuyaue/zSLiI73XQ6BDyanmup4rvpTxxTXkceNAplK8ecRFDOnEj1+lWXXUfKzL99lv7RPVfaaVBj6o02b2sWhoJaboRCDZ47NC2vmSJvYE/jGs0PQaTijFaKPXleheZD+nb3PRG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(30864003)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ng+ov+Hd8n00ofVrnfdtKpYDHtpCAmXoWfqKO6QrKBtg9+jfJVuMHxc6X3SXacqAJ4M+0/xLEUaqUNyW71m1cYzyrKjiP20+f4O+qsyo+JmgJDoBHc04RBgT1TUKH/BFGtZ9b4g3046X+H4TE5LAHxynwftI9oY2OlHLy2+jt86rpXyeq94siYz+u8UueVU4iQNUFE2Zjw+7rV3Q1ikOipm11Hx2oVIu/4XVFmxZiiiJaI3dn1Sooo81G7WCK8EXCj2ROC4EKWaYYiLgTdSJX6dPCfC6fiHw2KkjTtj2AvrWTLqWK0n+td9YPi5+edyrFmdfVK23zJ/cqSemtOmMYhdtxw8a37FQgLch/HsqTpyvrhMJ79LwfabowojrKOf5AU8Nhm7HwmrSwIXTHJSh27vxCJ4suk9pvTINUPqHDupR456hRU1HebVJKWYmbQbT7qtGB/rodPbON2tHWQ61oSSdRvR48gknD5ZA3OfRgErgDU5/VQ/2uaCxcJPA/uRIoSwZURzhO/VHYPVhDQYrfyxVZNopAhPXbBKHRqNi/N5Ym7E9dxbhQm7A1xwfw9JzNW8lm6tuMfShDjlT4lTy8X5+UKyhj9NLZr9iiJIhy0ek/rQpG0UMRg6AFvh5J90uU/Kxs8yMOHHC8L7rFwNyROPnlK2pVLDkHgDHH7hhWyzAdIZA7mDoUIphqbxGDq+E5nhZwViQ4R0km/kElUzdM8/Xcf9XvYukv9BKgPKj1eBKGPyysEgk07EoOekw/AMKcNZPv6mKW+WlyHV/4qXASjnfUwhxLJCBcVeiid6NOculFeqMSFLlQestmdyHwLT2ZjqoqQ4N9tL8KurUu1m1B3Yrtxghb6qS+g9HX1anmXacF0LmQkwvTBuSa1yEwNod3MsgDWYPnbsIOchgVU3GWvU6Viv17vhzwK/AEs+9ZvDTGpruBFAhLxSrSe/ukocSxTHt9H2MASnUEsQCKw5kqw+lqDcdJEPV4I98BZ/glVK0OF24nrC+C5elmWUBO/Uju/GJGhZVvu4w0y4tXz0aGp+5WjXO4JnOCVP/V2Oy18aJ82ke4U39rbHtBtMmPy4ayFgDsXJXWFA9avWugEaq/dHQEyuYSl8CBocaDXtkR486+aJG7doJdUER2VouwHetFtAcXPu2FEEjZsIWF7DqZ6rIXtVSXVVY5CAhrKxm8HSE/0o4lyAbc7OuCoBubTnEFIxZoQy209FiCX0En+0rGXlx3nwbLuMnnqbFzxRZu9xU1Me0V92Gw5wSIl8gFZsOZVpoVmKUeYwRXN8x1NMQr8seJ2LRDRRrxGkpuhMk+9py+ZIyXjRgGBvaouyAzt0DZfO/ISWKl8KEN4reKg1ghRUJSYRaHY3l2+s1NmqDzWio0p9YnssNmy+Jel8cfEvDrgCxlv7h4i2xECLhNDPJmSKoUDROeApJAkEwF52OVb7I4MqRRCMCKHLvLGButlHJ8eB3EtBwaorwk9WcFIlLiizaWLooNZQD3NmcfhzS+VpkxA7S5twKXioJ6lCFvmG6EKH2TipwPij3ehbVQGBnsjjgcKAH/2AY5musd1UG7w8vnaczp9CUDNQ8kfgilpuKjzXo6/rF3ezDVrtUmiU/Xw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: EO0oWHLafYwpFJm/h8GD7wrE7mcW5e4zJDXkGlji6ORK49afZLylFcmNDB+JM6HlDVYnfklsY8lny1ZAF0CPUjqLm12IJxFrZBrMn8EVaHD2vBoZo0wozCzm+Q2yNSUaNc9ivkqPXNEAAaIlEu5FyU4vOLytEpR81qMg2oalngQTQrVLSS2h8mcPT3GAtklh8o1Lhy7ayljUXLWk4q+VAqlFABjCJsMpIvDywQkX6dr0cIFX+kSCr1wK32vyBKwBY1KqvUgpPNlUp0ak56qS74zz7RgRXuprVAvubX0wMDuOZu7iZzEgvKmbHfVy19hvof/VGpANEy+LmZiKKDcBmx1qrga2MLpd733wtvV1shjF4UBzt9/CDWkB8yY5fkIft8U0lzqF25YJxVddIrGlsgqNRWY5jQCTtYAkVeq/T1mwhitNTzaiiby7JZtny7+xyACDunZOcZ3UmsU06BMz+NgAofHAiCnfwkUlbm5WD7ZFFFRo75Y7Gh1cczvBcHa5yA0CNMJqpJXHDynbUAsW1R60crgErzdff2j2vgVQKLcvzUppeOnmB7uSzMFCHstm4mtOxS1sJJDadL0U81Iz7EHKc3yAtFk0ReCcepvEKapdrFshC3+eJZCWULPubiewcNdgivtNGehUVSJ9/17bBkdq/oBH1/t0YuIOWgK5PhU+zcyKGl+CVumB2S+dytJ9u8z70lc2M/Y6aAReF8liE9dVTBDI0/6S5/nM+mOKfXmQ0Yqc33xy8z6YJmSI61u1ZARJ5QwHW0/EFKN32PCzetkqZKlcCDGcrQWzcF0R0ZK8rB77t36RSlpcPVtGLF9I+fsrwkGu4HHI2tpfnlDTDNblUXq/w++1J5tbOg0BuoZXe+6xnzVbN1gk6maqercuULWukwo3w5SdfOUEazEoybgDC2wdymEspDTVoEcFmY1jSl5BT+XRszHTmQTN8BpgMYDwYDggejGREVDTlDo4hpXlCJ4g71W40LryTZej3t8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fce2952a-ccdc-480b-9cfc-08dad6de4e54 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:31.3317 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ItO+DuL6AnW78nnyO3TjPsxPP6oh39rqwG0nLvkt/CBPmHfCaUxAg8Kasf/K3WJEPHQnbfsM86he4TJz9/8QAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050137 X-Proofpoint-ORIG-GUID: 5S3HLZht5cFZ5jKdAvofW7VPnzzQ5UoL X-Proofpoint-GUID: 5S3HLZht5cFZ5jKdAvofW7VPnzzQ5UoL Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The tristate checker, like the Makefile.modbuiltin that preceded it, relies on running the makefiles with some CONFIG_ variables set to uppercase values ('Y' or 'M'). Large portions of the core build system assume that these values are lowercase, but we mostly don't care about those because they are only involved in actual building, and make tristatecheck doesn't build anything (the parts that do need changing so that recursion etc still worked were changed as part of the tristate commit). But some makefiles that are not part of the core build system also contain assumptions that CONFIG_ variables are always lowercase (every one of these was also broken wrt the old modules.builtin machinery, but now this is part of a verifier, the problems are more obvious). In most cases this is just something like obj-$(subst m,y,$(CONFIG_FOO)) += blah.o to indicate that blah.o is always built in even if CONFIG_FOO is a module. There is a new macro to help this relatively common case, which should now be rewritten as obj-$(call always_built_in,$(CONFIG_FOO)) += blah.o One other case we handle is that in net/dccp where things are built as modules iff any member of some other set are modular; this is now handled like so: obj-$(call module_if_any_modular,$(CONFIG_IP_DCCP)$(CONFIG_IPV6)) += dccp_ipv6.o dccp_ipv6-$(call module_if_any_modular,$(CONFIG_IP_DCCP)$(CONFIG_IPV6)) := ipv6.o Signed-off-by: Nick Alcock --- Notes: v10: new. drivers/Makefile | 2 +- drivers/hv/Makefile | 2 +- drivers/mmc/Makefile | 2 +- drivers/net/wireless/silabs/wfx/Makefile | 2 +- drivers/s390/char/Makefile | 2 +- drivers/s390/crypto/Makefile | 2 +- net/8021q/Makefile | 2 +- net/Makefile | 2 +- net/bridge/Makefile | 4 ++-- net/dccp/Makefile | 4 ++-- net/ipv6/Makefile | 2 +- net/l2tp/Makefile | 12 ++++++------ net/netfilter/Makefile | 2 +- net/netlabel/Makefile | 2 +- net/sctp/Makefile | 2 +- scripts/Kbuild.include | 15 +++++++++++++++ 16 files changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/Makefile b/drivers/Makefile index bdf1c66141c9..a6d3296f0c23 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -159,7 +159,7 @@ obj-$(CONFIG_SOUNDWIRE) += soundwire/ # Virtualization drivers obj-$(CONFIG_VIRT_DRIVERS) += virt/ -obj-$(subst m,y,$(CONFIG_HYPERV)) += hv/ +obj-$(call always_built_in,$(CONFIG_HYPERV)) += hv/ obj-$(CONFIG_PM_DEVFREQ) += devfreq/ obj-$(CONFIG_EXTCON) += extcon/ diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile index d76df5c8c2a9..06777af02a78 100644 --- a/drivers/hv/Makefile +++ b/drivers/hv/Makefile @@ -13,4 +13,4 @@ hv_vmbus-$(CONFIG_HYPERV_TESTING) += hv_debugfs.o hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o # Code that must be built-in -obj-$(subst m,y,$(CONFIG_HYPERV)) += hv_common.o +obj-$(call always_built_in,$(CONFIG_HYPERV)) += hv_common.o diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 3ea0126a9a72..1f4f9ce02490 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -4,4 +4,4 @@ # obj-$(CONFIG_MMC) += core/ -obj-$(subst m,y,$(CONFIG_MMC)) += host/ +obj-$(call always_built_in,$(CONFIG_MMC)) += host/ diff --git a/drivers/net/wireless/silabs/wfx/Makefile b/drivers/net/wireless/silabs/wfx/Makefile index c8b356f71c99..9fe47f5a050a 100644 --- a/drivers/net/wireless/silabs/wfx/Makefile +++ b/drivers/net/wireless/silabs/wfx/Makefile @@ -20,6 +20,6 @@ wfx-y := \ debug.o wfx-$(CONFIG_SPI) += bus_spi.o # When CONFIG_MMC == m, append to 'wfx-y' (and not to 'wfx-m') -wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o +wfx-$(call always_built_in,$(CONFIG_MMC)) += bus_sdio.o obj-$(CONFIG_WFX) += wfx.o diff --git a/drivers/s390/char/Makefile b/drivers/s390/char/Makefile index ce32270082f5..d21086e99528 100644 --- a/drivers/s390/char/Makefile +++ b/drivers/s390/char/Makefile @@ -34,7 +34,7 @@ obj-$(CONFIG_SCLP_VT220_TTY) += sclp_vt220.o obj-$(CONFIG_PCI) += sclp_pci.o -obj-$(subst m,y,$(CONFIG_ZCRYPT)) += sclp_ap.o +obj-$(call always_built_in,$(CONFIG_ZCRYPT)) += sclp_ap.o obj-$(CONFIG_VMLOGRDR) += vmlogrdr.o obj-$(CONFIG_VMCP) += vmcp.o diff --git a/drivers/s390/crypto/Makefile b/drivers/s390/crypto/Makefile index 22d2db690cd3..e3594486d8f3 100644 --- a/drivers/s390/crypto/Makefile +++ b/drivers/s390/crypto/Makefile @@ -4,7 +4,7 @@ # ap-objs := ap_bus.o ap_card.o ap_queue.o -obj-$(subst m,y,$(CONFIG_ZCRYPT)) += ap.o +obj-$(call always_built_in,$(CONFIG_ZCRYPT)) += ap.o # zcrypt_api.o and zcrypt_msgtype*.o depend on ap.o zcrypt-objs := zcrypt_api.o zcrypt_card.o zcrypt_queue.o zcrypt-objs += zcrypt_msgtype6.o zcrypt_msgtype50.o diff --git a/net/8021q/Makefile b/net/8021q/Makefile index e05d4d7aab35..50b48af58322 100644 --- a/net/8021q/Makefile +++ b/net/8021q/Makefile @@ -2,7 +2,7 @@ # # Makefile for the Linux VLAN layer. # -obj-$(subst m,y,$(CONFIG_VLAN_8021Q)) += vlan_core.o +obj-$(call always_built_in,$(CONFIG_VLAN_8021Q)) += vlan_core.o obj-$(CONFIG_VLAN_8021Q) += 8021q.o 8021q-y := vlan.o vlan_dev.o vlan_netlink.o diff --git a/net/Makefile b/net/Makefile index 6a62e5b27378..94165eb38b65 100644 --- a/net/Makefile +++ b/net/Makefile @@ -42,7 +42,7 @@ obj-$(CONFIG_PHONET) += phonet/ ifneq ($(CONFIG_VLAN_8021Q),) obj-y += 8021q/ endif -obj-$(CONFIG_IP_DCCP) += dccp/ +obj-$(call always_built_in,$(CONFIG_IP_DCCP)) += dccp/ obj-$(CONFIG_IP_SCTP) += sctp/ obj-$(CONFIG_RDS) += rds/ obj-$(CONFIG_WIRELESS) += wireless/ diff --git a/net/bridge/Makefile b/net/bridge/Makefile index 24bd1c0a9a5a..4f3109e170c8 100644 --- a/net/bridge/Makefile +++ b/net/bridge/Makefile @@ -12,10 +12,10 @@ bridge-y := br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o \ bridge-$(CONFIG_SYSFS) += br_sysfs_if.o br_sysfs_br.o -bridge-$(subst m,y,$(CONFIG_BRIDGE_NETFILTER)) += br_nf_core.o +bridge-$(call always_built_in,$(CONFIG_BRIDGE_NETFILTER)) += br_nf_core.o br_netfilter-y := br_netfilter_hooks.o -br_netfilter-$(subst m,y,$(CONFIG_IPV6)) += br_netfilter_ipv6.o +br_netfilter-$(call always_built_in,$(CONFIG_IPV6)) += br_netfilter_ipv6.o obj-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o bridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o br_mdb.o br_multicast_eht.o diff --git a/net/dccp/Makefile b/net/dccp/Makefile index 5b4ff37bc806..607f6d3dd795 100644 --- a/net/dccp/Makefile +++ b/net/dccp/Makefile @@ -17,8 +17,8 @@ dccp-$(CONFIG_IP_DCCP_TFRC_LIB) += ccids/lib/tfrc.o \ dccp_ipv4-y := ipv4.o # build dccp_ipv6 as module whenever either IPv6 or DCCP is a module -obj-$(subst y,$(CONFIG_IP_DCCP),$(CONFIG_IPV6)) += dccp_ipv6.o -dccp_ipv6-y := ipv6.o +obj-$(call module_if_any_modular,$(CONFIG_IP_DCCP)$(CONFIG_IPV6)) += dccp_ipv6.o +dccp_ipv6-$(call module_if_any_modular,$(CONFIG_IP_DCCP)$(CONFIG_IPV6)) := ipv6.o obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile index 3036a45e8a1e..b05b0e4668f5 100644 --- a/net/ipv6/Makefile +++ b/net/ipv6/Makefile @@ -47,7 +47,7 @@ obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o obj-$(CONFIG_INET) += output_core.o protocol.o \ ip6_offload.o tcpv6_offload.o exthdrs_offload.o -obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o +obj-$(call always_built_in,$(CONFIG_IPV6)) += inet6_hashtables.o ifneq ($(CONFIG_IPV6),) obj-$(CONFIG_NET_UDP_TUNNEL) += ip6_udp_tunnel.o diff --git a/net/l2tp/Makefile b/net/l2tp/Makefile index cf8f27071d3f..ff94be92a36e 100644 --- a/net/l2tp/Makefile +++ b/net/l2tp/Makefile @@ -8,11 +8,11 @@ obj-$(CONFIG_L2TP) += l2tp_core.o CFLAGS_l2tp_core.o += -I$(src) # Build l2tp as modules if L2TP is M -obj-$(subst y,$(CONFIG_L2TP),$(CONFIG_PPPOL2TP)) += l2tp_ppp.o -obj-$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_IP)) += l2tp_ip.o -obj-$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_V3)) += l2tp_netlink.o -obj-$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_ETH)) += l2tp_eth.o -obj-$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_DEBUGFS)) += l2tp_debugfs.o +obj-$(subst Y,$(CONFIG_L2TP),$(subst y,$(CONFIG_L2TP),$(CONFIG_PPPOL2TP))) += l2tp_ppp.o +obj-$(subst Y,$(CONFIG_L2TP),$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_IP))) += l2tp_ip.o +obj-$(subst Y,$(CONFIG_L2TP),$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_V3))) += l2tp_netlink.o +obj-$(subst Y,$(CONFIG_L2TP),$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_ETH))) += l2tp_eth.o +obj-$(subst Y,$(CONFIG_L2TP),$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_DEBUGFS))) += l2tp_debugfs.o ifneq ($(CONFIG_IPV6),) -obj-$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_IP)) += l2tp_ip6.o +obj-$(subst Y,$(CONFIG_L2TP),$(subst y,$(CONFIG_L2TP),$(CONFIG_L2TP_IP))) += l2tp_ip6.o endif diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile index 0f060d100880..a6f65c956b1b 100644 --- a/net/netfilter/Makefile +++ b/net/netfilter/Makefile @@ -6,7 +6,7 @@ nf_conntrack-y := nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_exp nf_conntrack_proto_icmp.o \ nf_conntrack_extend.o nf_conntrack_acct.o nf_conntrack_seqadj.o -nf_conntrack-$(subst m,y,$(CONFIG_IPV6)) += nf_conntrack_proto_icmpv6.o +nf_conntrack-$(call always_built_in,$(CONFIG_IPV6)) += nf_conntrack_proto_icmpv6.o nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMEOUT) += nf_conntrack_timeout.o nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMESTAMP) += nf_conntrack_timestamp.o nf_conntrack-$(CONFIG_NF_CONNTRACK_EVENTS) += nf_conntrack_ecache.o diff --git a/net/netlabel/Makefile b/net/netlabel/Makefile index 5a46381a64e7..8052bd8e7af8 100644 --- a/net/netlabel/Makefile +++ b/net/netlabel/Makefile @@ -13,4 +13,4 @@ obj-y += netlabel_mgmt.o # protocol modules obj-y += netlabel_unlabeled.o obj-y += netlabel_cipso_v4.o -obj-$(subst m,y,$(CONFIG_IPV6)) += netlabel_calipso.o +obj-$(call always_built_in,$(CONFIG_IPV6)) += netlabel_calipso.o diff --git a/net/sctp/Makefile b/net/sctp/Makefile index e845e4588535..683a345f3626 100644 --- a/net/sctp/Makefile +++ b/net/sctp/Makefile @@ -21,4 +21,4 @@ sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o sctp-$(CONFIG_PROC_FS) += proc.o sctp-$(CONFIG_SYSCTL) += sysctl.o -sctp-$(subst m,y,$(CONFIG_IPV6)) += ipv6.o +sctp-$(call always_built_in,$(CONFIG_IPV6)) += ipv6.o diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 8042c067312e..701bbb499427 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -188,6 +188,21 @@ cmd_and_fixdep = \ # and if so will execute $(rule_foo). if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:) +# Usage. $(call always-built-in,CONFIG_VAR) +# Expands to y if CONFIG_VAR is m, suitable for always-built-in pieces +# of things that otherwise may be modular. +always_built_in = $(subst M,Y,$(subst m,y,$(1))) + +# Usage, obj-$(call module_if_any_modular,$(CONCATENATED)$(CONFIG)$(VARS)) +# Expands to m if any of the concatenated config vars are m, otherwise +# y if any of them are y, otherwise n +module_if_any_modular = $(strip \ + $(if $(findstring m,$(subst M,m,$(1))), \ + $(if $(findstring M,$(1)),M,m), \ + $(if $(findstring y,$(subst Y,y,$(1))), \ + $(if $(findstring Y,$(1)),Y,y), \ + $(if $(findstring N,$(1)),N,n)))) + ### # why - tell why a target got built # enabled by make V=2 From patchwork Mon Dec 5 16:31:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064755 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 92071C4332F for ; Mon, 5 Dec 2022 16:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232484AbiLEQdo (ORCPT ); Mon, 5 Dec 2022 11:33:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232285AbiLEQdL (ORCPT ); Mon, 5 Dec 2022 11:33:11 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 916B41EED2; Mon, 5 Dec 2022 08:32:54 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fat9X017554; Mon, 5 Dec 2022 16:32:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2022-7-12; bh=QXL/IKG7+T3FqHTBBoamSkfCy0bpbzeigaZlZ7VGoYg=; b=ofIps6qaV5jrv72V82Gltb4QHqnkmvi28jHXqgaYCaM/KZEVm/3NbbOoTDQ/8LzmuNMH CUT8w/UwyESuEJcMATgNkEon1aPCBJ3B5o4Fzn8JQClCdc1iwQg+/2IguEcWBf2rWA4m hF7vA9pSfaT/1nAQqYJY+8VTugvzkizOffPK8GDJHIdRB4p/rPsZCCNAQpEgHWYfGF+3 J7JtJupzQuRo4h/QO/KTzT4JtA/3mgvtUzRjVdnTz+HlHg7GHD7/lef3VkK7xMX/CN5B ccC/J+8dhaJKMXuIwOEcU4tf8KNoPcizoG9ej9iWaWIlxfqKnAPNPGc+YZKzI8CB4vfu 3A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7ycf4fsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:42 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQvl7005382; Mon, 5 Dec 2022 16:32:40 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ucswawq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BUsx7Ku0UXZdgWqqXwjul56nmR+zLfsRFhggY7ex7JHHrP4GIGv9elOKbT5UUjvO0heCe8kxDm+GdCsZ7dbRVhqiBZIZUfsWGwVfp+/6vf/gb6/7C3jDWF3+VMrPSbaW5e1Q6LghPqypxjMLazzmPhmhXm7Iu2VjW80gg/5SuP1zGt/azLNHeg5GuiT6LCBjlbrGFyYHoNDO3phSSU6yR8zfTdkwntaW16YFaYcfw2pypUP2PZCIPJBEiuKZyGI2dt6MDF85KEO/EdYScVNbDkOnur+mMZZMJvxfvdp+CYCLruQmmJBeocVAIlnFMUcxHEdPQbFBsPZATsEs+E05rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QXL/IKG7+T3FqHTBBoamSkfCy0bpbzeigaZlZ7VGoYg=; b=eqC/g0U0XStU4zbmyuQFtvU922dZBM7q3tZ1HIYqhdaXA8sGayiRB0EF5ywi1ztTqlPrMJJDQ+q+ruj7ZOLRc2Z2Lbu32jZSZ7sxtAptoMoVMZm/u7mq1oZ+zsv2NNoXp9iGzW0Ml3LTxbV9NN15QGRZXlmzWJhR/JcHvheU9+lz4zMk3vk7uWSFEAYwqpEn18IyRPA5JF87JF1bnTNHHpJ4SkuswDNMlLRDeoX4mo5JRmeLjlhgEE3ycvFmpXihqtyH/EDeu1hKYdOoVK5Busgo2LWJoxLZtTcwkKGIM9khLy5jTXlLnSxBJ4ArHavstWZDAKOguQ56k5ULXb7cWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QXL/IKG7+T3FqHTBBoamSkfCy0bpbzeigaZlZ7VGoYg=; b=YqbLW1oZqJiTLZUYZ0DlyV9VOnb6qukTQdKiNSCN0tQSdXVCVwdBkRccx+WgSn0KswMaI3LnK054XKrBCnH9FFQy8aAQV0ZhNXRd3Jc+3xa2FUeEd+tcARc4z+GZbDt6Bt9wbkAyARzxUEa+FVpWqzEBJ9hNmlXCEoL8JYehShQ= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:36 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:36 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 05/13] kbuild: remove MODULE_LICENSE/AUTHOR/DESCRIPTION in non-modules Date: Mon, 5 Dec 2022 16:31:49 +0000 Message-Id: <20221205163157.269335-6-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO6P265CA0025.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ff::18) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: 7dc47e3b-87b6-4545-5279-08dad6de510f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pOd0o73YCfsU6IMg95A+sW1Ro5YBE+EcPciuEf/oDqYjuiqzyUQRWs/DyoZZtKoZpPOYVFyuzCqi2U7wEjJC+k1slYLb5tZSc74ho9p0MeuhaLFqGcos3bPYKrLSmrCaw8ylcgFiGC/WJRay9GeUdVuFQpQUradbY5GVQ5EosLRqpG7P+aLWlysn0fcjZcACntOej3IIiGFHPOyI+rKmkSJdMYCJ4NgaNQm7O9fi/z3gK84r5YmhW8BdVP41OIc1rIxUk1afzI4vQQlET/3Yf1zv1UN6Es5gfTNH4vytAmxuAFtJq2GBwuc3D3phK+dwj7/vjT4THb4Un+vnDnYEc33jjZlGAL8Kek0VMvTAnPthW7HxyjA6e3wMWKFN2/HCaXdaktuILSrR8Ivb65YaqvUEPhaUKRbDDOt8vT+c4M5/7dJjgiCrmCpCIhzQRr/nwoFaDFF29fOMtpZPsIqa7NvGBYzT/JXkuDNkyQhZv1hdvhORSJ3YF4d+jJSndjXGe7jL6u5b7oatLSH60tY7Wk/nLwacw5IX8b3dmypVDhrG+efxUnvIzdUOaSNP8RV+lg69j8leX6UyOL8LCSzwp7rOYfz32bWsUB+eL6kJnItxwMa1CKZwzAMCZqBMEtin5XKnzRnzsXELwn4ODCk0KVGH4d9EL8jfAIaw53APRYcaJ3q0v21yput4lRcBGmvNkH1FbjA1AQMIljZJGvl5Gg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(30864003)(44832011)(8936002)(5660300002)(66574015)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002)(504134003)(241875001)(579004)(559001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RFFkfHxi1kD8nmnIfu4/SS3/4kHV?= =?utf-8?q?SrCvJd7w3m1Kns8LEQJdDBUyczpBteP5HYVryyy5JFaBVwB4K13uVBeKdsRqq4cQX?= =?utf-8?q?XaktYOxz9BQfxeJ1l4weg6rWSp2RhmMajc9pyquYa9DidbSSFvqucZnKVWp6lNk2z?= =?utf-8?q?4Qz7TqgsolPFzczhFd4HluqkwijRe517T67LYKjSLbiV6nubowGtZl0Nu+uOmlliJ?= =?utf-8?q?l7Vt59qTeEIKCmrW0TNRpxkAKSg1Jh9N68GnHJ8LzlTiVfpzFxndo0DndChVcHFCK?= =?utf-8?q?yjDAJ81lLsWs00scj9I9BHWij5ElYowqtqjdXw5e+kMPmefbf5SJhlB+r8f7sXhgD?= =?utf-8?q?3xUAwpxGhy4O22VXtzqTY/vLy0j4ohlhAUa7vhDHOMlqyLBgO2QbdYzD387Ha7RO9?= =?utf-8?q?7jdsFCH3PDlqCWS3wP7PnodiF1Nj3+X/DXGTg1x+r4AMLgYHVafw7rylUMspz4owv?= =?utf-8?q?iZYX/LlK7TIzso1YpNA3FQ69PH+73T4Iqom9+oZgnvqgBB5CDfk4ruR8iybRQUKlc?= =?utf-8?q?5iY42EOTxMWp0/aUyJLvdLWFqAuvUxQS5WOEfz5aJyCsJRcvWv+0URtPxAD3BsL6U?= =?utf-8?q?jijMn8T0o0aygBRp31HC41xkCk0mOC2UqNgC9szNHg9EQHjU4WEhSZov/ffRZbg11?= =?utf-8?q?IP69Sk7NP2eXHtKd5FV0CCGJWRwk055li0mquVCMR1wy7gb5oVD4vPz7OXf5DixHd?= =?utf-8?q?FZFhv8jP8qxqmr1x6kv2ES1v/FeVKAZNYOsE+KN/k1ZPlk+JsLiRpavLB1jh4T3DA?= =?utf-8?q?f4jWCy+cy7t0gybl5bHH44pIYzt/nhFCLnqblxw4MIPzjLqi1yrx21RjXUXBqZQr/?= =?utf-8?q?Fh8iz7u6ih7GJ7GWyR2EG+Wjoz/jiogJvyDMwmhR4u+NugBXVj1KFjQ7QgQF1VxxW?= =?utf-8?q?VRfH/igm1JHCbC9SOHk07l2VJifskR56qKZpYnWamUMiVSUk5fsthdjWZqcX2I0I2?= =?utf-8?q?vMAXCZor6YfecSCuAei+s+269m+uyJcrrzR4fLDiqFLk1zM+X+Tmph5kEVziraNga?= =?utf-8?q?0tx/ZI+nBC+OiC+d0FIwDgk6EyUcCTSzWfUMbh4SFT+hbGcb1OeWgdZj2Nxy9pwNY?= =?utf-8?q?lJJZ7x0Lhez5CetfMOO2xIzMd+uCWJJ/grkN9EiVSpYIiIHbT8tPjU1iW+oVRAo6M?= =?utf-8?q?Zk9UX4FEJUmnlSi3/kOxmykgEiXOdGOMkIhG6xjF6AGtds+qiS+pi/G8cF9Crjy5F?= =?utf-8?q?tBroSfYLNaBnU0jMQKBbhtqOXSwbaSqR474fSfnxl5lceXLWo0Clz2VkeU7GLXEux?= =?utf-8?q?2TXgzhuYZavVCFT/3u/TBAKUI78AVii1k64TkXQkFdR7ARJ7v4Wk5VzhPaXfCJopV?= =?utf-8?q?nky5njbtagYAQr9rBw0a7c3lUCJFCbwSDrF83emGSN7rRkvbrvSrx/eQagIvkwC1M?= =?utf-8?q?GQAE6oGJ6DNDdARbXRFWO6h9ODE/spx+ZiR1EwpjQKsXTGROpEptemVaz6pwPLL+x?= =?utf-8?q?OKLOEQAKIvGiMppKQcn4sbcEcV6G7seBoWk9OSI60vHKfM+MUQaUTrMUgCCJxyIQW?= =?utf-8?q?Z6UgR/ibqdC7gSO+yFpaiLqPyM42UKzx2g=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: =?utf-8?q?vAD+0w31y3BECTzE?= =?utf-8?q?xjGLymk76rGxGCWVxpzH/7mqH7axN8GO67bgJsaWyVuWI25Qb33ryHotyHtxsRIoT?= =?utf-8?q?oy6NnLuegaC3m6Xf+1ibg7nHED5elivG88jpWPxLxUqKRGHTsVQBZvbXAi6OslpQ7?= =?utf-8?q?ms74dopBXAeVLlApNduGtN4VByxCoyQrSIkPHExyaAyZiTptPPadt/Zh1rI/7vpPZ?= =?utf-8?q?reFXFvij6BFEHYDpYHLkXT9LnJU5Gepy00MHX900FgdCUyqXCaRzIDHEm/tYUwc5P?= =?utf-8?q?Etzzu3u6FuAv1B0Dut9X/C2P+GCsfZBTO3Hsa4eUH7Y/5lZEtqzF1O0NqQ0lvltwi?= =?utf-8?q?MfUPTSVwb/Oayxofh/ex60gMBtzq3LtQzrpc53JirXNC42ILexj8FsQI2qjS62rP9?= =?utf-8?q?nLFjzAXv9sJzYs81ONUHQpVvWyjCsDO0zFMlh+Emi9JwzzfH7kkDRfzl6Yrd9G7Xe?= =?utf-8?q?HsXM2F+XTrTx6MKnmRBZ2T2yc2tbcsfdSScbxWbWXPlj3H3riGhIXRHCbMY+OFy2N?= =?utf-8?q?pnv6tsyqlM9mUH+vBCYI71AO8ckOp87bEmZ5Ieh8pihnEgIJdonkVHLmI4Mee/kOe?= =?utf-8?q?rXMRbJ93/4MoKZypU1XaG/Y/daH7PBTZpWyVYfDMgW65ffmiAwnMw2TnB4GxSBALO?= =?utf-8?q?vb38ZQbZn+IEuUcnM6ltMuB7zF2PN+UJg/BaA6/Hm466dnqLSB8UTBelGAH7I8fPC?= =?utf-8?q?jGzx99J6z1gOU3xsYhDKD5bbpBq7RF9/jJe25U9pURJxqHw8uUPGc8aXrhV6tBIvH?= =?utf-8?q?LI+UmijDNwFsWVRgBfJkhTL7BIbl6UQ0iLVH02vctaByw6I8Nal72WhqtB3ZmShTA?= =?utf-8?q?dhnnDMs5jMthxBNwjOibuMuGx9ThfAnjoZca3BE1cBXnIBW6uE53UWEl5yJcN5Wio?= =?utf-8?q?tx2rQobS5e+eg7mWN3CLpQjUjUgtqHm2RwPJqqxAfgh+jj1EzXfu0dX6ERmWcFSpu?= =?utf-8?q?DHgsJLgdjxew=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7dc47e3b-87b6-4545-5279-08dad6de510f X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:36.0201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4QWCzhdrLNz1Kx4LbUogOomfsc2GEIWaZw5dN2l2YIuRKIy21qVW3FHesIUtXO7X8xirrx/8tHnuKajggGT08Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050137 X-Proofpoint-ORIG-GUID: GTorPwPTkrtBUM2uX5SVu3I5ToxH8m7D X-Proofpoint-GUID: GTorPwPTkrtBUM2uX5SVu3I5ToxH8m7D Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Since commit 8b41fc4454e ("kbuild: create modules.builtin without Makefile.modbuiltin or tristate.conf"), MODULE_LICENSE declarations in non-modules will cause modprobe to misidentify their containing object file as a module when it is not, which might cause it to spuriously fail when trying to load something that is built in to the kernel. They also cause misconstruction of modules.builtin.objs, leading to incorrect output in kallmodsyms (notating things as being in modules when they actually cannot be built as a module at all). Automatically identified with the new tristate checker, and purged with sed and a subsequent make allmodconfig to double-check. Signed-off-by: Nick Alcock --- Notes: v10: new. arch/x86/crypto/blake2s-glue.c | 1 - arch/x86/mm/debug_pagetables.c | 3 --- crypto/asymmetric_keys/asymmetric_type.c | 1 - drivers/accessibility/braille/braille_console.c | 4 ---- drivers/amba/tegra-ahb.c | 3 --- drivers/android/binder.c | 1 - drivers/bus/arm-cci.c | 2 -- drivers/bus/arm-integrator-lm.c | 3 --- drivers/bus/bt1-apb.c | 3 --- drivers/bus/bt1-axi.c | 3 --- drivers/bus/imx-weim.c | 3 --- drivers/bus/intel-ixp4xx-eb.c | 3 --- drivers/bus/qcom-ebi2.c | 3 --- drivers/bus/qcom-ssc-block-bus.c | 3 --- drivers/bus/simple-pm-bus.c | 3 --- drivers/clk/bcm/clk-bcm2835-aux.c | 3 --- drivers/clk/bcm/clk-bcm2835.c | 3 --- drivers/clk/clk-bm1880.c | 3 --- drivers/clk/clk-fixed-mmio.c | 3 --- drivers/clk/clk-fsl-sai.c | 3 --- drivers/clk/hisilicon/clk-hi3559a.c | 2 -- drivers/clk/microchip/clk-mpfs-ccc.c | 3 --- drivers/clk/microchip/clk-mpfs.c | 5 ----- drivers/clk/renesas/rcar-usb2-clock-sel.c | 2 -- drivers/clk/renesas/renesas-cpg-mssr.c | 2 -- drivers/clk/renesas/rzg2l-cpg.c | 2 -- drivers/clocksource/em_sti.c | 3 --- drivers/clocksource/sh_cmt.c | 3 --- drivers/clocksource/sh_mtu2.c | 3 --- drivers/clocksource/sh_tmu.c | 3 --- drivers/clocksource/timer-stm32-lp.c | 2 -- drivers/clocksource/timer-tegra186.c | 3 --- drivers/clocksource/timer-ti-dm.c | 3 --- drivers/cpufreq/freq_table.c | 3 --- drivers/cpufreq/intel_pstate.c | 3 --- drivers/cpufreq/tegra124-cpufreq.c | 3 --- drivers/dma-buf/heaps/cma_heap.c | 2 -- drivers/dma-buf/heaps/system_heap.c | 1 - drivers/dma-buf/udmabuf.c | 2 -- drivers/dma/ep93xx_dma.c | 3 --- drivers/dma/ipu/ipu_idmac.c | 3 --- drivers/dma/mv_xor_v2.c | 2 -- drivers/dma/s3c24xx-dma.c | 3 --- drivers/dma/sh/shdma-base.c | 3 --- drivers/dma/stm32-dmamux.c | 4 ---- drivers/dma/stm32-mdma.c | 4 ---- drivers/edac/altera_edac.c | 3 --- drivers/firmware/broadcom/bcm47xx_nvram.c | 1 - drivers/firmware/imx/imx-scu.c | 3 --- drivers/firmware/imx/scu-pd.c | 3 --- drivers/gpio/gpio-aspeed-sgpio.c | 2 -- drivers/gpio/gpio-imx-scu.c | 3 --- drivers/gpio/gpio-mxs.c | 6 ------ drivers/gpio/gpio-rda.c | 3 --- drivers/gpu/drm/drm_mipi_dsi.c | 3 --- drivers/hwspinlock/hwspinlock_core.c | 3 --- drivers/interconnect/core.c | 3 --- drivers/iommu/sun50i-iommu.c | 4 ---- drivers/irqchip/irq-al-fic.c | 3 --- drivers/irqchip/irq-ls-scfg-msi.c | 3 --- drivers/irqchip/irq-mbigen.c | 4 ---- drivers/irqchip/irq-mchp-eic.c | 3 --- drivers/irqchip/irq-mvebu-pic.c | 3 --- drivers/irqchip/irq-renesas-intc-irqpin.c | 3 --- drivers/irqchip/irq-renesas-irqc.c | 3 --- drivers/irqchip/irq-renesas-rza1.c | 3 --- drivers/irqchip/irq-renesas-rzg2l.c | 3 --- drivers/irqchip/irq-sl28cpld.c | 3 --- drivers/irqchip/irq-ti-sci-inta.c | 3 --- drivers/irqchip/irq-ti-sci-intr.c | 3 --- drivers/leds/leds-asic3.c | 3 --- drivers/mailbox/rockchip-mailbox.c | 4 ---- drivers/mailbox/zynqmp-ipi-mailbox.c | 3 --- drivers/memory/bt1-l2-ctl.c | 3 --- drivers/memory/da8xx-ddrctl.c | 3 --- drivers/memory/fsl_ifc.c | 3 --- drivers/memory/mvebu-devbus.c | 3 --- drivers/memory/tegra/mc.c | 3 --- drivers/memory/tegra/tegra186-emc.c | 3 --- drivers/mfd/88pm860x-core.c | 3 --- drivers/mfd/altera-sysmgr.c | 3 --- drivers/mfd/bcm2835-pm.c | 3 --- drivers/mfd/da903x.c | 4 ---- drivers/mfd/da9052-core.c | 3 --- drivers/mfd/da9052-i2c.c | 3 --- drivers/mfd/da9052-spi.c | 3 --- drivers/mfd/da9055-core.c | 3 --- drivers/mfd/da9055-i2c.c | 3 --- drivers/mfd/ezx-pcap.c | 3 --- drivers/mfd/intel_soc_pmic_crc.c | 4 ---- drivers/mfd/lp8788.c | 3 --- drivers/mfd/omap-usb-host.c | 4 ---- drivers/mfd/omap-usb-tll.c | 4 ---- drivers/mfd/palmas.c | 3 --- drivers/mfd/stmpe-i2c.c | 3 --- drivers/mfd/stmpe-spi.c | 3 --- drivers/mfd/tc3589x.c | 3 --- drivers/mfd/tps6586x.c | 3 --- drivers/mfd/twl4030-audio.c | 3 --- drivers/mfd/twl6040.c | 4 ---- drivers/mtd/parsers/bcm63xxpart.c | 6 ------ drivers/nvmem/core.c | 4 ---- drivers/nvmem/zynqmp_nvmem.c | 3 --- drivers/pci/controller/dwc/pcie-histb.c | 2 -- drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c | 3 --- drivers/pci/controller/pci-tegra.c | 1 - drivers/pci/controller/pci-versatile.c | 2 -- drivers/pci/controller/pcie-hisi-error.c | 2 -- drivers/pci/controller/pcie-microchip-host.c | 3 --- drivers/pci/endpoint/pci-ep-cfs.c | 3 --- drivers/pci/endpoint/pci-epc-core.c | 3 --- drivers/pci/endpoint/pci-epc-mem.c | 3 --- drivers/pci/endpoint/pci-epf-core.c | 3 --- drivers/pci/hotplug/acpiphp_core.c | 3 --- drivers/pci/hotplug/shpchp_core.c | 3 --- drivers/perf/apple_m1_cpu_pmu.c | 1 - drivers/phy/intel/phy-intel-lgm-combo.c | 2 -- drivers/pinctrl/actions/pinctrl-s500.c | 4 ---- drivers/pinctrl/actions/pinctrl-s700.c | 3 --- drivers/pinctrl/actions/pinctrl-s900.c | 4 ---- drivers/pinctrl/bcm/pinctrl-ns.c | 2 -- drivers/pinctrl/mediatek/pinctrl-mt8188.c | 2 -- drivers/pinctrl/mediatek/pinctrl-mt8192.c | 2 -- drivers/pinctrl/mediatek/pinctrl-mt8365.c | 3 --- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 4 ---- drivers/pinctrl/pinctrl-amd.c | 3 --- drivers/pinctrl/renesas/pinctrl-rza1.c | 3 --- drivers/pinctrl/renesas/pinctrl-rza2.c | 3 --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 3 --- drivers/pinctrl/renesas/pinctrl-rzn1.c | 3 --- drivers/pinctrl/renesas/pinctrl-rzv2m.c | 3 --- drivers/power/reset/as3722-poweroff.c | 3 --- drivers/power/reset/gpio-poweroff.c | 3 --- drivers/power/reset/gpio-restart.c | 3 --- drivers/power/reset/keystone-reset.c | 3 --- drivers/power/reset/ltc2952-poweroff.c | 3 --- drivers/power/reset/mt6323-poweroff.c | 3 --- drivers/power/reset/regulator-poweroff.c | 3 --- drivers/power/reset/restart-poweroff.c | 3 --- drivers/power/reset/tps65086-restart.c | 3 --- drivers/power/supply/power_supply_core.c | 6 ------ drivers/power/supply/wm97xx_battery.c | 3 --- drivers/powercap/powercap_sys.c | 3 --- drivers/regulator/stm32-pwr.c | 3 --- drivers/remoteproc/remoteproc_core.c | 2 -- drivers/reset/reset-axs10x.c | 3 --- drivers/reset/reset-hsdk.c | 3 --- drivers/reset/reset-lantiq.c | 3 --- drivers/reset/reset-microchip-sparx5.c | 3 --- drivers/reset/reset-mpfs.c | 3 --- drivers/soc/apple/apple-pmgr-pwrstate.c | 3 --- drivers/soc/bcm/bcm2835-power.c | 3 --- drivers/soc/bcm/raspberrypi-power.c | 4 ---- drivers/soc/fujitsu/a64fx-diag.c | 3 --- drivers/soc/sunxi/sunxi_sram.c | 3 --- drivers/soc/tegra/cbb/tegra194-cbb.c | 3 --- drivers/soc/tegra/cbb/tegra234-cbb.c | 2 -- drivers/tty/n_null.c | 3 --- drivers/tty/serial/imx_earlycon.c | 3 --- drivers/tty/serial/rda-uart.c | 3 --- drivers/video/console/vgacon.c | 1 - drivers/video/fbdev/asiliantfb.c | 1 - drivers/video/fbdev/gbefb.c | 1 - drivers/video/fbdev/imsttfb.c | 1 - drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 3 --- drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c | 3 --- drivers/video/fbdev/vesafb.c | 1 - drivers/video/fbdev/wm8505fb.c | 3 --- drivers/video/fbdev/wmt_ge_rops.c | 4 ---- drivers/xen/grant-dma-ops.c | 3 --- drivers/xen/xenbus/xenbus_probe.c | 1 - fs/binfmt_elf.c | 1 - fs/nfs_common/nfs_ssc.c | 1 - fs/unicode/utf8-core.c | 1 - kernel/dma/map_benchmark.c | 3 --- kernel/events/hw_breakpoint_test.c | 2 -- kernel/trace/rv/reactor_panic.c | 3 --- kernel/trace/rv/reactor_printk.c | 3 --- kernel/watch_queue.c | 3 --- lib/btree.c | 3 --- lib/crypto/blake2s-generic.c | 3 --- lib/crypto/blake2s.c | 3 --- lib/glob.c | 2 -- lib/packing.c | 2 -- lib/pldmfw/pldmfw.c | 3 --- lib/test_fprobe.c | 1 - mm/zpool.c | 3 --- mm/zswap.c | 3 --- net/mctp/af_mctp.c | 3 --- 189 files changed, 539 deletions(-) diff --git a/arch/x86/crypto/blake2s-glue.c b/arch/x86/crypto/blake2s-glue.c index aaba21230528..0df9ec15643a 100644 --- a/arch/x86/crypto/blake2s-glue.c +++ b/arch/x86/crypto/blake2s-glue.c @@ -74,4 +74,3 @@ static int __init blake2s_mod_init(void) module_init(blake2s_mod_init); -MODULE_LICENSE("GPL v2"); diff --git a/arch/x86/mm/debug_pagetables.c b/arch/x86/mm/debug_pagetables.c index 092ea436c7e6..ad25ad29aa10 100644 --- a/arch/x86/mm/debug_pagetables.c +++ b/arch/x86/mm/debug_pagetables.c @@ -71,6 +71,3 @@ static void __exit pt_dump_debug_exit(void) module_init(pt_dump_debug_init); module_exit(pt_dump_debug_exit); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Arjan van de Ven "); -MODULE_DESCRIPTION("Kernel debugging helper that dumps pagetables"); diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c index 41a2f0eb4ce4..a5da8ccd353e 100644 --- a/crypto/asymmetric_keys/asymmetric_type.c +++ b/crypto/asymmetric_keys/asymmetric_type.c @@ -17,7 +17,6 @@ #include #include "asymmetric_keys.h" -MODULE_LICENSE("GPL"); const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = { [VERIFYING_MODULE_SIGNATURE] = "mod sig", diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/accessibility/braille/braille_console.c index c4d54a5326b1..4ea6893659af 100644 --- a/drivers/accessibility/braille/braille_console.c +++ b/drivers/accessibility/braille/braille_console.c @@ -22,10 +22,6 @@ #include #include -MODULE_AUTHOR("samuel.thibault@ens-lyon.org"); -MODULE_DESCRIPTION("braille device"); -MODULE_LICENSE("GPL"); - /* * Braille device support part. */ diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c index 0b2c20fddb7c..084ac10c4286 100644 --- a/drivers/amba/tegra-ahb.c +++ b/drivers/amba/tegra-ahb.c @@ -283,7 +283,4 @@ static struct platform_driver tegra_ahb_driver = { }; module_platform_driver(tegra_ahb_driver); -MODULE_AUTHOR("Hiroshi DOYU "); -MODULE_DESCRIPTION("Tegra AHB driver"); -MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRV_NAME); diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 880224ec6abb..e36164108da6 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -6597,4 +6597,3 @@ device_initcall(binder_init); #define CREATE_TRACE_POINTS #include "binder_trace.h" -MODULE_LICENSE("GPL v2"); diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c index b8184a903583..6702bee4ca5c 100644 --- a/drivers/bus/arm-cci.c +++ b/drivers/bus/arm-cci.c @@ -583,5 +583,3 @@ EXPORT_SYMBOL_GPL(cci_probed); early_initcall(cci_init); core_initcall(cci_platform_init); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("ARM CCI support"); diff --git a/drivers/bus/arm-integrator-lm.c b/drivers/bus/arm-integrator-lm.c index 2344d560b144..61a649acdfef 100644 --- a/drivers/bus/arm-integrator-lm.c +++ b/drivers/bus/arm-integrator-lm.c @@ -124,6 +124,3 @@ static struct platform_driver integrator_ap_lm_driver = { }, }; module_platform_driver(integrator_ap_lm_driver); -MODULE_AUTHOR("Linus Walleij "); -MODULE_DESCRIPTION("Integrator AP Logical Module driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c index 63b1b4a76671..1d4e509b195b 100644 --- a/drivers/bus/bt1-apb.c +++ b/drivers/bus/bt1-apb.c @@ -414,6 +414,3 @@ static struct platform_driver bt1_apb_driver = { }; module_platform_driver(bt1_apb_driver); -MODULE_AUTHOR("Serge Semin "); -MODULE_DESCRIPTION("Baikal-T1 APB-bus driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/bus/bt1-axi.c b/drivers/bus/bt1-axi.c index 70e49a6e5374..9b4461ec8084 100644 --- a/drivers/bus/bt1-axi.c +++ b/drivers/bus/bt1-axi.c @@ -307,6 +307,3 @@ static struct platform_driver bt1_axi_driver = { }; module_platform_driver(bt1_axi_driver); -MODULE_AUTHOR("Serge Semin "); -MODULE_DESCRIPTION("Baikal-T1 AXI-bus driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 828c66bbaa67..b8519526dd24 100644 --- a/drivers/bus/imx-weim.c +++ b/drivers/bus/imx-weim.c @@ -403,6 +403,3 @@ static void __exit weim_exit(void) } module_exit(weim_exit); -MODULE_AUTHOR("Freescale Semiconductor Inc."); -MODULE_DESCRIPTION("i.MX EIM Controller Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/bus/intel-ixp4xx-eb.c b/drivers/bus/intel-ixp4xx-eb.c index a4388440aca7..6e02369aedeb 100644 --- a/drivers/bus/intel-ixp4xx-eb.c +++ b/drivers/bus/intel-ixp4xx-eb.c @@ -424,6 +424,3 @@ static struct platform_driver ixp4xx_exp_driver = { }, }; module_platform_driver(ixp4xx_exp_driver); -MODULE_AUTHOR("Linus Walleij "); -MODULE_DESCRIPTION("Intel IXP4xx external bus driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/bus/qcom-ebi2.c b/drivers/bus/qcom-ebi2.c index 663c82749222..5846c2ffe99c 100644 --- a/drivers/bus/qcom-ebi2.c +++ b/drivers/bus/qcom-ebi2.c @@ -401,6 +401,3 @@ static struct platform_driver qcom_ebi2_driver = { }, }; module_platform_driver(qcom_ebi2_driver); -MODULE_AUTHOR("Linus Walleij "); -MODULE_DESCRIPTION("Qualcomm EBI2 driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/bus/qcom-ssc-block-bus.c b/drivers/bus/qcom-ssc-block-bus.c index eedeb29a5ff3..040f3432b989 100644 --- a/drivers/bus/qcom-ssc-block-bus.c +++ b/drivers/bus/qcom-ssc-block-bus.c @@ -384,6 +384,3 @@ static struct platform_driver qcom_ssc_block_bus_driver = { module_platform_driver(qcom_ssc_block_bus_driver); -MODULE_DESCRIPTION("A driver for handling the init sequence needed for accessing the SSC block on (some) qcom SoCs over AHB"); -MODULE_AUTHOR("Michael Srba "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c index 6b8d6257ed8a..22fe6478e7b5 100644 --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -90,6 +90,3 @@ static struct platform_driver simple_pm_bus_driver = { module_platform_driver(simple_pm_bus_driver); -MODULE_DESCRIPTION("Simple Power-Managed Bus Driver"); -MODULE_AUTHOR("Geert Uytterhoeven "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/bcm/clk-bcm2835-aux.c b/drivers/clk/bcm/clk-bcm2835-aux.c index 290a2846a86b..9aeeee6096a8 100644 --- a/drivers/clk/bcm/clk-bcm2835-aux.c +++ b/drivers/clk/bcm/clk-bcm2835-aux.c @@ -67,6 +67,3 @@ static struct platform_driver bcm2835_aux_clk_driver = { }; builtin_platform_driver(bcm2835_aux_clk_driver); -MODULE_AUTHOR("Eric Anholt "); -MODULE_DESCRIPTION("BCM2835 auxiliary peripheral clock driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index e74fe6219d14..eec7146b12a0 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -2348,6 +2348,3 @@ static struct platform_driver bcm2835_clk_driver = { builtin_platform_driver(bcm2835_clk_driver); -MODULE_AUTHOR("Eric Anholt "); -MODULE_DESCRIPTION("BCM2835 clock driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/clk/clk-bm1880.c b/drivers/clk/clk-bm1880.c index fad78a22218e..67aace6d4e2a 100644 --- a/drivers/clk/clk-bm1880.c +++ b/drivers/clk/clk-bm1880.c @@ -947,6 +947,3 @@ static struct platform_driver bm1880_clk_driver = { }; module_platform_driver(bm1880_clk_driver); -MODULE_AUTHOR("Manivannan Sadhasivam "); -MODULE_DESCRIPTION("Clock driver for Bitmain BM1880 SoC"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/clk-fixed-mmio.c b/drivers/clk/clk-fixed-mmio.c index 5225d17d6b3f..b4d51972357e 100644 --- a/drivers/clk/clk-fixed-mmio.c +++ b/drivers/clk/clk-fixed-mmio.c @@ -97,6 +97,3 @@ static struct platform_driver of_fixed_mmio_clk_driver = { }; module_platform_driver(of_fixed_mmio_clk_driver); -MODULE_AUTHOR("Jan Kotas "); -MODULE_DESCRIPTION("Memory Mapped IO Fixed clock driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/clk-fsl-sai.c b/drivers/clk/clk-fsl-sai.c index 6238fcea0467..c2cb71d474d2 100644 --- a/drivers/clk/clk-fsl-sai.c +++ b/drivers/clk/clk-fsl-sai.c @@ -86,7 +86,4 @@ static struct platform_driver fsl_sai_clk_driver = { }; module_platform_driver(fsl_sai_clk_driver); -MODULE_DESCRIPTION("Freescale SAI bitclock-as-a-clock driver"); -MODULE_AUTHOR("Michael Walle "); -MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:fsl-sai-clk"); diff --git a/drivers/clk/hisilicon/clk-hi3559a.c b/drivers/clk/hisilicon/clk-hi3559a.c index 9ea1a80acbe8..f56c837811ae 100644 --- a/drivers/clk/hisilicon/clk-hi3559a.c +++ b/drivers/clk/hisilicon/clk-hi3559a.c @@ -841,5 +841,3 @@ static void __exit hi3559av100_crg_exit(void) module_exit(hi3559av100_crg_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("HiSilicon Hi3559AV100 CRG Driver"); diff --git a/drivers/clk/microchip/clk-mpfs-ccc.c b/drivers/clk/microchip/clk-mpfs-ccc.c index 7be028dced63..cce7d9689859 100644 --- a/drivers/clk/microchip/clk-mpfs-ccc.c +++ b/drivers/clk/microchip/clk-mpfs-ccc.c @@ -285,6 +285,3 @@ static void __exit clk_ccc_exit(void) } module_exit(clk_ccc_exit); -MODULE_DESCRIPTION("Microchip PolarFire SoC Clock Conditioning Circuitry Driver"); -MODULE_AUTHOR("Conor Dooley "); -MODULE_LICENSE("GPL"); diff --git a/drivers/clk/microchip/clk-mpfs.c b/drivers/clk/microchip/clk-mpfs.c index 4f0a19db7ed7..1433e467cab9 100644 --- a/drivers/clk/microchip/clk-mpfs.c +++ b/drivers/clk/microchip/clk-mpfs.c @@ -509,8 +509,3 @@ static void __exit clk_mpfs_exit(void) } module_exit(clk_mpfs_exit); -MODULE_DESCRIPTION("Microchip PolarFire SoC Clock Driver"); -MODULE_AUTHOR("Padmarao Begari "); -MODULE_AUTHOR("Daire McNamara "); -MODULE_AUTHOR("Conor Dooley "); -MODULE_LICENSE("GPL"); diff --git a/drivers/clk/renesas/rcar-usb2-clock-sel.c b/drivers/clk/renesas/rcar-usb2-clock-sel.c index 684d8937965e..2968c9b1aaa5 100644 --- a/drivers/clk/renesas/rcar-usb2-clock-sel.c +++ b/drivers/clk/renesas/rcar-usb2-clock-sel.c @@ -219,5 +219,3 @@ static struct platform_driver rcar_usb2_clock_sel_driver = { }; builtin_platform_driver(rcar_usb2_clock_sel_driver); -MODULE_DESCRIPTION("Renesas R-Car USB2 clock selector Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c index 1a0cdf001b2f..a4f4f1fee9d3 100644 --- a/drivers/clk/renesas/renesas-cpg-mssr.c +++ b/drivers/clk/renesas/renesas-cpg-mssr.c @@ -1153,5 +1153,3 @@ void __init mssr_mod_reparent(struct mssr_mod_clk *mod_clks, } } -MODULE_DESCRIPTION("Renesas CPG/MSSR Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c index 3ff6ecd61756..8f530972ccf7 100644 --- a/drivers/clk/renesas/rzg2l-cpg.c +++ b/drivers/clk/renesas/rzg2l-cpg.c @@ -1430,5 +1430,3 @@ static int __init rzg2l_cpg_init(void) subsys_initcall(rzg2l_cpg_init); -MODULE_DESCRIPTION("Renesas RZ/G2L CPG Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c index ab190dffb1ed..6eaa6620a330 100644 --- a/drivers/clocksource/em_sti.c +++ b/drivers/clocksource/em_sti.c @@ -366,6 +366,3 @@ static void __exit em_sti_exit(void) subsys_initcall(em_sti_init); module_exit(em_sti_exit); -MODULE_AUTHOR("Magnus Damm"); -MODULE_DESCRIPTION("Renesas Emma Mobile STI Timer Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 64dcb082d4cf..cec602c91499 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -1155,6 +1155,3 @@ sh_early_platform_init("earlytimer", &sh_cmt_device_driver); subsys_initcall(sh_cmt_init); module_exit(sh_cmt_exit); -MODULE_AUTHOR("Magnus Damm"); -MODULE_DESCRIPTION("SuperH CMT Timer Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 169a1fccc497..b71d634464c7 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -528,6 +528,3 @@ sh_early_platform_init("earlytimer", &sh_mtu2_device_driver); subsys_initcall(sh_mtu2_init); module_exit(sh_mtu2_exit); -MODULE_AUTHOR("Magnus Damm"); -MODULE_DESCRIPTION("SuperH MTU2 Timer Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index b00dec0655cb..b92f1d3f53e9 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -677,6 +677,3 @@ sh_early_platform_init("earlytimer", &sh_tmu_device_driver); subsys_initcall(sh_tmu_init); module_exit(sh_tmu_exit); -MODULE_AUTHOR("Magnus Damm"); -MODULE_DESCRIPTION("SuperH TMU Timer Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clocksource/timer-stm32-lp.c b/drivers/clocksource/timer-stm32-lp.c index db2841d0beb8..54ab3db7de55 100644 --- a/drivers/clocksource/timer-stm32-lp.c +++ b/drivers/clocksource/timer-stm32-lp.c @@ -217,5 +217,3 @@ static struct platform_driver stm32_clkevent_lp_driver = { module_platform_driver(stm32_clkevent_lp_driver); MODULE_ALIAS("platform:stm32-lptimer-timer"); -MODULE_DESCRIPTION("STMicroelectronics STM32 clockevent low power driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c index ea742889ee06..d87e2ed2c5bf 100644 --- a/drivers/clocksource/timer-tegra186.c +++ b/drivers/clocksource/timer-tegra186.c @@ -509,6 +509,3 @@ static struct platform_driver tegra186_wdt_driver = { }; module_platform_driver(tegra186_wdt_driver); -MODULE_AUTHOR("Thierry Reding "); -MODULE_DESCRIPTION("NVIDIA Tegra186 timers driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c index cad29ded3a48..85842520065f 100644 --- a/drivers/clocksource/timer-ti-dm.c +++ b/drivers/clocksource/timer-ti-dm.c @@ -1265,6 +1265,3 @@ static struct platform_driver omap_dm_timer_driver = { module_platform_driver(omap_dm_timer_driver); -MODULE_DESCRIPTION("OMAP Dual-Mode Timer Driver"); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Texas Instruments Inc"); diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 67e56cf638ef..c34d813e4687 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -365,6 +365,3 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy) return set_freq_table_sorted(policy); } -MODULE_AUTHOR("Dominik Brodowski "); -MODULE_DESCRIPTION("CPUfreq frequency table helpers"); -MODULE_LICENSE("GPL"); diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 6ff73c30769f..518febe0c9f4 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -3526,6 +3526,3 @@ static int __init intel_pstate_setup(char *str) } early_param("intel_pstate", intel_pstate_setup); -MODULE_AUTHOR("Dirk Brandewie "); -MODULE_DESCRIPTION("'intel_pstate' - P state driver Intel Core processors"); -MODULE_LICENSE("GPL"); diff --git a/drivers/cpufreq/tegra124-cpufreq.c b/drivers/cpufreq/tegra124-cpufreq.c index 7a1ea6fdcab6..d41292a87b14 100644 --- a/drivers/cpufreq/tegra124-cpufreq.c +++ b/drivers/cpufreq/tegra124-cpufreq.c @@ -219,6 +219,3 @@ static int __init tegra_cpufreq_init(void) } module_init(tegra_cpufreq_init); -MODULE_AUTHOR("Tuomas Tynkkynen "); -MODULE_DESCRIPTION("cpufreq driver for NVIDIA Tegra124"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 28fb04eccdd0..6d6b92743613 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -403,5 +403,3 @@ static int add_default_cma_heap(void) return ret; } module_init(add_default_cma_heap); -MODULE_DESCRIPTION("DMA-BUF CMA Heap"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index fcf836ba9c1f..1b8d1db6ce23 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -437,4 +437,3 @@ static int system_heap_create(void) return 0; } module_init(system_heap_create); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 2bcdb935a3ac..f3421e56c140 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -398,5 +398,3 @@ static void __exit udmabuf_dev_exit(void) module_init(udmabuf_dev_init) module_exit(udmabuf_dev_exit) -MODULE_AUTHOR("Gerd Hoffmann "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index d19ea885c63e..26c38657a079 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c @@ -1429,6 +1429,3 @@ static int __init ep93xx_dma_module_init(void) } subsys_initcall(ep93xx_dma_module_init); -MODULE_AUTHOR("Mika Westerberg "); -MODULE_DESCRIPTION("EP93xx DMA driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index baab1ca9f621..82a22ee145b1 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c @@ -1796,7 +1796,4 @@ static int __init ipu_init(void) } subsys_initcall(ipu_init); -MODULE_DESCRIPTION("IPU core driver"); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Guennadi Liakhovetski "); MODULE_ALIAS("platform:ipu-core"); diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c index 113834e1167b..c10f9959b7dd 100644 --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c @@ -919,5 +919,3 @@ static struct platform_driver mv_xor_v2_driver = { module_platform_driver(mv_xor_v2_driver); -MODULE_DESCRIPTION("DMA engine driver for Marvell's Version 2 of XOR engine"); -MODULE_LICENSE("GPL"); diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c index a09eeb545f7d..aa10b57560be 100644 --- a/drivers/dma/s3c24xx-dma.c +++ b/drivers/dma/s3c24xx-dma.c @@ -1423,6 +1423,3 @@ bool s3c24xx_dma_filter(struct dma_chan *chan, void *param) } EXPORT_SYMBOL(s3c24xx_dma_filter); -MODULE_DESCRIPTION("S3C24XX DMA Driver"); -MODULE_AUTHOR("Heiko Stuebner"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c index 158e5e7defae..8c3080997f07 100644 --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c @@ -1047,6 +1047,3 @@ static void __exit shdma_exit(void) } module_exit(shdma_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("SH-DMA driver base library"); -MODULE_AUTHOR("Guennadi Liakhovetski "); diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c index ee3cbbf51006..67dafaf85c4b 100644 --- a/drivers/dma/stm32-dmamux.c +++ b/drivers/dma/stm32-dmamux.c @@ -397,7 +397,3 @@ static int __init stm32_dmamux_init(void) } arch_initcall(stm32_dmamux_init); -MODULE_DESCRIPTION("DMA Router driver for STM32 DMA MUX"); -MODULE_AUTHOR("M'boumba Cedric Madianga "); -MODULE_AUTHOR("Pierre-Yves Mordret "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index b9d4c843635f..559576f197e3 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -1813,7 +1813,3 @@ static int __init stm32_mdma_init(void) subsys_initcall(stm32_mdma_init); -MODULE_DESCRIPTION("Driver for STM32 MDMA controller"); -MODULE_AUTHOR("M'boumba Cedric Madianga "); -MODULE_AUTHOR("Pierre-Yves Mordret "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index e7e8e624a436..17e3f788bcf5 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -2226,6 +2226,3 @@ static struct platform_driver altr_edac_a10_driver = { }; module_platform_driver(altr_edac_a10_driver); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Thor Thayer"); -MODULE_DESCRIPTION("EDAC Driver for Altera Memories"); diff --git a/drivers/firmware/broadcom/bcm47xx_nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c index bd235833b687..2f70c8814b73 100644 --- a/drivers/firmware/broadcom/bcm47xx_nvram.c +++ b/drivers/firmware/broadcom/bcm47xx_nvram.c @@ -237,4 +237,3 @@ char *bcm47xx_nvram_get_contents(size_t *nvram_size) } EXPORT_SYMBOL(bcm47xx_nvram_get_contents); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c index dca79caccd01..93d57a3b64fa 100644 --- a/drivers/firmware/imx/imx-scu.c +++ b/drivers/firmware/imx/imx-scu.c @@ -356,6 +356,3 @@ static struct platform_driver imx_scu_driver = { }; builtin_platform_driver(imx_scu_driver); -MODULE_AUTHOR("Dong Aisheng "); -MODULE_DESCRIPTION("IMX SCU firmware protocol driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/firmware/imx/scu-pd.c b/drivers/firmware/imx/scu-pd.c index af3d057e6421..83f7274a3fe5 100644 --- a/drivers/firmware/imx/scu-pd.c +++ b/drivers/firmware/imx/scu-pd.c @@ -418,6 +418,3 @@ static struct platform_driver imx_sc_pd_driver = { }; builtin_platform_driver(imx_sc_pd_driver); -MODULE_AUTHOR("Dong Aisheng "); -MODULE_DESCRIPTION("IMX SCU Power Domain driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpio/gpio-aspeed-sgpio.c b/drivers/gpio/gpio-aspeed-sgpio.c index 454cefbeecf0..e3f656945704 100644 --- a/drivers/gpio/gpio-aspeed-sgpio.c +++ b/drivers/gpio/gpio-aspeed-sgpio.c @@ -608,5 +608,3 @@ static struct platform_driver aspeed_sgpio_driver = { }; module_platform_driver_probe(aspeed_sgpio_driver, aspeed_sgpio_probe); -MODULE_DESCRIPTION("Aspeed Serial GPIO Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/gpio/gpio-imx-scu.c b/drivers/gpio/gpio-imx-scu.c index 17be21b8f3b7..45ce2785d487 100644 --- a/drivers/gpio/gpio-imx-scu.c +++ b/drivers/gpio/gpio-imx-scu.c @@ -134,6 +134,3 @@ static int __init _imx_scu_gpio_init(void) subsys_initcall_sync(_imx_scu_gpio_init); -MODULE_AUTHOR("Shenwei Wang "); -MODULE_DESCRIPTION("NXP GPIO over IMX SCU API"); -MODULE_LICENSE("GPL"); diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c index 7f59e5d936c2..cacee67c0f8f 100644 --- a/drivers/gpio/gpio-mxs.c +++ b/drivers/gpio/gpio-mxs.c @@ -359,9 +359,3 @@ static int __init mxs_gpio_init(void) return platform_driver_register(&mxs_gpio_driver); } postcore_initcall(mxs_gpio_init); - -MODULE_AUTHOR("Freescale Semiconductor, " - "Daniel Mack , " - "Juergen Beisert "); -MODULE_DESCRIPTION("Freescale MXS GPIO"); -MODULE_LICENSE("GPL"); diff --git a/drivers/gpio/gpio-rda.c b/drivers/gpio/gpio-rda.c index 62ba18b3a602..568ba1c3601f 100644 --- a/drivers/gpio/gpio-rda.c +++ b/drivers/gpio/gpio-rda.c @@ -284,6 +284,3 @@ static struct platform_driver rda_gpio_driver = { module_platform_driver_probe(rda_gpio_driver, rda_gpio_probe); -MODULE_DESCRIPTION("RDA Micro GPIO driver"); -MODULE_AUTHOR("Manivannan Sadhasivam "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 3ec02748d56f..d5c0725045c8 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -1292,6 +1292,3 @@ static int __init mipi_dsi_bus_init(void) } postcore_initcall(mipi_dsi_bus_init); -MODULE_AUTHOR("Andrzej Hajda "); -MODULE_DESCRIPTION("MIPI DSI Bus"); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index fd5f5c5a5244..2f32e4706ca8 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -949,6 +949,3 @@ struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, } EXPORT_SYMBOL_GPL(devm_hwspin_lock_request_specific); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Hardware spinlock interface"); -MODULE_AUTHOR("Ohad Ben-Cohen "); diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 25debded65a8..764c92a06e68 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -1144,6 +1144,3 @@ static int __init icc_init(void) device_initcall(icc_init); -MODULE_AUTHOR("Georgi Djakov "); -MODULE_DESCRIPTION("Interconnect Driver Core"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index cd9b74ee24de..a06e9ec880fa 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -997,7 +997,3 @@ static struct platform_driver sun50i_iommu_driver = { }; builtin_platform_driver_probe(sun50i_iommu_driver, sun50i_iommu_probe); -MODULE_DESCRIPTION("Allwinner H6 IOMMU driver"); -MODULE_AUTHOR("Maxime Ripard "); -MODULE_AUTHOR("zhuxianbin "); -MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/irqchip/irq-al-fic.c b/drivers/irqchip/irq-al-fic.c index 886de028a901..0b11f4881afe 100644 --- a/drivers/irqchip/irq-al-fic.c +++ b/drivers/irqchip/irq-al-fic.c @@ -24,9 +24,6 @@ #define NR_FIC_IRQS 32 -MODULE_AUTHOR("Talel Shenhar"); -MODULE_DESCRIPTION("Amazon's Annapurna Labs Interrupt Controller Driver"); -MODULE_LICENSE("GPL v2"); enum al_fic_state { AL_FIC_UNCONFIGURED = 0, diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c index 527c90e0920e..af9feb9beff3 100644 --- a/drivers/irqchip/irq-ls-scfg-msi.c +++ b/drivers/irqchip/irq-ls-scfg-msi.c @@ -428,6 +428,3 @@ static struct platform_driver ls_scfg_msi_driver = { module_platform_driver(ls_scfg_msi_driver); -MODULE_AUTHOR("Minghuan Lian "); -MODULE_DESCRIPTION("Freescale Layerscape SCFG MSI controller driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c index f3faf5c99770..98496aa0311e 100644 --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c @@ -387,7 +387,3 @@ static struct platform_driver mbigen_platform_driver = { module_platform_driver(mbigen_platform_driver); -MODULE_AUTHOR("Jun Ma "); -MODULE_AUTHOR("Yun Wu "); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("HiSilicon MBI Generator driver"); diff --git a/drivers/irqchip/irq-mchp-eic.c b/drivers/irqchip/irq-mchp-eic.c index c726a19837d2..0aa28f4ae03b 100644 --- a/drivers/irqchip/irq-mchp-eic.c +++ b/drivers/irqchip/irq-mchp-eic.c @@ -275,6 +275,3 @@ IRQCHIP_PLATFORM_DRIVER_BEGIN(mchp_eic) IRQCHIP_MATCH("microchip,sama7g5-eic", mchp_eic_init) IRQCHIP_PLATFORM_DRIVER_END(mchp_eic) -MODULE_DESCRIPTION("Microchip External Interrupt Controller"); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Claudiu Beznea "); diff --git a/drivers/irqchip/irq-mvebu-pic.c b/drivers/irqchip/irq-mvebu-pic.c index ef3d3646ccc2..ea541b1fef5b 100644 --- a/drivers/irqchip/irq-mvebu-pic.c +++ b/drivers/irqchip/irq-mvebu-pic.c @@ -193,8 +193,5 @@ static struct platform_driver mvebu_pic_driver = { }; module_platform_driver(mvebu_pic_driver); -MODULE_AUTHOR("Yehuda Yitschak "); -MODULE_AUTHOR("Thomas Petazzoni "); -MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:mvebu_pic"); diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c index e83756aca14e..5eacec89cdb4 100644 --- a/drivers/irqchip/irq-renesas-intc-irqpin.c +++ b/drivers/irqchip/irq-renesas-intc-irqpin.c @@ -606,6 +606,3 @@ static void __exit intc_irqpin_exit(void) } module_exit(intc_irqpin_exit); -MODULE_AUTHOR("Magnus Damm"); -MODULE_DESCRIPTION("Renesas INTC External IRQ Pin Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/irqchip/irq-renesas-irqc.c b/drivers/irqchip/irq-renesas-irqc.c index 1ee5e9941f67..d3e1394dfaa7 100644 --- a/drivers/irqchip/irq-renesas-irqc.c +++ b/drivers/irqchip/irq-renesas-irqc.c @@ -268,6 +268,3 @@ static void __exit irqc_exit(void) } module_exit(irqc_exit); -MODULE_AUTHOR("Magnus Damm"); -MODULE_DESCRIPTION("Renesas IRQC Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/irqchip/irq-renesas-rza1.c b/drivers/irqchip/irq-renesas-rza1.c index 72c06e883d1c..7340868edd9f 100644 --- a/drivers/irqchip/irq-renesas-rza1.c +++ b/drivers/irqchip/irq-renesas-rza1.c @@ -279,6 +279,3 @@ static void __exit rza1_irqc_exit(void) } module_exit(rza1_irqc_exit); -MODULE_AUTHOR("Geert Uytterhoeven "); -MODULE_DESCRIPTION("Renesas RZ/A1 IRQC Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/irqchip/irq-renesas-rzg2l.c b/drivers/irqchip/irq-renesas-rzg2l.c index 25fd8ee66565..80079ac40384 100644 --- a/drivers/irqchip/irq-renesas-rzg2l.c +++ b/drivers/irqchip/irq-renesas-rzg2l.c @@ -388,6 +388,3 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) IRQCHIP_PLATFORM_DRIVER_BEGIN(rzg2l_irqc) IRQCHIP_MATCH("renesas,rzg2l-irqc", rzg2l_irqc_init) IRQCHIP_PLATFORM_DRIVER_END(rzg2l_irqc) -MODULE_AUTHOR("Lad Prabhakar "); -MODULE_DESCRIPTION("Renesas RZ/G2L IRQC Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/irqchip/irq-sl28cpld.c b/drivers/irqchip/irq-sl28cpld.c index fbb354413ffa..24a68af87e59 100644 --- a/drivers/irqchip/irq-sl28cpld.c +++ b/drivers/irqchip/irq-sl28cpld.c @@ -91,6 +91,3 @@ static struct platform_driver sl28cpld_intc_driver = { }; module_platform_driver(sl28cpld_intc_driver); -MODULE_DESCRIPTION("sl28cpld Interrupt Controller Driver"); -MODULE_AUTHOR("Michael Walle "); -MODULE_LICENSE("GPL"); diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c index 5fdbb4358dd0..63f003d36f3e 100644 --- a/drivers/irqchip/irq-ti-sci-inta.c +++ b/drivers/irqchip/irq-ti-sci-inta.c @@ -741,6 +741,3 @@ static struct platform_driver ti_sci_inta_irq_domain_driver = { }; module_platform_driver(ti_sci_inta_irq_domain_driver); -MODULE_AUTHOR("Lokesh Vutla "); -MODULE_DESCRIPTION("K3 Interrupt Aggregator driver over TI SCI protocol"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/irqchip/irq-ti-sci-intr.c b/drivers/irqchip/irq-ti-sci-intr.c index fe8fad22bcf9..2d014fe02530 100644 --- a/drivers/irqchip/irq-ti-sci-intr.c +++ b/drivers/irqchip/irq-ti-sci-intr.c @@ -300,6 +300,3 @@ static struct platform_driver ti_sci_intr_irq_domain_driver = { }; module_platform_driver(ti_sci_intr_irq_domain_driver); -MODULE_AUTHOR("Lokesh Vutla "); -MODULE_DESCRIPTION("K3 Interrupt Router driver over TI SCI protocol"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/leds/leds-asic3.c b/drivers/leds/leds-asic3.c index 8cbc1b8bafa5..5929f3b3f0cb 100644 --- a/drivers/leds/leds-asic3.c +++ b/drivers/leds/leds-asic3.c @@ -171,7 +171,4 @@ static struct platform_driver asic3_led_driver = { module_platform_driver(asic3_led_driver); -MODULE_AUTHOR("Paul Parsons "); -MODULE_DESCRIPTION("HTC ASIC3 LED driver"); -MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:leds-asic3"); diff --git a/drivers/mailbox/rockchip-mailbox.c b/drivers/mailbox/rockchip-mailbox.c index 979acc810f30..c80b2b8a162d 100644 --- a/drivers/mailbox/rockchip-mailbox.c +++ b/drivers/mailbox/rockchip-mailbox.c @@ -256,7 +256,3 @@ static struct platform_driver rockchip_mbox_driver = { module_platform_driver(rockchip_mbox_driver); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Rockchip mailbox: communicate between CPU cores and MCU"); -MODULE_AUTHOR("Addy Ke "); -MODULE_AUTHOR("Caesar Wang "); diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c index 31a0fa914274..68d44ff802b8 100644 --- a/drivers/mailbox/zynqmp-ipi-mailbox.c +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c @@ -716,6 +716,3 @@ static void __exit zynqmp_ipi_exit(void) } module_exit(zynqmp_ipi_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Xilinx ZynqMP IPI Mailbox driver"); -MODULE_AUTHOR("Xilinx Inc."); diff --git a/drivers/memory/bt1-l2-ctl.c b/drivers/memory/bt1-l2-ctl.c index 85965fa26e0b..ecba9881e446 100644 --- a/drivers/memory/bt1-l2-ctl.c +++ b/drivers/memory/bt1-l2-ctl.c @@ -319,6 +319,3 @@ static struct platform_driver l2_ctl_driver = { }; module_platform_driver(l2_ctl_driver); -MODULE_AUTHOR("Serge Semin "); -MODULE_DESCRIPTION("Baikal-T1 L2-cache driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/memory/da8xx-ddrctl.c b/drivers/memory/da8xx-ddrctl.c index b32005bf269c..13c086579932 100644 --- a/drivers/memory/da8xx-ddrctl.c +++ b/drivers/memory/da8xx-ddrctl.c @@ -162,6 +162,3 @@ static struct platform_driver da8xx_ddrctl_driver = { }; module_platform_driver(da8xx_ddrctl_driver); -MODULE_AUTHOR("Bartosz Golaszewski "); -MODULE_DESCRIPTION("TI da8xx DDR2/mDDR controller driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c index e83b61c925a4..4716f344559a 100644 --- a/drivers/memory/fsl_ifc.c +++ b/drivers/memory/fsl_ifc.c @@ -327,6 +327,3 @@ static int __init fsl_ifc_init(void) } subsys_initcall(fsl_ifc_init); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Freescale Semiconductor"); -MODULE_DESCRIPTION("Freescale Integrated Flash Controller driver"); diff --git a/drivers/memory/mvebu-devbus.c b/drivers/memory/mvebu-devbus.c index 8450638e8670..95ec816352dc 100644 --- a/drivers/memory/mvebu-devbus.c +++ b/drivers/memory/mvebu-devbus.c @@ -342,6 +342,3 @@ static int __init mvebu_devbus_init(void) } module_init(mvebu_devbus_init); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Ezequiel Garcia "); -MODULE_DESCRIPTION("Marvell EBU SoC Device Bus controller"); diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c index 2f7a58a9df1a..9f02f72c2825 100644 --- a/drivers/memory/tegra/mc.c +++ b/drivers/memory/tegra/mc.c @@ -958,6 +958,3 @@ static int tegra_mc_init(void) } arch_initcall(tegra_mc_init); -MODULE_AUTHOR("Thierry Reding "); -MODULE_DESCRIPTION("NVIDIA Tegra Memory Controller driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/memory/tegra/tegra186-emc.c b/drivers/memory/tegra/tegra186-emc.c index 54b47ca33483..139d01435ad1 100644 --- a/drivers/memory/tegra/tegra186-emc.c +++ b/drivers/memory/tegra/tegra186-emc.c @@ -291,6 +291,3 @@ static struct platform_driver tegra186_emc_driver = { }; module_platform_driver(tegra186_emc_driver); -MODULE_AUTHOR("Thierry Reding "); -MODULE_DESCRIPTION("NVIDIA Tegra186 External Memory Controller driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index 5dc86dd66202..4997404ed4c6 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c @@ -1276,6 +1276,3 @@ static void __exit pm860x_i2c_exit(void) } module_exit(pm860x_i2c_exit); -MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM860x"); -MODULE_AUTHOR("Haojian Zhuang "); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c index 5d3715a28b28..41fdb1bda3d6 100644 --- a/drivers/mfd/altera-sysmgr.c +++ b/drivers/mfd/altera-sysmgr.c @@ -196,6 +196,3 @@ static void __exit altr_sysmgr_exit(void) } module_exit(altr_sysmgr_exit); -MODULE_AUTHOR("Thor Thayer <>"); -MODULE_DESCRIPTION("SOCFPGA System Manager driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c index 49cd1f03884a..b277825be741 100644 --- a/drivers/mfd/bcm2835-pm.c +++ b/drivers/mfd/bcm2835-pm.c @@ -121,6 +121,3 @@ static struct platform_driver bcm2835_pm_driver = { }; module_platform_driver(bcm2835_pm_driver); -MODULE_AUTHOR("Eric Anholt "); -MODULE_DESCRIPTION("Driver for Broadcom BCM2835 PM MFD"); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c index 3f8f6ad3a98c..34d6df2dd7ca 100644 --- a/drivers/mfd/da903x.c +++ b/drivers/mfd/da903x.c @@ -560,7 +560,3 @@ static void __exit da903x_exit(void) } module_exit(da903x_exit); -MODULE_DESCRIPTION("PMIC Driver for Dialog Semiconductor DA9034"); -MODULE_AUTHOR("Eric Miao "); -MODULE_AUTHOR("Mike Rapoport "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c index 8b42d2f7024f..c7d6dcfd35a4 100644 --- a/drivers/mfd/da9052-core.c +++ b/drivers/mfd/da9052-core.c @@ -651,6 +651,3 @@ void da9052_device_exit(struct da9052 *da9052) da9052_irq_exit(da9052); } -MODULE_AUTHOR("David Dajun Chen "); -MODULE_DESCRIPTION("DA9052 MFD Core"); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c index 5a74696c8704..d964f26698a5 100644 --- a/drivers/mfd/da9052-i2c.c +++ b/drivers/mfd/da9052-i2c.c @@ -207,6 +207,3 @@ static void __exit da9052_i2c_exit(void) } module_exit(da9052_i2c_exit); -MODULE_AUTHOR("David Dajun Chen "); -MODULE_DESCRIPTION("I2C driver for Dialog DA9052 PMIC"); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/da9052-spi.c b/drivers/mfd/da9052-spi.c index b79a57b45c1e..4e18fa1db842 100644 --- a/drivers/mfd/da9052-spi.c +++ b/drivers/mfd/da9052-spi.c @@ -100,6 +100,3 @@ static void __exit da9052_spi_exit(void) } module_exit(da9052_spi_exit); -MODULE_AUTHOR("David Dajun Chen "); -MODULE_DESCRIPTION("SPI driver for Dialog DA9052 PMIC"); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/da9055-core.c b/drivers/mfd/da9055-core.c index c3bcbd8905c6..102a2c17fbfa 100644 --- a/drivers/mfd/da9055-core.c +++ b/drivers/mfd/da9055-core.c @@ -397,6 +397,3 @@ void da9055_device_exit(struct da9055 *da9055) mfd_remove_devices(da9055->dev); } -MODULE_DESCRIPTION("Core support for the DA9055 PMIC"); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("David Dajun Chen "); diff --git a/drivers/mfd/da9055-i2c.c b/drivers/mfd/da9055-i2c.c index 276c7d1c509e..643dec98c9ac 100644 --- a/drivers/mfd/da9055-i2c.c +++ b/drivers/mfd/da9055-i2c.c @@ -96,6 +96,3 @@ static void __exit da9055_i2c_exit(void) } module_exit(da9055_i2c_exit); -MODULE_AUTHOR("David Dajun Chen "); -MODULE_DESCRIPTION("I2C driver for Dialog DA9055 PMIC"); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c index 3d5ce18aa9ae..13127d7b6598 100644 --- a/drivers/mfd/ezx-pcap.c +++ b/drivers/mfd/ezx-pcap.c @@ -528,7 +528,4 @@ static void __exit ezx_pcap_exit(void) subsys_initcall(ezx_pcap_init); module_exit(ezx_pcap_exit); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Daniel Ribeiro / Harald Welte"); -MODULE_DESCRIPTION("Motorola PCAP2 ASIC Driver"); MODULE_ALIAS("spi:ezx-pcap"); diff --git a/drivers/mfd/intel_soc_pmic_crc.c b/drivers/mfd/intel_soc_pmic_crc.c index b1548a933dc3..0cbb990d01bd 100644 --- a/drivers/mfd/intel_soc_pmic_crc.c +++ b/drivers/mfd/intel_soc_pmic_crc.c @@ -270,7 +270,3 @@ static struct i2c_driver crystal_cove_i2c_driver = { module_i2c_driver(crystal_cove_i2c_driver); -MODULE_DESCRIPTION("I2C driver for Intel SoC PMIC"); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Yang, Bin "); -MODULE_AUTHOR("Zhu, Lejun "); diff --git a/drivers/mfd/lp8788.c b/drivers/mfd/lp8788.c index 724a5712b36b..4f85864b9511 100644 --- a/drivers/mfd/lp8788.c +++ b/drivers/mfd/lp8788.c @@ -242,6 +242,3 @@ static void __exit lp8788_exit(void) } module_exit(lp8788_exit); -MODULE_DESCRIPTION("TI LP8788 MFD Driver"); -MODULE_AUTHOR("Milo Kim"); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 787d2ae86375..1d423cb01337 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c @@ -850,11 +850,7 @@ static struct platform_driver usbhs_omap_driver = { .remove = usbhs_omap_remove, }; -MODULE_AUTHOR("Keshava Munegowda "); -MODULE_AUTHOR("Roger Quadros "); MODULE_ALIAS("platform:" USBHS_DRIVER_NAME); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("usb host common core driver for omap EHCI and OHCI"); static int omap_usbhs_drvinit(void) { diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c index 080d7970a377..5e5d077ac0c9 100644 --- a/drivers/mfd/omap-usb-tll.c +++ b/drivers/mfd/omap-usb-tll.c @@ -448,10 +448,6 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata) } EXPORT_SYMBOL_GPL(omap_tll_disable); -MODULE_AUTHOR("Keshava Munegowda "); -MODULE_AUTHOR("Roger Quadros "); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("usb tll driver for TI OMAP EHCI and OHCI controllers"); static int __init omap_usbtll_drvinit(void) { diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index 8b7429bd2e3e..b677e38de7bb 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c @@ -750,6 +750,3 @@ static void __exit palmas_i2c_exit(void) } module_exit(palmas_i2c_exit); -MODULE_AUTHOR("Graeme Gregory "); -MODULE_DESCRIPTION("Palmas chip family multi-function driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c index 4d55494a97c4..51da3a632adb 100644 --- a/drivers/mfd/stmpe-i2c.c +++ b/drivers/mfd/stmpe-i2c.c @@ -136,6 +136,3 @@ static void __exit stmpe_exit(void) } module_exit(stmpe_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("STMPE MFD I2C Interface Driver"); -MODULE_AUTHOR("Rabin Vincent "); diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c index ad8055a0e286..98ee83f90d1a 100644 --- a/drivers/mfd/stmpe-spi.c +++ b/drivers/mfd/stmpe-spi.c @@ -156,6 +156,3 @@ static void __exit stmpe_exit(void) } module_exit(stmpe_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("STMPE MFD SPI Interface Driver"); -MODULE_AUTHOR("Viresh Kumar "); diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index d5d0ec117acb..f425f7a6d169 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c @@ -503,6 +503,3 @@ static void __exit tc3589x_exit(void) } module_exit(tc3589x_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("TC3589x MFD core driver"); -MODULE_AUTHOR("Hanumath Prasad, Rabin Vincent"); diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index fb340da64bbc..97b32236ef15 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c @@ -641,6 +641,3 @@ static void __exit tps6586x_exit(void) } module_exit(tps6586x_exit); -MODULE_DESCRIPTION("TPS6586X core driver"); -MODULE_AUTHOR("Mike Rapoport "); -MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c index 4536d829b43e..ed96b52cd799 100644 --- a/drivers/mfd/twl4030-audio.c +++ b/drivers/mfd/twl4030-audio.c @@ -283,7 +283,4 @@ static struct platform_driver twl4030_audio_driver = { module_platform_driver(twl4030_audio_driver); -MODULE_AUTHOR("Peter Ujfalusi "); -MODULE_DESCRIPTION("TWL4030 audio block MFD driver"); -MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:twl4030-audio"); diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c index f429b8f00db6..5db429eafbb0 100644 --- a/drivers/mfd/twl6040.c +++ b/drivers/mfd/twl6040.c @@ -840,7 +840,3 @@ static struct i2c_driver twl6040_driver = { module_i2c_driver(twl6040_driver); -MODULE_DESCRIPTION("TWL6040 MFD"); -MODULE_AUTHOR("Misael Lopez Cruz "); -MODULE_AUTHOR("Jorge Eduardo Candelaria "); -MODULE_LICENSE("GPL"); diff --git a/drivers/mtd/parsers/bcm63xxpart.c b/drivers/mtd/parsers/bcm63xxpart.c index b15bdadaedb5..f252e3eb017f 100644 --- a/drivers/mtd/parsers/bcm63xxpart.c +++ b/drivers/mtd/parsers/bcm63xxpart.c @@ -164,9 +164,3 @@ static struct mtd_part_parser bcm63xx_cfe_parser = { }; module_mtd_part_parser(bcm63xx_cfe_parser); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Daniel Dickinson "); -MODULE_AUTHOR("Florian Fainelli "); -MODULE_AUTHOR("Mike Albon "); -MODULE_AUTHOR("Jonas Gorski , Nava kishore Manne "); -MODULE_DESCRIPTION("ZynqMP NVMEM driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/pci/controller/dwc/pcie-histb.c b/drivers/pci/controller/dwc/pcie-histb.c index e2b80f10030d..2db5bc06d1be 100644 --- a/drivers/pci/controller/dwc/pcie-histb.c +++ b/drivers/pci/controller/dwc/pcie-histb.c @@ -450,5 +450,3 @@ static struct platform_driver histb_pcie_platform_driver = { }; module_platform_driver(histb_pcie_platform_driver); -MODULE_DESCRIPTION("HiSilicon STB PCIe host controller driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c b/drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c index f6fcd95c2bf5..704bca668f76 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c @@ -56,6 +56,3 @@ static struct platform_driver mobiveil_pcie_driver = { builtin_platform_driver(mobiveil_pcie_driver); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Mobiveil PCIe host controller driver"); -MODULE_AUTHOR("Subrahmanya Lingappa "); diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c index 8e323e93be91..378e56e9d414 100644 --- a/drivers/pci/controller/pci-tegra.c +++ b/drivers/pci/controller/pci-tegra.c @@ -2813,4 +2813,3 @@ static struct platform_driver tegra_pcie_driver = { .remove = tegra_pcie_remove, }; module_platform_driver(tegra_pcie_driver); -MODULE_LICENSE("GPL"); diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c index 7991d334e0f1..73ca239096cc 100644 --- a/drivers/pci/controller/pci-versatile.c +++ b/drivers/pci/controller/pci-versatile.c @@ -168,5 +168,3 @@ static struct platform_driver versatile_pci_driver = { }; module_platform_driver(versatile_pci_driver); -MODULE_DESCRIPTION("Versatile PCI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/controller/pcie-hisi-error.c b/drivers/pci/controller/pcie-hisi-error.c index 7959c9c8d2bc..6866bc42da1b 100644 --- a/drivers/pci/controller/pcie-hisi-error.c +++ b/drivers/pci/controller/pcie-hisi-error.c @@ -323,5 +323,3 @@ static struct platform_driver hisi_pcie_error_handler_driver = { }; module_platform_driver(hisi_pcie_error_handler_driver); -MODULE_DESCRIPTION("HiSilicon HIP PCIe controller error handling driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c index 7263d175b5ad..b424bb1d13f5 100644 --- a/drivers/pci/controller/pcie-microchip-host.c +++ b/drivers/pci/controller/pcie-microchip-host.c @@ -1135,6 +1135,3 @@ static struct platform_driver mc_pcie_driver = { }; builtin_platform_driver(mc_pcie_driver); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Microchip PCIe host controller driver"); -MODULE_AUTHOR("Daire McNamara "); diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index d4850bdd837f..bb5c30cbdc2a 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -726,6 +726,3 @@ static void __exit pci_ep_cfs_exit(void) } module_exit(pci_ep_cfs_exit); -MODULE_DESCRIPTION("PCI EP CONFIGFS"); -MODULE_AUTHOR("Kishon Vijay Abraham I "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 3bc9273d0a08..e68c663a2072 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -854,6 +854,3 @@ static void __exit pci_epc_exit(void) } module_exit(pci_epc_exit); -MODULE_DESCRIPTION("PCI EPC Library"); -MODULE_AUTHOR("Kishon Vijay Abraham I "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/endpoint/pci-epc-mem.c b/drivers/pci/endpoint/pci-epc-mem.c index a97b56a6d2db..2353249311ad 100644 --- a/drivers/pci/endpoint/pci-epc-mem.c +++ b/drivers/pci/endpoint/pci-epc-mem.c @@ -258,6 +258,3 @@ void pci_epc_mem_free_addr(struct pci_epc *epc, phys_addr_t phys_addr, } EXPORT_SYMBOL_GPL(pci_epc_mem_free_addr); -MODULE_DESCRIPTION("PCI EPC Address Space Management"); -MODULE_AUTHOR("Kishon Vijay Abraham I "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 9ed556936f48..682a69be2040 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -566,6 +566,3 @@ static void __exit pci_epf_exit(void) } module_exit(pci_epf_exit); -MODULE_DESCRIPTION("PCI EPF Library"); -MODULE_AUTHOR("Kishon Vijay Abraham I "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 853e04ad272c..fd8b98c5641a 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c @@ -43,9 +43,6 @@ static struct acpiphp_attention_info *attention_info; #define DRIVER_AUTHOR "Greg Kroah-Hartman , Takayoshi Kochi , Matthew Wilcox " #define DRIVER_DESC "ACPI Hot Plug PCI Controller Driver" -MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL"); MODULE_PARM_DESC(disable, "disable acpiphp driver"); module_param_named(disable, acpiphp_disabled, bool, 0444); diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 53692b048301..7610a3f6fb5a 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c @@ -30,9 +30,6 @@ int shpchp_poll_time; #define DRIVER_AUTHOR "Dan Zink , Greg Kroah-Hartman , Dely Sy " #define DRIVER_DESC "Standard Hot Plug PCI Controller Driver" -MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL"); module_param(shpchp_debug, bool, 0644); module_param(shpchp_poll_mode, bool, 0644); diff --git a/drivers/perf/apple_m1_cpu_pmu.c b/drivers/perf/apple_m1_cpu_pmu.c index 979a7c2b4f56..7123beeb992f 100644 --- a/drivers/perf/apple_m1_cpu_pmu.c +++ b/drivers/perf/apple_m1_cpu_pmu.c @@ -581,4 +581,3 @@ static struct platform_driver m1_pmu_driver = { }; module_platform_driver(m1_pmu_driver); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/phy/intel/phy-intel-lgm-combo.c b/drivers/phy/intel/phy-intel-lgm-combo.c index 6010e246d52e..a15e73f5b1b2 100644 --- a/drivers/phy/intel/phy-intel-lgm-combo.c +++ b/drivers/phy/intel/phy-intel-lgm-combo.c @@ -615,5 +615,3 @@ static struct platform_driver intel_cbphy_driver = { module_platform_driver(intel_cbphy_driver); -MODULE_DESCRIPTION("Intel Combo-phy driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pinctrl/actions/pinctrl-s500.c b/drivers/pinctrl/actions/pinctrl-s500.c index ced778079b76..c944c68f22a8 100644 --- a/drivers/pinctrl/actions/pinctrl-s500.c +++ b/drivers/pinctrl/actions/pinctrl-s500.c @@ -1721,7 +1721,3 @@ static void __exit s500_pinctrl_exit(void) } module_exit(s500_pinctrl_exit); -MODULE_AUTHOR("Actions Semi Inc."); -MODULE_AUTHOR("Cristian Ciocaltea "); -MODULE_DESCRIPTION("Actions Semi S500 SoC Pinctrl Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/pinctrl/actions/pinctrl-s700.c b/drivers/pinctrl/actions/pinctrl-s700.c index fd00940a5799..391aaabdd527 100644 --- a/drivers/pinctrl/actions/pinctrl-s700.c +++ b/drivers/pinctrl/actions/pinctrl-s700.c @@ -1906,6 +1906,3 @@ static void __exit s700_pinctrl_exit(void) } module_exit(s700_pinctrl_exit); -MODULE_AUTHOR("Actions Semi Inc."); -MODULE_DESCRIPTION("Actions Semi S700 Soc Pinctrl Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/pinctrl/actions/pinctrl-s900.c b/drivers/pinctrl/actions/pinctrl-s900.c index 811249a8011e..baddcf15005c 100644 --- a/drivers/pinctrl/actions/pinctrl-s900.c +++ b/drivers/pinctrl/actions/pinctrl-s900.c @@ -1824,7 +1824,3 @@ static void __exit s900_pinctrl_exit(void) } module_exit(s900_pinctrl_exit); -MODULE_AUTHOR("Actions Semi Inc."); -MODULE_AUTHOR("Manivannan Sadhasivam "); -MODULE_DESCRIPTION("Actions Semi S900 SoC Pinctrl Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/pinctrl/bcm/pinctrl-ns.c b/drivers/pinctrl/bcm/pinctrl-ns.c index 465cc96814a1..62879fadf2f0 100644 --- a/drivers/pinctrl/bcm/pinctrl-ns.c +++ b/drivers/pinctrl/bcm/pinctrl-ns.c @@ -298,6 +298,4 @@ static struct platform_driver ns_pinctrl_driver = { module_platform_driver(ns_pinctrl_driver); -MODULE_AUTHOR("Rafał Miłecki"); -MODULE_LICENSE("GPL v2"); MODULE_DEVICE_TABLE(of, ns_pinctrl_of_match_table); diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8188.c b/drivers/pinctrl/mediatek/pinctrl-mt8188.c index d0e75c1b4417..3d811d83110a 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8188.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8188.c @@ -1669,5 +1669,3 @@ static int __init mt8188_pinctrl_init(void) arch_initcall(mt8188_pinctrl_init); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("MediaTek MT8188 Pinctrl Driver"); diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8192.c b/drivers/pinctrl/mediatek/pinctrl-mt8192.c index 78c02b7c81f0..5204d87de9d3 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8192.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8192.c @@ -1430,5 +1430,3 @@ static int __init mt8192_pinctrl_init(void) } arch_initcall(mt8192_pinctrl_init); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("MediaTek MT8192 Pinctrl Driver"); diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8365.c b/drivers/pinctrl/mediatek/pinctrl-mt8365.c index 57f37a294063..b591c54b5894 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8365.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8365.c @@ -476,6 +476,3 @@ static int __init mtk_pinctrl_init(void) } arch_initcall(mtk_pinctrl_init); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("MediaTek MT8365 Pinctrl Driver"); -MODULE_AUTHOR("Zhiyong Tao "); diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c index 1c4e89b046de..2d95765e3b54 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c @@ -2043,7 +2043,3 @@ static int __init npcm7xx_pinctrl_register(void) } arch_initcall(npcm7xx_pinctrl_register); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("jordan_hargrave@dell.com"); -MODULE_AUTHOR("tomer.maimon@nuvoton.com"); -MODULE_DESCRIPTION("Nuvoton NPCM7XX Pinctrl and GPIO driver"); diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index 6be896871718..215a4aab1283 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -1203,6 +1203,3 @@ static struct platform_driver amd_gpio_driver = { module_platform_driver(amd_gpio_driver); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Ken Xue , Jeff Wu "); -MODULE_DESCRIPTION("AMD GPIO pinctrl driver"); diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c index 529c0fc4ec06..111eaf8951f8 100644 --- a/drivers/pinctrl/renesas/pinctrl-rza1.c +++ b/drivers/pinctrl/renesas/pinctrl-rza1.c @@ -1405,6 +1405,3 @@ static int __init rza1_pinctrl_init(void) } core_initcall(rza1_pinctrl_init); -MODULE_AUTHOR("Jacopo Mondi "); -MODULE_DESCRIPTION("Pin and gpio controller driver for RZ/A2 SoC"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index a43824fd9505..2f90c1fa52ee 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -1557,6 +1557,3 @@ static int __init rzg2l_pinctrl_init(void) } core_initcall(rzg2l_pinctrl_init); -MODULE_AUTHOR("Lad Prabhakar "); -MODULE_DESCRIPTION("Pin and gpio controller driver for RZ/G2L family"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pinctrl/renesas/pinctrl-rzn1.c b/drivers/pinctrl/renesas/pinctrl-rzn1.c index 849d091205d4..bd60a640b6a3 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzn1.c +++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c @@ -946,6 +946,3 @@ static int __init _pinctrl_drv_register(void) } subsys_initcall(_pinctrl_drv_register); -MODULE_AUTHOR("Phil Edworthy "); -MODULE_DESCRIPTION("Renesas RZ/N1 pinctrl driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c index e8c18198bebd..dbd842edcce8 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c +++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c @@ -1114,6 +1114,3 @@ static int __init rzv2m_pinctrl_init(void) } core_initcall(rzv2m_pinctrl_init); -MODULE_AUTHOR("Phil Edworthy "); -MODULE_DESCRIPTION("Pin and gpio controller driver for RZ/V2M"); -MODULE_LICENSE("GPL"); diff --git a/drivers/power/reset/as3722-poweroff.c b/drivers/power/reset/as3722-poweroff.c index 661e1c67f82e..a2182470a5e1 100644 --- a/drivers/power/reset/as3722-poweroff.c +++ b/drivers/power/reset/as3722-poweroff.c @@ -81,7 +81,4 @@ static struct platform_driver as3722_poweroff_driver = { module_platform_driver(as3722_poweroff_driver); -MODULE_DESCRIPTION("Power off driver for ams AS3722 PMIC Device"); MODULE_ALIAS("platform:as3722-power-off"); -MODULE_AUTHOR("Laxman Dewangan "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c index 1c5af2fef142..b6c5cce9fe6c 100644 --- a/drivers/power/reset/gpio-poweroff.c +++ b/drivers/power/reset/gpio-poweroff.c @@ -103,7 +103,4 @@ static struct platform_driver gpio_poweroff_driver = { module_platform_driver(gpio_poweroff_driver); -MODULE_AUTHOR("Jamie Lentin "); -MODULE_DESCRIPTION("GPIO poweroff driver"); -MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:poweroff-gpio"); diff --git a/drivers/power/reset/gpio-restart.c b/drivers/power/reset/gpio-restart.c index 5466eeea261c..ee6ba7313e0e 100644 --- a/drivers/power/reset/gpio-restart.c +++ b/drivers/power/reset/gpio-restart.c @@ -137,6 +137,3 @@ static struct platform_driver gpio_restart_driver = { module_platform_driver(gpio_restart_driver); -MODULE_AUTHOR("David Riley "); -MODULE_DESCRIPTION("GPIO restart driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/power/reset/keystone-reset.c b/drivers/power/reset/keystone-reset.c index c720112db704..cfacee839b10 100644 --- a/drivers/power/reset/keystone-reset.c +++ b/drivers/power/reset/keystone-reset.c @@ -167,7 +167,4 @@ static struct platform_driver rsctrl_driver = { }; module_platform_driver(rsctrl_driver); -MODULE_AUTHOR("Ivan Khoronzhuk "); -MODULE_DESCRIPTION("Texas Instruments keystone reset driver"); -MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" KBUILD_MODNAME); diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c index 65d9528cc989..087533bfc752 100644 --- a/drivers/power/reset/ltc2952-poweroff.c +++ b/drivers/power/reset/ltc2952-poweroff.c @@ -315,6 +315,3 @@ static struct platform_driver ltc2952_poweroff_driver = { module_platform_driver(ltc2952_poweroff_driver); -MODULE_AUTHOR("René Moll "); -MODULE_DESCRIPTION("LTC PowerPath power-off driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c index d90e76fcb938..97e9de37bf07 100644 --- a/drivers/power/reset/mt6323-poweroff.c +++ b/drivers/power/reset/mt6323-poweroff.c @@ -95,6 +95,3 @@ static struct platform_driver mt6323_pwrc_driver = { module_platform_driver(mt6323_pwrc_driver); -MODULE_DESCRIPTION("Poweroff driver for MT6323 PMIC"); -MODULE_AUTHOR("Sean Wang "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/power/reset/regulator-poweroff.c b/drivers/power/reset/regulator-poweroff.c index 20701203935f..4787829875d4 100644 --- a/drivers/power/reset/regulator-poweroff.c +++ b/drivers/power/reset/regulator-poweroff.c @@ -77,7 +77,4 @@ static struct platform_driver regulator_poweroff_driver = { module_platform_driver(regulator_poweroff_driver); -MODULE_AUTHOR("Michael Klein "); -MODULE_DESCRIPTION("Regulator poweroff driver"); -MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:poweroff-regulator"); diff --git a/drivers/power/reset/restart-poweroff.c b/drivers/power/reset/restart-poweroff.c index 04d4228119b2..7adc454658ff 100644 --- a/drivers/power/reset/restart-poweroff.c +++ b/drivers/power/reset/restart-poweroff.c @@ -57,7 +57,4 @@ static struct platform_driver restart_poweroff_driver = { }; module_platform_driver(restart_poweroff_driver); -MODULE_AUTHOR("Andrew Lunn "); -MODULE_DESCRIPTION("TPS65086 restart driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 4b5fb172fa99..b253fc0e401f 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1569,9 +1569,3 @@ static void __exit power_supply_class_exit(void) subsys_initcall(power_supply_class_init); module_exit(power_supply_class_exit); - -MODULE_DESCRIPTION("Universal power supply monitor class"); -MODULE_AUTHOR("Ian Molton , " - "Szabolcs Gyurko, " - "Anton Vorontsov "); -MODULE_LICENSE("GPL"); diff --git a/drivers/power/supply/wm97xx_battery.c b/drivers/power/supply/wm97xx_battery.c index a0e1eaa25d93..73d9f7dc4945 100644 --- a/drivers/power/supply/wm97xx_battery.c +++ b/drivers/power/supply/wm97xx_battery.c @@ -271,6 +271,3 @@ static struct platform_driver wm97xx_bat_driver = { module_platform_driver(wm97xx_bat_driver); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Marek Vasut "); -MODULE_DESCRIPTION("WM97xx battery driver"); diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c index f0654a932b37..73246663d614 100644 --- a/drivers/powercap/powercap_sys.c +++ b/drivers/powercap/powercap_sys.c @@ -672,6 +672,3 @@ static int __init powercap_init(void) fs_initcall(powercap_init); -MODULE_DESCRIPTION("PowerCap sysfs Driver"); -MODULE_AUTHOR("Srinivas Pandruvada "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c index 2a42acb7c24e..42e3a8860abc 100644 --- a/drivers/regulator/stm32-pwr.c +++ b/drivers/regulator/stm32-pwr.c @@ -181,6 +181,3 @@ static struct platform_driver stm32_pwr_driver = { }; module_platform_driver(stm32_pwr_driver); -MODULE_DESCRIPTION("STM32MP1 PWR voltage regulator driver"); -MODULE_AUTHOR("Pascal Paillet "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8768cb64f560..1e2dac5e54ea 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2752,5 +2752,3 @@ static void __exit remoteproc_exit(void) } module_exit(remoteproc_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Generic Remote Processor Framework"); diff --git a/drivers/reset/reset-axs10x.c b/drivers/reset/reset-axs10x.c index a854ef41364d..4f9bce547988 100644 --- a/drivers/reset/reset-axs10x.c +++ b/drivers/reset/reset-axs10x.c @@ -79,6 +79,3 @@ static struct platform_driver axs10x_reset_driver = { }; builtin_platform_driver(axs10x_reset_driver); -MODULE_AUTHOR("Eugeniy Paltsev "); -MODULE_DESCRIPTION("Synopsys AXS10x reset driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c index 4c7b8647b49c..8b88aca4c4a4 100644 --- a/drivers/reset/reset-hsdk.c +++ b/drivers/reset/reset-hsdk.c @@ -133,6 +133,3 @@ static struct platform_driver hsdk_reset_driver = { }; builtin_platform_driver(hsdk_reset_driver); -MODULE_AUTHOR("Eugeniy Paltsev "); -MODULE_DESCRIPTION("Synopsys HSDK SDP reset driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/reset/reset-lantiq.c b/drivers/reset/reset-lantiq.c index b936cfe85641..2ca9bd5930b8 100644 --- a/drivers/reset/reset-lantiq.c +++ b/drivers/reset/reset-lantiq.c @@ -205,6 +205,3 @@ static struct platform_driver lantiq_rcu_reset_driver = { }; module_platform_driver(lantiq_rcu_reset_driver); -MODULE_AUTHOR("Martin Blumenstingl "); -MODULE_DESCRIPTION("Lantiq XWAY RCU Reset Controller Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/reset/reset-microchip-sparx5.c b/drivers/reset/reset-microchip-sparx5.c index f3528dd1d084..47b9b43470a0 100644 --- a/drivers/reset/reset-microchip-sparx5.c +++ b/drivers/reset/reset-microchip-sparx5.c @@ -177,6 +177,3 @@ static int __init mchp_sparx5_reset_init(void) */ postcore_initcall(mchp_sparx5_reset_init); -MODULE_DESCRIPTION("Microchip Sparx5 switch reset driver"); -MODULE_AUTHOR("Steen Hegelund "); -MODULE_LICENSE("Dual MIT/GPL"); diff --git a/drivers/reset/reset-mpfs.c b/drivers/reset/reset-mpfs.c index e003e50590ec..0735076f3c84 100644 --- a/drivers/reset/reset-mpfs.c +++ b/drivers/reset/reset-mpfs.c @@ -151,7 +151,4 @@ static struct auxiliary_driver mpfs_reset_driver = { module_auxiliary_driver(mpfs_reset_driver); -MODULE_DESCRIPTION("Microchip PolarFire SoC Reset Driver"); -MODULE_AUTHOR("Conor Dooley "); -MODULE_LICENSE("GPL"); MODULE_IMPORT_NS(MCHP_CLK_MPFS); diff --git a/drivers/soc/apple/apple-pmgr-pwrstate.c b/drivers/soc/apple/apple-pmgr-pwrstate.c index e1122288409a..968272e7a38a 100644 --- a/drivers/soc/apple/apple-pmgr-pwrstate.c +++ b/drivers/soc/apple/apple-pmgr-pwrstate.c @@ -317,8 +317,5 @@ static struct platform_driver apple_pmgr_ps_driver = { }, }; -MODULE_AUTHOR("Hector Martin "); -MODULE_DESCRIPTION("PMGR power state driver for Apple SoCs"); -MODULE_LICENSE("GPL v2"); module_platform_driver(apple_pmgr_ps_driver); diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c index 5bcd047768b6..6ff7a4612c18 100644 --- a/drivers/soc/bcm/bcm2835-power.c +++ b/drivers/soc/bcm/bcm2835-power.c @@ -715,6 +715,3 @@ static struct platform_driver bcm2835_power_driver = { }; module_platform_driver(bcm2835_power_driver); -MODULE_AUTHOR("Eric Anholt "); -MODULE_DESCRIPTION("Driver for Broadcom BCM2835 PM power domains and reset"); -MODULE_LICENSE("GPL"); diff --git a/drivers/soc/bcm/raspberrypi-power.c b/drivers/soc/bcm/raspberrypi-power.c index 068715d6e66d..40b05ea991a2 100644 --- a/drivers/soc/bcm/raspberrypi-power.c +++ b/drivers/soc/bcm/raspberrypi-power.c @@ -240,7 +240,3 @@ static struct platform_driver rpi_power_driver = { }; builtin_platform_driver(rpi_power_driver); -MODULE_AUTHOR("Alexander Aring "); -MODULE_AUTHOR("Eric Anholt "); -MODULE_DESCRIPTION("Raspberry Pi power domain driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/soc/fujitsu/a64fx-diag.c b/drivers/soc/fujitsu/a64fx-diag.c index d87f348427bf..84ee52116cdb 100644 --- a/drivers/soc/fujitsu/a64fx-diag.c +++ b/drivers/soc/fujitsu/a64fx-diag.c @@ -149,6 +149,3 @@ static struct platform_driver a64fx_diag_driver = { module_platform_driver(a64fx_diag_driver); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Hitomi Hasegawa "); -MODULE_DESCRIPTION("A64FX diag driver"); diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c index 92f9186c1c42..d704c9d7eac6 100644 --- a/drivers/soc/sunxi/sunxi_sram.c +++ b/drivers/soc/sunxi/sunxi_sram.c @@ -419,6 +419,3 @@ static struct platform_driver sunxi_sram_driver = { }; builtin_platform_driver_probe(sunxi_sram_driver, sunxi_sram_probe); -MODULE_AUTHOR("Maxime Ripard "); -MODULE_DESCRIPTION("Allwinner sunXi SRAM Controller Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/soc/tegra/cbb/tegra194-cbb.c b/drivers/soc/tegra/cbb/tegra194-cbb.c index 1ae0bd9a1ac1..0fb96b72735d 100644 --- a/drivers/soc/tegra/cbb/tegra194-cbb.c +++ b/drivers/soc/tegra/cbb/tegra194-cbb.c @@ -2359,6 +2359,3 @@ static void __exit tegra194_cbb_exit(void) } module_exit(tegra194_cbb_exit); -MODULE_AUTHOR("Sumit Gupta "); -MODULE_DESCRIPTION("Control Backbone error handling driver for Tegra194"); -MODULE_LICENSE("GPL"); diff --git a/drivers/soc/tegra/cbb/tegra234-cbb.c b/drivers/soc/tegra/cbb/tegra234-cbb.c index 3528f9e15d5c..69fdd547eb3d 100644 --- a/drivers/soc/tegra/cbb/tegra234-cbb.c +++ b/drivers/soc/tegra/cbb/tegra234-cbb.c @@ -1109,5 +1109,3 @@ static void __exit tegra234_cbb_exit(void) } module_exit(tegra234_cbb_exit); -MODULE_DESCRIPTION("Control Backbone 2.0 error handling driver for Tegra234"); -MODULE_LICENSE("GPL"); diff --git a/drivers/tty/n_null.c b/drivers/tty/n_null.c index f913b665af72..d8719740bd11 100644 --- a/drivers/tty/n_null.c +++ b/drivers/tty/n_null.c @@ -63,7 +63,4 @@ static void __exit n_null_exit(void) module_init(n_null_init); module_exit(n_null_exit); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Alan Cox"); MODULE_ALIAS_LDISC(N_NULL); -MODULE_DESCRIPTION("Null ldisc driver"); diff --git a/drivers/tty/serial/imx_earlycon.c b/drivers/tty/serial/imx_earlycon.c index 7aab38b2bd8c..e1f6e117c4c0 100644 --- a/drivers/tty/serial/imx_earlycon.c +++ b/drivers/tty/serial/imx_earlycon.c @@ -45,6 +45,3 @@ imx_console_early_setup(struct earlycon_device *dev, const char *opt) OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup); OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup); -MODULE_AUTHOR("NXP"); -MODULE_DESCRIPTION("IMX earlycon driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/tty/serial/rda-uart.c b/drivers/tty/serial/rda-uart.c index 0e387e2144fa..2fe38d6e513c 100644 --- a/drivers/tty/serial/rda-uart.c +++ b/drivers/tty/serial/rda-uart.c @@ -824,6 +824,3 @@ static void __exit rda_uart_exit(void) module_init(rda_uart_init); module_exit(rda_uart_exit); -MODULE_AUTHOR("Manivannan Sadhasivam "); -MODULE_DESCRIPTION("RDA8810PL serial device driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index fcdf017e2665..8e13af1f9042 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1204,4 +1204,3 @@ const struct consw vga_con = { }; EXPORT_SYMBOL(vga_con); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/asiliantfb.c b/drivers/video/fbdev/asiliantfb.c index 3818437a8f69..f1992da7e64e 100644 --- a/drivers/video/fbdev/asiliantfb.c +++ b/drivers/video/fbdev/asiliantfb.c @@ -629,4 +629,3 @@ static void __exit asiliantfb_exit(void) pci_unregister_driver(&asiliantfb_driver); } -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c index 000b4aa44241..39e89b9f8dca 100644 --- a/drivers/video/fbdev/gbefb.c +++ b/drivers/video/fbdev/gbefb.c @@ -1285,4 +1285,3 @@ static void __exit gbefb_exit(void) module_init(gbefb_init); module_exit(gbefb_exit); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index d7edb9c5d3a3..39562b0449a0 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1631,7 +1631,6 @@ static void __exit imsttfb_exit(void) pci_unregister_driver(&imsttfb_pci_driver); } -MODULE_LICENSE("GPL"); module_init(imsttfb_init); module_exit(imsttfb_exit); diff --git a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c index a9df8ee79810..531db18df108 100644 --- a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c +++ b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c @@ -574,6 +574,3 @@ static int mmphw_init(void) } module_init(mmphw_init); -MODULE_AUTHOR("Li Guoqing"); -MODULE_DESCRIPTION("Framebuffer driver for mmp"); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c b/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c index 34fae588e202..1b6bf02b1d70 100644 --- a/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c +++ b/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c @@ -167,6 +167,3 @@ static struct spi_driver panel_tpohvga_driver = { }; module_spi_driver(panel_tpohvga_driver); -MODULE_AUTHOR("Lisa Du"); -MODULE_DESCRIPTION("Panel driver for tpohvga"); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c index 929d4775cb4b..73b35fc67d8b 100644 --- a/drivers/video/fbdev/vesafb.c +++ b/drivers/video/fbdev/vesafb.c @@ -508,4 +508,3 @@ static struct platform_driver vesafb_driver = { }; module_platform_driver(vesafb_driver); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/wm8505fb.c b/drivers/video/fbdev/wm8505fb.c index 8f4d674fa0d0..373d6d35845d 100644 --- a/drivers/video/fbdev/wm8505fb.c +++ b/drivers/video/fbdev/wm8505fb.c @@ -405,7 +405,4 @@ static struct platform_driver wm8505fb_driver = { module_platform_driver(wm8505fb_driver); -MODULE_AUTHOR("Ed Spiridonov "); -MODULE_DESCRIPTION("Framebuffer driver for WMT WM8505"); -MODULE_LICENSE("GPL v2"); MODULE_DEVICE_TABLE(of, wmt_dt_ids); diff --git a/drivers/video/fbdev/wmt_ge_rops.c b/drivers/video/fbdev/wmt_ge_rops.c index 42255d27a1db..922ec9b15da3 100644 --- a/drivers/video/fbdev/wmt_ge_rops.c +++ b/drivers/video/fbdev/wmt_ge_rops.c @@ -167,8 +167,4 @@ static struct platform_driver wmt_ge_rops_driver = { module_platform_driver(wmt_ge_rops_driver); -MODULE_AUTHOR("Alexey Charkov "); -MODULE_DESCRIPTION("Accelerators for raster operations using " - "WonderMedia Graphics Engine"); -MODULE_LICENSE("GPL v2"); MODULE_DEVICE_TABLE(of, wmt_dt_ids); diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c index daa525df7bdc..92f0d3d16d96 100644 --- a/drivers/xen/grant-dma-ops.c +++ b/drivers/xen/grant-dma-ops.c @@ -400,6 +400,3 @@ bool xen_virtio_restricted_mem_acc(struct virtio_device *dev) return ret; } -MODULE_DESCRIPTION("Xen grant DMA-mapping layer"); -MODULE_AUTHOR("Juergen Gross "); -MODULE_LICENSE("GPL"); diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 58b732dcbfb8..86c04f239e87 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -1066,4 +1066,3 @@ static int __init xenbus_init(void) postcore_initcall(xenbus_init); -MODULE_LICENSE("GPL"); diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 6a11025e5850..4bc7efece674 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -2344,7 +2344,6 @@ static void __exit exit_elf_binfmt(void) core_initcall(init_elf_binfmt); module_exit(exit_elf_binfmt); -MODULE_LICENSE("GPL"); #ifdef CONFIG_BINFMT_ELF_KUNIT_TEST #include "binfmt_elf_test.c" diff --git a/fs/nfs_common/nfs_ssc.c b/fs/nfs_common/nfs_ssc.c index 7c1509e968c8..832246b22c51 100644 --- a/fs/nfs_common/nfs_ssc.c +++ b/fs/nfs_common/nfs_ssc.c @@ -12,7 +12,6 @@ #include #include "../nfs/nfs4_fs.h" -MODULE_LICENSE("GPL"); struct nfs_ssc_client_ops_tbl nfs_ssc_client_tbl; EXPORT_SYMBOL_GPL(nfs_ssc_client_tbl); diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c index 67aaadc3ab07..8395066341a4 100644 --- a/fs/unicode/utf8-core.c +++ b/fs/unicode/utf8-core.c @@ -214,4 +214,3 @@ void utf8_unload(struct unicode_map *um) } EXPORT_SYMBOL(utf8_unload); -MODULE_LICENSE("GPL v2"); diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c index 0520a8f4fb1d..44fdbb0de1f3 100644 --- a/kernel/dma/map_benchmark.c +++ b/kernel/dma/map_benchmark.c @@ -354,6 +354,3 @@ static void __exit map_benchmark_cleanup(void) module_init(map_benchmark_init); module_exit(map_benchmark_cleanup); -MODULE_AUTHOR("Barry Song "); -MODULE_DESCRIPTION("dma_map benchmark driver"); -MODULE_LICENSE("GPL"); diff --git a/kernel/events/hw_breakpoint_test.c b/kernel/events/hw_breakpoint_test.c index c57610f52bb4..692bfe95f067 100644 --- a/kernel/events/hw_breakpoint_test.c +++ b/kernel/events/hw_breakpoint_test.c @@ -329,5 +329,3 @@ static struct kunit_suite hw_breakpoint_test_suite = { kunit_test_suites(&hw_breakpoint_test_suite); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Marco Elver "); diff --git a/kernel/trace/rv/reactor_panic.c b/kernel/trace/rv/reactor_panic.c index d65f6c25a87c..2ab57e6d12bd 100644 --- a/kernel/trace/rv/reactor_panic.c +++ b/kernel/trace/rv/reactor_panic.c @@ -38,6 +38,3 @@ static void __exit unregister_react_panic(void) module_init(register_react_panic); module_exit(unregister_react_panic); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Daniel Bristot de Oliveira"); -MODULE_DESCRIPTION("panic rv reactor: panic if an exception is found."); diff --git a/kernel/trace/rv/reactor_printk.c b/kernel/trace/rv/reactor_printk.c index 4b6b7106a477..c8e1b3f8bb4e 100644 --- a/kernel/trace/rv/reactor_printk.c +++ b/kernel/trace/rv/reactor_printk.c @@ -37,6 +37,3 @@ static void __exit unregister_react_printk(void) module_init(register_react_printk); module_exit(unregister_react_printk); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Daniel Bristot de Oliveira"); -MODULE_DESCRIPTION("printk rv reactor: printk if an exception is hit."); diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index a6f9bdd956c3..f1b4df16a63b 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -27,9 +27,6 @@ #include #include -MODULE_DESCRIPTION("Watch queue"); -MODULE_AUTHOR("Red Hat, Inc."); -MODULE_LICENSE("GPL"); #define WATCH_QUEUE_NOTE_SIZE 128 #define WATCH_QUEUE_NOTES_PER_PAGE (PAGE_SIZE / WATCH_QUEUE_NOTE_SIZE) diff --git a/lib/btree.c b/lib/btree.c index a82100c73b55..201de7eb1bbd 100644 --- a/lib/btree.c +++ b/lib/btree.c @@ -792,6 +792,3 @@ static void __exit btree_module_exit(void) module_init(btree_module_init); module_exit(btree_module_exit); -MODULE_AUTHOR("Joern Engel "); -MODULE_AUTHOR("Johannes Berg "); -MODULE_LICENSE("GPL"); diff --git a/lib/crypto/blake2s-generic.c b/lib/crypto/blake2s-generic.c index 75ccb3e633e6..d9483fb0da5b 100644 --- a/lib/crypto/blake2s-generic.c +++ b/lib/crypto/blake2s-generic.c @@ -110,6 +110,3 @@ void blake2s_compress_generic(struct blake2s_state *state, const u8 *block, EXPORT_SYMBOL(blake2s_compress_generic); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("BLAKE2s hash function"); -MODULE_AUTHOR("Jason A. Donenfeld "); diff --git a/lib/crypto/blake2s.c b/lib/crypto/blake2s.c index 98e688c6d891..3a55fc138399 100644 --- a/lib/crypto/blake2s.c +++ b/lib/crypto/blake2s.c @@ -67,6 +67,3 @@ static int __init blake2s_mod_init(void) } module_init(blake2s_mod_init); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("BLAKE2s hash function"); -MODULE_AUTHOR("Jason A. Donenfeld "); diff --git a/lib/glob.c b/lib/glob.c index 15b73f490720..5cad078f0b4f 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -6,8 +6,6 @@ * ATA code that depends on it can be as well. In practice, they're * both usually compiled in and the module overhead goes away. */ -MODULE_DESCRIPTION("glob(7) matching"); -MODULE_LICENSE("Dual MIT/GPL"); /** * glob_match - Shell-style pattern matching, like !fnmatch(pat, str, 0) diff --git a/lib/packing.c b/lib/packing.c index 9a72f4bbf0e2..cfa5167c84b1 100644 --- a/lib/packing.c +++ b/lib/packing.c @@ -210,5 +210,3 @@ int packing(void *pbuf, u64 *uval, int startbit, int endbit, size_t pbuflen, } EXPORT_SYMBOL(packing); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Generic bitfield packing and unpacking"); diff --git a/lib/pldmfw/pldmfw.c b/lib/pldmfw/pldmfw.c index 6e77eb6d8e72..816c4c6f8a47 100644 --- a/lib/pldmfw/pldmfw.c +++ b/lib/pldmfw/pldmfw.c @@ -874,6 +874,3 @@ int pldmfw_flash_image(struct pldmfw *context, const struct firmware *fw) } EXPORT_SYMBOL(pldmfw_flash_image); -MODULE_AUTHOR("Jacob Keller "); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PLDM firmware flash update library"); diff --git a/lib/test_fprobe.c b/lib/test_fprobe.c index e0381b3ec410..692c1438ed58 100644 --- a/lib/test_fprobe.c +++ b/lib/test_fprobe.c @@ -171,4 +171,3 @@ static struct kunit_suite fprobe_test_suite = { kunit_test_suites(&fprobe_test_suite); -MODULE_LICENSE("GPL"); diff --git a/mm/zpool.c b/mm/zpool.c index 68facc193496..03bf00a404c8 100644 --- a/mm/zpool.c +++ b/mm/zpool.c @@ -394,6 +394,3 @@ bool zpool_can_sleep_mapped(struct zpool *zpool) return zpool->can_sleep_mapped; } -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Dan Streetman "); -MODULE_DESCRIPTION("Common API for compressed memory storage"); diff --git a/mm/zswap.c b/mm/zswap.c index 2d48fd59cc7a..add3d5b55bd0 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1537,6 +1537,3 @@ static int __init init_zswap(void) /* must be late so crypto has time to come up */ late_initcall(init_zswap); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Seth Jennings "); -MODULE_DESCRIPTION("Compressed cache for swap pages"); diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c index fc9e728b6333..597ddd40645c 100644 --- a/net/mctp/af_mctp.c +++ b/net/mctp/af_mctp.c @@ -693,8 +693,5 @@ static __exit void mctp_exit(void) subsys_initcall(mctp_init); module_exit(mctp_exit); -MODULE_DESCRIPTION("MCTP core"); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Jeremy Kerr "); MODULE_ALIAS_NETPROTO(PF_MCTP); From patchwork Mon Dec 5 16:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064753 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 735A1C4708D for ; Mon, 5 Dec 2022 16:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232644AbiLEQdP (ORCPT ); Mon, 5 Dec 2022 11:33:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbiLEQcx (ORCPT ); Mon, 5 Dec 2022 11:32:53 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD72FAE2; Mon, 5 Dec 2022 08:32:48 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5FWtr0010614; Mon, 5 Dec 2022 16:32:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=CIioloYzC7gdBzrJh7tX69ZHfh3W/3jHE+b99zDWImM=; b=Tau7CNy4N9SIXaXNFiI/aIhvhEVxRsejYr0d/kGLuplNquFlGn74+tXsp3AIzyjKaxw/ tRn/FayiJBj7d9jXsg16/a18poDvpe8LRqQmSUhslf9kgYQnKoFLv2UPhJ8oG/I7fJ88 JOybROee7R8Cq8xumeQ95ckYjgu0xExEbY750GK5nYIXqTVuxxTC12GOjzAdmkFTuqz6 WQ0ay01MAv+TukE2T5DbZgm41gTLv3MHZl/RPEcmM2oJxNeevT6kOJCCB6N3gQG4A6Hq 11dJNFeltL5uqZQWOXlEAI9LI2ndhBmE0Jd+/6iOGtELpo5TQP+dpCLYJZJ9AJchNClI Dg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7ydjck0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:42 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQvl9005382; Mon, 5 Dec 2022 16:32:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ucswawq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kzr7pH4Yo+UWJE6o1iI0mZFY5KHlhpjJ2yRjuRTE77DjThfxXjsFk2CIzXY2gjVLbPtreSz57Xa2WysOe/JLf4YoH8ZJyB7/TBGOyd3Gg2IDZKn/PP4ll8Nu/VBkLFVKFEPkApM8fVYm9m4Au0J2b1Nq3r+ijj9RC9OM4TTtvxZBomIwyC5JPybLV81Dg/+gPXDETpA4wkgjV694CySvdRc4PDle568dNdoMpTycAQsRGW8J8MlZq68HfpCcLHQFMMbTVsuqMiqnAR0QYPYbRux4LKPeaNlAVh9OZowWPqA1xGxtLmN3NRzUL0seajcDxOR72A3oEgggS9maWXTefA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CIioloYzC7gdBzrJh7tX69ZHfh3W/3jHE+b99zDWImM=; b=MJZIyUDZtfeU9tMiJ2NSn40BmnUx6vEBIxPwVukKUYhgjGqmFzkVfSY0Y4byzy8TP/TyYIqyxt5uwbvzT+BDNgfE5yfW9Co84Sp21nZpDF6AIZlUMmodlFFLpdT0df3O3BFeglsxRIgGaYUuNj+2JdqfBIfnOJz+7uIdLck/JVfRRmLxt/UApkVjB6JO8dCj96A9tkCtKXYsDooBJ03i+ILJb8nOPm348kmZFkD+avGE8SZPJDPNsSWzgYAtOzUxUn3RcEhHpI496EWOletb3pPPkw6oujWknXtnN0xs1bZwfYijVQzojoZl363F/LXBE2bxqYdkO7bw9MboX6QRxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CIioloYzC7gdBzrJh7tX69ZHfh3W/3jHE+b99zDWImM=; b=mPWxx3TwLo28dexlpZ2SAshcmfMYJ1At5iH0nyi25Nij+vHctrkpoO1X1L1PW7ML+D0KLmodv8a1QU+VCBgY4a8nUykWGHnfJIymjQJoBkSIof2HdV+wmpJ/8jjSxhwRaVJ7P0t3Pxd1RvGnzX2jOlynmGxp761I0Lbw7kpMYj4= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:39 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:39 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 06/13] build: add a simple iterator over modules.builtin.objs Date: Mon, 5 Dec 2022 16:31:50 +0000 Message-Id: <20221205163157.269335-7-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P265CA0116.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c3::16) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: 37132d86-b51b-45d1-2528-08dad6de531c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 84LNDJD+CI6/DNgTc8w2U+SE3giLmzpSqmh4UGQoGFxdAwMZOi4falqZnNQBOXfEpCOxa3EME2pTn/b6QpShkFAFtmqOJI8hGtX4vX/AAHfrMqB+C2Xi8oNPOVUUiN5H0ZWluhjI8g0wtMDAVNU7l21RjhLVAKqSChtGHonkCi9qR4K4vUvfoRPxD7Mt3JG7YyfYitcDW9aVwQjo2yLk4491HICo2tQ6owQqoXD8139evJVPnOxp8CqSe2cxh43ncJ+tqpKYBFz+pggfed6gO5RPVDZkbbF3CDgiA0P+w7fY1MmSI/YGAG+eAig/UtTECUj/YIlrZTxxQDl6mCzsvcEmRTXuL/VfeJRDGbpcY982CePYvEB3/Mk1LX0bF61WdZYBaCJb2ByrGzeerUev4t46DPyLzfWZdJooDQRogpdDZx8dZXD3zD7te8E8lQwV30EN1PxYF6n1z8dIV7NXVxmXtWEIy8krUh6rcmtxlpioJmhR1Pjx6bHiek67ALSQQa2IWnmIlIKdVRb1srTZbTRH8XbnU26BhgsqqXsxzDNasNYj2SWsEDswIhJcYXoBeww2y54KW7OxvbVCMNVjhrlwjkLNWv8M/QvjCn7zZ5SSa3PIHeK3WiYDwerdtCie0Ajd5kS5Y2FJmL2i8n8WbaQos1PtzEYosIKxAZSDwnGTg0TxHKIpuKY+pEzMTl/g X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002)(66899015)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JzfQMS3O8YOnwZYODT0W3QYrAS1CmptBHv4djSyg/OwCcvl76yGEgqDk9nSFvB4pFtAaoPRZayUhOEriArJn73EITOLFojwAPXHv0e4hSHavHQo/vSruttzNGytT8pKdv7Zb696uboRrr6NrMKyqKHRl07YJ6xBXmiqIHvV0C6DKTsnWuavJp6+Z3mFkB2e7Px/F1JYim/bh9dpGhfKmlGG0u+Sbt+adNw+J+Zi3/eT+Mv9IOZjqgkj8yiMMo5aBpkq7UvaMqRq9FPo52xEw0gvcKCjE6losxBJ9xlN5G+sdWsvQPlLd2PejOSlMLAlU78Y93YXapFZmx6qmA2YzQWZBynvzW0vCT3OKDi1iM4MAqfCGu+uwlFNVkhSCYRQereMSn0kiVjXUzmTc0eOSzVKMedh0xc7o4QO0twbFqZOznd9xIrWnBn3NtTkeIJz69jiobI+UFsTv9aw7ZwZiwTSr47SoP4I9YMk8Yo/Ag6poruFsLDF9xUQyZIQkb+xnyriM9z4GqzjTjMPSFJuq2H16l2GEgu1CwUTikuA+jmMzlk8LEl3Bkx/ArIbydfN7rBtCmK2j8XJxeAif6eYJeysJY/Y2BRiyY9tx7z+lROKVFXaQ2LZv5XLxvD4bYsbd/Dd4HAL/4TdSn0xQPqVLwXNkVeJ7vB584RZ7B7BV1oBcpN6Cewb5N1N+KnhdkHDGimCDpEbxacVp5hjfBt6+hEI46AhvdKtl+gGGCAI9rtFm8jlblRVYypuThp4G9+6/TyvFblwW91kYyzdYIVRmu9Q4YSYhxvwhO7whyIPuMLlZtQPFMHtSNJ7lzS+PVAB2dT0EEttVonQArn7mpTNgFwwjnCFYg/m7/7l1ut0LlwPqbnfY7tX1B6pPkb9iCq21V1P7god1aknqXrfGOr8yYXFLagurvoXkwnLi1IQ0JVO9g2YwnZNGgV+FPhJxrFxnejha157Acr1dc+Xw17fBEWppelemCHFDcgeqP2xwL3W0ORPTph3ET9GVO6LXzAeGXHe9faku3YRsdUf1vufWbFYehkhhTcVUsSwd5jh177HxNdaqAsPCpgJmkgKUSNSjQXsAe1KM3wCWgUMCZK0+YA8sTApFk6SygRYCuuZ3pQ237zE2OgelonXu30A5+xV2wugQXR5SaG5zqaEMX4Nwa1+ku7gUDTHhIO5YDGJhl7xzVa8YZpbahr3WZR+uHCrdIzMANLusY6uF5MIPZIk7v4gTtPNeaV30T3EWV/w32n1mCRULnleAaxIIBZXewnhiptrCCsdgDZo4v+qXjmmK9eRVKi6mVdqpthg65Sark3dIBQYw9bZIj814RANG8wIG6JNRqMVxfaRVqR/w+jE5BfOD2oPyjCFsYJVytMq6AB0Z/nF4h2JqhotcYp/q/y1QfoQGuNv2zovMpudGz1YbF/hG+Md7z5qBhf2XBFfqcG9Dl98GgvlMWwfCvdvStzpqmuKmFfY4EJ9VnqZeiZSthNzHOk3C+uSOFKSBh0XmUDYJV8qtsbvnhpVHu/nrSUTh6FVK0TAxAwRkA9dlOeqXtHg5nyu7Z5evVYtIlCmmEeRm/yKoJ68h27Eg3vPy1stOcA2JIjIiGfGEWQi9fg+1pQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 3/117EOKCv+3mKOxiDjW4JCV+v728PileeIuP6m439vT0k9FgUS4p/B8KiBvqwIFpOimCuOPMargR24zCHw5lm6sAwFJaGyqKfVpPQINPm/o6eVdgbH8I7RoFTK1ulW7XNRc4GkJKE9IPSbcsUdcBZ5xd0QhIGNBWI4yjpZfB+GxZKOHK0y/twCfK3Cm7Genq/bO3GG6W5nuqu20XILyH8F+cHuIfa5l5ZSI/pIkSwD4p6KAS0Un+VYC1HYczougCMSsl72bID7Rz7c/DAbFN2eZtydCHtc+JNTEGtn9X9wZ5tzWUBrnEtQf594KqpnkyU61J41HPvA6ssyufOpMcE7WhioJAe71mzsJRAOkZmmrrfkTECKWspAuz40FZbwDptrO29H6uqYh99uFnPpPeUee/aPGJm5DQSUzFJhS/kpiIn0BbDkOBPeKqzMbNTg5/5cD3vw4FMB/PiPk750darn2NEOibrnme/FYVgKnf19eHKKXfPcGKTtHmkRMhNGbg/rG2ZAR3l1HXbsCVsBjHyhPvWMJrDnIj0O5yBf/7yBW1Wu34WNji80isK6XvcvE5pU1mTE8UpfGkdRc9S8iIXrMsiRZgKni0bw1sIIFeb4IdOR/ADPa2L0vXzNEH6HfOUt1TjiyAMDLijV1sLyHw/+OJ2wElnVghdfgVGWZMJz32KfwUuK+vfn9QYYeM/dCAUV4PgBhrSsT6erPKN14hQpmDOeT1q/a9GXeeilnIbWY8EL1SO0kPE5XMsrWSHRqSq7Dl0KFTK2NjcHLp+BxDVmueLKIjfffwcUtwT7LqfeCFw+nwu4WpjnasqaoQXxYOArj/HAetW8DazGNg4i+U18TyX7BLUsSAhYvtJtQHLF75i163Kz8h/TkG7YLtDQ+8zEbsNp0lluMq1kY0gTBW5lkRpbIX49Lkr+uZZ8e93HWiqhCLhcVel4IekhwEHc/JIU9W44ZAvNU+kyzj7M+6IBHXLscAlb1C9w4VN7S82o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37132d86-b51b-45d1-2528-08dad6de531c X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:39.3502 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +aWptUiNnbd1jYp2nxyKUJzdVeefKBmCADnJ5Q4fKoN11hLbO2q+u/zenWnJ6BfmafztQ+GGp6MTjDol6Fj0vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050137 X-Proofpoint-ORIG-GUID: Od8lDHT69NpebnHVLlcIWhbmRLzW_wG9 X-Proofpoint-GUID: Od8lDHT69NpebnHVLlcIWhbmRLzW_wG9 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org This iterator makes it easier to deal with modules.builtin.objs files, taking away the parsing burden and letting the caller treat them like C arrays: { struct modules_builtin_iter *i; char *module_name = NULL; char **module_paths; i = modules_builtin_iter_new(modules_builtin); if (i == NULL) { fprintf(stderr, "Cannot iterate over builtin modules.\n"); exit(1); } while ((module_paths = modules_builtin_iter_next(i, &module_name))) { char **walk = module_paths; while (*walk) { /* do stuff */ walk++; } free(module_paths); } free(module_name); modules_builtin_iter_free(i); } Will be tied into the build system later, as needed by callers (initially, the kallmodsyms machinery, which wants to know which builtin modules particular symbols are part of). Signed-off-by: Nick Alcock --- Notes: v10: split out of modules_thick.builtin code. Adjust to use modules.builtin.objs. Armour against lines with no colons. scripts/modules_builtin.c | 200 ++++++++++++++++++++++++++++++++++++++ scripts/modules_builtin.h | 48 +++++++++ 2 files changed, 248 insertions(+) create mode 100644 scripts/modules_builtin.c create mode 100644 scripts/modules_builtin.h diff --git a/scripts/modules_builtin.c b/scripts/modules_builtin.c new file mode 100644 index 000000000000..df52932a4417 --- /dev/null +++ b/scripts/modules_builtin.c @@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * A simple modules_builtin reader. + * + * (C) 2014, 2022 Oracle, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include + +#include "modules_builtin.h" + +/* + * Read a modules.builtin.objs file and translate it into a stream of + * name / module-name pairs. + */ + +/* + * Construct a modules.builtin.objs iterator. + */ +struct modules_builtin_iter * +modules_builtin_iter_new(const char *modules_builtin_file) +{ + struct modules_builtin_iter *i; + + i = calloc(1, sizeof(struct modules_builtin_iter)); + if (i == NULL) + return NULL; + + i->f = fopen(modules_builtin_file, "r"); + + if (i->f == NULL) { + fprintf(stderr, "Cannot open builtin module file %s: %s\n", + modules_builtin_file, strerror(errno)); + return NULL; + } + + return i; +} + +/* + * Iterate, returning a new null-terminated array of object file names, and a + * new dynamically-allocated module name. (The module name passed in is freed.) + * + * The array of object file names should be freed by the caller: the strings it + * points to are owned by the iterator, and should not be freed. + */ + +char ** __attribute__((__nonnull__)) +modules_builtin_iter_next(struct modules_builtin_iter *i, char **module_name) +{ + size_t npaths = 1; + char **module_paths; + char *last_slash; + char *last_dot; + char *trailing_linefeed; + char *object_name = i->line; + char *dash; + int composite = 0; + + /* + * Read in all module entries, computing the suffixless, pathless name + * of the module and building the next arrayful of object file names for + * return. + * + * Modules can consist of multiple files: in this case, the portion + * before the colon is the path to the module (as before): the portion + * after the colon is a space-separated list of files that should be + * considered part of this module. In this case, the portion before the + * name is an "object file" that does not actually exist: it is merged + * into built-in.a without ever being written out. + * + * All module names have - translated to _, to match what is done to the + * names of the same things when built as modules. + */ + + /* + * Reinvocation of exhausted iterator. Return NULL, once. + */ +retry: + if (getline(&i->line, &i->line_size, i->f) < 0) { + if (ferror(i->f)) { + fprintf(stderr, "Error reading from modules_builtin file:" + " %s\n", strerror(errno)); + exit(1); + } + rewind(i->f); + return NULL; + } + + if (i->line[0] == '\0') + goto retry; + + trailing_linefeed = strchr(i->line, '\n'); + if (trailing_linefeed != NULL) + *trailing_linefeed = '\0'; + + /* + * Slice the line in two at the colon, if any. If there is anything + * past the ': ', this is a composite module. (We allow for no colon + * for robustness, even though one should always be present.) + */ + if (strchr(i->line, ':') != NULL) { + char *name_start; + + object_name = strchr(i->line, ':'); + *object_name = '\0'; + object_name++; + name_start = object_name + strspn(object_name, " \n"); + if (*name_start != '\0') { + composite = 1; + object_name = name_start; + } + } + + /* + * Figure out the module name. + */ + last_slash = strrchr(i->line, '/'); + last_slash = (!last_slash) ? i->line : + last_slash + 1; + free(*module_name); + *module_name = strdup(last_slash); + dash = *module_name; + + while (dash != NULL) { + dash = strchr(dash, '-'); + if (dash != NULL) + *dash = '_'; + } + + last_dot = strrchr(*module_name, '.'); + if (last_dot != NULL) + *last_dot = '\0'; + + /* + * Multifile separator? Object file names explicitly stated: + * slice them up and shuffle them in. + * + * The array size may be an overestimate if any object file + * names start or end with spaces (very unlikely) but cannot be + * an underestimate. (Check for it anyway.) + */ + if (composite) { + char *one_object; + + for (npaths = 0, one_object = object_name; + one_object != NULL; + npaths++, one_object = strchr(one_object + 1, ' ')); + } + + module_paths = malloc((npaths + 1) * sizeof(char *)); + if (!module_paths) { + fprintf(stderr, "%s: out of memory on module %s\n", __func__, + *module_name); + exit(1); + } + + if (composite) { + char *one_object; + size_t i = 0; + + while ((one_object = strsep(&object_name, " ")) != NULL) { + if (i >= npaths) { + fprintf(stderr, "%s: num_objs overflow on module " + "%s: this is a bug.\n", __func__, + *module_name); + exit(1); + } + + module_paths[i++] = one_object; + } + } else + module_paths[0] = i->line; /* untransformed module name */ + + module_paths[npaths] = NULL; + + return module_paths; +} + +/* + * Free an iterator. Can be called while iteration is underway, so even + * state that is freed at the end of iteration must be freed here too. + */ +void +modules_builtin_iter_free(struct modules_builtin_iter *i) +{ + if (i == NULL) + return; + fclose(i->f); + free(i->line); + free(i); +} diff --git a/scripts/modules_builtin.h b/scripts/modules_builtin.h new file mode 100644 index 000000000000..5138792b42ef --- /dev/null +++ b/scripts/modules_builtin.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * A simple modules.builtin.objs reader. + * + * (C) 2014, 2022 Oracle, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef _LINUX_MODULES_BUILTIN_H +#define _LINUX_MODULES_BUILTIN_H + +#include +#include + +/* + * modules.builtin.objs iteration state. + */ +struct modules_builtin_iter { + FILE *f; + char *line; + size_t line_size; +}; + +/* + * Construct a modules_builtin.objs iterator. + */ +struct modules_builtin_iter * +modules_builtin_iter_new(const char *modules_builtin_file); + +/* + * Iterate, returning a new null-terminated array of object file names, and a + * new dynamically-allocated module name. (The module name passed in is freed.) + * + * The array of object file names should be freed by the caller: the strings it + * points to are owned by the iterator, and should not be freed. + */ + +char ** __attribute__((__nonnull__)) +modules_builtin_iter_next(struct modules_builtin_iter *i, char **module_name); + +void +modules_builtin_iter_free(struct modules_builtin_iter *i); + +#endif From patchwork Mon Dec 5 16:31:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064754 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 86528C47090 for ; Mon, 5 Dec 2022 16:33:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232733AbiLEQdR (ORCPT ); Mon, 5 Dec 2022 11:33:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232384AbiLEQcy (ORCPT ); Mon, 5 Dec 2022 11:32:54 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B40CE1DA50; Mon, 5 Dec 2022 08:32:51 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5FmSrX031059; Mon, 5 Dec 2022 16:32:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=HmUknPKehfmwOKCjqceNHmSEPBtZqknlCR5dmDXWl5s=; b=AZETqHcY9JOJwvzbaKQiayvBqQkScjr21wnF7XZa4QHU0OtWGnuF7u9hViMheBXc21SR fkxpbYceLvprmBp/DToDZtjSLuu/NT3D72v9Osvd/QJ21MVS/Txi9FE0eT+z/S61IjSU +iYciRlW92m8csCX4DstuvUa1S2XSTUIi9IGmEOoJ8avDfPqkIj8ulFtq5qp+PG4SIlG 2T1Z+0mR/OYARPSLx0oiMJdBZN37NhsInrnzJeoi3NQJ6Aug3aeKgE0u2jqm/NjdA20o OShsJDVUoVl66zVA3DNGgVwez3Vn2AomOcnkQkCBlWl/MEVWscokZF5y0gdGH3shT9E8 Uw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7yeqm9vu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:46 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQvSE039173; Mon, 5 Dec 2022 16:32:45 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ucdnhqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:32:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MxRBxYkK7s5G4qfCK+VyLh7qiK5zILlIT/7Fr5DqhNnAJ/5OuN6fGKrreMXq8k4AifeCpVhVfgINcXv3yMjkadvk4NQBNVv2JK1ezwJs9VpUQYw/l5pPIuhqK86S4MsgJqCsWUDXnKE2vQ+jrMeCGb4WhN5MLxOu9sDqF17T9AbxtVrF5tz7iYX1/eByoGdwTfkYF98MynT/gEp7U/p6iCqViqrb2wQHRl0YHPZrqKLFeK35Hbr2C3HeIGlfita4T9sckem3nDa72ktZdk/zld/uhM/sYNJXb7kykGSI1pr2zWAnPz4E0s29XggFlaqrTOSTjrtclXw6SETqKc0MTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HmUknPKehfmwOKCjqceNHmSEPBtZqknlCR5dmDXWl5s=; b=mjL5z7V/utQ4SQ5ignqamh8VCHYHPmcb4HOsTKBWWFqFqVzxvKrkHTHjHnrAW1z0B2a1DO4G+9PBhNIMLThtvDTvnL3tVZxN6qYwh+sOx70sBzHCimJtuoy3p3gUxKLyZcMCLb60UktXSEgOc+hx/zAMSGpw/4gYBIzcreyicmQEqpfHf3y1xnNQpgGXHfDKEtYGTOVLC5WpMyxENZSE4P26N6Q88xIuMLjGyqbDvGxVHAcVECqm1zQTG2oRBKjqLh+EFgMHjDJoqZbLSJYs9V1XQsbEhGptCTP8APAGZQ71pz8pZoMUhhu2f7Vo2N7PaEIWUZ+m2DIzA/A3XBMH6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HmUknPKehfmwOKCjqceNHmSEPBtZqknlCR5dmDXWl5s=; b=I7ltCO6YEAWj1G+AIkUox6YpTVRwCtSFKKd92aH9fguH/tlKvIZVSpKuK6qUqrPFHaIfOGq199+Ap6SaDwjuuxFc3ki3o9OiFFm8GQkmgYwZFr1lFLooRyX8v5pzcX66D9Ir2gGmLYgoPU+kHegX8JUAX/5uNj+ozkMaophXHwk= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:43 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:43 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 07/13] kbuild: generate an address ranges map at vmlinux link time Date: Mon, 5 Dec 2022 16:31:51 +0000 Message-Id: <20221205163157.269335-8-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P123CA0021.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::8) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: 3dd7cb37-bd56-4e76-7107-08dad6de5583 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WN/dy2O1zY9zUNm/5h+bPY1ODfMb21MZPCuQN0uqzY04P4RZDEwK0ios2AxFIrGAEh8hY1vC9oZbcm80FrUKkR8zp5PCPm718I9fvxQbfuzh2iOKsoDs44tGpbueLe9zRkgMswuDG7lEWPF7qlLxMoixnoS0E2ES6jgsvcgx0WvJZUvwLUUIMzT9SCxC2Cg43OnEG3LKbNTLhB0kf62/cswBvsms47llzNjglc8mA0xj1XUOL3zCamjjk9rLiujLU2Z/KgwvQwlIWolkE2VmeWnwZLpcM0UYrxXRTV4zsq20jpZZRH92cV4ogWNZJ2qXddS8JWLqP8nfzIa11GoDtaJXMQf9fFdQjAbABKYu4IuwJ4PTlrMUvj5OCjcIT98JU0oHl6RKZzKRBAMuqbQHCEbPdfB0POvsbXDdZ5iYvN+vaOuFStVzN9rfw3LoX9+sDueQCRCi8q1yiLso4pi3HjJJ9l3JiJmZA8rKpjQum72s4wr6V3EzFBPuDEl5QyRfFwunTlk1LIsQjVdQY+z2zg74ri01h3csra86EPEbiq5PN+WDfN9cJfhM039XADHsLevl+fDBBU06tETbIeXb4vV/r/lrPNE6MtfvWNWFzdCSZQ9xDpw2SDP8+iZv5DZfbSO+uwKdppSE1bNs9SDxEg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rA9hNnko6xWb27amdR92SjFgEAyxn/gZRZINFkh3kNsrVmynYc2ztqLhlLsYunrgLDr1LmhpvPvkJMNjtZ2M8aDD4piJh3C3UeOdg7gnt/UDif9pGSc1EgtjGtxDyK4NVUK0uxFBDbBSVwWLpnH6MFGOaX7Ni+5Alx4mvw+FO55qsH+5+ZAzLePWk//IzyZPDNTyf378UkdFzn7xxm0Y72j8aS67d7tYFhPddYBnPY1BelKn5e+kla6R54eOsANPkewJamoTiWzB0WivNfjbFFR9Q/lsIn9rMDOn2VcRlT8r8CLVHu6fvszeJdDcp3Y2sp/ofHWbBF8eNnbEQ/cYjzKIghpHqJZEhX3kG0u003Sa6YvJtkx+YfxyLN0YNewiyexO9DjXZKUzPC7m8jtZ3cSYFa8jPV074naI7tUZsYuXD+ZULQB0lJDzHvZV4Kfty6ugDjTChBjAqKbj65hcA0mUU/ZSiP0grH4O9ogaJYMz+M7Okl5Z6eYRu0lgY/rPJ4j7rSd4q1yGTijM1O/koV4rmqC3Ppl4U1FuApH1rQ2opcYBfIeHZdMZqq3Ha+OWY211z/CmvE0kXMsZ7sBm58CNxDxTUpntd0J+7684ixKACb+s+04vKlIQckI4pz2447cOxFZYYs9wX/D+kz9rn/QDpt6VhBIDcBHSNf/9IU3ewqGqyF+A6IHH1BqMeIqMW1Kt5ITt5tQx6O5FIdZpYQcgEPe5Aflqg/+MpQmSMK7UPkFwN8gsF0fe6Zl/EycwqCB1NoOHYfyJprzNioqCU5E3fX/Lwn5HMiefpV5WyP6kiGvf+IYgUUfzV5Yt/vhySmSLZ8QhKlay3KEYxBDaw0UkMSyFDq7wsl5/EEFhstluLmj3aywynL7W26xFUpcZkn/HKHZVby0vjSrNZTggxfdVmEUMm0+nUKRsesPKyq/U8fJAfboi2gIqqUG2MAyeoo/AQhrh6RwwlAz1IOhD4iGn0jw9B/DB+7QKHizv3H2bn3LdvX0yzM9CDG2X5NNALKC1RYOSfVPRD7THGEYqEzKIZfD39ZyiiLJDgwBaZ1VhisTgLjg61oBufYAdXmTA3U6WMb66lXe0++O0actiYjHHc2VYwyeAUypxoNp+M8azbSFL2ztAzc5zfJCo2YpUhrfWXp/4kwZA1Rr55B4dQscaD5hYzhD7D/xceBI3XMySjck6078Wmfzqgu+BPS+boeGrWQRE3QQKkgOEWebEoeX0LbETgM14/s0S1IDboXZ0MfM3ZIQhQXHXJDtEw3S4YxuKjKC3NWm9h94FQfxYaaI7Z1mUTWoeOwtGCpz3UiAk9Sm5MIBkF0oPCkSZ2gGCMXSA96kTHLcML/fcJoUBwx0iPVBFj4Ike7CtyQ4ONVFlsCtXpGeEeD87RuIhvZV41PhKvONfjrKOrzDUXvmR4tZJ1NyLFBxINUIta/vqAszcByQTosQi7q6fWqYmEDoCLKdEw6CptDfU0TaB+9kxD4lrJWlz4LnTviQJnM7xXEgM97K7yNggUGvWPM/SWvSMWhIPRzxKeBhJMPoLWU+dsbuaOhh1c7nZFb3gf30dD5Lex4/8rfRXUbMOSOg4d6JfPVDJmzI1Kji/XKWcqkHa2A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0DLIgnR8bSFRuP7jRBwu1AeMArmnDV/akCRHneBWrB/UXYynx/lFTy52JW3ZjUkKIqMyhMgImqsrp7ftBKkzdb1KprrlPlQOikITzWHA+J1drJ9Gy3qDiRFH5WHQVyjinvAlj1i7+/DTagI0dke7B267KNdzQq5tDKKNDw19v9DbteclQoxj0lcgTg1MSgtMOj+82m8BGvozawdHuOuLMKRbwRdjucTsyvYGzFh9QPWdn3bOmD+aa9pDYebf0WXKiDzKAtSnhnpihKhgau59ZhcuXFnsh6E43VxFURxBQYtxYp0vX1+leS9vp8F9UfwZJSGVj7sUIG4zYRjo8BSRXKJ0J4MNzZ8R2P45OiAibi8fkf97Ib3e1B4uqwywJ0UujGPLyHO6jATlTwbFwdmVaGevRbGnLwO7V652+KLf3r6Y15zOFeXzSJUBDWT/DY60YI/AaQjjKszxUf7zAFJP+9sXvmy4OWHu9vNpdl/rjJLvXXfPmpy0jdlY0gzsEa/+y6tmeCTmetJ4F/pZXnY4uwRUxqcxH/ZoFx130K9PsJN5VYam1X2PHMZ5hIic0S0DYul5vM6ve6Frk6ymfSrGT9p7L9c7ZMxsQfjLmSVN39njejGuJMl0p4oiaDLUJBwsqnf+RgZNwPuCIKjmVD5ij0maYjU0e/aoH3GAr84nhyi8HCZSC6NLenm49HFk75O8vv5LbBO5yKBfk9VlvAaygkveE10SBsaVn5BcLiJJG54RPL45ObnvDDsFsLu8Fsj3kSKrW4iWpCsqK4lQhFBuC1VzIPKbYTKOG6vW3D/AKuXQ19OcT+qiuSRTQ7W4VQcNSVXmw8wAn5MLPYCStAr4cpY9T4JfnaTqp/DCrhfbI8agLsuPCD9nm6L9FhhyElBHcdxzuHmDKy+OCqkpbmxj7Q9Wugv0+ZevHvCK4zPQB4uO73g3Ud5+lH53DER2TZ86qZhJvTL+n5eQpss0fdfsnPedKZl2WDm6jg0vWCuG2GI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3dd7cb37-bd56-4e76-7107-08dad6de5583 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:43.3826 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BZxXhgOnBtkNLchqQyBFoAHJLgBkfj4R6m6L6lZlxLCGKt3LOtcCLgb7KSF/do3gCesXYF5ihU0+M7/1vUZfCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 mlxscore=0 suspectscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050137 X-Proofpoint-GUID: ADxBPUqObwMMh_bwklZw5xDHmzc_nhAs X-Proofpoint-ORIG-GUID: ADxBPUqObwMMh_bwklZw5xDHmzc_nhAs Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org This emits a new file, .tmp_vmlinux.ranges, which maps address range/size pairs in vmlinux to the object files which make them up, e.g., in part: 0x0000000000000000 0x30 arch/x86/kernel/cpu/common.o 0x0000000000001000 0x1000 arch/x86/events/intel/ds.o 0x0000000000002000 0x4000 arch/x86/kernel/irq_64.o 0x0000000000006000 0x5000 arch/x86/kernel/process.o 0x000000000000b000 0x1000 arch/x86/kernel/cpu/common.o 0x000000000000c000 0x5000 arch/x86/mm/cpu_entry_area.o 0x0000000000011000 0x10 arch/x86/kernel/espfix_64.o 0x0000000000011010 0x2 arch/x86/kernel/cpu/common.o [...] This will be used by kallmodsyms to let us associate symbols with built-in modules at address-range granularity (i.e., space-efficiently), and to let us disambiguate symbols with identical name and module by annotating them with the translation unit they come from. In my simple tests this seems to work with clang too, but if I'm not sure how stable the format of clang's linker mapfiles is: if it turns out not to work in some versions, the mapfile-massaging awk script added here might need some adjustment. CONFIG_LTO_CLANG by default optimizes by working from the LTOed vmlinux.o file: but this doesn't work for kallmodsyms, as the resulting mapfile lists vmlinux.o as the source object file in all cases, ruining its attempt to disambiguate symbols using object file names. So we suppress that optimization in this case. We also suppress it when IBT is enabled, but IBT *requires* use of the intermediate vmlinux.o, since that's the .o that objtool has run over. We lift this restriction in the next commit. (There are similar problems with everything else that uses ld -r: since this amounts, in total, to a few parts of KVM on aarch64, I haven't implemented a general ld -r fix: the fix in the next commit is specific to vmlinux.o.) Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- Notes: v6: use ${wl} where appropriate to avoid failure on UML v10: mention ultimate use in kallmodsyms, conflicts with IBT and ld -r scripts/link-vmlinux.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 32e573943cf0..a40d372b1289 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -60,7 +60,10 @@ vmlinux_link() # skip output file argument shift - if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then + # kallmodsyms needs a linker mapfile that contains original object + # file names, so cannot use this optimization. + if { is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; } && \ + ! is_enabled CONFIG_KALLMODSYMS; then # Use vmlinux.o instead of performing the slow LTO link again. objs=vmlinux.o libs= @@ -94,7 +97,7 @@ vmlinux_link() ldflags="${ldflags} ${wl}--strip-debug" fi - if is_enabled CONFIG_VMLINUX_MAP; then + if is_enabled CONFIG_VMLINUX_MAP || is_enabled CONFIG_KALLMODSYMS; then ldflags="${ldflags} ${wl}-Map=${output}.map" fi @@ -144,6 +147,21 @@ kallsyms() { local kallsymopt; + # read the linker map to identify ranges of addresses: + # - for each *.o file, report address, size, pathname + # - most such lines will have four fields + # - but sometimes there is a line break after the first field + # - start reading at "Linker script and memory map" + # - stop reading at ".brk" + if is_enabled CONFIG_KALLMODSYMS; then + ${AWK} ' + /\.o$/ && start==1 { print $(NF-2), $(NF-1), $NF } + /^Linker script and memory map/ { start = 1 } + /^\.brk/ { exit(0) } + ' ${3} | sort > .tmp_vmlinux.ranges + fi + + # get kallsyms options if is_enabled CONFIG_KALLSYMS_ALL; then kallsymopt="${kallsymopt} --all-symbols" fi @@ -175,7 +193,7 @@ kallsyms_step() vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o} mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms - kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S} + kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S} ${kallsyms_vmlinux}.map info AS ${kallsyms_S} ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \ From patchwork Mon Dec 5 16:31:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064756 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 E81B1C47089 for ; Mon, 5 Dec 2022 16:34:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232335AbiLEQe1 (ORCPT ); Mon, 5 Dec 2022 11:34:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbiLEQdp (ORCPT ); Mon, 5 Dec 2022 11:33:45 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5543DDF5F; Mon, 5 Dec 2022 08:33:30 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fc1f8007848; Mon, 5 Dec 2022 16:33:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=l32MOUudC0t6Nqjg2Gti/mWtMRe+Rd58udSjs02jLB0=; b=FnjTjrhw6ZZVS7wunFu7sq9/RJjlylzmC6tFRO04sFIDdIC4LHHmO906ft/+58fUZF1U TvCBY5EnPkBd1edSe+F78Y/FDpw7BtFZIOITc8sxSXD9GEzncjy6Vx/tzJV6elvBe14z s/VAi2oCNVuthP04LKVG8qF1fzWzZsrEk80KQuvlk0884xqITM1WvmTAxrYgJLiRJ+tC Q0+pHF47q41Nq63MpN2MMnAXJbPRWkQrLilViJvhkY+XRMmTOkdElVsSq/DASLnNnM/F wvExj5HsZ3QZJq3bPPwMQ0Bmuxm+RvuDNndtupq36JspM0Kzx2N8nTszjUCIiavoWJTE GA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7ybgmbgm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:24 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQwoR012906; Mon, 5 Dec 2022 16:33:23 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3m8u925434-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L2j1FZShRWvajJQKP6XQqo1yXBm+c/WCymlu5IpChuEMV0BYap8truf3e+jzkLKLUHeu1phRnm2PV/iY9s3yukLMXnjbxMrt0fMh7+FaNocJMHciCqao/BCbX2M/3vtzuAy7tioPvqjGbmx9/dAT2FNUOqQwIi3u6thSqzpXEZ2xbX5zxtLLvUKsGwlu9HNmWBH1cZpsG7VEf/eoVEAh8Til8eAfdd2weDt2cMm7fkV0XHbPNxskhJX1DHYyP6RTNFVXlSgu05zkhOez27UjYymnWwClb0AYweQFG2OSiQOJynGqW0+yQi2nOYqDmbVriqjDdX0kjg3nXNQ5PRPGng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l32MOUudC0t6Nqjg2Gti/mWtMRe+Rd58udSjs02jLB0=; b=MhLhZEbU/kOuAejsGAM+Apd/bse7s+OkCok+iGb7R5kZmhZrcJdzKv7KYzME9JzD0YOWy84mQf0B7uLKAsWybsZAhLY9YFCD6Uh9uvPBfcp+aYA29/TYDQFZEro5UjsumWbtSFLN2DhbhNL6wRT14sOJaYQvkn01PotV3oDMFp6Zuz2exs+zaxx4UUqJZlEXS0lxWRDWpnzawN0ItawIOZAAEPJgFzJzzETM7LvYigoJKzi316uAh5pHOrNqy2872WP5TZQLMY2OuOinHtdGXAtMzvc1tB9ZMtzIA6OJqrOFEKJbpySOwCED38IiFXu7wQ2vEeScKntk8BFQpgb52w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l32MOUudC0t6Nqjg2Gti/mWtMRe+Rd58udSjs02jLB0=; b=WRM8/aTcaAqmV4ps9VYsD6lCemay6DYxpmbeD+N+CPslK9RhpRIzOyVI+XlM4Kd/F0hlaLihLrFaXbgnaMLqo8fnSpO0/0uPAPd5xOaS1UbNa5BJzOXmRpkAgjn7nlYynB1MAlFS6AP07usRS4/XvuTlzPELWXKhNgymSi4AtaM= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:32:47 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:32:47 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 08/13] kbuild: make address ranges map work with IBT Date: Mon, 5 Dec 2022 16:31:52 +0000 Message-Id: <20221205163157.269335-9-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P123CA0019.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::6) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bcffff0-422e-4ff2-9438-08dad6de57e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fiGrfpBp+9hmdKnmwg+GWVbkEAz7NjEeqK75kNfgxuXLGjyzKoOUcY1RzCaI9Ud70aUL8cHcrYVMpUHT0lIgplALqp52vxIgqm8sswZ6xsVx5JiLt+uRgiYeR9cdh2hHZgk3XdnRbMLhiNOWQUvxyjEHEYDq5WxL1pEnIwReR9QJCnpA37XBVu8vmBrZ6d2QudJmbkFEtahTLUpFfh5vRDj6zjhZSEptCw+tN1X9GjAWznd2IdP2j4bkKYqG8BU6SxdylZwYHL/ZzEN4itUk0gF/9qQmKFE8jJBOMBxYsZYioMmzlMi6BI7QgPmBDh8I02x8DIqMXIkCLLlGyDcHdD1WLO1jPn3z1bEycw1H9f73iedu/aIdSgX732W9T5EEUTN23oCqgn8RnPztA4IM2MCHc6a/LY7MysHgCbiPOd6+DgjvVJI2btpA35VKIQos8fvJ2+T5zCVD3QwDvB8SAbe4OSbQRpr3W4EgtEz5UWSjRFR4OZ/yxEWev/glenu9U0u0GIhWaOH5KtIAfbw8CH+uIr4j5D1oYWUM1WTQ8Sh5D3TSMvHrmKLLrRscKGL8Eq5XsuyHm2XFrM9UlQtPpQ7jXMDhClEgxcAIj6m26sQaTVRtpjCPVPDmocySX1450AcqV0iTFAUaenpD6JYtoA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(186003)(6512007)(38100700002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k0ZbPkUzWPFSxT9bUKsNwHWDlFP7WDegH/640c/xWeSK9smdMAUYjl+Nt/DP05yTSQ0Aua1uaJTcN0i5pR75vkeyWm1sIUdzBhNNZmIv3YpjcW39qtOwl29ABLWTpr+2pznkdNIjJXM1oQHBfOTpmiumdGHVhjmeKNreTpmCoV6kTUv2EOW8gEL1sv6m8CDsD5t1wqzqGtcIIAu3ddtL6Qi7cbOLIRj1HCBKFvxWGY4ZSllGyrQxXNPD6hdvcvD4I9r447Xr1gsk1qM7x5lzC2D3koNkOPyosh9ODD8AaDfrokQpoefl8rHBOAGmXAoSDeypAw0hZQrv90MB2Kzabuzd6IvQylxLFF8dLo7A7eiPPopBssjulTOqYY6bcmVKWvzIeKgoxS+FbBxcGgb6cAtaCw/pF9cmO3Pe8RULe1dvVc8n8zGfEJV9ubFma3+10ONEniS7L/NhAy0sYZSe6DgU8B8tFRw6aAc+fj1vQw4VKIprrPasqSdZrPq3/MspIDB59aYnnq0ShrG7DH3i3PZ0I6UNOVydkxJ5PdeexmXMBvGLhYxGo/GaF+fTkCly1IHk6Xac8RgLgX3hcu770mlKdYgZgNUXXuVxyrGHVDdZNFMFrYc7m80pNVOYTz0yGbnfESyA8tdAg27jbc95lhdqW0oRV8YE15pw/QJZeowurJGGZNwOHM36qBo1ak1erFjhXfWDfbLS0cjLz3+kIaoVh1NQ4S0QrLjfWmVQFwaQezOI1nHAk1Fiqg1+2uZIeYWmUa7hJd0ky9fofYsWqn6GsxqPAzfts0x5AUFeX1wt1s3i2IcPKtHMoR4dhQPm87WfS7L6pIW/7Ut2vNy1c4drI7Z7k8Kd1lNvina7aXjycIGA+xGH7tNbvpdz5fjfbHSqvP8/6VEhkI3tGpDGGcNH+rYfijCiytRwdlLA0e3O3Wf2sQvjwGW3ar0RIpCg+Tu1P7sLTWBD4EDeX1upbqEUrJrzVwzgjKmLCLxh3eYPtAUq3cW4jZlvtt02+LY7OwR686xO97jzLnSTOsm1xq0UF8VCs1b5PqONfDv5MT0zo7YvwuhtP2HwToZybU6lRW7zgQ88KIYZgk5yADntylQXfFf2Zxnbf26JQSRzfVbTiHcgRK03gV4SZfeRCdRTLpDhwjOhoMUbqjNbxbzMifxaLpTJ5d42TSWX/tXDsEDWFpyQfKHVR7PiSX0PI0Uvcjgp42P1opTN2pvZT4UiLWWKRwgBNs76n6YR3IIm4dWoKcwJGh903hPlbdlOl3xpjedVo9pOmhgrPyODkasLV+B+eCYZBmOe2FsGFJYHpewleMaUkWPmnn8PaJmDFmrAzUn68L0IwEMpy+WE7N5qRptMKXwydVXieJYXQkseFMZuS+PrLga7+9Eb0SGM5r4GSjO6+Rqw8EG771nmNDq/+VkHBmeb0j81G5ZtfiT9ph/8PS7HgFjJipjEZNCGObZUWDwC8lfMbCsKX+wp7D3b0HImLAQHWQRHEqQVDor6Qf0GijvMLptp5oULX37ouTMgPgXNoP4oqntV/Xr3+7/aJB/3mGQznUEWykGaj53Z2ruiiZLFCOEADgXVnvim+APwJ2W4y0ddWwCruFUVZTpeDA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YlueLCXaVtvidwBjRfCgqNmylUCmDK9n02wIZWZKhdjUR3Jiqs1rdJLtOJwihO7Qrniow/5IykLU+c0l5dtclgm+E1FlEAnkII2fNBVxfRbI6u1JYQkvR3FHfrkEZdN9EsPkiYyqCkW0h23ORBciruoa+RpP992Xl8A26eP0Hng5XYVg8gJAKM/fGIqvQIRm680cTdF9TR8kW0vjeWFMyUeOPmGEj6GZhWovwtcojh3iFQPGnwbY4r/xxuxo5eoiMkgCxkn1f0qH8xhbZbxuqE0HgFgxNE0+w3iFu+JKJpujwtr8SU328/hC9zIOnu+uzqW67ouoc/F5vAyu2EDINefZRSP0qQP3ZJ8LPP9kKATV5JN1cDSOW3KPXXHBMjBpj4tVq09xsW4IvG+GMfdYX/geSu/4qb5rOFeMubLRhefytDgytDLrSE4EhYeQOJKwdg3HDaLphLqHsZTtTXxb0TQOTx9rBq9R6PF0UaD3QDO2yZtbi+ZwJ/spHxVJNFCTdC6+5Uu8iNgJZf1Hp1bwiq6gF7pFdGUFkNEXk0950fDiqsphQfkxDSDgemQjKeGBEFUYWJQMT5c5+hZ6eQFaKjUEvuir0mnciUVdiYS0eczw8J4pdHqDLPcsr5DHW0yUaq3kQhFppxcX9HvW/6kbgfzC/waypLvZSHZzZ8o6jinXQYExF79K7XEdSTJBt1YnX0pJ94Oz64pilfZ45J9AZLnsd6zlqWXSrr5IFznPwSXbE2MDEoxKjCfF0w4DqMtN5PutEVesJm7gPTQUEKlCsb3WXDKJsL+OX9vXhaljxCRbbwrvGXCi2Rr8HyLjgwDKJjQK2X8vh/+UuKlW/+cg0NRiiKSEbh+LQlvCUHmSz43NTt3LnVbfUHK85dbvQeA6R5dkaM1YiciLBv8Eh8Sp6q2G1hGuhFQzOWTvx4uzmP/BKt389qBnx7mIVauNU4H9pVbQ5jr+nPPtGRozsx59CDwCPj7tZiz5vpT88G4391g= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bcffff0-422e-4ff2-9438-08dad6de57e8 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:47.4009 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HLymWR2t2NS95oTOeRFI4D3Y7c6hEDcB2jCst36RQHs35WYEXu1G5p30ZjbdhC7Q3ytBWGxKNrzjADCac9pv4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050138 X-Proofpoint-ORIG-GUID: sdWb27LiDak7CaaLZk5OpDM3BDmeRPYe X-Proofpoint-GUID: sdWb27LiDak7CaaLZk5OpDM3BDmeRPYe Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The previous commit emits .tmp_vmlinux.ranges, which maps address range/size pairs in vmlinux to the object files which make them up; this is used by kallmodsyms to let us associate symbols with object file names and kernel module names at address-range granularity (i.e., space-efficiently). But the previous commit only works if the final linker runs directly on the input .o files from the kernel build: if an intermediate ld -r is done, the final link emits a mapfile containing only the name of the intermediate ld -r (vmlinux.o), which messes up .tmp_vmlinux.ranges and makes kallmodsyms attribute all symbols to {vmlinux.o} which isn't much use for disambiguation. vmlinux.o has the object file names we need, but the addresses are all wrong so we can't use that either. This commit fixes that by extracting the addresses from the final vmlinux mapfile (or one of the intermediate kallsyms mapfiles) and using them to adjust the address/objfile name pairs extracted from the vmlinux.o mapfile, giving us a ranges map with the right addresses and the right names. It's a bit painful because the addresses are often large numbers, and awk is... not good at handling them (GNU awk can use large integers, but the feature is at risk of removal). So we emit a slightly different file format with a pair of hex values (the address in vmlinux.o and section address from the final mapfile), then pipe it through a tiny new C filter (scripts/addaddrs) whose only purpose is to add those two numbers together! One niggle is that .hot/.cold stuff is no longer correctly attributed to its object file any more -- it seems to not appear in any of the mapfiles at all (only in System.map), so I don't see any way to fix this. (This possibly makes it work with clang LTO too, but I haven't tested it, and if the mapfile format differs it will fail until that's fixed. But this definitely overcomes *one* of the roadblocks preventing clang LTO from working with kallmodsyms.) Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- Notes: v10: new. Documentation/dontdiff | 1 + init/Kconfig | 10 ++++++++++ scripts/.gitignore | 1 + scripts/Makefile | 1 + scripts/Makefile.vmlinux_o | 6 +++++- scripts/addaddrs.c | 28 ++++++++++++++++++++++++++++ scripts/link-vmlinux.sh | 34 +++++++++++++++++++++++++--------- 7 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 scripts/addaddrs.c diff --git a/Documentation/dontdiff b/Documentation/dontdiff index 17686f59039c..72c089eea111 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -79,6 +79,7 @@ SCCS System.map* TAGS aconf +addaddrs af_names.h aic7*reg.h* aic7*reg_print.c* diff --git a/init/Kconfig b/init/Kconfig index c45935cd2f1f..160ec1370594 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1570,6 +1570,16 @@ config POSIX_TIMERS If unsure say y. +config KALLMODSYMS + default y + bool "Enable support for /proc/kallmodsyms" if EXPERT + depends on KALLSYMS + select VMLINUX_MAP + help + This option enables the /proc/kallmodsyms file, which unambiguously + maps built-in kernel symbols and their associated object files and + modules to addresses. + config PRINTK default y bool "Enable support for printk" if EXPERT diff --git a/scripts/.gitignore b/scripts/.gitignore index b7aec8eb1bd4..d042f0e3d13f 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +/addaddrs /asn1_compiler /bin2c /generate_rust_target diff --git a/scripts/Makefile b/scripts/Makefile index 1575af84d557..356cafcd313d 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -5,6 +5,7 @@ hostprogs-always-$(CONFIG_BUILD_BIN2C) += bin2c hostprogs-always-$(CONFIG_KALLSYMS) += kallsyms +hostprogs-always-$(CONFIG_KALLMODSYMS) += addaddrs hostprogs-always-$(BUILD_C_RECORDMCOUNT) += recordmcount hostprogs-always-$(CONFIG_BUILDTIME_TABLE_SORT) += sorttable hostprogs-always-$(CONFIG_ASN1) += asn1_compiler diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 9b4ca83f0695..94c2ec366b91 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -27,6 +27,10 @@ ifdef CONFIG_LTO_CLANG initcalls-lds := .tmp_initcalls.lds endif +ifneq ($(CONFIG_VMLINUX_MAP)$(CONFIG_KALLMODSYMS),) +KBUILD_MAPFLAGS = -Map=$@.map +endif + # objtool for vmlinux.o # --------------------------------------------------------------------------- # @@ -47,7 +51,7 @@ objtool-args = $(vmlinux-objtool-args-y) --link quiet_cmd_ld_vmlinux.o = LD $@ cmd_ld_vmlinux.o = \ $(LD) ${KBUILD_LDFLAGS} -r -o $@ \ - $(addprefix -T , $(initcalls-lds)) \ + $(KBUILD_MAPFLAGS) $(addprefix -T , $(initcalls-lds)) \ --whole-archive vmlinux.a --no-whole-archive \ --start-group $(KBUILD_VMLINUX_LIBS) --end-group \ $(cmd_objtool) diff --git a/scripts/addaddrs.c b/scripts/addaddrs.c new file mode 100644 index 000000000000..d15cbbf8d262 --- /dev/null +++ b/scripts/addaddrs.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* Used only by link-vmlinux.sh */ + +#include +#include +#include + +int main (void) +{ + int i = 0; + while (!feof(stdin)) { + uint64_t a, b; + int ret; + char *rest = NULL; + + i++; + if ((ret = scanf("%" SCNx64 " %" SCNx64 " %m[^\n]\n", &a, &b, &rest)) < 3) { + fprintf(stderr, + "Syntax error: invalid line %i found in rangefile generation: at least three fields expected, %i converted\n", i, ret); + exit(1); + } + + printf("0x%018" PRIx64 " %s\n", a+b, rest); + free(rest); + } + exit(0); +} diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index a40d372b1289..3b3ea6214062 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -60,10 +60,7 @@ vmlinux_link() # skip output file argument shift - # kallmodsyms needs a linker mapfile that contains original object - # file names, so cannot use this optimization. - if { is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; } && \ - ! is_enabled CONFIG_KALLMODSYMS; then + if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then # Use vmlinux.o instead of performing the slow LTO link again. objs=vmlinux.o libs= @@ -153,12 +150,31 @@ kallsyms() # - but sometimes there is a line break after the first field # - start reading at "Linker script and memory map" # - stop reading at ".brk" + # if there is a vmlinux.o.map and LTO_CLANG or KERNEL_IBT are + # turned on, we have used a vmlinux -r'ed .o for linking: use this + # as our primary information source, but acquire section addresses + # from the (later) linker map we were passed in. This makes things + # a bit more complex, since we have to recognize and eliminate + # sections elided by the linker, and add together numbers larger + # than awk can portably handle. if is_enabled CONFIG_KALLMODSYMS; then - ${AWK} ' - /\.o$/ && start==1 { print $(NF-2), $(NF-1), $NF } - /^Linker script and memory map/ { start = 1 } - /^\.brk/ { exit(0) } - ' ${3} | sort > .tmp_vmlinux.ranges + if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then + ${AWK} 'BEGIN { addresses = 1 } + /^Linker script and memory map/ { start = 1 } + !start { next } + { got_section = 0 } + /^ \./ { section = $1; got_section = 1; if (NF == 1) { getline }} + addresses && got_section && !(section in addrs) { addrs[section] = $2 } + !addresses && got_section && section in addrs { print $(NF-2), addrs[section], $(NF-1), $NF } + /^\.brk/ || /^\.bss\.\.brk/ { addresses = 0; start = 0; nextfile } + ' ${3} vmlinux.o.map | scripts/addaddrs | sort > .tmp_vmlinux.ranges + else + ${AWK} ' + start && /\.o$/ { print $(NF-2), $(NF-1), $NF } + /^Linker script and memory map/ { start = 1 } + /^\.brk/ { exit(0) } + ' ${3} | sort > .tmp_vmlinux.ranges + fi fi # get kallsyms options From patchwork Mon Dec 5 16:31:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064758 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 CE183C47090 for ; Mon, 5 Dec 2022 16:34:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232920AbiLEQec (ORCPT ); Mon, 5 Dec 2022 11:34:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232548AbiLEQdq (ORCPT ); Mon, 5 Dec 2022 11:33:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986211F9C7; Mon, 5 Dec 2022 08:33:32 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fc1fA007848; Mon, 5 Dec 2022 16:33:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=nBeGtXAEMs7KAvRWYQGzRw9wzNveavWRhFn1oNHr4xI=; b=ipuoLx25Yt/L73BwvSqXfu46ZkO6lzJIuR0UFmMWRIoOfyEwPYkc3rZPGy0G7p8Brw/K IhsF6zQ8VDCpiWaSKMMUa7jIYLUi/JHu7YCVBltQGSTz/zn7XDtM5E6tpBf5NAVTu2gA Ea/Dwy0LXjjw7eKaQMNWFvAPnE1iX2Gw5Zh0Mb7wgMvi/pH1YmVLG6iyz0LxGYS7zgKm 7NgIftdwMwrDvkQky4T+7hplCQMOv5rtwrNjcv4mm7EkTrgsvjnhncLSbMw4jCUkwYoQ 8+HuLuv+qzUmXmAQKHOaciH1MGkwC3r0yrE7XlUJBIt8q/EU5HcN3k0W385+6Q3lEnfg Mg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7ybgmbgp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:25 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQwoS012906; Mon, 5 Dec 2022 16:33:24 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3m8u925434-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B5/1rCJ9/7W0UI/22xtlUOu5pPfCvrQjkYlBo1MrSWpOfU3flrnxfm1Pt509QwkZxlkmsXF07ks3h5nOCld7/ejaGIBcnxks4XLRVrwv8rQ4SUTleddtuFeiRCluDlT9ZG8VdD1N90U41s0XoH2kRqF3J+vpAbv/HdjKvKgJ2X6MS9KOOK9Q7UYOXWg6qi624+BtcpoxuTtXY8lCNtctqMoJ6+A5ET4AkNLjxCVnoohms59yddf9bWAzRqWEVuV3KRRNlVsyPGi5WDNwjFKF0Tn+vwwntGZMZ7cbIcTdd74FNmDJfEj5U54Yg1FIza2Fsch7EajPFv2hjzoEL+jvhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nBeGtXAEMs7KAvRWYQGzRw9wzNveavWRhFn1oNHr4xI=; b=nwvBjqDPqgHC8UbOnhTuazFOAsfSW6gqzEwCD2EyBCFNss2uJ9Dk7wvxZEzKz2pxioN03sGOBXi7Cew2oZYNh1MLWsLSUPFO/5WUmWd0E7etxEiHbYMEZZK0tbRv9mT7IipcoUMSFnQTVdesl0UKDLsChaXxJ4Yx+XZqwfTVFuelG0VZIzV6EKTKeBibleJG/rLaQXJ8+3fQwIQzwnWAvoLoPAyMDRnXA4vPOwAI2mf/Sfoh1KEkBno6IhwqW5sdiDpP2YhOipXubmPsUmhtmu/laW26iuyVJR5QtISxjxbpo24ynE+0i6uBzjGjb5lOP3N44eICwfC1RB4R7HoHXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nBeGtXAEMs7KAvRWYQGzRw9wzNveavWRhFn1oNHr4xI=; b=KlUpTPzwyRrLMUOv8VeFK2cBhkXMPdoQwuq+X9qZFdeNoPnm4UuS03CVdkYNhh+aEkWwGkazHbc2FFwQXd4JYDHpBgVeOxuB7LPW02MGoGGWGIhAclVDnoz4HI5mf3HbeHUX0DHdriRYpyGvkXx2/sXOc/i9xlx3CndS+OtylsA= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by DS7PR10MB7324.namprd10.prod.outlook.com (2603:10b6:8:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 16:33:00 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:33:00 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 09/13] kallsyms: introduce sections needed to map symbols to built-in modules Date: Mon, 5 Dec 2022 16:31:53 +0000 Message-Id: <20221205163157.269335-10-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P302CA0009.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:2c2::17) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|DS7PR10MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: 29411d67-2c55-492e-cbac-08dad6de5a6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 31QypZFNgEzfPNBQSEwKoT++nkSxPiBG3SAZcSNV68WsP47HeY0GepLY+jbUBA262UpcLoXL6+cttgF4gzQCcElGvcl4mZoLQLMcifXIRvpgazhaculvnTJjOPoY0c2rUXHu6V26u39PRYlkOcoNx1tpA+sbpXITxOoj+78Xm1iMoF0c+5t2fL3jYiGJQsl+vhqK/OR9ngpbBJtY6qlqdJDhJICtCM1ciCH3+9AA650RQamHnhMkW6dj+JDteVzUR6yB0N3Go/IiWvzjXbM3bZqjTZDkD28CegX8/cvBxlwaL/lTJE67+nuHLyhTVXs1/tEigyHiuYtInS///vK3madZnzy+5+YtW9ebyJ4y+bbpjsExh/exahfVgO9B9dbkVndcu9DHUZKbvyGt2G7GGVplM3lN4xd8fT3ub/40R8ohgDVCZXOgF/dKa304nUfAbJOxJABkEGPAsoVWRW3PXilH9wOLX7UhiTnxh2RvACjPrHWCWamnMduaXcCceFa5nC2749SbLqZDzlQg9eQCO6IlMpz9q31FdSU/BZ7iRE6ej37JEq6NNMw9Nv2E4dfPZkdHHJvhj6naRUON1sGLRZxkCbVJpNJLGU2Tu1b+8/h0bm64Klv6XlnrYSZ8o9LXiVOcE1AWm28xyuifqv1leg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199015)(86362001)(36756003)(1076003)(2616005)(41300700001)(66946007)(4326008)(66476007)(66556008)(8676002)(30864003)(44832011)(8936002)(5660300002)(6506007)(6486002)(107886003)(478600001)(6666004)(316002)(45080400002)(186003)(6512007)(38100700002)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zQvgeYJ3pdQlPM3FRl0xnJXla74MP4mH9PbABnYMMX/ksc0m9jzyZEuCpUjVXMI1yEqbYOsjLRk9B2aPCUUWxUzrJaIDs01Jo6QMa8FJ+AZ2Rzkl2tuRr27pmCubUWh5WZP3t81L1w7qwrp2/3EkMt1myK5tSQidOetdrmDcPtRTYnvN3UWwQ8niQE1OI1tAUuWy3ctApCYMK/KWDFR10NucXh1dL10VLcKSussDRWIaTYGj7RdH2VfUMaq1GYvX0U6wd7lZ7TdOlXyH7nYjip9rPZXvC1HM5KnnTIJH3xiXY4UFjcHAbegIdaYAwn1ifCrCOxthZFLd9mu1+XgOj5S+in41AoOD5+K+RXUWMyuhveoVH0azJeXVCOl0rURj5HqwmDOJJm1e/NtWqSdIoBpPipdKDQkjdE5nIGjSsd1ucT2iIV+tUM0SD62s/UmC7JHVM4GV2wPx/DIYxHXZK1CRw/bl/CTkExrAbXjoDZ6HDIZn6Tly90azeRBeIEjCxZYzm0WCzG839JKNYXiW5I1+BS8nJTF/tfkOyyWtOtNAN2MwnEN9cBIW/SA2M7HbLW0UHg7TC95ofutFwF9XNX+3+tcsKMYEP/DEM49g+j9x473hFcZb7/5X7cs0QHq4wPZQ9+eUl197kUKjZTMM3nGo7NTO5hSDDFVsOxnp1fFJbIubK1TUDUrQRv5lRJW3bVD7qmu3bxv4MMxSTwxnQM0AKs+sVyUiLeE/EuasT/XMPfG2wqZ9gojn877bCHYgn2heqQjNmxQNiGg/mFT/MZ7Zc+31V40bsQ1pslYI7KUh6RADVupj0icvYx517c51FjeDoHAAcMkYOgIH/bgc3xQr8oUFC+op7qstlPsqw1brLEzhaQ/ooB4PAnoaKblX6KcBXt/IyfRYaNrxQr8abAhNVQJEfWAoJz8OLAqYaECSm9VENxBH0YnfDb+FMxHE6FGzMdTYZRKvoQnM/PCnRGrj5CPdGfEgdY9ZXVT0QRi84q8deL3TJk9zXpKd3gJ1eOsSmk+9q2tpWUemLe9UWhB74uD2pVajI/gvBdsbei+6o2/+BJsZ1poYwofPprH1JPkirwEXrtX9cMplt1NEUITD5z9opDOPh78bHncmFRFmn/zE1t3necP5o4Zl+7eEvGJq7tIA5YwFE4Cl+CZrPmM7efZWvcsE7x159enEUXQRvvGb9J+j9xYObeYGn8ZJPqfHlwWPTmqIx2sdxFrweLS5XjM6ZpsNcE0JWvjRIZuWH1/M4rVsaJMatZd2/wxHYmcTAX/CcXrhRf4/l5D3QkSR8qEKOGI8PkDgWvMROhQrymb4A5BC7f0yxWYiJoqaZ+puIhkzfClE/v8CReG9NstBU+1o/t7RUmbwGj4VRQE4s9hY43KaahDslwEE4Po0MgGVk7IQGxQs8WqNRE5OWG98AI/bnJgltYXICIAWMfunYezKXjuDc+44zfqDmVZEMJcwAqxsxLd81/FJd75KeqZtyH8iKnCwG6bvGYq4RkfCi1iUj1n6c9aSgb7TStM9v4oweQgIfeBIlJ0xQiXOdegpiXXYZXM0RsrI1XwzlEesyl6st5tEhA3G1nvdWN0fYdGqeTlL9ItLhK4X+jWbzQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: n3I5lwdW+tPyCDRNkkbs8+nYf6wMEbUpf9Ir+12LVqDj28QZrs4r980yjMRdKU6hW/9u/VqtjTrCSMaZkfJsDBU2s+AGR+7+jXMVo9HV8GctIXT+meqk17TDI0tQLXmC6v1SOKG5C0YWsW021qLVWkerKL0g24YvGyMqQIBVXPj+1Iki7PgW+bVEXPmO2HhQ1GVgIKGB26HpFmKYKVD20/Oq6HMOEasOdu12whbBgJ/mtzvMeaE1wZ7gtiI1rWbnqfPHUVmo0FQ9ejSnF2522z5llUhQbnA+HaTUgC0k/0JfbFcKP8lvo4i26XPDjtN9HcbbYWzbRSZ0726tAOazmUuwnn0JojbYgW+eJuwbH5gYzVoq6Dww2XoFLJDe42+OPScTuBl9lkxKyvkI63x+J3dH22b5Xzo5Luv/DofiC4Pmbk+qOn6PILRQvm1GviZGN7taOBj+1ALGL9Lnyh8r/VC6qj0ZOMNRe/pSdYiu1GD+bpwmzoz+jI4dWZHRxKQ9GyGr5vihqvjpTtsgyMMFRnnOdWkWIsbB9mfMpYAVPnZ8PA+C4crlnVV4zCKSKGzPJlkVIR79xdheJELax6tB/u+ceDLG2Xzgw63IIIPgrFsNEWN1RfXlvzG4wEPhoEogWCv2/HBrzjnrIJtkiqn7Q2vFRy02bJwN9fhNEboXLTtjqeaQBiQmIYRi1sDp9cmTLBYSC+DNiMWAUBZWs7we27XNt2ZiUZtUwDQ+o0rQIB9kbyW36kiUP6coV54FWZG+Op5hKDDGSp+9jGEqCM/ZeY0hYasESC7wWBw2Y7CM09di0IB8jGbb9Vl3sqzxr0wWJCncW0cUF9yRwMy7X51tamY93pORt3GtLACbvr/2IG3Mu/HlwyhG+KVWJ1yeBU/3zNHKdIxbW0y3Rve8F8xCjNgyNToONcAbs8Fazpn9YSLPS0qtEN1OP9PZ+shLjkHTWDkEXB2/vZ9gNIipBZgracPPhTXYxqvQIpuWy+Fduuk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29411d67-2c55-492e-cbac-08dad6de5a6c X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:51.6228 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R6s+NQPei2ihQDziOD86HfKq7CEW38N6NQstvUhUxM9bit5JlH/s9/wPTPkiIP7NUqbWaS01HE+ytoz4ofPsgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7324 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050138 X-Proofpoint-ORIG-GUID: p1VWc0XnHSJCH4MtZs_gj2zPZyiJ7F72 X-Proofpoint-GUID: p1VWc0XnHSJCH4MtZs_gj2zPZyiJ7F72 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org This is part of the kallmodsyms machinery, allowing disambiguation of every symbol in the kernel by annotating symbols that are part of built-in modules with their module name. In order to do this we need a space-efficient way to associate symbols with modules without annotating every single symbol. The mapping needed to do this consists of three new symbols, computed by integrating the information in the (just-added) .tmp_vmlinux.ranges and modules.builtin.objs: taken together, they map address ranges (corresponding to object files on the input) to the names of zero or more modules containing those address ranges. - kallsyms_module_addresses/kallsyms_module_offsets encodes the address/offset of each object file (derived from the linker map), in exactly the same way as kallsyms_addresses/kallsyms_offsets does for symbols. There is no size: instead, the object files are assumed to tile the address space. (This is slightly more space-efficient than using a size). Non-text-section addresses are skipped: for now, all the users of this interface only need module/non-module information for instruction pointer addresses, not absolute-addressed symbols and the like. This restriction can easily be lifted in future. (Regarding the name: right now the entries correspond pretty closely to object files, so we could call the section kallsyms_objfiles or something, but the optimizer added in the next commit will change this.) - kallsyms_mod_objnames encodes the name of each module in a modified form of strtab: notably, if an object file appears in *multiple* modules, all of which are built in, this is encoded via a zero byte, a one-byte module count, then a series of that many null-terminated strings. As a special case, the table starts with a single zero byte which does *not* represent the start of a multi-module list. (The name is "objnames" because in an upcoming commit it will store some object file names too.) - kallsyms_modules connects the two, encoding a table associated 1:1 with kallsyms_module_addresses / kallsyms_module_offsets, pointing at an offset in kallsyms_module_names describing which module (or modules, for a multi-module list) the code occupying this address range is part of. If an address range is part of no module (always built-in) it points at 0 (the null byte at the start of the kallsyms_module_names list). There is no optimization yet: kallsyms_modules and kallsyms_module_names will almost certainly contain many duplicate entries, and kallsyms_module_{addresses,offsets} may contain consecutive entries that point to the same place. The size hit is fairly substantial as a result, though still much less than a naive implementation mapping each symbol to a module name would be: 50KiB or so. Since this commit is the first user of the modules_builtin iterator, introduce rules to actually build it when CONFIG_KALLMODSYMS is set. Since it's also the first user of the new Kconfig symbol to enable compiling-out of /proc/kallmodsyms support, introduce that symbol too. Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- Notes: v9: Rename .kallsyms_module_names to .kallsyms_mod_objnames now that it contains object file names too. Adjustments to the Kconfig wording; adjustments to modules_thick.builtin rules. Adjust to getopt_long use in scripts/kallsyms. scripts/Makefile | 6 + scripts/kallsyms.c | 375 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 373 insertions(+), 8 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 356cafcd313d..9312d36107aa 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -33,6 +33,12 @@ ifdef CONFIG_BUILDTIME_MCOUNT_SORT HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED endif +kallsyms-objs := kallsyms.o + +ifdef CONFIG_KALLMODSYMS +kallsyms-objs += modules_builtin.o +endif + # The following programs are only built on demand hostprogs += unifdef diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 04e04fbd9625..48bf4661bd09 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -5,7 +5,10 @@ * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * - * Usage: nm -n vmlinux | scripts/kallsyms [--all-symbols] > symbols.S + * Usage: nm -n vmlinux + * | scripts/kallsyms [--all-symbols] [--absolute-percpu] + * [--base-relative] [--builtin=modules.builtin.objs] + * > symbols.S * * Table compression uses all the unused char codes on the symbols and * maps these to the most used substrings (tokens). For instance, it might @@ -25,6 +28,10 @@ #include #include #include +#include +#include "modules_builtin.h" + +#include "../include/generated/autoconf.h" #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) @@ -86,11 +93,118 @@ static int token_profit[0x10000]; static unsigned char best_table[256][2]; static unsigned char best_table_len[256]; +#ifdef CONFIG_KALLMODSYMS +static unsigned int strhash(const char *s) +{ + /* fnv32 hash */ + unsigned int hash = 2166136261U; + + for (; *s; s++) + hash = (hash ^ *s) * 0x01000193; + return hash; +} + +#define OBJ2MOD_BITS 10 +#define OBJ2MOD_N (1 << OBJ2MOD_BITS) +#define OBJ2MOD_MASK (OBJ2MOD_N - 1) +struct obj2mod_elem { + char *obj; + char *mods; /* sorted module name strtab */ + size_t nmods; /* number of modules in "mods" */ + size_t mods_size; /* size of all mods together */ + int mod_offset; /* offset of module name in .kallsyms_mod_objnames */ + struct obj2mod_elem *obj2mod_next; +}; + +/* + * Map from object files to obj2mod entries (a unique mapping). + */ + +static struct obj2mod_elem *obj2mod[OBJ2MOD_N]; +static size_t num_objfiles; + +/* + * An ordered list of address ranges and the objfile that occupies that range. + */ +struct addrmap_entry { + char *obj; + unsigned long long addr; + unsigned long long end_addr; + struct obj2mod_elem *objfile; +}; +static struct addrmap_entry *addrmap; +static int addrmap_num, addrmap_alloced; + +static void obj2mod_init(void) +{ + memset(obj2mod, 0, sizeof(obj2mod)); +} + +static struct obj2mod_elem *obj2mod_get(const char *obj) +{ + int i = strhash(obj) & OBJ2MOD_MASK; + struct obj2mod_elem *elem; + + for (elem = obj2mod[i]; elem; elem = elem->obj2mod_next) { + if (strcmp(elem->obj, obj) == 0) + return elem; + } + return NULL; +} + +/* + * Note that a given object file is found in some module, interning it in the + * obj2mod hash. Should not be called more than once for any given (module, + * object) pair. + */ +static void obj2mod_add(char *obj, char *mod) +{ + int i = strhash(obj) & OBJ2MOD_MASK; + struct obj2mod_elem *elem; + + elem = obj2mod_get(obj); + if (!elem) { + elem = malloc(sizeof(struct obj2mod_elem)); + if (!elem) + goto oom; + memset(elem, 0, sizeof(struct obj2mod_elem)); + elem->obj = strdup(obj); + if (!elem->obj) + goto oom; + elem->mods = strdup(mod); + if (!elem->mods) + goto oom; + + elem->obj2mod_next = obj2mod[i]; + obj2mod[i] = elem; + num_objfiles++; + } else { + elem->mods = realloc(elem->mods, elem->mods_size + + strlen(mod) + 1); + if (!elem->mods) + goto oom; + strcpy(elem->mods + elem->mods_size, mod); + } + + elem->mods_size += strlen(mod) + 1; + elem->nmods++; + if (elem->nmods > 255) { + fprintf(stderr, "kallsyms: %s: too many modules associated with this object file\n", + obj); + exit(EXIT_FAILURE); + } + return; +oom: + fprintf(stderr, "kallsyms: out of memory\n"); + exit(1); +} +#endif /* CONFIG_KALLMODSYMS */ static void usage(void) { fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] " - "[--base-relative] [--lto-clang] in.map > out.S\n"); + "[--base-relative] [--lto-clang] [--builtin=modules.builtin.objs] " + " in.map > out.S\n"); exit(1); } @@ -114,10 +228,16 @@ static bool is_ignored_symbol(const char *name, char type) "kallsyms_offsets", "kallsyms_relative_base", "kallsyms_num_syms", + "kallsyms_num_modules", "kallsyms_names", "kallsyms_markers", "kallsyms_token_table", "kallsyms_token_index", + "kallsyms_module_offsets", + "kallsyms_module_addresses", + "kallsyms_modules", + "kallsyms_mod_objnames", + "kallsyms_mod_objnames_len", /* Exclude linker generated symbols which vary between passes */ "_SDA_BASE_", /* ppc */ "_SDA2_BASE_", /* ppc */ @@ -264,8 +384,8 @@ static struct sym_entry *read_symbol(FILE *in) return sym; } -static int symbol_in_range(const struct sym_entry *s, - const struct addr_range *ranges, int entries) +static int addr_in_range(unsigned long long addr, + const struct addr_range *ranges, int entries) { size_t i; const struct addr_range *ar; @@ -273,7 +393,7 @@ static int symbol_in_range(const struct sym_entry *s, for (i = 0; i < entries; ++i) { ar = &ranges[i]; - if (s->addr >= ar->start && s->addr <= ar->end) + if (addr >= ar->start && addr <= ar->end) return 1; } @@ -287,8 +407,8 @@ static int symbol_valid(const struct sym_entry *s) /* if --all-symbols is not specified, then symbols outside the text * and inittext sections are discarded */ if (!all_symbols) { - if (symbol_in_range(s, text_ranges, - ARRAY_SIZE(text_ranges)) == 0) + if (addr_in_range(s->addr, text_ranges, + ARRAY_SIZE(text_ranges)) == 0) return 0; /* Corner case. Discard any symbols with the same value as * _etext _einittext; they can move between pass 1 and 2 when @@ -380,6 +500,121 @@ static void output_address(unsigned long long addr) printf("\tPTR\t_text - %#llx\n", _text - addr); } +#ifdef CONFIG_KALLMODSYMS +/* Output the .kallmodsyms_mod_objnames symbol content. */ +static void output_kallmodsyms_mod_objnames(void) +{ + struct obj2mod_elem *elem; + size_t offset = 1; + size_t i; + + /* + * Traverse and emit, updating mod_offset accordingly. Emit a single \0 + * at the start, to encode non-modular objfiles. + */ + output_label("kallsyms_mod_objnames"); + printf("\t.byte\t0\n"); + for (i = 0; i < OBJ2MOD_N; i++) { + for (elem = obj2mod[i]; elem; + elem = elem->obj2mod_next) { + const char *onemod; + size_t i; + + elem->mod_offset = offset; + onemod = elem->mods; + + /* + * Technically this is a waste of space: we could just + * as well implement multimodule entries by pointing one + * byte further back, to the trailing \0 of the previous + * entry, but doing it this way makes it more obvious + * when an entry is a multimodule entry. + */ + if (elem->nmods != 1) { + printf("\t.byte\t0\n"); + printf("\t.byte\t%zi\n", elem->nmods); + offset += 2; + } + + for (i = elem->nmods; i > 0; i--) { + printf("\t.asciz\t\"%s\"\n", onemod); + offset += strlen(onemod) + 1; + onemod += strlen(onemod) + 1; + } + } + } + printf("\n"); + output_label("kallsyms_mod_objnames_len"); + printf("\t.long\t%zi\n", offset); +} + +static void output_kallmodsyms_objfiles(void) +{ + size_t i = 0; + size_t emitted_offsets = 0; + size_t emitted_objfiles = 0; + + if (base_relative) + output_label("kallsyms_module_offsets"); + else + output_label("kallsyms_module_addresses"); + + for (i = 0; i < addrmap_num; i++) { + long long offset; + int overflow; + + if (base_relative) { + if (!absolute_percpu) { + offset = addrmap[i].addr - relative_base; + overflow = (offset < 0 || offset > UINT_MAX); + } else { + offset = relative_base - addrmap[i].addr - 1; + overflow = (offset < INT_MIN || offset >= 0); + } + if (overflow) { + fprintf(stderr, "kallsyms failure: " + "objfile %s at address %#llx out of range in relative mode\n", + addrmap[i].objfile ? addrmap[i].objfile->obj : + "in always-built-in object", table[i]->addr); + exit(EXIT_FAILURE); + } + printf("\t.long\t0x%x\n", (int)offset); + } else + printf("\tPTR\t%#llx\n", addrmap[i].addr); + emitted_offsets++; + } + + output_label("kallsyms_modules"); + + for (i = 0; i < addrmap_num; i++) { + struct obj2mod_elem *elem = addrmap[i].objfile; + /* + * Address range cites no modular object file: point at 0, the + * built-in module. + */ + if (addrmap[i].objfile == NULL) { + printf("\t.long\t0x0\n"); + emitted_objfiles++; + continue; + } + + /* + * Zero offset is the initial \0, there to catch uninitialized + * obj2mod entries, and is forbidden. + */ + assert(elem->mod_offset != 0); + + printf("\t.long\t0x%x\n", elem->mod_offset); + emitted_objfiles++; + } + + assert(emitted_offsets == emitted_objfiles); + output_label("kallsyms_num_modules"); + printf("\t.long\t%zi\n", emitted_objfiles); + printf("\n"); +} +#endif /* CONFIG_KALLMODSYMS */ + /* uncompress a compressed symbol. When this function is called, the best table * might still be compressed itself, so the function needs to be recursive */ static int expand_symbol(const unsigned char *data, int len, char *result) @@ -538,6 +773,11 @@ static void write_src(void) printf("\n"); } +#ifdef CONFIG_KALLMODSYMS + output_kallmodsyms_mod_objnames(); + output_kallmodsyms_objfiles(); +#endif + output_label("kallsyms_num_syms"); printf("\t.long\t%u\n", table_cnt); printf("\n"); @@ -855,7 +1095,7 @@ static void make_percpus_absolute(void) unsigned int i; for (i = 0; i < table_cnt; i++) - if (symbol_in_range(table[i], &percpu_range, 1)) { + if (addr_in_range(table[i]->addr, &percpu_range, 1)) { /* * Keep the 'A' override for percpu symbols to * ensure consistent behavior compared to older @@ -882,14 +1122,124 @@ static void record_relative_base(void) } } +#ifdef CONFIG_KALLMODSYMS +/* + * Read the linker map. + */ +static void read_linker_map(void) +{ + unsigned long long addr, size; + char *obj; + FILE *f = fopen(".tmp_vmlinux.ranges", "r"); + + if (!f) { + fprintf(stderr, "Cannot open '.tmp_vmlinux.ranges'.\n"); + exit(1); + } + + addrmap_num = 0; + addrmap_alloced = 4096; + addrmap = malloc(sizeof(*addrmap) * addrmap_alloced); + if (!addrmap) + goto oom; + + /* + * For each address range, add to addrmap the address and the objfile + * entry to which the range maps. Only add entries relating to text + * ranges. + * + * Ranges that do not correspond to a built-in module, but to an + * always-built-in object file, have no obj2mod_elem and point at NULL + * instead. Their obj member is still filled out. + */ + + while (fscanf(f, "%llx %llx %ms\n", &addr, &size, &obj) == 3) { + struct obj2mod_elem *elem = obj2mod_get(obj); + + if (addr == 0 || size == 0 || + !addr_in_range(addr, text_ranges, ARRAY_SIZE(text_ranges))) { + free(obj); + continue; + } + + if (addrmap_num >= addrmap_alloced) { + addrmap_alloced *= 2; + addrmap = realloc(addrmap, + sizeof(*addrmap) * addrmap_alloced); + if (!addrmap) + goto oom; + } + + addrmap[addrmap_num].addr = addr; + addrmap[addrmap_num].end_addr = addr + size; + addrmap[addrmap_num].objfile = elem; + addrmap[addrmap_num].obj = obj; + addrmap_num++; + } + fclose(f); + return; + +oom: + fprintf(stderr, "kallsyms: out of memory\n"); + exit(1); +} + +/* + * Read "modules.builtin.objs" (the list of built-in modules). Construct the + * obj2mod hash to track objfile -> module mappings. Read ".tmp_vmlinux.ranges" + * (the linker map) and build addrmap[], which maps address ranges to built-in + * module names (using obj2mod). + */ +static void read_modules(const char *modules_builtin) +{ + struct modules_builtin_iter *i; + char *module_name = NULL; + char **module_paths; + + obj2mod_init(); + /* + * Iterate over all modules in modules.builtin.objs and add each. + */ + i = modules_builtin_iter_new(modules_builtin); + if (i == NULL) { + fprintf(stderr, "Cannot iterate over builtin modules.\n"); + exit(1); + } + + while ((module_paths = modules_builtin_iter_next(i, &module_name))) { + char **walk = module_paths; + while (*walk) { + obj2mod_add(*walk, module_name); + walk++; + } + free(module_paths); + } + + free(module_name); + modules_builtin_iter_free(i); + + /* + * Read linker map. + */ + read_linker_map(); +} +#else +static void read_modules(const char *unused) {} +#endif /* CONFIG_KALLMODSYMS */ + int main(int argc, char **argv) { + char *modules_builtin = "modules.builtin.objs"; + while (1) { + static int has_modules_builtin; + static struct option long_options[] = { {"all-symbols", no_argument, &all_symbols, 1}, {"absolute-percpu", no_argument, &absolute_percpu, 1}, {"base-relative", no_argument, &base_relative, 1}, {"lto-clang", no_argument, <o_clang, 1}, + {"builtin", required_argument, &has_modules_builtin, 1}, {}, }; @@ -899,12 +1249,21 @@ int main(int argc, char **argv) break; if (c != 0) usage(); + + if (has_modules_builtin) { + modules_builtin = strdup(optarg); + if (!modules_builtin) { + fprintf(stderr, "Out of memory parsing args\n"); + exit(1); + } + } } if (optind >= argc) usage(); read_map(argv[optind]); + read_modules(modules_builtin); shrink_table(); if (absolute_percpu) make_percpus_absolute(); From patchwork Mon Dec 5 16:31:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064757 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 2B8FBC4321E for ; Mon, 5 Dec 2022 16:34:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232887AbiLEQe2 (ORCPT ); Mon, 5 Dec 2022 11:34:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232323AbiLEQdp (ORCPT ); Mon, 5 Dec 2022 11:33:45 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E31DF67; Mon, 5 Dec 2022 08:33:30 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5FhsIx018566; Mon, 5 Dec 2022 16:33:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=9F/+18Uokw90L39bo1hOkJcegJluMpq3v31MmwEUqhw=; b=NVroG4hZMYWMvhVeKPIFnny+aLEwlL7wopIDWEvF+fLDJOHN2MENnRglOqbprT/QFubt c7ZTG5HAuNIpwfF43Tv77ClhdScx427dMNdjnsrnr2cevDUunwVuBF3N9xEy+8QcjrKA EDQBUUybDAbifPo/fOgAjvHhxv2cZ08rmNBk7kPCuW8Xx50ENW5kWURWI16dd5Gx/MfU +xP3IrzY/DN1PHLP6iRMRm9nxQeVjh/5274PkVGX3RFAE52VHmNBeDCag8qjaYjNnl16 YGj3PtHSWeyWu0mSx2p2cvS6NajSARrxUBN0/vdJ+iZzAeoeaEC4E4P6FtJURMtAXX11 lg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7yb3c9su-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:24 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQu6m027839; Mon, 5 Dec 2022 16:33:23 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ua9dpwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bbm9JFuSJo5oxlOUFDh+a5FQWGYsDL/hCyr/lGwg3uEBx7Opawi31ECywY/JAs/srcvmCyJsRvGhNoB9G3FxaXyQpcSIdwMEZqbw1CYEZ4DASeEW+p3hJ9es1+En058IVIH0VHWdLZ0dPt9U/S2BoL5/RycSLsUFVACLTkepsL15+VgDbJ5Zp39JLN23ClCPDsMXkPEgX8EKJHUMdChkXwVWNTX57EqvLZAI941z6oNWIUALEDw5zz7rHBPO2L/KMQ/2G+TdGxzxKKVkZNKkE+aIEjWFYu1qSlBX3Yc7cXjIGlpwzsWXe/BSMO+v0JpDurC98tRfqngi7P99zRdz1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9F/+18Uokw90L39bo1hOkJcegJluMpq3v31MmwEUqhw=; b=RqI9GCfyCQ3o2uK3UBeQP6vWMYbN2YuH0WT2lrDhBcaGFunjeyTSmU7eKN6ei2vFsKTRCwzvJfhu0x0GJcKrvu4aBD5uue20jvuwF4Eq0jkUv3dqnLfwCqZbTGNokdR5fQ2uzdHVmBioWelxfVwiYm7B559A0pyqpjkLChPsy/EsWc7IWS44baAs97AM35U5I20fm5a+PBJDoOmKM+Z+6+MSi6qVOLMhcc01hiJTdtq90hq5hDrsPKNFTlhreMaZolCyc3/vzQcNRyZuQmbqEey3fYmLaxsNVNt39okHbQ07Jl89V4S+PjQ1CyjT595Qvak+GoPrNmCiEn9GGlMvOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9F/+18Uokw90L39bo1hOkJcegJluMpq3v31MmwEUqhw=; b=nrvLkK9Z1dgudoLULqjmLx6P2LZhLvZs5H2tlxJHz4XC1eNy0W7QIse7wyPUJGma1AJgxcYw7/toyJsZfsA+JHS8BS5xy+T6ClTbx2jfjcRnz/liB777tCE2azolHg8wOZDVKjMS5UU/w7hMhRBfMmGBB8xshADIf0NNH7UqLG8= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by PH7PR10MB5721.namprd10.prod.outlook.com (2603:10b6:510:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Mon, 5 Dec 2022 16:33:21 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:33:21 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 10/13] kallsyms: optimize .kallsyms_modules* Date: Mon, 5 Dec 2022 16:31:54 +0000 Message-Id: <20221205163157.269335-11-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P302CA0002.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:2c2::8) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|PH7PR10MB5721:EE_ X-MS-Office365-Filtering-Correlation-Id: 615acd7d-2005-477f-1276-08dad6de5cb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zIGz6JQ50rhB5Qb5znSlWjv6YKt4jAUhIlil4/JR+J52yOKUoOlf+sAQFaFd3tSTkMXKmDTBC40eb/zPfZEYvZbZEHdzDF//6ngu5PCMkQtksSa+JSOaXFDU7mDYG0W9rQzgdosaBQHp4TPDpRbCLo146ydJxWe4wo0tR9TTcSIE03tyTC5SrfbFU79JhmeuNsapptvIF9E7CLX0dJ1fj11EO5K7o/iyicAbEKurXliIgEM2G9NnARGvTEJqCGPPeHizKQard3W7APMNweL+fIXh/OVg64pPEBO5CBN4Qj93/xbfedR1wWmd8HT/Cu8O2HhGpnVCtW5w6Yynlxndg7rK+3szQDxrr7lDgp4gh4s3KbHz8qgkfUIKvg92HVOkGkXaoaBwTKPKaRxNJUHAarfCeA7ak+gxOsX8isKfPag7lpEp7InKNNi7wClZIEmr1uopfxfN4qXJXalkNEbMshsK7cxdsGUXPBiKdTJxnv864hCCd3bS74WJUImfV6C96b9UWaY2gW8zGx8eVQcndvuLTY/qK2s9EjZkxRaDRWW9qJvI5Ktmf3JGmbaxeKyZcKBv6kCu7Q4NtjlwZEa1h7y4XTYu0Y1+hNj3vaSitYlHUNA3IvmxX6wuuNmQAJp/Fr9yYafoGSy5/xcn35Wh2JcLdZqIyxxXElauAY8yIr4in6vNJPEX9mZJrLZaCCq0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(136003)(346002)(396003)(39860400002)(451199015)(316002)(6486002)(107886003)(478600001)(6666004)(6506007)(6512007)(66946007)(8676002)(4326008)(66476007)(66556008)(83380400001)(30864003)(8936002)(5660300002)(44832011)(186003)(41300700001)(2906002)(1076003)(36756003)(2616005)(38100700002)(86362001)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cDeQ7vIJ8NU3niMj9fCUX+MR7ZLLvWAMPAbsjnaOacKmxi+ICVlHF5y9+ji8Vr2EK2Ucn4SOJjYd0fzGDc7z99d8TK3ikbCe++teRke2YNFa4n8GLAeCoALc5LlOEC5pFLpsulgKuqmxi7Q5ZcRcy/rbY7Jvo/LYM6bPEy8UWcu7SL1WgJjBiqByU+qPsFx/AZOuNq5FbpO7r4/fKqTQ9j3yaYkjhop4gmcHOjcJevXRDuIWk3KBV1zZHPNmB5EsbszBn4mzq+2UgUNsH5envC7NLO3bU/Ttpqw9LH8zylfiGGXnndbTwGSTrypYUqmLD253tl75+OrUjhAD8ipF45B8YdWA7z4oxVUdJC/vc7sxOl8O7svs2V5dVRh5UkMsYMQowCGjjy0XI7zH/lOsab2GK3zKTO8DlfUsAGdeRAWhzzL7B6MVYybdxFTktm6Wx66cPAnxXY2cynZhwG7ASSl4ICR5yVgpBmJOj+d3ImnN06Iyw0bjziiS9zgikBL7D9jtbM5Wgvvgz2+6rb7IumUgAcotqc84DMYiL5ci+WhdHrrDcV38bBfYwWcHTKmK07P6xQ1M+ZNKO7neNaCWxaO9k2IA0VemrqEoxBeMO0LEuNZMD9SvWQ6a+s9+GL4rZBbXC7qJkdzMKGaDME//ttJ76UbhgiGNFOIfum0YTKEGciugCwkji21bBAufn6j2oWfTjDiIJdpm3T8PXwOWbtQ3sz5nsbxH9i6OdiFxaYFJbIFjx+KYGwTMnUw11Apyo9OhUadN7xuANMA4fFaZW0YFd0g0Rx/DCEhxDmFinv2ATjsWA+pTNve15gW8y8+pi4q9B5NuUdxfHJ/7gbeya/84JGtOAxkbKLVRTASm/gWhtXS42EyylGZXLn6dPoSbkmFhrsGji4SmNVLMfI5UZccWbPDuCS0GlaNoA0LdV+S8TKE7NTlEjS4VAn9jo+FdW4mM8AWQQ8lSdgjmuRK841cEzR5NWNlDVoU71sViwG7tYv4jXh+UVIUIeV0Q/Udb1lyeE5QCnLt5Fx2nOlFd4jRLmhcEolAibmEoiWzrF6O4P8p2kcUYi30HvqzYcc5qkj9+R9Y5kx9PnNk5OiTxi+A+aGkdwm93e9i+K9qgI0nJFWMuq5n30+gpVvQxM94V6T5wAG7Fen0WV7vK0maK6jc0u2ztcq850cdFRgZY8lTiyr+mWdVf3cyL02EqgGSLaarYCrxRzAyHsy+txocL1ZfoUFntXUU8opeuO2EX33YKz0Evj7Jiw4rVukLc1ZDB1BR1OwlmLKd9gpa94XZ7nS9eJvA8ZITRvmVasoQ48A9/a4liHxU+s40mrDFRM3LeWqX9HczP6WT04/VwFpIk1lpM9KBT2xWoc4T+DXpbaGEwJ6uBOqBeZvvYAqduSXucb4cbfwtlvBODDCng1xST09vP6aJoPwTGV34PmmMRs5ASBWRZCgySl7rbhqW4J6weHVczyuCqMCA6udDVpDuwjfhb4sRty0j7+7NXXXX5qc0Qa9547kOLcT/w9fpVvFinH6WM07+32krcw82TMm7syxQOuemHZJmdv1pMtyQrSvk9EzNblK7nkLUbmCHE9rQEPNhycWyg6PbYW5Ezn7zttg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: dgCQsu4r/M34W39t0Fo4/yHGrf57YRQtRAtodlXB50uM9kOxingRALtdraFnRqFA9pk9x4FOSiEQozA05B6PcV4nOW1Dnl95WZgqOCXDKhtIx+YvNl0oGxw/5X5dKe4owGSoxKylNucv49wt+RI5VOZi13VjoIYcdopLYxN9ExDJwxsQWqu0t48vE+bQ58U2eBotEYPSaSR4i3/Nnv8ByOoSfM4SnqPNMERrM4Wj8cV1vmU5qWhmAxyqQrrGTTtATzTEjjd6DSbryk+IQU5EczneKi/mECWToBiCFyLsCNlb6e8NSnY4cAXu3XwCJu1z0xC2PBEfHmnxvt8kX0s/DyoMtPX/8uRMMb8LH7gwjgNxAWimcMOpErawjX1wWLdazvGYNMaWr6e4KoOSdAeqnoghAeJ2s3Zun2Fad/71pL5Q62v6RN1dGxMx/nDliMvcFiXAAEeCap5XuYjCA7mNr3dwDq/BJMoaLBXN/Lxd6zUF3ij73gNjzB3KpRK62+IvtXeQvLlQwCLstjvsfFOsvh5SiNoxY7NIZxPE13i6DOOFwJRopXfMH28vI+l5E87wCfm0agLRQN3UjwmFX9r/kS3hOfeE1ulX4oktm0+IET69poRg+3g6WygsVWxDp+4VUtCGUbxMLz2UwnMdEzkvXZNwtho+2LI5ssgf3AexDRTjV0oScNbkIyFgrKSyZteIxDyKQLCCkRv6J+eh3XtJFNjehRNeErKbrsq0ye4ktORGvFAy0y5rVcWu3KV8X3PKmAXKxN4S4NrXh3SlWX6rXTjmp4blxqopX0T0Melj8maDh4RXDf4KOS71+xtn5vhvkEUmk/1eUbrqq+dw3aN5Ris/0Szz0TjkTt+BN/5a6zzjRx2bQSxCL3qLLDHLZuOFevLFmZcpxT89vWL/8DiXFMokbm/qx/eifMt5DWesjR0/Xpuj5B0o1sp2h37BGm1UW3B7tLBVvoVpjv0LjJanSyyNv5I7ZraO9TxmgdTXcPQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 615acd7d-2005-477f-1276-08dad6de5cb5 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:55.4676 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +pHEMiVPmVVTJnYRqpfE5eFYysvi5qDwImlh3nO1L5UNpB7ufARIHR//T55l6rHtVPdQQOEwvkb/W8e5lHc4yA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5721 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050138 X-Proofpoint-ORIG-GUID: C4E9OcYX2-g9Y0-NzDQpP2A-z_uC3ePK X-Proofpoint-GUID: C4E9OcYX2-g9Y0-NzDQpP2A-z_uC3ePK Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org These symbols are terribly inefficiently stored at the moment. Add a simple optimizer which fuses obj2mod_elem entries and uses this to implement three cheap optimizations: - duplicate names are eliminated from .kallsyms_module_names. - entries in .kallsyms_modules which point at single-file modules which also appear in a multi-module list are redirected to point inside that list, and the single-file entry is dropped from .kallsyms_module_names. Thus, modules which contain some object files shared with other modules and some object files exclusive to them do not double up the module name. (There might still be some duplication between multiple multi-module lists, but this is an extremely marginal size effect, and resolving it would require an extra layer of lookup tables which would be even more complex, and incompressible to boot). - Entries in .kallsyms_modules that would contain the same value after the above optimizations are fused together, along with their corresponding .kallsyms_module_addresses/offsets entries. Due to this fusion process, and because object files can be split apart into multiple parts by the linker for hot/cold partitioning and the like, entries in .kallsyms_module_addresses/offsets no longer correspond 1:1 to object files, but more to some contiguous range of addresses which are guaranteed to belong to a single built-in module, but which may well stretch over multiple object files. The optimizer's time complexity is O(log n) in the number of objfiles at most (and probably much lower), so, given the relatively low number of objfiles, its runtime overhead is in the noise. Optimization reduces the overhead of the kallmodsyms tables by about 7500 items, dropping the .tmp_kallsyms2.o object file size by about 33KiB, leaving it 8672 bytes larger than before: a gain of .4%. The vmlinux size is not yet affected because the variables are not used and are eliminated by the linker: but if they were used (after the next commit but one), the size impact of all of this on the final kernel is minimal: in my testing, vmlinux grew by 0.17% (10824 bytes), and the compressed vmlinux only grew by 0.08% (7552 bytes): though this is very configuration-dependent, it seems likely to scale roughly with the kernel as a whole. (The next commit changes these numbers a bit, but not much.) Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- Notes: v9: Fix a bug in optimize_obj2mod that prevented proper reuse of module names for object files appearing in both multimodule modules and single-module modules. Adjustments to allow for objfile support. Tiny style fixes. v10: Slight conflict adjustments. scripts/kallsyms.c | 297 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 288 insertions(+), 9 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 48bf4661bd09..4d8289040ad5 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -104,6 +104,17 @@ static unsigned int strhash(const char *s) return hash; } +static unsigned int memhash(char *s, size_t len) +{ + /* fnv32 hash */ + unsigned int hash = 2166136261U; + size_t i; + + for (i = 0; i < len; i++) + hash = (hash ^ *(s + i)) * 0x01000193; + return hash; +} + #define OBJ2MOD_BITS 10 #define OBJ2MOD_N (1 << OBJ2MOD_BITS) #define OBJ2MOD_MASK (OBJ2MOD_N - 1) @@ -113,14 +124,35 @@ struct obj2mod_elem { size_t nmods; /* number of modules in "mods" */ size_t mods_size; /* size of all mods together */ int mod_offset; /* offset of module name in .kallsyms_mod_objnames */ + + /* + * Hash values of all module names in this elem, combined: used for + * rapid comparisons. Populated quite late, at optimize_obj2mod time. + */ + unsigned int modhash; + + /* + * If set at emission time, this points at another obj2mod entry that + * contains the module name we need (possibly at a slightly later + * offset, if the entry is for an objfile that appears in many modules). + */ + struct obj2mod_elem *xref; + + /* + * Chain links for object -> module and module->object mappings. + */ struct obj2mod_elem *obj2mod_next; + struct obj2mod_elem *mod2obj_next; }; /* - * Map from object files to obj2mod entries (a unique mapping). + * Map from object files to obj2mod entries (a unique mapping), and vice versa + * (not unique, but entries for objfiles in more than one module in this hash + * are ignored). */ static struct obj2mod_elem *obj2mod[OBJ2MOD_N]; +static struct obj2mod_elem *mod2obj[OBJ2MOD_N]; static size_t num_objfiles; /* @@ -164,6 +196,8 @@ static void obj2mod_add(char *obj, char *mod) elem = obj2mod_get(obj); if (!elem) { + int j = strhash(mod) & OBJ2MOD_MASK; + elem = malloc(sizeof(struct obj2mod_elem)); if (!elem) goto oom; @@ -177,8 +211,15 @@ static void obj2mod_add(char *obj, char *mod) elem->obj2mod_next = obj2mod[i]; obj2mod[i] = elem; + elem->mod2obj_next = mod2obj[j]; + mod2obj[j] = elem; num_objfiles++; } else { + /* + * objfile appears in multiple modules. mod2obj for this entry + * will be ignored from now on, except insofar as it is needed + * to maintain the hash chain. + */ elem->mods = realloc(elem->mods, elem->mods_size + strlen(mod) + 1); if (!elem->mods) @@ -198,6 +239,162 @@ static void obj2mod_add(char *obj, char *mod) fprintf(stderr, "kallsyms: out of memory\n"); exit(1); } + +static int qstrcmp(const void *a, const void *b) +{ + return strcmp((const char *) a, (const char *) b); +} + +static int qmodhash(const void *a, const void *b) +{ + struct obj2mod_elem * const *el_a = a; + struct obj2mod_elem * const *el_b = b; + if ((*el_a)->modhash < (*el_b)->modhash) + return -1; + else if ((*el_a)->modhash > (*el_b)->modhash) + return 1; + return 0; +} + +/* + * Associate all object files in obj2mod which refer to the same module with a + * single obj2mod entry for emission, preferring to point into the module list + * in a multi-module objfile. + */ +static void optimize_obj2mod(void) +{ + size_t i; + size_t n = 0; + struct obj2mod_elem *elem; + struct obj2mod_elem *dedup; + + /* An array of all obj2mod_elems, later sorted by hashval. */ + struct obj2mod_elem **uniq; + struct obj2mod_elem *last; + + /* + * Canonicalize all module lists by sorting them, then compute their + * hash values. + */ + uniq = malloc(sizeof(struct obj2mod_elem *) * num_objfiles); + if (uniq == NULL) + goto oom; + + for (i = 0; i < OBJ2MOD_N; i++) { + for (elem = obj2mod[i]; elem; elem = elem->obj2mod_next) { + if (elem->nmods >= 2) { + char **sorter; + char *walk; + char *tmp_mods; + size_t j; + + tmp_mods = malloc(elem->mods_size); + sorter = malloc(sizeof(char *) * elem->nmods); + if (sorter == NULL || tmp_mods == NULL) + goto oom; + memcpy(tmp_mods, elem->mods, elem->mods_size); + + for (j = 0, walk = tmp_mods; j < elem->nmods; + j++) { + sorter[j] = walk; + walk += strlen(walk) + 1; + } + qsort(sorter, elem->nmods, sizeof (char *), + qstrcmp); + for (j = 0, walk = elem->mods; j < elem->nmods; + j++) { + strcpy(walk, sorter[j]); + walk += strlen(walk) + 1; + } + free(tmp_mods); + free(sorter); + } + + uniq[n] = elem; + uniq[n]->modhash = memhash(elem->mods, elem->mods_size); + n++; + } + } + + qsort(uniq, num_objfiles, sizeof (struct obj2mod_elem *), qmodhash); + + /* + * Work over multimodule entries. These must be emitted into + * .kallsyms_mod_objnames as a unit, but we can still optimize by + * reusing some other identical entry. Single-file modules are amenable + * to the same optimization, but we avoid doing it for now so that we + * can prefer to point them directly inside a multimodule entry. + */ + for (i = 0, last = NULL; i < num_objfiles; i++) { + const char *onemod; + size_t j; + + if (uniq[i]->nmods < 2) + continue; + + /* Duplicate multimodule. Reuse the first we saw. */ + if (last != NULL && last->modhash == uniq[i]->modhash && + memcmp(uniq[i]->mods, last->mods, + uniq[i]->mods_size) == 0) { + uniq[i]->xref = last; + continue; + } + + /* + * Single-module entries relating to modules also emitted as + * part of this multimodule entry can refer to it: later, we + * will hunt down the right specific module name within this + * multimodule entry and point directly to it. + */ + onemod = uniq[i]->mods; + for (j = uniq[i]->nmods; j > 0; j--) { + int h = strhash(onemod) & OBJ2MOD_MASK; + + for (dedup = mod2obj[h]; dedup; + dedup = dedup->mod2obj_next) { + if (dedup->nmods > 1) + continue; + + if (strcmp(dedup->mods, onemod) != 0) + continue; + dedup->xref = uniq[i]; + assert(uniq[i]->xref == NULL); + } + onemod += strlen(onemod) + 1; + } + + last = uniq[i]; + } + + /* + * Now traverse all single-module entries, xreffing every one that + * relates to a given module to the first one we saw that refers to that + * module. + */ + for (i = 0, last = NULL; i < num_objfiles; i++) { + if (uniq[i]->nmods > 1) + continue; + + if (uniq[i]->xref != NULL) + continue; + + /* Duplicate module name. Reuse the first we saw. */ + if (last != NULL && last->modhash == uniq[i]->modhash && + memcmp(uniq[i]->mods, last->mods, uniq[i]->mods_size) == 0) { + uniq[i]->xref = last; + assert(last->xref == NULL); + continue; + } + last = uniq[i]; + } + + free(uniq); + + return; +oom: + fprintf(stderr, "kallsyms: out of memory optimizing module list\n"); + exit(EXIT_FAILURE); +} #endif /* CONFIG_KALLMODSYMS */ static void usage(void) @@ -509,8 +706,8 @@ static void output_kallmodsyms_mod_objnames(void) size_t i; /* - * Traverse and emit, updating mod_offset accordingly. Emit a single \0 - * at the start, to encode non-modular objfiles. + * Traverse and emit, chasing xref and updating mod_offset accordingly. + * Emit a single \0 at the start, to encode non-modular objfiles. */ output_label("kallsyms_mod_objnames"); printf("\t.byte\t0\n"); @@ -519,9 +716,25 @@ static void output_kallmodsyms_mod_objnames(void) elem = elem->obj2mod_next) { const char *onemod; size_t i; + struct obj2mod_elem *out_elem = elem; - elem->mod_offset = offset; - onemod = elem->mods; + /* + * Single-module ref to a multimodule: will be emitted + * as a whole, so avoid emitting pieces of it (which + * would go unreferenced in any case). + */ + if (elem->xref && + elem->nmods == 1 && elem->xref->nmods > 1) + continue; + + if (elem->xref) + out_elem = elem->xref; + + if (out_elem->mod_offset != 0) + continue; /* Already emitted. */ + + out_elem->mod_offset = offset; + onemod = out_elem->mods; /* * Technically this is a waste of space: we could just @@ -530,13 +743,14 @@ static void output_kallmodsyms_mod_objnames(void) * entry, but doing it this way makes it more obvious * when an entry is a multimodule entry. */ - if (elem->nmods != 1) { + if (out_elem->nmods != 1) { printf("\t.byte\t0\n"); - printf("\t.byte\t%zi\n", elem->nmods); + printf("\t.byte\t%zi\n", out_elem->nmods); offset += 2; } - for (i = elem->nmods; i > 0; i--) { + for (i = out_elem->nmods; i > 0; i--) { + printf("/* 0x%lx */\n", offset); printf("\t.asciz\t\"%s\"\n", onemod); offset += strlen(onemod) + 1; onemod += strlen(onemod) + 1; @@ -563,6 +777,13 @@ static void output_kallmodsyms_objfiles(void) long long offset; int overflow; + /* + * Fuse consecutive address ranges citing the same object file + * into one. + */ + if (i > 0 && addrmap[i-1].objfile == addrmap[i].objfile) + continue; + if (base_relative) { if (!absolute_percpu) { offset = addrmap[i].addr - relative_base; @@ -588,6 +809,13 @@ static void output_kallmodsyms_objfiles(void) for (i = 0; i < addrmap_num; i++) { struct obj2mod_elem *elem = addrmap[i].objfile; + int orig_nmods; + const char *orig_modname; + int mod_offset; + + if (i > 0 && addrmap[i-1].objfile == addrmap[i].objfile) + continue; + /* * Address range cites no modular object file: point at 0, the * built-in module. @@ -598,13 +826,63 @@ static void output_kallmodsyms_objfiles(void) continue; } + orig_nmods = elem->nmods; + orig_modname = elem->mods; + + /* + * Chase down xrefs, if need be. There can only be one layer of + * these: from single-module entry to other single-module + * entry, or from single- or multi-module entry to another + * multi-module entry. Single -> single and multi -> multi + * always points at the start of the xref target, so its offset + * can be used as is. + */ + if (elem->xref) + elem = elem->xref; + + if (elem->nmods == 1 || orig_nmods > 1) { + + if (elem->nmods == 1) + printf("/* 0x%llx--0x%llx: module %s */\n", + addrmap[i].addr, addrmap[i].end_addr, + elem->mods); + else + printf("/* 0x%llx--0x%llx: multimodule */\n", + addrmap[i].addr, addrmap[i].end_addr); + + mod_offset = elem->mod_offset; + } else { + /* + * If this is a reference from a single-module entry to + * a multi-module entry, hunt down the offset to this + * specific module's name (which is guaranteed to be + * present: see optimize_obj2mod). + */ + + size_t j = elem->nmods; + const char *onemod = elem->mods; + mod_offset = elem->mod_offset; + + for (; j > 0; j--) { + if (strcmp(orig_modname, onemod) == 0) + break; + onemod += strlen(onemod) + 1; + } + assert(j > 0); + /* + * +2 to skip the null byte and count at the start of + * the multimodule entry. + */ + mod_offset += onemod - elem->mods + 2; + } + /* * Zero offset is the initial \0, there to catch uninitialized * obj2mod entries, and is forbidden. */ assert(elem->mod_offset != 0); - printf("\t.long\t0x%x\n", elem->mod_offset); + printf("\t.long\t0x%x\n", mod_offset); emitted_objfiles++; } @@ -1217,6 +1495,7 @@ static void read_modules(const char *modules_builtin) free(module_name); modules_builtin_iter_free(i); + optimize_obj2mod(); /* * Read linker map. From patchwork Mon Dec 5 16:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064761 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 7AC15C4332F for ; Mon, 5 Dec 2022 16:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232959AbiLEQeq (ORCPT ); Mon, 5 Dec 2022 11:34:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232589AbiLEQds (ORCPT ); Mon, 5 Dec 2022 11:33:48 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 038A11FCF7; Mon, 5 Dec 2022 08:33:34 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fhwbv007846; Mon, 5 Dec 2022 16:33:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=14R3otcJhcIArEc1TbFipBQ3dJK1VYzJrrjSZH9V3/8=; b=QVvGDf19IJff/sxX5OM2FgLnUcAWvEz0gOYYi2oFQWdVKtkUhNQMJ/w81M6EKAAyYzEN lICVSgCSZHrOjBXKIzqARN96E1oiN4Ow6Ds/v0AzKzK+4HxlFedMM9jZyBBGHhj9qLv0 k/b7l7e6x92Pwpr/b9nIeRSevQO3vsinI3JzrJ3VpWaoC2/cAccSSs8WpFWNGtdPI/4g cgo3XrqGJk9T83t9PFWG8+EQEObOmvS7AA8vOijFt0z0BoTddj1ugKM84KYwCSYzY/LE GiXqHlNfJCqcnkqHqOuV4PfiNosgjFF/vdqz1o9bEDYCGoRdrbhj9h8SzJ7XzbE16DrI 8w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7ybgmbgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:24 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQu6n027839; Mon, 5 Dec 2022 16:33:24 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ua9dpwh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RWrWc2MqaaIfkTNhXQ2IHvfHktUlKtMXpEJ45K+bm/DDRLTGtKxvhQscoqFrsDq7RmLV1Sy0fJZ07p2bZjvzTqr2AmD8/VCioRK9iEF/juixwkG0v6b6enaFy5dX+3RzeD7sMzdCqY3+y9vmdiXJefHZ06rno3MOhK9WMIZnaDmg+ibicDsE6bE6ECUj4OizS4XB/Ob6ZXu1GDLUk4ErCKJKYAGpqPnR9wYglT8tRO5h3RUGdSfH3Gu3gzhTd3gcZMCLOfN8PoGwOS1EfLub8Il1AGAh1s6l8EOOvyOTFQp0Y3UqTBJUoEAtEWSx5AysWIWSXkjiSEC9wYZ8b1KbaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=14R3otcJhcIArEc1TbFipBQ3dJK1VYzJrrjSZH9V3/8=; b=J37dEPiTGFFctKGtSp/J8fF1W4z2NO1Av7BTiUDBBBKrlDWl9V30XcLAvLKOyfEjdofvrU37/k2XhFyCyGmPvPiJC2VXV5oAiWEm7lidWJGOW9rIk1gdOVwx8m75iCGp25Wh2Kvw2V8gw0upstbBQMKNLnVZ3FJ6kAmrf2CuefussF6wqD4T8FAXu18vhRWBPUTrYnKLUziEsRhM4uWESN0C8mXFVU8RnjBAJRJqwLM3rVPc4avrDQSgJh2YPVRJMXsdcBMMs9JnipxLs1CHAPT2NUZjHiBckpnQDFRWG0pXlXqeedl6NOWycEE/XH5M83xjk8BFBPxuGfq3Q8Jl6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=14R3otcJhcIArEc1TbFipBQ3dJK1VYzJrrjSZH9V3/8=; b=gk1HX4B2jT8wei7W+lC+l/3HOx2+/hAbjFfdpbw4HrHKJluYsw/XgNLXLC75ly42EYjVF0yfrg2bCIhqtJWScTHRtRA6o8IbJAj6gBtlRpWYoTK26HITcXGB392jDMV4+/4tkBrzVONY+s1Q1EXE8CCDWXqmcUzLh8TziNtWHLg= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by PH7PR10MB5721.namprd10.prod.outlook.com (2603:10b6:510:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Mon, 5 Dec 2022 16:33:21 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:33:21 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 11/13] kallsyms: distinguish text symbols fully using object file names Date: Mon, 5 Dec 2022 16:31:55 +0000 Message-Id: <20221205163157.269335-12-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P302CA0004.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:2c2::9) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|PH7PR10MB5721:EE_ X-MS-Office365-Filtering-Correlation-Id: 3af3e139-6c6d-4e08-e70f-08dad6de5f41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2dhCUgy3yc7rW4r5ywUFpDG8gm1tRs9BJWPFUe9zF46ROxTtIi6U++edWT9tKfSTeR6AOeXRGPR81+9xOU1rgLQmHDO+I1XzmTydDfZ6N5VYTMIvDkNevy5hwGuRstOywRNFv3IHMUc7qGwxgMcW24lEDrDQnB1yR10nqpzUI1bdEjiSuBXE+llUzpdANuQKUBoq/2P2u1WYFhkz/QdW70/I0fKezM8f6HiFebHzzu32wPWVs1QaVDsPlZsZD+7ctg0SCANuydcKjMvftorcy/AOWVwK16Q6nnDb8k3VhFJhR3APFMIlqT+/BHc3caLZJ+p6bsaKnOhGxKKuLS8BDhiQh6zv0ZYp0gNBvuAIprle+tsz7/K5uPS/kJjfA9r4YBukwe0aspkcwXI4m8MH412X46b9mm4BnrbTPwodkQSdBAo96EfugLV+3oS9kc9RtSWU3V5HLW3N3DwPKp0NAhvih2MKqwUrwq9MqJuQpbjL2CDhLvEWtQ7zRQOQ9WVbQCpsJFxssgaDIh/PaY+oCnTtKSTns8WcHnhA9crVcXkTUY5zCAb/KsjuFxsDBLiPu5smSNy9K7W2dyy+aKNrMEbbzIiMzHpRqjPltvv9e7Xl4p03eFyAJwjiXoWchy1xTugdp/n/+jWOhb4E8O/QDQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(136003)(346002)(396003)(39860400002)(451199015)(316002)(6486002)(107886003)(478600001)(6666004)(6506007)(6512007)(66946007)(8676002)(4326008)(66476007)(66556008)(83380400001)(30864003)(8936002)(5660300002)(44832011)(186003)(41300700001)(2906002)(1076003)(36756003)(2616005)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2MBeMIMlNyLbfKTrnHMbsalk+c4J69EfGL6KTVgeyWfdpO2aVFMLVN/V0NCC7NtZ803oTpdyRG1JsPIUTvqGQuyE18scheSGo1nmDjLPCLzQ2cO6upGEwvJE+Lem1f/2QXYP24vb/O7e4L32fYmmP0jN845EqOzvBpGcVZBTVqR6o+Xgq3bopzcYCgjEnIAz9la/mGUn9YSbkEvLdmIuGH/hzNXMnIXN3P8k/eA1JbAAlzELViakPmNK7qJGVy9xYO5tbBlYDo0LnU3R9Jc9IkcDv1iQxu5oW1TVaps55P7jsXElQP+/7AclAtVTTJ4T4uevQTr7H65oqTkeWxu4h0IKfFzZmpVdxv79AjtuPQ8DM2gHlECwVVkeHc9kC787r7hgAscIrPrW/DgLIeiv4vaa5VSqZEVSlIdf5qyZbwBvecFwLounYmagBZ4QITi3WPTqmfoQPKOV0arEaAM2M5MqIjK2ZJ0j8tnOUXXvYwgeNJ3OAnT2iD6FRC8eNFlkeLVqe1NrmiUawiqh/sOl903gfGDru3DJiS2BTRCUSZ3XVsD/T3DF5zszyBk3NPZSg0ZiRTQxhN0jP6S3EuijVzs3j8XWq4zy7VkQF+m8hqt7jkbaiLTrtRfkOwDcajIT7wBexzLUzf8hWnblUE/drGcZXZr3OsS/dnNYOW3qPgRwMT4NTvVoVm4t4bT25KY+2viitQ3Olx5r4jifKRqouI/CwzevImz0vbh6sqF4U6Sb/opqfW4bMFaa7a86Zc6x1cTZCCcyBR+Byx+W7UARozN9NXpV+PXVSFBuT7yIbrHcoCcceSJS9f89/Le2Gm0i+/ESPNKzuJ4mtMBTQ2ou8J0HvodKlNkt+YVS1IRYU1WsoOtIhbxXiovmP10myYMD7cx1bGQZt2rw4NZPaSuayjrHuIu1Vn4wQX9OQCAK+kZLSQP59117XIMJVi/b/9l8Gl5zlUJtO+SPRnEoiMM68KGMPD1CQzLiSoosZLfaTFAldHDRmW/Fj0oMxGB3A2jWnDRAXRWGp2g5fTyLj33xv3b1mLBnpJ8QtkAtKXHXqkeRRy8MvpeYgVWfY8Be/1gSpOnJaU2S4Wr9/JJdLgeN9DIb7JuQJ9ynfHfT8JO95Oa0IQd0LzHhU/FGVfH+3xY90vNFGnG64fxMEunzvqS8OdeyUzpfZZtPdP7GW4R9DZy/qZ1iG70oRQVIxI+U5ClRdLREftNcPDtv/XZ9RIQy4q9H9i9Fo9KlcKbJUmnLf/xW1gVZB6W61MUCFtkbPJcljDLr2wJfgpZq1eK5pqaVOJEPlbN+LdXdGO/BTsnTONicDbVOZmUWGikzd4PPBufhG/rWbzAjjV6zNq3q3ujyZ94ElwgXevP258qcnQIZR425Qz/Z04B9XDXr8iu8MAsCtXpzVkURhlw7Z4iyS3GOn/gScmfyrxhoGmLqLksRqmCeYVKeJ4zr7fhYafIVR9h7ZnlXnWZonII2IxAJTJAucuGhTilIj5SbTabxA3VD0K9AYpt2/6I35SXpOyjTcjjrMO69h6P6XO9dmoIIAN4OzMR5USQBmUfUnz00UdsTQtD6ODZpW+xO9nFsNCeuzHNec3SvGDCUjaSfeg/LvdYRZw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 01cz2mwmxMEBp+tzdTcgkvVokXgIwk/GNNQVUZVobaFZONMeNCf6ClovlBoiGShavM2EYgCcZtkAaccASVYZggUV5kkUehLTnrRUc/grSMbTpE1q1t7DNezhZ1FeaNkRUOzvT8gW4HBHwZ9baTNE0hy320M/vLqr4/VogyCwHmlInJr+Mm+VRxYrIxdpHgGtAAbxadvFiZpSsGrcoTzMmNSPe7l0RolA93zIJE5LNq7/0ivBQmcg30zr99fR3L2sCc56LyeIW74C3anDy3cbqBY027Tyte7Jx2NBAf3YkSPh1VWAZbKin9wIQ5rMDRvZ9Ic6hEpEttsV7IeYKPZtOWLKF4jyZzhVJlp26xbhOVvcJ3zS2DHECoV/DcB8w+KLF8nSRrl2IfOiijKBtPUqG8qR5n6sFecga396lAlEZsYuzwbgtqGnXK4TLyDbW+RlunaQ9QZCE7/nqGjbKGv4s4c65arPVAuLfW48J5frggf6xUNOURTbqJKbj6RcnHovZtl6xoEuKKKMcCbgVnqzhUGJ/WRPUHt2BrnYEXoyHKw7FXOQlIhFO/ewvgq86nniJT8YJWMuV5m4GSzv1ONxJJ377INLyosrKD84TM0wSpEuSDtWDpqsdzkcnBDpD/e4ad2V1GjRYMgSw6MuJZD0WOYqIRN1ZzcnFO+OEvzzqvHYepa9xtgu+dyIDJ0oJ3mbQH6RQrlX6ZugNSfkEVlXR2fc5eiBv+qf+x0AuoMKnygkjrIWPTWycDkhFirkTnjFtp+VNCUjXVU8x+xblBz5DK+Pz9B6xmj5dJ4HLOBXkaTvCG6TsaV/c53WULU3bZo2cwwIJxPTH+jOl+xzDmbBLwXimc32t8ePqSZ5HmQTUgq8kWAQCcTCs6sqI/WZNGMhfjYetEPBRV4ZutLEoeKW0RD6g7j7BCpgs9HdJOy0tkmmSKtuvpPmbgff0bWD4EC6v1uk3+B8FakexN5C/CMNFcntE9QyqSMBHTodgKUtMu4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3af3e139-6c6d-4e08-e70f-08dad6de5f41 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:32:59.7303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w9RJDL7hz2qwE2hdh8kr1zYq3VqHhKoMSKhAs8rS9SYsustVvRWp+cLJ62Y9yT9SXf1JbGxCkeXqlREHq3q3hQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5721 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050138 X-Proofpoint-ORIG-GUID: fRggojZ87wb_FNM_XnLwsqQNHMboa5Nx X-Proofpoint-GUID: fRggojZ87wb_FNM_XnLwsqQNHMboa5Nx Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The commits before this one will let /proc/kallmodsyms distinguish identically-named text symbols located in different built-in object files from each other; but identically-named symbols can appear in any object files at all, including object files that cannot be built as modules. Even modules can have identically-named symbols in them, in distinct translation units. (This might seem like overdesign, after all, how many such symbols can there be? But Some config options introduce huge numbers of such symbols, notably _sub_I_65535_1: these all contain code and might show up in trace output, but appear in almost every compiled object file. Distinguishing them really needs machine assistance: nobody wants to figure out which of three thousand _sub_I_65535_1's is which by hand!) We already have nearly all the machinery to disambiguate such symbols reliably. Since any given object file emitted by the compiler can contain at most one definition of a given symbol, it suffices to name the object files containing any symbol which is otherwise ambiguous. (No others need be named, saving a bunch of space). We associate address ranges with object file names using a new .kallsyms_objfiles section just like the previously-added .kallsyms_modules section. But that's not quite enough. Even the object file name is ambiguous in some cases: e.g. there are a lot of files named "core.o" in the kernel. We could just store the full pathname for every object file, but this is needlessly wasteful: doing this eats more than 50KiB in object file names alone, and nearly all the content of every name is repeated for many names. But if we store the object file names in the same section as the built-in module names, drop the .o, and store minimal path suffixes, we can save almost all that space. (For example, "core.o" would be stored as "core" unless there are ambiguous symbols in two different object files both named "core", in which case they'd be named "sched/core" and "futex/core", etc, possibly re-extending to "kernel/sched/core" if still ambiguous). We do this by a repeated-rehashing process. First, we compute a hash value for symbol\0modhash for every symbol (the modhash is ignored if this is a built-in symbol). Any two symbols with the same such hash are identically-named: add the maximally-shortened (one-component, .o-stripped) object file name for all such symbols, and rehash, this time hashing symbol\0objname\0modhash. Any two symbols which still have the same hash are still ambiguous: lengthen the name given to one of the symbols' object files and repeat -- we pick the object file with the longest full pathname so that we can disambiguate e.g. arch/x86/kernel/smp.o and kernel/smp.o from each other. Eventually, all the ambiguity will go away. (We do have to take care not to re-lengthen anything we already lengthened in any given hashing round.) This involves multiple sorting passes but the impact on compilation time appears to be nearly zero, and the impact on space in the running kernel is noticeable: only a few dozen names usually need lengthening, so we can completely ignore the overhead from storing repeated path components because there are hardly any of them. But that's not all. We can also do similar optimization tricks to what was done with .kallsyms_modules, reusing module names and names of already-emitted object files: so any given object file name only appears once in the strtab, and can be cited by many address ranges and even by module entries. Put all this together and the net overhead of this in my testing is about 3KiB of new object file names in the .kallsyms_mod_objnames table and 6KiB for the .kallsyms_objfiles table (mostly zeroes: in future maybe we can find a way to elide some of those, but 6KiB is small enough that it's not worth taking too much effort). No ambiguous textual symbols remain outside actual modules (which can still contain identically-named symbols in different object files because kallsyms doesn't run over them so none of these tables can be built for them. At least, it doesn't yet). We warn about any ambiguous symbols we find at build time. (Caveat: the nvhe module on aarch64 is still linked with ld -r, which causes its contents to appear to come from a single object file when the linker emits its final mapfile. We spot such unfixable ambiguous symbols and don't warn about them because there's nothing we can do. The solution is probably to fix nvhe so it uses thin archives like everything else does.) Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- Notes: v9: new. v10: Handle objnames that are substrings of other objnames. Warn about conflicts which seem to be the result of ld -r. Fix potential infloop emitting .kallsyms_mod_objnames. Mention ultimate user (kallmodsyms), problems with ld -r and aarch64 nvhe in commit log. scripts/kallsyms.c | 595 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 582 insertions(+), 13 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 4d8289040ad5..ecb993efe499 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -115,6 +115,9 @@ static unsigned int memhash(char *s, size_t len) return hash; } +/* + * Object file -> module and shortened object file name tracking machinery. + */ #define OBJ2MOD_BITS 10 #define OBJ2MOD_N (1 << OBJ2MOD_BITS) #define OBJ2MOD_MASK (OBJ2MOD_N - 1) @@ -145,15 +148,40 @@ struct obj2mod_elem { struct obj2mod_elem *mod2obj_next; }; +/* + * Shortened object file names. These are only ever consulted after checking + * the obj2mod hashes: names that already exist in there are used directly from + * there (pointed to via the mod_xref field) rather than being re-emitted. + * Entries that do not exist there are added to the end of the mod_objnames + * list. + */ +struct obj2short_elem { + const char *obj; + char *desuffixed; /* objname sans suffix */ + const char *short_obj; /* shortened at / and suffix */ + int short_offset; /* offset of short name in .kallsyms_mod_objnames */ + int last_rehash; /* used during disambiguate_hash_syms */ + + struct obj2mod_elem *mod_xref; + struct obj2short_elem *short_xref; + struct obj2short_elem *short_next; +}; + /* * Map from object files to obj2mod entries (a unique mapping), and vice versa * (not unique, but entries for objfiles in more than one module in this hash - * are ignored). + * are ignored); also map from object file names to shortened names for them + * (also unique: there is no point storing both longer and shorter forms of one + * name, so if a longer name is needed we consistently use it instead of the + * shorter form.) + * + * obj2short is populated very late, at disambiguate_syms time. */ static struct obj2mod_elem *obj2mod[OBJ2MOD_N]; static struct obj2mod_elem *mod2obj[OBJ2MOD_N]; -static size_t num_objfiles; +static struct obj2short_elem *obj2short[OBJ2MOD_N]; +static size_t num_objfiles, num_shortnames; /* * An ordered list of address ranges and the objfile that occupies that range. @@ -167,6 +195,9 @@ struct addrmap_entry { static struct addrmap_entry *addrmap; static int addrmap_num, addrmap_alloced; +static void disambiguate_syms(void); +static void optimize_objnames(void); + static void obj2mod_init(void) { memset(obj2mod, 0, sizeof(obj2mod)); @@ -184,6 +215,18 @@ static struct obj2mod_elem *obj2mod_get(const char *obj) return NULL; } +static struct obj2short_elem *obj2short_get(const char *obj) +{ + int i = strhash(obj) & OBJ2MOD_MASK; + struct obj2short_elem *elem; + + for (elem = obj2short[i]; elem; elem = elem->short_next) { + if (strcmp(elem->obj, obj) == 0) + return elem; + } + return NULL; +} + /* * Note that a given object file is found in some module, interning it in the * obj2mod hash. Should not be called more than once for any given (module, @@ -256,6 +299,12 @@ static int qmodhash(const void *a, const void *b) return 0; } +static int qobj2short(const void *a, const void *b) +{ + return strcmp((*(struct obj2short_elem **)a)->short_obj, + (*(struct obj2short_elem **)b)->short_obj); +} + /* * Associate all object files in obj2mod which refer to the same module with a * single obj2mod entry for emission, preferring to point into the module list @@ -395,6 +444,370 @@ static void optimize_obj2mod(void) fprintf(stderr, "kallsyms: out of memory optimizing module list\n"); exit(EXIT_FAILURE); } + +/* + * Associate all short-name entries in obj2short that refer to the same short + * name with a single entry for emission, either (preferably) a module that + * shares that name or (alternatively) the first obj2short entry referencing + * that name. + */ +static void optimize_objnames(void) +{ + size_t i; + size_t num_objnames = 0; + struct obj2short_elem *elem; + struct obj2short_elem **uniq; + struct obj2short_elem *last; + + uniq = malloc(sizeof(struct obj2short_elem *) * num_shortnames); + if (uniq == NULL) { + fprintf(stderr, "kallsyms: out of memory optimizing object file name list\n"); + exit(EXIT_FAILURE); + } + + /* + * Much like optimize_obj2mod, except there is no need to canonicalize + * anything or handle multimodule entries, and we need to chase down + * possible entries in mod2obj first (so as not to duplicate them in the + * final kallsyms_mod_objnames strtab). + */ + for (i = 0; i < OBJ2MOD_N; i++) + for (elem = obj2short[i]; elem; elem = elem->short_next) + uniq[num_objnames++] = elem; + + qsort(uniq, num_objnames, sizeof(struct obj2short_elem *), qobj2short); + + for (i = 0, last = NULL; i < num_objnames; i++) { + int h = strhash(uniq[i]->short_obj) & OBJ2MOD_MASK; + struct obj2mod_elem *mod_elem; + + for (mod_elem = mod2obj[h]; mod_elem; + mod_elem = mod_elem->mod2obj_next) { + /* + * mod_elem entries are only valid if they are for + * single-module objfiles: see obj2mod_add + */ + if (mod_elem->nmods > 1) + continue; + + if (strcmp(mod_elem->mods, uniq[i]->short_obj) != 0) + continue; + uniq[i]->mod_xref = mod_elem; + break; + } + + /* + * Only look for a short_xref match if we don't already have one + * in mod_xref. (This means that multiple objfiles with the + * same short name that is also a module name all chain directly + * to the module name via mod_xref, rather than going through a + * chain of short_xrefs.) + */ + if (uniq[i]->mod_xref) + continue; + + if (last != NULL && strcmp(last->short_obj, + uniq[i]->short_obj) == 0) { + uniq[i]->short_xref = last; + continue; + } + + last = uniq[i]; + } + + free(uniq); +} + +/* + * Used inside disambiguate_syms to identify colliding symbols. We spot this by + * hashing symbol\0modhash (or just the symbol name if this is in the core + * kernel) and seeing if that collides. (This means we don't need to bother + * canonicalizing the module list, since optimize_obj2mod already did it for + * us.) + * + * If that collides, we try disambiguating by adding ever-longer pieces of the + * object file name before the modhash until we no longer collide. The result + * of this repeated addition becomes the obj2short hashtab. + */ +struct sym_maybe_collides { + struct sym_entry *sym; + struct addrmap_entry *addr; + unsigned int symhash; + int warned; +}; + +static int qsymhash(const void *a, const void *b) +{ + const struct sym_maybe_collides *el_a = a; + const struct sym_maybe_collides *el_b = b; + if (el_a->symhash < el_b->symhash) + return -1; + else if (el_a->symhash > el_b->symhash) + return 1; + return 0; +} + +static int find_addrmap(const void *a, const void *b) +{ + const struct sym_entry *sym = a; + const struct addrmap_entry *map = b; + + if (sym->addr < map->addr) + return -1; + else if (sym->addr >= map->end_addr) + return 1; + return 0; +} + +/* + * Allocate or lengthen an object file name for a symbol that needs it. + */ +static int lengthen_short_name(struct sym_maybe_collides *sym, + struct sym_maybe_collides *last_sym, + int hash_cycle) +{ + struct obj2short_elem *short_objname; + + /* + * If both symbols come from the same object file, skip as unresolvable + * and avoid retrying. This can happen if the intermediate object file + * was partially linked via ld -r, concealing the original object file + * names from the linker and thus from us. + */ + if (strcmp(last_sym->addr->obj, sym->addr->obj) == 0) { + if (!sym->warned && !last_sym->warned) { + fprintf(stderr, "Symbol %s appears multiple times in %s; likely linked with ld -r; entry in /proc/kallmodsyms will be ambiguous\n", + &sym->sym->sym[1], sym->addr->obj); + } + sym->warned = 1; + last_sym->warned = 1; + return 0; + } + + /* + * Always lengthen the symbol that has the longest objname to lengthen, + * ensuring that where one objname is a strict subset of another, we + * always lengthen the one that will eventually resolve the ambiguity. + */ + if (strlen(last_sym->addr->obj) > strlen(sym->addr->obj)) { + struct sym_maybe_collides *tmp; + + tmp = sym; + sym = last_sym; + last_sym = tmp; + } + + short_objname = obj2short_get(sym->addr->obj); + + if (!short_objname) { + int i = strhash(sym->addr->obj) & OBJ2MOD_MASK; + char *p; + + short_objname = malloc(sizeof(struct obj2short_elem)); + if (short_objname == NULL) + goto oom; + + /* + * New symbol: try maximal shortening, which is just the object + * file name (no directory) with the suffix removed (the suffix + * is useless for disambiguation since it is almost always .o). + * + * Add a bit of paranoia to allow for names starting with /, + * ending with ., and names with no suffix. (At least two of + * these are most unlikely, but possible.) + */ + + memset(short_objname, 0, sizeof(struct obj2short_elem)); + short_objname->obj = sym->addr->obj; + + p = strrchr(sym->addr->obj, '.'); + if (p) + short_objname->desuffixed = strndup(sym->addr->obj, + p - sym->addr->obj); + else + short_objname->desuffixed = strdup(sym->addr->obj); + + if (short_objname->desuffixed == NULL) + goto oom; + + p = strrchr(short_objname->desuffixed, '/'); + if (p && p[1] != 0) + short_objname->short_obj = p + 1; + else + short_objname->short_obj = short_objname->desuffixed; + + short_objname->short_next = obj2short[i]; + short_objname->last_rehash = hash_cycle; + obj2short[i] = short_objname; + + num_shortnames++; + return 1; + } + + /* + * Objname already lengthened by a previous symbol clash: do nothing + * until we rehash again. + */ + if (short_objname->last_rehash == hash_cycle) + return 0; + short_objname->last_rehash = hash_cycle; + + /* + * Existing symbol: lengthen the objname we already have. + */ + + if (short_objname->desuffixed == short_objname->short_obj) { + fprintf(stderr, "Cannot disambiguate %s: objname %s is " + "max-length but still colliding\n", + &sym->sym->sym[1], short_objname->short_obj); + return 0; + } + + /* + * Allow for absolute paths, where the first byte is '/'. + */ + + if (short_objname->desuffixed >= short_objname->short_obj - 2) + short_objname->short_obj = short_objname->desuffixed; + else { + for (short_objname->short_obj -= 2; + short_objname->short_obj > short_objname->desuffixed && + *short_objname->short_obj != '/'; + short_objname->short_obj--); + + if (*short_objname->short_obj == '/') + short_objname->short_obj++; + } + return 1; + oom: + fprintf(stderr, "Out of memory disambiguating syms\n"); + exit(EXIT_FAILURE); +} + +/* + * Do one round of disambiguation-check symbol hashing, factoring in the current + * set of applicable shortened object file names for those symbols that need + * them. + */ +static void disambiguate_hash_syms(struct sym_maybe_collides *syms) +{ + size_t i; + for (i = 0; i < table_cnt; i++) { + struct obj2short_elem *short_objname = NULL; + char *tmp, *p; + size_t tmp_size; + + if (syms[i].sym == NULL) { + syms[i].symhash = 0; + continue; + } + + short_objname = obj2short_get(syms[i].addr->obj); + + tmp_size = strlen((char *) &(syms[i].sym->sym[1])) + 1; + + if (short_objname) + tmp_size += strlen(short_objname->short_obj) + 1; + + if (syms[i].addr->objfile) + tmp_size += sizeof(syms[i].addr->objfile->modhash); + + tmp = malloc(tmp_size); + if (tmp == NULL) { + fprintf(stderr, "Out of memory disambiguating syms\n"); + exit(EXIT_FAILURE); + } + + p = stpcpy(tmp, (char *) &(syms[i].sym->sym[1])); + p++; + if (short_objname) { + p = stpcpy(p, short_objname->short_obj); + p++; + } + if (syms[i].addr->objfile) + memcpy(p, &(syms[i].addr->objfile->modhash), + sizeof(syms[i].addr->objfile->modhash)); + + syms[i].symhash = memhash(tmp, tmp_size); + free(tmp); + } + + qsort(syms, table_cnt, sizeof (struct sym_maybe_collides), qsymhash); +} + +/* + * Figure out which object file names are necessary to disambiguate all symbols + * in the linked kernel: transform them for minimum length while retaining + * disambiguity: point to them in obj2short. + */ +static void disambiguate_syms(void) +{ + size_t i; + int retry; + int hash_cycle = 0; + unsigned int lasthash; + struct sym_maybe_collides *syms; + + syms = calloc(table_cnt, sizeof(struct sym_maybe_collides)); + + if (syms == NULL) + goto oom; + + /* + * Initial table population: symbol-dependent things not affected by + * disambiguation rounds. + */ + for (i = 0; i < table_cnt; i++) { + struct addrmap_entry *addr; + + /* + * Only bother doing anything for function symbols. + */ + if (table[i]->sym[0] != 't' && table[i]->sym[0] != 'T' && + table[i]->sym[0] != 'w' && table[i]->sym[0] != 'W') + continue; + + addr = bsearch(table[i], addrmap, addrmap_num, + sizeof(struct addrmap_entry), find_addrmap); + + /* + * Some function symbols (section start symbols, discarded + * non-text-range symbols, etc) don't appear in the linker map + * at all. + */ + if (addr == NULL) + continue; + + syms[i].sym = table[i]; + syms[i].addr = addr; + } + + do { + hash_cycle++; + retry = 0; + lasthash = 0; + disambiguate_hash_syms(syms); + + for (i = 0; i < table_cnt; i++) { + if (syms[i].sym == NULL) + continue; + if (syms[i].symhash == lasthash) { + if (lengthen_short_name(&syms[i], &syms[i-1], + hash_cycle)) + retry = 1; + } + lasthash = syms[i].symhash; + } + } while (retry); + + free(syms); + return; + oom: + fprintf(stderr, "kallsyms: out of memory disambiguating syms\n"); + exit(EXIT_FAILURE); + +} + #endif /* CONFIG_KALLMODSYMS */ static void usage(void) @@ -426,6 +839,7 @@ static bool is_ignored_symbol(const char *name, char type) "kallsyms_relative_base", "kallsyms_num_syms", "kallsyms_num_modules", + "kallsyms_num_objfiles", "kallsyms_names", "kallsyms_markers", "kallsyms_token_table", @@ -433,6 +847,7 @@ static bool is_ignored_symbol(const char *name, char type) "kallsyms_module_offsets", "kallsyms_module_addresses", "kallsyms_modules", + "kallsyms_objfiles", "kallsyms_mod_objnames", "kallsyms_mod_objnames_len", /* Exclude linker generated symbols which vary between passes */ @@ -702,6 +1117,7 @@ static void output_address(unsigned long long addr) static void output_kallmodsyms_mod_objnames(void) { struct obj2mod_elem *elem; + struct obj2short_elem *short_elem; size_t offset = 1; size_t i; @@ -757,15 +1173,77 @@ static void output_kallmodsyms_mod_objnames(void) } } } + + /* + * Module names are done; now emit objfile names that don't match + * objfile names. They go in the same section to enable deduplication + * between (maximally-shortened) objfile names and module names. + * (This is another reason why objfile names drop the suffix.) + */ + for (i = 0; i < OBJ2MOD_N; i++) { + for (short_elem = obj2short[i]; short_elem; + short_elem = short_elem->short_next) { + + struct obj2short_elem *out_elem = short_elem; + + /* Already emitted? */ + if (out_elem->mod_xref) + continue; + + if (out_elem->short_xref) + out_elem = out_elem->short_xref; + + if (out_elem->short_offset != 0) + continue; + + printf("/* 0x%lx: shortened from %s */\n", offset, + out_elem->obj); + + out_elem->short_offset = offset; + printf("\t.asciz\t\"%s\"\n", out_elem->short_obj); + offset += strlen(out_elem->short_obj) + 1; + } + } + printf("\n"); output_label("kallsyms_mod_objnames_len"); printf("\t.long\t%zi\n", offset); } +/* + * Return 1 if this address range cites the same built-in module and objfile + * name as the previous one. + */ +static int same_kallmodsyms_range(int i) +{ + struct obj2short_elem *last_short; + struct obj2short_elem *this_short; + if (i == 0) + return 0; + + last_short = obj2short_get(addrmap[i-1].obj); + this_short = obj2short_get(addrmap[i].obj); + + if (addrmap[i-1].objfile == addrmap[i].objfile) { + + if ((last_short == NULL && this_short != NULL) || + (last_short != NULL && this_short == NULL)) + return 0; + + if (last_short == NULL && this_short == NULL) + return 1; + + if (strcmp(last_short->short_obj, this_short->short_obj) == 0) + return 1; + } + return 0; +} + static void output_kallmodsyms_objfiles(void) { size_t i = 0; size_t emitted_offsets = 0; + size_t emitted_modules = 0; size_t emitted_objfiles = 0; if (base_relative) @@ -777,12 +1255,15 @@ static void output_kallmodsyms_objfiles(void) long long offset; int overflow; - /* - * Fuse consecutive address ranges citing the same object file - * into one. - */ - if (i > 0 && addrmap[i-1].objfile == addrmap[i].objfile) - continue; + printf("/* 0x%llx--0x%llx: %s */\n", addrmap[i].addr, + addrmap[i].end_addr, addrmap[i].obj); + + /* + * Fuse consecutive address ranges citing the same built-in + * module and objfile name into one. + */ + if (same_kallmodsyms_range(i)) + continue; if (base_relative) { if (!absolute_percpu) { @@ -809,11 +1290,12 @@ static void output_kallmodsyms_objfiles(void) for (i = 0; i < addrmap_num; i++) { struct obj2mod_elem *elem = addrmap[i].objfile; + struct obj2mod_elem *orig_elem = NULL; int orig_nmods; const char *orig_modname; int mod_offset; - if (i > 0 && addrmap[i-1].objfile == addrmap[i].objfile) + if (same_kallmodsyms_range(i)) continue; /* @@ -821,8 +1303,10 @@ static void output_kallmodsyms_objfiles(void) * built-in module. */ if (addrmap[i].objfile == NULL) { + printf("/* 0x%llx--0x%llx: %s: built-in */\n", + addrmap[i].addr, addrmap[i].end_addr, addrmap[i].obj); printf("\t.long\t0x0\n"); - emitted_objfiles++; + emitted_modules++; continue; } @@ -837,8 +1321,10 @@ static void output_kallmodsyms_objfiles(void) * always points at the start of the xref target, so its offset * can be used as is. */ - if (elem->xref) + if (elem->xref) { + orig_elem = elem; elem = elem->xref; + } if (elem->nmods == 1 || orig_nmods > 1) { @@ -874,6 +1360,19 @@ static void output_kallmodsyms_objfiles(void) * the multimodule entry. */ mod_offset += onemod - elem->mods + 2; + + /* + * If this was the result of an xref chase, store this + * mod_offset in the original entry so we can just reuse + * it if an objfile shares this name. + */ + + printf("/* 0x%llx--0x%llx: %s: single-module ref to %s in multimodule at %x */\n", + addrmap[i].addr, addrmap[i].end_addr, + orig_elem->mods, onemod, elem->mod_offset); + + if (orig_elem) + orig_elem->mod_offset = mod_offset; } /* @@ -883,12 +1382,68 @@ static void output_kallmodsyms_objfiles(void) assert(elem->mod_offset != 0); printf("\t.long\t0x%x\n", mod_offset); - emitted_objfiles++; + emitted_modules++; } - assert(emitted_offsets == emitted_objfiles); + assert(emitted_offsets == emitted_modules); output_label("kallsyms_num_modules"); + printf("\t.long\t%zi\n", emitted_modules); + + output_label("kallsyms_objfiles"); + + for (i = 0; i < addrmap_num; i++) { + struct obj2short_elem *elem; + int mod_offset; + + if (same_kallmodsyms_range(i)) + continue; + + /* + * No corresponding objfile name: no disambiguation needed; + * point at 0. + */ + elem = obj2short_get(addrmap[i].obj); + + if (elem == NULL) { + printf("/* 0x%llx--0x%llx: %s: unambiguous */\n", + addrmap[i].addr, addrmap[i].end_addr, + addrmap[i].obj); + printf("\t.long\t0x0\n"); + emitted_objfiles++; + continue; + } + + /* + * Maybe the name is also used for a module: if it is, it cannot + * be a multimodule. + */ + + if (elem->mod_xref) { + assert(elem->mod_xref->nmods == 1); + mod_offset = elem->mod_xref->mod_offset; + printf("/* 0x%llx--0x%llx: %s: shortened as %s, references module */\n", + addrmap[i].addr, addrmap[i].end_addr, + addrmap[i].obj, elem->short_obj); + } else { + /* + * A name only used for objfiles. Chase down xrefs to + * reuse existing entries. + */ + if (elem->short_xref) + elem = elem->short_xref; + + mod_offset = elem->short_offset; + printf("/* 0x%llx--0x%llx: %s: shortened as %s */\n", + addrmap[i].addr, addrmap[i].end_addr, + addrmap[i].obj, elem->short_obj); + } + printf("\t.long\t0x%x\n", mod_offset); + emitted_objfiles++; + } + assert(emitted_offsets == emitted_objfiles); + output_label("kallsyms_num_objfiles"); printf("\t.long\t%zi\n", emitted_objfiles); + printf("\n"); } #endif /* CONFIG_KALLMODSYMS */ @@ -1501,6 +2056,20 @@ static void read_modules(const char *modules_builtin) * Read linker map. */ read_linker_map(); + + /* + * Now the modules are sorted out and we know their address ranges, use + * the modhashes computed in optimize_obj2mod to identify any symbols + * that are still ambiguous and set up the minimal representation of + * their objfile name to disambiguate them. + */ + disambiguate_syms(); + + /* + * Now we have objfile names, optimize the objfile list. + */ + optimize_objnames(); + } #else static void read_modules(const char *unused) {} From patchwork Mon Dec 5 16:31:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064759 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 AC3D4C4321E for ; Mon, 5 Dec 2022 16:34:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbiLEQed (ORCPT ); Mon, 5 Dec 2022 11:34:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbiLEQdq (ORCPT ); Mon, 5 Dec 2022 11:33:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546FC1F9F8; Mon, 5 Dec 2022 08:33:33 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5Fk189018570; Mon, 5 Dec 2022 16:33:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=nB/TI+yi4xJXPvGW7ZydQLZZ5QhREcsRqGfho6p6tWs=; b=0i4R6BxkHIUl39ciLlRZ4CtQJJcaepAjOjn1r+F3zdRBz1CNoTlThXl8HafjA1piZKF3 ++If7x5eqoA94mUGZUG5gi9YXKKxIdyPWXqA93dULld/j8lDW7EbfGmgj7xd1TNHH/Q0 dHDBMIDy2OFIgrS0UvXQVSAfy4Z8AY6+0zOd3Ki3KfvQOo+i5NfQ1tonienAm4BS7b44 s3amKVS5LsjRAzLovYtjUMUlP2OWocI8mDsX/RYSg9lBHCPgmeiX8OT+mgmdVUhhuwFd oIh6Yd+wFOoAooxTvcyBKYFl3qgPkaEBBKEMa+UzaYCyiO3iCjh6/u+WRvMziRNmLdqS /A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7yb3c9t1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:25 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQu6o027839; Mon, 5 Dec 2022 16:33:24 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ua9dpwh-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TxROQjXjqBcffY1EUvmq8jpXrDyDaKmIymcUHecIXQ3SkwunQN0oPCjbAE1hRA/X6cWwzIpBL5rEj3l1Yhs4mPUI+jQsXH9+wIrt1eWkSOwy+0jDBYoWsutW2dVnM/0dWAqkd7BdI908mNWXTk8RiufTOR9Z1Ym41m0+rB7HaYw+7LSOJmLySd/chiUUbEshQyfXDWbmFKMk1K45AypoO19Hb7QnKWPBZNEqednYMyQmxjgJFhnc8r2Bu+XIINB25UZb+3gDZGhzuHA380/osRQqGk2uzp37fxblndaSy5Ci5+k2i4ielyzhQzCSBc7exLurtifkuzYfFoOc80eXVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nB/TI+yi4xJXPvGW7ZydQLZZ5QhREcsRqGfho6p6tWs=; b=XWm6FjQ9O3gPBjV4ORCnNe6sq71LDO3y8OuPI6XixOzfiFLZVZ9jEvGQYTnRM1Cftv8+FbOT59p1kaGLUTGZE4cicwNqx071Q7GwZ3nDlc/NBs7Xson846y7xJD0nheDY+cT6IPhHmzEWj5/ZGGu7pccExGU0633d00GfAo9Q4ux6kHEbh4pM2im2CUO1KwX6hswiY9v5JkZuF6utOOECBrHzDloVx8uZjFWMLjQxH4hDC0e6t6eG76qA6AD9W9ALV2M04CvNJrI9VwZubfA9FutUvqk8OYwZtjtQ/hKJfrPf1eMhGy8nIJa5Uw6aOyvK3iFUHX1f/HQq5yFmoAxig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nB/TI+yi4xJXPvGW7ZydQLZZ5QhREcsRqGfho6p6tWs=; b=ATRrdH2oAiH6surarQd9GGQeY8iUkIBN7ZeQng/uDUuysPdblf6pRvwM4iQK9WbAtgRw56RhhWYheP97qGR/vDXVV7tnDMNJ8p/5aZgcXCaAwit+X5jNTCUJwlAU7c8Nb6C4WwucQT5bAWFtyRl+v+NwOm4kOCNonAvRJsmr8xs= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by PH7PR10MB5721.namprd10.prod.outlook.com (2603:10b6:510:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Mon, 5 Dec 2022 16:33:22 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:33:22 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 12/13] kallsyms: add /proc/kallmodsyms for text symbol disambiguation Date: Mon, 5 Dec 2022 16:31:56 +0000 Message-Id: <20221205163157.269335-13-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P123CA0029.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::16) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|PH7PR10MB5721:EE_ X-MS-Office365-Filtering-Correlation-Id: 3419ee3b-851e-4d70-cd03-08dad6de61e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kVYkKWvllfEZMe9N9bxpaIeYfe48QfQnfVtjStqi0EUR/Kcp2ns4/eO4qiC+1IEfatntqehg/Y6aWxCKnlYrSjPWcuh9uX7um1CBm3rWO0sP3Ruy4PO0V5RrzsN2/sQegOw+ag1Abfx8Vkv7iqPn/hmJmKyhnNqyLckuLB1NmmJLrqAEcCUp0wxWRH625PJGnOAN/GSF0g0+2AzsUCCblNhdreHVpNcaqCcBrV/H2R1wMX2vwkn0Z2DMRUF7/ui01H/wCLtUWvYFs/6rE5/2LM00YBrFIbeMzZxskedjNVQLARkQucaBrqCZlJKkJmAs1niGbgLYHucFxTzak/sTa6j0mhVvZCXMXMt2YcmbU3/wb6ZroOhrlQMuuzST24fIpFDZaE1Y93P4xgxd0oDR4r3Lf4JIphW/KPpwoyaRxxfuz7zZTh7Qu6pHhOhztkhpHOHckAsOllgirJZcAXWme4q0nf8pqP+2xQPJliyMxCMMSBGXckYIUshuy8wZeFL/nKz3WuMSBQ63IbuxbLaQGODqkmZCYSb3T32nY4nUfxsQquFRwtFnpozYVLtBJSKoL/ysJP8FaB3HSYABBXdmgb3srBDSWa4lZiE5qhqQd1XGJsRQz/e0wESNlYmlJRPOARcepwTzR3ziJvWe2qUfxg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(136003)(346002)(396003)(39860400002)(451199015)(316002)(6486002)(107886003)(478600001)(6666004)(6506007)(6512007)(66946007)(8676002)(4326008)(66476007)(66556008)(83380400001)(30864003)(8936002)(5660300002)(44832011)(186003)(41300700001)(2906002)(1076003)(36756003)(2616005)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MLKszoSr+RIbK6UdDVzYYgTM7+oDClp7LYAXyhfuWcy29TYnCUQ6QiVht0RZueXtSiiWE+nThPzbb9DCwNTFmfZqiRiugx3UQXU1S/1mL/6istwfTmQ5NAhQBzI9bXMGxzf+LEtGMQU4zzA7YVyjoF99+7NG4ELufKPuOa60FuUOT1W3w2iAFmzFsi4wbuHjkrAKrPk7m44mEhVcCPvMkpBwRXI+xCW31E3vd9MHO+cVDKl/btQ4X1jJhkG4NxQiPIvuY05POIxwpv+fIzHIpgTwNPgzSROsfqYPd8FFsngCvJYfaxXs4CsnrLzyTl5mH2J8ooMVupnT2oQ3sCpvbmtE0b3Nu4Nz/MpwpaSLPrqO/RE/s6HVru3QW2RSRnC97/wVo3ybo4AVHnT9cjJabF8MpRsGN0nD0Co2eaxhYocCTiv4HmfROzQCSNGlJ+VF5M0j44KAU41gDVnWc8FM4wB+q2dZzD18xe0Q4BlDCN9bZS0e4GWvh9IGI+1Xs8+CgXb2tvCLm/2Dg9XNM2Av6z0gp2uafOmE15xKCtA+o7sRDD/KDI+nIQf/63jWT81gs5T29eZJNLmD7P+Nvzyf4ajNQxrf4WvOZk3rLwttevJcWWzF1Xp5diM3/v6hmNE3cxtgQtNIA6BRAjWSjA4AzWuF+pDcwZ2nhVW5MrRNO84z4JQHW7nXeZMZMYc54gM9eGZ96SMuN0pQb2MOdkt69wPwbF4pAd5hNfvvMjL7V6YCB8mOZnpmULuTGpL/dLLogz9WHRzoIap/z9yZterJVgCatYBtkCLGpy0bfgZdtrqXT+mi+epqBg8G1kUA3UT1yFTTAXmIFvnspQO2lIYTF4bL6DVfKgxA8/9tcOoOgLhSxss7Qxekh6a/sg0ytXLuMXcEhPLZCysTfrkN0Yes0aPOhJT9rk2DDuhPn22b5h8WZOmGL1kUZtAylMHvfE2wGvMmkM1nAAT2BUqxr8SaklzW2OKIzjA3fmXHf8wkZRw09mJw5mM80lfoKAae9zmyXV6pam6qvHJbiVzTKOdMCNtNX58cLEmFx3yhk4BSN1aMEUQP1DyvTEd8wswaaNkEDlQj5S/NfOdGfxoiJsFIlWMY/zEmpK6/7UzItYJi5cnCw+/Do+y03jdwI45jdZCol9MrQxIf1hRCBPuhBRETsAxPH0uw5vTvx3e7AX+nBNocbl5RPSNMo2pKqom54NCGGSMl6RXWJ2VdV7SgoXSKivuB4u3otvdzwo5LG504ddJFJX0LGGKgbK6VrvZKxF/QLM/hzRRV0FI+1EHYxiH0H8xkKk62qSCy7QJ3ezCtsMjFCeLm3rkZPt4m4UoTFuI06VaiixlrYuNLtSjd/Tv6REcPiFLVTMhuaLgMc3QnP/z0lD4AEmPl8ONtaZdXxrG4IwsM9yQHGw7Y97Vpft4IN7HubYbX8Hy2dEValRvoCZ9FMAiACMaUx+FEjgyS6LHppWMV8X1n9vhigaz+X09NCDYO7wSt60YuO///Ewf3xkrPnLAkr7y7/rvFDuBzZrDNPRVIGngCjHiJJAbAc2kcecHaWoLhimIc8kUKuDbQBPTpOj0pCal/23OVakILgXAa/R2wy5Q4td9e8jaSaCR9Ag== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: KU2wXOTn+9K8Dx4vQTlKm8uGeUNt0hR4b8TSVR/TxcScOTWQa7fermwCzaBvDo6sEuyMLJx9iXhtF3ZMQuCyUp/SxrMM614UKOTpmhN+T5R+7RoewTQ8Kp2PG0VFyE+888zt2MZ0fD4YkYooOHRigiR+i8Tjo9aHswNriU6ebei1vg/pu0/CTy9gLP9SGxa8TLkk7/20+hU8row/TT1+8IXt4r+Te3a6NjYlDOC5gfPRLwqfhvfWFdbpYFkgfv/OYwL1t8mnP1ThyRbRoh1uAHU/xJKni+eKIonUFoU6ZUcNRh1VtD+ZajfOqY1CS7h/MTQ2QrlTywolTmVqlhw7UYEVHYyl15Alp+eSVXB8muRNbm6E6yDGGANl4sGaqks6oPf0HfC6egmD4AP6njFCUQ4jjcFEsxd+nOWUeZWUxnaVG17WG6OA5AuI+4vUGio6KLBGJHnPCl10B90GxyxBKZEDOnRiBpyxka+GD4JAFNtOW1Hu1KKr9+YOVqXGiDGiEJzh7QocIPjomtlKwqJU5ygObIiTniwQkYuf6gyLatjQRbm98mX02szMB9NapYIv4quh6Z03r36MwK+Toadj0RG0d1ogf7isCUphqZ4BSsWzknlq//wZVsLf4BQ+3ujjx+l0mmr+oBs0NBelDCrHhekwfx6794OO6CdfCxw1eQ0MFUPNIESvRJwmX1FDEAbezJZ+fu90w6jSHE8J3uv8XPDu818qW208NGpib29js+/7UiLjf/DOKxxrLdJVmE7UmocGCVcTkO/Ddelsyq3uXiUJSMxJ3taj6uNRZYPiK/oPZOzebIClWuSjFFtFS1oYDuoptHy38OrESfogYhXsXwtC83zqBZXMgFOTgKKww69SAr3pNJmDB88VVNSjOufM/RsgYl5xbE/2EfDxqDv0pl32YHvscWb+juzTvpVcwq2/fuhluMNKr+qh+p1QdE2yt7CsWii3hDedJkFntGtM0C1lPpdTvjs7R0EX9NzgAjI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3419ee3b-851e-4d70-cd03-08dad6de61e4 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:33:04.1533 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9NsWeNgbFzBNU6RHfURm6a4dKGZe0mZrMdoKPMi94E8OTnEu++Yw+18U1S46sl++aB33BK25UqbO6hDsuQAH2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5721 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050138 X-Proofpoint-ORIG-GUID: GyqHBe2gfCzU-kVDkvS5qEDNHVX-0Ytu X-Proofpoint-GUID: GyqHBe2gfCzU-kVDkvS5qEDNHVX-0Ytu Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Use the tables added in the previous commits to introduce a new /proc/kallmodsyms, in which [module names] are also given for things that *could* have been modular had they not been built in to the kernel. So symbols that are part of, say, ext4 are reported as [ext4] even if ext4 happens to be buiilt in to the kernel in this configuration. This helps disambiguate symbols with identical names when some are in built-in modules are some are not, but if symbols are still ambiguous, {object file names} are added as needed to disambiguate them. The object file names are only shown if they would prevent ambiguity, and are minimized by chopping off as many leading path components as possible without (symbol, module, objfile) combinations becoming ambiguous again. (Not every symbol with an {object file name} is necessarily ambiguous, but at least one symbol in any such object file would have been ambiguous if the object file was not mentioned.) Symbols that are part of multiple modules at the same time are shown with [multiple] [module names]: consumers will have to be ready to handle such lines. Also, kernel symbols for built-in modules will be sorted by address, as usual for the core kernel, so will probably appear interspersed with other symbols that are part of different modules and non-modular always-built-in symbols, which, as usual, have no square-bracketed module denotation. This differs from /proc/kallsyms; even though /proc/kallsyms shows the same symbols as /proc/kallmodsyms in the same order, the only modules it names are loadable ones, which are necessarily in single contiguous blocks and thus shown contiguously. The result looks like this: ([...] to show where lines are omitted for brevity): ffffffff97606e50 t not_visible ffffffff97606e70 T perf_msr_probe ffffffff97606f80 t test_msr [rapl] ffffffff97606fa0 t __rapl_pmu_event_start [rapl] [...] ffffffffa6007350 t rapl_pmu_event_stop [rapl] ffffffffa6007440 t rapl_pmu_event_del [rapl] ffffffffa6007460 t rapl_hrtimer_handle [rapl] ffffffffa6007500 t rapl_pmu_event_read [rapl] ffffffffa6007520 t rapl_pmu_event_init [rapl] ffffffffa6007630 t rapl_cpu_offline [rapl] ffffffffa6007710 t amd_pmu_event_map {core.o} ffffffffa6007750 t amd_pmu_add_event {core.o} ffffffffa6007760 t amd_put_event_constraints_f17h {core.o} The [rapl] notation is emitted even if rapl is built into the kernel (but, obviously, not if it's not in the .config at all, or is in a loadable module that is not loaded). The {core.o} is an object file name. Further down, we see what happens when object files are reused by multiple modules, all of which are built in to the kernel, and some of which have symbols that would be ambiguous without an object file name attached in addition to the module names: ffffffff97d7aed0 t liquidio_pcie_mmio_enabled [liquidio] ffffffff97d7aef0 t liquidio_pcie_resume [liquidio] ffffffff97d7af00 t liquidio_ptp_adjtime [liquidio] ffffffff97d7af50 t liquidio_ptp_enable [liquidio] ffffffff97d7af70 t liquidio_get_stats64 [liquidio] ffffffff97d7b0f0 t liquidio_fix_features [liquidio] ffffffff97d7b1c0 t liquidio_get_port_parent_id [liquidio] [...] ffffffff97d824c0 t lio_vf_rep_modinit [liquidio] ffffffff97d824f0 t lio_vf_rep_modexit [liquidio] ffffffff97d82520 t lio_ethtool_get_channels [liquidio] [liquidio_vf] ffffffff97d82600 t lio_ethtool_get_ringparam [liquidio] [liquidio_vf] ffffffff97d826a0 t lio_get_msglevel [liquidio] [liquidio_vf] ffffffff97d826c0 t lio_vf_set_msglevel [liquidio] [liquidio_vf] ffffffff97d826e0 t lio_get_pauseparam [liquidio] [liquidio_vf] ffffffff97d82710 t lio_get_ethtool_stats [liquidio] [liquidio_vf] ffffffff97d82e70 t lio_vf_get_ethtool_stats [liquidio] [liquidio_vf] [...] ffffffff97d91a80 t cn23xx_vf_mbox_thread [liquidio] [liquidio_vf] {cn23xx_vf_device.o} ffffffff97d91aa0 t cpumask_weight.constprop.0 [liquidio] [liquidio_vf] {cn23xx_vf_device.o} ffffffff97d91ac0 t cn23xx_vf_msix_interrupt_handler [liquidio] [liquidio_vf] {cn23xx_vf_device.o} ffffffff97d91bd0 t cn23xx_vf_get_oq_ticks [liquidio] [liquidio_vf] {cn23xx_vf_device.o} ffffffff97d91c00 t cn23xx_vf_ask_pf_to_do_flr [liquidio] [liquidio_vf] {cn23xx_vf_device.o} ffffffff97d91c70 t cn23xx_octeon_pfvf_handshake [liquidio] [liquidio_vf] {cn23xx_vf_device.o} ffffffff97d91e20 t cn23xx_setup_octeon_vf_device [liquidio] [liquidio_vf] {cn23xx_vf_device.o} ffffffff97d92060 t octeon_mbox_read [liquidio] [liquidio_vf] ffffffff97d92230 t octeon_mbox_write [liquidio] [liquidio_vf] [...] ffffffff97d946b0 t octeon_alloc_soft_command_resp [liquidio] [liquidio_vf] ffffffff97d947e0 t octnet_send_nic_data_pkt [liquidio] [liquidio_vf] ffffffff97d94820 t octnet_send_nic_ctrl_pkt [liquidio] [liquidio_vf] ffffffff97d94ab0 t liquidio_get_stats64 [liquidio_vf] ffffffff97d94c10 t liquidio_fix_features [liquidio_vf] ffffffff97d94cd0 t wait_for_pending_requests [liquidio_vf] Like /proc/kallsyms, the output is driven by address, so keeps the curious property of /proc/kallsyms that symbols may appear repeatedly with different addresses: but now, unlike in /proc/kallsyms, we can see that those symbols appear repeatedly because they are *different symbols* that ultimately belong to different modules or different object files within a module, all of which are built in to the kernel. As with /proc/kallsyms, non-root usage produces addresses that are all zero. I am not wedded to the name or format of /proc/kallmodsyms, but felt it best to split it out of /proc/kallsyms to avoid breaking existing kallsyms parsers. This is currently driven by a new config option, but now that kallmodsyms data uses very little space, this option might be something people don't want to bother with: maybe we can just control it via CONFIG_KALLSYMS or something. Internally, this uses a new kallsyms_builtin_module_address() almost identical to kallsyms_sym_address() to get the address corresponding to a given .kallsyms_modules index, and a new get_builtin_modobj_idx quite similar to get_symbol_pos to determine the index in the .kallsyms_modules and .kallsyms_objfiles arrays that relate to a given address. We save a little time by exploiting the fact that all callers will only ever traverse this list from start to end by allowing them to pass in the previous index returned from this function as a hint: thus very few bsearches are actually needed. (In theory this could change to just walk straight down kallsyms_module_addresses/offsets and not bother bsearching at all, but doing it this way is hardly any slower and much more robust.) We explicitly filter out displaying modules for non-text symbols (perhaps this could be lifted for initialized data symbols in future). There might be occasional incorrect module or objfile names for section start/end symbols. The display process is complicated a little by the weird format of the .kallsyms_mod_objnames table: we have to look for multimodule entries and print them as space-separated lists of module names. Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- Notes: v9: add objfile support. Commit message adjustments. v10: Slight conflict adjustments. kernel/kallsyms.c | 277 ++++++++++++++++++++++++++++++++++--- kernel/kallsyms_internal.h | 14 ++ 2 files changed, 274 insertions(+), 17 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 83f499182c9a..5306208060a0 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -163,6 +163,25 @@ unsigned long kallsyms_sym_address(int idx) return kallsyms_relative_base - 1 - kallsyms_offsets[idx]; } +#ifdef CONFIG_KALLMODSYMS +static unsigned long kallsyms_builtin_module_address(int idx) +{ + if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE)) + return kallsyms_module_addresses[idx]; + + /* values are unsigned offsets if --absolute-percpu is not in effect */ + if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU)) + return kallsyms_relative_base + (u32)kallsyms_module_offsets[idx]; + + /* ...otherwise, positive offsets are absolute values */ + if (kallsyms_module_offsets[idx] >= 0) + return kallsyms_module_offsets[idx]; + + /* ...and negative offsets are relative to kallsyms_relative_base - 1 */ + return kallsyms_relative_base - 1 - kallsyms_module_offsets[idx]; +} +#endif + static bool cleanup_symbol_name(char *s) { char *res; @@ -385,6 +404,54 @@ static unsigned long get_symbol_pos(unsigned long addr, return low; } +/* + * The caller passes in an address, and we return an index to the corresponding + * builtin module index in .kallsyms_modules and .kallsyms_objfiles, or + * (unsigned long) -1 if none match. + * + * The hint_idx, if set, is a hint as to the possible return value, to handle + * the common case in which consecutive runs of addresses relate to the same + * index. + */ +#ifdef CONFIG_KALLMODSYMS +static unsigned long get_builtin_modobj_idx(unsigned long addr, unsigned long hint_idx) +{ + unsigned long low, high, mid; + + if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE)) + BUG_ON(!kallsyms_module_addresses); + else + BUG_ON(!kallsyms_module_offsets); + + /* + * Do a binary search on the sorted kallsyms_modules array. The last + * entry in this array indicates the end of the text section, not an + * object file. + */ + low = 0; + high = kallsyms_num_modules - 1; + + if (hint_idx > low && hint_idx < (high - 1) && + addr >= kallsyms_builtin_module_address(hint_idx) && + addr < kallsyms_builtin_module_address(hint_idx + 1)) + return hint_idx; + + if (addr >= kallsyms_builtin_module_address(low) + && addr < kallsyms_builtin_module_address(high)) { + while (high - low > 1) { + mid = low + (high - low) / 2; + if (kallsyms_builtin_module_address(mid) <= addr) + low = mid; + else + high = mid; + } + return low; + } + + return (unsigned long) -1; +} +#endif + /* * Lookup an address but don't bother to find any names. */ @@ -656,6 +723,9 @@ struct kallsym_iter { char type; char name[KSYM_NAME_LEN]; char module_name[MODULE_NAME_LEN]; + const char *builtin_module_names; + const char *builtin_objfile_name; + unsigned long hint_builtin_modobj_idx; int exported; int show_value; }; @@ -686,6 +756,9 @@ static int get_ksymbol_mod(struct kallsym_iter *iter) &iter->value, &iter->type, iter->name, iter->module_name, &iter->exported); + iter->builtin_module_names = NULL; + iter->builtin_objfile_name = NULL; + if (ret < 0) { iter->pos_mod_end = iter->pos; return 0; @@ -705,6 +778,9 @@ static int get_ksymbol_ftrace_mod(struct kallsym_iter *iter) &iter->value, &iter->type, iter->name, iter->module_name, &iter->exported); + iter->builtin_module_names = NULL; + iter->builtin_objfile_name = NULL; + if (ret < 0) { iter->pos_ftrace_mod_end = iter->pos; return 0; @@ -719,6 +795,8 @@ static int get_ksymbol_bpf(struct kallsym_iter *iter) strlcpy(iter->module_name, "bpf", MODULE_NAME_LEN); iter->exported = 0; + iter->builtin_module_names = NULL; + iter->builtin_objfile_name = NULL; ret = bpf_get_kallsym(iter->pos - iter->pos_ftrace_mod_end, &iter->value, &iter->type, iter->name); @@ -739,23 +817,74 @@ static int get_ksymbol_kprobe(struct kallsym_iter *iter) { strlcpy(iter->module_name, "__builtin__kprobes", MODULE_NAME_LEN); iter->exported = 0; + iter->builtin_module_names = NULL; + iter->builtin_objfile_name = NULL; return kprobe_get_kallsym(iter->pos - iter->pos_bpf_end, &iter->value, &iter->type, iter->name) < 0 ? 0 : 1; } /* Returns space to next name. */ -static unsigned long get_ksymbol_core(struct kallsym_iter *iter) +static unsigned long get_ksymbol_core(struct kallsym_iter *iter, int kallmodsyms) { unsigned off = iter->nameoff; - iter->module_name[0] = '\0'; + iter->exported = 0; iter->value = kallsyms_sym_address(iter->pos); iter->type = kallsyms_get_symbol_type(off); + iter->module_name[0] = '\0'; + iter->builtin_module_names = NULL; + iter->builtin_objfile_name = NULL; + off = kallsyms_expand_symbol(off, iter->name, ARRAY_SIZE(iter->name)); +#ifdef CONFIG_KALLMODSYMS + if (kallmodsyms) { + unsigned long modobj_idx = (unsigned long) -1; + + if (kallsyms_module_offsets) + modobj_idx = + get_builtin_modobj_idx(iter->value, + iter->hint_builtin_modobj_idx); + /* + * This is a built-in module iff the tables of built-in modules + * (address->module name mappings), object files (ditto), and + * module/objfile names are known, and if the address was found + * there, and if the corresponding module index is nonzero, and + * iff this is a text (or weak) symbol. All other cases mean + * off the end of the binary or in a non-modular range in + * between one or more modules. + * + * The same rules are true for kallsyms_objfiles, except that + * zero entries are much more common because we only record + * object file names if we need them to disambiguate one or more + * symbols: see scripts/kallsyms.c:disambiguate_syms. + * + * (Also guard against corrupt kallsyms_modules or + * kallsyms_objfiles arrays pointing off the end of + * kallsyms_mod_objnames.) + */ + if (kallsyms_modules != NULL && kallsyms_mod_objnames != NULL && + kallsyms_objfiles != NULL && + (iter->type == 't' || iter->type == 'T' || + iter->type == 'w' || iter->type == 'W') && + modobj_idx != (unsigned long) -1) { + + if (kallsyms_modules[modobj_idx] != 0 && + kallsyms_modules[modobj_idx] < kallsyms_mod_objnames_len) + iter->builtin_module_names = + &kallsyms_mod_objnames[kallsyms_modules[modobj_idx]]; + + if (kallsyms_objfiles[modobj_idx] != 0 && + kallsyms_objfiles[modobj_idx] < kallsyms_mod_objnames_len) + iter->builtin_objfile_name = + &kallsyms_mod_objnames[kallsyms_objfiles[modobj_idx]]; + } + iter->hint_builtin_modobj_idx = modobj_idx; + } +#endif return off - iter->nameoff; } @@ -801,7 +930,7 @@ static int update_iter_mod(struct kallsym_iter *iter, loff_t pos) } /* Returns false if pos at or past end of file. */ -static int update_iter(struct kallsym_iter *iter, loff_t pos) +static int update_iter(struct kallsym_iter *iter, loff_t pos, int kallmodsyms) { /* Module symbols can be accessed randomly. */ if (pos >= kallsyms_num_syms) @@ -811,7 +940,7 @@ static int update_iter(struct kallsym_iter *iter, loff_t pos) if (pos != iter->pos) reset_iter(iter, pos); - iter->nameoff += get_ksymbol_core(iter); + iter->nameoff += get_ksymbol_core(iter, kallmodsyms); iter->pos++; return 1; @@ -821,14 +950,14 @@ static void *s_next(struct seq_file *m, void *p, loff_t *pos) { (*pos)++; - if (!update_iter(m->private, *pos)) + if (!update_iter(m->private, *pos, 0)) return NULL; return p; } static void *s_start(struct seq_file *m, loff_t *pos) { - if (!update_iter(m->private, *pos)) + if (!update_iter(m->private, *pos, 0)) return NULL; return m->private; } @@ -837,7 +966,7 @@ static void s_stop(struct seq_file *m, void *p) { } -static int s_show(struct seq_file *m, void *p) +static int s_show_internal(struct seq_file *m, void *p, int kallmodsyms) { void *value; struct kallsym_iter *iter = m->private; @@ -848,23 +977,82 @@ static int s_show(struct seq_file *m, void *p) value = iter->show_value ? (void *)iter->value : NULL; - if (iter->module_name[0]) { + /* + * Real module, or built-in module and /proc/kallsyms being shown. + */ + if (iter->module_name[0] != '\0' || + (iter->builtin_module_names != NULL && kallmodsyms != 0)) { char type; /* - * Label it "global" if it is exported, - * "local" if not exported. + * Label it "global" if it is exported, "local" if not exported. */ type = iter->exported ? toupper(iter->type) : tolower(iter->type); - seq_printf(m, "%px %c %s\t[%s]\n", value, - type, iter->name, iter->module_name); - } else - seq_printf(m, "%px %c %s\n", value, +#ifdef CONFIG_KALLMODSYMS + if (kallmodsyms) { + /* + * /proc/kallmodsyms, built as a module. + */ + if (iter->builtin_module_names == NULL) + seq_printf(m, "%px %c %s\t[%s]", value, + type, iter->name, + iter->module_name); + /* + * /proc/kallmodsyms, single-module symbol. + */ + else if (*iter->builtin_module_names != '\0') + seq_printf(m, "%px %c %s\t[%s]", value, + type, iter->name, + iter->builtin_module_names); + /* + * /proc/kallmodsyms, multimodule symbol. Formatted + * as \0MODULE_COUNTmodule-1\0module-2\0, where + * MODULE_COUNT is a single byte, 2 or higher. + */ + else { + size_t i = *(char *)(iter->builtin_module_names + 1); + const char *walk = iter->builtin_module_names + 2; + + seq_printf(m, "%px %c %s\t[%s]", value, + type, iter->name, walk); + + while (--i > 0) { + walk += strlen(walk) + 1; + seq_printf(m, " [%s]", walk); + } + } + /* + * Possibly there is an objfile name too, if needed to + * disambiguate at least one symbol. + */ + if (iter->builtin_objfile_name) + seq_printf(m, " {%s.o}", iter->builtin_objfile_name); + + seq_printf(m, "\n"); + } else /* !kallmodsyms */ +#endif /* CONFIG_KALLMODSYMS */ + seq_printf(m, "%px %c %s\t[%s]\n", value, + type, iter->name, iter->module_name); + } else { + seq_printf(m, "%px %c %s", value, iter->type, iter->name); +#ifdef CONFIG_KALLMODSYMS + if (kallmodsyms) { + if (iter->builtin_objfile_name) + seq_printf(m, "\t{%s.o}", iter->builtin_objfile_name); + } +#endif /* CONFIG_KALLMODSYMS */ + seq_printf(m, "\n"); + } return 0; } +static int s_show(struct seq_file *m, void *p) +{ + return s_show_internal(m, p, 0); +} + static const struct seq_operations kallsyms_op = { .start = s_start, .next = s_next, @@ -872,6 +1060,36 @@ static const struct seq_operations kallsyms_op = { .show = s_show }; +#ifdef CONFIG_KALLMODSYMS +static int s_mod_show(struct seq_file *m, void *p) +{ + return s_show_internal(m, p, 1); +} + +static void *s_mod_next(struct seq_file *m, void *p, loff_t *pos) +{ + (*pos)++; + + if (!update_iter(m->private, *pos, 1)) + return NULL; + return p; +} + +static void *s_mod_start(struct seq_file *m, loff_t *pos) +{ + if (!update_iter(m->private, *pos, 1)) + return NULL; + return m->private; +} + +static const struct seq_operations kallmodsyms_op = { + .start = s_mod_start, + .next = s_mod_next, + .stop = s_stop, + .show = s_mod_show +}; +#endif + #ifdef CONFIG_BPF_SYSCALL struct bpf_iter__ksym { @@ -997,7 +1215,8 @@ bool kallsyms_show_value(const struct cred *cred) } } -static int kallsyms_open(struct inode *inode, struct file *file) +static int kallsyms_open_internal(struct inode *inode, struct file *file, + const struct seq_operations *ops) { /* * We keep iterator in m->private, since normal case is to @@ -1005,7 +1224,7 @@ static int kallsyms_open(struct inode *inode, struct file *file) * using get_symbol_offset for every symbol. */ struct kallsym_iter *iter; - iter = __seq_open_private(file, &kallsyms_op, sizeof(*iter)); + iter = __seq_open_private(file, ops, sizeof(*iter)); if (!iter) return -ENOMEM; reset_iter(iter, 0); @@ -1018,6 +1237,18 @@ static int kallsyms_open(struct inode *inode, struct file *file) return 0; } +static int kallsyms_open(struct inode *inode, struct file *file) +{ + return kallsyms_open_internal(inode, file, &kallsyms_op); +} + +#ifdef CONFIG_KALLMODSYMS +static int kallmodsyms_open(struct inode *inode, struct file *file) +{ + return kallsyms_open_internal(inode, file, &kallmodsyms_op); +} +#endif + #ifdef CONFIG_KGDB_KDB const char *kdb_walk_kallsyms(loff_t *pos) { @@ -1028,7 +1259,7 @@ const char *kdb_walk_kallsyms(loff_t *pos) reset_iter(&kdb_walk_kallsyms_iter, 0); } while (1) { - if (!update_iter(&kdb_walk_kallsyms_iter, *pos)) + if (!update_iter(&kdb_walk_kallsyms_iter, *pos, 0)) return NULL; ++*pos; /* Some debugging symbols have no name. Ignore them. */ @@ -1045,9 +1276,21 @@ static const struct proc_ops kallsyms_proc_ops = { .proc_release = seq_release_private, }; +#ifdef CONFIG_KALLMODSYMS +static const struct proc_ops kallmodsyms_proc_ops = { + .proc_open = kallmodsyms_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = seq_release_private, +}; +#endif + static int __init kallsyms_init(void) { proc_create("kallsyms", 0444, NULL, &kallsyms_proc_ops); +#ifdef CONFIG_KALLMODSYMS + proc_create("kallmodsyms", 0444, NULL, &kallmodsyms_proc_ops); +#endif return 0; } device_initcall(kallsyms_init); diff --git a/kernel/kallsyms_internal.h b/kernel/kallsyms_internal.h index 27fabdcc40f5..91534a75c996 100644 --- a/kernel/kallsyms_internal.h +++ b/kernel/kallsyms_internal.h @@ -22,8 +22,22 @@ __section(".rodata") __attribute__((weak)); extern const unsigned long kallsyms_relative_base __section(".rodata") __attribute__((weak)); +extern const unsigned long kallsyms_num_modules +__section(".rodata") __attribute__((weak)); + +extern const unsigned long kallsyms_num_objfiles +__section(".rodata") __attribute__((weak)); + +extern const unsigned long kallsyms_mod_objnames_len +__section(".rodata") __attribute__((weak)); + extern const char kallsyms_token_table[] __weak; extern const u16 kallsyms_token_index[] __weak; +extern const unsigned long kallsyms_module_addresses[] __weak; +extern const int kallsyms_module_offsets[] __weak; +extern const u32 kallsyms_modules[] __weak; +extern const u32 kallsyms_objfiles[] __weak; +extern const char kallsyms_mod_objnames[] __weak; extern const unsigned int kallsyms_markers[] __weak; extern const u8 kallsyms_seqs_of_names[] __weak; From patchwork Mon Dec 5 16:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 13064760 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 35B69C4332F for ; Mon, 5 Dec 2022 16:34:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbiLEQej (ORCPT ); Mon, 5 Dec 2022 11:34:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232170AbiLEQds (ORCPT ); Mon, 5 Dec 2022 11:33:48 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F219B1FCC2; Mon, 5 Dec 2022 08:33:33 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5FlDQl018571; Mon, 5 Dec 2022 16:33:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=ESW/Yjf5FS3Id/vgv6YbnhM53BV7oX8cqgIBpuTM/+g=; b=eAPOTHRh7+u9UPebQAYjy22A0NWQLop4Fqh0A44O9UI13n+3FB9UcQjr9KLLrK/3J811 jMZJhGYUGa5FvF6kgg2IR28JNW78V39EXEP7O0OHDUz5JwhYR0oSxtioPo/IgvfGuwyX 0kPb3SudcAUnJJSYGreoej+gCsVv17LiBXpHG72NoLr7UX36vUozMKz+HKoRfPWRD3VW zTVr9f/lJdOLEIOwOYKojzWHBdSHDQxlR9Aavr0sUGdQ+xtrLU4ZxUtCQ69cmkCujm/U OsxjSudBGUU9XUA9tZpjHekCb4sHyTU6F0zaynLAOix6jhJQotfh7eV/VLqDSJvDA31y Vw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m7yb3c9t4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:27 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2B5GQu6r027839; Mon, 5 Dec 2022 16:33:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m8ua9dpwh-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 16:33:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XjNfAk9Kupf/ZeWwMx91jpmCUjUTpQ7gESkzocHV0CCAPAnK7B1B8qqy3AlNCk//+vGkD2RV2Xo9G6s28eNsYtSVFfmilcEFlHoLfUrps3X5mVpcSJ6QHaOhgWXMvJ+CFdUBov1Ju8bpRVJ5BD1ajBHmVUDrfIjI93TaPMg8tUMyITeNNbWB2hr6tWXWigh5Jg5rgbzABbLP5sUwtOqDgvtcX2vFkPs6RH78p+dZcim4gBzBN34wvbZ8pjvHZFnR5xUYa5wNEKV+xy28nfg/+XWo1zaV95uhcBWK0IxHLgb2HM136Tf4LNoSZqHMmrxfY0q+zesPPpe0iRCkt70THw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ESW/Yjf5FS3Id/vgv6YbnhM53BV7oX8cqgIBpuTM/+g=; b=jFMiviVceju27bD3fT3t4DaegeiNT6uH8OfqvlDNXmEeUGI3HWBzxghxudtoknuq1LhO/WwSJUV8Zhu3dR9ZYdfNMIVSHbewOHkHNMuah+CbmhZL27r+Xh+QAPfNmR+3pUwC4x3sIH3/+tozuduiUJDWc2loaYEppv0bCZye/NlOmkV6b0b6CFBG/IgbkEakRD7BEuJucIDBFP1R725AWS36ixoRbwYSw5qRVJdMNEvADG3q/rwHeb5y9HpvYirEtYLv8SDdQ2wDO/fbNW38r7RhFDXhq9KNYk3rh9ZaAT1tWT5SG6KNu1HYY2fNYGOV4QkcyK87ZXz3WOD9KO3PFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ESW/Yjf5FS3Id/vgv6YbnhM53BV7oX8cqgIBpuTM/+g=; b=SSSzK9NA9QNfv8f3msbsE+Fsvj6gbBlXCpZmdURn2wh5npywv5NYszHZX/jYm3N3DtTuIaUTI2IN6DAGN+kAPZ7jyaBfQXfKqfOarddztj2VppxeJN/ARnQkdOZ9vnqaq6AC/yyJSWyagOOZITBt02NwXK2ZHj0q00GlJ5C2HP0= Received: from DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) by PH7PR10MB5721.namprd10.prod.outlook.com (2603:10b6:510:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Mon, 5 Dec 2022 16:33:22 +0000 Received: from DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7]) by DS0PR10MB6798.namprd10.prod.outlook.com ([fe80::6e94:e2a2:ca1f:2a7%9]) with mapi id 15.20.5880.014; Mon, 5 Dec 2022 16:33:22 +0000 From: Nick Alcock To: mcgrof@kernel.org, masahiroy@kernel.org Cc: linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, eugene.loh@oracle.com, kris.van.hees@oracle.com Subject: [PATCH v10 13/13] perf: proof-of-concept kallmodsyms support Date: Mon, 5 Dec 2022 16:31:57 +0000 Message-Id: <20221205163157.269335-14-nick.alcock@oracle.com> X-Mailer: git-send-email 2.38.0.266.g481848f278 In-Reply-To: <20221205163157.269335-1-nick.alcock@oracle.com> References: <20221205163157.269335-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO2P265CA0042.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:61::30) To DS0PR10MB6798.namprd10.prod.outlook.com (2603:10b6:8:13c::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB6798:EE_|PH7PR10MB5721:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b0de3a9-11cb-4d2b-ea31-08dad6de645c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7ZuaS7o4syyHesY9W+rHAPGrYjaCwqvDaVWsyPDi2Xlgn89dA+K+q5ASNj/sg+MBICL1ND+XnCfcXXIPpGKHjv2x2gu8xB0dh+PackcGVnXgyGclztWEfJW/2tgnO/tYU/uehjyiRq40rSYg0le400H+9t5xwQ/v8ScN39e+CYzflU5jo8huyDg4sjrz4sglZ7QD+8heRRGpYMoQy+ha13HT4629y2+/Cy56ms//jsoenJr8/zvxBnY49vMsMeiLhVAHRtDsZ5uH4bS8aSYMBiHvbyD9/7O+uIsOzbq6Sb5HzutfrDDE28NCmW2qpLxJ8ARkOZypOlWaNQxm5hqW9+l3onujD+ujIMGwGTsyhSnICZNu6OqTmGcOFUJA2CD6gNeiBaFaTpiHghCQNEpQFCH0TAqeRw9vD7uI8wqWNfPN5pQY0hS3VfVDCTi5s1MRxzKjJgOT7f8kVL3bFQWKPwQBdg1MRCoNwcPPJ9TLZXek2N2H1b3MwjW0nZ85ZQ5p41VWhOlVk2TAbegbhXUT//Bz/3nfQtD59kX/4lAK/n/YhGCFp5ZXpHMla75AZ/SHB4qcbyt2HrrTmmZhMSl+JUPxPozP0eJWUojinuzuS6Djx0dMpIxpeD7aEMkKM8/J2LAr2vAQHEXly6TfrGClug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB6798.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(136003)(346002)(396003)(39860400002)(451199015)(316002)(6486002)(107886003)(478600001)(6666004)(6506007)(6512007)(66946007)(8676002)(4326008)(66476007)(66556008)(83380400001)(30864003)(8936002)(5660300002)(44832011)(186003)(41300700001)(2906002)(1076003)(36756003)(2616005)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zfAlLWfbaAxtYmzNagh/Bdxp9Wm8MJhbsFKE7ArTvKJRN/Dko06dq4/vhgn/iVxn0/1Sh1qAheQo41mMby1bwByL1UFlhIY1cMfoahZFoEIl/jue9k2CEhRTPLfk6CK9TnS8mJ3MB8GQbRNduY9jSSBcMdP7pit+6rOcnB8qYW0A0O+UB40rJY9PYXsuARGFDhB/RXQaMPsMvUeGK9tqTMoCZbkWD0exU4v5kdRbdbdpMchddGClLQCMvDBF+s6WbinnJhtaA3ASQxOvcoMZFX6gs+kUpDh0Qy+Qd7EMcJSLmXurMGAalJNVBgstJqiUm0X3pNnUhRNUYwW/tQcbmS70q0P8TTmZkhfP53NM61FkgkugnEVV15405k+OsB89/wcvivvBxG+HeBtNLKlaFM9VZf+Jd5dgUQIiTX8Y//WdwFYnk82Nrxlh2jOzu8CPOMY0ei1shJSUQhaXYnnX9LnZUwzcutumTa0h6UEjEM+sBU0RMcFNDgQKcpHCD2sIaT4I2VIdUIOCqUypy6Wwua/ygXRwDAnL6NL0YwsGaLepuMJsuiSvtOFTXrerx8EIGRk89+X/2x+h/Rc5ol61cXcMhiobR2d5YSPeZna0H2ev3VFNklkCE9/NkBOWZkP0ThhnQ86YYa1rUyJKJq5u0HU3052hN4CKoaPTpa6bX/5PlRV7fRXBbBFkgE8aB3fIH4QoB7vPPNFWIvdyiv1i2CTTF3dtRi1p+I0vvbAG/xBpspswVOyYQg4tjgxJCZNJGE7eLbSFW+wFe2U0xlKXvxX6KHW+5qwG24SfuDJxVsbU7zwm3ArGs8hypdVQm1/i75Fk7v95SatBWspnhO+AIHZ8jeLh8rvotWzk2xWMlWEatjhZu30awybaMDNbRHV4HnP5Q275izz2TRBMBnLKk2FWGJcz2tEyWtL0FGW5cnJSDcFs42S7cTjlu1G/+vXYbW6hrgmVmOvYn9pFhU+E+5UeWCwSVX4O782emiBuSXET/j+c1HSA1GiR0xHlkb3dgRdik3TOyeYZjju0J1oxsE02t1brhY5tGZaUmUj2FdGzY+dR0RhkOkh06ELoBuNbS1iCl5GbswOleX5ciXI1oPulmi6KfhRX05xPKFreUNrUwmAzkSCRh9KHlRpLcE6FpBSkzwcniTXkW/96qNLYjnHUyO4FwvSOTbHOsrEmmQDxhTgKgP8ynN7UNm3Grp2A8wlp+V2TRmiTj61mnbdK2vqLLq0qFBNHMX+K5KbNmRtY6CJ8GEQX+m20S80Wlk8fGgmei09EoJ4W8ZvwxaEN7B2FvMAS1xmM680vr8lc2/2JjJS8mmyTQAfZKSFkmXdEhSME1Uc1rpahNwbkNS0fTScyT1b/Vu1O2VnmexRQlU2Qiy1X3q5s7KqqnGzl2mdAKOiv0Zy7f8F3F22Ns85S0Kb3XQEgOQtK+qcL459vgr0XhZ9m4RlZ+dGGQytlk7D3yuvPxvc7WNjUtBwna8e1SlQCsL6SmniJjygy+ztw/3YXt4iPjnCHZmx88QZ69qQyZJI58ltLsBH5IsXhL2h3Imld5Subrl5WCdajBAP6ejcVWKLh1w+67rni1ipcSDAr/gPtV2Lt9skyrDqiJrEeOg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ics5MmndpIwnwPzKQZiirv4Z0rQ5DsKeULBKMnlk4DFz/X4ksG8kyPex9EW5PtFUPf7IOtANWvKevc/auMi4/lQppUBJwWdm2CcyTlkSVHMgsLQjzmH7nHVmShQpRk97Nqgbn3o1IqaoIFnrHVAXOQQblEN1PRA55JV0TMN9cfFb02FYMpz8ZA6S5DFywhbuh+LSsUohr7jgAVztUUsluv5nIyhEzCWIkQvLzQQdd22IDfkCCqL4PcCjtpVj9/GB4b77SmuCc0Q37KLQrNf4PqkjBxLw+gXrEr6Zyzd7DNGAfzP4QP75AYLaUXu0tpgoClkEbMkp+5pKgLH3rwDmq9mOS17vvALBM6aMBOQSfjc+i9+h7ADqVe1I1DKdDrn8UEflwWgPhCmRRFKAkhyjW5wGkf0rJ4UULM2Q62rvx5DPHYunBUNJujiBXEBt3h9oqXrrKNkoPfFSv6O1IJZvy+4cvXKbhhII+EMdAYybEy/NW4b6whSmskOmpfb4SS1MWb3p7bTeWqhAWOt44hEl/YGiSe0cF/g3kU4h+EIu7UhlEHvO1X6hDpQiS2TmcOciRLWf72JqxGcvbYYErbuuCfpo7WyJm4ploDjalF/C4HMuKE8Z8AeHdTfvS1h6QhCsViC4T/1zbHwWk2QU3p8eQOn36yDzVm+X6xXfBkWDTkLS+ndHJZDq8AP7Iq66eNneM3VwN4A9aiygfK4ZG/aP4ZUBgP52wAr8ZY2wWall8UA256BXJawqV5aY2FgtOhySz3gKqhh5JmZiNy2kUoan2i7v4zB3gY3CZ4PSW9Tiytz/BHppU5m2YbYbHKLEREfXl0lI/hYLTpexWAJweXNDkQooJRtOShcO7/+ZdtHmbwx9DKe0bWwOb2w8l12PZfhcNdKeZ/d+LTc4N8luBqbDyJqqmE+fgmWXHNFDHOJ5uTzufmlMGKcEE6+UawKnlZJ2mbVbJI1ABin1cbxHj/YuJaPApa0ln5OsMBRg3kBcsls= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b0de3a9-11cb-4d2b-ea31-08dad6de645c X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB6798.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 16:33:08.3116 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3jebo8q5r+1vTGHZIDr9cRTWJZHpNJCtsF+hPETuEBYH6QNwwOcpECmsXmOdqQA7z3tHckr6yJiGk/RgiWb4kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5721 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050138 X-Proofpoint-ORIG-GUID: POZJEwmWLamAmJDwRH2CSvf4nERC9JKn X-Proofpoint-GUID: POZJEwmWLamAmJDwRH2CSvf4nERC9JKn Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org This is only very partial: it adds support to 'perf kallsyms', allowing you to say, e.g. % ./perf kallsyms __scsi_device_lookup __scsi_device_lookup: scsi_mod (built-in) 0xffffffff9b901de0-0xffffffff9b901e30 (0xffffffff9b901de0-0xffffffff9b901e30) and get told that this is in a built-in module. We also handle symbols that are in multiple modules at once: % ./perf kallsyms lio_set_fecparam lio_set_fecparam: liquidio, liquidio_vf (built-in) 0xffffffff9b934da0-0xffffffff9b934e10 (0xffffffff9b934da0-0xffffffff9b934e10) We do this the simplistic way, by augmenting symbols with a module array field, the members of which are atoms in a new machine.modules red-black tree (structured the same, and managed with the same code, as the existing transient tree that is used to compare /proc/modules against each other). kallsyms symbols no longer carry a [module name] around with them that needs cutting off whenever it's used (all users that relied on this adjusted, I hope) but instead have that name hived off into the per-symbol module array, with a new 'built_in' field to tell users whether this is a built-in module or not. Since we cannot use the presence of '[' to detect modules any more, we do it at kallmodsyms read time by spotting _end and considering it to denote the end of the core kernel and the start of the modular range. (I *think* this works on all arches.) Full perf support probably requires syntactic additions to let you specify (and show) translation unit names to disambiguate symbols as needed. I'd implement this but I'm not sure what syntax people would prefer... whatever the syntax is should probably be shared with ftrace and friends as well, and maybe even the kernel oops backtrace printer. Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- Notes: v10: Mention in the commit log the need for syntactic enhancements to fully use kallmodsyms to disambiguate symbols. tools/perf/builtin-kallsyms.c | 35 +++++- tools/perf/util/event.c | 14 ++- tools/perf/util/machine.c | 6 +- tools/perf/util/machine.h | 1 + tools/perf/util/symbol.c | 207 +++++++++++++++++++++++++--------- tools/perf/util/symbol.h | 12 +- 6 files changed, 211 insertions(+), 64 deletions(-) diff --git a/tools/perf/builtin-kallsyms.c b/tools/perf/builtin-kallsyms.c index c08ee81529e8..6bcec2522d2d 100644 --- a/tools/perf/builtin-kallsyms.c +++ b/tools/perf/builtin-kallsyms.c @@ -35,10 +35,37 @@ static int __cmd_kallsyms(int argc, const char **argv) continue; } - printf("%s: %s %s %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n", - symbol->name, map->dso->short_name, map->dso->long_name, - map->unmap_ip(map, symbol->start), map->unmap_ip(map, symbol->end), - symbol->start, symbol->end); + if (!symbol->modules) { + printf("%s: %s %s %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n", + symbol->name, map->dso->short_name, map->dso->long_name, + map->unmap_ip(map, symbol->start), map->unmap_ip(map, symbol->end), + symbol->start, symbol->end); + } else { + if (!symbol->built_in) + printf("%s: %s %s %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n", + symbol->name, map->dso->short_name, map->dso->long_name, + map->unmap_ip(map, symbol->start), map->unmap_ip(map, symbol->end), + symbol->start, symbol->end); + else if (symbol->modules[1] == 0) + printf("%s: %s (built-in) %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n", + symbol->name, symbol->modules[0], map->unmap_ip(map, symbol->start), + map->unmap_ip(map, symbol->end), symbol->start, symbol->end); + else { /* Symbol in multiple modules at once */ + char **mod; + + printf("%s: ", symbol->name); + + for (mod = symbol->modules; *mod; mod++) { + if (mod != symbol->modules) + printf(", "); + printf("%s", *mod); + } + + printf (" (built-in) %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n", + map->unmap_ip(map, symbol->start), map->unmap_ip(map, symbol->end), + symbol->start, symbol->end); + } + } } machine__delete(machine); diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1fa14598b916..a344b35f7e38 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -97,16 +97,28 @@ static int find_symbol_cb(void *arg, const char *name, char type, u64 start) { struct process_symbol_args *args = arg; + char *chop, *tmp_alloc = NULL; + const char *tmp = name; + + if ((chop = strchr(name, '\t')) != NULL) { + tmp_alloc = strndup(name, name - chop); + if (tmp_alloc == NULL) + return -ENOMEM; + tmp = tmp_alloc; + } /* * Must be a function or at least an alias, as in PARISC64, where "_text" is * an 'A' to the same address as "_stext". */ if (!(kallsyms__is_function(type) || - type == 'A') || strcmp(name, args->name)) + type == 'A') || strcmp(tmp, args->name)) { + free(tmp_alloc); return 0; + } args->start = start; + free(tmp_alloc); return 1; } diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 76316e459c3d..2be5a3c1a267 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -173,7 +173,7 @@ struct machine *machine__new_kallsyms(void) * ask for not using the kcore parsing code, once this one is fixed * to create a map per module. */ - if (machine && machine__load_kallsyms(machine, "/proc/kallsyms") <= 0) { + if (machine && machine__load_kallsyms(machine, "/proc/kallmodsyms") <= 0) { machine__delete(machine); machine = NULL; } @@ -237,6 +237,7 @@ void machine__exit(struct machine *machine) zfree(&machine->mmap_name); zfree(&machine->current_tid); zfree(&machine->kallsyms_filename); + modules__delete_modules(&machine->modules); for (i = 0; i < THREADS__TABLE_SIZE; i++) { struct threads *threads = &machine->threads[i]; @@ -1410,7 +1411,8 @@ int machines__create_kernel_maps(struct machines *machines, pid_t pid) int machine__load_kallsyms(struct machine *machine, const char *filename) { struct map *map = machine__kernel_map(machine); - int ret = __dso__load_kallsyms(map->dso, filename, map, true); + int ret = __dso__load_kallsyms(map->dso, filename, map, &machine->modules, + true); if (ret > 0) { dso__set_loaded(map->dso); diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 74935dfaa937..393063840cd1 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -55,6 +55,7 @@ struct machine { struct dsos dsos; struct maps *kmaps; struct map *vmlinux_map; + struct rb_root modules; u64 kernel_start; pid_t *current_tid; size_t current_tid_sz; diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index a3a165ae933a..aab7ffdd0573 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -41,10 +41,16 @@ #include #include -static int dso__load_kernel_sym(struct dso *dso, struct map *map); +static int dso__load_kernel_sym(struct dso *dso, struct map *map, + struct rb_root *modules); static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map); static bool symbol__is_idle(const char *name); +static int read_proc_modules(const char *filename, struct rb_root *modules); +static struct module_info *find_module(const char *name, + struct rb_root *modules); +static void add_module(struct module_info *mi, struct rb_root *modules); + int vmlinux_path__nr_entries; char **vmlinux_path; @@ -85,6 +91,12 @@ static enum dso_binary_type binary_type_symtab[] = { #define DSO_BINARY_TYPE__SYMTAB_CNT ARRAY_SIZE(binary_type_symtab) +struct module_info { + struct rb_node rb_node; + char *name; + u64 start; +}; + static bool symbol_type__filter(char symbol_type) { symbol_type = toupper(symbol_type); @@ -234,15 +246,10 @@ void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms) * kernel text segment and beginning of first module's text * segment is very big. Therefore do not fill this gap and do * not assign it to the kernel dso map (kallsyms). - * - * In kallsyms, it determines module symbols using '[' character - * like in: - * ffffffffc1937000 T hdmi_driver_init [snd_hda_codec_hdmi] */ if (prev->end == prev->start) { /* Last kernel/module symbol mapped to end of page */ - if (is_kallsyms && (!strchr(prev->name, '[') != - !strchr(curr->name, '['))) + if (is_kallsyms && prev->built_in != curr->built_in) prev->end = roundup(prev->end + 4096, 4096); else prev->end = curr->start; @@ -301,6 +308,8 @@ struct symbol *symbol__new(u64 start, u64 len, u8 binding, u8 type, const char * sym->type = type; sym->binding = binding; sym->namelen = namelen - 1; + sym->modules = NULL; + sym->built_in = 0; pr_debug4("%s: %s %#" PRIx64 "-%#" PRIx64 "\n", __func__, name, start, sym->end); @@ -318,6 +327,7 @@ void symbol__delete(struct symbol *sym) annotation__exit(notes); } } + free(sym->modules); free(((void *)sym) - symbol_conf.priv_size); } @@ -716,12 +726,37 @@ static bool symbol__is_idle(const char *name) return strlist__has_entry(idle_symbols_list, name); } -static int map__process_kallsym_symbol(void *arg, const char *name, +struct process_kallsym_symbol_arg { + struct dso *dso; + struct rb_root *modules; + int seen_end; +}; + +static int map__process_kallsym_symbol(void *arg_, const char *name, char type, u64 start) { struct symbol *sym; - struct dso *dso = arg; + struct process_kallsym_symbol_arg *arg = arg_; + struct dso *dso = arg->dso; struct rb_root_cached *root = &dso->symbols; + struct rb_root *modules = arg->modules; + char *module; + const char *modulep; + int counting = 1; + size_t nmods = 0; + char **mods = NULL; + char **modp = NULL; + + /* + * Split off the modules part. + */ + if ((module = strchr(name, '\t')) != NULL) { + *module = 0; + module++; + } + + if (strcmp(name, "_end") == 0) + arg->seen_end = 1; if (!symbol_type__filter(type)) return 0; @@ -731,18 +766,88 @@ static int map__process_kallsym_symbol(void *arg, const char *name, return 0; /* - * module symbols are not sorted so we add all - * symbols, setting length to 0, and rely on - * symbols__fixup_end() to fix it up. + * non-builtin module symbols are not sorted so we add all symbols, + * setting length to 0, and rely on symbols__fixup_end() to fix it up. */ sym = symbol__new(start, 0, kallsyms2elf_binding(type), kallsyms2elf_type(type), name); if (sym == NULL) return -ENOMEM; + + sym->built_in = !arg->seen_end; + + /* + * Pass over the modules list twice: once to count the number of + * modules this symbol is part of and allocate an array to store their + * names, then again to fill it out. + * + * Arguably inefficient, due to one allocation per built-in symbol, even + * though many symbols will have the same mods array. In practice, + * it's just too small a waste to matter. The module names are pointers + * into the machine->modules rb-tree (lazily populated here). + */ + +fill: + modulep = module; + while (modulep && (modulep = strchr(modulep, '[')) != NULL) { + struct module_info *mi; + const char *end_bra = strchr(modulep, ']'); + + modulep++; + if (end_bra == NULL || end_bra <= modulep) + continue; + + if (counting) { + nmods++; + continue; + } + + /* + * Fill-out phase. + */ + + *modp = strndup(modulep, end_bra - modulep); + if (*modp == NULL) { + free(mods); + return -ENOMEM; + } + + mi = find_module(*modp, modules); + if (!mi) { + mi = zalloc(sizeof(struct module_info)); + + if (!mi) { + free (mods); + free (*modp); + return -ENOMEM; + } + mi->name = *modp; + } + else { + free(*modp); + *modp = mi->name; + } + + modp++; + } + + if (counting && nmods > 0) { + mods = calloc(nmods + 1, sizeof (char *)); + if (mods == NULL) + return -ENOMEM; + modp = mods; + + counting = 0; + goto fill; + } + + sym->modules = mods; + /* * We will pass the symbols to the filter later, in - * map__split_kallsyms, when we have split the maps per module + * map__split_kallsyms, when we have split the maps per + * (non-built-in) module */ - __symbols__insert(root, sym, !strchr(name, '[')); + __symbols__insert(root, sym, !arg->seen_end); return 0; } @@ -752,9 +857,11 @@ static int map__process_kallsym_symbol(void *arg, const char *name, * so that we can in the next step set the symbol ->end address and then * call kernel_maps__split_kallsyms. */ -static int dso__load_all_kallsyms(struct dso *dso, const char *filename) +static int dso__load_all_kallsyms(struct dso *dso, const char *filename, + struct rb_root *modules) { - return kallsyms__parse(filename, dso, map__process_kallsym_symbol); + struct process_kallsym_symbol_arg arg = {dso, modules, 0}; + return kallsyms__parse(filename, &arg, map__process_kallsym_symbol); } static int maps__split_kallsyms_for_kcore(struct maps *kmaps, struct dso *dso) @@ -766,22 +873,14 @@ static int maps__split_kallsyms_for_kcore(struct maps *kmaps, struct dso *dso) struct rb_root_cached *root = &dso->symbols; struct rb_node *next = rb_first_cached(root); - if (!kmaps) - return -1; - *root = RB_ROOT_CACHED; while (next) { - char *module; - pos = rb_entry(next, struct symbol, rb_node); next = rb_next(&pos->rb_node); rb_erase_cached(&pos->rb_node, &old_root); RB_CLEAR_NODE(&pos->rb_node); - module = strchr(pos->name, '\t'); - if (module) - *module = '\0'; curr_map = maps__find(kmaps, pos->start); @@ -830,19 +929,19 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta, x86_64 = machine__is(machine, "x86_64"); while (next) { - char *module; - pos = rb_entry(next, struct symbol, rb_node); next = rb_next(&pos->rb_node); - module = strchr(pos->name, '\t'); - if (module) { + if (!pos->built_in && pos->modules) { if (!symbol_conf.use_modules) goto discard_symbol; - *module++ = '\0'; - - if (strcmp(curr_map->dso->short_name, module)) { + /* + * Non-built-in symbols can only be in one module at + * once. + */ + assert(pos->modules[1] == NULL); + if (strcmp(curr_map->dso->short_name, pos->modules[0])) { if (curr_map != initial_map && dso->kernel == DSO_SPACE__KERNEL_GUEST && machine__is_default_guest(machine)) { @@ -856,12 +955,12 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta, dso__set_loaded(curr_map->dso); } - curr_map = maps__find_by_name(kmaps, module); + curr_map = maps__find_by_name(kmaps, pos->modules[0]); if (curr_map == NULL) { pr_debug("%s/proc/{kallsyms,modules} " "inconsistency while looking " "for \"%s\" module!\n", - machine->root_dir, module); + machine->root_dir, pos->modules[0]); curr_map = initial_map; goto discard_symbol; } @@ -971,12 +1070,6 @@ bool symbol__restricted_filename(const char *filename, return restricted; } -struct module_info { - struct rb_node rb_node; - char *name; - u64 start; -}; - static void add_module(struct module_info *mi, struct rb_root *modules) { struct rb_node **p = &modules->rb_node; @@ -995,7 +1088,7 @@ static void add_module(struct module_info *mi, struct rb_root *modules) rb_insert_color(&mi->rb_node, modules); } -static void delete_modules(struct rb_root *modules) +void modules__delete_modules(struct rb_root *modules) { struct module_info *mi; struct rb_node *next = rb_first(modules); @@ -1060,7 +1153,7 @@ static int read_proc_modules(const char *filename, struct rb_root *modules) return -1; if (modules__parse(filename, modules, __read_proc_modules)) { - delete_modules(modules); + modules__delete_modules(modules); return -1; } @@ -1101,9 +1194,9 @@ int compare_proc_modules(const char *from, const char *to) if (!from_node && !to_node) ret = 0; - delete_modules(&to_modules); + modules__delete_modules(&to_modules); out_delete_from: - delete_modules(&from_modules); + modules__delete_modules(&from_modules); return ret; } @@ -1133,7 +1226,7 @@ static int do_validate_kcore_modules(const char *filename, struct maps *kmaps) } } out: - delete_modules(&modules); + modules__delete_modules(&modules); return err; } @@ -1467,18 +1560,20 @@ static int kallsyms__delta(struct kmap *kmap, const char *filename, u64 *delta) } int __dso__load_kallsyms(struct dso *dso, const char *filename, - struct map *map, bool no_kcore) + struct map *map, struct rb_root *modules, + bool no_kcore) { struct kmap *kmap = map__kmap(map); u64 delta = 0; - if (symbol__restricted_filename(filename, "/proc/kallsyms")) + if (symbol__restricted_filename(filename, "/proc/kallsyms") && + symbol__restricted_filename(filename, "/proc/kallmodsyms")) return -1; if (!kmap || !kmap->kmaps) return -1; - if (dso__load_all_kallsyms(dso, filename) < 0) + if (dso__load_all_kallsyms(dso, filename, modules) < 0) return -1; if (kallsyms__delta(kmap, filename, &delta)) @@ -1499,9 +1594,9 @@ int __dso__load_kallsyms(struct dso *dso, const char *filename, } int dso__load_kallsyms(struct dso *dso, const char *filename, - struct map *map) + struct map *map, struct rb_root *modules) { - return __dso__load_kallsyms(dso, filename, map, false); + return __dso__load_kallsyms(dso, filename, map, modules, false); } static int dso__load_perf_map(const char *map_path, struct dso *dso) @@ -1814,12 +1909,13 @@ int dso__load(struct dso *dso, struct map *map) dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP; if (dso->kernel && !kmod) { + machine = map__kmaps(map)->machine; + if (dso->kernel == DSO_SPACE__KERNEL) - ret = dso__load_kernel_sym(dso, map); + ret = dso__load_kernel_sym(dso, map, &machine->modules); else if (dso->kernel == DSO_SPACE__KERNEL_GUEST) ret = dso__load_guest_kernel_sym(dso, map); - machine = map__kmaps(map)->machine; if (machine__is(machine, "x86_64")) machine__map_x86_64_entry_trampolines(machine, dso); goto out; @@ -2220,7 +2316,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) return strdup(path); } -static int dso__load_kernel_sym(struct dso *dso, struct map *map) +static int dso__load_kernel_sym(struct dso *dso, struct map *map, + struct rb_root *modules) { int err; const char *kallsyms_filename = NULL; @@ -2282,7 +2379,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map) kallsyms_filename = kallsyms_allocated_filename; do_kallsyms: - err = dso__load_kallsyms(dso, kallsyms_filename, map); + err = dso__load_kallsyms(dso, kallsyms_filename, map, modules); if (err > 0) pr_debug("Using %s for symbols\n", kallsyms_filename); free(kallsyms_allocated_filename); @@ -2323,11 +2420,11 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map) if (!kallsyms_filename) return -1; } else { - sprintf(path, "%s/proc/kallsyms", machine->root_dir); + sprintf(path, "%s/proc/kallmodsyms", machine->root_dir); kallsyms_filename = path; } - err = dso__load_kallsyms(dso, kallsyms_filename, map); + err = dso__load_kallsyms(dso, kallsyms_filename, map, &machine->modules); if (err > 0) pr_debug("Using %s for symbols\n", kallsyms_filename); if (err > 0 && !dso__is_kcore(dso)) { diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 0b893dcc8ea6..9ca218e09acf 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -66,6 +66,11 @@ struct symbol { u8 annotate2:1; /** Architecture specific. Unused except on PPC where it holds st_other. */ u8 arch_sym; + /** Null-terminated array of pointers to names of containing modules in the + modules red-black tree. May be NULL for none. */ + char **modules; + /** Set if this symbol is built in to the core kernel. */ + int built_in; /** The name of length namelen associated with the symbol. */ char name[]; }; @@ -137,8 +142,9 @@ int dso__load_vmlinux(struct dso *dso, struct map *map, const char *vmlinux, bool vmlinux_allocated); int dso__load_vmlinux_path(struct dso *dso, struct map *map); int __dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map, - bool no_kcore); -int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map); + struct rb_root *modules, bool no_kcore); +int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map, + struct rb_root *modules); void dso__insert_symbol(struct dso *dso, struct symbol *sym); @@ -161,6 +167,8 @@ int sysfs__read_build_id(const char *filename, struct build_id *bid); int modules__parse(const char *filename, void *arg, int (*process_module)(void *arg, const char *name, u64 start, u64 size)); +void modules__delete_modules(struct rb_root *modules); + int filename__read_debuglink(const char *filename, char *debuglink, size_t size);