]> err.no Git - linux-2.6/log
linux-2.6
16 years agox86: traps_xx: modify __die
Alexander van Heukelum [Tue, 1 Jul 2008 23:31:03 +0000 (01:31 +0200)]
x86: traps_xx: modify __die

if (cond) block -> if (!cond) goto end_of_block

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: traps_xx: shuffle headers and globals
Alexander van Heukelum [Tue, 1 Jul 2008 23:30:30 +0000 (01:30 +0200)]
x86: traps_xx: shuffle headers and globals

Reorder headers and collect globals in traps_32.c and traps_64.c

Code size and data size are unaffected by the changes. Code
itself is changed due to different ordering of data and bss.
The bss segment changed size due to a change in the packing
of the variables.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: initial changes to unify traps_32.c and traps_64.c
Alexander van Heukelum [Tue, 1 Jul 2008 23:29:44 +0000 (01:29 +0200)]
x86: initial changes to unify traps_32.c and traps_64.c

This patch does not change the generated object files.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: rename paravirtualized TSC functions
Alok Kataria [Tue, 1 Jul 2008 18:43:36 +0000 (11:43 -0700)]
x86: rename paravirtualized TSC functions

Rename the paravirtualized calculate_cpu_khz to calibrate_tsc.
In all cases, we actually calibrate_tsc and use that as the cpu_khz value.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Signed-off-by: Dan Hecht <dhecht@vmware.com>
Cc: Dan Hecht <dhecht@vmware.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge tsc_init and clocksource code
Alok Kataria [Tue, 1 Jul 2008 18:43:34 +0000 (11:43 -0700)]
x86: merge tsc_init and clocksource code

Unify the clocksource code.
Unify the tsc_init code.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Signed-off-by: Dan Hecht <dhecht@vmware.com>
Cc: Dan Hecht <dhecht@vmware.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge the TSC cpu-freq code
Alok Kataria [Tue, 1 Jul 2008 18:43:31 +0000 (11:43 -0700)]
x86: merge the TSC cpu-freq code

Unify the TSC cpufreq code.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Signed-off-by: Dan Hecht <dhecht@vmware.com>
Cc: Dan Hecht <dhecht@vmware.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge tsc calibration
Alok Kataria [Tue, 1 Jul 2008 18:43:24 +0000 (11:43 -0700)]
x86: merge tsc calibration

Merge the tsc calibration code for the 32bit and 64bit kernel.
The paravirtualized calculate_cpu_khz for 64bit now points to the correct
tsc_calibrate code as in 32bit.
Original native_calculate_cpu_khz for 64 bit is now called as calibrate_cpu.

Also moved the recalibrate_cpu_khz function in the common file.
Note that this function is called only from powernow K7 cpu freq driver.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Signed-off-by: Dan Hecht <dhecht@vmware.com>
Cc: Dan Hecht <dhecht@vmware.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge sched_clock handling
Alok Kataria [Tue, 1 Jul 2008 18:43:18 +0000 (11:43 -0700)]
x86: merge sched_clock handling

Move the basic global variable definitions and sched_clock handling in the
common "tsc.c" file.

 - Unify notsc kernel command line handling for 32 bit and 64bit.
 - Functional changes for 64bit.
        - "tsc_disabled" is updated if "notsc" is passed at boottime.
        - Fallback to jiffies for sched_clock, incase notsc is passed on
  commandline.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Signed-off-by: Dan Hecht <dhecht@vmware.com>
Cc: Dan Hecht <dhecht@vmware.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: apic_32.c - add lapic resource
Cyrill Gorcunov [Tue, 1 Jul 2008 17:43:52 +0000 (21:43 +0400)]
x86: apic_32.c - add lapic resource

Add lapic resource into kernel resource map and mark it as busy

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CC: Maciej W. Rozycki <macro@linux-mips.org>
16 years agox86, uv: update x86 mmr list for SGI uv
Dimitri Sivanich [Wed, 2 Jul 2008 20:39:35 +0000 (15:39 -0500)]
x86, uv: update x86 mmr list for SGI uv

This patch updates the X86 mmr list for SGI uv.

Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
Cc: Jack Steiner <steiner@sgi.com>
Cc: Russ Anderson <rja@sgi.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: map UV chipset space - UV support
Jack Steiner [Tue, 1 Jul 2008 19:45:38 +0000 (14:45 -0500)]
x86: map UV chipset space - UV support

Create page table entries to map the SGI UV chipset GRU. local MMR &
global MMR ranges.

Signed-off-by: Jack Steiner <steiner@sgi.com>
Cc: linux-mm@kvack.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: map UV chipset space - pagetable
Jack Steiner [Tue, 1 Jul 2008 19:45:32 +0000 (14:45 -0500)]
x86: map UV chipset space - pagetable

Add boot-time function for creating additional 2MB page table entries for
mapping chipset specific cached/uncached ranges.

Signed-off-by: Jack Steiner <steiner@sgi.com>
Cc: linux-mm@kvack.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: let early_reserve_e820 update e820_saved too
Yinghai Lu [Thu, 3 Jul 2008 18:39:00 +0000 (11:39 -0700)]
x86: let early_reserve_e820 update e820_saved too

so when it is called after early_param, e820_saved get updated too.
esp for mpc update.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: Bernhard Walle <bwalle@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: make e820_saved have update from setup_data
Yinghai Lu [Thu, 3 Jul 2008 18:37:13 +0000 (11:37 -0700)]
x86: make e820_saved have update from setup_data

seperate reserve_setup_data into e820_reserved_setup_data,
and reserve_early_setup_data.

So could use e820_reserved_setup_data to backup e820 with setup_data.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: Bernhard Walle <bwalle@suse.de>
Cc: Ying Huang <ying.huang@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move saving e820_saved to setup_memory_map
Yinghai Lu [Thu, 3 Jul 2008 18:35:37 +0000 (11:35 -0700)]
x86: move saving e820_saved to setup_memory_map

so other path that will override memory_setup or
machine_specific_memory_setup could have e820_saved too.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Bernhard Walle <bwalle@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: use FIRMWARE_MEMMAP on x86/E820
Bernhard Walle [Fri, 27 Jun 2008 11:12:55 +0000 (13:12 +0200)]
x86: use FIRMWARE_MEMMAP on x86/E820

This patch uses the /sys/firmware/memmap interface provided in the last patch
on the x86 architecture when E820 is used. The patch copies the E820
memory map very early, and registers the E820 map afterwards via
firmware_map_add_early().

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Acked-by: Greg KH <gregkh@suse.de>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Cc: kexec@lists.infradead.org
Cc: yhlu.kernel@gmail.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agosysfs: add /sys/firmware/memmap
Bernhard Walle [Fri, 27 Jun 2008 11:12:54 +0000 (13:12 +0200)]
sysfs: add /sys/firmware/memmap

This patch adds /sys/firmware/memmap interface that represents the BIOS
(or Firmware) provided memory map. The tree looks like:

    /sys/firmware/memmap/0/start   (hex number)
                           end     (hex number)
                           type    (string)
    ...                 /1/start
                           end
                           type

With the following shell snippet one can print the memory map in the same form
the kernel prints itself when booting on x86 (the E820 map).

  --------- 8< --------------------------
    #!/bin/sh
    cd /sys/firmware/memmap
    for dir in * ; do
        start=$(cat $dir/start)
        end=$(cat $dir/end)
        type=$(cat $dir/type)
        printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type"
    done
  --------- >8 --------------------------

That patch only provides the needed interface:

 1. The sysfs interface.
 2. The structure and enumeration definition.
 3. The function firmware_map_add() and firmware_map_add_early()
    that should be called from architecture code (E820/EFI, for
    example) to add the contents to the interface.

If the kernel is compiled without CONFIG_FIRMWARE_MEMMAP, the interface does
nothing without cluttering the architecture-specific code with #ifdef's.

The purpose of the new interface is kexec: While /proc/iomem represents
the *used* memory map (e.g. modified via kernel parameters like 'memmap'
and 'mem'), the /sys/firmware/memmap tree represents the unmodified memory
map provided via the firmware. So kexec can:

 - use the original memory map for rebooting,
 - use the /proc/iomem for setting up the ELF core headers for kdump
   case that should only represent the memory of the system.

The patch has been tested on i386 and x86_64.

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Acked-by: Greg KH <gregkh@suse.de>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Cc: kexec@lists.infradead.org
Cc: yhlu.kernel@gmail.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove acpi_srat config v2
Yinghai Lu [Sun, 6 Jul 2008 18:42:11 +0000 (11:42 -0700)]
x86: remove acpi_srat config v2

use ACPI_NUMA directly

and move srat_32.c to mm/

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove have_arch_parse_srat -v2
Yinghai Lu [Sun, 6 Jul 2008 18:42:11 +0000 (11:42 -0700)]
x86: remove have_arch_parse_srat -v2

we already have the same srat handling interface for 32bit.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agoprintk: export console_drivers
Ingo Molnar [Mon, 2 Jun 2008 11:19:08 +0000 (13:19 +0200)]
printk: export console_drivers

this symbol is needed by drivers/video/xen-fbfront.ko.

[ cherry-picked from tip/core/printk ]

Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/cpa: use an undefined PTE bit for testing CPA
Jeremy Fitzhardinge [Tue, 1 Jul 2008 23:46:37 +0000 (16:46 -0700)]
x86/cpa: use an undefined PTE bit for testing CPA

Rather than using _PAGE_GLOBAL - which not all CPUs support - to test
CPA, use one of the reserved-for-software-use PTE flags instead.  This
allows CPA testing to work on CPUs which don't support PGD.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86_32: remove __PAGE_KERNEL(_EXEC)
Jeremy Fitzhardinge [Tue, 1 Jul 2008 23:46:36 +0000 (16:46 -0700)]
x86_32: remove __PAGE_KERNEL(_EXEC)
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

Older x86-32 processors do not support global mappings (PGD), so must
only use it if the processor supports it.

The _PAGE_KERNEL* flags always have _PAGE_KERNEL set, since logically
we always want it set.

This is OK even on processors which do not support PGD, since all
_PAGE flags are masked with __supported_pte_mask before being turned
into a real in-pagetable pte.  On 32-bit systems, __supported_pte_mask
is initialized to not contain _PAGE_GLOBAL, and it is then added if
the CPU is found to support it.

The x86-32 code used to use __PAGE_KERNEL/__PAGE_KERNEL_EXEC for this
purpose, but they're now redundant and can be removed.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: always set _PAGE_GLOBAL in _PAGE_KERNEL* flags
Jeremy Fitzhardinge [Tue, 1 Jul 2008 23:46:35 +0000 (16:46 -0700)]
x86: always set _PAGE_GLOBAL in _PAGE_KERNEL* flags

Consistently set _PAGE_GLOBAL in _PAGE_KERNEL flags.  This makes 32-
and 64-bit code consistent, and removes some special cases where
__PAGE_KERNEL* did not have _PAGE_GLOBAL set, causing confusion as a
result of the inconsistencies.

