2010-02-05 06:17:19

by Masami Hiramatsu

[permalink] [raw]
Subject: [PATCH -tip 1/2] x86/alternatives: Fix build warning

Fixes below warnings.

====
FYI, there's this new build warning on x86 defconfig:

arch/x86/kernel/alternative.c: In function 'alternatives_text_reserved':
arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast

Caused by:

2cfa197: ftrace/alternatives: Introducing *_text_reserved functions
====

Signed-off-by: Masami Hiramatsu <[email protected]>
Reported-by: Ingo Molnar <[email protected]>
---

arch/x86/kernel/alternative.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 3832fdc..99d9920 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -399,10 +399,10 @@ int alternatives_text_reserved(void *start, void *end)
u8 **ptr;

list_for_each_entry(mod, &smp_alt_modules, next) {
- if (mod->text > end || mod->text_end < start)
+ if (mod->text > (u8 *)end || mod->text_end < (u8 *)start)
continue;
for (ptr = mod->locks; ptr < mod->locks_end; ptr++)
- if (start <= *ptr && end >= *ptr)
+ if ((u8 *)start <= *ptr && (u8 *)end >= *ptr)
return 1;
}



--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]


2010-02-05 06:17:07

by Masami Hiramatsu

[permalink] [raw]
Subject: [PATCH -tip 2/2] kprobes: Add mcount in kprobes blacklist

Since mcount function can be called from everywhere,
it should be blacklisted. Moreover, the "mcount" symbol
is a special symbol name. So, it is better to put it in
the generic blacklist.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Ingo Molnar <[email protected]>
---

kernel/kprobes.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c3340e8..ccec774 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -94,6 +94,7 @@ static struct kprobe_blackpoint kprobe_blacklist[] = {
{"native_get_debugreg",},
{"irq_entries_start",},
{"common_interrupt",},
+ {"mcount",}, /* mcount can be called from everywhere */
{NULL} /* Terminator */
};



--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-02-05 07:13:12

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH -tip 1/2] x86/alternatives: Fix build warning


* Masami Hiramatsu <[email protected]> wrote:

> Fixes below warnings.
>
> ====
> FYI, there's this new build warning on x86 defconfig:
>
> arch/x86/kernel/alternative.c: In function 'alternatives_text_reserved':
> arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
> arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
> arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
> arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
>
> Caused by:
>
> 2cfa197: ftrace/alternatives: Introducing *_text_reserved functions
> ====
>
> Signed-off-by: Masami Hiramatsu <[email protected]>
> Reported-by: Ingo Molnar <[email protected]>
> ---
>
> arch/x86/kernel/alternative.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index 3832fdc..99d9920 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -399,10 +399,10 @@ int alternatives_text_reserved(void *start, void *end)
> u8 **ptr;
>
> list_for_each_entry(mod, &smp_alt_modules, next) {
> - if (mod->text > end || mod->text_end < start)
> + if (mod->text > (u8 *)end || mod->text_end < (u8 *)start)
> continue;
> for (ptr = mod->locks; ptr < mod->locks_end; ptr++)
> - if (start <= *ptr && end >= *ptr)
> + if ((u8 *)start <= *ptr && (u8 *)end >= *ptr)
> return 1;
> }

Such casts are a bit ugly and in general type casts are somewhat dangerous.

One possible solution would be to add intermediary local variables
(text_start/text_end) with u8 * type and assign start/end to them - which can
be done without a cast.

Thanks,

Ingo

2010-02-05 07:51:38

by Masami Hiramatsu

[permalink] [raw]
Subject: [tip:perf/core] kprobes: Add mcount to the kprobes blacklist

Commit-ID: 5ecaafdbf44b1ba400b746c60c401d54c7ee0863
Gitweb: http://git.kernel.org/tip/5ecaafdbf44b1ba400b746c60c401d54c7ee0863
Author: Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 5 Feb 2010 01:24:34 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 5 Feb 2010 08:13:57 +0100

kprobes: Add mcount to the kprobes blacklist

Since mcount function can be called from everywhere,
it should be blacklisted. Moreover, the "mcount" symbol
is a special symbol name. So, it is better to put it in
the generic blacklist.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Steven Rostedt <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
kernel/kprobes.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c3340e8..ccec774 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -94,6 +94,7 @@ static struct kprobe_blackpoint kprobe_blacklist[] = {
{"native_get_debugreg",},
{"irq_entries_start",},
{"common_interrupt",},
+ {"mcount",}, /* mcount can be called from everywhere */
{NULL} /* Terminator */
};

2010-02-05 16:52:56

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH -tip 1/2] x86/alternatives: Fix build warning

Ingo Molnar wrote:
>
> * Masami Hiramatsu <[email protected]> wrote:
>
>> Fixes below warnings.
>>
>> ====
>> FYI, there's this new build warning on x86 defconfig:
>>
>> arch/x86/kernel/alternative.c: In function 'alternatives_text_reserved':
>> arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
>> arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
>> arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
>> arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
>>
>> Caused by:
>>
>> 2cfa197: ftrace/alternatives: Introducing *_text_reserved functions
>> ====
>>
>> Signed-off-by: Masami Hiramatsu <[email protected]>
>> Reported-by: Ingo Molnar <[email protected]>
>> ---
>>
>> arch/x86/kernel/alternative.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
>> index 3832fdc..99d9920 100644
>> --- a/arch/x86/kernel/alternative.c
>> +++ b/arch/x86/kernel/alternative.c
>> @@ -399,10 +399,10 @@ int alternatives_text_reserved(void *start, void *end)
>> u8 **ptr;
>>
>> list_for_each_entry(mod, &smp_alt_modules, next) {
>> - if (mod->text > end || mod->text_end < start)
>> + if (mod->text > (u8 *)end || mod->text_end < (u8 *)start)
>> continue;
>> for (ptr = mod->locks; ptr < mod->locks_end; ptr++)
>> - if (start <= *ptr && end >= *ptr)
>> + if ((u8 *)start <= *ptr && (u8 *)end >= *ptr)
>> return 1;
>> }
>
> Such casts are a bit ugly and in general type casts are somewhat dangerous.

I doubt this type casting is dangerous..., but yeah, it's ugly :-)

> One possible solution would be to add intermediary local variables
> (text_start/text_end) with u8 * type and assign start/end to them - which can
> be done without a cast.

Sure, I'll update it.

Thank you,


--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-02-05 17:09:26

by Masami Hiramatsu

[permalink] [raw]
Subject: [PATCH -tip v2] x86/alternatives: Fix build warning

Fixes below warnings.

====
FYI, there's this new build warning on x86 defconfig:

arch/x86/kernel/alternative.c: In function 'alternatives_text_reserved':
arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast

Caused by:

2cfa197: ftrace/alternatives: Introducing *_text_reserved functions
====

Changes in v2:
- Use local variables to compare, instead of type casts.

Signed-off-by: Masami Hiramatsu <[email protected]>
Reported-by: Ingo Molnar <[email protected]>
---

arch/x86/kernel/alternative.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 3832fdc..e6ea034 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -397,12 +397,14 @@ int alternatives_text_reserved(void *start, void *end)
{
struct smp_alt_module *mod;
u8 **ptr;
+ u8 *text_start = start;
+ u8 *text_end = end;

list_for_each_entry(mod, &smp_alt_modules, next) {
- if (mod->text > end || mod->text_end < start)
+ if (mod->text > text_end || mod->text_end < text_start)
continue;
for (ptr = mod->locks; ptr < mod->locks_end; ptr++)
- if (start <= *ptr && end >= *ptr)
+ if (text_start <= *ptr && text_end >= *ptr)
return 1;
}



--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-02-07 19:44:50

by Masami Hiramatsu

[permalink] [raw]
Subject: [tip:perf/core] x86/alternatives: Fix build warning

Commit-ID: 076dc4a65a6d99a16979e2c7917e669fb8c91ee5
Gitweb: http://git.kernel.org/tip/076dc4a65a6d99a16979e2c7917e669fb8c91ee5
Author: Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 5 Feb 2010 12:16:47 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Sun, 7 Feb 2010 18:08:24 +0100

x86/alternatives: Fix build warning

Fixes these warnings:

arch/x86/kernel/alternative.c: In function 'alternatives_text_reserved':
arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast

Caused by:

2cfa197: ftrace/alternatives: Introducing *_text_reserved functions

Changes in v2:
- Use local variables to compare, instead of type casts.

Reported-by: Ingo Molnar <[email protected]>
Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/alternative.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 3c13284..e63b80e 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -395,12 +395,14 @@ int alternatives_text_reserved(void *start, void *end)
{
struct smp_alt_module *mod;
u8 **ptr;
+ u8 *text_start = start;
+ u8 *text_end = end;

list_for_each_entry(mod, &smp_alt_modules, next) {
- if (mod->text > end || mod->text_end < start)
+ if (mod->text > text_end || mod->text_end < text_start)
continue;
for (ptr = mod->locks; ptr < mod->locks_end; ptr++)
- if (start <= *ptr && end >= *ptr)
+ if (text_start <= *ptr && text_end >= *ptr)
return 1;
}

2010-02-15 05:23:46

by Masami Hiramatsu

[permalink] [raw]
Subject: [tip:tracing/urgent] kprobes: Add mcount to the kprobes blacklist

Commit-ID: 8b833c506c05c498d4215e2c260be44225daf6de
Gitweb: http://git.kernel.org/tip/8b833c506c05c498d4215e2c260be44225daf6de
Author: Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 5 Feb 2010 01:24:34 -0500
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 15 Feb 2010 05:45:49 +0100

kprobes: Add mcount to the kprobes blacklist

Since mcount function can be called from everywhere,
it should be blacklisted. Moreover, the "mcount" symbol
is a special symbol name. So, it is better to put it in
the generic blacklist.

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: systemtap <[email protected]>
Cc: DLE <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Steven Rostedt <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
kernel/kprobes.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index b7df302..c4b4343 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -93,6 +93,7 @@ static struct kprobe_blackpoint kprobe_blacklist[] = {
{"native_get_debugreg",},
{"irq_entries_start",},
{"common_interrupt",},
+ {"mcount",}, /* mcount can be called from everywhere */
{NULL} /* Terminator */
};