From patchwork Mon Sep 19 15:56:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 607362 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 B9565C6FA86 for ; Mon, 19 Sep 2022 15:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230002AbiISP5A (ORCPT ); Mon, 19 Sep 2022 11:57:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbiISP47 (ORCPT ); Mon, 19 Sep 2022 11:56:59 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2084.outbound.protection.outlook.com [40.107.94.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5150810544; Mon, 19 Sep 2022 08:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lQ7iJqVUnTwrsiz9mzFvoEP/u9h9vr5MlWtsTPG5S+OhtIdhsZRwojnKZeTs7wz25lhZCer8OBMXSmxfmsVv8PpZTRz2XE3gq8l9t9opOX2Z50Eob6YFseVBHY3YkzctH2WqK3TxUQ7miUmW/XTKSK9yAX4WWzzvj2YixMF6yqI1vEk6qq8khy1PHapxovvYKyPDMTiDQsUK7C4kOdsMSD/oxkmAFIZp3MM1cjjfKxHh5lg79T/Q+Zb9cY3zBUOQLIol/swy/HbungNeetklCnMv1OQvZ7i/r8zB0PsoDFGgB59NAMoncbBWehzRc4Jj+u50IlWok0BBJkotvSb8Tg== 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=cHVVtPH9cZ5zdqMlNQu4tD1oz6I+8NMZ/o30hZRnc6I=; b=dJdw1SQPxVt8MFNs5qZkEspbzm+IkDmIYn4JJd9Ngq3yIpObalcHpIzJ0P1RvvalQ+UR+pOOfPwTVyvv3jLlSrgJ9PqwLN3Nv6tGKESjD1TqfWYhHrcBdSqoJj4RbSLV4zIthL+dXErlHJ8fAZWAoiy3pjdDu02reyw1MnsLzFgtpC5f2bbICYahXBt/LEAaPwH3xEIObj/RmRRC2jpgrEr/UmTKbgX7qjcYwrgmIkNpKjMyZ73X9A+DwJn3jVjDH1uHoHvlK/uZIn8KjKUMqKzHZbb5SeG4wh6QEs09SKNbvBdWxXhuC4Uacf65Pzs9tCsp9dyFdXeNcs9XSkO1JA== 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=cHVVtPH9cZ5zdqMlNQu4tD1oz6I+8NMZ/o30hZRnc6I=; b=Qtm9fJ1jDiInwUHuIMnbO4JuuB5lPGN1+k4cCtyV4K03CRLWrOJ6sFMSp2uCsKIHZYnq466LUPqUly7ZU+jySSby/TKZAdrnPnl70pZw6CgpV7a7WcVbxCTzJNB/MnrTFkjbDONqDx0dea9oh99j5mQhG6phbdDuRSfe5uaca2E= Received: from MW4PR04CA0353.namprd04.prod.outlook.com (2603:10b6:303:8a::28) by MN2PR12MB4287.namprd12.prod.outlook.com (2603:10b6:208:1dd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21; Mon, 19 Sep 2022 15:56:56 +0000 Received: from CO1NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8a:cafe::e1) by MW4PR04CA0353.outlook.office365.com (2603:10b6:303:8a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21 via Frontend Transport; Mon, 19 Sep 2022 15:56:56 +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 CO1NAM11FT092.mail.protection.outlook.com (10.13.175.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5632.12 via Frontend Transport; Mon, 19 Sep 2022 15:56:55 +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; Mon, 19 Sep 2022 10:56:54 -0500 From: Kim Phillips To: , CC: , , , Mike Day , , Kim Phillips , , Suravee Suthikulpanit , Joerg Roedel Subject: [PATCH v2 1/2] iommu/amd: Fix ivrs_acpihid cmdline parsing code Date: Mon, 19 Sep 2022 10:56:37 -0500 Message-ID: <20220919155638.391481-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT092:EE_|MN2PR12MB4287:EE_ X-MS-Office365-Filtering-Correlation-Id: 37a5486f-f788-4118-1abe-08da9a5793de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2uMq2r5LosbScVsEZwfsM/Fmvsk78zVq8f792VSKYvrrTyHpg1fHQGViFyoKhzMSjVWsBCgnJZ6rwugW0OjjVizJMV4TRZLy9YdnDxmde3D22xvMudoD5uAJyhQuhj10aePXVH9+BgnY72WB0tkTaA8B3UwS0dbMTHXqyJHMD5P0vhzIbTQWyJtI9zisSydTwozMKwS9MMiK1TDitRhHo5Gt04jiVACwQU4hwRxm3EBBUdDYtVtQmhw5vpETORIMTaxbBQdXOk8eYUTT01Dl/BHyntOOxxQ8J8UprVd5N5pm7fkC9EX4YqEJ+LdpB/mXSWZje9Smvg1usNVYLOU+9y0bIiZSpMtV+Ul2cA60KOe9OWeaDgMl+vtPL1h3+rrr4vrHvSM21eUtwN2su9vix+nvQChFEBzrgaRh/mfTbND6lkof0FiHeTq9G/7dwJhTrk02IF73sCaG3rLoygfPsHAXByxm4suCOsNu7bFgS3hMkBpl3bSknGvFO/tAhFJL3+p/Qu9jCwiH46npKMRVwS2+d0ZUqNGxLAzxJdgQt425rmOfbGWq5g2bgvjnhkRmEZucWdTl+kTVd47MX3ViIGrRwFAOpEnXaaP9sRH96rPiJvpwgRd5D5TUehDTV2DQxmGKz5x6IsU/MTRMjghAGKUFRPNd1njzejYl9IoAu++YtoLiYjlPAlrX2wLJIji/on5umopz7i0PJMVacs3viTYK4kxdIac3/68aq3CJtezrXyny3lZp9mPX/DHqs3fB/bzqw7SPhJcg5+IdxfIrJeTI/sMHJGCQEBV9rKPsj+wwMa1zMfh6Gw/SFxhPw1iK 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)(396003)(346002)(136003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(5660300002)(36860700001)(44832011)(82740400003)(47076005)(26005)(81166007)(40480700001)(2906002)(316002)(54906003)(110136005)(478600001)(40460700003)(1076003)(356005)(336012)(426003)(82310400005)(2616005)(186003)(16526019)(8936002)(41300700001)(86362001)(36756003)(6666004)(70206006)(70586007)(8676002)(4326008)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2022 15:56:55.8110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37a5486f-f788-4118-1abe-08da9a5793de 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: CO1NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4287 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 --- v2: no changes 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 Mon Sep 19 15:56:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 607680 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 5200BC6FA86 for ; Mon, 19 Sep 2022 15:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbiISP5T (ORCPT ); Mon, 19 Sep 2022 11:57:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiISP5S (ORCPT ); Mon, 19 Sep 2022 11:57:18 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2054.outbound.protection.outlook.com [40.107.244.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF65910544; Mon, 19 Sep 2022 08:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NhOOe4EiocUMCCZso36NSn+Zfmq3nMqD32PTQRKA0iWo47o+gvvizRH9MGPFnZovYQ9HwxQjWhk2RjhvVFjx1asflbdWQHTmEj1/A+Yn4gprUEzLTHAf7Fg9gO33MyB8lI3JYDTX+Ojw+V+db2uW1O5QggQTxEWwftbEnGGsv189xRNymyKjvSSjYhhusUm9gWSBnHf/pLR9SVM2GsmEbp2+5DTxpuzFmSaWW0x8zGkQRSHvsVQqOFmUQeThBu4++xU1mf332kUQfhikYGskkmxBGSNkJ8wvBcmhI6zp36gWu8LTNkWna4VjOvNtNtE/nUeYTDfNuz6e3cniNfawrA== 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=OzcmikmZ3O8qk+Tp6UNoyLo2uEXUGdDF7nXUHRdSzwE=; b=JPWxPLA1HenoJ8G4KSMPSOqwgdRR3mkm0mnd0nWKy2oMEqE7Q5+SOqtY51c1gT9uAnR6Uq5wzOScLYNyVd+TZ5ZmkPdiyqm/d9iTieN1udgDG8LtbDXda58u8+aRCgfMUP7sIVoiPSchwy99DO9/lBXV2ri1y9tJgFPRO09vZOapvYhGF7sYH1yNfjyOrTn1zlJ4dg2GRTOAM5XqXWUF613Tk5UnM45logWtig7L5wqbW/+X7rejHE8zlGjuBbeb5z2aUDcgce5hOc5wBXJWw/pgBAg1gq6A4a6+JxGB4quw8fzuiIm9abFjlohz8Pc6PHapUbRaVjjxgA7oYTQe1A== 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=OzcmikmZ3O8qk+Tp6UNoyLo2uEXUGdDF7nXUHRdSzwE=; b=Vsq1N/Lpi4NblSl4prSdcqn7QbVFPMnWs6f8Krqsjgj2szuSw7uyl4nWPTXEuEcfpwlvkmp7+Crz+XOgn2jhF9U1vuJtD800naeQLQhNEr8V/72rCqkILkrcS1/idgzp0T7nQ68m3dCf4r08hvaNM0/pIHEBqwOxfAVrx4mOmfs= Received: from MW4PR03CA0175.namprd03.prod.outlook.com (2603:10b6:303:8d::30) by DS7PR12MB6358.namprd12.prod.outlook.com (2603:10b6:8:95::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Mon, 19 Sep 2022 15:57:15 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::a5) by MW4PR03CA0175.outlook.office365.com (2603:10b6:303:8d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21 via Frontend Transport; Mon, 19 Sep 2022 15:57:15 +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 CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5632.12 via Frontend Transport; Mon, 19 Sep 2022 15:57:14 +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; Mon, 19 Sep 2022 10:57:06 -0500 From: Kim Phillips To: , CC: , , , Mike Day , , Kim Phillips , Subject: [PATCH v2 2/2] iommu/amd: Fix ill-formed ivrs_ioapic, ivrs_hpet and ivrs_acpihid options Date: Mon, 19 Sep 2022 10:56:38 -0500 Message-ID: <20220919155638.391481-2-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919155638.391481-1-kim.phillips@amd.com> References: <20220919155638.391481-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT085:EE_|DS7PR12MB6358:EE_ X-MS-Office365-Filtering-Correlation-Id: 4404d3c7-6259-440a-e4b9-08da9a579f34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wa8FvQun4ezEBUVy3t3T12UsaTQn2R+Zy0iQZAWgka11og+LKz1zkGzCrpLk6F+CnkQHarHBwHyXmiDI8ynL1X5jGexvY46369OQ9Y5J7DlG+ozxniKliOzf+41bxoWSHwAA0htrYqdxdPe2XqM1AN9OZPXVptDci8NhnAGXiKjCXHGD5u9yWUaZycnaqUcABxk096UlzjLzrzaENdhHmOHKhKFZMzyWStC+ckkGmvsZcbekwar4EwO+2ILj4qAO7o5WFmn10f8qzcocbO2ONUnzBnfaP9w4YONuGJbr+Hrrcg8d0eymw1yo7Ci4bdqbcbCyejHT9/DOhF3kCDIZMt1H+8PNUTY8ptZSx7mGOhA29WMucXbjElMFv3RR48X6byFf13VpmFtgeE2QHsNP22qnVnLgpFcN+uoYEiYjswWZUhVnDxKE+SftO4CBG0ycmC7gUsSsmCKLo0hYE+sH5/TFuzyjrMK60gEgOtKr4jcrOqRx1ncJyY9Layh2vfg/1JB5wDGpDrpVj+bLCRKr4/346R+guLm8w+6jM58pAhxevBgQxQknkk6gOWpdEz9ZiaunxR3MbMjfe2X6rG1hjawAv1DlzHPfc0LiNsSI1bYkyB5bKeM2GrcLeJ/fFTcySzblp9zSjwLj85WliSyUqD5PX7Xa2YgVIS54ZlsW2MDosH+Qg6VtilOGrIyxjKgc5iOd5s2jcDaarfmXWwmdqTiMNg58rQXp6ZDRwJrZYDSkai41M4Tg2+isYQbPm01Y9OX9btfbBqVkKXl0JX/PrnwTx0fIFR2nsSBMzJwCN9p43pW0xUgNBo6Yb3C8SjxnjvvZOFGCVFDK5ZhJApByNA== 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)(346002)(39860400002)(376002)(136003)(396003)(451199015)(40470700004)(46966006)(36840700001)(36860700001)(44832011)(4326008)(36756003)(478600001)(110136005)(966005)(70206006)(70586007)(54906003)(41300700001)(7696005)(6666004)(86362001)(2616005)(8936002)(82310400005)(81166007)(26005)(356005)(336012)(40460700003)(16526019)(83380400001)(5660300002)(40480700001)(82740400003)(8676002)(316002)(186003)(1076003)(47076005)(426003)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2022 15:57:14.8347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4404d3c7-6259-440a-e4b9-08da9a579f34 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: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6358 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 --- v2: - Address Robin Murphy's comment: Have deprecated users see: "option format deprecated; use ivrs_ioapic=%d@%04x:%02x:%02x.%d instead" - Fix cut-n-paste bug: ivrs_ioapic= -> ivrs_hpet= .../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..77f780ad343e 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_hpet=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..6601b677c250 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("ivrs_ioapic%s option format deprecated; use ivrs_ioapic=%d@%04x:%02x:%02x.%d instead\n", + str, id, seg, bus, dev, fn); + 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("ivrs_hpet%s option format deprecated; use ivrs_hpet=%d@%04x:%02x:%02x.%d instead\n", + str, id, seg, bus, dev, fn); + 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("ivrs_acpihid%s option format deprecated; use ivrs_acpihid=%s@%04x:%02x:%02x.%d instead\n", + str, acpiid, seg, bus, dev, fn); + 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;