]> git.karo-electronics.de Git - linux-beck.git/log
linux-beck.git
16 years agox86: cleanup acpi_32/64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:36 +0000 (13:30 +0100)]
x86: cleanup acpi_32/64.h

Fix coding style to get a readable diff

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: cleanup smp.h variants
Thomas Gleixner [Wed, 30 Jan 2008 12:30:36 +0000 (13:30 +0100)]
x86: cleanup smp.h variants

Bring the smp.h variants into sync to prepare merging and
paravirt support.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: merge mpspec variants
Thomas Gleixner [Wed, 30 Jan 2008 12:30:35 +0000 (13:30 +0100)]
x86: merge mpspec variants

The delta is now minimal. Merge them

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: cleanup mpspec variants
Thomas Gleixner [Wed, 30 Jan 2008 12:30:35 +0000 (13:30 +0100)]
x86: cleanup mpspec variants

Bring the mpspec variants into sync to prepare merging and
paravirt support.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: merge tlbflush.h variants
Thomas Gleixner [Wed, 30 Jan 2008 12:30:35 +0000 (13:30 +0100)]
x86: merge tlbflush.h variants

The delta is now minimal. Merge them

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: cleanup tlbflush.h variants
Thomas Gleixner [Wed, 30 Jan 2008 12:30:35 +0000 (13:30 +0100)]
x86: cleanup tlbflush.h variants

Bring the tlbflush.h variants into sync to prepare merging and
paravirt support.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: merge spinlock.h variants
Thomas Gleixner [Wed, 30 Jan 2008 12:30:34 +0000 (13:30 +0100)]
x86: merge spinlock.h variants

Merge them finally together

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: spinlock_32/64 substitute types and instructions
Thomas Gleixner [Wed, 30 Jan 2008 12:30:34 +0000 (13:30 +0100)]
x86: spinlock_32/64 substitute types and instructions

Use _slock_t for the spinlock data types and replace the instructions
by string defines, which makes the code of 32/64 bit versions more
or less identical.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: spinlock_32/64 match the jump labels and symbols
Thomas Gleixner [Wed, 30 Jan 2008 12:30:34 +0000 (13:30 +0100)]
x86: spinlock_32/64 match the jump labels and symbols

Match the jump labels in  the 32/64 variants and switch the
64bit version to symbols, so the functions are almost identical
except for the operand size now.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: use immediates instead of RW_LOCK_BIAS_STR
Thomas Gleixner [Wed, 30 Jan 2008 12:30:34 +0000 (13:30 +0100)]
x86: use immediates instead of RW_LOCK_BIAS_STR

Use immediate instead of the RW_LOCK_BIAS_STR.
Makes the code more readable and gets rid of the string constant.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix asm constraints in spinlock_32/64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:34 +0000 (13:30 +0100)]
x86: fix asm constraints in spinlock_32/64.h

Use the correct constraints for the spinlock assembler functions.

read (modify) write functions need "+m" instead of "=m"

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: consolidate spinlock.h
Glauber de Oliveira Costa [Wed, 30 Jan 2008 12:30:33 +0000 (13:30 +0100)]
x86: consolidate spinlock.h

The cli and sti instructions need to be replaced by paravirt hooks.
For the i386 architecture, this is already done. The code requirements
aren't much different from x86_64 POV, so this part is consolidated in
the common header

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: irqflags consolidation
Glauber de Oliveira Costa [Wed, 30 Jan 2008 12:30:33 +0000 (13:30 +0100)]
x86: irqflags consolidation

This patch consolidates the irqflags include files containing common
paravirt definitions. The native definition for interrupt handling, halt,
and such, are the same for 32 and 64 bit, and they are kept in irqflags.h.
the differences are split in the arch-specific files.

The syscall function, irq_enable_sysexit, has a very specific i386 naming,
and its name is then changed to a more general one.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: clean up nmi_32/64.c
Hiroshi Shimamoto [Wed, 30 Jan 2008 12:30:33 +0000 (13:30 +0100)]
x86: clean up nmi_32/64.c

clean up and make nmi_32/64.c more similar.
- white space and coding style clean up.
- nmi_cpu_busy is available on CONFIG_SMP.
- move functions __acpi_nmi_enable, acpi_nmi_enable,
  __acpi_nmi_disable and acpi_nmi_disable.
- make variables name more similar.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: clean up stack allocation and free
clameter@sgi.com [Wed, 30 Jan 2008 12:30:32 +0000 (13:30 +0100)]
x86: clean up stack allocation and free

Clean up the allocation and freeing of stacks a bit by using a __GFP_ZERO flag
instead of memset.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Mike Travis <travis@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: bitops_32.h style cleanups
Randy Dunlap [Wed, 30 Jan 2008 12:30:32 +0000 (13:30 +0100)]
x86: bitops_32.h style cleanups

Coding style cleanups in x86/bitops_32.h:

- drop space in "* addr"
- whitespace & indentation fixes
- spello fixes

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: remove extern declarations for code, data, bss resources
Bernhard Walle [Wed, 30 Jan 2008 12:30:32 +0000 (13:30 +0100)]
x86: remove extern declarations for code, data, bss resources

This patch removes the extern struct resource declarations for
data_resource, code_resource and bss_resource on x86 and declares that
three structures as static as done on other architectures like IA64.

On i386, these structures are moved to setup_32.c (from e820_32.c) because
that's code that is not specific to e820 and also required on EFI systems.
That makes the "extern" reference superfluous.

On x86_64, data_resource, code_resource and bss_resource are passed to
e820_reserve_resources() as arguments just as done on i386 and IA64.  That
also avoids the "extern" reference and it's possible to make it static.

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: remove dead code in ia32-emu
Cyrill Gorcunov [Wed, 30 Jan 2008 12:30:32 +0000 (13:30 +0100)]
x86: remove dead code in ia32-emu

Remove useless second time checking of fsave argument in save_i387_ia32()
routine.  It's possible the compiler is doing the same but that is much
better to remove the dead code explicitly.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: remove duplicate includes
Lucas Woods [Wed, 30 Jan 2008 12:30:32 +0000 (13:30 +0100)]
x86: remove duplicate includes

Signed-off-by: Lucas Woods <woodzy@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: mtrr use type bool [RESEND AGAIN]
Paul Jimenez [Wed, 30 Jan 2008 12:30:31 +0000 (13:30 +0100)]
x86: mtrr use type bool [RESEND AGAIN]

This is a janitorish patch to 1) remove private TRUE/FALSE #def's in
favor of using the standard enum from linux/stddef.h and 2) switch the
variables holding those values to type 'bool' (from linux/types.h)
since it both seems more appropriate and allows for potentially better
optimization.

As a truly minor aside, I removed a couple of comments documenting
a 'do_safe' parameter that seems to no longer exist.

Signed-off-by: Paul Jimenez <pj@place.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: pci-dma_64.c: cleanups
Adrian Bunk [Wed, 30 Jan 2008 12:30:31 +0000 (13:30 +0100)]
x86: pci-dma_64.c: cleanups

This patch contains the following cleanups:
- make the needlessly global iommu_setup() static
- remove the unused EXPORT_SYMBOL(iommu_merge)

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: pci-calgary_64.c: make a variable static
Adrian Bunk [Wed, 30 Jan 2008 12:30:31 +0000 (13:30 +0100)]
x86: pci-calgary_64.c: make a variable static

"debugging" is a horrible name for a global variable - thankfully it can
become static.

Also put it out of __read_mostly so that gcc no longer has to emit it
at all.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: nmi_64.c: make code static
Adrian Bunk [Wed, 30 Jan 2008 12:30:31 +0000 (13:30 +0100)]
x86: nmi_64.c: make code static

This patch makes the following needlessly global code static:
- panic_on_timeout
- setup_nmi_watchdog()

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86 mce_64.c: make struct mcelog static
Adrian Bunk [Wed, 30 Jan 2008 12:30:30 +0000 (13:30 +0100)]
x86 mce_64.c: make struct mcelog static

This patch makes the needlessly global struct mcelog static.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: io_apic_64.c: remove unused config check
Hiroshi Shimamoto [Wed, 30 Jan 2008 12:30:30 +0000 (13:30 +0100)]
x86: io_apic_64.c: remove unused config check

CONFIG_IRQBALANCE doesn't exist on x86_64.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86 e820_64.c: make 2 functions static
Adrian Bunk [Wed, 30 Jan 2008 12:30:30 +0000 (13:30 +0100)]
x86 e820_64.c: make 2 functions static

This patch makes the following needlessly global functions static:
- e820_print_map()
- early_panic()

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: actually merge <asm/alternative.h>
H. Peter Anvin [Wed, 30 Jan 2008 12:30:30 +0000 (13:30 +0100)]
x86: actually merge <asm/alternative.h>

This actually merges <asm-x86/alternative_{32,64}.h> into
<asm-x86/alternative.h>.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: prepare merger of <asm/alternative_{32,64}.h>
H. Peter Anvin [Wed, 30 Jan 2008 12:30:30 +0000 (13:30 +0100)]
x86: prepare merger of <asm/alternative_{32,64}.h>

Prepare for merging <asm/alternative_{32,64}.h> by making the 32- and
64-bit versions textually identical.  This involves:

- removing arbitrary header inclusion differences
- reorganizing the 32-bit version slightly to match the 64-bit version
- using <asm/asm.h> to unify the assembly code
- renaming struct paravirt_patch to struct paravirt_patch_site in the
  64-bit version to match the 32-bit version; there are no references
  to struct paravirt_patch elsewhere in the tree.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: make i8259_64 more _32-like
Paul Jimenez [Wed, 30 Jan 2008 12:30:29 +0000 (13:30 +0100)]
x86: make i8259_64 more _32-like

Howdy! Here's a simple janitorish patch for you:

This patch mainly hinges around two includes and their ramifications:

#include <i8259.h> which provides cached_{slave,master}_mask
#include <io_ports.h> which provides PIC_{MASTER,SLAVE}_{IMR,CMD}

Adding these two includes and using those half dozen or so definitions
removed 140+ lines of diffs between i8259_32.c and i8259_64.c, thus
making it easier for the real substantitive differences between them to
show up, and hopefully therefore making it easier to eventually merge
the two.  All the warnings that checkpatch.pl throws (missing spaces
after commas and >80 character lines) exist intentionally to match
i8259_32.c.

Signed-off-by: Paul Jimenez <pj@place.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: move 8259 defines to i8259.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:29 +0000 (13:30 +0100)]
x86: move 8259 defines to i8259.h

Move the i8259 defines and remove the now io_ports.h

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: unexport __{read,write}_lock_failed
Adrian Bunk [Wed, 30 Jan 2008 12:30:29 +0000 (13:30 +0100)]
x86: unexport __{read,write}_lock_failed

This patch removes the unused exports for __{read,write}_lock_failed.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: remove more bogus filenames in comments.
Dave Jones [Wed, 30 Jan 2008 12:30:28 +0000 (13:30 +0100)]
x86: remove more bogus filenames in comments.

Signed-off-by: Dave Jones <davej@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: nuke a ton of unused exports
Thomas Gleixner [Wed, 30 Jan 2008 12:30:28 +0000 (13:30 +0100)]
x86: nuke a ton of unused exports

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove dead code and exports
Thomas Gleixner [Wed, 30 Jan 2008 12:30:28 +0000 (13:30 +0100)]
x86: remove dead code and exports

No users.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: nuke a ton of dead hpet code
Thomas Gleixner [Wed, 30 Jan 2008 12:30:27 +0000 (13:30 +0100)]
x86: nuke a ton of dead hpet code

No users, just ballast

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: smp_64.c: remove unused exports and cleanup while at it
Thomas Gleixner [Wed, 30 Jan 2008 12:30:27 +0000 (13:30 +0100)]
x86: smp_64.c: remove unused exports and cleanup while at it

The exports are nowhere used. There is even no reason why they were
ever introduced.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/kernel/time_64.c includes
Thomas Gleixner [Wed, 30 Jan 2008 12:30:27 +0000 (13:30 +0100)]
x86: clean up arch/x86/kernel/time_64.c includes

Reduce the lets include all to the minimum.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: share rtc code
Thomas Gleixner [Wed, 30 Jan 2008 12:30:27 +0000 (13:30 +0100)]
x86: share rtc code

Remove the rtc code from time_64.c and add the extra bits to the
i386 path. The ACPI century check is probably valid for i386 as
well, but this is material for a separate patch.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: isolate the rtc code for sharing
Thomas Gleixner [Wed, 30 Jan 2008 12:30:26 +0000 (13:30 +0100)]
x86: isolate the rtc code for sharing

The mach-default/mach_time.h code inline is moved to arch/x86/kernel/rtc.c
and the header files are adjusted.

Shrink the 3 dozen includes to the ones we really need.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: unify mc146818rtc.h - prepare for sharing rtc code
Thomas Gleixner [Wed, 30 Jan 2008 12:30:26 +0000 (13:30 +0100)]
x86: unify mc146818rtc.h - prepare for sharing rtc code

Unify mc146818rtc.h by adding the rtc_cmos_read/write functions to
time_64.c. This is a preparatory patch to finaly share the rtc code,
which is unsurprisingly similar.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove the duplicated arch/x86/ia32/mmap32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:26 +0000 (13:30 +0100)]
x86: remove the duplicated arch/x86/ia32/mmap32.c

Use mmap_32.c in arch/x86/mm instead

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/mm/mmap_32/64.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:25 +0000 (13:30 +0100)]
x86: clean up arch/x86/mm/mmap_32/64.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/kernel/vsmp_64.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:24 +0000 (13:30 +0100)]
x86: clean up arch/x86/kernel/vsmp_64.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up ioport_32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:24 +0000 (13:30 +0100)]
x86: clean up ioport_32.c

Remove unused variables, rename the "unused" argument to regp. It is used !
Codingstyle fixes.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: simplify set_bitmap in ioport_32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:23 +0000 (13:30 +0100)]
x86: simplify set_bitmap in ioport_32.c

Simplify set_bitmap(). This is not in a hotpath and we really can use the
straight forward loop through those bits. A similar implementation is used
in the 64 bit code as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge include/asm-x86/scatterlist.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:21 +0000 (13:30 +0100)]
x86: merge include/asm-x86/scatterlist.h

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge include/asm-x86/dma.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:20 +0000 (13:30 +0100)]
x86: merge include/asm-x86/dma.h

Almost identical.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge futex_32/64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:20 +0000 (13:30 +0100)]
x86: merge futex_32/64.h

Finally merge them together.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: prepare merging futex_32/64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:20 +0000 (13:30 +0100)]
x86: prepare merging futex_32/64.h

Replace .quad/.long with a define and use the same asm syntax
for i386 and x86.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: prepare merging arch/x86/kernel/apic_32/64.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:20 +0000 (13:30 +0100)]
x86: prepare merging arch/x86/kernel/apic_32/64.c

Shuffle code around, so we get a readable diff.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: make smp_local_timer_interrupt() static
Thomas Gleixner [Wed, 30 Jan 2008 12:30:20 +0000 (13:30 +0100)]
x86: make smp_local_timer_interrupt() static

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move ack_bad_irq into irq code
Thomas Gleixner [Wed, 30 Jan 2008 12:30:19 +0000 (13:30 +0100)]
x86: move ack_bad_irq into irq code

Match i386, where we have this in the irq code. It belongs there.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move ioapic code where it belongs
Thomas Gleixner [Wed, 30 Jan 2008 12:30:19 +0000 (13:30 +0100)]
x86: move ioapic code where it belongs

The commit 399287229c775a8962a852a761d65dc9475dec7c hacked the
ioapic resource mapping into apic.c for no good reason.
Move the code into io_apic_64.c where it belongs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove obsolte declarations from proto.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:19 +0000 (13:30 +0100)]
x86: remove obsolte declarations from proto.h

Nuke duplicate and obsolete crap from this ugly dump bin.
There are still some entries left which need to be sorted out,
but I'm tired of that puzzle game right now.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove duplicate start_kernel declaration
Thomas Gleixner [Wed, 30 Jan 2008 12:30:19 +0000 (13:30 +0100)]
x86: remove duplicate start_kernel declaration

start_kernel is already declared in a generic header file.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove obsolete nohpet declaration
Thomas Gleixner [Wed, 30 Jan 2008 12:30:18 +0000 (13:30 +0100)]
x86: remove obsolete nohpet declaration

Lonely user is hpet.c, so no need to declare it elsewhere.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move pmtmr related declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:18 +0000 (13:30 +0100)]
x86: move pmtmr related declarations

Move more stuff out of proto.h

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move tsc related declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:18 +0000 (13:30 +0100)]
x86: move tsc related declarations

tsc has also it's own header file. Nuke the stupid 64 bit ifdef
while at it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move pda related declaration
Thomas Gleixner [Wed, 30 Jan 2008 12:30:18 +0000 (13:30 +0100)]
x86: move pda related declaration

pda has its own header file as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move page related declaration
Thomas Gleixner [Wed, 30 Jan 2008 12:30:17 +0000 (13:30 +0100)]
x86: move page related declaration

end_pfn is in page.h, so end_pfn_map has a place there as well

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move numa related declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:17 +0000 (13:30 +0100)]
x86: move numa related declarations

More stuff shuffeled to the correct place

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move mce related declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:17 +0000 (13:30 +0100)]
x86: move mce related declarations

Move the mce related declarations where they belong, fix the
users and remove 32bit dependency in mce.h

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move debug related declarations to kdebug.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:17 +0000 (13:30 +0100)]
x86: move debug related declarations to kdebug.h

Move them and fixup some users.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move k8 related declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:16 +0000 (13:30 +0100)]
x86: move k8 related declarations

Move k8 related declarations to k8.h and fix numa_64.c

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move idle related declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:16 +0000 (13:30 +0100)]
x86: move idle related declarations

Move idle related declarations to processor_64.h, where the
the others are as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: make early_indentify_cpu static
Thomas Gleixner [Wed, 30 Jan 2008 12:30:16 +0000 (13:30 +0100)]
x86: make early_indentify_cpu static

early_indentify_cpu is only used in setup_64.c

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move acpi and pci declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:16 +0000 (13:30 +0100)]
x86: move acpi and pci declarations

Move acpi/pci related declarations to the correct headers
and remove the duplicate.

Build fix from: Andrew Morton

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove duplicated declarations
Thomas Gleixner [Wed, 30 Jan 2008 12:30:15 +0000 (13:30 +0100)]
x86: remove duplicated declarations

Remove declarations which are made already in the appropriate header file.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge apic_32/64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:15 +0000 (13:30 +0100)]
x86: merge apic_32/64.h

Unify apic.h variants.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: use u32 for some lapic functions
Thomas Gleixner [Wed, 30 Jan 2008 12:30:15 +0000 (13:30 +0100)]
x86: use u32 for some lapic functions

Use u32 so 32 and 64bit have the same interface.

Andrew Morton: xen, lguest build fixes

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: use u32 for safe_apic_wait_icr_idle()
Thomas Gleixner [Wed, 30 Jan 2008 12:30:15 +0000 (13:30 +0100)]
x86: use u32 for safe_apic_wait_icr_idle()

Preperatory patch for merging apic headers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: rename get_maxlvt to lapic_get_maxlvt
Thomas Gleixner [Wed, 30 Jan 2008 12:30:14 +0000 (13:30 +0100)]
x86: rename get_maxlvt to lapic_get_maxlvt

Use the same name for the 32 and 64 bit variant.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: prepare unification of include/asm-x86/apic_32/64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:14 +0000 (13:30 +0100)]
x86: prepare unification of include/asm-x86/apic_32/64.h

White space and coding style clenaup.

Move the K8 local apic defines to apicdef.h, where they belong

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: unify include/asm-x86/apicdef_32/64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:14 +0000 (13:30 +0100)]
x86: unify include/asm-x86/apicdef_32/64.h

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge arch/x86/kernel/ldt_32/64.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:14 +0000 (13:30 +0100)]
x86: merge arch/x86/kernel/ldt_32/64.c

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: prepare arch/x86/kernel/ldt_32/64.c for merging
Thomas Gleixner [Wed, 30 Jan 2008 12:30:13 +0000 (13:30 +0100)]
x86: prepare arch/x86/kernel/ldt_32/64.c for merging

White space and coding style cleanups.

Change unsigned to int. There is no win when we compare mincount against pc->size,
which is an int as well. Casting pc->size to unsigned just might hide real problems.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: introduce ldt_write accessor
Thomas Gleixner [Wed, 30 Jan 2008 12:30:13 +0000 (13:30 +0100)]
x86: introduce ldt_write accessor

Create a ldt write accessor like the 32 bit one.

Preparatory patch for merging ldt.c and anyway necessary for
64bit paravirt ops.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up include/asm-x86/desc_64.h
Thomas Gleixner [Wed, 30 Jan 2008 12:30:13 +0000 (13:30 +0100)]
x86: clean up include/asm-x86/desc_64.h

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/kernel/ldt_32/64.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:13 +0000 (13:30 +0100)]
x86: clean up arch/x86/kernel/ldt_32/64.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/kernel/e820_64.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:12 +0000 (13:30 +0100)]
x86: clean up arch/x86/kernel/e820_64.c

White space and coding style cleanup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: code cleanups in arch/x86/kernel/pci-gart_64.c
Ingo Molnar [Wed, 30 Jan 2008 12:30:12 +0000 (13:30 +0100)]
x86: code cleanups in arch/x86/kernel/pci-gart_64.c

