linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] Fix Xen boot with CONFIG_CC_STACKPROTECTOR
@ 2009-08-20  0:29 Jeremy Fitzhardinge
  2009-08-20 10:06 ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2009-08-20  0:29 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel Mailing List, the arch/x86 maintainers

Hi Ingo,

Here's a couple of little changes which prevents an early boot crash
under Xen, due to the stackprotector preamble using segment registers
before they're set up.  I only need to disable stackprotector for a
handful of functions, but unfortunately it looks like it can only be
disabled on a per-file basis.

Thanks,
    J

The following changes since commit 64f1607ffbbc772685733ea63e6f7f4183df1b16:
  Linus Torvalds (1):
        Linux 2.6.31-rc6

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git bugfix

Jeremy Fitzhardinge (2):
      x86: make sure load_percpu_segment has no stackprotector
      xen: rearrange things to fix stackprotector

 arch/x86/kernel/cpu/Makefile |    4 ++++
 arch/x86/xen/Makefile        |    4 ++++
 arch/x86/xen/enlighten.c     |   22 ++++++++++------------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 4e242f9..8b5b9b6 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -7,6 +7,10 @@ ifdef CONFIG_FUNCTION_TRACER
 CFLAGS_REMOVE_common.o = -pg
 endif
 
+# Make sure load_percpu_segment has no stackprotector
+nostackp := $(call cc-option, -fno-stack-protector)
+CFLAGS_common.o		:= $(nostackp)
+
 obj-y			:= intel_cacheinfo.o addon_cpuid_features.o
 obj-y			+= proc.o capflags.o powerflags.o common.o
 obj-y			+= vmware.o hypervisor.o
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index 3b767d0..a5b9288 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -5,6 +5,10 @@ CFLAGS_REMOVE_time.o = -pg
 CFLAGS_REMOVE_irq.o = -pg
 endif
 
+# Make sure early boot has no stackprotector
+nostackp := $(call cc-option, -fno-stack-protector)
+CFLAGS_enlighten.o		:= $(nostackp)
+
 obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			time.o xen-asm.o xen-asm_$(BITS).o \
 			grant-table.o suspend.o
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index f09e8c3..edcf72a 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -925,10 +925,6 @@ asmlinkage void __init xen_start_kernel(void)
 
 	xen_domain_type = XEN_PV_DOMAIN;
 
-	BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0);
-
-	xen_setup_features();
-
 	/* Install Xen paravirt ops */
 	pv_info = xen_info;
 	pv_init_ops = xen_init_ops;
@@ -937,8 +933,15 @@ asmlinkage void __init xen_start_kernel(void)
 	pv_apic_ops = xen_apic_ops;
 	pv_mmu_ops = xen_mmu_ops;
 
-	xen_init_irq_ops();
+#ifdef CONFIG_X86_64
+	/*
+	 * Setup percpu state.  We only need to do this for 64-bit
+	 * because 32-bit already has %fs set properly.
+	 */
+	load_percpu_segment(0);
+#endif
 
+	xen_init_irq_ops();
 	xen_init_cpuid_mask();
 
 #ifdef CONFIG_X86_LOCAL_APIC
@@ -948,6 +951,8 @@ asmlinkage void __init xen_start_kernel(void)
 	set_xen_basic_apic_ops();
 #endif
 
