Skip to contentSkip to conversation

x86: ignore unspecified bit positions in the ACPI global lock field

PATCH Applied Jan Engelhardt 2 participants 4 messages Mar 5, 2020 – Mar 19, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: ignore unspecified bit positions in the ACPI global lock field

The value in "new" is constructed from "old" such that all bits defined as reserved by the ACPI spec[1] are left untouched. But if those bits do not happen to be all zero, "new < 3" will not evaluate to true.

The firmware of the laptop(s) Medion MD63490 / Akoya P15648 comes with garbage inside the "FACS" ACPI table. The starting value is old=0x4944454d, therefore new=0x4944454e, which is >= 3. Mask off the reserved bits.

[1] https://uefi.org/sites/default/files/resources/ACPI_6_2.pdf

References: https://bugzilla.kernel.org/show_bug.cgi?id=206553

---
 arch/x86/kernel/acpi/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/acpi/boot.c +1 -1
index 04205ce127a1..f9e84a0e2fa2 100644
@@ -1740,7 +1740,7 @@ int __acpi_acquire_global_lock(unsigned int *lock)
 		new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
 		val = cmpxchg(lock, old, new);
 	} while (unlikely (val != old));
-	return (new < 3) ? -1 : 0;
+	return ((new & 0x3) < 3) ? -1 : 0;
 }
 
 int __acpi_release_global_lock(unsigned int *lock)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 23 lines · CET Jan Engelhardt

The value in "new" is constructed from "old" such that all bits defined as reserved by the ACPI spec[1] are left untouched. But if those bits do not happen to be all zero, "new < 3" will not evaluate to true.

The firmware of the laptop(s) Medion MD63490 / Akoya P15648 comes with garbage inside the "FACS" ACPI table. The starting value is old=0x4944454d, therefore new=0x4944454e, which is >= 3. Mask off the reserved bits.

[1] https://uefi.org/sites/default/files/resources/ACPI_6_2.pdf

References: https://bugzilla.kernel.org/show_bug.cgi?id=206553

---
 arch/x86/kernel/acpi/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/acpi/boot.c +0 -0
index 04205ce127a1..f9e84a0e2fa2 100644

arch/x86/kernel/acpi/boot.c int __acpi_acquire_global_lock(unsigned int *lock) · line 1746

Quoted 8 lines
arch/x86/kernel/acpi/boot.c +1 -1
@@ -1740,7 +1740,7 @@ int __acpi_acquire_global_lock(unsigned int *lock)
 		new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
 		val = cmpxchg(lock, old, new);
 	} while (unlikely (val != old));
-	return (new < 3) ? -1 : 0;
+	return ((new & 0x3) < 3) ? -1 : 0;
 }
 
 int __acpi_release_global_lock(unsigned int *lock)

Applied as 5.7 material, thanks!

#2 lore raw
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · CET Jan Engelhardt

The value in "new" is constructed from "old" such that all bits defined as reserved by the ACPI spec[1] are left untouched. But if those bits do not happen to be all zero, "new < 3" will not evaluate to true.

The firmware of the laptop(s) Medion MD63490 / Akoya P15648 comes with garbage inside the "FACS" ACPI table. The starting value is old=0x4944454d, therefore new=0x4944454e, which is >= 3. Mask off the reserved bits.

Quoted 4 lines

arch/x86/kernel/acpi/boot.c int __acpi_acquire_global_lock(unsigned int *lock) · line 1743

Quoted 2 lines
arch/x86/kernel/acpi/boot.c +1 -1
-	return (new < 3) ? -1 : 0;
+	return ((new & 0x3) < 3) ? -1 : 0;

Applied as 5.7 material, thanks!

Would it make sense to funnel this into the upcoming 5.6?

#3 lore raw
Quoted 12 lines · CET Jan Engelhardt
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · CET Jan Engelhardt

The value in "new" is constructed from "old" such that all bits defined as reserved by the ACPI spec[1] are left untouched. But if those bits do not happen to be all zero, "new < 3" will not evaluate to true.

The firmware of the laptop(s) Medion MD63490 / Akoya P15648 comes with garbage inside the "FACS" ACPI table. The starting value is old=0x4944454d, therefore new=0x4944454e, which is >= 3. Mask off the reserved bits.

Quoted 7 lines
Quoted 4 lines

arch/x86/kernel/acpi/boot.c int __acpi_acquire_global_lock(unsigned int *lock) · line 1743

Quoted 2 lines
arch/x86/kernel/acpi/boot.c +1 -1
-	return (new < 3) ? -1 : 0;
+	return ((new & 0x3) < 3) ? -1 : 0;

Applied as 5.7 material, thanks!

Would it make sense to funnel this into the upcoming 5.6?

It's been marked for -stable, so it will get into 5.6.y early.

Hopefully, it will get some extra test coverage before that.