code cleanups:

                                       errors   lines of code   errors/KLOC
 arch/x86/kernel/pci-gart_64.c            183             748         244.6
 arch/x86/kernel/pci-gart_64.c              0             790             0

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: lindent arch/i386/math-emu, cleanup
Ingo Molnar [Wed, 30 Jan 2008 12:30:12 +0000 (13:30 +0100)]
x86: lindent arch/i386/math-emu, cleanup

manually clean up some of the damage that lindent caused.
(this is a separate commit so that in the unlikely case of
a typo we can bisect it down to the manual edits.)

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: lindent arch/i386/math-emu
Ingo Molnar [Wed, 30 Jan 2008 12:30:11 +0000 (13:30 +0100)]
x86: lindent arch/i386/math-emu

lindent these files:
                                       errors   lines of code   errors/KLOC
 arch/x86/math-emu/                      2236            9424         237.2
 arch/x86/math-emu/                       128            8706          14.7

no other changes. No code changed:

   text    data     bss     dec     hex filename
   5589802  612739 3833856 10036397         9924ad vmlinux.before
   5589802  612739 3833856 10036397         9924ad vmlinux.after

the intent of this patch is to ease the automated tracking of kernel
code quality - it's just much easier for us to maintain it if every file
in arch/x86 is supposed to be clean.

NOTE: it is a known problem of lindent that it causes some style damage
of its own, but it's a safe tool (well, except for the gcc array range
initializers extension), so we did the bulk of the changes via lindent,
and did the manual fixups in a followup patch.

the resulting math-emu code has been tested by Thomas Gleixner on a real
386 DX CPU as well, and it works fine.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: mach-voyager, lindent
Ingo Molnar [Wed, 30 Jan 2008 12:30:10 +0000 (13:30 +0100)]
x86: mach-voyager, lindent

lindent the mach-voyager files to get rid of more than 300 style errors:

                                       errors   lines of code   errors/KLOC
 arch/x86/mach-voyager/   [old]           409            3729         109.6
 arch/x86/mach-voyager/   [new]            71            3678          19.3

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: clean up arch/x86/kernel/aperture_64.c printk()s
Ingo Molnar [Wed, 30 Jan 2008 12:30:10 +0000 (13:30 +0100)]
x86: clean up arch/x86/kernel/aperture_64.c printk()s

clean up arch/x86/kernel/aperture_64.c printk()s.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: clean up arch/x86/kernel/aperture_64.c
Ingo Molnar [Wed, 30 Jan 2008 12:30:09 +0000 (13:30 +0100)]
x86: clean up arch/x86/kernel/aperture_64.c

whitespace cleanup. No code changed:

   text    data     bss     dec     hex filename
   2080      76       4    2160     870 aperture_64.o.before
   2080      76       4    2160     870 aperture_64.o.after

                                       errors   lines of code   errors/KLOC
 arch/x86/kernel/aperture_64.c            114             299         381.2
 arch/x86/kernel/aperture_64.c              0             315             0

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: clean up arch/x86/ia32/mmap32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:09 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/mmap32.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/ia32/syscall32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:08 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/syscall32.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/ia32/sys_ia32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:08 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/sys_ia32.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/ia32/ptrace32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:08 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/ptrace32.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/ia32/ipc32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:08 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/ipc32.c

White space and coding style cleanup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/ia32/ia32_signal.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:07 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/ia32_signal.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/ia32/aout32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:07 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/aout32.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up arch/x86/ia32/fpu32.c
Thomas Gleixner [Wed, 30 Jan 2008 12:30:07 +0000 (13:30 +0100)]
x86: clean up arch/x86/ia32/fpu32.c

White space and coding style clenaup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: unify asm/cpufeature.h
H. Peter Anvin [Wed, 30 Jan 2008 12:30:07 +0000 (13:30 +0100)]
x86: unify asm/cpufeature.h

asm/cpufeature.h was already almost unified; this completes the job.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: add <asm/asm.h>
H. Peter Anvin [Wed, 30 Jan 2008 12:30:06 +0000 (13:30 +0100)]
x86: add <asm/asm.h>

Create <asm/asm.h>, with common definitions suitable for assembly
unification.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: enable irq in default_idle on 64-bit
Hiroshi Shimamoto [Wed, 30 Jan 2008 12:30:06 +0000 (13:30 +0100)]
x86: enable irq in default_idle on 64-bit

