public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: add "auto" to acpi_enforce_resources
@ 2009-01-25 21:05 Luca Tettamanti
  2009-01-26  8:37 ` Hans de Goede
  2009-01-29 10:30 ` Thomas Renninger
  0 siblings, 2 replies; 45+ messages in thread
From: Luca Tettamanti @ 2009-01-25 21:05 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-kernel, Hans de Goede, Len Brown

(This is an improved version of my earlier patch, I've reworked deviced
detection to simply check for the desired HID)

The following patch adds "auto" option to "acpi_enforce_resource"; this value
is also the new default.
"auto" enforces strict resource checking - disallowing access by native drivers
to IO ports and memory regions claimed by ACPI firmware - when a device with a
known ACPI driver is found (currently only ASUS ATK0110 is checked), and
reverts to lax checking otherwise.

The patch is mainly aimed to block native hwmon drivers from touching
monitoring chips that ACPI thinks it own.

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
---
New revision, now it simply checks the HID.

 Documentation/kernel-parameters.txt |   19 ++++++++++++++++
 drivers/acpi/osl.c                  |   41 +++++++++++++++++++++++++++++++++---
 2 files changed, 57 insertions(+), 3 deletions(-)

Index: b/Documentation/kernel-parameters.txt
===================================================================
--- a/Documentation/kernel-parameters.txt	2009-01-17 21:22:49.218882286 +0100
+++ b/Documentation/kernel-parameters.txt	2009-01-21 23:25:41.262478018 +0100
@@ -258,6 +258,25 @@
 			to assume that this machine's pmtimer latches its value
 			and always returns good values.
 
+	acpi_enforce_resources=	[ACPI]
+			{ strict, auto, lax, no }
+			Check for resource conflicts between native drivers
+			and ACPI OperationRegions (SystemIO and System Memory
+			only). IO ports and memory declared in ACPI might be
+			used by the ACPI subsystem in arbitrary AML code and
+			can interfere with legacy drivers.
+			strict: access to resources claimed by ACPI is denied;
+			legacy drivers trying to access reserved resources
+			will fail to load.
+			auto (default): try and detect ACPI devices with known
+			ACPI drivers; escalates the setting to "strict" if such
+			a device is found, otherwise behaves like "lax".
+			lax: access to resources claimed by ACPI is allowed;
+			legacy drivers trying to access reserved resources
+			will load and a warning message is logged.
+			no: ACPI OperationRegions are not marked as reserved,
+			no further checks are performed.
+
 	agp=		[AGP]
 			{ off | try_unsupported }
 			off: disable AGP support
Index: b/drivers/acpi/osl.c
===================================================================
--- a/drivers/acpi/osl.c	2009-01-17 21:22:49.190882303 +0100
+++ b/drivers/acpi/osl.c	2009-01-25 22:04:30.759209000 +0100
@@ -1063,7 +1063,10 @@
  * in arbitrary AML code and can interfere with legacy drivers.
  * acpi_enforce_resources= can be set to:
  *
- *   - strict           (2)
+ *   - auto             (2)
+ *     -> detect possible conflicts with ACPI drivers and switch to
+ *     strict if needed, otherwise act like lax
+ *   - strict           (3)
  *     -> further driver trying to access the resources will not load
  *   - lax (default)    (1)
  *     -> further driver trying to access the resources will load, but you
@@ -1073,11 +1076,12 @@
  *     -> ACPI Operation Region resources will not be registered
  *
  */
-#define ENFORCE_RESOURCES_STRICT 2
+#define ENFORCE_RESOURCES_STRICT 3
+#define ENFORCE_RESOURCES_AUTO   2
 #define ENFORCE_RESOURCES_LAX    1
 #define ENFORCE_RESOURCES_NO     0
 
