* [PATCH] ACPI: make some IO ports off-limits to AML
@ 2009-02-04 3:59 Len Brown
2009-02-04 6:15 ` Matthew Garrett
0 siblings, 1 reply; 3+ messages in thread
From: Len Brown @ 2009-02-04 3:59 UTC (permalink / raw)
To: linux-acpi; +Cc: Linux Kernel Mailing List
From: Len Brown <len.brown@intel.com>
ACPICA exports acpi_os_validate_address() so the OS
can prevent BIOS AML from accessing specified addresses.
Start using this interface to prevent AML from accessing
some well known IO addresses that the OS "owns".
Signed-off-by: Len Brown <len.brown@intel.com>
---
drivers/acpi/osl.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 6729a49..4fb01b0 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1317,6 +1317,54 @@ acpi_os_validate_interface (char *interface)
return AE_SUPPORT;
}
+#ifdef CONFIG_X86
+
+struct aml_port_desc {
+ uint start;
+ uint end;
+ char* name;
+ char warned;
+};
+
+static struct aml_port_desc aml_invalid_port_list[] = {
+ {0x20, 0x21, "PIC0", 0},
+ {0xA0, 0xA1, "PIC1", 0},
+ {0x4D0, 0x4D1, "ELCR", 0}
+};
+
+/*
+ * valid_aml_io_address()
+ *
+ * if valid, return true
+ * else invalid, warn once, return false
+ */
+static bool valid_aml_io_address(uint address, uint length)
+{
+ int i;
+ int entries = sizeof(aml_invalid_port_list) / sizeof(struct aml_port_desc);
+
+ for (i = 0; i < entries; ++i) {
+ if ((address >= aml_invalid_port_list[i].start &&
+ address <= aml_invalid_port_list[i].end) ||
+ (address + length >= aml_invalid_port_list[i].start &&
+ address + length <= aml_invalid_port_list[i].end))
+ {
+ if (!aml_invalid_port_list[i].warned)
+ {
+ printk(KERN_ERR "ACPI: Denied BIOS AML access"
+ " to invalid port 0x%x+0x%x (%s)\n",
+ address, length,
+ aml_invalid_port_list[i].name);
+ aml_invalid_port_list[i].warned = 1;
+ }
+ return false; /* invalid */
+ }
+ }
+ return true; /* valid */
+}
+#else
+static inline bool valid_aml_io_address(uint address, uint length) { return true; }
+#endif
/******************************************************************************
*
* FUNCTION: acpi_os_validate_address
@@ -1346,6 +1394,8 @@ acpi_os_validate_address (
switch (space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ if (!valid_aml_io_address(address, length))
+ return AE_AML_ILLEGAL_ADDRESS;
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
/* Only interference checks against SystemIO and SytemMemory
are needed */
--
1.6.1.2.319.gbd9e
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ACPI: make some IO ports off-limits to AML
2009-02-04 3:59 [PATCH] ACPI: make some IO ports off-limits to AML Len Brown
@ 2009-02-04 6:15 ` Matthew Garrett
2009-03-28 1:30 ` Len Brown
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Garrett @ 2009-02-04 6:15 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, Linux Kernel Mailing List
On Tue, Feb 03, 2009 at 10:59:43PM -0500, Len Brown wrote:
> Start using this interface to prevent AML from accessing
> some well known IO addresses that the OS "owns".
It might be nice to extend this to cover the other ports listed at
http://www.microsoft.com/whdc/archive/BIOSAML.mspx if (and only if) the
firmware requested _OSI("Windows 2001") or later.
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ACPI: make some IO ports off-limits to AML
2009-02-04 6:15 ` Matthew Garrett
@ 2009-03-28 1:30 ` Len Brown
0 siblings, 0 replies; 3+ messages in thread
From: Len Brown @ 2009-03-28 1:30 UTC (permalink / raw)
To: Matthew Garrett; +Cc: linux-acpi, Linux Kernel Mailing List
On Wed, 4 Feb 2009, Matthew Garrett wrote:
> On Tue, Feb 03, 2009 at 10:59:43PM -0500, Len Brown wrote:
>
> > Start using this interface to prevent AML from accessing
> > some well known IO addresses that the OS "owns".
>
> It might be nice to extend this to cover the other ports listed at
> http://www.microsoft.com/whdc/archive/BIOSAML.mspx if (and only if) the
> firmware requested _OSI("Windows 2001") or later.
Right. We reverted this initialization-time check for 2.6.29
b/c it had false positives of opregions that were never used.
For 2.6.30 we replaced it with a run-time check, and the check
follows the compatibility rules referenced above.
http://git.kernel.org/?p=linux/kernel/git/lenb/linux-acpi-2.6.git;a=commitdiff;h=7f0719039085cc40114abce84cf29fe57da226f4
cheers,
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-28 1:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-04 3:59 [PATCH] ACPI: make some IO ports off-limits to AML Len Brown
2009-02-04 6:15 ` Matthew Garrett
2009-03-28 1:30 ` Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox