public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: yakui_zhao <yakui.zhao@intel.com>
To: lenb@kernel.org
Cc: linux-acpi@vger.kernel.org
Subject: [PATCH]: ACPI: Add the module param check for processor.max_cstate
Date: Fri, 24 Apr 2009 10:25:12 +0800	[thread overview]
Message-ID: <1240539912.3651.68.camel@localhost.localdomain> (raw)

From: Zhao Yakui <yakui.zhao@intel.com>

When the boot option of "processor.max_cstate=0" is added, the C-state 
won't be configured correctly. In such case the cpu idle function will access
the uninitialized memory region and then kernel panic will happen.

So it is necessary to add the module param check for the processor.max_cstate.
If it is equal to or less than zero, it will be ignored. If it is beyond the
max threshold, it is also ignored.

http://bugzilla.kernel.org/show_bug.cgi?id=13142

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
---
 drivers/acpi/processor_idle.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/processor_idle.c
===================================================================
--- linux-2.6.orig/drivers/acpi/processor_idle.c	2009-04-21 15:48:52.000000000 +0800
+++ linux-2.6/drivers/acpi/processor_idle.c	2009-04-24 10:00:47.000000000 +0800
@@ -70,7 +70,32 @@
 #define PM_TIMER_TICKS_TO_US(p)		(((p) * 1000)/(PM_TIMER_FREQUENCY/1000))
 
 static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
-module_param(max_cstate, uint, 0000);
+
+static int param_set_max_cstate(const char *val, struct kernel_param *kp)
+{
+	unsigned long cstate = 0;
+	int ret = 0;
+
+	if (!val)
+		return -EINVAL;
+
+	ret = strict_strtoul(val, 10, &cstate);
+	if (ret == -EINVAL || (unsigned int)cstate != cstate)
+		return -EINVAL;
+	/*
+	 * if the value is equal to or less than zero, it will be ingored.
+	 * Of course it will also be ignored if it is bigger than the
+	 * threshold of ACPI_PROCESSOR_MAX_POWER.
+	 */
+	if (cstate <= 0 || cstate > ACPI_PROCESSOR_MAX_POWER)
+		return -EINVAL;
+
+	max_cstate = cstate;
+
+	return 0;
+}
+module_param_call(max_cstate, param_set_max_cstate, NULL,
+		  &max_cstate, 0000);
 static unsigned int nocst __read_mostly;
 module_param(nocst, uint, 0000);
 



             reply	other threads:[~2009-04-24  2:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-24  2:25 yakui_zhao [this message]
2009-04-24  3:24 ` [PATCH]: ACPI: Add the module param check for processor.max_cstate Len Brown
2009-04-24  3:30   ` yakui_zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1240539912.3651.68.camel@localhost.localdomain \
    --to=yakui.zhao@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox