All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip] x86: smp_scan_config - use signed long as scan area size
@ 2009-08-20 17:34 Cyrill Gorcunov
  2009-08-21 16:04 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov @ 2009-08-20 17:34 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner; +Cc: LKML

Unsigned value potentially could be overlapped
if length parameter is that: length % 16 != 0.

This is not a problem at moment since all values
we pass now are 16 divisible (0x400 and 0x10000).

Though there is no need unsigned value anyway.
Max range pointed out by MP specification is
in kilobytes so plain "signed long" is enough.

This allow us to be on a safe side.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---

(I doubt if we ever will need to scan 1G of physical
 memory with 16 byte step at booting procedure 'xcept
 memtest case)

Please review. Not sure if the patch is that worth
but anyway :)

 arch/x86/kernel/mpparse.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.git/arch/x86/kernel/mpparse.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/mpparse.c
+++ linux-2.6.git/arch/x86/kernel/mpparse.c
@@ -705,7 +705,7 @@ static void __init smp_reserve_bootmem(s
 #endif
 }
 
-static int __init smp_scan_config(unsigned long base, unsigned long length,
+static int __init smp_scan_config(unsigned long base, long length,
 				  unsigned reserve)
 {
 	unsigned int *bp = phys_to_virt(base);

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

* Re: [PATCH -tip] x86: smp_scan_config - use signed long as scan area size
  2009-08-20 17:34 [PATCH -tip] x86: smp_scan_config - use signed long as scan area size Cyrill Gorcunov
@ 2009-08-21 16:04 ` Ingo Molnar
  2009-08-21 16:49   ` Cyrill Gorcunov
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2009-08-21 16:04 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: H. Peter Anvin, Thomas Gleixner, LKML


* Cyrill Gorcunov <gorcunov@openvz.org> wrote:

> Unsigned value potentially could be overlapped
> if length parameter is that: length % 16 != 0.
> 
> This is not a problem at moment since all values
> we pass now are 16 divisible (0x400 and 0x10000).
> 
> Though there is no need unsigned value anyway.
> Max range pointed out by MP specification is
> in kilobytes so plain "signed long" is enough.
> 
> This allow us to be on a safe side.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
> 
> (I doubt if we ever will need to scan 1G of physical
>  memory with 16 byte step at booting procedure 'xcept
>  memtest case)
> 
> Please review. Not sure if the patch is that worth
> but anyway :)
> 
>  arch/x86/kernel/mpparse.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6.git/arch/x86/kernel/mpparse.c
> =====================================================================
> --- linux-2.6.git.orig/arch/x86/kernel/mpparse.c
> +++ linux-2.6.git/arch/x86/kernel/mpparse.c
> @@ -705,7 +705,7 @@ static void __init smp_reserve_bootmem(s
>  #endif
>  }
>  
> -static int __init smp_scan_config(unsigned long base, unsigned long length,
> +static int __init smp_scan_config(unsigned long base, long length,
>  				  unsigned reserve)
>  {
>  	unsigned int *bp = phys_to_virt(base);

Hm, does a BUILD_BUG_ON((length & 15) != 0) line catch incorrectly 
aligned length parameters?

	Ingo

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

* Re: [PATCH -tip] x86: smp_scan_config - use signed long as scan area size
  2009-08-21 16:04 ` Ingo Molnar
@ 2009-08-21 16:49   ` Cyrill Gorcunov
  0 siblings, 0 replies; 3+ messages in thread
From: Cyrill Gorcunov @ 2009-08-21 16:49 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: H. Peter Anvin, Thomas Gleixner, LKML

[Ingo Molnar - Fri, Aug 21, 2009 at 06:04:26PM +0200]
| 
| * Cyrill Gorcunov <gorcunov@openvz.org> wrote:
| 
| > Unsigned value potentially could be overlapped
| > if length parameter is that: length % 16 != 0.
| > 
| > This is not a problem at moment since all values
| > we pass now are 16 divisible (0x400 and 0x10000).
| > 
| > Though there is no need unsigned value anyway.
| > Max range pointed out by MP specification is
| > in kilobytes so plain "signed long" is enough.
| > 
| > This allow us to be on a safe side.
| > 
| > Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
| > ---
| > 
...
| 
| Hm, does a BUILD_BUG_ON((length & 15) != 0) line catch incorrectly 
| aligned length parameters?
| 
| 	Ingo
| 

For my gcc it doesn't (gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3). Perhaps
some clever future gcc version would be able to note that constant is passed as argument
and catch it. But at moment it doesn't. (Or maybe there is some cmd option
which force compiler to inspect calls more precisely?)

We could use BUG_ON as well here but I think it doesn't worth it.
0xefffffff is enough to scan 1G of physical memory which we hard
to believe ever do (note 16 byte step size here). And code is not
getting bigger.

Ingo, current situation is not a problem since we know which
values we're passing so I thought about possible (if ever) errors
only.

Also we could introduce inline helper to check the size alignment
(in this case gcc will recognize constants I believe and catch
 nits on build time). But I really doubt it is worth thing to do.

	-- Cyrill

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

end of thread, other threads:[~2009-08-21 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-20 17:34 [PATCH -tip] x86: smp_scan_config - use signed long as scan area size Cyrill Gorcunov
2009-08-21 16:04 ` Ingo Molnar
2009-08-21 16:49   ` Cyrill Gorcunov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.