From patchwork Wed Sep 14 19:03:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 606231 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 6924CECAAD3 for ; Wed, 14 Sep 2022 19:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbiINTET (ORCPT ); Wed, 14 Sep 2022 15:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbiINTES (ORCPT ); Wed, 14 Sep 2022 15:04:18 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2059.outbound.protection.outlook.com [40.107.220.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2189C4332D; Wed, 14 Sep 2022 12:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kVaXqoc6lEOpJu1ZoTI2yoRPkVr2yXo84sOf951i4hLbgzTcPvNjkp8Ez+Or619muuv6kWjyFkSGy0fXdaeiyIzuGUbK6bkxsAcETsEhJpVK7Xqn+uSA6KxPPrB6rkNAPY6ymxqPyEoa0mT5bE4DBuLlF+u+BFH8UXWi53NymFozLYIbn+xIreP7qRzE78ErSLPrLN5boPYaiDDaoEGfz9Bqd21eC4Czlclyx5QuC5PikKY9ef9GjXdAds71WiUhnSmAxv7QzBpD1Ve/J+CcPVdOebTBqyA8GebT6V+MqucqjdDt+Xue3wH0xObFCzLKp/sEj2sEzwKPA8tqpfkJuw== 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=B+cU7VBWDPa+H6fi0gHL2b5vwqw9vTpbD0DqqTSRn/I=; b=NV9ZbYGiwvuB2G0gPGOkGorZKpiv5LZefbfTZyyWqmwwzkaTzH4CeWODBgZvUCJ93mTj+fhlsfWTqeouX1C+ujY8C8f6g58GPIN83u75oVcNdEDA7svQ8EfaiuQUr3bMmiJoktMwvaixBnleyUHFwLg5oU84g8ZKs7JFlamLjRJ55jB7FtNosLjBf4haLsEc+s7ynmCBrfM3C1CqGwXo047UKHor3zXNujYgCArXlK4Vol4D0+fZJl4a9/213Mw9/PXKNYhHNJQkt9mEYKxsXJVgR3o+kfIHKPY6yW3cv1XQla7ajnS0gg+6jQrBaTbgIOA8aHbMOSWPJGSZhkKZmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.linux.dev smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B+cU7VBWDPa+H6fi0gHL2b5vwqw9vTpbD0DqqTSRn/I=; b=gPXPbfpcazDOt8YFRvnAlIxGP4P/VSE9DpEdcvkoDjWP1kmPW0CaxIyjxewib1np8huzaZ5BEunRfHobkztMELTCDVUuUhxOQxfCPcjIY/CrqniLYJzrGcx/MlcWhENXkq02QfAqgm7dYqTJ18gNlmPJj3yjN/p1lsxXvJ3p390= Received: from BN0PR08CA0009.namprd08.prod.outlook.com (2603:10b6:408:142::13) by BY5PR12MB4114.namprd12.prod.outlook.com (2603:10b6:a03:20c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.23; Wed, 14 Sep 2022 19:04:14 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::ac) by BN0PR08CA0009.outlook.office365.com (2603:10b6:408:142::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12 via Frontend Transport; Wed, 14 Sep 2022 19:04:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT013.mail.protection.outlook.com (10.13.176.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5632.12 via Frontend Transport; Wed, 14 Sep 2022 19:04:13 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 14 Sep 2022 14:04:09 -0500 From: Kim Phillips To: , CC: , , , Mike Day , , Kim Phillips , , Suravee Suthikulpanit , Joerg Roedel Subject: [PATCH 1/2] iommu/amd: Fix ivrs_acpihid cmdline parsing code Date: Wed, 14 Sep 2022 14:03:29 -0500 Message-ID: <20220914190330.60779-1-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT013:EE_|BY5PR12MB4114:EE_ X-MS-Office365-Filtering-Correlation-Id: 09b06418-2cd3-4f5a-cf82-08da9683ea12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BMVHc/ojr9pMG3BRplOA7mdKjbkZMcxLdI9cq0pVQCvk7U8CVi+4D4sPiyZJSL17h95ndurqsnNXbjLpJekZ5IXDM7t0pp6DuBcf94uFOhNgJ+B276r2lnef8pvwNJUnQ1n+wkUNyWHLGoS9swCdjw2zeRvaYE68MpcLmBjovB5OoDRKm3yinTlKDBdFg+mPxOoHxDqntWooLcLw3reyxjxGI1NPm5gZob/AWdPnzyK1wqMvrQj8Usanr26YxfhbANcIWvThbE9oD0oc796QqhvmACWx9IDIwECEhwxpuyW7aF4XlF32vUYy51Acsc4CWTywPluadQymV2MP38ZhHWKR5Y6isDjTM3ObZDaKur+La0CE6tCwGWeeiDraltt0eB5zZCoW9uHZUb+d2ug3lYbVolIwYY4VkxBlrgKCnc5eDsedjd6mFvxz4Pt1JsRSJPydWbEogF6fOsH3mTOczNoumz+NbHjwd1Z5Jf4xMA0+PIM8jxs09bGXi77YI9kpAyZRyXpeuyPUI4RDkM9GcFOsvK5p/DiEM9qK9FNOtepE3X9VTnsxCoFgUoxjiz8o82uhmQyhoqy6QtCznANTb6uVIctoNe3wZXPVIX7vv2YIhgf1sTaBs3SqwP+wBjBnSlKLGG4EWfz+eHqa+eZDEGVKHW/97IFUZ90qfwjf1s2DmxZ7ASQoNhOdL+/Ts9o4QlWx6t0SNrQ1T/TGYrn5BALeCEUKbImRktOd1oD7+OiU36eDSg7oOk0k63kLVw3Y+9sXG6Usr1soQCOEnCIIBmqglYT+z+CkOhP9YEemFh5n4Rvh+tUS2irzrJpmKhnd X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(336012)(16526019)(2616005)(44832011)(186003)(1076003)(41300700001)(6666004)(82740400003)(8676002)(5660300002)(4326008)(26005)(70586007)(8936002)(70206006)(40460700003)(36756003)(36860700001)(86362001)(82310400005)(40480700001)(356005)(81166007)(426003)(47076005)(2906002)(110136005)(478600001)(7696005)(54906003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2022 19:04:13.7548 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09b06418-2cd3-4f5a-cf82-08da9683ea12 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4114 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The second (UID) strcmp in acpi_dev_hid_uid_match considers "0" and "00" different, which can prevent device registration. Have the AMD IOMMU driver's ivrs_acpihid parsing code remove any leading zeroes to make the UID strcmp succeed. Now users can safely specify "AMDxxxxx:00" or "AMDxxxxx:0" and expect the same behaviour. Fixes: ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter") Signed-off-by: Kim Phillips Cc: stable@vger.kernel.org Cc: Suravee Suthikulpanit Cc: Joerg Roedel --- drivers/iommu/amd/init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index fdc642362c14..ef0e1a4b5a11 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -3471,6 +3471,13 @@ static int __init parse_ivrs_acpihid(char *str) return 1; } + /* + * Ignore leading zeroes after ':', so e.g., AMDI0095:00 + * will match AMDI0095:0 in the second strcmp in acpi_dev_hid_uid_match + */ + while (*uid == '0' && *(uid + 1)) + uid++; + i = early_acpihid_map_size++; memcpy(early_acpihid_map[i].hid, hid, strlen(hid)); memcpy(early_acpihid_map[i].uid, uid, strlen(uid)); From patchwork Wed Sep 14 19:03:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 605810 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 AEB40C6FA86 for ; Wed, 14 Sep 2022 19:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229622AbiINTE4 (ORCPT ); Wed, 14 Sep 2022 15:04:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbiINTE4 (ORCPT ); Wed, 14 Sep 2022 15:04:56 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2063.outbound.protection.outlook.com [40.107.220.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C165D4F18D; Wed, 14 Sep 2022 12:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z3MZnhLLRsGB4PliA9EhfW8klQCw1PIzaLRdwWmkb/VrehfMBQJVQEEmmwtOz8LSm2e9GL0cPAKZqcBjpHykVIUYYZtYuhj9IoMzF3Y5bXyirIHjly0Lx7q6NVJYcMzMxSx0fHhHSirmMnpZeXMEOVCLQz1namQzm3oR2GGbbcOL9KRXIEwlW7TOBl3vTAwJ2kazGAk/9Aa+4rb52NmBjRKMYFzx3kKLOXZSH6pAarHa694KRLC6VCf9kmP3dKgYvMVTo/5J6uNdfr+kFcyYLghnUmE9PsaZGwxtKBLBUuP9WfWM+3ijZ8iFjJz+l5l9ypBFusMvP1NViKSELoq/FA== 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=Fh+MujYit8jljxBhR5IEO+DPua0el8ztAonqqE4gdjw=; b=EGVrFTGcgOetB3jH1Zv8t3JF01NI8x6khfGyI7eroa79GOH7Zy0R7xjaSKirsUObj9/SKDlX/CD74tMM1CnKbbkwGGvMrQB9UJ/BjsNCBbIN5ePG0xsPf/KtdhL6dgfLl0vNNaPKfCJFHtKu3a14ED4bIUrAL/rVpA+XoZl4q5+k+dwfLmjo6dMmnxPIVEFu7ZlBsq8JYeoAlwt+eNdov5RVfDhe9dEgHIU/MbY3F/fSfYbi8UE6bPUyfFEIioLDGpDD1qugGy4s5RbMLcmpIKTukuSybfsCFMD9/C8jm8AgXE+rpQH1VMUC+Ktya9G3CC8m7qRc4r5cFJVh3EGnOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.linux.dev smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fh+MujYit8jljxBhR5IEO+DPua0el8ztAonqqE4gdjw=; b=bF4TmPRFZTQaJKPbizegqWTFOh5GbAUtSui/YBJibUrmeLZsyFk5gWSzwLHCr0Ek3ELfiPS9gNrSRrKuQ7TqtsMW1vDaUSKQp9dx7C1ZHPXbIJ+U1hkvFK+4GUKNzERQy7Og5iWpL8w9/lQpOAY1giPdbBKWMa8o2b5zomNOC54= Received: from BN9PR03CA0609.namprd03.prod.outlook.com (2603:10b6:408:106::14) by CO6PR12MB5490.namprd12.prod.outlook.com (2603:10b6:303:13d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Wed, 14 Sep 2022 19:04:52 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:106:cafe::98) by BN9PR03CA0609.outlook.office365.com (2603:10b6:408:106::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.14 via Frontend Transport; Wed, 14 Sep 2022 19:04:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5632.12 via Frontend Transport; Wed, 14 Sep 2022 19:04:51 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 14 Sep 2022 14:04:45 -0500 From: Kim Phillips To: , CC: , , , Mike Day , , Kim Phillips , Subject: [PATCH 2/2] iommu/amd: Fix ill-formed ivrs_ioapic, ivrs_hpet and ivrs_acpihid options Date: Wed, 14 Sep 2022 14:03:30 -0500 Message-ID: <20220914190330.60779-2-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220914190330.60779-1-kim.phillips@amd.com> References: <20220914190330.60779-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT020:EE_|CO6PR12MB5490:EE_ X-MS-Office365-Filtering-Correlation-Id: bd04de79-a930-4bce-188c-08da968400a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h2P8qxbvvycHpQ3UquQiOFukND0j8MCetNI0WwMsHXeLkmG3lMhQI2t97sQHGwMTB+xJ0IXXy7UzHe+Ck1ckGNs5omVrKL/Y01/Xwnti/KTcG42XRB+6OpVAxPh/eIYdKgpSq2uC0fUTVUvA0Pf3zxXgcAiEqcq6P19O4xVkKmJpH8epS7y+xkv32moUkQgBIfvpVT/Niv4BL4SyikoMeJwxCr8fk9B97aB3oRvxLbLcNoUyLstfub6ZB9yorvm9PXBYH65JYqvEOWKP90/Eg4U5Fc5wJ9LibPMCkIga/yg/8yL/NCI+dkcjsik8rqA3XPbnHDJOvTuSFiWtliNl3FKkIQTm3yAo3Si6LX8F6do0cLAaExqb1Rja2d8iacfOAoTZHJi9n8pT4xmlQCcGcoezFnu6n3Go0snmiFQZuTkLpX85nvb97EJWzOkGZ+3qtUT0/jbdrpHIf4QHR/FQm5lFYm+vsmwr44WZVb/yZTtp5ketIF4+LMp3frlzMLdLhhnBZRr4lzrmiJHid1PFZqeGCwdhKyVrUtnabD09um45T0qJxjMcgkaXzVKr6HSgEbm0KwGL2FSdKZd3lewajGrR93vIapHLp1PBHS/puaLAu9e+mp8TrQfTHrCw8YU3r7p+gBallBsLEvBDbIb0ub3Jiu0bbUXV7kIoCmPhwIB0AwPoshf6fTS9CpHevfaDB2HMV3v8iNw4SrNGowckdvx5be6maSJLZgbsqVzFJNWP6UXgrP1ndHNGHJGfUnobH0AEALmjj9lRWoR/3dFHrE1DgX/hbHKFRO/ZTnFWClki8SqW0SHECM+el8XAUF+PmVxXzmvnuEjJpTg7VYqUGw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199015)(36840700001)(46966006)(40470700004)(478600001)(82310400005)(356005)(82740400003)(36860700001)(7696005)(41300700001)(426003)(36756003)(26005)(44832011)(54906003)(70206006)(47076005)(110136005)(8676002)(8936002)(83380400001)(6666004)(4326008)(966005)(40460700003)(81166007)(1076003)(186003)(40480700001)(16526019)(2906002)(336012)(2616005)(86362001)(5660300002)(70586007)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2022 19:04:51.5347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd04de79-a930-4bce-188c-08da968400a1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5490 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently, these options cause the following libkmod error: libkmod: ERROR ../libkmod/libkmod-config.c:489 kcmdline_parse_result: \ Ignoring bad option on kernel command line while parsing module \ name: 'ivrs_xxxx[XX:XX' Fix by introducing a new parameter format for these options and throw a warning for the deprecated format. Users are still allowed to omit the PCI Segment if zero. Adding a Link: to the reason why we're modding the syntax parsing in the driver and not in libkmod. Fixes: ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/linux-modules/20200310082308.14318-2-lucas.demarchi@intel.com/ Reported-by: Kim Phillips Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Kim Phillips --- .../admin-guide/kernel-parameters.txt | 27 +++++-- drivers/iommu/amd/init.c | 79 +++++++++++++------ 2 files changed, 76 insertions(+), 30 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index d7f30902fda0..23666104ab9b 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2294,7 +2294,13 @@ Provide an override to the IOAPIC-ID<->DEVICE-ID mapping provided in the IVRS ACPI table. By default, PCI segment is 0, and can be omitted. - For example: + + For example, to map IOAPIC-ID decimal 10 to + PCI segment 0x1 and PCI device 00:14.0, + write the parameter as: + ivrs_ioapic=10@0001:00:14.0 + + Deprecated formats: * To map IOAPIC-ID decimal 10 to PCI device 00:14.0 write the parameter as: ivrs_ioapic[10]=00:14.0 @@ -2306,7 +2312,13 @@ Provide an override to the HPET-ID<->DEVICE-ID mapping provided in the IVRS ACPI table. By default, PCI segment is 0, and can be omitted. - For example: + + For example, to map HPET-ID decimal 10 to + PCI segment 0x1 and PCI device 00:14.0, + write the parameter as: + ivrs_ioapic=10@0001:00:14.0 + + Deprecated formats: * To map HPET-ID decimal 0 to PCI device 00:14.0 write the parameter as: ivrs_hpet[0]=00:14.0 @@ -2317,15 +2329,20 @@ ivrs_acpihid [HW,X86-64] Provide an override to the ACPI-HID:UID<->DEVICE-ID mapping provided in the IVRS ACPI table. + By default, PCI segment is 0, and can be omitted. For example, to map UART-HID:UID AMD0020:0 to PCI segment 0x1 and PCI device ID 00:14.5, write the parameter as: - ivrs_acpihid[0001:00:14.5]=AMD0020:0 + ivrs_acpihid=AMD0020:0@0001:00:14.5 - By default, PCI segment is 0, and can be omitted. - For example, PCI device 00:14.5 write the parameter as: + Deprecated formats: + * To map UART-HID:UID AMD0020:0 to PCI segment is 0, + PCI device ID 00:14.5, write the parameter as: ivrs_acpihid[00:14.5]=AMD0020:0 + * To map UART-HID:UID AMD0020:0 to PCI segment 0x1 and + PCI device ID 00:14.5, write the parameter as: + ivrs_acpihid[0001:00:14.5]=AMD0020:0 js= [HW,JOY] Analog joystick See Documentation/input/joydev/joystick.rst. diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index ef0e1a4b5a11..13c6b581549c 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -3385,18 +3385,24 @@ static int __init parse_amd_iommu_options(char *str) static int __init parse_ivrs_ioapic(char *str) { u32 seg = 0, bus, dev, fn; - int ret, id, i; + int id, i; u32 devid; - ret = sscanf(str, "[%d]=%x:%x.%x", &id, &bus, &dev, &fn); - if (ret != 4) { - ret = sscanf(str, "[%d]=%x:%x:%x.%x", &id, &seg, &bus, &dev, &fn); - if (ret != 5) { - pr_err("Invalid command line: ivrs_ioapic%s\n", str); - return 1; - } + if (sscanf(str, "=%d@%x:%x.%x", &id, &bus, &dev, &fn) == 4 || + sscanf(str, "=%d@%x:%x:%x.%x", &id, &seg, &bus, &dev, &fn) == 5) + goto found; + + if (sscanf(str, "[%d]=%x:%x.%x", &id, &bus, &dev, &fn) == 4 || + sscanf(str, "[%d]=%x:%x:%x.%x", &id, &seg, &bus, &dev, &fn) == 5) { + pr_warn("Deprecated option : ivrs_ioapic%s\n", str); + pr_warn("Please see kernel parameters document and update the option.\n"); + goto found; } + pr_err("Invalid command line: ivrs_ioapic%s\n", str); + return 1; + +found: if (early_ioapic_map_size == EARLY_MAP_SIZE) { pr_err("Early IOAPIC map overflow - ignoring ivrs_ioapic%s\n", str); @@ -3417,18 +3423,24 @@ static int __init parse_ivrs_ioapic(char *str) static int __init parse_ivrs_hpet(char *str) { u32 seg = 0, bus, dev, fn; - int ret, id, i; + int id, i; u32 devid; - ret = sscanf(str, "[%d]=%x:%x.%x", &id, &bus, &dev, &fn); - if (ret != 4) { - ret = sscanf(str, "[%d]=%x:%x:%x.%x", &id, &seg, &bus, &dev, &fn); - if (ret != 5) { - pr_err("Invalid command line: ivrs_hpet%s\n", str); - return 1; - } + if (sscanf(str, "=%d@%x:%x.%x", &id, &bus, &dev, &fn) == 4 || + sscanf(str, "=%d@%x:%x:%x.%x", &id, &seg, &bus, &dev, &fn) == 5) + goto found; + + if (sscanf(str, "[%d]=%x:%x.%x", &id, &bus, &dev, &fn) == 4 || + sscanf(str, "[%d]=%x:%x:%x.%x", &id, &seg, &bus, &dev, &fn) == 5) { + pr_warn("Deprecated option : ivrs_hpet%s\n", str); + pr_warn("Please see kernel parameters document and update the option.\n"); + goto found; } + pr_err("Invalid command line: ivrs_hpet%s\n", str); + return 1; + +found: if (early_hpet_map_size == EARLY_MAP_SIZE) { pr_err("Early HPET map overflow - ignoring ivrs_hpet%s\n", str); @@ -3449,19 +3461,36 @@ static int __init parse_ivrs_hpet(char *str) static int __init parse_ivrs_acpihid(char *str) { u32 seg = 0, bus, dev, fn; - char *hid, *uid, *p; + char *hid, *uid, *p, *addr; char acpiid[ACPIHID_UID_LEN + ACPIHID_HID_LEN] = {0}; - int ret, i; - - ret = sscanf(str, "[%x:%x.%x]=%s", &bus, &dev, &fn, acpiid); - if (ret != 4) { - ret = sscanf(str, "[%x:%x:%x.%x]=%s", &seg, &bus, &dev, &fn, acpiid); - if (ret != 5) { - pr_err("Invalid command line: ivrs_acpihid(%s)\n", str); - return 1; + int i; + + addr = strchr(str, '@'); + if (!addr) { + if (sscanf(str, "[%x:%x.%x]=%s", &bus, &dev, &fn, acpiid) == 4 || + sscanf(str, "[%x:%x:%x.%x]=%s", &seg, &bus, &dev, &fn, acpiid) == 5) { + pr_warn("Deprecated option: ivrs_acpihid%s\n", str); + pr_warn("Please see kernel parameters document and update the option.\n"); + goto found; } + goto not_found; } + /* We have the '@', make it the terminator to get just the acpiid */ + *addr++ = 0; + + if (sscanf(str, "=%s", acpiid) != 1) + goto not_found; + + if (sscanf(addr, "%x:%x.%x", &bus, &dev, &fn) == 3 || + sscanf(addr, "%x:%x:%x.%x", &seg, &bus, &dev, &fn) == 4) + goto found; + +not_found: + pr_err("Invalid command line: ivrs_acpihid%s\n", str); + return 1; + +found: p = acpiid; hid = strsep(&p, ":"); uid = p;