mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 6/9] x86: initialize stack canary in secondary start
@ 2010-02-13  1:40 Pan, Jacob jun
  2010-02-20  1:28 ` [tip:x86/mrst] x86: Initialize " tip-bot for Jacob Pan
  0 siblings, 1 reply; 4+ messages in thread
From: Pan, Jacob jun @ 2010-02-13  1:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Thomas Gleixner, Arjan van de Ven, Barnes, Jesse,
	Du, Alek, Tang, Feng, H. Peter Anvin

>From 0d84c04b845a36cf43aaa14c175ef10ff5e50480 Mon Sep 17 00:00:00 2001
From: Jacob Pan <jacob.jun.pan@intel.com>
Date: Thu, 17 Sep 2009 07:36:43 -0700
Subject: [PATCH 6/9] x86: initialize stack canary in secondary start

some secondary clockevent setup code needs to call request_irq, which will
cause fake stack check failure in schedule() if voluntary preemption
model is chosen, it is safe to have stack canary initialized here early,
since start_secondary() does not return.

Signed-off-by: Jacob Pan <jacob.jun.pan@intel.com>
---
 arch/x86/kernel/smpboot.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 678d0b8..56ce974 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -48,6 +48,7 @@
 #include <linux/err.h>
 #include <linux/nmi.h>
 #include <linux/tboot.h>
+#include <linux/stackprotector.h>
 
 #include <asm/acpi.h>
 #include <asm/desc.h>
@@ -324,6 +325,9 @@ notrace static void __cpuinit start_secondary(void *unused)
 	/* enable local interrupts */
 	local_irq_enable();
 
+	/* to prevent fake stack check failure in clock setup */
+	boot_init_stack_canary();
+
 	x86_cpuinit.setup_percpu_clockev();
 
 	wmb();
-- 
1.6.5.3


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

* [tip:x86/mrst] x86: Initialize stack canary in secondary start
  2010-02-13  1:40 [PATCH 6/9] x86: initialize stack canary in secondary start Pan, Jacob jun
@ 2010-02-20  1:28 ` tip-bot for Jacob Pan
  2010-02-20  8:04   ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: tip-bot for Jacob Pan @ 2010-02-20  1:28 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, jacob.jun.pan, tglx

Commit-ID:  35f720c5930f689647d51ad77e2a8d6f0abf66c8
Gitweb:     http://git.kernel.org/tip/35f720c5930f689647d51ad77e2a8d6f0abf66c8
Author:     Jacob Pan <jacob.jun.pan@intel.com>
AuthorDate: Thu, 17 Sep 2009 07:36:43 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 19 Feb 2010 16:25:17 -0800

x86: Initialize stack canary in secondary start

Some secondary clockevent setup code needs to call request_irq, which
will cause fake stack check failure in schedule() if voluntary
preemption model is chosen.  It is safe to have stack canary
initialized here early, since start_secondary() does not return.

Signed-off-by: Jacob Pan <jacob.jun.pan@intel.com>
LKML-Reference: <43F901BD926A4E43B106BF17856F07559FB80D02@orsmsx508.amr.corp.intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/kernel/smpboot.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index b4e870c..3e6150d 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -48,6 +48,7 @@
 #include <linux/err.h>
 #include <linux/nmi.h>
 #include <linux/tboot.h>
+#include <linux/stackprotector.h>
 
 #include <asm/acpi.h>
 #include <asm/desc.h>
@@ -324,6 +325,9 @@ notrace static void __cpuinit start_secondary(void *unused)
 	/* enable local interrupts */
 	local_irq_enable();
 
+	/* to prevent fake stack check failure in clock setup */
+	boot_init_stack_canary();
+
 	x86_cpuinit.setup_percpu_clockev();
 
 	wmb();

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

* Re: [tip:x86/mrst] x86: Initialize stack canary in secondary start
  2010-02-20  1:28 ` [tip:x86/mrst] x86: Initialize " tip-bot for Jacob Pan
@ 2010-02-20  8:04   ` Thomas Gleixner
  2010-02-22 18:24     ` Pan, Jacob jun
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2010-02-20  8:04 UTC (permalink / raw)
  To: mingo, H. Peter Anvin, LKML, Pan, Jacob jun; +Cc: linux-tip-commits

On Sat, 20 Feb 2010, tip-bot for Jacob Pan wrote:

> Commit-ID:  35f720c5930f689647d51ad77e2a8d6f0abf66c8
> Gitweb:     http://git.kernel.org/tip/35f720c5930f689647d51ad77e2a8d6f0abf66c8
> Author:     Jacob Pan <jacob.jun.pan@intel.com>
> AuthorDate: Thu, 17 Sep 2009 07:36:43 -0700
> Committer:  H. Peter Anvin <hpa@zytor.com>
> CommitDate: Fri, 19 Feb 2010 16:25:17 -0800
> 
> x86: Initialize stack canary in secondary start
> 
> Some secondary clockevent setup code needs to call request_irq, which
> will cause fake stack check failure in schedule() if voluntary
> preemption model is chosen.  It is safe to have stack canary
> initialized here early, since start_secondary() does not return.

So with that patch applied we can remove the boot_init_stack_canary()
in process_32/64.c cpu_idle(), can't we ?

Thanks,

	tglx


> Signed-off-by: Jacob Pan <jacob.jun.pan@intel.com>
> LKML-Reference: <43F901BD926A4E43B106BF17856F07559FB80D02@orsmsx508.amr.corp.intel.com>
> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
> ---
>  arch/x86/kernel/smpboot.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index b4e870c..3e6150d 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -48,6 +48,7 @@
>  #include <linux/err.h>
>  #include <linux/nmi.h>
>  #include <linux/tboot.h>
> +#include <linux/stackprotector.h>
>  
>  #include <asm/acpi.h>
>  #include <asm/desc.h>
> @@ -324,6 +325,9 @@ notrace static void __cpuinit start_secondary(void *unused)
>  	/* enable local interrupts */
>  	local_irq_enable();
>  
> +	/* to prevent fake stack check failure in clock setup */
> +	boot_init_stack_canary();
> +
>  	x86_cpuinit.setup_percpu_clockev();
>  
>  	wmb();
> 

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

* RE: [tip:x86/mrst] x86: Initialize stack canary in secondary start
  2010-02-20  8:04   ` Thomas Gleixner