+	xen_setup_features();
+
 	if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) {
 		pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start;
 		pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
@@ -955,13 +960,6 @@ asmlinkage void __init xen_start_kernel(void)
 
 	machine_ops = xen_machine_ops;
 
-#ifdef CONFIG_X86_64
-	/*
-	 * Setup percpu state.  We only need to do this for 64-bit
-	 * because 32-bit already has %fs set properly.
-	 */
-	load_percpu_segment(0);
-#endif
 	/*
 	 * The only reliable way to retain the initial address of the
 	 * percpu gdt_page is to remember it here, so we can go and



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

* Re: [GIT PULL] Fix Xen boot with CONFIG_CC_STACKPROTECTOR
  2009-08-20  0:29 [GIT PULL] Fix Xen boot with CONFIG_CC_STACKPROTECTOR Jeremy Fitzhardinge
@ 2009-08-20 10:06 ` Ingo Molnar
  2009-08-20 16:00   ` H. Peter Anvin
  2009-08-20 16:24   ` Jeremy Fitzhardinge
  0 siblings, 2 replies; 5+ messages in thread
From: Ingo Molnar @ 2009-08-20 10:06 UTC (permalink / raw)
  To: Jeremy Fitzhardinge, Arjan van de Ven, H. Peter Anvin,
	Thomas Gleixner
  Cc: Ingo Molnar, Linux Kernel Mailing List, the arch/x86 maintainers


* Jeremy Fitzhardinge <jeremy@goop.org> wrote:

> Hi Ingo,
> 
> Here's a couple of little changes which prevents an early boot crash
> under Xen, due to the stackprotector preamble using segment registers
> before they're set up.  I only need to disable stackprotector for a
> handful of functions, but unfortunately it looks like it can only be
> disabled on a per-file basis.
> 
> Thanks,
>     J
> 
> The following changes since commit 64f1607ffbbc772685733ea63e6f7f4183df1b16:
>   Linus Torvalds (1):
>         Linux 2.6.31-rc6
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git bugfix
> 
> Jeremy Fitzhardinge (2):
>       x86: make sure load_percpu_segment has no stackprotector
>       xen: rearrange things to fix stackprotector
> 
>  arch/x86/kernel/cpu/Makefile |    4 ++++
>  arch/x86/xen/Makefile        |    4 ++++
>  arch/x86/xen/enlighten.c     |   22 ++++++++++------------
>  3 files changed, 18 insertions(+), 12 deletions(-)

Pulled into tip:x86/urgent, thanks a lot Jeremy!

Btw., is there any way to turn off stackprotector on a 
per function basis, a GCC attribute perhaps? That would 
be preferable to turning it off for all of common.o.

	Ingo

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

* Re: [GIT PULL] Fix Xen boot with CONFIG_CC_STACKPROTECTOR
  2009-08-20 10:06 ` Ingo Molnar
@ 2009-08-20 16:00   ` H. Peter Anvin
  2009-08-20 16:24   ` Jeremy Fitzhardinge
  1 sibling, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2009-08-20 16:00 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Jeremy Fitzhardinge, Arjan van de Ven, Thomas Gleixner,
	Ingo Molnar, Linux Kernel Mailing List, the arch/x86 maintainers

On 08/20/2009 03:06 AM, Ingo Molnar wrote:
> 
> Pulled into tip:x86/urgent, thanks a lot Jeremy!
> 
> Btw., is there any way to turn off stackprotector on a 
> per function basis, a GCC attribute perhaps? That would 
> be preferable to turning it off for all of common.o.
> 

Jeremy asked me that, I researched it, and there isn't one -- the only
option is to segregate functions into separate files.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

* Re: [GIT PULL] Fix Xen boot with CONFIG_CC_STACKPROTECTOR
  2009-08-20 10:06 ` Ingo Molnar
  2009-08-20 16:00   ` H. Peter Anvin
@ 2009-08-20 16:24   ` Jeremy Fitzhardinge
  2009-08-21  8:27     ` Ingo Molnar
  1 sibling, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2009-08-20 16:24 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Arjan van de Ven, H. Peter Anvin, Thomas Gleixner, Ingo Molnar,
	Linux Kernel Mailing List, the arch/x86 maintainers

On 08/20/09 03:06, Ingo Molnar wrote:
>> I only need to disable stackprotector for a
>> handful of functions, but unfortunately it looks like it can only be
>> disabled on a per-file basis.
> Pulled into tip:x86/urgent, thanks a lot Jeremy!
>
> Btw., is there any way to turn off stackprotector on a 
> per function basis, a GCC attribute perhaps? That would 
> be preferable to turning it off for all of common.o.


Yeah, its awkward.  But it looks like this patch is not sufficient, so
drop it for now.  I'll send a replacement shortly (though it doesn't
hurt to keep it; I can just generate a delta if that's better).

    J

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

* Re: [GIT PULL] Fix Xen boot with CONFIG_CC_STACKPROTECTOR
  2009-08-20 16:24   ` Jeremy Fitzhardinge
@ 2009-08-21  8:27     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2009-08-21  8:27 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Arjan van de Ven, H. Peter Anvin, Thomas Gleixner, Ingo Molnar,
	Linux Kernel Mailing List, the arch/x86 maintainers


* Jeremy Fitzhardinge <jeremy@goop.org> wrote:

> On 08/20/09 03:06, Ingo Molnar wrote:
> >> I only need to disable stackprotector for a
> >> handful of functions, but unfortunately it looks like it can only be
> >> disabled on a per-file basis.
> > Pulled into tip:x86/urgent, thanks a lot Jeremy!
> >
> > Btw., is there any way to turn off stackprotector on a 
> > per function basis, a GCC attribute perhaps? That would 
> > be preferable to turning it off for all of common.o.
> 
> Yeah, its awkward.  But it looks like this patch is not 
> sufficient, so drop it for now.  I'll send a replacement shortly 
> (though it doesn't hurt to keep it; I can just generate a delta if 
> that's better).

I already pulled it as the fixes looked right so please send a delta 
based on top of tip:x86/urgent.

Thanks,

	Ingo

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-20  0:29 [GIT PULL] Fix Xen boot with CONFIG_CC_STACKPROTECTOR Jeremy Fitzhardinge
2009-08-20 10:06 ` Ingo Molnar
2009-08-20 16:00   ` H. Peter Anvin
2009-08-20 16:24   ` Jeremy Fitzhardinge
2009-08-21  8:27     ` Ingo Molnar

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).