Jiri Slaby ef7db2
From: Mario Limonciello <mario.limonciello@amd.com>
Jiri Slaby ef7db2
Date: Thu, 15 Dec 2022 09:51:20 -0600
Jiri Slaby ef7db2
Subject: [PATCH] ACPICA: Drop port I/O validation for some regions
Jiri Slaby ef7db2
References: bsc#1012628
Jiri Slaby ef7db2
Patch-mainline: 6.2.3
Jiri Slaby ef7db2
Git-commit: e1d9148582ab2c3dada5c5cf8ca7531ca269fee5
Jiri Slaby ef7db2
Jiri Slaby ef7db2
[ Upstream commit e1d9148582ab2c3dada5c5cf8ca7531ca269fee5 ]
Jiri Slaby ef7db2
Jiri Slaby ef7db2
Microsoft introduced support in Windows XP for blocking port I/O
Jiri Slaby ef7db2
to various regions.  For Windows compatibility ACPICA has adopted
Jiri Slaby ef7db2
the same protections and will disallow writes to those
Jiri Slaby ef7db2
(presumably) the same regions.
Jiri Slaby ef7db2
Jiri Slaby ef7db2
On some systems the AML included with the firmware will issue 4 byte
Jiri Slaby ef7db2
long writes to 0x80.  These writes aren't making it over because of this
Jiri Slaby ef7db2
blockage. The first 4 byte write attempt is rejected, and then
Jiri Slaby ef7db2
subsequently 1 byte at a time each offset is tried. The first at 0x80
Jiri Slaby ef7db2
works, but then the next 3 bytes are rejected.
Jiri Slaby ef7db2
Jiri Slaby ef7db2
This manifests in bizarre failures for devices that expected the AML to
Jiri Slaby ef7db2
write all 4 bytes.  Trying the same AML on Windows 10 or 11 doesn't hit
Jiri Slaby ef7db2
this failure and all 4 bytes are written.
Jiri Slaby ef7db2
Jiri Slaby ef7db2
Either some of these regions were wrong or some point after Windows XP
Jiri Slaby ef7db2
some of these regions blocks have been lifted.
Jiri Slaby ef7db2
Jiri Slaby ef7db2
In the last 15 years there doesn't seem to be any reports popping up of
Jiri Slaby ef7db2
this error in the Windows event viewer anymore.  There is no documentation
Jiri Slaby ef7db2
at Microsoft's developer site indicating that Windows ACPI interpreter
Jiri Slaby ef7db2
blocks these regions. Between the lack of documentation and the fact that
Jiri Slaby ef7db2
the writes actually do work in Windows 10 and 11, it's quite likely
Jiri Slaby ef7db2
Windows doesn't actually enforce this anymore.
Jiri Slaby ef7db2
Jiri Slaby ef7db2
So to help the issue, only enforce Windows XP specific entries if the
Jiri Slaby ef7db2
latest _OSI supported is Windows XP. Continue to enforce the
Jiri Slaby ef7db2
ALWAYS_ILLEGAL entries.
Jiri Slaby ef7db2
Jiri Slaby ef7db2
Link: https://github.com/acpica/acpica/pull/817
Jiri Slaby ef7db2
Fixes: 7f0719039085 ("ACPICA: New: I/O port protection")
Jiri Slaby ef7db2
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Jiri Slaby ef7db2
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Jiri Slaby ef7db2
Signed-off-by: Sasha Levin <sashal@kernel.org>
Jiri Slaby ef7db2
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Jiri Slaby ef7db2
---
Jiri Slaby ef7db2
 drivers/acpi/acpica/hwvalid.c | 7 ++++---
Jiri Slaby ef7db2
 1 file changed, 4 insertions(+), 3 deletions(-)
Jiri Slaby ef7db2
Jiri Slaby ef7db2
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
Jiri Slaby ef7db2
index 915b2644..0d392e7b 100644
Jiri Slaby ef7db2
--- a/drivers/acpi/acpica/hwvalid.c
Jiri Slaby ef7db2
+++ b/drivers/acpi/acpica/hwvalid.c
Jiri Slaby ef7db2
@@ -23,8 +23,8 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width);
Jiri Slaby ef7db2
  *
Jiri Slaby ef7db2
  * The table is used to implement the Microsoft port access rules that
Jiri Slaby ef7db2
  * first appeared in Windows XP. Some ports are always illegal, and some
Jiri Slaby ef7db2
- * ports are only illegal if the BIOS calls _OSI with a win_XP string or
Jiri Slaby ef7db2
- * later (meaning that the BIOS itelf is post-XP.)
Jiri Slaby ef7db2
+ * ports are only illegal if the BIOS calls _OSI with nothing newer than
Jiri Slaby ef7db2
+ * the specific _OSI strings.
Jiri Slaby ef7db2
  *
Jiri Slaby ef7db2
  * This provides ACPICA with the desired port protections and
Jiri Slaby ef7db2
  * Microsoft compatibility.
Jiri Slaby ef7db2
@@ -145,7 +145,8 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width)
Jiri Slaby ef7db2
 
Jiri Slaby ef7db2
 			/* Port illegality may depend on the _OSI calls made by the BIOS */
Jiri Slaby ef7db2
 
Jiri Slaby ef7db2
-			if (acpi_gbl_osi_data >= port_info->osi_dependency) {
Jiri Slaby ef7db2
+			if (port_info->osi_dependency == ACPI_ALWAYS_ILLEGAL ||
Jiri Slaby ef7db2
+			    acpi_gbl_osi_data == port_info->osi_dependency) {
Jiri Slaby ef7db2
 				ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
Jiri Slaby ef7db2
 						  "Denied AML access to port 0x%8.8X%8.8X/%X (%s 0x%.4X-0x%.4X)\n",
Jiri Slaby ef7db2
 						  ACPI_FORMAT_UINT64(address),
Jiri Slaby ef7db2
-- 
Jiri Slaby ef7db2
2.35.3
Jiri Slaby ef7db2