This patch only affects x86-64, which generally always supports PGD.
The x86-32 patch is next.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86_64/setup: unconditionally populate the pgd
Jeremy Fitzhardinge [Tue, 1 Jul 2008 23:46:33 +0000 (16:46 -0700)]
x86_64/setup: unconditionally populate the pgd

When allocating a new pud, unconditionally populate the pgd (why did
we bother to create a new pud if we weren't going to populate it?).

This will only happen if the pgd slot was empty, since any existing
pud will be reused.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix "x86: let setup_arch call init_apic_mappings for 32bit"
Ingo Molnar [Fri, 4 Jul 2008 10:16:55 +0000 (12:16 +0200)]
x86: fix "x86: let setup_arch call init_apic_mappings for 32bit"

add back this line lost from trap_init():

        set_trap_gate(0,  &divide_error);

Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move prefill_possible_map calling early, fix
Ingo Molnar [Thu, 3 Jul 2008 13:57:47 +0000 (15:57 +0200)]
x86: move prefill_possible_map calling early, fix

fix:

arch/x86/kernel/built-in.o: In function `setup_arch':
: undefined reference to `prefill_possible_map'

Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move prefill_possible_map calling early
Yinghai Lu [Thu, 3 Jul 2008 01:54:40 +0000 (18:54 -0700)]
x86: move prefill_possible_map calling early

call it right after we are done with MADT/mptable handling, instead of
doing that in setup_per_cpu_areas() later on...

this way for_possible_cpu() can be used early.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move init_cpu_to_node after get_smp_config
Yinghai Lu [Thu, 3 Jul 2008 01:53:44 +0000 (18:53 -0700)]
x86: move init_cpu_to_node after get_smp_config

when acpi=off, cpu_to_apicid is ready after get_smp_config
so need to move init_cpu_to_node after it.

otherwise, we will get wrong cpu->node mapping, and it will rely on
amd_detect_cmp() to correct it - but that is too late as
setup_per_cpu_data is already called before that so  we will get
per_cpu_data on the wrong node.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge zones_sizes_init for numa and non numa on 32-bit
Yinghai Lu [Wed, 2 Jul 2008 07:31:02 +0000 (00:31 -0700)]
x86: merge zones_sizes_init for numa and non numa on 32-bit

move out e820_register_active_regions from non numa zones_sizes_init()
and remove numa version zones_sizes_init().

and let 32 bit call remove_all_active_ranges() in setup_arch() directly
like 64-bit

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: do not printout if we do not find setup_data
Yinghai Lu [Wed, 2 Jul 2008 03:04:10 +0000 (20:04 -0700)]
x86: do not printout if we do not find setup_data

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: make early_res_to_bootmem print out less 80 width chars
Yinghai Lu [Wed, 2 Jul 2008 03:03:11 +0000 (20:03 -0700)]
x86: make early_res_to_bootmem print out less 80 width chars

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: change copy_e820_map to append_e820_map
Yinghai Lu [Wed, 2 Jul 2008 03:02:16 +0000 (20:02 -0700)]
x86: change copy_e820_map to append_e820_map

so it has a more meaningful name.
also change it to static.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix documentation bug about relocatability
Bernhard Walle [Thu, 26 Jun 2008 19:55:18 +0000 (21:55 +0200)]
x86: fix documentation bug about relocatability

This patch fixes a small bug in documentation: x86_64 also has now
the ability to build a relocatable kernel.

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Cc: vgoyal@redhat.com
Cc: kexec@lists.infradead.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: find offset for crashkernel reservation automatically
Bernhard Walle [Thu, 26 Jun 2008 19:54:08 +0000 (21:54 +0200)]
x86: find offset for crashkernel reservation automatically

This patch removes the need of the crashkernel=...@offset parameter to define
a fixed offset for crashkernel reservation. That feature can be used together
with a relocatable kernel where the kexec-tools relocate the kernel and
get the actual offset from /proc/iomem.

The use case is a kernel where the .text+.data+.bss is after 16M physical
memory (debug kernel with lockdep on x86_64 can cause that) which caused a
major pain in autoconfiguration in our distribution.

Also, that patch unifies crashdump architectures a bit since IA64 has
that semantics from the very beginning of the kdump port.

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Cc: vgoyal@redhat.com
Cc: Bernhard Walle <bwalle@suse.de>
Cc: kexec@lists.infradead.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: cleanup e820_setup_gap(), v2
Alok Kataria [Wed, 25 Jun 2008 18:02:42 +0000 (11:02 -0700)]
x86: cleanup e820_setup_gap(), v2

e820_search_gap also take a end_addr parameter to limit search from
start_addr to end_addr.

Signed-off-by: AloK N Kataria <akataria@vmware.com>
Acked-by: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: "lenb@kernel.org" <lenb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: add check for node passed to node_to_cpumask, v3
Mike Travis [Fri, 27 Jun 2008 17:10:13 +0000 (10:10 -0700)]
x86: add check for node passed to node_to_cpumask, v3

  * When CONFIG_DEBUG_PER_CPU_MAPS is set, the node passed to
    node_to_cpumask and node_to_cpumask_ptr should be validated.
    If invalid, then a dump_stack is performed and a zero cpumask
    is returned.

v2: Slightly different version to remove a compiler warning.
v3: Redone to reflect moving setup.c -> setup_percpu.c

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix CPA self-test for "x86/paravirt: groundwork for 64-bit Xen support"
Jeremy Fitzhardinge [Mon, 30 Jun 2008 23:04:48 +0000 (16:04 -0700)]
x86: fix CPA self-test for "x86/paravirt: groundwork for 64-bit Xen support"

Ingo Molnar wrote:
> -tip auto-testing found pagetable corruption (CPA self-test failure):
>
> [   32.956015] CPA self-test:
> [   32.958822]  4k 2048 large 508 gb 0 x 2556[ffff880000000000-ffff88003fe00000] miss 0
> [   32.964000] CPA ffff88001d54e000: bad pte 1d4000e3
> [   32.968000] CPA ffff88001d54e000: unexpected level 2
> [   32.972000] CPA ffff880022c5d000: bad pte 22c000e3
> [   32.976000] CPA ffff880022c5d000: unexpected level 2
> [   32.980000] CPA ffff8800200ce000: bad pte 200000e3
> [   32.984000] CPA ffff8800200ce000: unexpected level 2
> [   32.988000] CPA ffff8800210f0000: bad pte 210000e3
>
> config and full log can be found at:
>
>  http://redhat.com/~mingo/misc/config-Mon_Jun_30_11_11_51_CEST_2008.bad
>  http://redhat.com/~mingo/misc/log-Mon_Jun_30_11_11_51_CEST_2008.bad

Phew.  OK, I've worked this out.  Short version is that's it's a false
alarm, and there was no real failure here.  Long version:

    * I changed the code to create the physical mapping pagetables to
      reuse any existing mapping rather than replace it.   Specifically,
      reusing an pud pointed to by the pgd caused this symptom to appear.
    * The specific PUD being reused is the one created statically in
      head_64.S, which creates an initial 1GB mapping.
    * That mapping doesn't have _PAGE_GLOBAL set on it, due to the
      inconsistency between __PAGE_* and PAGE_*.
    * The CPA test attempts to clear _PAGE_GLOBAL, and then checks to
      see that the resulting range is 1) shattered into 4k pages, and 2)
      has no _PAGE_GLOBAL.
    * However, since it didn't have _PAGE_GLOBAL on that range to start
      with, change_page_attr_clear() had nothing to do, and didn't
      bother shattering the range,
    * resulting in the reported messages

The simple fix is to set _PAGE_GLOBAL in level2_ident_pgt.

An additional fix to make CPA testing more robust by using some other
pagetable bit (one of the unused available-to-software ones).  This
would solve spurious CPA test warnings under Xen which uses _PAGE_GLOBAL
for its own purposes (ie, not under guest control).

Also, we should revisit the use of _PAGE_GLOBAL in asm-x86/pgtable.h,
and use it consistently, and drop MAKE_GLOBAL.  The first time I
proposed it it caused breakages in the very early CPA code; with luck
that's all fixed now.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Mark McLoughlin <markmc@redhat.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: don't reallocate pgt for node0
Yinghai Lu [Tue, 1 Jul 2008 01:34:58 +0000 (18:34 -0700)]
x86: don't reallocate pgt for node0

kva ram already mapped right after away, so don't need to get that for low ram.
avoid wasting one copy of pgdat.

also add node id in early_res name in case we get it from find_e820_area.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move reserve_setup_data to setup.c
Yinghai Lu [Mon, 30 Jun 2008 23:20:54 +0000 (16:20 -0700)]
x86: move reserve_setup_data to setup.c

Ying Huang would like setup_data to be reserved, but not included in the
no save range.

Here we try to modify the e820 table to reserve that range early.
also add that in early_res in case bootloader messes up with the ramdisk.

other solution would be
1. add early_res_to_highmem...
2. early_res_to_e820...
but they could reserve another type memory wrongly, if early_res has some
resource reserved early, and not needed later, but it is not removed from
early_res in time. Like the RAMDISK (already handled).

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: andi@firstfloor.org
Tested-by: Huang, Ying <ying.huang@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, paravirt, 64-bit: fix compile errors with IA32_EMULATION off
Jeremy Fitzhardinge [Mon, 30 Jun 2008 18:10:53 +0000 (11:10 -0700)]
x86, paravirt, 64-bit: fix compile errors with IA32_EMULATION off

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years ago- x86: move early_ioremap prototypes to io.h
Ingo Molnar [Mon, 30 Jun 2008 08:33:47 +0000 (10:33 +0200)]
- x86: move early_ioremap prototypes to io.h

now that the early-ioremap code is unified, move the prototypes too from
io_32.h to io.h.

this fixes:

arch/x86/kernel/setup.c:531: error: implicit declaration of function ‘early_ioremap_init'

on 64-bit.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: setup_arch() && early_ioremap_init()
Jeremy Fitzhardinge [Mon, 30 Jun 2008 03:02:44 +0000 (20:02 -0700)]
x86: setup_arch() && early_ioremap_init()

Looks like the setup.c unification missed the early_ioremap init from
the early_ioremap unification.  Unconditionally call early_ioremap_init().

needed for "x86/paravirt: groundwork for 64-bit Xen support".

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Mark McLoughlin <markmc@redhat.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: nmi_watchdog - documentation fix - v2
Ingo Molnar [Mon, 30 Jun 2008 06:47:42 +0000 (08:47 +0200)]
x86: nmi_watchdog - documentation fix - v2

typo fixes from Randy Dunlap and Alan Cox.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: nmi_watchdog - documentation fix
Cyrill Gorcunov [Fri, 27 Jun 2008 15:43:40 +0000 (19:43 +0400)]
x86: nmi_watchdog - documentation fix

nmi_watchdog is set to NMI_NONE by default (ie disabled) on _any_
mode so lets fix documentation too.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: use disable_apic in 32bit
Yinghai Lu [Sun, 29 Jun 2008 07:06:37 +0000 (00:06 -0700)]
x86: use disable_apic in 32bit

