From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73BF26FA0 for ; Mon, 16 Jan 2023 17:13:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAC63C433EF; Mon, 16 Jan 2023 17:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673889187; bh=/+XKC0htm1YV3EoS/KhypXJSvwoj19uRRydTrVjasaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xjQ5ByWl3bXIRx0wicy3WRBcHm1uQFWxuXa7ogt5hD+m4wfRhMow6ufouWKkiauDS nDHW4WSoI60aIzRivOi/TXe/rMRhWPHYbJ74QYYLBNYJ2Xe/368QXx12H4uCg/kYvY hkIB6Rzf0LFjxqaZ9KtFtfmNKdkmX3Q5f9tn4pck= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kim Phillips , Suravee Suthikulpanit , Joerg Roedel Subject: [PATCH 4.14 292/338] iommu/amd: Fix ivrs_acpihid cmdline parsing code Date: Mon, 16 Jan 2023 16:52:45 +0100 Message-Id: <20230116154833.809653860@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154820.689115727@linuxfoundation.org> References: <20230116154820.689115727@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Kim Phillips commit 5f18e9f8868c6d4eae71678e7ebd4977b7d8c8cf upstream. 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 Link: https://lore.kernel.org/r/20220919155638.391481-1-kim.phillips@amd.com Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/amd_iommu_init.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -2919,6 +2919,13 @@ static int __init parse_ivrs_acpihid(cha 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));