linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/2] bootmem: add alloc_bootmem_align()
@ 2010-11-16 21:23 Suresh Siddha
  2010-11-16 21:23 ` [patch 2/2] xsave: use alloc_bootmem_align() instead of alloc_bootmem() Suresh Siddha
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Suresh Siddha @ 2010-11-16 21:23 UTC (permalink / raw)
  To: hpa, mingo, tglx, linux-kernel; +Cc: Suresh Siddha, H. Peter Anvin

[-- Attachment #1: add_alloc_bootmem_align.patch --]
[-- Type: text/plain, Size: 737 bytes --]

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
---
 include/linux/bootmem.h |    2 ++
 1 file changed, 2 insertions(+)

Index: tree/include/linux/bootmem.h
===================================================================
--- tree.orig/include/linux/bootmem.h
+++ tree/include/linux/bootmem.h
@@ -105,6 +105,8 @@ extern void *__alloc_bootmem_low_node(pg
 
 #define alloc_bootmem(x) \
 	__alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
+#define alloc_bootmem_align(x, align) \
+	__alloc_bootmem(x, align, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_nopanic(x) \
 	__alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_pages(x) \



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

* [patch 2/2] xsave: use alloc_bootmem_align() instead of alloc_bootmem()
  2010-11-16 21:23 [patch 1/2] bootmem: add alloc_bootmem_align() Suresh Siddha
@ 2010-11-16 21:23 ` Suresh Siddha
  2010-12-14  0:49   ` [tip:x86/urgent] x86, xsave: Use " tip-bot for Suresh Siddha
  2010-11-16 22:14 ` [patch 1/2] bootmem: add alloc_bootmem_align() H. Peter Anvin
  2010-12-14  0:48 ` [tip:x86/urgent] bootmem: Add alloc_bootmem_align() tip-bot for Suresh Siddha
  2 siblings, 1 reply; 6+ messages in thread
From: Suresh Siddha @ 2010-11-16 21:23 UTC (permalink / raw)
  To: hpa, mingo, tglx, linux-kernel; +Cc: Suresh Siddha, H. Peter Anvin

[-- Attachment #1: xsave_use_alloc_bootmem_align.patch --]
[-- Type: text/plain, Size: 1030 bytes --]

Alignment of alloc_bootmem() depends on the value of L1_CACHE_SHIFT. What
we need here is 64byte alignment. Use alloc_bootmem_align() instead.

This fixes a kernel boot crash reported by Jody when the cpu in .config
is set to MPENTIUMII

Reported-by: Jody Bruchon <jody@nctritech.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/kernel/xsave.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: tree/arch/x86/kernel/xsave.c
===================================================================
--- tree.orig/arch/x86/kernel/xsave.c
+++ tree/arch/x86/kernel/xsave.c
@@ -394,7 +394,8 @@ static void __init setup_xstate_init(voi
 	 * Setup init_xstate_buf to represent the init state of
 	 * all the features managed by the xsave
 	 */
-	init_xstate_buf = alloc_bootmem(xstate_size);
+	init_xstate_buf = alloc_bootmem_align(xstate_size,
+					      __alignof__(struct xsave_struct));
 	init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
 
 	clts();



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

* Re: [patch 1/2] bootmem: add alloc_bootmem_align()
  2010-11-16 21:23 [patch 1/2] bootmem: add alloc_bootmem_align() Suresh Siddha
  2010-11-16 21:23 ` [patch 2/2] xsave: use alloc_bootmem_align() instead of alloc_bootmem() Suresh Siddha
@ 2010-11-16 22:14 ` H. Peter Anvin
  2010-11-17  0:06   ` Suresh Siddha
  2010-12-14  0:48 ` [tip:x86/urgent] bootmem: Add alloc_bootmem_align() tip-bot for Suresh Siddha
  2 siblings, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2010-11-16 22:14 UTC (permalink / raw)
  To: Suresh Siddha; +Cc: hpa, mingo, tglx, linux-kernel, H. Peter Anvin

On 11/16/2010 01:23 PM, Suresh Siddha wrote:
> Index: tree/include/linux/bootmem.h
> ===================================================================
> --- tree.orig/include/linux/bootmem.h
> +++ tree/include/linux/bootmem.h
> @@ -105,6 +105,8 @@ extern void *__alloc_bootmem_low_node(pg
>  
>  #define alloc_bootmem(x) \
>  	__alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> +#define alloc_bootmem_align(x, align) \
> +	__alloc_bootmem(x, align, __pa(MAX_DMA_ADDRESS))
>  #define alloc_bootmem_nopanic(x) \
>  	__alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
>  #define alloc_bootmem_pages(x) \

  [...]

>  	 */
> -	init_xstate_buf = alloc_bootmem(xstate_size);
> +	init_xstate_buf = alloc_bootmem_align(xstate_size,
> +					      __alignof__(struct xsave_struct));
>  	init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;

Perhaps it would make even more sense to have:

#define alloc_bootmem_alignof(x, type) \
	__alloc_bootmem(x, __alignof__(type), __pa(MAX_DMA_ADDRESS))


?

	-hpa

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

* Re: [patch 1/2] bootmem: add alloc_bootmem_align()
  2010-11-16 22:14 ` [patch 1/2] bootmem: add alloc_bootmem_align() H. Peter Anvin