change the enable_local_apic to static force_enable_local_apic for 32bit

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix init_memory_mapping over boundary, v4
Yinghai Lu [Sun, 29 Jun 2008 07:39:06 +0000 (00:39 -0700)]
x86: fix init_memory_mapping over boundary, v4

use PMD_SHIFT to calculate boundary also adjust size for pre-allocated
table size

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix warning in e820_reserve_resources with 32bit
Yinghai Lu [Sun, 29 Jun 2008 00:49:59 +0000 (17:49 -0700)]
x86: fix warning in e820_reserve_resources with 32bit

when 64bit resource is not enabled, we get:

arch/x86/kernel/e820.c: In function ‘e820_reserve_resources’:
arch/x86/kernel/e820.c:1217: warning: comparison is always false due to limited range of data type

because res->start/end is resource_t aka u32. it will overflow.

fix it with temp end of u64

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix init_memory_mapping over boundary v3
Yinghai Lu [Sat, 28 Jun 2008 10:30:39 +0000 (03:30 -0700)]
x86: fix init_memory_mapping over boundary v3

some ram-end boundary only has page alignment, instead of 2M alignment.

v2: make init_memory_mapping more solid: start could be any value other than 0
v3: fix NON PAE by handling left over in kernel_physical_mapping

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86_64: fix non-paravirt compilation
Jeremy Fitzhardinge [Fri, 27 Jun 2008 19:04:03 +0000 (12:04 -0700)]
x86_64: fix non-paravirt compilation

Make sure SWAPGS and PARAVIRT_ADJUST_EXCEPTION_FRAME are properly
defined when CONFIG_PARAVIRT is off.

Fixes Ingo's build failure:
arch/x86/kernel/entry_64.S: Assembler messages:
arch/x86/kernel/entry_64.S:1201: Error: invalid character '_' in mnemonic
arch/x86/kernel/entry_64.S:1205: Error: invalid character '_' in mnemonic
arch/x86/kernel/entry_64.S:1209: Error: invalid character '_' in mnemonic
arch/x86/kernel/entry_64.S:1213: Error: invalid character '_' in mnemonic

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Mark McLoughlin <markmc@redhat.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Stephen Tweedie <sct@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: let setup_arch call init_apic_mappings for 32bit
Yinghai Lu [Fri, 27 Jun 2008 08:41:56 +0000 (01:41 -0700)]
x86: let setup_arch call init_apic_mappings for 32bit

instead of calling it from trap_init()

also move init ioapic mapping out of apic_32.c

so 32 bit do same as 64 bit

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: early res print out alignment v2
Yinghai Lu [Fri, 27 Jun 2008 22:36:54 +0000 (15:36 -0700)]
x86: early res print out alignment v2

v2: fix print info to cont

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt: groundwork for 64-bit Xen support, fix #2
Jeremy Fitzhardinge [Thu, 26 Jun 2008 19:02:49 +0000 (12:02 -0700)]
x86/paravirt: groundwork for 64-bit Xen support, fix #2

Ingo Molnar wrote:
> that fixed the build but now we've got a boot crash with this config:
>
>  time.c: Detected 2010.304 MHz processor.
>  spurious 8259A interrupt: IRQ7.
>  BUG: unable to handle kernel NULL pointer dereference at  0000000000000000
>  IP: [<0000000000000000>]
>  PGD 0
>  Thread overran stack, or stack corrupted
>  Oops: 0010 [1] SMP
>  CPU 0
>

I don't know if this will fix this bug, but it's definitely a bugfix.
It was trashing random pages by overwriting them with pagetables...

Don't trash a large pmd's data when mapping physical memory.
This is a bugfix for "x86_64: adjust mapping of physical pagetables
to work with Xen".

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt: groundwork for 64-bit Xen support, fix
Jeremy Fitzhardinge [Thu, 26 Jun 2008 14:28:51 +0000 (07:28 -0700)]
x86/paravirt: groundwork for 64-bit Xen support, fix

Ingo Molnar wrote:
> * Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>
>
>>> It quickly broke the build in testing:
>>>
>>>  include/asm/pgalloc.h: In function ‘paravirt_pgd_free':
>>>  include/asm/pgalloc.h:14: error: parameter name omitted
>>>  arch/x86/kernel/entry_64.S: In file included from
>>> arch/x86/kernel/traps_64.c:51:include/asm/pgalloc.h: In function
>>> ‘paravirt_pgd_free':
>>>  include/asm/pgalloc.h:14: error: parameter name omitted
>>>
>>>
>> No, looks like my fault.  The non-PARAVIRT version of
>> paravirt_pgd_free() is:
>>
>> static inline void paravirt_pgd_free(struct mm_struct *mm, pgd_t *) {}
>>
>> but C doesn't like missing parameter names, even if unused.
>>
>> This should fix it:
>>
>
> that fixed the build but now we've got a boot crash with this config:
>
>  time.c: Detected 2010.304 MHz processor.
>  spurious 8259A interrupt: IRQ7.
>  BUG: unable to handle kernel NULL pointer dereference at  0000000000000000
>  IP: [<0000000000000000>]
>  PGD 0
>  Thread overran stack, or stack corrupted
>  Oops: 0010 [1] SMP
>  CPU 0
>
> with:
>
>   http://redhat.com/~mingo/misc/config-Thu_Jun_26_12_46_46_CEST_2008.bad
>

Use SWAPGS_UNSAFE_STACK in ia32entry.S in the places where the active
stack is the usermode stack.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move fix mapping page table range early
Yinghai Lu [Thu, 26 Jun 2008 04:51:28 +0000 (21:51 -0700)]
x86: move fix mapping page table range early

do that in init_memory_mapping