@ 2010-02-22 18:24     ` Pan, Jacob jun
  0 siblings, 0 replies; 4+ messages in thread
From: Pan, Jacob jun @ 2010-02-22 18:24 UTC (permalink / raw)
  To: Thomas Gleixner, mingo, H. Peter Anvin, LKML
  Cc: linux-tip-commits, Arjan van de Ven


>So with that patch applied we can remove the boot_init_stack_canary()
>in process_32/64.c cpu_idle(), can't we ?
>

[[JPAN]] i agree, bsp stack canary will be initialized in start_kernel() and
ap stack canary will be covered in start_secondary().
arjan, do you have any comments? here is the new patch.

>From 1073c9f6e1e3b0012f85b5a9c7c83e35bcc16107 Mon Sep 17 00:00:00 2001
From: Jacob Pan <jacob.jun.pan@intel.com>
Date: Mon, 22 Feb 2010 04:14:11 -0800
Subject: [PATCH] x86/boot: reduce redundant stack canary init

move secondary cpu boot stack canary initialization prior to cpu_idle()
then remove boot_init_stack_canary() calls from cpu_idle().
this change reduced redundent stack canary init for the bsp also avoid
fake stack check failure for secondary if early schedule needed before
cpu_idle.

Signed-off-by: Jacob Pan <jacob.jun.pan@intel.com>
---
 arch/x86/kernel/process_32.c |    9 ---------
 arch/x86/kernel/process_64.c |    9 ---------
 arch/x86/kernel/smpboot.c    |    4 ++++
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index f6c6266..d4c764a 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -85,15 +85,6 @@ void cpu_idle(void)
 {
 	int cpu = smp_processor_id();
 
-	/*
-	 * If we're the non-boot CPU, nothing set the stack canary up
-	 * for us.  CPU0 already has it initialized but no harm in
-	 * doing it again.  This is a good place for updating it, as
-	 * we wont ever return from this function (so the invalid
-	 * canaries already on the stack wont ever trigger).
-	 */
-	boot_init_stack_canary();
-
 	current_thread_info()->status |= TS_POLLING;
 
 	/* endless idle loop with no priority at all */
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index fc6ad4b..1fd6713 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -110,15 +110,6 @@ void cpu_idle(void)
 {
 	current_thread_info()->status |= TS_POLLING;
 
-	/*
-	 * If we're the non-boot CPU, nothing set the stack canary up
-	 * for us.  CPU0 already has it initialized but no harm in
-	 * doing it again.  This is a good place for updating it, as
-	 * we wont ever return from this function (so the invalid
-	 * canaries already on the stack wont ever trigger).
-	 */
-	boot_init_stack_canary();
-
 	/* endless idle loop with no priority at all */
 	while (1) {
 		tick_nohz_stop_sched_tick(1);
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index c08829a..820638d 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -48,6 +48,7 @@
 #include <linux/err.h>
 #include <linux/nmi.h>
 #include <linux/tboot.h>
+#include <linux/stackprotector.h>
 
 #include <asm/acpi.h>
 #include <asm/desc.h>
@@ -328,6 +329,9 @@ notrace static void __cpuinit start_secondary(void *unused)
 	/* enable local interrupts */
 	local_irq_enable();
 
+	/* to prevent fake stack check failure in clock setup */
+	boot_init_stack_canary();
+
 	x86_cpuinit.setup_percpu_clockev();
 
 	wmb();
-- 
1.5.6.5



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

end of thread, other threads:[~2010-02-22 18:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-13  1:40 [PATCH 6/9] x86: initialize stack canary in secondary start Pan, Jacob jun
2010-02-20  1:28 ` [tip:x86/mrst] x86: Initialize " tip-bot for Jacob Pan
2010-02-20  8:04   ` Thomas Gleixner
2010-02-22 18:24     ` Pan, Jacob jun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome