From patchwork Fri Apr 24 02:25:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhao, Yakui" X-Patchwork-Id: 19719 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3O2OZK0010261 for ; Fri, 24 Apr 2009 02:24:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbZDXCYe (ORCPT ); Thu, 23 Apr 2009 22:24:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755181AbZDXCYe (ORCPT ); Thu, 23 Apr 2009 22:24:34 -0400 Received: from mga09.intel.com ([134.134.136.24]:41051 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706AbZDXCYd (ORCPT ); Thu, 23 Apr 2009 22:24:33 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 23 Apr 2009 19:14:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.40,238,1239001200"; d="scan'208";a="509486978" Received: from yakui_zhao.sh.intel.com (HELO [10.239.36.120]) ([10.239.36.120]) by orsmga001.jf.intel.com with ESMTP; 23 Apr 2009 19:23:42 -0700 Subject: [PATCH]: ACPI: Add the module param check for processor.max_cstate From: yakui_zhao To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org Organization: Intel Open Source Technology Center Date: Fri, 24 Apr 2009 10:25:12 +0800 Message-Id: <1240539912.3651.68.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Zhao Yakui 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 --- drivers/acpi/processor_idle.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);