Merge branch 'linus' into x86/boot

Merge this into x86/boot so that we can queue up dependent patches.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
x86/reboot: Reduce to a single DMI table for reboot quirks

This commit reduces the X86_32 reboot_dmi_table and the X86_64
pci_reboot_dmi_table into a single table with a single set of
functions (e.g., only 1 call to core_initcall).

The table entries that use set_bios_reboot are grouped together
inside a #define CONFIG_X86_32 block.

Note that there's a single entry that uses set_kbd_reboot, which
used to be available only on X86_32.  This commit moves that
entry outside the X86_32 block because it seems it never should
have been in there.  There's multiple places in reboot.c that
assume KBD is valid regardless of X86_32/X86_64.

Signed-off-by: Michael D Labriola <michael.d.labriola@gmail.com>
Cc: Matthew Garrett <mjg@redhat.com>
Link: http://lkml.kernel.org/n/tip-lv3aliubas2l3aenq8v3uklk@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
x86/reboot: Clean up coding style

This commit simply cleans up the style used in this file to fall
in line with what's specified in CodingStyle.  Mostly comment
changes, with a single removal of unneeded braces.

Note that the comments for all the DMI quirks in
reboot_dmi_table now all line up consistently using tabs instead
of spaces.

Signed-off-by: Michael D Labriola <michael.d.labriola@gmail.com>
Link: http://lkml.kernel.org/n/tip-lde9yy7qsomh0sdqevn7xp56@git.kernel.org
[ Fixed a few small details. ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
x86/mm: Fix the size calculation of mapping tables

For machines that enable PSE, the first 2/4M memory region still uses
4K pages, so needs more PTEs in this case, but
find_early_table_space() doesn't count this.

This patch fixes it.

The bug was found via code review, no misbehavior of the kernel
was observed.

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: <ianfang.cn@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/n/tip-kq6a00qe33h7c7ais2xsywnh@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
x86, tlb: Switch cr3 in leave_mm() only when needed

Currently leave_mm() unconditionally switches the cr3 to swapper_pg_dir.
But there is no need to change the cr3, if we already left that mm.

intel_idle() for example calls leave_mm() on every deep c-state entry where
the CPU flushes the TLB for us. Similarly flush_tlb_all() was also calling
leave_mm() whenever the TLB is in LAZY state. Both these paths will be
improved with this change.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/1332460885.16101.147.camel@sbsiddha-desk.sc.intel.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
x86, efi: Fix issue of overlapping .reloc section for EFI_STUB

Previously the .reloc section was embedded in the .text
section.

No relocations are required during the PE/COFF loading phase
for the kernel using the EFI_STUB UEFI loader. To fix the
issue of overlapping sections, create a .reloc section with a
zero length.

The .reloc section header must exist to make sure the image
will be loaded by the UEFI firmware, but a zero-length
section header seems to be sufficient.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Link: http://lkml.kernel.org/r/1332520506-6472-2-git-send-email-jordan.l.justen@intel.com
Acked-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
x86, efi: Fix .text section overlapping image header for EFI_STUB

This change modifes the PE .text section to start after
the first sector of the kernel image.

The header may be modified by the UEFI secure boot signing,
so it is not appropriate for it to be included in one of the
image sections. Since the sections are part of the secure
boot hash, this modification to the .text section contents
would invalidate the secure boot signed hash.

Note: UEFI secure boot does hash the image header, but
fields that are changed by the signing process are excluded
from the hash calculation.  This exclusion process is only
handled for the image header, and not image sections.

Luckily, we can still easily boot without the first sector
by initializing a few fields in arch/x86/boot/compressed/eboot.c.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Link: http://lkml.kernel.org/r/1332520506-6472-3-git-send-email-jordan.l.justen@intel.com
[jordan.l.justen@intel.com: set .text vma & file offset]
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
x86, efi: Fix NumberOfRvaAndSizes field in PE32 header for EFI_STUB

We've actually got six data directories in the header, not one. Even
though the firmware loader doesn't seem to mind, when we come to sign
the kernel image the signing tool thinks that there is no Certificate
Table data directory, even though we've allocated space for one.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Link: http://lkml.kernel.org/r/1332520506-6472-4-git-send-email-jordan.l.justen@intel.com
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Merge branch x86/build into x86/efi and fix up arch/x86/boot/tools/build.c

Reason for merge:
       The updates to the EFI boot stub generation conflicted with the
       changes to properly use the get/put_unaligned_le*() macros to
       generate images.

       This merge commit completes the conversion in
       arch/x86/boot/tools/build.c including the places in the code
       which had been changed on the x86/efi branch.

Resolved Conflicts:
	arch/x86/boot/tools/build.c

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
x86: spinlock.h: Remove REG_PTR_MODE

REG_PTR_MODE has no users at all.

Signed-off-by: Richard Weinberger <richard@nod.at>
Link: http://lkml.kernel.org/r/1333064283-3109-1-git-send-email-richard@nod.at
Acked-by: Acked-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
debug: Add CONFIG_READABLE_ASM

Add a config option to disable various gcc compiler optimizations that
make assembler listings much harder to read. This is everything that reorders
code significantly or creates partial functions.

This is mainly to keep kernel hackers sane.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1332960678-11879-2-git-send-email-andi@firstfloor.org
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
serial: sh-sci: modify sci_break_ctl()

SCIF modules which have SCSPTR can output the break signal. Now that we
have a way of determining port features/capabilities, add trivial break
control via SCSPTR support. Tested on sh7757lcr.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh: kgdb: Fix up basic SMP support.

kgdb needs a kgdb_roundup_cpus() definition in the architecture backend,
so just copy over the MIPS version, which already does what we want.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh: kgdb: Individual register get/set support.

This updates sh following the generic kgdb changes adding support
for individual register get/set for kgdb/kdb use.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh: kgdb: Fill out sleeping_thread_to_gdb_regs() state.

Presently we're using a pretty dumbed-down implementation that copies
over register state visible from the thread info, leaving the bulk of the
switch_to state uncopied.

Given that we're also depending on register bank toggling for switch_to
optimization we ought to also explicitly zero out the GP regs that reside
in an alternate bank in order to prevent handing back garbage.

There are a few extra registers that we have state for in switch_to, so
copy those over while we're at it.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh: kgdb: Fix up NULL pointer deref by kgdb_nmicallback.

kgdb_nmicallback expects valid register state, so just fetch the register
state with get_irq_regs() as on other platforms.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh: kgdb: Unset CACHE_FLUSH_IS_SAFE for SMP.

Our SMP cache flush ops use CPU cross calls to deal with things
like I-cache accesses not being broadcast in hardware, so ensure that
the CACHE_FLUSH_IS_SAFE reflects this.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh: clkfwk: Support variable size accesses for MSTP clocks.

The bulk of the MSTP users require 32-bit access, but this isn't the case
for some of the SH-2A parts, so add in some basic infrastructure to let
the CPU define its required access size in preparation.

Requested-by: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh/mm/fault_32.c: Port OOM changes to do_page_fault

Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99
(mm: retry page fault when blocking on disk transfer) and
commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb
(x86,mm: make pagefault killable)

The above commits introduced changes into the x86 pagefault handler
for making the page fault handler retryable as well as killable.

These changes reduce the mmap_sem hold time, which is crucial
during OOM killer invocation.

Port these changes to the 32-bit SH platform.

Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
sh64: Port OOM changes to do_page_fault

Reflect the sh32 OOM changes for the sh64 page fault handler, too.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>