also remove one init_ohci1394_dma_on_all_controllers

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: clean up ARCH_SETUP
Yinghai Lu [Thu, 26 Jun 2008 02:52:15 +0000 (19:52 -0700)]
x86: clean up ARCH_SETUP

asm-x86/paravirt.h already have protection with CONFIG_PARAVIRT inside

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: limit E820 map when a user-defined memory map is specified
Bernhard Walle [Wed, 25 Jun 2008 19:39:16 +0000 (21:39 +0200)]
x86: limit E820 map when a user-defined memory map is specified

This patch brings back limiting of the E820 map when a user-defined
E820 map is specified. While the behaviour of i386 (32 bit) was to limit
the E820 map (and /proc/iomem), the behaviour of x86-64 (64 bit) was not to
limit.

That patch limits the E820 map again for both x86 architectures.

Code was tested for compilation and booting on a 32 bit and 64 bit system.

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Acked-by: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: kexec@lists.infradead.org
Cc: vgoyal@redhat.com
Cc: Bernhard Walle <bwalle@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix pte allocation in "x86: introduce init_memory_mapping for 32bit"
Jeremy Fitzhardinge [Tue, 24 Jun 2008 21:32:48 +0000 (17:32 -0400)]
x86: fix pte allocation in "x86: introduce init_memory_mapping for 32bit"

The patch "x86: introduce init_memory_mapping for 32bit" does not allocate
enough space for PTEs if the CPU does not implement PSE.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Acked-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt, 64-bit: make load_gs_index() a paravirt operation
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:32 +0000 (00:19 -0400)]
x86/paravirt, 64-bit: make load_gs_index() a paravirt operation

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt, 64-bit: add adjust_exception_frame
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:31 +0000 (00:19 -0400)]
x86/paravirt, 64-bit: add adjust_exception_frame

64-bit Xen pushes a couple of extra words onto an exception frame.
Add a hook to deal with them.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: swapgs pvop with a user-stack can never be called
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:30 +0000 (00:19 -0400)]
x86, 64-bit: swapgs pvop with a user-stack can never be called

It's never safe to call a swapgs pvop when the user stack is current -
it must be inline replaced.  Rather than making a call, the
SWAPGS_UNSAFE_STACK pvop always just puts "swapgs" as a placeholder,
which must either be replaced inline or trap'n'emulated (somehow).

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: ia32entry: replace privileged instructions with pvops
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:29 +0000 (00:19 -0400)]
x86, 64-bit: ia32entry: replace privileged instructions with pvops

Replace privileged instructions with the corresponding pvops in
ia32entry.S.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt: add sysret/sysexit pvops for returning to 32-bit compatibility userspace
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:28 +0000 (00:19 -0400)]
x86/paravirt: add sysret/sysexit pvops for returning to 32-bit compatibility userspace

In a 64-bit system, we need separate sysret/sysexit operations to
return to a 32-bit userspace.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citirx.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt, 64-bit: don't restore user rsp within sysret
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:27 +0000 (00:19 -0400)]
x86/paravirt, 64-bit: don't restore user rsp within sysret

There's no need to combine restoring the user rsp within the sysret
pvop, so split it out.  This makes the pvop's semantics closer to the
machine instruction.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citirx.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt: split sysret and sysexit
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:26 +0000 (00:19 -0400)]
x86/paravirt: split sysret and sysexit

Don't conflate sysret and sysexit; they're different instructions with
different semantics, and may be in use at the same time (at least
within the same kernel, depending on whether its an Intel or AMD
system).

sysexit - just return to userspace, does no register restoration of
    any kind; must explicitly atomically enable interrupts.

sysret - reloads flags from r11, so no need to explicitly enable
    interrupts on 64-bit, responsible for restoring usermode %gs

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citirx.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: use __KERNEL_DS as SS when returning to a kernel thread
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:25 +0000 (00:19 -0400)]
x86: use __KERNEL_DS as SS when returning to a kernel thread

This is needed when the kernel is running on RING3, such as under Xen.
x86_64 has a weird feature that makes it #GP on iret when SS is a null
descriptor.

This need to be tested on bare metal to make sure it doesn't cause any
problems. AMD specs say SS is always ignored (except on iret?).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: save %fs and %gs before load_TLS() and arch_leave_lazy_cpu_mode()
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:24 +0000 (00:19 -0400)]
x86: save %fs and %gs before load_TLS() and arch_leave_lazy_cpu_mode()

We must do this because load_TLS() may need to clear %fs and %gs.
(e.g. under Xen).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: __switch_to(): move arch_leave_lazy_cpu_mode() to the right place
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:23 +0000 (00:19 -0400)]
x86, 64-bit: __switch_to(): move arch_leave_lazy_cpu_mode() to the right place

We must leave lazy mode before switching the %fs and %gs selectors.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: split set_pte_vaddr()
Eduardo Habkost [Wed, 25 Jun 2008 04:19:22 +0000 (00:19 -0400)]
x86, 64-bit: split set_pte_vaddr()

We will need to set a pte on l3_user_pgt. Extract set_pte_vaddr_pud()
from set_pte_vaddr(), that will accept the l3 page table as parameter.

This change should be a no-op for existing code.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: PSE no longer a hard requirement
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:21 +0000 (00:19 -0400)]
x86, 64-bit: PSE no longer a hard requirement

Because Xen doesn't support PSE mappings in guests, all code which
assumed the presence of PSE has been changed to fall back to smaller
mappings if necessary.  As a result, PSE is optional rather than
required (though still used whereever possible).

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: create small vmemmap mappings if PSE not available
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:20 +0000 (00:19 -0400)]
x86, 64-bit: create small vmemmap mappings if PSE not available

If PSE is not available, then fall back to 4k page mappings for the
vmemmap area.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: adjust mapping of physical pagetables to work with Xen
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:19 +0000 (00:19 -0400)]
x86, 64-bit: adjust mapping of physical pagetables to work with Xen

This makes a few of changes to the construction of the initial
pagetables to work better with paravirt_ops/Xen.  The main areas
are:

 1. Support non-PSE mapping of memory, since Xen doesn't currently
    allow 2M pages to be mapped in guests.

 2. Make sure that the ioremap alias of all pages are dropped before
    attaching the new page to the pagetable.  This avoids having
    writable aliases of pagetable pages.

 3. Preserve existing pagetable entries, rather than overwriting.  Its
    possible that a fair amount of pagetable has already been constructed,
    so reuse what's already in place rather than ignoring and overwriting it.

The algorithm relies on the invariant that any page which is part of
the kernel pagetable is itself mapped in the linear memory area.  This
way, it can avoid using ioremap on a pagetable page.

The invariant holds because it maps memory from low to high addresses,
and also allocates memory from low to high.  Each allocated page can
map at least 2M of address space, so the mapped area will always
progress much faster than the allocated area.  It relies on the early
boot code mapping enough pages to get started.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: split x86_64_start_kernel
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:18 +0000 (00:19 -0400)]
x86, 64-bit: split x86_64_start_kernel

Split x86_64_start_kernel() into two pieces:

   The first essentially cleans up after head_64.S.  It clears the
   bss, zaps low identity mappings, sets up some early exception
   handlers.

   The second part preserves the boot data, reserves the kernel's
   text/data/bss, pagetables and ramdisk, and then starts the kernel
   proper.

This split is so that Xen can call the second part to do the set up it
needs done.  It doesn't need any of the first part setups, because it
doesn't boot via head_64.S, and its redundant or actively damaging.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: add FIX_PARAVIRT_BOOTMAP fixmap slot
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:17 +0000 (00:19 -0400)]
x86, 64-bit: add FIX_PARAVIRT_BOOTMAP fixmap slot

This matches 32 bit.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agoparavirt/x86, 64-bit: move __PAGE_OFFSET to leave a space for hypervisor
Eduardo Habkost [Wed, 25 Jun 2008 04:19:16 +0000 (00:19 -0400)]
paravirt/x86, 64-bit: move __PAGE_OFFSET to leave a space for hypervisor

Set __PAGE_OFFSET to the most negative possible address +
16*PGDIR_SIZE.  The gap is to allow a space for a hypervisor to fit.
The gap is more or less arbitrary, but it's what Xen needs.

When booting native, kernel/head_64.S has a set of compile-time
generated pagetables used at boot time.  This patch removes their
absolutely hard-coded layout, and makes it parameterised on
__PAGE_OFFSET (and __START_KERNEL_map).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt: define PARA_INDIRECT for indirect asm calls
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:15 +0000 (00:19 -0400)]
x86/paravirt: define PARA_INDIRECT for indirect asm calls

On 32-bit it's best to use a %cs: prefix to access memory where the
other segments may not bet set up properly yet.  On 64-bit it's best
to use a rip-relative addressing mode.  Define PARA_INDIRECT() to
abstract this and generate the proper addressing mode in each case.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt: add debugging for missing operations
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:14 +0000 (00:19 -0400)]
x86/paravirt: add debugging for missing operations

Rather than just jumping to 0 when there's a missing operation, raise a BUG.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: preallocate and prepopulate separately
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:13 +0000 (00:19 -0400)]
x86: preallocate and prepopulate separately

Jan Beulich points out that vmalloc_sync_all() assumes that the
kernel's pmd is always expected to be present in the pgd.  The current
pgd construction code will add the pgd to the pgd_list before its pmds
have been pre-populated, thereby making it visible to
vmalloc_sync_all().

However, because pgd_prepopulate_pmd also does the allocation, it may
block and cannot be done under spinlock.

The solution is to preallocate the pmds out of the spinlock, then
populate them while holding the pgd_list lock.

This patch also pulls the pmd preallocation and mop-up functions out
to be common, assuming that the compiler will generate no code for
them when PREALLOCTED_PMDS is 0.  Also, there's no need for pgd_ctor
to clear the pgd again, since it's allocated as a zeroed page.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86/paravirt: add a pgd_alloc/free hooks
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:12 +0000 (00:19 -0400)]
x86/paravirt: add a pgd_alloc/free hooks

Add hooks which are called at pgd_alloc/free time.  The pgd_alloc hook
may return an error code, which if non-zero, causes the pgd allocation
to be failed.  The hooks may be used to allocate/free auxillary
per-pgd information.

also fix:

> * Ingo Molnar <mingo@elte.hu> wrote:
>
>  include/asm/pgalloc.h: In function ‘paravirt_pgd_free':
>  include/asm/pgalloc.h:14: error: parameter name omitted
>  arch/x86/kernel/entry_64.S: In file included from
>  arch/x86/kernel/traps_64.c:51:include/asm/pgalloc.h: In function ‘paravirt_pgd_free':
>  include/asm/pgalloc.h:14: error: parameter name omitted

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: simplify vmalloc_sync_all
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:11 +0000 (00:19 -0400)]
x86: simplify vmalloc_sync_all

vmalloc_sync_all() is only called from register_die_notifier and
alloc_vm_area.  Neither is on any performance-critical paths, so
vmalloc_sync_all() itself is not on any hot paths.

Given that the optimisations in vmalloc_sync_all add a fair amount of
code and complexity, and are fairly hard to evaluate for correctness,
it's better to just remove them to simplify the code rather than worry
about its absolute performance.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: add sync_cmpxchg
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:10 +0000 (00:19 -0400)]
x86, 64-bit: add sync_cmpxchg

