2015-05-20 11:25:46

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH] mce: fix fail to set 'monarchtimeout' via boot option

I use "mce=1,10000000" in cmdline to change the monarch timeout, but
it does not work.

The cause is that get_option() has parsed the ',' already, we need
not to check the ',' again.

--
get_option(): read an int from an option string;
if available accept a subsequent comma as well.

Return values:
0 - no int in string
1 - int found, no subsequent comma
2 - int found including a subsequent comma
3 - hyphen found to denote a range

Cc: <[email protected]> # 2.6.32+
Signed-off-by: Xie XiuQi <[email protected]>
---
arch/x86/kernel/cpu/mcheck/mce.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 2a2bb91..46ca8e7 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2020,11 +2020,8 @@ static int __init mcheck_enable(char *str)
else if (!strcmp(str, "bios_cmci_threshold"))
cfg->bios_cmci_threshold = true;
else if (isdigit(str[0])) {
- get_option(&str, &(cfg->tolerant));
- if (*str == ',') {
- ++str;
+ if (get_option(&str, &(cfg->tolerant) == 2)
get_option(&str, &(cfg->monarch_timeout));
- }
} else {
pr_info("mce argument %s ignored. Please use /sys\n", str);
return 0;
--
1.8.3.1


2015-05-20 17:43:31

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] mce: fix fail to set 'monarchtimeout' via boot option

On Wed, May 20, 2015 at 07:22:23PM +0800, Xie XiuQi wrote:
> I use "mce=1,10000000" in cmdline to change the monarch timeout, but
> it does not work.
>
> The cause is that get_option() has parsed the ',' already, we need
> not to check the ',' again.
>
> --
> get_option(): read an int from an option string;
> if available accept a subsequent comma as well.
>
> Return values:
> 0 - no int in string
> 1 - int found, no subsequent comma
> 2 - int found including a subsequent comma
> 3 - hyphen found to denote a range
>
> Cc: <[email protected]> # 2.6.32+

I don't think that's a serious enough a bug to justify the stable tag.

> Signed-off-by: Xie XiuQi <[email protected]>
> ---
> arch/x86/kernel/cpu/mcheck/mce.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index 2a2bb91..46ca8e7 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -2020,11 +2020,8 @@ static int __init mcheck_enable(char *str)
> else if (!strcmp(str, "bios_cmci_threshold"))
> cfg->bios_cmci_threshold = true;
> else if (isdigit(str[0])) {
> - get_option(&str, &(cfg->tolerant));
> - if (*str == ',') {
> - ++str;
> + if (get_option(&str, &(cfg->tolerant) == 2)

This patch wasn't build-tested, right:

arch/x86/kernel/cpu/mcheck/mce.c: In function ‘mcheck_enable’:
arch/x86/kernel/cpu/mcheck/mce.c:1993:41: warning: comparison between pointer and integer
if (get_option(&str, &(cfg->tolerant) == 2)
^
arch/x86/kernel/cpu/mcheck/mce.c:1993:24: warning: passing argument 2 of ‘get_option’ makes pointer from integer without a cast
if (get_option(&str, &(cfg->tolerant) == 2)
^
In file included from include/asm-generic/bug.h:13:0,
from ./arch/x86/include/asm/bug.h:35,
from include/linux/bug.h:4,
from include/linux/thread_info.h:11,
from arch/x86/kernel/cpu/mcheck/mce.c:13:
include/linux/kernel.h:420:12: note: expected ‘int *’ but argument is of type ‘int’
extern int get_option(char **str, int *pint);
^
arch/x86/kernel/cpu/mcheck/mce.c:1994:4: error: expected ‘)’ before ‘get_option’
get_option(&str, &(cfg->monarch_timeout));
^
arch/x86/kernel/cpu/mcheck/mce.c:1995:2: error: expected expression before ‘}’ token
} else {
^
make[4]: *** [arch/x86/kernel/cpu/mcheck/mce.o] Error 1
make[3]: *** [arch/x86/kernel/cpu/mcheck] Error 2
make[2]: *** [arch/x86/kernel/cpu] Error 2
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2
make: *** Waiting for unfinished jobs....

> get_option(&str, &(cfg->monarch_timeout));
> - }
> } else {
> pr_info("mce argument %s ignored. Please use /sys\n", str);
> return 0;

Anyway, I fixed it up and applied it.

Thanks.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--

2015-05-21 01:00:20

by Xie XiuQi

[permalink] [raw]
Subject: Re: [PATCH] mce: fix fail to set 'monarchtimeout' via boot option

On 2015/5/21 1:43, Borislav Petkov wrote:
> On Wed, May 20, 2015 at 07:22:23PM +0800, Xie XiuQi wrote:
>> I use "mce=1,10000000" in cmdline to change the monarch timeout, but
>> it does not work.
>>
>> The cause is that get_option() has parsed the ',' already, we need
>> not to check the ',' again.
>>
>> --
>> get_option(): read an int from an option string;
>> if available accept a subsequent comma as well.
>>
>> Return values:
>> 0 - no int in string
>> 1 - int found, no subsequent comma
>> 2 - int found including a subsequent comma
>> 3 - hyphen found to denote a range
>>
>> Cc: <[email protected]> # 2.6.32+
>
> I don't think that's a serious enough a bug to justify the stable tag.
>
>> Signed-off-by: Xie XiuQi <[email protected]>
>> ---

...

>> return 0;
>
> Anyway, I fixed it up and applied it.

Sorry, I will check carefully next time.

Thanks.

>
> Thanks.
>