local_irq_enable() is missing after sched_clock_idle_wakeup_event().

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: idle wakeup event in the HLT loop
Ingo Molnar [Wed, 30 Jan 2008 12:30:06 +0000 (13:30 +0100)]
x86: idle wakeup event in the HLT loop

do a proper idle-wakeup event on HLT as well - some CPUs stop the TSC
in HLT too, not just when going through the ACPI methods.

(the ACPI idle code already does this.)

[ update the 64-bit side too, as noticed by Jiri Slaby. ]

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: scale cyc_2_nsec according to CPU frequency
Guillaume Chazarain [Wed, 30 Jan 2008 12:30:06 +0000 (13:30 +0100)]
x86: scale cyc_2_nsec according to CPU frequency

scale the sched_clock() cyc_2_nsec scaling factor according to
CPU frequency changes.

[ mingo@elte.hu: simplified it and fixed it for SMP. ]

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 years agox86: protect against sigaltstack wraparound
Roland McGrath [Wed, 30 Jan 2008 12:30:06 +0000 (13:30 +0100)]
x86: protect against sigaltstack wraparound

cf http://lkml.org/lkml/2007/10/3/41

To summarize: on Linux, SA_ONSTACK decides whether you are already on the
signal stack based on the value of the SP at the time of a signal.  If
you are not already inside the range, you are not "on the signal stack"
and so the new signal handler frame starts over at the base of the signal
stack.

sigaltstack (and sigstack before it) was invented in BSD.  There, the
SA_ONSTACK behavior has always been different.  It uses a kernel state
flag to decide, rather than the SP value.  When you first take an
SA_ONSTACK signal and switch to the alternate signal stack, it sets the
SS_ONSTACK flag in the thread's sigaltstack state in the kernel.
Thereafter you are "on the signal stack" and don't switch SP before
pushing a handler frame no matter what the SP value is.  Only when you
sigreturn from the original handler context do you clear the SS_ONSTACK
flag so that a new handler frame will start over at the base of the
alternate signal stack.

The undesireable effect of the Linux behavior is that an overflow of the
alternate signal stack can not only go undetected, but lead to a ring
buffer effect of clobbering the original handler frame at the base of the
signal stack for each successive signal that comes just after the
overflow.  This is what Shi Weihua's test case demonstrates.  Normally
this does not come up because of the signal mask, but the test case uses
SA_NODEFER for its SIGSEGV handler.

The other subtle part of the existing Linux semantics is that a simple
longjmp out of a signal handler serves to take you off the signal stack
in a safe and reliable fashion without having used sigreturn (nor having
just returned from the handler normally, which means the same).  After
the longjmp (or even informal stack switching not via any proper libc or
kernel interface), the alternate signal stack stands ready to be used
again.

A paranoid program would allocate a PROT_NONE red zone around its
alternate signal stack.  Then a small overflow would trigger a SIGSEGV in
handler setup, and be fatal (core dump) whether or not SIGSEGV is
blocked.  As with thread stack red zones, that cannot catch all overflows
(or underflows).  e.g., a local array as large as page size allocated in
a function called from a handler, but not actually touched before more
calls push more stack, could cause an overflow that silently pushes into
some unrelated allocated pages.

The BSD behavior does not do anything in particular about overflow.  But
it does at least avoid the wraparound or "ring buffer effect", so you'll
just get a straightforward all-out overflow down your address space past
the low end of the alternate signal stack.  I don't know what the BSD
behavior is for longjmp out of an SA_ONSTACK handler.

The POSIX wording relating to sigaltstack is pretty minimal.  I don't
think it speaks to this issue one way or another.  (The program that
overflows its stack is clearly in undefined behavior territory of one
sort or another anyhow.)

Given the longjmp issue and the potential for highly subtle complications
in existing programs relying on this in arcane ways deep in their code, I
am very dubious about changing the behavior to the BSD style persistent
flag.  I think Shi Weihua's patches have a similar effect by tracking the
SP used in the last handler setup.

I think it would be sensible for the signal handler setup code to detect
when it would itself be causing a stack overflow.  Maybe something like
the following patch (untested).  This issue exists in the same way on all
machines, so ideally they would all do a similar check.

When it's the handler function itself or its callees that cause the
overflow, rather than the signal handler frame setup alone crossing the
boundary, this still won't help.  But I don't see any way to distinguish
that from the valid longjmp case.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>