Add sync_cmpxchg to match 32-bit's sync_cmpxchg.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86, 64-bit: add prototype for x86_64_start_kernel()
Jeremy Fitzhardinge [Wed, 25 Jun 2008 04:19:09 +0000 (00:19 -0400)]
x86, 64-bit: add prototype for x86_64_start_kernel()

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: build fix
Ingo Molnar [Thu, 26 Jun 2008 10:40:35 +0000 (12:40 +0200)]
x86: build fix

fix:

In file included from arch/x86/kernel/setup.c:118:
include/asm/highmem.h:64: error: expected identifier or ‘(' before ‘do'
include/asm/highmem.h:64: error: expected identifier or ‘(' before ‘while'
include/asm/highmem.h:67: error: expected identifier or ‘(' before ‘do'
include/asm/highmem.h:67: error: expected identifier or ‘(' before ‘while'

Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: remove extra newline from setup.c
Ingo Molnar [Thu, 26 Jun 2008 10:29:29 +0000 (12:29 +0200)]
x86: remove extra newline from setup.c

Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: we only have init_pg_tables_end for 32bit
Yinghai Lu [Thu, 26 Jun 2008 01:02:06 +0000 (18:02 -0700)]
x86: we only have init_pg_tables_end for 32bit

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: change some functions in setup.c to static
Yinghai Lu [Thu, 26 Jun 2008 01:00:22 +0000 (18:00 -0700)]
x86: change some functions in setup.c to static

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: make x86_find_smp_config depends on 64 bit too
Yinghai Lu [Thu, 26 Jun 2008 00:59:41 +0000 (17:59 -0700)]
x86: make x86_find_smp_config depends on 64 bit too

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move parse elfvorehdr back to setup.c
Yinghai Lu [Thu, 26 Jun 2008 00:58:55 +0000 (17:58 -0700)]
x86: move parse elfvorehdr back to setup.c

Signed-off-by: Yinghai <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move reserve_standard_io_resources back to setup.c
Yinghai Lu [Thu, 26 Jun 2008 00:58:02 +0000 (17:58 -0700)]
x86: move reserve_standard_io_resources back to setup.c

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move back crashkernel back to setup.c
Yinghai Lu [Thu, 26 Jun 2008 00:57:13 +0000 (17:57 -0700)]
x86: move back crashkernel back to setup.c

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move parse_setup_data back to setup.c
Yinghai Lu [Thu, 26 Jun 2008 00:56:22 +0000 (17:56 -0700)]
x86: move parse_setup_data back to setup.c

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: move boot_params back to setup.c
Yinghai Lu [Thu, 26 Jun 2008 00:55:20 +0000 (17:55 -0700)]
x86: move boot_params back to setup.c

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: rename setup_32.c to setup.c
Yinghai Lu [Thu, 26 Jun 2008 00:54:23 +0000 (17:54 -0700)]
x86: rename setup_32.c to setup.c

and let 64 bit use that instead of setup_64.c

[ mingo@elte.hu ]

x86: build fix

fix:

arch/x86/kernel/setup.c: In function ‘setup_arch':
arch/x86/kernel/setup.c:561: error: implicit declaration of function ‘efi_reserve_early'

and:

arch/x86/kernel/setup.c:766: error: implicit declaration of function 'init_cpu_to_node'

and:

arch/x86/kernel/setup.c:676: warning: operation on 'max_pfn_mapped' may be undefined

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: space to tab in setup_arch
Yinghai Lu [Thu, 26 Jun 2008 00:53:22 +0000 (17:53 -0700)]
x86: space to tab in setup_arch

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: merge 64bit setup_arch into setup_32
Yinghai Lu [Thu, 26 Jun 2008 00:52:35 +0000 (17:52 -0700)]
x86: merge 64bit setup_arch into setup_32

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: add extra includes for 64bit support
Yinghai Lu [Thu, 26 Jun 2008 00:51:29 +0000 (17:51 -0700)]
x86: add extra includes for 64bit support

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: put global variable for 32bit all together
Yinghai Lu [Thu, 26 Jun 2008 00:50:06 +0000 (17:50 -0700)]
x86: put global variable for 32bit all together

those variables are not needed by 64 bit.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: update reserve_initrd to support 64bit
Yinghai Lu [Thu, 26 Jun 2008 00:49:26 +0000 (17:49 -0700)]
x86: update reserve_initrd to support 64bit

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: we can use full bootmem after have init_memory_mapping
Yinghai Lu [Thu, 26 Jun 2008 00:48:23 +0000 (17:48 -0700)]
x86: we can use full bootmem after have init_memory_mapping

So remove outdated comments

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: rename setup.c to setup_percpu.c
Yinghai Lu [Thu, 26 Jun 2008 00:48:14 +0000 (17:48 -0700)]
x86: rename setup.c to setup_percpu.c

some functions need to be moved to setup_numa.c
after we merge setup32/64.c, some funcs need to be moved back to setup.c

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
16 years agox86: fix memory setup bug
Yinghai Lu [Thu, 26 Jun 2008 07:44:56 +0000 (00:44 -0700)]
x86: fix memory setup bug

interesting...

[    0.000000]   mapped low ram: 0 - 20000000
[    0.000000]   low ram: 00000000 - 1fff0000
[    0.000000]   bootmap 00002000 - 00006000

max_pfn_mapped > max_low_pfn?

it seems init_memory_mapping reveals an old bug.

please check attached test patch.

Signed-off-by: Ingo Molnar <mingo@elte.hu>