diff options
| author | Mario Limonciello <mario.limonciello@amd.com> | 2026-09-08 14:34:58 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2026-09-10 16:27:07 +0200 |
| commit | 3107a9a3241d6b585cbc08c7035b03fa44e9fb94 (patch) | |
| tree | 2c3369324049fa201c033a5993f83556f59d21d6 /include/acpi | |
| parent | 78ddbfaa72d68acc98cd5ba12eca071d452702c4 (diff) | |
ACPI: utils: Ignore leading root scope prefix in string _UID match
Firmware may express an ACPI namespace path used as a _UID with or
without the leading root scope character ('\'). For example, an AMD
IVRS IVHD ACPI HID device entry may carry a character UID of
"\_SB.MHSP" while the corresponding device's _UID evaluates to
"_SB.MHSP" (or vice versa). This semantic difference is due to how
Windows PnP enumerates and uses devices.
acpi_str_uid_match() compared the two strings verbatim, so such
entries failed to match on the UID even though they refer to the same
object. In the AMD IOMMU case (get_acpihid_device_id()) this caused
the exact HID+UID match to be missed and the code to fall through to
the HID-only path, spuriously raising a FW_BUG.
Skip a single leading '\' on either string before comparing so that
paths that differ only by the root scope prefix are treated as a
match. The integer _UID path is unaffected.
[ rjw: It is sad that making this change needed to be considered at all.
That being said, it is also rather unlikely that someone will use a
leading backslash as the only difference to distinguish one UID
string from antother, so this change is unlikely to break anything. ]
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
[ rjw: Added separator line to a kerneldoc comment ]
[ rjw: Droppend Link: tag with a limited access target ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/acpi')
| -rw-r--r-- | include/acpi/acpi_bus.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a10a591c18b2..22be27e02682 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -830,7 +830,15 @@ static inline bool acpi_str_uid_match(struct acpi_device *adev, const char *uid2 { const char *uid1 = acpi_device_uid(adev); - return uid1 && uid2 && !strcmp(uid1, uid2); + if (!uid1 || !uid2) + return false; + + if (*uid1 == '\\' && uid1[1]) + uid1++; + if (*uid2 == '\\' && uid2[1]) + uid2++; + + return !strcmp(uid1, uid2); } static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2) @@ -857,6 +865,10 @@ static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2) * * Matches UID in @adev with given @uid2. * + * If both the UID in @adev and @uid2 are strings, they are compared + * after optionally skipping a leading backslash ('\') if the given + * string contains additional characters. + * * Returns: %true if matches, %false otherwise. */ #define acpi_dev_uid_match(adev, uid2) \ |
