From patchwork Thu Apr 6 19:00:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203853 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 3D216C77B6C for ; Thu, 6 Apr 2023 19:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240349AbjDFTBE (ORCPT ); Thu, 6 Apr 2023 15:01:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240067AbjDFTBD (ORCPT ); Thu, 6 Apr 2023 15:01:03 -0400 Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F23134C01 for ; Thu, 6 Apr 2023 12:00:59 -0700 (PDT) Received: by mail-io1-xd4a.google.com with SMTP id b2-20020a6bcb02000000b0075e09ef5a2eso10771265iog.13 for ; Thu, 06 Apr 2023 12:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807659; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eGQLnr57manA7/d3sSj7CWvU90h1ejgPAAwZbA4W80Y=; b=E1XOP1CaY8koFy3ME6her9rJ9Nke8XHAoAVsqLpY3lPsNoEYGcrpUF5PF5gHdN47bK NGSiShp2xcYg0DXa0KIabY1O37FSpfutYwWTjtRVrU9oHpeB9FGTYAd99a4F1/6Y8FZn AbnD5SAV+TZ0GjZP3RdKVI6rqFp6OB//JibKTs1ZBw4TBgjK4lD7u+6bQxjHMtj/gsBd BKNR9Uz/lHv1iRy4b6qhPk1HwfMVdk/ucdXhOaul/MyfX6WSdjJGRwtYds3NlIxOeBAy hYI94iBkFDpAsYZMS2B43djCX50lmE22kkHDNV9FYiOmAE1uw+MDpJDDPPsBmoU8NICk 6/qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807659; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eGQLnr57manA7/d3sSj7CWvU90h1ejgPAAwZbA4W80Y=; b=MozvE1aIrEoslUzPnVNNo8cz7wYyeOondfdsFYzFrs+to2iFGhQrmNREz6Vxue7hSC xNpIh8wMGyqihxE2qfHkDmbHuvklFmamKLxSHAeuWGdwI3DUtCpJjrv0Pb6Da8oFHFJ3 rERZ9NviHRER4aPraUlBEz8pW1TrKMyAUWobFU6pukjx0ovd7fHzW/Qg+GBgfHqRV994 JcvNdT3UeAY1ZdhU4WYRy1V3RN4gNv9MEd88faoRo/fPJ5Bzqv7hdXaoe8oimwlyEAGh syu9ROXRPNhD+4g8129wHIq5ECk50XFW4pwdo4HmF5YUnzMw/dBZWAjsCiodN0s2X0c1 eCiQ== X-Gm-Message-State: AAQBX9dKpPTkvRb6dyzCzjy8qaBmuCE6jE9KuJmIK/Mu+f0fJS53iSwc G7E96R0W186vWE4GEEvWFmTWZcFwO1XEKEr3OMQeTLcIUrpdfjSU4Yi1e8bhLLPlcMv28biNLW1 hRKcJq9KMKBVVuuJ3R719MjK2gfUiBqn7ShMvwJJP/jgWWS8V80V5CHE41hDNraCHOIIlY6T3ni jP3r8= X-Google-Smtp-Source: AKy350bXUyOdQnwpKnTh5pwn2Z58BJIiX3qb6NKTnyLlDlV/PWR/2NVrpWvh92/1KkRXzxoRshzXEZc+XwdEVcY= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a92:1a49:0:b0:315:8f6c:50a6 with SMTP id z9-20020a921a49000000b003158f6c50a6mr6481064ill.1.1680807658940; Thu, 06 Apr 2023 12:00:58 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:20 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-2-allenwebb@google.com> Subject: [PATCH v10 01/11] rockchip-mailbox: Remove unneeded MODULE_DEVICE_TABLE From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb , kernel test robot Precedence: bulk List-ID: A one character difference in the name supplied to MODULE_DEVICE_TABLE breaks compilation for ROCKCHIP_MBOX after built-in modules can generate match-id based module aliases. Since this wasn't being used before and builtin aliases aren't needed in this case, remove it. This was not caught earlier because ROCKCHIP_MBOX can not be built as a module and MODULE_DEVICE_TABLE is a no-op for built-in modules. Fixes: f70ed3b5dc8b ("mailbox: rockchip: Add Rockchip mailbox driver") Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202212171140.NB93eVvI-lkp@intel.com/ Signed-off-by: Allen Webb --- drivers/mailbox/rockchip-mailbox.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/mailbox/rockchip-mailbox.c b/drivers/mailbox/rockchip-mailbox.c index e02d3c9e3693..1f0adc283d1b 100644 --- a/drivers/mailbox/rockchip-mailbox.c +++ b/drivers/mailbox/rockchip-mailbox.c @@ -159,7 +159,6 @@ static const struct of_device_id rockchip_mbox_of_match[] = { { .compatible = "rockchip,rk3368-mailbox", .data = &rk3368_drv_data}, { }, }; -MODULE_DEVICE_TABLE(of, rockchp_mbox_of_match); static int rockchip_mbox_probe(struct platform_device *pdev) { From patchwork Thu Apr 6 19:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203855 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 9EA9CC76196 for ; Thu, 6 Apr 2023 19:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240067AbjDFTBK (ORCPT ); Thu, 6 Apr 2023 15:01:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240347AbjDFTBE (ORCPT ); Thu, 6 Apr 2023 15:01:04 -0400 Received: from mail-io1-xd49.google.com (mail-io1-xd49.google.com [IPv6:2607:f8b0:4864:20::d49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2F2C901C for ; Thu, 6 Apr 2023 12:01:00 -0700 (PDT) Received: by mail-io1-xd49.google.com with SMTP id i4-20020a6b5404000000b0075ff3fb6f4cso9375416iob.9 for ; Thu, 06 Apr 2023 12:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807660; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=caRdwk2BRQJWlUMku9R1oT1hxRVhqY9kuoHjJ2qZO3g=; b=HuY+LMV/FW4ZqSzq5yDbeAtOqVe3PbLdJaq++8RHO6OXQDsm/6mnCfRNuEDUX8rnRu LzHICsVuWjfcys0wQIe0hSf7kC/k2Q2GLP+lbAa6rW9vGYZR1HC/9X2OIbnSqopcgcxt szfP1syYaS19WUCtCMVmcvO8vcOvnj9DsAgZrsa/BOqVnoK0R4N+YrJcQ9GxnGtju1v9 N/ddst62vdTXCMn+ZIAe+MCGUwB66nGomYBEICkYLFdOJbLsEApYyZT+t++qABtYxv7s 0GjANLTFns1opniPJvRxtcQsblzPbgiZg6IX8kdW0O3MVkxywZ0q8kLKSL2Y1/RyfVun PKOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807660; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=caRdwk2BRQJWlUMku9R1oT1hxRVhqY9kuoHjJ2qZO3g=; b=ZRVG6VFRZ/SBevXvLoKLj8PBR/06650H8idgDd2l+n6wtehCgiZ3YApZFtvIey8ipc ec56HjEork2Sye8oLXBOfA5rDJlzsIyidK46Mrau1KN81ypmx7awwJ507BRtkJvouL3A ZxkxH17f/382yBd+xPhFsYJMh2UKRtxDqPnSeWCWbVWCRQVcHAY3rAQfigqzQTbmcY7v DdjjXHJcj7fr0wG6jqd47Tx7YcvnCseRO2Vas59oF1b7dJl8I4Gzsd8R9Fk5o/xVg3GM YfxVPUHgry11Cl1T4AIDRL2WhRVX3cCTOD49+XIS5cYWKKr2ly/2J4Kg/M/l/4juSG7g /ftw== X-Gm-Message-State: AAQBX9cbQ2/OFcZ0z8Sw/9/ILuQH5XsT0AW2BmUY/CKWE1xB3zUCSdQP zsNywqtDZgZGycZL5F8DQRKOdsaRDEbIBHueFlSsVBCCRpV8GLWEXFrgLVDXE5LwFq6NgcTRaA6 Gci2feIltr8/2ViPnZM+qnK6lgzWoz/ZV/yTaUyVPgW7oPapN/fWe6KI7dSXsO2cKv448DEoywB kkgTs= X-Google-Smtp-Source: AKy350YZuifQDcAImF7FIJpdSl4uI0utqVn+lwF5XQxv4tsCuonBlHCBbuxU7Zq6L46KIXeGCiA3IUpgdFEzMO8= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:b181:0:b0:3c5:14ca:58c6 with SMTP id t1-20020a02b181000000b003c514ca58c6mr6033175jah.4.1680807659752; Thu, 06 Apr 2023 12:00:59 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:21 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-3-allenwebb@google.com> Subject: [PATCH v10 02/11] scsi/BusLogic: Always include device id table From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb , kernel test robot Precedence: bulk List-ID: A future patch makes use of the device table for built-in modules, so do not ifdef out the match id table. Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202212171257.0oLypyYS-lkp@intel.com/ Signed-off-by: Allen Webb --- drivers/scsi/BusLogic.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index f7b7ffda1161..79fc8a24e614 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -3713,7 +3713,6 @@ static void __exit blogic_exit(void) __setup("BusLogic=", blogic_setup); -#ifdef MODULE /*static struct pci_device_id blogic_pci_tbl[] = { { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, @@ -3729,7 +3728,6 @@ static const struct pci_device_id blogic_pci_tbl[] = { {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)}, {0, }, }; -#endif MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); module_init(blogic_init); From patchwork Thu Apr 6 19:00:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203854 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 33D6FC7618D for ; Thu, 6 Apr 2023 19:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240184AbjDFTBJ (ORCPT ); Thu, 6 Apr 2023 15:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240067AbjDFTBF (ORCPT ); Thu, 6 Apr 2023 15:01:05 -0400 Received: from mail-il1-x149.google.com (mail-il1-x149.google.com [IPv6:2607:f8b0:4864:20::149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA89F93D3 for ; Thu, 6 Apr 2023 12:01:01 -0700 (PDT) Received: by mail-il1-x149.google.com with SMTP id d5-20020a923605000000b003232594207dso26428275ila.8 for ; Thu, 06 Apr 2023 12:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807661; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CIaNzDoEfkQUCUs5a1+ah5UqZ1hq5cACYGIKF90PLWA=; b=G+FTw3D1oOQIjnAKB1cpn9CiPMPKCCFM4zdri/XtQJGkhM8ftL306NfOcRuhgBJwAT +mqD0LOE5YJzkUY6ePsFoGVjZiuuVZ9E2USexjk/EUU97k0/6RzsAAanDkVOThd1NSb/ UHy8zFuNtffS3eWlDckeeAT9oCY7xDJSH2ttDYfw5Ys4YqfON7UCSPfniEHkJXIicK5X pym1+Tk0FtNI+3SFj6R7I0VHLqY1yU3s7SCpVrnruhY/CbD+oW8s5P5fV208J/K1wmOr VQqc6oZ6PtBD6O5hhHqZblnYB84HAIivUECRQzO7E8yY+rSsgFhBq+ttRv64b/8RpqGV 7E3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807661; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CIaNzDoEfkQUCUs5a1+ah5UqZ1hq5cACYGIKF90PLWA=; b=pUDrNGfmu7SJdNiiJkNbVQ3WsENkIxDMeq1JFwVPNAlBbmXpsAkQZ3fK5RqS5mmVmt x2OBs5VS3tSD5n+r1r3+O0tRPk0+n1rSx6WHwODLQEPwBWZBAR6hFlrhb+2bpZ5rgwx4 Y8cOiPstDAuxSnHrtJt2snPU2VThwkCDpKIt3E70dbYg3lBQ7fZCxKbR1ORmJZlZqs3A zyAGGEAoGzKMdLHYyx9LARBkB4WdrmTNcCJnislyegddO3NT7RsnfQuKM43eGRytFVDw NBvl5BNGVLCpQ/a4VrhhAzlrbVlwrHZNELkPWj9/b3VvEmA+QmhbwRAZ11sgbe0FcSnP WVHg== X-Gm-Message-State: AAQBX9ftYJAjeg6pm0DBjsDrspVCmC/Iy8rmptvBAwO0zDiYYXBgwKql MrLXHBVi1s8oma1zlKXBjHXDKsM77kDM+L4lAOfzAgMZ2+M5zvAqXamgz0kNHptk2j5Ai8ACU9J OzkfXqfFac83/cuuq/zb9ep2bsYnCAzQIcgFCBY5UjaUTQ0eV0glzt8usfVJJHJV6F8kCXc+zu6 qwJ2M= X-Google-Smtp-Source: AKy350Z+5g/pbGkfqFeQV7zALWCzNXPo9m7bN766vJbNtaAOGFM9jzMpqoRBx0ByEqTie31Zw2uJvsgSxEzqmLQ= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:a10c:0:b0:405:8be:eaaa with SMTP id f12-20020a02a10c000000b0040508beeaaamr6056313jag.5.1680807660861; Thu, 06 Apr 2023 12:01:00 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:22 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-4-allenwebb@google.com> Subject: [PATCH v10 03/11] stmpe-spi: Fix MODULE_DEVICE_TABLE entries From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb , kernel test robot Precedence: bulk List-ID: A one character difference in the name supplied to MODULE_DEVICE_TABLE breaks compilation for STMPE_SPI after built-in modules can generate match-id based module aliases. Since this wasn't being used before and builtin aliases aren't needed in this case, remove it. This was not caught earlier because STMPE_SPI can not be built as a module and MODULE_DEVICE_TABLE is a no-op for built-in modules. Fixes: e789995d5c61 ("mfd: Add support for STMPE SPI interface") Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202212171140.NB93eVvI-lkp@intel.com/ Signed-off-by: Allen Webb --- drivers/mfd/stmpe-spi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c index e9cbf33502b3..e9cb6a635472 100644 --- a/drivers/mfd/stmpe-spi.c +++ b/drivers/mfd/stmpe-spi.c @@ -129,7 +129,6 @@ static const struct spi_device_id stmpe_spi_id[] = { { "stmpe2403", STMPE2403 }, { } }; -MODULE_DEVICE_TABLE(spi, stmpe_id); static struct spi_driver stmpe_spi_driver = { .driver = { From patchwork Thu Apr 6 19:00:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203856 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 0B8D7C77B6F for ; Thu, 6 Apr 2023 19:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239846AbjDFTBL (ORCPT ); Thu, 6 Apr 2023 15:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240363AbjDFTBH (ORCPT ); Thu, 6 Apr 2023 15:01:07 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E242186AD for ; Thu, 6 Apr 2023 12:01:02 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id d5-20020a923605000000b003232594207dso26428331ila.8 for ; Thu, 06 Apr 2023 12:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807662; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lY1ByN87FMvQLmIB6FmZa+RzwBjVh5nyLSYhKEEms/o=; b=TXJhoFceFs9wdYTRZd708YmwDXv6ZmJEZM5qsCVnFNFux6VSIy2sN485OdoLj6gH/u AQsSA/pqWjyYGM48tvaIncpfU2OLAUpCMQfGEUljMQY32VJVtir3KfI0/oLx5XXuijgt IdQDFo/dXt9qgNaakCRBJpEPF2lgHkdbMkFeyywUgZbfu/OiLuvJ3B+dRHj3/Osu3wFs Igv3FoQJ+xdCyHBUlOkjbozloyiEts0oRkMIvsUAEiq5xM+8ae/xA8FEMfg2w3bV7nHX XXgsLfahva+s2fFRR2U9HW32kdVcssWxj7eIV8JYkxojb7lCllY002RCrgMUSAo+vdRi BYJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807662; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lY1ByN87FMvQLmIB6FmZa+RzwBjVh5nyLSYhKEEms/o=; b=7DRY92zs0KcGx1dOUnjcG6BUZc2ZsDPOBesZ5iCfVk/E4tjYsrjTc0YPbWmNKTj4az 4awV3ocsawPItS4juY7JaN4YNRBzRTAZNTq3mzs7MepqN+oVhZKeqFewgG2f3L91mQ6K NZFV0tyI4G6/ZEgLw4eSa4cmL/EWoss08FrrAvlJZkQkiE5ITE3Y/fBx0Z4AylOTHha2 RFzNsiTGJkmaSfXaBmevr6H6t1yOD6gxTerPmtjVmacgSTvVTbePZOtp2VKcyYyUP9jv pmOvWbS4NxUot5QUgwT93w3wScOPODYW3jYKu1ucjLMGGObbhdKollToOxXzM65cAUko yxaw== X-Gm-Message-State: AAQBX9ewD6w9AR2G8mXt3rDh1E2l8XTHw8WXADPrjco08dmpaUv6Y8Nz 6GkthWyrXyVvXdriHz1ZPTM1cuy0biklTh9DHTZeWcwYcJq+q5tcyK3+NeoLIPTddNwJBaRlQch V9UdZqgKRIXPXRJ59slRxES+eWPQcHIJhhf3VR8ApMnLnhSViczVcSZZ689Ddsz3Cj103lqU+j9 oZOng= X-Google-Smtp-Source: AKy350Y53lWgT3pwwk/QGvquIa8pju0CYYGVAfASYtJqDKWDb552KXeL4N024JqlQO8Qz0mCpt8UDRDqw6NUjSI= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:8503:0:b0:3a9:75c9:da25 with SMTP id g3-20020a028503000000b003a975c9da25mr5548851jai.1.1680807662053; Thu, 06 Apr 2023 12:01:02 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:23 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-5-allenwebb@google.com> Subject: [PATCH v10 04/11] module.h: MODULE_DEVICE_TABLE for built-in modules From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: Implement MODULE_DEVICE_TABLE for build-in modules to make it possible to generate a builtin.alias file to complement modules.alias. Signed-off-by: Allen Webb --- include/linux/module.h | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 4435ad9439ab..b1cb12e06996 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -237,14 +237,36 @@ extern void cleanup_module(void); /* What your module does. */ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) -#ifdef MODULE -/* Creates an alias so file2alias.c can find device table. */ +/* + * Creates an alias so file2alias.c can find device table. + * + * Use this in cases where a device table is used to match devices because it + * surfaces match-id based module aliases to userspace for: + * - Automatic module loading through modules.alias. + * - Tools like USBGuard which block devices based on policy such as which + * modules match a device. + * + * The only use-case for built-in drivers today is to enable userspace to + * prevent / allow probe for devices on certain subsystems even if the driver is + * already loaded. An example is the USB subsystem with its authorized_default + * sysfs attribute. For more details refer to the kernel's Documentation for USB + * about authorized_default. + * + * The module name is included in the alias for two reasons: + * - It avoids creating two aliases with the same name for built-in modules. + * Historically MODULE_DEVICE_TABLE was a no-op for built-in modules, so + * there was nothing to stop different modules from having the same device + * table name and consequently the same alias when building as a module. + * - The module name is needed by files2alias.c to associate a particular + * device table with its associated module for built-in modules since + * files2alias would otherwise see the module name as `vmlinuz.o`. + */ #define MODULE_DEVICE_TABLE(type, name) \ -extern typeof(name) __mod_##type##__##name##_device_table \ - __attribute__ ((unused, alias(__stringify(name)))) -#else /* !MODULE */ -#define MODULE_DEVICE_TABLE(type, name) -#endif +extern void *CONCATENATE( \ + CONCATENATE(__mod_##type##__##name##__, \ + __KBUILD_MODNAME), \ + _device_table) \ + __attribute__ ((unused, alias(__stringify(name)))) /* Version of form [:][-]. * Or for CVS/RCS ID version, everything but the number is stripped. From patchwork Thu Apr 6 19:00:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203857 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 A569BC77B6C for ; Thu, 6 Apr 2023 19:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240165AbjDFTBb (ORCPT ); Thu, 6 Apr 2023 15:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbjDFTBW (ORCPT ); Thu, 6 Apr 2023 15:01:22 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0439C9767 for ; Thu, 6 Apr 2023 12:01:03 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id z7-20020a921a47000000b0032600db79f7so22908056ill.18 for ; Thu, 06 Apr 2023 12:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807663; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FEZbsR+WTyUtWxubualsRcS33WiF75x8OXTLlDIM76E=; b=D81pJQDCQ+OdL291Z2IZ2aoLcZ9JSdF//vAX5266oVAnQZPAsb2ROsi95KVjKK3wKl XbpTpcSS49IV425LJMR5r61TCIqtP2EcrXEcJYbsOu8cFWo+BVrf6iH+dJ58GpAVEbGn Ob0KC9VY5azkYE4xJEOA4ueXQijtPJP+hpJhW/YwaW4aQyUwR3vMc7NqkaFbDsODU7Nw /7C7nADEmWmY3+IZXHXTYCeVpPUBnR7rp5s6E1NNNGgXR1+Bt8XYVSPcNp7Zl8/rSVHw Qsi4OfLOzlOEZEGuq+ld/NjtkVhfX4p3akpLLAcW1NwdJOuSYjjL4pHgWvhxnmu7Be9V Pzag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807663; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FEZbsR+WTyUtWxubualsRcS33WiF75x8OXTLlDIM76E=; b=FwZMZxDKy1MGp8hXz3uQPfWMHNE0jdM4lbMpFcB+eLCJC5f+hrj658xIDCdYsKJGYV FC1VKlSb8c7WDgvpLu+tjFXatT1z53y+js6XFYN4PpeKOK+SOM2fZkM1OpDYLmX2LNcy sbXfkstp8ozEx4zx9E0/5EBzwuFouDNnABPAuxjelWEhPaIrx9aT8ko2OEIbxDeumoYn +u4icLCzpo1MhVemodCxarINmWGXmaNr9MxNAMbKWJiP5ssIJDbn2kPEnMMlJFycrzZb TSat1HJu6AlAmgYt8PpjV0RNEWU/PwcsXj2qHmmFcwGhLDnEb7OfsDsLat/ENKzEf7BV KX3Q== X-Gm-Message-State: AAQBX9eKYmH/kRw5eq+GW/q2vdv5yNqh+9b1nfWbpnbGgNGFBsc14hWN bnnGnIF1GE5tj/T5OsyvOQCYKxLwKK2/PkcTx+qy2Fz2L6DP2Jyy1g0bnSVIXvREkWWgXjj8+1I SvZI92xTB1JPt7EN4CLAgXoT0TG4l9Q2JGnlQuXwd4a4zAevpJObW2EiWQX82shnxMjD12VdN97 5bBzA= X-Google-Smtp-Source: AKy350bmElFuE1Xid/gxRe2zw6r7kNsu5GgybFoCIrVluA8w6qJgsdQVeebMx1wlwhideMS0TE7hnev66x532k0= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:2a45:0:b0:406:c43f:6320 with SMTP id w66-20020a022a45000000b00406c43f6320mr4089761jaw.0.1680807662877; Thu, 06 Apr 2023 12:01:02 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:24 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-6-allenwebb@google.com> Subject: [PATCH v10 05/11] modpost: Track module name for built-in modules From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: Keep track of the module name when processing match table symbols. Signed-off-by: Allen Webb --- scripts/mod/file2alias.c | 39 +++++++++++++++++++++++++++++++++++---- scripts/mod/modpost.h | 1 + 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 91c2e7ba5e52..b392d51c3b06 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -28,6 +28,7 @@ typedef Elf64_Addr kernel_ulong_t; #include #endif +#include #include #include @@ -1540,9 +1541,9 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) { void *symval; - char *zeros = NULL; - const char *name, *identifier; - unsigned int namelen; + char *zeros = NULL, *modname_str = NULL; + const char *name, *identifier, *modname; + unsigned int namelen, modnamelen; /* We're looking for a section relative symbol */ if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) @@ -1552,7 +1553,12 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) return; - /* All our symbols are of form __mod____device_table. */ + /* + * All our symbols are either of form + * __mod____device_table + * or + * __mod_____kmod__device_table + */ if (strncmp(symname, "__mod_", strlen("__mod_"))) return; name = symname + strlen("__mod_"); @@ -1564,8 +1570,30 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, identifier = strstr(name, "__"); if (!identifier) return; + modnamelen = namelen; namelen = identifier - name; + /* + * In the vmlinuz.o case we want to handle __kmod_ so aliases from + * builtin modules are attributed correctly. + */ + modname = strstr(identifier + 2, "__kmod_"); + if (modname) { + modname += strlen("__kmod_"); + modnamelen -= (modname - name) + strlen("_device_table"); + modname_str = malloc(modnamelen + 1); + /* We don't want to continue if the allocation fails. */ + assert(modname_str); + memcpy(modname_str, modname, modnamelen); + modname_str[modnamelen] = '\0'; + } + + if (modname_str) + modname = modname_str; + else + modname = mod->name; + mod->builtin_name = modname; + /* Handle all-NULL symbols allocated into .bss */ if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { zeros = calloc(1, sym->st_size); @@ -1597,6 +1625,9 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, } } free(zeros); + mod->builtin_name = NULL; + if (modname_str) + free(modname_str); } /* Now add out buffered information to the generated C source */ diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 1178f40a73f3..34fe5fc0b02c 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -128,6 +128,7 @@ struct module { struct list_head missing_namespaces; // Actual imported namespaces struct list_head imported_namespaces; + const char *builtin_name; char name[]; }; From patchwork Thu Apr 6 19:00:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203858 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 5F64BC7618D for ; Thu, 6 Apr 2023 19:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240453AbjDFTBc (ORCPT ); Thu, 6 Apr 2023 15:01:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240389AbjDFTBX (ORCPT ); Thu, 6 Apr 2023 15:01:23 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A8922735 for ; Thu, 6 Apr 2023 12:01:04 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id q17-20020a056e020c3100b003245df8be9fso26453034ilg.14 for ; Thu, 06 Apr 2023 12:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807664; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lPtoJrKBH3N2nk7pm0WBiOte1w3zyXs+2rCz5/qKsmI=; b=X+v0xVsX9ePu+gtwgv1xggQ+b9AWSfR2kutza91lJ4sEaRsWLI9aUai/oOu71s6gex 085PISyP11GQiy5TpHe2KqUiiMys2wj6F3LZKs5fY+J3Euxw/MW+oV/FzVW5akzVCEWr Qu5KuDjMRCJLNQE2PQELcL1qsl5c3UE5cppY4EeC0WUbfohnh8Rb91QCTO2vr1Jum8eD IL/nYTUBqV+289xqR3EbtbZO4r6o2gkaZ9oSaqJyrcQ7KjYOFHXumoiW5Zkfb4k1DmEx p7lyo49HTkd6WcC1RTXvZKvH4Mp3QBWwR7HpWyThE8NkxJ8/AodWw2njEC2lbvvSLDEg XUIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807664; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lPtoJrKBH3N2nk7pm0WBiOte1w3zyXs+2rCz5/qKsmI=; b=GF5BsIHjcKiAVgBFvzv3b1XLsfMhT5H2M1QrGktdWZR374ZiP+6Ap+UpTPqHchqECr UB5hKqbPFeveMZu9+H/KLYwtkX4GdF9nlT2GWvyNOlI7R5QRKugh/inA7ClKu2x5/NjE /5iBnUSpjuqA7czJ17Q1zhgVKj/U1WJBIrfhX66CVwFssagqP5zuWBfAUnDN39YwolGs brVke5fww6lao2xQNPSlrWOvcDCCtWXJwXuu6cVl3wFeo4pfHESIIbdZxkgDvN2rMfa/ ORzqWlGQmi+88JjDEOvV/NEr4ivUl9XJPaYgdPks4X66YVYlBlGyeqLxTMJJoI8xOd48 1d6A== X-Gm-Message-State: AAQBX9f0SX6Hu79c5sL7/l0QIcDv6duk9M0rj+itB8H3/Y1ZFCaSuH+1 FQ+k42MYqQmfuM8vI0cH8i2EDT/R7a+AGQfqGIOgIZMEQyycQQ0yt7FIc2yViHj3pUKFhyRI7TC +zA71nDZwY3yU5aKihnmoNLP1CZPEwrO0cRsYkPHCfE3h4h7KAaVI303tSbMEmXybbn1B6F1juH 1dmko= X-Google-Smtp-Source: AKy350b3ywgYGOuNRaHCfri+YC25Y0XY6ETeOx4MfHOdbQbf18wi5MjpLqXr6pg04A8qD1H12AIVIIUEY6rzGOQ= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:85ae:0:b0:3ec:dc1f:12dd with SMTP id d43-20020a0285ae000000b003ecdc1f12ddmr6262286jai.6.1680807663728; Thu, 06 Apr 2023 12:01:03 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:25 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-7-allenwebb@google.com> Subject: [PATCH v10 06/11] modpost: Add -b option for emitting built-in aliases From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: This adds a command line option for writing the match-id based built-in aliases to a file. A future patch extends file2alias.c to support this command. The -b option accepts the output path as a parameter and requires vmlinuz.o to be one of the input files for the aliases to be found. Signed-off-by: Allen Webb --- scripts/mod/modpost.c | 30 ++++++++++++++++++++++++++++-- scripts/mod/modpost.h | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index efff8078e395..2e452aec0fc6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2173,6 +2173,19 @@ static void write_if_changed(struct buffer *b, const char *fname) write_buf(b, fname); } +/* Write the builtin aliases to the specified file. */ +static void write_builtin(const char *fname) +{ + struct buffer buf = { }; + struct module *mod; + + list_for_each_entry(mod, &modules, list) + buf_write(&buf, mod->modalias_buf.p, mod->modalias_buf.pos); + + write_if_changed(&buf, fname); + free(buf.p); +} + static void write_vmlinux_export_c_file(struct module *mod) { struct buffer buf = { }; @@ -2329,13 +2342,23 @@ int main(int argc, char **argv) { struct module *mod; char *missing_namespace_deps = NULL; - char *dump_write = NULL, *files_source = NULL; + char *builtin_write = NULL, *dump_write = NULL, *files_source = NULL; int opt; LIST_HEAD(dump_lists); struct dump_list *dl, *dl2; - while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) { + while ((opt = getopt(argc, argv, "b:ei:mnT:o:awENd:")) != -1) { switch (opt) { + case 'b': + /* + * Writes the match-id based built-in module aliases to + * the specified path. + * + * vmlinuz.o needs to be one of the input files for the + * aliases to be found. + */ + builtin_write = optarg; + break; case 'e': external_module = true; break; @@ -2398,6 +2421,9 @@ int main(int argc, char **argv) write_mod_c_file(mod); } + if (builtin_write) + write_builtin(builtin_write); + if (missing_namespace_deps) write_namespace_deps_files(missing_namespace_deps); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 34fe5fc0b02c..c55a6aeb46bf 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -123,6 +123,7 @@ struct module { bool has_init; bool has_cleanup; struct buffer dev_table_buf; + struct buffer modalias_buf; char srcversion[25]; // Missing namespace dependencies struct list_head missing_namespaces; From patchwork Thu Apr 6 19:00:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203859 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 94EECC77B6C for ; Thu, 6 Apr 2023 19:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240477AbjDFTBf (ORCPT ); Thu, 6 Apr 2023 15:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240376AbjDFTB2 (ORCPT ); Thu, 6 Apr 2023 15:01:28 -0400 Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D23B89EFF for ; Thu, 6 Apr 2023 12:01:05 -0700 (PDT) Received: by mail-io1-xd4a.google.com with SMTP id v126-20020a6bac84000000b007587234a54cso24648852ioe.6 for ; Thu, 06 Apr 2023 12:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Bt77I86eFgSbNaHK2t0i9/m/bTrUBRuYsHv7CbhjIr4=; b=gGaKPKflAxPJskJy8MYWIZ1zGy8JetUF3tcjeHXdaxT9RttPBdGV08CwKIrPIo+1+v GdrlN+UenxsaTd6j37BEg+IeE8RAXAb1nZvuujxF1SDejaQ6L5VlOT1mPFNxmzdShJ42 jWDSXooi1wn60L0/ZPaJqCSHCabEVM5k2IuBzu+3e1Bjl45I1n69jie8qj9ZKPhH3FAv 6nUSYGmVucJp1xtsyijza3z9sodintasi2zjYpdAdjOZjD04JaBOCzqMbvksTqMA21+e HsOsDewz6OvWSPAX4YEGOl6qFQS4nhG23kRhNad8SEYLTI9+httLSlZo5osesgMiNws/ 7fhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bt77I86eFgSbNaHK2t0i9/m/bTrUBRuYsHv7CbhjIr4=; b=jscFQeu1UmH0PH5GUam6+oR6Qfj6h6ahakRkDGKjhfowXTBb1d8OB6yZQ/LDVR+DHW B/SQ8/jwtyJOfxBbKFzlBttT/T1dvmNjtNDSng9pehAXSwinTir3iKSe08xZo0YeYfEe d5V3biN091wBn4PTInx9WnVvVRMqTjOc59TZq2SvFsd0HNGjC1pLC20lhD/BvoPCrjsr x3G8cQgsOHsavumd7RAYfu0ia/ML05UA86meHOQG4wte9lsczTKuINNuYpH0r2L1acXa FrcFbl2F+GefGXFzUXHUFF206c9SYW2OO0JfJQLxvOrgHO2AMRBlZxE+8A2Y/B67BGb/ tAVw== X-Gm-Message-State: AAQBX9fZg+VCfiq9HN0N0riUBCMkTKSG6ZpwKBiYglN38j0xOhsh+0es NnUnrD9MLItCrMbYO1oI+GrqVjVrgzszqacew10ywOy9jxmlfPIwyD9p6Bwo/4Dtcpp6hidBFHz gIN09nqw4LG/XuqyX6QVrZGGqojGzjdqOBNqRgH2lMQnzsyoy8VPDR/YY6o/G82uw6QH6JpaSjC nxb0c= X-Google-Smtp-Source: AKy350YvGrGN4n61kxqDKxiBKleyueyiQrPvC6O+CnLmm0EGLHXB3+GJdstqxviJ7IrnooMhhcchZlrK/+eB4BI= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:848e:0:b0:408:f9aa:a54d with SMTP id f14-20020a02848e000000b00408f9aaa54dmr5772053jai.6.1680807664892; Thu, 06 Apr 2023 12:01:04 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:26 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-8-allenwebb@google.com> Subject: [PATCH v10 07/11] file2alias.c: Implement builtin.alias generation From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: This populates the mod->modalias_buf with aliases for built-in modules when modpost is run against vmlinuz.o. Signed-off-by: Allen Webb --- scripts/mod/file2alias.c | 61 ++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b392d51c3b06..3793d4632b94 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -233,6 +233,8 @@ static void do_usb_entry(void *symval, add_wildcard(alias); buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name); } /* Handles increment/decrement of BCD formatted integers */ @@ -377,9 +379,13 @@ static void do_of_entry_multi(void *symval, struct module *mod) *tmp = '_'; buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name); strcat(alias, "C"); add_wildcard(alias); buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name); } static void do_of_table(void *symval, unsigned long size, @@ -611,12 +617,18 @@ static void do_pnp_device_entry(void *symval, unsigned long size, buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"pnp:d%s*\");\n", *id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n", + *id, mod->builtin_name); /* fix broken pnp bus lowercasing */ for (j = 0; j < sizeof(acpi_id); j++) acpi_id[j] = toupper((*id)[j]); buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n", + acpi_id, mod->builtin_name); } } @@ -638,6 +650,8 @@ static void do_pnp_card_entries(void *symval, unsigned long size, const char *id = (char *)(*devs)[j].id; int i2, j2; int dup = 0; + char acpi_id[PNP_ID_LEN]; + int k; if (!id[0]) break; @@ -663,19 +677,23 @@ static void do_pnp_card_entries(void *symval, unsigned long size, } /* add an individual alias for every device entry */ - if (!dup) { - char acpi_id[PNP_ID_LEN]; - int k; - - buf_printf(&mod->dev_table_buf, - "MODULE_ALIAS(\"pnp:d%s*\");\n", id); - - /* fix broken pnp bus lowercasing */ - for (k = 0; k < sizeof(acpi_id); k++) - acpi_id[k] = toupper(id[k]); - buf_printf(&mod->dev_table_buf, - "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); - } + if (dup) + continue; + + buf_printf(&mod->dev_table_buf, + "MODULE_ALIAS(\"pnp:d%s*\");\n", id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n", + id, mod->builtin_name); + + /* fix broken pnp bus lowercasing */ + for (k = 0; k < sizeof(acpi_id); k++) + acpi_id[k] = toupper(id[k]); + buf_printf(&mod->dev_table_buf, + "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n", + acpi_id, mod->builtin_name); } } } @@ -1476,10 +1494,13 @@ static void do_table(void *symval, unsigned long size, size -= id_size; for (i = 0; i < size; i += id_size) { - if (do_entry(mod->name, symval+i, alias)) { - buf_printf(&mod->dev_table_buf, - "MODULE_ALIAS(\"%s\");\n", alias); - } + if (!do_entry(mod->name, symval + i, alias)) + continue; + buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (!mod->builtin_name) + continue; + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, + mod->builtin_name); } } @@ -1554,10 +1575,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, return; /* - * All our symbols are either of form - * __mod____device_table - * or - * __mod_____kmod__device_table + * All our symbols are of form + * __mod_____kmod__device_table */ if (strncmp(symname, "__mod_", strlen("__mod_"))) return; From patchwork Thu Apr 6 19:00:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203860 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 2A4A7C7618D for ; Thu, 6 Apr 2023 19:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240491AbjDFTBj (ORCPT ); Thu, 6 Apr 2023 15:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240012AbjDFTBb (ORCPT ); Thu, 6 Apr 2023 15:01:31 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AAD5A261 for ; Thu, 6 Apr 2023 12:01:06 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id n9-20020a056e02148900b003263d81730aso15043484ilk.0 for ; Thu, 06 Apr 2023 12:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EIFZuvNlh3Q7f5viDBmDdFqHrpvMkDaR3sC9sXOJCEg=; b=r6Dgw36L4ye+f7TRQYGeV5tzr0btpwq3zzgs/UuXhg7VhxHkEGdn4IEj/h2PQMM8C7 9XrmV58b2OYGBa/Itz+04VD1lyNfP8oKVgBL+a+JqxD9bgvLCoGGT9xlOS7M7FSZhlrL dgPrDoQF1NMokITcEqaqE16eLq+/TyrGqoh7gwe5XUJYnNmAwK+1UyWGWYmy5FrIUyET RBrF9++/dM7QoNSpDAic5FyiBVC0USYGzK5MLgC687r/qXuqx0qG4J/VlJlQEiwErT5K pXhpKWhcW9txjXhgoS8Wh4mQInW++2qbyZT76CeylXl4fLCs7gG2hexuiYdjLRP04I53 0URw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EIFZuvNlh3Q7f5viDBmDdFqHrpvMkDaR3sC9sXOJCEg=; b=MLw2JDLTrUguRxHy87ul4DLHirBZtLf1bbj5YKqaznvJMuvsw/5OrkpkoNIJyJIJKM JlR+CSWe72ESSr8PRYMN3oW9YGag76bYw2mCJ/TYzcTgTe2PZT/PLs47b00voBK08FGM kztbnTN5/sDASpN+M9+VWM+8dsGKNE9xdp8J3yZ0xEZO5mEs75RQZTOXWK1rginPTWeI FonFltMPlLegRcN37hQmaWPT2GVc/rfhZqqwmiSPonYTxEx9RT6dksyctr7keYpeqKWf Dpa8CjGXBGE+uaxjzfjl/oZCtiZPTONuglZgw+oUvseRgvsjy3/yEuG27Oo9/x2h8KJd PaGA== X-Gm-Message-State: AAQBX9djYlOszVU6pas0lwM54af+CWq/8p5qHUn6/+wGFr9fhC8elsTU e9SDd8LPGWGfvNgFipv7Ji2nMv8QAIpBu4lODPf01foCojC78VRBZ+3PTBNEihw4hS7C3cwHIys ucxg7gqPGrkM814y8OV73RpqkmOZGKs/7m67VzLUSXmzbrLtKx5H+5JMH79VbYch+S4MoaEfyjP j4VV0= X-Google-Smtp-Source: AKy350YazP6AHiQUBJHLnELBlt24GFwGrksJ3FmwYx1omjP2DXfHXKkoCpwyla4mFW8rQJlG/AJrwns8MJ8tans= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a05:6e02:f44:b0:310:9afc:aa6 with SMTP id y4-20020a056e020f4400b003109afc0aa6mr6249545ilj.0.1680807665734; Thu, 06 Apr 2023 12:01:05 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:27 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-9-allenwebb@google.com> Subject: [PATCH v10 08/11] build: Add modules.builtin.alias From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: Generate modules.builtin.alias using modpost and install it with the modules. Signed-off-by: Allen Webb --- .gitignore | 1 + Makefile | 1 + scripts/Makefile.modpost | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 13a7f08a3d73..ddaa622bddac 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ modules.order /System.map /Module.markers /modules.builtin +/modules.builtin.alias /modules.builtin.modinfo /modules.nsdeps diff --git a/Makefile b/Makefile index a2c310df2145..43dcc1ea5fcf 100644 --- a/Makefile +++ b/Makefile @@ -1578,6 +1578,7 @@ __modinst_pre: fi @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order @cp -f modules.builtin $(MODLIB)/ + @cp -f modules.builtin.alias $(MODLIB)/ @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ endif # CONFIG_MODULES diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 0980c58d8afc..e3ecc17a7a19 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -15,6 +15,7 @@ # 2) modpost is then used to # 3) create one .mod.c file per module # 4) create one Module.symvers file with CRC for all exported symbols +# 5) create modules.builtin.alias the aliases for built-in modules # Step 3 is used to place certain information in the module's ELF # section, including information such as: @@ -63,6 +64,20 @@ modpost-args += -T $(MODORDER) modpost-deps += $(MODORDER) endif +ifneq ($(wildcard vmlinux.o),) +output-builtin.alias := modules.builtin.alias +modpost-args += -b .modules.builtin.alias.in +.modules.builtin.alias.in: $(output-symdump) + @# Building $(output-symdump) generates .modules.builtin.alias.in as a + @# side effect. + @[ -e $@ ] || $(MODPOST) -b .modules.builtin.alias.in vmlinux.o + +$(output-builtin.alias): .modules.builtin.alias.in + sort -o $@ $^ + +__modpost: $(output-builtin.alias) +endif + ifeq ($(KBUILD_EXTMOD),) # Generate the list of in-tree objects in vmlinux From patchwork Thu Apr 6 19:00:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203861 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 8674BC77B6C for ; Thu, 6 Apr 2023 19:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240511AbjDFTBv (ORCPT ); Thu, 6 Apr 2023 15:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240428AbjDFTBc (ORCPT ); Thu, 6 Apr 2023 15:01:32 -0400 Received: from mail-io1-xd49.google.com (mail-io1-xd49.google.com [IPv6:2607:f8b0:4864:20::d49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C3E4A5CD for ; Thu, 6 Apr 2023 12:01:07 -0700 (PDT) Received: by mail-io1-xd49.google.com with SMTP id 3-20020a6b1403000000b007588213c81aso24825911iou.18 for ; Thu, 06 Apr 2023 12:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807666; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ei4XEWjw7tArTwCoMKhp2ugctsL7jq49nRaYDRBL1Mc=; b=fbhRqzlGZlbPiWZ5IBGIy4z7rckgpL+76StH6hDf38wyBwByXbCIsFAmlVE0cVG5TK HqsTdsJmsOQJn26fMUBbDBhi697JYKpNT9cxQeU2fDWUSLG/eByrdUnKIe23vrDVZxqf ZBP1v4gu3dj1CHb/wtHjIhqoU1bMKJKU3wrEELXyN2gGsZyVLOip7UnrYagQr/ev81xN b3Bd3vKO5r1GVoi09bRFAB8/a7Y+D6JuDR595SthHnsolBMZsbGW92HOBuSfhM/J8OsN ba5cd5hdIpxcz5JXh8vvJQADy3Ad8PB/eaqfwUiX7uO/j4zE7x5OlmQhexuRZ9/HWi41 5dOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807666; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ei4XEWjw7tArTwCoMKhp2ugctsL7jq49nRaYDRBL1Mc=; b=K5iqlLg0fsH2n13vHamy7zwQt9ceSdQkdEi8Eg+sGd+Qj5SuDpHE4lvwW3nkL8F+Xf 2ZR54LgduMrd9IoITJssRkf5eCqZjNOx708jYRNxLrTHemvzGFVx65t3iCN1g4dsbLB8 fHo27nSICh82pD2XzT6KqNSYD/OROtHeV0WgU1fyh6lERpju029sgbInzGWHvife8EYA 5W2lhPvhkkNLx/hgLT/lm6IPX6rfDXYqf8gRcyhMAtEt3HvdFijJW70TVAF1n9bawdap +/k2rHWZCLSSvJZipjVt8wO5vjKS3IWYWIpnWC127vEHvorXayfVQbht+fuLYS03B2PJ lYWQ== X-Gm-Message-State: AAQBX9c+QlQgvJNLwMT30ksU3Z7il2fLgv0viVoZxCnAUj0PQzbKYzdX GQeJ6oA9oHSvLwdGGOHDE3Mm3eSP5gFz7nvgRK3ZxkZTJHVrgYc+bMg4X4cBfRxIgcmHYvrF75j I42eTkApGW8W0IicvU+6PzJxz7PwiJZcwgW8ItVFvSo1xwwZwp7yH0+5701n+EPYCWSe/rtJu3D 9QWNI= X-Google-Smtp-Source: AKy350ZZbJ29Gs9P2JWFiLO/pUBF8z9KEDzLtRKohDDgzI4f5p+saGHIi3qNgDRvjyVBK16Y4yqOOCNY933bmd4= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:2a45:0:b0:406:c43f:6320 with SMTP id w66-20020a022a45000000b00406c43f6320mr4089875jaw.0.1680807666582; Thu, 06 Apr 2023 12:01:06 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:28 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-10-allenwebb@google.com> Subject: [PATCH v10 09/11] Documentation: Include modules.builtin.alias From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: Update the documentation to include the presense and use case of modules.builtin.alias. Reviewed-by: Luis Chamberlain Signed-off-by: Allen Webb --- Documentation/kbuild/kbuild.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index 5202186728b4..b27c66c3ca9e 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -17,6 +17,13 @@ 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.alias +--------------------- +This file lists all match-id based aliases for modules built into the kernel. +An example usage of the built-in aliases is to enable software such as +USBGuard to allow or block devices outside of just the vendor, product, and +device ID. This enables more flexible security policies in userspace. + modules.builtin.modinfo ----------------------- This file contains modinfo from all modules that are built into the kernel. From patchwork Thu Apr 6 19:00:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203862 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 C8A8BC76196 for ; Thu, 6 Apr 2023 19:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240540AbjDFTBz (ORCPT ); Thu, 6 Apr 2023 15:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240440AbjDFTBc (ORCPT ); Thu, 6 Apr 2023 15:01:32 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B326AD39 for ; Thu, 6 Apr 2023 12:01:09 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id j11-20020a25230b000000b00b6871c296bdso39401277ybj.5 for ; Thu, 06 Apr 2023 12:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807668; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=M+j5aQ/96ezpNDW1vgfpLxhNNS1dVHH3UOwyvtk8Itw=; b=dzEtqbwSdQhApPhmcdODEKLYN82oHMMRmk8B4PyhxAByUq4XPTOH182HpSho2ATXyq KgeYBblH+4J9FVR+YQgyEItKH6SG6HgT4e1NbJYPphg4J4Cdw8PrLc+icd1mFFUI/+Ov Tg3XjwSVDvcwufsAomanvHBrZnnqOygpEPAMxmyDk2bBGkrfEta4tR9HGcKL/WDrCRhB RrAV2bbfnrcdMoo0feXgPMPjKoMMRjOnzJN+dLUHkpowLc01KF8F9hmWFfLsPJ/wDvlP DKXRnwqPahyh7FVswOhLr0I6v2HSy3rD2orKYuluaQ2pG6DeT41sTA/0kLY/zB0POi4f 28eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807668; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M+j5aQ/96ezpNDW1vgfpLxhNNS1dVHH3UOwyvtk8Itw=; b=U5bq6wav19fmnX+9Ag7DQJyIR9zzk6CQrMEIkL5dYocj+52NurGtftEVZSnFMMBGnd Xuo3qR3vNV74cDgGCc9OM1XMwW2/pnOpoTToMlWVFG9/7zPcI7FyNMci9qcoo4AjysI+ zgD9s5NQ/z8bAbjiF/0ZrKQuImtXYl+gFvjF5lYayaMnK+9FKUBvlyZ7yz16rn7qb4O8 J3cSrqQFe3nVi2b9t6iCcnc1DDusDr5r9i0ONnLBgGY6tZuhqFERaQI+Muyo34Kqfjks 7bC+uQUufuaZbiwU9dFKDLZZWSN0dFmtH3272voA5CPwvmAkTYcWh6+cXaz99kTSr/Bf iRSA== X-Gm-Message-State: AAQBX9feg0di8hG04kvZtogpcz9V4MPl2YR3mgNtfssLPgBLsIQn6g9j ZJhTDb+ioUi5ldJmgpUpYF9ilKVWzRVrvVfhTX8k5UJD+czvA4+tz4Q8x1DlD1dGvljZ+wdawi8 fTYn1H386L6g35c+pMCfedyJ8J7IVYFv1C0I3sPNVAFqJJabAzi9TrLO4RiK5Pn/XDG6F/M5Q9r S0NRE= X-Google-Smtp-Source: AKy350ZPBPvYArlTUHfBAIsSIdCLRqDyqZwRoWsoQhyrepd+MVYiDIkO59WJizadi3iwpqKF3i7yQRnRE3QGOEQ= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a25:76c6:0:b0:b8b:ee74:c9d4 with SMTP id r189-20020a2576c6000000b00b8bee74c9d4mr251123ybc.12.1680807667734; Thu, 06 Apr 2023 12:01:07 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:29 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-11-allenwebb@google.com> Subject: [PATCH v10 10/11] Documentation: Update writing_usb_driver for built-in modules From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: Built-in modules that set id_table need to set MODULE_DEVICE_TABLE so update the documentation accordingly. Signed-off-by: Allen Webb --- Documentation/driver-api/usb/writing_usb_driver.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index 95c4f5d14052..5f38e3bd469a 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -128,6 +128,9 @@ single device with a specific vendor and product ID:: }; MODULE_DEVICE_TABLE (usb, skel_table); +The ``MODULE_DEVICE_TABLE`` should also be set for built-in USB drivers +that provide an id_table, so that tools like USBGuard can properly +associate devices with your driver. There are other macros that can be used in describing a struct :c:type:`usb_device_id` for drivers that support a whole class of USB From patchwork Thu Apr 6 19:00:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203863 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 E3946C76196 for ; Thu, 6 Apr 2023 19:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240552AbjDFTCB (ORCPT ); Thu, 6 Apr 2023 15:02:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240448AbjDFTBc (ORCPT ); Thu, 6 Apr 2023 15:01:32 -0400 Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD7CAD38 for ; Thu, 6 Apr 2023 12:01:09 -0700 (PDT) Received: by mail-io1-xd4a.google.com with SMTP id p128-20020a6b8d86000000b007583ebb18fdso24450053iod.19 for ; Thu, 06 Apr 2023 12:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807668; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lXaHngygoOShOtLfr1dWwTlpzanuSNfDsA9/IVCyMM4=; b=A1qC/ZvuARpF4aifJXh0p0le494sYKU2NUrJtNd2o8ZvihCjDaf3+R7KzU/ysrpbl6 l4vRFYVToK0UOMs0pZfZJ7KBI+Rl41ceZohihh9yw628OH8pKSweYgOGEyjX53rN+MH3 u2r5VzZepyIuhRLZEHGDRHYR4Yryg2rfMG46aAd7Jca5I7jedUgP1ewH8NgnLcVyakEp F4H5kVYuwj8RvLh0MhgIVykT7rtStfd74mo/DgYwCZTwVY2UqPmjoOLrZ57Eg7pCyh03 BpB549iKmEZJpj+E0ENtaR6aAv1+3vU3S/3z9qiLV4svNL23ganVPoSrhWkMrbQjfGbE QLFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807668; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lXaHngygoOShOtLfr1dWwTlpzanuSNfDsA9/IVCyMM4=; b=uhgLxK4CSE66wupwVrAxHBRdYwWc8BY5UPfzZJ6PwMzsrPpv5N8PLrVrUDpZZ5qpeU RqEw0y/bDnhnabClNNXTA/WMzaAXojSH+VCD3S/R0JqPcshh0FZUFbumkd0fxV+dnjCC YXUCsKKo1b1IOVR9rO5ZR2vz2KC3sZO2Eq4JM2QjtTP3ezJk06FMha36WxRWX+ISQM91 DPxxtiDBNGJvEt75MBzplxn7KPjqyQGxveCRe5kgaLPi922PucyUiL88hpbyF9aJKZoh /H+EIxKpnAzzQLyw4D7AaZmaKYALIPw0khVUT9CBgr6NzJIunYaxZFeNVuP3negmHPG5 cUZw== X-Gm-Message-State: AAQBX9cmB7k+Aw8HuGBDN4EVj76omldXBBP3343t+Nr0jZEmiv//70ea GUg18JOUVIktELi0a8X9nwpLhx4nbjdC2atU5gLm80a4JN6xV2Z/6c7ltjfsn2lzoOfbKvIXIvB gPjKQCd8hv6GNlS8ifkIjZx+a/zx7j7JcZ0lMxvEjQ8teWp4bxk8beDokpQ4BN1cBrSea8P6386 GEEVg= X-Google-Smtp-Source: AKy350Y3vePEPTjTofpsZaUJlnNunFT2KZcMeGuMTuCI/IqR0X3Td2aohNhIvplwI6YzX9YZIveMg5tfNSLS/1k= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a05:6e02:d44:b0:326:315:f3d with SMTP id h4-20020a056e020d4400b0032603150f3dmr6023365ilj.1.1680807668678; Thu, 06 Apr 2023 12:01:08 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:30 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-12-allenwebb@google.com> Subject: [PATCH v10 11/11] Documentation: add USB authorization document to driver-api From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: There is a user-facing USB authorization document, but it is midding details a driver should have developer, so add them in a new document. Signed-off-by: Allen Webb --- .../driver-api/usb/authorization.rst | 71 +++++++++++++++++++ Documentation/driver-api/usb/index.rst | 1 + 2 files changed, 72 insertions(+) create mode 100644 Documentation/driver-api/usb/authorization.rst diff --git a/Documentation/driver-api/usb/authorization.rst b/Documentation/driver-api/usb/authorization.rst new file mode 100644 index 000000000000..383dcc037a15 --- /dev/null +++ b/Documentation/driver-api/usb/authorization.rst @@ -0,0 +1,71 @@ +.. SPDX-License-Identifier: GPL-2.0 + +==================== +Device Authorization +==================== + +This document is intended for driver developers. See +Documentation/usb/authorization.rst if you are looking for how to use +USB authorization. + +Authorization provides userspace a way to allow or block configuring +devices early during enumeration before any modules are probed for the +device. While it is possible to block a device by not loading the +required modules, this also prevents other devices from using the +module as well. For example someone might have an unattended computer +downloading installation media to a USB drive. Presumably this computer +would be locked to make it more difficult for a bad actor to access the +computer. Since USB storage devices are not needed to interact with the +lock screen, the authorized_default sysfs attribute can be set to not +authorize new USB devices by default. A userspace tool like USBGuard +can then vet the devices. Mice, keyboards, etc can be allowed by +writing to their authorized sysfs attribute so that the lock screen can +still be used (this important in cases like suspend+resume or docks) +while other devices can be blocked as long as the lock screen is shown. + +Sysfs Attributes +================ + +Userspace can control USB device authorization through the +authorized_default and authorized sysfs attributes. + +authorized_default +------------------ + +Defined in ``drivers/usb/core/hcd.c`` + +The authorized_default sysfs attribute is only present for host +controllers. It determines the initial state of the authorized sysfs +attribute of USB devices newly connected to the corresponding host +controller. It can take on the following values: + ++---------------------------------------------------+ +| Value | Behavior | ++=======+===========================================+ +| -1 | Authorize all devices except wireless USB | ++-------+-------------------------------------------+ +| 0 | Do not authorize new devices | ++-------+-------------------------------------------+ +| 1 | Authorize new devices | ++-------+-------------------------------------------+ +| 2 | Authorize new internal devices only | ++---------------------------------------------------+ + +Note that firmware platform code determines if a device is internal or +not and this is reported as the connect_type sysfs attribute of the USB +port. This is currently supported by ACPI, but device tree still needs +an implementation. Authorizing new internal devices only can be useful +to work around issues with devices that misbehave if there are delays +in probing their module. + +authorized +---------- + +Defined in ``drivers/usb/core/sysfs.c`` + +Every USB device has an authorized sysfs attribute which can take the +values 0 and 1. When authorized is 0, the device still is present in +sysfs, but none of its interfaces can be associated with drivers and +modules will not be probed. When authorized is 1 (or set to one) a +configuration is chosen for the device and its interfaces are +registered allowing drivers to bind to them. diff --git a/Documentation/driver-api/usb/index.rst b/Documentation/driver-api/usb/index.rst index cfa8797ea614..ffe37916f99f 100644 --- a/Documentation/driver-api/usb/index.rst +++ b/Documentation/driver-api/usb/index.rst @@ -7,6 +7,7 @@ Linux USB API usb gadget anchors + authorization bulk-streams callbacks dma