@ 2010-11-17  0:06   ` Suresh Siddha
  0 siblings, 0 replies; 6+ messages in thread
From: Suresh Siddha @ 2010-11-17  0:06 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: hpa, mingo, tglx, linux-kernel, H. Peter Anvin

On Tue, 2010-11-16 at 14:14 -0800, H. Peter Anvin wrote:
> On 11/16/2010 01:23 PM, Suresh Siddha wrote:
> > Index: tree/include/linux/bootmem.h
> > ===================================================================
> > --- tree.orig/include/linux/bootmem.h
> > +++ tree/include/linux/bootmem.h
> > @@ -105,6 +105,8 @@ extern void *__alloc_bootmem_low_node(pg
> >  
> >  #define alloc_bootmem(x) \
> >  	__alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> > +#define alloc_bootmem_align(x, align) \
> > +	__alloc_bootmem(x, align, __pa(MAX_DMA_ADDRESS))
> >  #define alloc_bootmem_nopanic(x) \
> >  	__alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> >  #define alloc_bootmem_pages(x) \
> 
>   [...]
> 
> >  	 */
> > -	init_xstate_buf = alloc_bootmem(xstate_size);
> > +	init_xstate_buf = alloc_bootmem_align(xstate_size,
> > +					      __alignof__(struct xsave_struct));
> >  	init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
> 
> Perhaps it would make even more sense to have:
> 
> #define alloc_bootmem_alignof(x, type) \
> 	__alloc_bootmem(x, __alignof__(type), __pa(MAX_DMA_ADDRESS))
> 

Wanted to keep it broad so that more people can start using it.

For example, most of the current x86 uses of alloc_bootmem_pages() (or
the __alloc_bootmem() calls in other architectures) can be replaced with
alloc_bootmem_align() and most of them don't have a relevant type to
describe the alignment.

thanks,
suresh


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

* [tip:x86/urgent] bootmem: Add alloc_bootmem_align()
  2010-11-16 21:23 [patch 1/2] bootmem: add alloc_bootmem_align() Suresh Siddha
  2010-11-16 21:23 ` [patch 2/2] xsave: use alloc_bootmem_align() instead of alloc_bootmem() Suresh Siddha
  2010-11-16 22:14 ` [patch 1/2] bootmem: add alloc_bootmem_align() H. Peter Anvin
@ 2010-12-14  0:48 ` tip-bot for Suresh Siddha
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Suresh Siddha @ 2010-12-14  0:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, stable, suresh.b.siddha, tglx, hpa

Commit-ID:  53dde5f385bc56e312f78b7cb25ffaf8efd4735d
Gitweb:     http://git.kernel.org/tip/53dde5f385bc56e312f78b7cb25ffaf8efd4735d
Author:     Suresh Siddha <suresh.b.siddha@intel.com>
AuthorDate: Tue, 16 Nov 2010 13:23:50 -0800
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 13 Dec 2010 16:11:13 -0800

bootmem: Add alloc_bootmem_align()

Add an alloc_bootmem_align() interface to allocate bootmem with
specified alignment.  This is necessary to be able to allocate the
xsave area in a subsequent patch.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <20101116212441.977574826@sbsiddha-MOBL3.sc.intel.com>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
---
 include/linux/bootmem.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 266ab92..499dfe9 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -105,6 +105,8 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
 
 #define alloc_bootmem(x) \
 	__alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
+#define alloc_bootmem_align(x, align) \
+	__alloc_bootmem(x, align, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_nopanic(x) \
 	__alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_pages(x) \

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

* [tip:x86/urgent] x86, xsave: Use alloc_bootmem_align() instead of alloc_bootmem()
  2010-11-16 21:23 ` [patch 2/2] xsave: use alloc_bootmem_align() instead of alloc_bootmem() Suresh Siddha
@ 2010-12-14  0:49   ` tip-bot for Suresh Siddha
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Suresh Siddha @ 2010-12-14  0:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, stable, suresh.b.siddha, tglx, hpa, jody

Commit-ID:  10340ae130fb70352eae1ae8a00b7906d91bf166
Gitweb:     http://git.kernel.org/tip/10340ae130fb70352eae1ae8a00b7906d91bf166
Author:     Suresh Siddha <suresh.b.siddha@intel.com>
AuthorDate: Tue, 16 Nov 2010 13:23:51 -0800
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 13 Dec 2010 16:13:11 -0800

x86, xsave: Use alloc_bootmem_align() instead of alloc_bootmem()

Alignment of alloc_bootmem() depends on the value of
L1_CACHE_SHIFT. What we need here, however, is 64 byte alignment.  Use
alloc_bootmem_align() and explicitly specify the alignment instead.

This fixes a kernel boot crash reported by Jody when the cpu in .config
is set to MPENTIUMII but the kernel is booted on a xsave-capable CPU.

Reported-by: Jody Bruchon <jody@nctritech.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <20101116212442.059967454@sbsiddha-MOBL3.sc.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
---
 arch/x86/kernel/xsave.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 9c253bd..5471285 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -394,7 +394,8 @@ static void __init setup_xstate_init(void)
 	 * Setup init_xstate_buf to represent the init state of
 	 * all the features managed by the xsave
 	 */
-	init_xstate_buf = alloc_bootmem(xstate_size);
+	init_xstate_buf = alloc_bootmem_align(xstate_size,
+					      __alignof__(struct xsave_struct));
 	init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
 
 	clts();

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

end of thread, other threads:[~2010-12-14  0:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-16 21:23 [patch 1/2] bootmem: add alloc_bootmem_align() Suresh Siddha
2010-11-16 21:23 ` [patch 2/2] xsave: use alloc_bootmem_align() instead of alloc_bootmem() Suresh Siddha
2010-12-14  0:49   ` [tip:x86/urgent] x86, xsave: Use " tip-bot for Suresh Siddha
2010-11-16 22:14 ` [patch 1/2] bootmem: add alloc_bootmem_align() H. Peter Anvin
2010-11-17  0:06   ` Suresh Siddha
2010-12-14  0:48 ` [tip:x86/urgent] bootmem: Add alloc_bootmem_align() tip-bot for Suresh Siddha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).