-static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
+static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_AUTO;
 
 static int __init acpi_enforce_resources_setup(char *str)
 {
@@ -1086,6 +1090,8 @@
 
 	if (!strcmp("strict", str))
 		acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
+	else if (!strcmp("auto", str))
+		acpi_enforce_resources = ENFORCE_RESOURCES_AUTO;
 	else if (!strcmp("lax", str))
 		acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
 	else if (!strcmp("no", str))
@@ -1096,6 +1102,35 @@
 
 __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
 
+static acpi_status acpi_detect_asus_atk_cb(acpi_handle obj_handle,
+		u32 nesting_level, void *context, void **return_value)
+{
+	*((bool *)return_value) = true;
+	return AE_CTRL_TERMINATE;
+}
+
+static int __init acpi_detect_asus_atk(void)
+{
+	acpi_status ret;
+	bool found = false;
+
+	if (acpi_enforce_resources != ENFORCE_RESOURCES_AUTO)
+		return 0;
+
+	ret = acpi_get_devices("ATK0110", acpi_detect_asus_atk_cb,
+			NULL, (void **)&found);
+
+	if (ret == AE_OK && found) {
+		printk(KERN_DEBUG "Asus ATK0110 interface detected: "
+				"enforcing resource checking.\n");
+		acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
+	} else
+		acpi_enforce_resources =  ENFORCE_RESOURCES_LAX;
+
+	return 0;
+}
+fs_initcall(acpi_detect_asus_atk);
+
 /* Check for resource conflicts between ACPI OperationRegions and native
  * drivers */
 int acpi_check_resource_conflict(struct resource *res)


Luca
-- 
La vasca da bagno fu inventata nel 1850, il telefono nel 1875.
Se fossi vissuto nel 1850, avrei potuto restare in vasca per 25 anni
senza sentir squillare il telefono

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2009-04-03  9:40 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-25 21:05 [PATCH] ACPI: add "auto" to acpi_enforce_resources Luca Tettamanti
2009-01-26  8:37 ` Hans de Goede
2009-01-29 10:30 ` Thomas Renninger
2009-01-29 15:16   ` Luca Tettamanti
2009-01-29 16:29     ` Thomas Renninger
2009-01-29 18:58       ` Hans de Goede
2009-01-29 21:31         ` Jean Delvare
2009-01-30 14:29         ` Thomas Renninger
2009-02-01 21:22           ` Luca Tettamanti
2009-02-02  9:11             ` Jean Delvare
2009-02-02 11:38               ` Luca Tettamanti
2009-02-02 17:22                 ` [PATCH 1/2] RFC: ACPI: Interface for ACPI drivers to place quirk code which gets executed early Thomas Renninger
2009-02-02 20:22                   ` Luca Tettamanti
2009-02-03 13:08                     ` Thomas Renninger
2009-02-03 13:45                       ` Luca Tettamanti
2009-02-03 14:19                         ` Jean Delvare
2009-02-04 13:37                     ` Thomas Renninger
2009-02-02 17:22                 ` [PATCH 2/2] RFC: ACPI: Set enforce_resources to strict if a ATK0110 device is found in namespace Thomas Renninger
2009-02-02 20:29                   ` Luca Tettamanti
2009-02-02 11:38             ` [PATCH] ACPI: add "auto" to acpi_enforce_resources Thomas Renninger
2009-01-29 21:15       ` Luca Tettamanti
2009-02-04  5:52     ` Len Brown
2009-02-04  6:05       ` Matthew Garrett
2009-02-04  8:37         ` Hans de Goede
2009-02-04 13:17           ` Matthew Garrett
2009-02-04 13:26             ` Jean Delvare
2009-02-04 14:20               ` Matthew Garrett
2009-02-10 13:57                 ` Jean Delvare
2009-02-10 14:08                   ` Matthew Garrett
2009-02-10 15:32                     ` Hans de Goede
2009-02-10 16:24                       ` Jean Delvare
2009-02-27 13:27                         ` Pavel Machek
2009-03-24 12:39                           ` Luca Tettamanti
2009-03-24 13:21                             ` Hans de Goede
2009-03-24 13:43                               ` Jean Delvare
2009-03-24 14:29                                 ` Hans de Goede
2009-03-29 20:16                               ` Luca Tettamanti
2009-03-29 20:33                                 ` Pavel Machek
2009-03-29 20:55                                 ` Jean Delvare
2009-03-29 22:01                                   ` Luca Tettamanti
2009-03-30  7:36                                     ` Jean Delvare
2009-04-02 22:59                                     ` Len Brown
2009-04-03  9:40                                       ` Jean Delvare
2009-02-12 12:44                     ` Jean Delvare
2009-04-02 22:45         ` polling (Re: [PATCH] ACPI: add "auto" to acpi_enforce_resources) Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox