aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/i386/kernel/acpi/earlyquirk.c10
-rw-r--r--arch/i386/kernel/entry.S4
-rw-r--r--arch/i386/kernel/io_apic.c4
-rw-r--r--arch/i386/kernel/setup.c5
-rw-r--r--arch/i386/kernel/srat.c8
-rw-r--r--arch/i386/pci/acpi.c17
-rw-r--r--arch/i386/pci/mmconfig.c7
-rw-r--r--arch/ia64/ia32/sys_ia32.c2
-rw-r--r--arch/m68knommu/platform/68360/head-ram.S408
-rw-r--r--arch/m68knommu/platform/68360/head-rom.S420
-rw-r--r--arch/ppc64/kernel/iSeries_pci.c2
-rw-r--r--arch/ppc64/kernel/maple_pci.c56
-rw-r--r--arch/ppc64/kernel/pSeries_setup.c8
-rw-r--r--arch/ppc64/kernel/pSeries_smp.c13
-rw-r--r--arch/ppc64/kernel/pci.c425
-rw-r--r--arch/ppc64/kernel/pmac_pci.c60
-rw-r--r--arch/ppc64/kernel/pmac_setup.c13
-rw-r--r--arch/ppc64/kernel/process.c34
-rw-r--r--arch/ppc64/kernel/ptrace.c28
-rw-r--r--arch/ppc64/kernel/ptrace32.c34
-rw-r--r--arch/ppc64/kernel/ras.c2
-rw-r--r--arch/ppc64/kernel/setup.c16
-rw-r--r--arch/ppc64/kernel/signal.c9
-rw-r--r--arch/ppc64/kernel/signal32.c8
-rw-r--r--arch/ppc64/kernel/xics.c44
-rw-r--r--arch/ppc64/mm/fault.c31
-rw-r--r--arch/ppc64/xmon/privinst.h1
-rw-r--r--arch/ppc64/xmon/xmon.c20
-rw-r--r--arch/s390/kernel/compat_linux.c2
-rw-r--r--arch/x86_64/boot/Makefile2
-rw-r--r--arch/x86_64/boot/compressed/misc.c6
-rw-r--r--arch/x86_64/defconfig65
-rw-r--r--arch/x86_64/ia32/ia32entry.S51
-rw-r--r--arch/x86_64/ia32/sys_ia32.c2
-rw-r--r--arch/x86_64/kernel/Makefile1
-rw-r--r--arch/x86_64/kernel/acpi/sleep.c1
-rw-r--r--arch/x86_64/kernel/aperture.c2
-rw-r--r--arch/x86_64/kernel/apic.c42
-rw-r--r--arch/x86_64/kernel/asm-offsets.c1
-rw-r--r--arch/x86_64/kernel/crash.c1
-rw-r--r--arch/x86_64/kernel/e820.c2
-rw-r--r--arch/x86_64/kernel/early_printk.c46
-rw-r--r--arch/x86_64/kernel/entry.S222
-rw-r--r--arch/x86_64/kernel/genapic.c18
-rw-r--r--arch/x86_64/kernel/genapic_cluster.c4
-rw-r--r--arch/x86_64/kernel/genapic_flat.c12
-rw-r--r--arch/x86_64/kernel/head.S2
-rw-r--r--arch/x86_64/kernel/i8259.c23
-rw-r--r--arch/x86_64/kernel/init_task.c2
-rw-r--r--arch/x86_64/kernel/io_apic.c34
-rw-r--r--arch/x86_64/kernel/irq.c1
-rw-r--r--arch/x86_64/kernel/mce.c42
-rw-r--r--arch/x86_64/kernel/mpparse.c5
-rw-r--r--arch/x86_64/kernel/msr.c279
-rw-r--r--arch/x86_64/kernel/nmi.c5
-rw-r--r--arch/x86_64/kernel/pci-gart.c8
-rw-r--r--arch/x86_64/kernel/process.c38
-rw-r--r--arch/x86_64/kernel/setup.c87
-rw-r--r--arch/x86_64/kernel/setup64.c3
-rw-r--r--arch/x86_64/kernel/smp.c129
-rw-r--r--arch/x86_64/kernel/smpboot.c47
-rw-r--r--arch/x86_64/kernel/suspend.c17
-rw-r--r--arch/x86_64/kernel/time.c2
-rw-r--r--arch/x86_64/kernel/traps.c57
-rw-r--r--arch/x86_64/kernel/vsyscall.c8
-rw-r--r--arch/x86_64/mm/fault.c10
-rw-r--r--arch/x86_64/mm/init.c79
-rw-r--r--arch/x86_64/mm/k8topology.c13
-rw-r--r--arch/x86_64/mm/numa.c9
-rw-r--r--arch/x86_64/mm/srat.c68
-rw-r--r--arch/x86_64/pci/k8-bus.c10
-rw-r--r--arch/x86_64/pci/mmconfig.c7
72 files changed, 2175 insertions, 979 deletions
diff --git a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c
index f1b9d2a46dab..1ae2aeeda18b 100644
--- a/arch/i386/kernel/acpi/earlyquirk.c
+++ b/arch/i386/kernel/acpi/earlyquirk.c
@@ -7,6 +7,7 @@
7#include <linux/pci.h> 7#include <linux/pci.h>
8#include <asm/pci-direct.h> 8#include <asm/pci-direct.h>
9#include <asm/acpi.h> 9#include <asm/acpi.h>
10#include <asm/apic.h>
10 11
11static int __init check_bridge(int vendor, int device) 12static int __init check_bridge(int vendor, int device)
12{ 13{
@@ -15,6 +16,15 @@ static int __init check_bridge(int vendor, int device)
15 if (vendor == PCI_VENDOR_ID_NVIDIA) { 16 if (vendor == PCI_VENDOR_ID_NVIDIA) {
16 acpi_skip_timer_override = 1; 17 acpi_skip_timer_override = 1;
17 } 18 }
19#ifdef CONFIG_X86_LOCAL_APIC
20 /*
21 * ATI IXP chipsets get double timer interrupts.
22 * For now just do this for all ATI chipsets.
23 * FIXME: this needs to be checked for the non ACPI case too.
24 */
25 if (vendor == PCI_VENDOR_ID_ATI)
26 disable_timer_pin_1 = 1;
27#endif
18 return 0; 28 return 0;
19} 29}
20 30
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index 3aad03839660..9e24f7b207ee 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -319,7 +319,7 @@ work_notifysig: # deal with pending signals and
319 # vm86-space 319 # vm86-space
320 xorl %edx, %edx 320 xorl %edx, %edx
321 call do_notify_resume 321 call do_notify_resume
322 jmp restore_all 322 jmp resume_userspace
323 323
324 ALIGN 324 ALIGN
325work_notifysig_v86: 325work_notifysig_v86:
@@ -329,7 +329,7 @@ work_notifysig_v86:
329 movl %eax, %esp 329 movl %eax, %esp
330 xorl %edx, %edx 330 xorl %edx, %edx
331 call do_notify_resume 331 call do_notify_resume
332 jmp restore_all 332 jmp resume_userspace
333 333
334 # perform syscall exit tracing 334 # perform syscall exit tracing
335 ALIGN 335 ALIGN
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 35d3ce26a544..378313b0cce9 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -60,6 +60,8 @@ int sis_apic_bug = -1;
60 */ 60 */
61int nr_ioapic_registers[MAX_IO_APICS]; 61int nr_ioapic_registers[MAX_IO_APICS];
62 62
63int disable_timer_pin_1 __initdata;
64
63/* 65/*
64 * Rough estimation of how many shared IRQs there are, can 66 * Rough estimation of how many shared IRQs there are, can
65 * be changed anytime. 67 * be changed anytime.
@@ -2211,6 +2213,8 @@ static inline void check_timer(void)
2211 setup_nmi(); 2213 setup_nmi();
2212 enable_8259A_irq(0); 2214 enable_8259A_irq(0);
2213 } 2215 }
2216 if (disable_timer_pin_1 > 0)
2217 clear_IO_APIC_pin(0, pin1);
2214 return; 2218 return;
2215 } 2219 }
2216 clear_IO_APIC_pin(0, pin1); 2220 clear_IO_APIC_pin(0, pin1);
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index f3d808451d25..dc39ca6a7eca 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -851,6 +851,11 @@ static void __init parse_cmdline_early (char ** cmdline_p)
851#endif 851#endif
852 852
853#ifdef CONFIG_X86_LOCAL_APIC 853#ifdef CONFIG_X86_LOCAL_APIC
854 if (!memcmp(from, "disable_timer_pin_1", 19))
855 disable_timer_pin_1 = 1;
856 if (!memcmp(from, "enable_timer_pin_1", 18))
857 disable_timer_pin_1 = -1;
858
854 /* disable IO-APIC */ 859 /* disable IO-APIC */
855 else if (!memcmp(from, "noapic", 6)) 860 else if (!memcmp(from, "noapic", 6))
856 disable_ioapic_setup(); 861 disable_ioapic_setup();
diff --git a/arch/i386/kernel/srat.c b/arch/i386/kernel/srat.c
index 7b3b27d64409..516bf5653b02 100644
--- a/arch/i386/kernel/srat.c
+++ b/arch/i386/kernel/srat.c
@@ -213,12 +213,18 @@ static __init void node_read_chunk(int nid, struct node_memory_chunk_s *memory_c
213 node_end_pfn[nid] = memory_chunk->end_pfn; 213 node_end_pfn[nid] = memory_chunk->end_pfn;
214} 214}
215 215
216static u8 pxm_to_nid_map[MAX_PXM_DOMAINS];/* _PXM to logical node ID map */
217
218int pxm_to_node(int pxm)
219{
220 return pxm_to_nid_map[pxm];
221}
222
216/* Parse the ACPI Static Resource Affinity Table */ 223/* Parse the ACPI Static Resource Affinity Table */
217static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) 224static int __init acpi20_parse_srat(struct acpi_table_srat *sratp)
218{ 225{
219 u8 *start, *end, *p; 226 u8 *start, *end, *p;
220 int i, j, nid; 227 int i, j, nid;
221 u8 pxm_to_nid_map[MAX_PXM_DOMAINS];/* _PXM to logical node ID map */
222 u8 nid_to_pxm_map[MAX_NUMNODES];/* logical node ID to _PXM map */ 228 u8 nid_to_pxm_map[MAX_NUMNODES];/* logical node ID to _PXM map */
223 229
224 start = (u8 *)(&(sratp->reserved) + 1); /* skip header */ 230 start = (u8 *)(&(sratp->reserved) + 1); /* skip header */
diff --git a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
index 42913f43feb0..2941674f35eb 100644
--- a/arch/i386/pci/acpi.c
+++ b/arch/i386/pci/acpi.c
@@ -3,16 +3,31 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/irq.h> 4#include <linux/irq.h>
5#include <asm/hw_irq.h> 5#include <asm/hw_irq.h>
6#include <asm/numa.h>
6#include "pci.h" 7#include "pci.h"
7 8
8struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum) 9struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum)
9{ 10{
11 struct pci_bus *bus;
12
10 if (domain != 0) { 13 if (domain != 0) {
11 printk(KERN_WARNING "PCI: Multiple domains not supported\n"); 14 printk(KERN_WARNING "PCI: Multiple domains not supported\n");
12 return NULL; 15 return NULL;
13 } 16 }
14 17
15 return pcibios_scan_root(busnum); 18 bus = pcibios_scan_root(busnum);
19#ifdef CONFIG_ACPI_NUMA
20 if (bus != NULL) {
21 int pxm = acpi_get_pxm(device->handle);
22 if (pxm >= 0) {
23 bus->sysdata = (void *)(unsigned long)pxm_to_node(pxm);
24 printk("bus %d -> pxm %d -> node %ld\n",
25 busnum, pxm, (long)(bus->sysdata));
26 }
27 }
28#endif
29
30 return bus;
16} 31}
17 32
18extern int pci_routeirq; 33extern int pci_routeirq;
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index 60f0e7a1162a..dfbf80cff834 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -127,13 +127,6 @@ static int __init pci_mmcfg_init(void)
127 (pci_mmcfg_config[0].base_address == 0)) 127 (pci_mmcfg_config[0].base_address == 0))
128 goto out; 128 goto out;
129 129
130 /* Kludge for now. Don't use mmconfig on AMD systems because
131 those have some busses where mmconfig doesn't work,
132 and we don't parse ACPI MCFG well enough to handle that.
133 Remove when proper handling is added. */
134 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
135 goto out;
136
137 printk(KERN_INFO "PCI: Using MMCONFIG\n"); 130 printk(KERN_INFO "PCI: Using MMCONFIG\n");
138 raw_pci_ops = &pci_mmcfg; 131 raw_pci_ops = &pci_mmcfg;
139 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 132 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index e29a8a55486a..3fa67ecebc83 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -2327,7 +2327,7 @@ sys32_sendfile (int out_fd, int in_fd, int __user *offset, unsigned int count)
2327 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *) &of : NULL, count); 2327 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *) &of : NULL, count);
2328 set_fs(old_fs); 2328 set_fs(old_fs);
2329 2329
2330 if (!ret && offset && put_user(of, offset)) 2330 if (offset && put_user(of, offset))
2331 return -EFAULT; 2331 return -EFAULT;
2332 2332
2333 return ret; 2333 return ret;
diff --git a/arch/m68knommu/platform/68360/head-ram.S b/arch/m68knommu/platform/68360/head-ram.S
new file mode 100644
index 000000000000..a5c639a51eef
--- /dev/null
+++ b/arch/m68knommu/platform/68360/head-ram.S
@@ -0,0 +1,408 @@
1/* arch/m68knommu/platform/68360/head-ram.S
2 *
3 * Startup code for Motorola 68360
4 *
5 * Copyright 2001 (C) SED Systems, a Division of Calian Ltd.
6 * Based on: arch/m68knommu/platform/68328/pilot/crt0_rom.S
7 * Based on: arch/m68knommu/platform/68360/uCquicc/crt0_rom.S, 2.0.38.1.pre7
8 * uClinux Kernel
9 * Copyright (C) Michael Leslie <mleslie@lineo.com>
10 * Based on: arch/m68knommu/platform/68EZ328/ucsimm/crt0_rom.S
11 * Copyright (C) 1998 D. Jeff Dionne <jeff@uclinux.org>,
12 *
13 */
14#define ASSEMBLY
15#include <linux/config.h>
16
17.global _stext
18.global _start
19
20.global _rambase
21.global __ramvec
22.global _ramvec
23.global _ramstart
24.global _ramend
25
26.global _quicc_base
27.global _periph_base
28
29#define REGB 0x1000
30#define PEPAR (_dprbase + REGB + 0x0016)
31#define GMR (_dprbase + REGB + 0x0040)
32#define OR0 (_dprbase + REGB + 0x0054)
33#define BR0 (_dprbase + REGB + 0x0050)
34#define OR1 (_dprbase + REGB + 0x0064)
35#define BR1 (_dprbase + REGB + 0x0060)
36#define OR4 (_dprbase + REGB + 0x0094)
37#define BR4 (_dprbase + REGB + 0x0090)
38#define OR6 (_dprbase + REGB + 0x00b4)
39#define BR6 (_dprbase + REGB + 0x00b0)
40#define OR7 (_dprbase + REGB + 0x00c4)
41#define BR7 (_dprbase + REGB + 0x00c0)
42
43#define MCR (_dprbase + REGB + 0x0000)
44#define AVR (_dprbase + REGB + 0x0008)
45
46#define SYPCR (_dprbase + REGB + 0x0022)
47
48#define PLLCR (_dprbase + REGB + 0x0010)
49#define CLKOCR (_dprbase + REGB + 0x000C)
50#define CDVCR (_dprbase + REGB + 0x0014)
51
52#define BKAR (_dprbase + REGB + 0x0030)
53#define BKCR (_dprbase + REGB + 0x0034)
54#define SWIV (_dprbase + REGB + 0x0023)
55#define PICR (_dprbase + REGB + 0x0026)
56#define PITR (_dprbase + REGB + 0x002A)
57
58/* Define for all memory configuration */
59#define MCU_SIM_GMR 0x00000000
60#define SIM_OR_MASK 0x0fffffff
61
62/* Defines for chip select zero - the flash */
63#define SIM_OR0_MASK 0x20000002
64#define SIM_BR0_MASK 0x00000001
65
66
67/* Defines for chip select one - the RAM */
68#define SIM_OR1_MASK 0x10000000
69#define SIM_BR1_MASK 0x00000001
70
71#define MCU_SIM_MBAR_ADRS 0x0003ff00
72#define MCU_SIM_MBAR_BA_MASK 0xfffff000
73#define MCU_SIM_MBAR_AS_MASK 0x00000001
74
75#define MCU_SIM_PEPAR 0x00B4
76
77#define MCU_DISABLE_INTRPTS 0x2700
78#define MCU_SIM_AVR 0x00
79
80#define MCU_SIM_MCR 0x00005cff
81
82#define MCU_SIM_CLKOCR 0x00
83#define MCU_SIM_PLLCR 0x8000
84#define MCU_SIM_CDVCR 0x0000
85
86#define MCU_SIM_SYPCR 0x0000
87#define MCU_SIM_SWIV 0x00
88#define MCU_SIM_PICR 0x0000
89#define MCU_SIM_PITR 0x0000
90
91
92#include <asm/m68360_regs.h>
93
94
95/*
96 * By the time this RAM specific code begins to execute, DPRAM
97 * and DRAM should already be mapped and accessible.
98 */
99
100 .text
101_start:
102_stext:
103 nop
104 ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */
105 /* We should not need to setup the boot stack the reset should do it. */
106 movea.l #__ramend, %sp /*set up stack at the end of DRAM:*/
107
108set_mbar_register:
109 moveq.l #0x07, %d1 /* Setup MBAR */
110 movec %d1, %dfc
111
112 lea.l MCU_SIM_MBAR_ADRS, %a0
113 move.l #_dprbase, %d0
114 andi.l #MCU_SIM_MBAR_BA_MASK, %d0
115 ori.l #MCU_SIM_MBAR_AS_MASK, %d0
116 moves.l %d0, %a0@
117
118 moveq.l #0x05, %d1
119 movec.l %d1, %dfc
120
121 /* Now we can begin to access registers in DPRAM */
122
123set_sim_mcr:
124 /* Set Module Configuration Register */
125 move.l #MCU_SIM_MCR, MCR
126
127 /* to do: Determine cause of reset */
128
129 /*
130 * configure system clock MC68360 p. 6-40
131 * (value +1)*osc/128 = system clock
132 */
133set_sim_clock:
134 move.w #MCU_SIM_PLLCR, PLLCR
135 move.b #MCU_SIM_CLKOCR, CLKOCR
136 move.w #MCU_SIM_CDVCR, CDVCR
137
138 /* Wait for the PLL to settle */
139 move.w #16384, %d0
140pll_settle_wait:
141 subi.w #1, %d0
142 bne pll_settle_wait
143
144 /* Setup the system protection register, and watchdog timer register */
145 move.b #MCU_SIM_SWIV, SWIV
146 move.w #MCU_SIM_PICR, PICR
147 move.w #MCU_SIM_PITR, PITR
148 move.w #MCU_SIM_SYPCR, SYPCR
149
150 /* Clear DPRAM - system + parameter */
151 movea.l #_dprbase, %a0
152 movea.l #_dprbase+0x2000, %a1
153
154 /* Copy 0 to %a0 until %a0 == %a1 */
155clear_dpram:
156 movel #0, %a0@+
157 cmpal %a0, %a1
158 bhi clear_dpram
159
160configure_memory_controller:
161 /* Set up Global Memory Register (GMR) */
162 move.l #MCU_SIM_GMR, %d0
163 move.l %d0, GMR
164
165configure_chip_select_0:
166 move.l #__ramend, %d0
167 subi.l #__ramstart, %d0
168 subq.l #0x01, %d0
169 eori.l #SIM_OR_MASK, %d0
170 ori.l #SIM_OR0_MASK, %d0
171 move.l %d0, OR0
172
173 move.l #__ramstart, %d0
174 ori.l #SIM_BR0_MASK, %d0
175 move.l %d0, BR0
176
177configure_chip_select_1:
178 move.l #__rom_end, %d0
179 subi.l #__rom_start, %d0
180 subq.l #0x01, %d0
181 eori.l #SIM_OR_MASK, %d0
182 ori.l #SIM_OR1_MASK, %d0
183 move.l %d0, OR1
184
185 move.l #__rom_start, %d0
186 ori.l #SIM_BR1_MASK, %d0
187 move.l %d0, BR1
188
189 move.w #MCU_SIM_PEPAR, PEPAR
190
191 /* point to vector table: */
192 move.l #_romvec, %a0
193 move.l #_ramvec, %a1
194copy_vectors:
195 move.l %a0@, %d0
196 move.l %d0, %a1@
197 move.l %a0@, %a1@
198 addq.l #0x04, %a0
199 addq.l #0x04, %a1
200 cmp.l #_start, %a0
201 blt copy_vectors
202
203 move.l #_ramvec, %a1
204 movec %a1, %vbr
205
206
207 /* Copy data segment from ROM to RAM */
208 moveal #_stext, %a0
209 moveal #_sdata, %a1
210 moveal #_edata, %a2
211
212 /* Copy %a0 to %a1 until %a1 == %a2 */
213LD1:
214 move.l %a0@, %d0
215 addq.l #0x04, %a0
216 move.l %d0, %a1@
217 addq.l #0x04, %a1
218 cmp.l #_edata, %a1
219 blt LD1
220
221 moveal #_sbss, %a0
222 moveal #_ebss, %a1
223
224 /* Copy 0 to %a0 until %a0 == %a1 */
225L1:
226 movel #0, %a0@+
227 cmpal %a0, %a1
228 bhi L1
229
230load_quicc:
231 move.l #_dprbase, _quicc_base
232
233store_ram_size:
234 /* Set ram size information */
235 move.l #_sdata, _rambase
236 move.l #_ebss, _ramstart
237 move.l #__ramend, %d0
238 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
239 move.l %d0, _ramend /* Different from __ramend.*/
240
241store_flash_size:
242 /* Set rom size information */
243 move.l #__rom_end, %d0
244 sub.l #__rom_start, %d0
245 move.l %d0, rom_length
246
247 pea 0
248 pea env
249 pea %sp@(4)
250 pea 0
251
252 lea init_thread_union, %a2
253 lea 0x2000(%a2), %sp
254
255lp:
256 jsr start_kernel
257
258_exit:
259 jmp _exit
260
261
262 .data
263 .align 4
264env:
265 .long 0
266_quicc_base:
267 .long 0
268_periph_base:
269 .long 0
270_ramvec:
271 .long 0
272_rambase:
273 .long 0
274_ramstart:
275 .long 0
276_ramend:
277 .long 0
278_dprbase:
279 .long 0xffffe000
280
281 .text
282
283 /*
284 * These are the exception vectors at boot up, they are copied into RAM
285 * and then overwritten as needed.
286 */
287
288.section ".data.initvect","awx"
289 .long __ramend /* Reset: Initial Stack Pointer - 0. */
290 .long _start /* Reset: Initial Program Counter - 1. */
291 .long buserr /* Bus Error - 2. */
292 .long trap /* Address Error - 3. */
293 .long trap /* Illegal Instruction - 4. */
294 .long trap /* Divide by zero - 5. */
295 .long trap /* CHK, CHK2 Instructions - 6. */
296 .long trap /* TRAPcc, TRAPV Instructions - 7. */
297 .long trap /* Privilege Violation - 8. */
298 .long trap /* Trace - 9. */
299 .long trap /* Line 1010 Emulator - 10. */
300 .long trap /* Line 1111 Emualtor - 11. */
301 .long trap /* Harware Breakpoint - 12. */
302 .long trap /* (Reserved for Coprocessor Protocol Violation)- 13. */
303 .long trap /* Format Error - 14. */
304 .long trap /* Uninitialized Interrupt - 15. */
305 .long trap /* (Unassigned, Reserver) - 16. */
306 .long trap /* (Unassigned, Reserver) - 17. */
307 .long trap /* (Unassigned, Reserver) - 18. */
308 .long trap /* (Unassigned, Reserver) - 19. */
309 .long trap /* (Unassigned, Reserver) - 20. */
310 .long trap /* (Unassigned, Reserver) - 21. */
311 .long trap /* (Unassigned, Reserver) - 22. */
312 .long trap /* (Unassigned, Reserver) - 23. */
313 .long trap /* Spurious Interrupt - 24. */
314 .long trap /* Level 1 Interrupt Autovector - 25. */
315 .long trap /* Level 2 Interrupt Autovector - 26. */
316 .long trap /* Level 3 Interrupt Autovector - 27. */
317 .long trap /* Level 4 Interrupt Autovector - 28. */
318 .long trap /* Level 5 Interrupt Autovector - 29. */
319 .long trap /* Level 6 Interrupt Autovector - 30. */
320 .long trap /* Level 7 Interrupt Autovector - 31. */
321 .long system_call /* Trap Instruction Vectors 0 - 32. */
322 .long trap /* Trap Instruction Vectors 1 - 33. */
323 .long trap /* Trap Instruction Vectors 2 - 34. */
324 .long trap /* Trap Instruction Vectors 3 - 35. */
325 .long trap /* Trap Instruction Vectors 4 - 36. */
326 .long trap /* Trap Instruction Vectors 5 - 37. */
327 .long trap /* Trap Instruction Vectors 6 - 38. */
328 .long trap /* Trap Instruction Vectors 7 - 39. */
329 .long trap /* Trap Instruction Vectors 8 - 40. */
330 .long trap /* Trap Instruction Vectors 9 - 41. */
331 .long trap /* Trap Instruction Vectors 10 - 42. */
332 .long trap /* Trap Instruction Vectors 11 - 43. */
333 .long trap /* Trap Instruction Vectors 12 - 44. */
334 .long trap /* Trap Instruction Vectors 13 - 45. */
335 .long trap /* Trap Instruction Vectors 14 - 46. */
336 .long trap /* Trap Instruction Vectors 15 - 47. */
337 .long 0 /* (Reserved for Coprocessor) - 48. */
338 .long 0 /* (Reserved for Coprocessor) - 49. */
339 .long 0 /* (Reserved for Coprocessor) - 50. */
340 .long 0 /* (Reserved for Coprocessor) - 51. */
341 .long 0 /* (Reserved for Coprocessor) - 52. */
342 .long 0 /* (Reserved for Coprocessor) - 53. */
343 .long 0 /* (Reserved for Coprocessor) - 54. */
344 .long 0 /* (Reserved for Coprocessor) - 55. */
345 .long 0 /* (Reserved for Coprocessor) - 56. */
346 .long 0 /* (Reserved for Coprocessor) - 57. */
347 .long 0 /* (Reserved for Coprocessor) - 58. */
348 .long 0 /* (Unassigned, Reserved) - 59. */
349 .long 0 /* (Unassigned, Reserved) - 60. */
350 .long 0 /* (Unassigned, Reserved) - 61. */
351 .long 0 /* (Unassigned, Reserved) - 62. */
352 .long 0 /* (Unassigned, Reserved) - 63. */
353 /* The assignment of these vectors to the CPM is */
354 /* dependent on the configuration of the CPM vba */
355 /* fields. */
356 .long 0 /* (User-Defined Vectors 1) CPM Error - 64. */
357 .long 0 /* (User-Defined Vectors 2) CPM Parallel IO PC11- 65. */
358 .long 0 /* (User-Defined Vectors 3) CPM Parallel IO PC10- 66. */
359 .long 0 /* (User-Defined Vectors 4) CPM SMC2 / PIP - 67. */
360 .long 0 /* (User-Defined Vectors 5) CPM SMC1 - 68. */
361 .long 0 /* (User-Defined Vectors 6) CPM SPI - 69. */
362 .long 0 /* (User-Defined Vectors 7) CPM Parallel IO PC9 - 70. */
363 .long 0 /* (User-Defined Vectors 8) CPM Timer 4 - 71. */
364 .long 0 /* (User-Defined Vectors 9) CPM Reserved - 72. */
365 .long 0 /* (User-Defined Vectors 10) CPM Parallel IO PC8- 73. */
366 .long 0 /* (User-Defined Vectors 11) CPM Parallel IO PC7- 74. */
367 .long 0 /* (User-Defined Vectors 12) CPM Parallel IO PC6- 75. */
368 .long 0 /* (User-Defined Vectors 13) CPM Timer 3 - 76. */
369 .long 0 /* (User-Defined Vectors 14) CPM Reserved - 77. */
370 .long 0 /* (User-Defined Vectors 15) CPM Parallel IO PC5- 78. */
371 .long 0 /* (User-Defined Vectors 16) CPM Parallel IO PC4- 79. */
372 .long 0 /* (User-Defined Vectors 17) CPM Reserved - 80. */
373 .long 0 /* (User-Defined Vectors 18) CPM RISC Timer Tbl - 81. */
374 .long 0 /* (User-Defined Vectors 19) CPM Timer 2 - 82. */
375 .long 0 /* (User-Defined Vectors 21) CPM Reserved - 83. */
376 .long 0 /* (User-Defined Vectors 22) CPM IDMA2 - 84. */
377 .long 0 /* (User-Defined Vectors 23) CPM IDMA1 - 85. */
378 .long 0 /* (User-Defined Vectors 24) CPM SDMA Bus Err - 86. */
379 .long 0 /* (User-Defined Vectors 25) CPM Parallel IO PC3- 87. */
380 .long 0 /* (User-Defined Vectors 26) CPM Parallel IO PC2- 88. */
381 .long 0 /* (User-Defined Vectors 27) CPM Timer 1 - 89. */
382 .long 0 /* (User-Defined Vectors 28) CPM Parallel IO PC1- 90. */
383 .long 0 /* (User-Defined Vectors 29) CPM SCC 4 - 91. */
384 .long 0 /* (User-Defined Vectors 30) CPM SCC 3 - 92. */
385 .long 0 /* (User-Defined Vectors 31) CPM SCC 2 - 93. */
386 .long 0 /* (User-Defined Vectors 32) CPM SCC 1 - 94. */
387 .long 0 /* (User-Defined Vectors 33) CPM Parallel IO PC0- 95. */
388 /* I don't think anything uses the vectors after here. */
389 .long 0 /* (User-Defined Vectors 34) - 96. */
390 .long 0,0,0,0,0 /* (User-Defined Vectors 35 - 39). */
391 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 40 - 49). */
392 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 50 - 59). */
393 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 60 - 69). */
394 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 70 - 79). */
395 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 80 - 89). */
396 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 90 - 99). */
397 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 100 - 109). */
398 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 110 - 119). */
399 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 120 - 129). */
400 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 130 - 139). */
401 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 140 - 149). */
402 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 150 - 159). */
403 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 160 - 169). */
404 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 170 - 179). */
405 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 180 - 189). */
406 .long 0,0,0 /* (User-Defined Vectors 190 - 192). */
407.text
408ignore: rte
diff --git a/arch/m68knommu/platform/68360/head-rom.S b/arch/m68knommu/platform/68360/head-rom.S
new file mode 100644
index 000000000000..0da357a4cfee
--- /dev/null
+++ b/arch/m68knommu/platform/68360/head-rom.S
@@ -0,0 +1,420 @@
1/* arch/m68knommu/platform/68360/head-rom.S
2 *
3 * Startup code for Motorola 68360
4 *
5 * Copyright (C) SED Systems, a Division of Calian Ltd.
6 * Based on: arch/m68knommu/platform/68328/pilot/crt0_rom.S
7 * Based on: arch/m68knommu/platform/68360/uCquicc/crt0_rom.S, 2.0.38.1.pre7
8 * uClinux Kernel
9 * Copyright (C) Michael Leslie <mleslie@lineo.com>
10 * Based on: arch/m68knommu/platform/68EZ328/ucsimm/crt0_rom.S
11 * Copyright (C) 1998 D. Jeff Dionne <jeff@uclinux.org>,
12 *
13 */
14#include <linux/config.h>
15
16.global _stext
17.global _sbss
18.global _start
19
20.global _rambase
21.global __ramvec
22.global _ramvec
23.global _ramstart
24.global _ramend
25
26.global _quicc_base
27.global _periph_base
28
29#define REGB 0x1000
30#define PEPAR (_dprbase + REGB + 0x0016)
31#define GMR (_dprbase + REGB + 0x0040)
32#define OR0 (_dprbase + REGB + 0x0054)
33#define BR0 (_dprbase + REGB + 0x0050)
34
35#define OR1 (_dprbase + REGB + 0x0064)
36#define BR1 (_dprbase + REGB + 0x0060)
37
38#define OR2 (_dprbase + REGB + 0x0074)
39#define BR2 (_dprbase + REGB + 0x0070)
40
41#define OR3 (_dprbase + REGB + 0x0084)
42#define BR3 (_dprbase + REGB + 0x0080)
43
44#define OR4 (_dprbase + REGB + 0x0094)
45#define BR4 (_dprbase + REGB + 0x0090)
46
47#define OR5 (_dprbase + REGB + 0x00A4)
48#define BR5 (_dprbase + REGB + 0x00A0)
49
50#define OR6 (_dprbase + REGB + 0x00b4)
51#define BR6 (_dprbase + REGB + 0x00b0)
52
53#define OR7 (_dprbase + REGB + 0x00c4)
54#define BR7 (_dprbase + REGB + 0x00c0)
55
56#define MCR (_dprbase + REGB + 0x0000)
57#define AVR (_dprbase + REGB + 0x0008)
58
59#define SYPCR (_dprbase + REGB + 0x0022)
60
61#define PLLCR (_dprbase + REGB + 0x0010)
62#define CLKOCR (_dprbase + REGB + 0x000C)
63#define CDVCR (_dprbase + REGB + 0x0014)
64
65#define BKAR (_dprbase + REGB + 0x0030)
66#define BKCR (_dprbase + REGB + 0x0034)
67#define SWIV (_dprbase + REGB + 0x0023)
68#define PICR (_dprbase + REGB + 0x0026)
69#define PITR (_dprbase + REGB + 0x002A)
70
71/* Define for all memory configuration */
72#define MCU_SIM_GMR 0x00000000
73#define SIM_OR_MASK 0x0fffffff
74
75/* Defines for chip select zero - the flash */
76#define SIM_OR0_MASK 0x20000000
77#define SIM_BR0_MASK 0x00000001
78
79/* Defines for chip select one - the RAM */
80#define SIM_OR1_MASK 0x10000000
81#define SIM_BR1_MASK 0x00000001
82
83#define MCU_SIM_MBAR_ADRS 0x0003ff00
84#define MCU_SIM_MBAR_BA_MASK 0xfffff000
85#define MCU_SIM_MBAR_AS_MASK 0x00000001
86
87#define MCU_SIM_PEPAR 0x00B4
88
89#define MCU_DISABLE_INTRPTS 0x2700
90#define MCU_SIM_AVR 0x00
91
92#define MCU_SIM_MCR 0x00005cff
93
94#define MCU_SIM_CLKOCR 0x00
95#define MCU_SIM_PLLCR 0x8000
96#define MCU_SIM_CDVCR 0x0000
97
98#define MCU_SIM_SYPCR 0x0000
99#define MCU_SIM_SWIV 0x00
100#define MCU_SIM_PICR 0x0000
101#define MCU_SIM_PITR 0x0000
102
103
104#include <asm/m68360_regs.h>
105
106
107/*
108 * By the time this RAM specific code begins to execute, DPRAM
109 * and DRAM should already be mapped and accessible.
110 */
111
112 .text
113_start:
114_stext:
115 nop
116 ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */
117 /* We should not need to setup the boot stack the reset should do it. */
118 movea.l #__ramend, %sp /* set up stack at the end of DRAM:*/
119
120
121set_mbar_register:
122 moveq.l #0x07, %d1 /* Setup MBAR */
123 movec %d1, %dfc
124
125 lea.l MCU_SIM_MBAR_ADRS, %a0
126 move.l #_dprbase, %d0
127 andi.l #MCU_SIM_MBAR_BA_MASK, %d0
128 ori.l #MCU_SIM_MBAR_AS_MASK, %d0
129 moves.l %d0, %a0@
130
131 moveq.l #0x05, %d1
132 movec.l %d1, %dfc
133
134 /* Now we can begin to access registers in DPRAM */
135
136set_sim_mcr:
137 /* Set Module Configuration Register */
138 move.l #MCU_SIM_MCR, MCR
139
140 /* to do: Determine cause of reset */
141
142 /*
143 * configure system clock MC68360 p. 6-40
144 * (value +1)*osc/128 = system clock
145 * or
146 * (value + 1)*osc = system clock
147 * You do not need to divide the oscillator by 128 unless you want to.
148 */
149set_sim_clock:
150 move.w #MCU_SIM_PLLCR, PLLCR
151 move.b #MCU_SIM_CLKOCR, CLKOCR
152 move.w #MCU_SIM_CDVCR, CDVCR
153
154 /* Wait for the PLL to settle */
155 move.w #16384, %d0
156pll_settle_wait:
157 subi.w #1, %d0
158 bne pll_settle_wait
159
160 /* Setup the system protection register, and watchdog timer register */
161 move.b #MCU_SIM_SWIV, SWIV
162 move.w #MCU_SIM_PICR, PICR
163 move.w #MCU_SIM_PITR, PITR
164 move.w #MCU_SIM_SYPCR, SYPCR
165
166 /* Clear DPRAM - system + parameter */
167 movea.l #_dprbase, %a0
168 movea.l #_dprbase+0x2000, %a1
169
170 /* Copy 0 to %a0 until %a0 == %a1 */
171clear_dpram:
172 movel #0, %a0@+
173 cmpal %a0, %a1
174 bhi clear_dpram
175
176configure_memory_controller:
177 /* Set up Global Memory Register (GMR) */
178 move.l #MCU_SIM_GMR, %d0
179 move.l %d0, GMR
180
181configure_chip_select_0:
182 move.l #0x00400000, %d0
183 subq.l #0x01, %d0
184 eori.l #SIM_OR_MASK, %d0
185 ori.l #SIM_OR0_MASK, %d0
186 move.l %d0, OR0
187
188 move.l #__rom_start, %d0
189 ori.l #SIM_BR0_MASK, %d0
190 move.l %d0, BR0
191
192 move.l #0x0, BR1
193 move.l #0x0, BR2
194 move.l #0x0, BR3
195 move.l #0x0, BR4
196 move.l #0x0, BR5
197 move.l #0x0, BR6
198 move.l #0x0, BR7
199
200 move.w #MCU_SIM_PEPAR, PEPAR
201
202 /* point to vector table: */
203 move.l #_romvec, %a0
204 move.l #_ramvec, %a1
205copy_vectors:
206 move.l %a0@, %d0
207 move.l %d0, %a1@
208 move.l %a0@, %a1@
209 addq.l #0x04, %a0
210 addq.l #0x04, %a1
211 cmp.l #_start, %a0
212 blt copy_vectors
213
214 move.l #_ramvec, %a1
215 movec %a1, %vbr
216
217
218 /* Copy data segment from ROM to RAM */
219 moveal #_etext, %a0
220 moveal #_sdata, %a1
221 moveal #_edata, %a2
222
223 /* Copy %a0 to %a1 until %a1 == %a2 */
224LD1:
225 move.l %a0@, %d0
226 addq.l #0x04, %a0
227 move.l %d0, %a1@
228 addq.l #0x04, %a1
229 cmp.l #_edata, %a1
230 blt LD1
231
232 moveal #_sbss, %a0
233 moveal #_ebss, %a1
234
235 /* Copy 0 to %a0 until %a0 == %a1 */
236L1:
237 movel #0, %a0@+
238 cmpal %a0, %a1
239 bhi L1
240
241load_quicc:
242 move.l #_dprbase, _quicc_base
243
244store_ram_size:
245 /* Set ram size information */
246 move.l #_sdata, _rambase
247 move.l #_ebss, _ramstart
248 move.l #__ramend, %d0
249 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
250 move.l %d0, _ramend /* Different from __ramend.*/
251
252store_flash_size:
253 /* Set rom size information */
254 move.l #__rom_end, %d0
255 sub.l #__rom_start, %d0
256 move.l %d0, rom_length
257
258 pea 0
259 pea env
260 pea %sp@(4)
261 pea 0
262
263 lea init_thread_union, %a2
264 lea 0x2000(%a2), %sp
265
266lp:
267 jsr start_kernel
268
269_exit:
270 jmp _exit
271
272
273 .data
274 .align 4
275env:
276 .long 0
277_quicc_base:
278 .long 0
279_periph_base:
280 .long 0
281_ramvec:
282 .long 0
283_rambase:
284 .long 0
285_ramstart:
286 .long 0
287_ramend:
288 .long 0
289_dprbase:
290 .long 0xffffe000
291
292
293 .text
294
295 /*
296 * These are the exception vectors at boot up, they are copied into RAM
297 * and then overwritten as needed.
298 */
299
300.section ".data.initvect","awx"
301 .long __ramend /* Reset: Initial Stack Pointer - 0. */
302 .long _start /* Reset: Initial Program Counter - 1. */
303 .long buserr /* Bus Error - 2. */
304 .long trap /* Address Error - 3. */
305 .long trap /* Illegal Instruction - 4. */
306 .long trap /* Divide by zero - 5. */
307 .long trap /* CHK, CHK2 Instructions - 6. */
308 .long trap /* TRAPcc, TRAPV Instructions - 7. */
309 .long trap /* Privilege Violation - 8. */
310 .long trap /* Trace - 9. */
311 .long trap /* Line 1010 Emulator - 10. */
312 .long trap /* Line 1111 Emualtor - 11. */
313 .long trap /* Harware Breakpoint - 12. */
314 .long trap /* (Reserved for Coprocessor Protocol Violation)- 13. */
315 .long trap /* Format Error - 14. */
316 .long trap /* Uninitialized Interrupt - 15. */
317 .long trap /* (Unassigned, Reserver) - 16. */
318 .long trap /* (Unassigned, Reserver) - 17. */
319 .long trap /* (Unassigned, Reserver) - 18. */
320 .long trap /* (Unassigned, Reserver) - 19. */
321 .long trap /* (Unassigned, Reserver) - 20. */
322 .long trap /* (Unassigned, Reserver) - 21. */
323 .long trap /* (Unassigned, Reserver) - 22. */
324 .long trap /* (Unassigned, Reserver) - 23. */
325 .long trap /* Spurious Interrupt - 24. */
326 .long trap /* Level 1 Interrupt Autovector - 25. */
327 .long trap /* Level 2 Interrupt Autovector - 26. */
328 .long trap /* Level 3 Interrupt Autovector - 27. */
329 .long trap /* Level 4 Interrupt Autovector - 28. */
330 .long trap /* Level 5 Interrupt Autovector - 29. */
331 .long trap /* Level 6 Interrupt Autovector - 30. */
332 .long trap /* Level 7 Interrupt Autovector - 31. */
333 .long system_call /* Trap Instruction Vectors 0 - 32. */
334 .long trap /* Trap Instruction Vectors 1 - 33. */
335 .long trap /* Trap Instruction Vectors 2 - 34. */
336 .long trap /* Trap Instruction Vectors 3 - 35. */
337 .long trap /* Trap Instruction Vectors 4 - 36. */
338 .long trap /* Trap Instruction Vectors 5 - 37. */
339 .long trap /* Trap Instruction Vectors 6 - 38. */
340 .long trap /* Trap Instruction Vectors 7 - 39. */
341 .long trap /* Trap Instruction Vectors 8 - 40. */
342 .long trap /* Trap Instruction Vectors 9 - 41. */
343 .long trap /* Trap Instruction Vectors 10 - 42. */
344 .long trap /* Trap Instruction Vectors 11 - 43. */
345 .long trap /* Trap Instruction Vectors 12 - 44. */
346 .long trap /* Trap Instruction Vectors 13 - 45. */
347 .long trap /* Trap Instruction Vectors 14 - 46. */
348 .long trap /* Trap Instruction Vectors 15 - 47. */
349 .long 0 /* (Reserved for Coprocessor) - 48. */
350 .long 0 /* (Reserved for Coprocessor) - 49. */
351 .long 0 /* (Reserved for Coprocessor) - 50. */
352 .long 0 /* (Reserved for Coprocessor) - 51. */
353 .long 0 /* (Reserved for Coprocessor) - 52. */
354 .long 0 /* (Reserved for Coprocessor) - 53. */
355 .long 0 /* (Reserved for Coprocessor) - 54. */
356 .long 0 /* (Reserved for Coprocessor) - 55. */
357 .long 0 /* (Reserved for Coprocessor) - 56. */
358 .long 0 /* (Reserved for Coprocessor) - 57. */
359 .long 0 /* (Reserved for Coprocessor) - 58. */
360 .long 0 /* (Unassigned, Reserved) - 59. */
361 .long 0 /* (Unassigned, Reserved) - 60. */
362 .long 0 /* (Unassigned, Reserved) - 61. */
363 .long 0 /* (Unassigned, Reserved) - 62. */
364 .long 0 /* (Unassigned, Reserved) - 63. */
365 /* The assignment of these vectors to the CPM is */
366 /* dependent on the configuration of the CPM vba */
367 /* fields. */
368 .long 0 /* (User-Defined Vectors 1) CPM Error - 64. */
369 .long 0 /* (User-Defined Vectors 2) CPM Parallel IO PC11- 65. */
370 .long 0 /* (User-Defined Vectors 3) CPM Parallel IO PC10- 66. */
371 .long 0 /* (User-Defined Vectors 4) CPM SMC2 / PIP - 67. */
372 .long 0 /* (User-Defined Vectors 5) CPM SMC1 - 68. */
373 .long 0 /* (User-Defined Vectors 6) CPM SPI - 69. */
374 .long 0 /* (User-Defined Vectors 7) CPM Parallel IO PC9 - 70. */
375 .long 0 /* (User-Defined Vectors 8) CPM Timer 4 - 71. */
376 .long 0 /* (User-Defined Vectors 9) CPM Reserved - 72. */
377 .long 0 /* (User-Defined Vectors 10) CPM Parallel IO PC8- 73. */
378 .long 0 /* (User-Defined Vectors 11) CPM Parallel IO PC7- 74. */
379 .long 0 /* (User-Defined Vectors 12) CPM Parallel IO PC6- 75. */
380 .long 0 /* (User-Defined Vectors 13) CPM Timer 3 - 76. */
381 .long 0 /* (User-Defined Vectors 14) CPM Reserved - 77. */
382 .long 0 /* (User-Defined Vectors 15) CPM Parallel IO PC5- 78. */
383 .long 0 /* (User-Defined Vectors 16) CPM Parallel IO PC4- 79. */
384 .long 0 /* (User-Defined Vectors 17) CPM Reserved - 80. */
385 .long 0 /* (User-Defined Vectors 18) CPM RISC Timer Tbl - 81. */
386 .long 0 /* (User-Defined Vectors 19) CPM Timer 2 - 82. */
387 .long 0 /* (User-Defined Vectors 21) CPM Reserved - 83. */
388 .long 0 /* (User-Defined Vectors 22) CPM IDMA2 - 84. */
389 .long 0 /* (User-Defined Vectors 23) CPM IDMA1 - 85. */
390 .long 0 /* (User-Defined Vectors 24) CPM SDMA Bus Err - 86. */
391 .long 0 /* (User-Defined Vectors 25) CPM Parallel IO PC3- 87. */
392 .long 0 /* (User-Defined Vectors 26) CPM Parallel IO PC2- 88. */
393 .long 0 /* (User-Defined Vectors 27) CPM Timer 1 - 89. */
394 .long 0 /* (User-Defined Vectors 28) CPM Parallel IO PC1- 90. */
395 .long 0 /* (User-Defined Vectors 29) CPM SCC 4 - 91. */
396 .long 0 /* (User-Defined Vectors 30) CPM SCC 3 - 92. */
397 .long 0 /* (User-Defined Vectors 31) CPM SCC 2 - 93. */
398 .long 0 /* (User-Defined Vectors 32) CPM SCC 1 - 94. */
399 .long 0 /* (User-Defined Vectors 33) CPM Parallel IO PC0- 95. */
400 /* I don't think anything uses the vectors after here. */
401 .long 0 /* (User-Defined Vectors 34) - 96. */
402 .long 0,0,0,0,0 /* (User-Defined Vectors 35 - 39). */
403 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 40 - 49). */
404 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 50 - 59). */
405 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 60 - 69). */
406 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 70 - 79). */
407 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 80 - 89). */
408 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 90 - 99). */
409 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 100 - 109). */
410 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 110 - 119). */
411 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 120 - 129). */
412 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 130 - 139). */
413 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 140 - 149). */
414 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 150 - 159). */
415 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 160 - 169). */
416 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 170 - 179). */
417 .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 180 - 189). */
418 .long 0,0,0 /* (User-Defined Vectors 190 - 192). */
419.text
420ignore: rte
diff --git a/arch/ppc64/kernel/iSeries_pci.c b/arch/ppc64/kernel/iSeries_pci.c
index 356e4fd9a94f..fbc273c32bcc 100644
--- a/arch/ppc64/kernel/iSeries_pci.c
+++ b/arch/ppc64/kernel/iSeries_pci.c
@@ -252,7 +252,7 @@ unsigned long __init find_and_init_phbs(void)
252 phb = (struct pci_controller *)kmalloc(sizeof(struct pci_controller), GFP_KERNEL); 252 phb = (struct pci_controller *)kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
253 if (phb == NULL) 253 if (phb == NULL)
254 return -ENOMEM; 254 return -ENOMEM;
255 pci_setup_pci_controller(phb); 255 pci_setup_pci_controller(phb);
256 256
257 phb->pci_mem_offset = phb->local_number = bus; 257 phb->pci_mem_offset = phb->local_number = bus;
258 phb->first_busno = bus; 258 phb->first_busno = bus;
diff --git a/arch/ppc64/kernel/maple_pci.c b/arch/ppc64/kernel/maple_pci.c
index 5a8b4d8c2dd6..1d297e0edfc0 100644
--- a/arch/ppc64/kernel/maple_pci.c
+++ b/arch/ppc64/kernel/maple_pci.c
@@ -283,7 +283,7 @@ static void __init setup_u3_agp(struct pci_controller* hose)
283 * the reg address cell, we shall fix that by killing struct 283 * the reg address cell, we shall fix that by killing struct
284 * reg_property and using some accessor functions instead 284 * reg_property and using some accessor functions instead
285 */ 285 */
286 hose->first_busno = 0xf0; 286 hose->first_busno = 0xf0;
287 hose->last_busno = 0xff; 287 hose->last_busno = 0xff;
288 hose->ops = &u3_agp_pci_ops; 288 hose->ops = &u3_agp_pci_ops;
289 hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000); 289 hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000);
@@ -315,24 +315,24 @@ static int __init add_bridge(struct device_node *dev)
315 char* disp_name; 315 char* disp_name;
316 int *bus_range; 316 int *bus_range;
317 int primary = 1; 317 int primary = 1;
318 struct property *of_prop; 318 struct property *of_prop;
319 319
320 DBG("Adding PCI host bridge %s\n", dev->full_name); 320 DBG("Adding PCI host bridge %s\n", dev->full_name);
321 321
322 bus_range = (int *) get_property(dev, "bus-range", &len); 322 bus_range = (int *) get_property(dev, "bus-range", &len);
323 if (bus_range == NULL || len < 2 * sizeof(int)) { 323 if (bus_range == NULL || len < 2 * sizeof(int)) {
324 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n", 324 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
325 dev->full_name); 325 dev->full_name);
326 } 326 }
327 327
328 hose = alloc_bootmem(sizeof(struct pci_controller)); 328 hose = alloc_bootmem(sizeof(struct pci_controller));
329 if (hose == NULL) 329 if (hose == NULL)
330 return -ENOMEM; 330 return -ENOMEM;
331 pci_setup_pci_controller(hose); 331 pci_setup_pci_controller(hose);
332 332
333 hose->arch_data = dev; 333 hose->arch_data = dev;
334 hose->first_busno = bus_range ? bus_range[0] : 0; 334 hose->first_busno = bus_range ? bus_range[0] : 0;
335 hose->last_busno = bus_range ? bus_range[1] : 0xff; 335 hose->last_busno = bus_range ? bus_range[1] : 0xff;
336 336
337 of_prop = alloc_bootmem(sizeof(struct property) + 337 of_prop = alloc_bootmem(sizeof(struct property) +
338 sizeof(hose->global_number)); 338 sizeof(hose->global_number));
@@ -346,25 +346,25 @@ static int __init add_bridge(struct device_node *dev)
346 } 346 }
347 347
348 disp_name = NULL; 348 disp_name = NULL;
349 if (device_is_compatible(dev, "u3-agp")) { 349 if (device_is_compatible(dev, "u3-agp")) {
350 setup_u3_agp(hose); 350 setup_u3_agp(hose);
351 disp_name = "U3-AGP"; 351 disp_name = "U3-AGP";
352 primary = 0; 352 primary = 0;
353 } else if (device_is_compatible(dev, "u3-ht")) { 353 } else if (device_is_compatible(dev, "u3-ht")) {
354 setup_u3_ht(hose); 354 setup_u3_ht(hose);
355 disp_name = "U3-HT"; 355 disp_name = "U3-HT";
356 primary = 1; 356 primary = 1;
357 } 357 }
358 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n", 358 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
359 disp_name, hose->first_busno, hose->last_busno); 359 disp_name, hose->first_busno, hose->last_busno);
360 360
361 /* Interpret the "ranges" property */ 361 /* Interpret the "ranges" property */
362 /* This also maps the I/O region and sets isa_io/mem_base */ 362 /* This also maps the I/O region and sets isa_io/mem_base */
363 pci_process_bridge_OF_ranges(hose, dev); 363 pci_process_bridge_OF_ranges(hose, dev);
364 pci_setup_phb_io(hose, primary); 364 pci_setup_phb_io(hose, primary);
365 365
366 /* Fixup "bus-range" OF property */ 366 /* Fixup "bus-range" OF property */
367 fixup_bus_range(dev); 367 fixup_bus_range(dev);
368 368
369 return 0; 369 return 0;
370} 370}
diff --git a/arch/ppc64/kernel/pSeries_setup.c b/arch/ppc64/kernel/pSeries_setup.c
index 9490b6c5b173..bfadccc7b8be 100644
--- a/arch/ppc64/kernel/pSeries_setup.c
+++ b/arch/ppc64/kernel/pSeries_setup.c
@@ -590,6 +590,13 @@ static int pseries_shared_idle(void)
590 return 0; 590 return 0;
591} 591}
592 592
593static int pSeries_pci_probe_mode(struct pci_bus *bus)
594{
595 if (systemcfg->platform & PLATFORM_LPAR)
596 return PCI_PROBE_DEVTREE;
597 return PCI_PROBE_NORMAL;
598}
599
593struct machdep_calls __initdata pSeries_md = { 600struct machdep_calls __initdata pSeries_md = {
594 .probe = pSeries_probe, 601 .probe = pSeries_probe,
595 .setup_arch = pSeries_setup_arch, 602 .setup_arch = pSeries_setup_arch,
@@ -597,6 +604,7 @@ struct machdep_calls __initdata pSeries_md = {
597 .get_cpuinfo = pSeries_get_cpuinfo, 604 .get_cpuinfo = pSeries_get_cpuinfo,
598 .log_error = pSeries_log_error, 605 .log_error = pSeries_log_error,
599 .pcibios_fixup = pSeries_final_fixup, 606 .pcibios_fixup = pSeries_final_fixup,
607 .pci_probe_mode = pSeries_pci_probe_mode,
600 .irq_bus_setup = pSeries_irq_bus_setup, 608 .irq_bus_setup = pSeries_irq_bus_setup,
601 .restart = rtas_restart, 609 .restart = rtas_restart,
602 .power_off = rtas_power_off, 610 .power_off = rtas_power_off,
diff --git a/arch/ppc64/kernel/pSeries_smp.c b/arch/ppc64/kernel/pSeries_smp.c
index 79c7f3223665..d2c7e2c4733b 100644
--- a/arch/ppc64/kernel/pSeries_smp.c
+++ b/arch/ppc64/kernel/pSeries_smp.c
@@ -272,6 +272,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
272 unsigned long start_here = __pa((u32)*((unsigned long *) 272 unsigned long start_here = __pa((u32)*((unsigned long *)
273 pSeries_secondary_smp_init)); 273 pSeries_secondary_smp_init));
274 unsigned int pcpu; 274 unsigned int pcpu;
275 int start_cpu;
275 276
276 if (cpu_isset(lcpu, of_spin_map)) 277 if (cpu_isset(lcpu, of_spin_map))
277 /* Already started by OF and sitting in spin loop */ 278 /* Already started by OF and sitting in spin loop */
@@ -282,12 +283,20 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
282 /* Fixup atomic count: it exited inside IRQ handler. */ 283 /* Fixup atomic count: it exited inside IRQ handler. */
283 paca[lcpu].__current->thread_info->preempt_count = 0; 284 paca[lcpu].__current->thread_info->preempt_count = 0;
284 285
285 status = rtas_call(rtas_token("start-cpu"), 3, 1, NULL, 286 /*
286 pcpu, start_here, lcpu); 287 * If the RTAS start-cpu token does not exist then presume the
288 * cpu is already spinning.
289 */
290 start_cpu = rtas_token("start-cpu");
291 if (start_cpu == RTAS_UNKNOWN_SERVICE)
292 return 1;
293
294 status = rtas_call(start_cpu, 3, 1, NULL, pcpu, start_here, lcpu);
287 if (status != 0) { 295 if (status != 0) {
288 printk(KERN_ERR "start-cpu failed: %i\n", status); 296 printk(KERN_ERR "start-cpu failed: %i\n", status);
289 return 0; 297 return 0;
290 } 298 }
299
291 return 1; 300 return 1;
292} 301}
293 302
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
index 8447dcc2c2b3..861138ad092c 100644
--- a/arch/ppc64/kernel/pci.c
+++ b/arch/ppc64/kernel/pci.c
@@ -51,6 +51,10 @@ unsigned long io_page_mask;
51 51
52EXPORT_SYMBOL(io_page_mask); 52EXPORT_SYMBOL(io_page_mask);
53 53
54#ifdef CONFIG_PPC_MULTIPLATFORM
55static void fixup_resource(struct resource *res, struct pci_dev *dev);
56static void do_bus_setup(struct pci_bus *bus);
57#endif
54 58
55unsigned int pcibios_assign_all_busses(void) 59unsigned int pcibios_assign_all_busses(void)
56{ 60{
@@ -225,10 +229,287 @@ static void __init pcibios_claim_of_setup(void)
225} 229}
226#endif 230#endif
227 231
232#ifdef CONFIG_PPC_MULTIPLATFORM
233static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
234{
235 u32 *prop;
236 int len;
237
238 prop = (u32 *) get_property(np, name, &len);
239 if (prop && len >= 4)
240 return *prop;
241 return def;
242}
243
244static unsigned int pci_parse_of_flags(u32 addr0)
245{
246 unsigned int flags = 0;
247
248 if (addr0 & 0x02000000) {
249 flags |= IORESOURCE_MEM;
250 if (addr0 & 0x40000000)
251 flags |= IORESOURCE_PREFETCH;
252 } else if (addr0 & 0x01000000)
253 flags |= IORESOURCE_IO;
254 return flags;
255}
256
257#define GET_64BIT(prop, i) ((((u64) (prop)[(i)]) << 32) | (prop)[(i)+1])
258
259static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)
260{
261 u64 base, size;
262 unsigned int flags;
263 struct resource *res;
264 u32 *addrs, i;
265 int proplen;
266
267 addrs = (u32 *) get_property(node, "assigned-addresses", &proplen);
268 if (!addrs)
269 return;
270 for (; proplen >= 20; proplen -= 20, addrs += 5) {
271 flags = pci_parse_of_flags(addrs[0]);
272 if (!flags)
273 continue;
274 base = GET_64BIT(addrs, 1);
275 size = GET_64BIT(addrs, 3);
276 if (!size)
277 continue;
278 i = addrs[0] & 0xff;
279 if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {
280 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
281 } else if (i == dev->rom_base_reg) {
282 res = &dev->resource[PCI_ROM_RESOURCE];
283 flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
284 } else {
285 printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
286 continue;
287 }
288 res->start = base;
289 res->end = base + size - 1;
290 res->flags = flags;
291 res->name = pci_name(dev);
292 fixup_resource(res, dev);
293 }
294}
295
296static struct pci_dev *of_create_pci_dev(struct device_node *node,
297 struct pci_bus *bus, int devfn)
298{
299 struct pci_dev *dev;
300 const char *type;
301
302 dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
303 if (!dev)
304 return NULL;
305 type = get_property(node, "device_type", NULL);
306 if (type == NULL)
307 type = "";
308
309 memset(dev, 0, sizeof(struct pci_dev));
310 dev->bus = bus;
311 dev->sysdata = node;
312 dev->dev.parent = bus->bridge;
313 dev->dev.bus = &pci_bus_type;
314 dev->devfn = devfn;
315 dev->multifunction = 0; /* maybe a lie? */
316
317 dev->vendor = get_int_prop(node, "vendor-id", 0xffff);
318 dev->device = get_int_prop(node, "device-id", 0xffff);
319 dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);
320 dev->subsystem_device = get_int_prop(node, "subsystem-id", 0);
321
322 dev->cfg_size = 256; /*pci_cfg_space_size(dev);*/
323
324 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),
325 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
326 dev->class = get_int_prop(node, "class-code", 0);
327
328 dev->current_state = 4; /* unknown power state */
329
330 if (!strcmp(type, "pci")) {
331 /* a PCI-PCI bridge */
332 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
333 dev->rom_base_reg = PCI_ROM_ADDRESS1;
334 } else if (!strcmp(type, "cardbus")) {
335 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
336 } else {
337 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
338 dev->rom_base_reg = PCI_ROM_ADDRESS;
339 dev->irq = NO_IRQ;
340 if (node->n_intrs > 0) {
341 dev->irq = node->intrs[0].line;
342 pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
343 dev->irq);
344 }
345 }
346
347 pci_parse_of_addrs(node, dev);
348
349 pci_device_add(dev, bus);
350
351 /* XXX pci_scan_msi_device(dev); */
352
353 return dev;
354}
355
356static void of_scan_pci_bridge(struct device_node *node, struct pci_dev *dev);
357
358static void __devinit of_scan_bus(struct device_node *node,
359 struct pci_bus *bus)
360{
361 struct device_node *child = NULL;
362 u32 *reg;
363 int reglen, devfn;
364 struct pci_dev *dev;
365
366 while ((child = of_get_next_child(node, child)) != NULL) {
367 reg = (u32 *) get_property(child, "reg", &reglen);
368 if (reg == NULL || reglen < 20)
369 continue;
370 devfn = (reg[0] >> 8) & 0xff;
371 /* create a new pci_dev for this device */
372 dev = of_create_pci_dev(child, bus, devfn);
373 if (!dev)
374 continue;
375 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
376 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
377 of_scan_pci_bridge(child, dev);
378 }
379
380 do_bus_setup(bus);
381}
382
383static void __devinit of_scan_pci_bridge(struct device_node *node,
384 struct pci_dev *dev)
385{
386 struct pci_bus *bus;
387 u32 *busrange, *ranges;
388 int len, i, mode;
389 struct resource *res;
390 unsigned int flags;
391 u64 size;
392
393 /* parse bus-range property */
394 busrange = (u32 *) get_property(node, "bus-range", &len);
395 if (busrange == NULL || len != 8) {
396 printk(KERN_ERR "Can't get bus-range for PCI-PCI bridge %s\n",
397 node->full_name);
398 return;
399 }
400 ranges = (u32 *) get_property(node, "ranges", &len);
401 if (ranges == NULL) {
402 printk(KERN_ERR "Can't get ranges for PCI-PCI bridge %s\n",
403 node->full_name);
404 return;
405 }
406
407 bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
408 if (!bus) {
409 printk(KERN_ERR "Failed to create pci bus for %s\n",
410 node->full_name);
411 return;
412 }
413
414 bus->primary = dev->bus->number;
415 bus->subordinate = busrange[1];
416 bus->bridge_ctl = 0;
417 bus->sysdata = node;
418
419 /* parse ranges property */
420 /* PCI #address-cells == 3 and #size-cells == 2 always */
421 res = &dev->resource[PCI_BRIDGE_RESOURCES];
422 for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) {
423 res->flags = 0;
424 bus->resource[i] = res;
425 ++res;
426 }
427 i = 1;
428 for (; len >= 32; len -= 32, ranges += 8) {
429 flags = pci_parse_of_flags(ranges[0]);
430 size = GET_64BIT(ranges, 6);
431 if (flags == 0 || size == 0)
432 continue;
433 if (flags & IORESOURCE_IO) {
434 res = bus->resource[0];
435 if (res->flags) {
436 printk(KERN_ERR "PCI: ignoring extra I/O range"
437 " for bridge %s\n", node->full_name);
438 continue;
439 }
440 } else {
441 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {
442 printk(KERN_ERR "PCI: too many memory ranges"
443 " for bridge %s\n", node->full_name);
444 continue;
445 }
446 res = bus->resource[i];
447 ++i;
448 }
449 res->start = GET_64BIT(ranges, 1);
450 res->end = res->start + size - 1;
451 res->flags = flags;
452 fixup_resource(res, dev);
453 }
454 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
455 bus->number);
456
457 mode = PCI_PROBE_NORMAL;
458 if (ppc_md.pci_probe_mode)
459 mode = ppc_md.pci_probe_mode(bus);
460 if (mode == PCI_PROBE_DEVTREE)
461 of_scan_bus(node, bus);
462 else if (mode == PCI_PROBE_NORMAL)
463 pci_scan_child_bus(bus);
464}
465#endif /* CONFIG_PPC_MULTIPLATFORM */
466
467static void __devinit scan_phb(struct pci_controller *hose)
468{
469 struct pci_bus *bus;
470 struct device_node *node = hose->arch_data;
471 int i, mode;
472 struct resource *res;
473
474 bus = pci_create_bus(NULL, hose->first_busno, hose->ops, node);
475 if (bus == NULL) {
476 printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
477 hose->global_number);
478 return;
479 }
480 bus->secondary = hose->first_busno;
481 hose->bus = bus;
482
483 bus->resource[0] = res = &hose->io_resource;
484 if (res->flags && request_resource(&ioport_resource, res))
485 printk(KERN_ERR "Failed to request PCI IO region "
486 "on PCI domain %04x\n", hose->global_number);
487
488 for (i = 0; i < 3; ++i) {
489 res = &hose->mem_resources[i];
490 bus->resource[i+1] = res;
491 if (res->flags && request_resource(&iomem_resource, res))
492 printk(KERN_ERR "Failed to request PCI memory region "
493 "on PCI domain %04x\n", hose->global_number);
494 }
495
496 mode = PCI_PROBE_NORMAL;
497#ifdef CONFIG_PPC_MULTIPLATFORM
498 if (ppc_md.pci_probe_mode)
499 mode = ppc_md.pci_probe_mode(bus);
500 if (mode == PCI_PROBE_DEVTREE) {
501 bus->subordinate = hose->last_busno;
502 of_scan_bus(node, bus);
503 }
504#endif /* CONFIG_PPC_MULTIPLATFORM */
505 if (mode == PCI_PROBE_NORMAL)
506 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
507 pci_bus_add_devices(bus);
508}
509
228static int __init pcibios_init(void) 510static int __init pcibios_init(void)
229{ 511{
230 struct pci_controller *hose, *tmp; 512 struct pci_controller *hose, *tmp;
231 struct pci_bus *bus;
232 513
233 /* For now, override phys_mem_access_prot. If we need it, 514 /* For now, override phys_mem_access_prot. If we need it,
234 * later, we may move that initialization to each ppc_md 515 * later, we may move that initialization to each ppc_md
@@ -242,13 +523,8 @@ static int __init pcibios_init(void)
242 printk("PCI: Probing PCI hardware\n"); 523 printk("PCI: Probing PCI hardware\n");
243 524
244 /* Scan all of the recorded PCI controllers. */ 525 /* Scan all of the recorded PCI controllers. */
245 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { 526 list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
246 hose->last_busno = 0xff; 527 scan_phb(hose);
247 bus = pci_scan_bus(hose->first_busno, hose->ops,
248 hose->arch_data);
249 hose->bus = bus;
250 hose->last_busno = bus->subordinate;
251 }
252 528
253#ifndef CONFIG_PPC_ISERIES 529#ifndef CONFIG_PPC_ISERIES
254 if (pci_probe_only) 530 if (pci_probe_only)
@@ -820,120 +1096,89 @@ void phbs_remap_io(void)
820/* 1096/*
821 * ppc64 can have multifunction devices that do not respond to function 0. 1097 * ppc64 can have multifunction devices that do not respond to function 0.
822 * In this case we must scan all functions. 1098 * In this case we must scan all functions.
1099 * XXX this can go now, we use the OF device tree in all the
1100 * cases that caused problems. -- paulus
823 */ 1101 */
824int pcibios_scan_all_fns(struct pci_bus *bus, int devfn) 1102int pcibios_scan_all_fns(struct pci_bus *bus, int devfn)
825{ 1103{
826 struct device_node *busdn, *dn;
827
828 if (bus->self)
829 busdn = pci_device_to_OF_node(bus->self);
830 else
831 busdn = bus->sysdata; /* must be a phb */
832
833 if (busdn == NULL)
834 return 0;
835
836 /*
837 * Check to see if there is any of the 8 functions are in the
838 * device tree. If they are then we need to scan all the
839 * functions of this slot.
840 */
841 for (dn = busdn->child; dn; dn = dn->sibling) {
842 struct pci_dn *pdn = dn->data;
843 if (pdn && (pdn->devfn >> 3) == (devfn >> 3))
844 return 1;
845 }
846
847 return 0; 1104 return 0;
848} 1105}
849 1106
1107static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
1108{
1109 struct pci_controller *hose = pci_bus_to_host(dev->bus);
1110 unsigned long start, end, mask, offset;
1111
1112 if (res->flags & IORESOURCE_IO) {
1113 offset = (unsigned long)hose->io_base_virt - pci_io_base;
1114
1115 start = res->start += offset;
1116 end = res->end += offset;
1117
1118 /* Need to allow IO access to pages that are in the
1119 ISA range */
1120 if (start < MAX_ISA_PORT) {
1121 if (end > MAX_ISA_PORT)
1122 end = MAX_ISA_PORT;
1123
1124 start >>= PAGE_SHIFT;
1125 end >>= PAGE_SHIFT;
1126
1127 /* get the range of pages for the map */
1128 mask = ((1 << (end+1)) - 1) ^ ((1 << start) - 1);
1129 io_page_mask |= mask;
1130 }
1131 } else if (res->flags & IORESOURCE_MEM) {
1132 res->start += hose->pci_mem_offset;
1133 res->end += hose->pci_mem_offset;
1134 }
1135}
850 1136
851void __devinit pcibios_fixup_device_resources(struct pci_dev *dev, 1137void __devinit pcibios_fixup_device_resources(struct pci_dev *dev,
852 struct pci_bus *bus) 1138 struct pci_bus *bus)
853{ 1139{
854 /* Update device resources. */ 1140 /* Update device resources. */
855 struct pci_controller *hose = pci_bus_to_host(bus);
856 int i; 1141 int i;
857 1142
858 for (i = 0; i < PCI_NUM_RESOURCES; i++) { 1143 for (i = 0; i < PCI_NUM_RESOURCES; i++)
859 if (dev->resource[i].flags & IORESOURCE_IO) { 1144 if (dev->resource[i].flags)
860 unsigned long offset = (unsigned long)hose->io_base_virt 1145 fixup_resource(&dev->resource[i], dev);
861 - pci_io_base;
862 unsigned long start, end, mask;
863
864 start = dev->resource[i].start += offset;
865 end = dev->resource[i].end += offset;
866
867 /* Need to allow IO access to pages that are in the
868 ISA range */
869 if (start < MAX_ISA_PORT) {
870 if (end > MAX_ISA_PORT)
871 end = MAX_ISA_PORT;
872
873 start >>= PAGE_SHIFT;
874 end >>= PAGE_SHIFT;
875
876 /* get the range of pages for the map */
877 mask = ((1 << (end+1))-1) ^ ((1 << start)-1);
878 io_page_mask |= mask;
879 }
880 }
881 else if (dev->resource[i].flags & IORESOURCE_MEM) {
882 dev->resource[i].start += hose->pci_mem_offset;
883 dev->resource[i].end += hose->pci_mem_offset;
884 }
885 }
886} 1146}
887EXPORT_SYMBOL(pcibios_fixup_device_resources); 1147EXPORT_SYMBOL(pcibios_fixup_device_resources);
888 1148
889void __devinit pcibios_fixup_bus(struct pci_bus *bus) 1149static void __devinit do_bus_setup(struct pci_bus *bus)
890{ 1150{
891 struct pci_controller *hose = pci_bus_to_host(bus); 1151 struct pci_dev *dev;
892 struct pci_dev *dev = bus->self;
893 struct resource *res;
894 int i;
895 1152
896 if (!dev) { 1153 ppc_md.iommu_bus_setup(bus);
897 /* Root bus. */
898 1154
899 hose->bus = bus; 1155 list_for_each_entry(dev, &bus->devices, bus_list)
900 bus->resource[0] = res = &hose->io_resource; 1156 ppc_md.iommu_dev_setup(dev);
901 1157
902 if (res->flags && request_resource(&ioport_resource, res)) 1158 if (ppc_md.irq_bus_setup)
903 printk(KERN_ERR "Failed to request IO on " 1159 ppc_md.irq_bus_setup(bus);
904 "PCI domain %d\n", pci_domain_nr(bus)); 1160}
905 1161
906 for (i = 0; i < 3; ++i) { 1162void __devinit pcibios_fixup_bus(struct pci_bus *bus)
907 res = &hose->mem_resources[i]; 1163{
908 bus->resource[i+1] = res; 1164 struct pci_dev *dev = bus->self;
909 if (res->flags && request_resource(&iomem_resource, res)) 1165
910 printk(KERN_ERR "Failed to request MEM on " 1166 if (dev && pci_probe_only &&
911 "PCI domain %d\n", 1167 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
912 pci_domain_nr(bus));
913 }
914 } else if (pci_probe_only &&
915 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
916 /* This is a subordinate bridge */ 1168 /* This is a subordinate bridge */
917 1169
918 pci_read_bridge_bases(bus); 1170 pci_read_bridge_bases(bus);
919 pcibios_fixup_device_resources(dev, bus); 1171 pcibios_fixup_device_resources(dev, bus);
920 } 1172 }
921 1173
922 ppc_md.iommu_bus_setup(bus); 1174 do_bus_setup(bus);
923
924 list_for_each_entry(dev, &bus->devices, bus_list)
925 ppc_md.iommu_dev_setup(dev);
926
927 if (ppc_md.irq_bus_setup)
928 ppc_md.irq_bus_setup(bus);
929 1175
930 if (!pci_probe_only) 1176 if (!pci_probe_only)
931 return; 1177 return;
932 1178
933 list_for_each_entry(dev, &bus->devices, bus_list) { 1179 list_for_each_entry(dev, &bus->devices, bus_list)
934 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) 1180 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
935 pcibios_fixup_device_resources(dev, bus); 1181 pcibios_fixup_device_resources(dev, bus);
936 }
937} 1182}
938EXPORT_SYMBOL(pcibios_fixup_bus); 1183EXPORT_SYMBOL(pcibios_fixup_bus);
939 1184
diff --git a/arch/ppc64/kernel/pmac_pci.c b/arch/ppc64/kernel/pmac_pci.c
index d37bff2d7d40..dc40a0cad0b4 100644
--- a/arch/ppc64/kernel/pmac_pci.c
+++ b/arch/ppc64/kernel/pmac_pci.c
@@ -388,7 +388,7 @@ static void __init setup_u3_agp(struct pci_controller* hose)
388 * the reg address cell, we shall fix that by killing struct 388 * the reg address cell, we shall fix that by killing struct
389 * reg_property and using some accessor functions instead 389 * reg_property and using some accessor functions instead
390 */ 390 */
391 hose->first_busno = 0xf0; 391 hose->first_busno = 0xf0;
392 hose->last_busno = 0xff; 392 hose->last_busno = 0xff;
393 has_uninorth = 1; 393 has_uninorth = 1;
394 hose->ops = &macrisc_pci_ops; 394 hose->ops = &macrisc_pci_ops;
@@ -473,7 +473,7 @@ static void __init setup_u3_ht(struct pci_controller* hose)
473 continue; 473 continue;
474 } 474 }
475 cur++; 475 cur++;
476 DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n", 476 DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n",
477 cur-1, res->start - 1, cur, res->end + 1); 477 cur-1, res->start - 1, cur, res->end + 1);
478 hose->mem_resources[cur].name = np->full_name; 478 hose->mem_resources[cur].name = np->full_name;
479 hose->mem_resources[cur].flags = IORESOURCE_MEM; 479 hose->mem_resources[cur].flags = IORESOURCE_MEM;
@@ -603,24 +603,24 @@ static int __init add_bridge(struct device_node *dev)
603 char* disp_name; 603 char* disp_name;
604 int *bus_range; 604 int *bus_range;
605 int primary = 1; 605 int primary = 1;
606 struct property *of_prop; 606 struct property *of_prop;
607 607
608 DBG("Adding PCI host bridge %s\n", dev->full_name); 608 DBG("Adding PCI host bridge %s\n", dev->full_name);
609 609
610 bus_range = (int *) get_property(dev, "bus-range", &len); 610 bus_range = (int *) get_property(dev, "bus-range", &len);
611 if (bus_range == NULL || len < 2 * sizeof(int)) { 611 if (bus_range == NULL || len < 2 * sizeof(int)) {
612 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n", 612 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
613 dev->full_name); 613 dev->full_name);
614 } 614 }
615 615
616 hose = alloc_bootmem(sizeof(struct pci_controller)); 616 hose = alloc_bootmem(sizeof(struct pci_controller));
617 if (hose == NULL) 617 if (hose == NULL)
618 return -ENOMEM; 618 return -ENOMEM;
619 pci_setup_pci_controller(hose); 619 pci_setup_pci_controller(hose);
620 620
621 hose->arch_data = dev; 621 hose->arch_data = dev;
622 hose->first_busno = bus_range ? bus_range[0] : 0; 622 hose->first_busno = bus_range ? bus_range[0] : 0;
623 hose->last_busno = bus_range ? bus_range[1] : 0xff; 623 hose->last_busno = bus_range ? bus_range[1] : 0xff;
624 624
625 of_prop = alloc_bootmem(sizeof(struct property) + 625 of_prop = alloc_bootmem(sizeof(struct property) +
626 sizeof(hose->global_number)); 626 sizeof(hose->global_number));
@@ -634,24 +634,24 @@ static int __init add_bridge(struct device_node *dev)
634 } 634 }
635 635
636 disp_name = NULL; 636 disp_name = NULL;
637 if (device_is_compatible(dev, "u3-agp")) { 637 if (device_is_compatible(dev, "u3-agp")) {
638 setup_u3_agp(hose); 638 setup_u3_agp(hose);
639 disp_name = "U3-AGP"; 639 disp_name = "U3-AGP";
640 primary = 0; 640 primary = 0;
641 } else if (device_is_compatible(dev, "u3-ht")) { 641 } else if (device_is_compatible(dev, "u3-ht")) {
642 setup_u3_ht(hose); 642 setup_u3_ht(hose);
643 disp_name = "U3-HT"; 643 disp_name = "U3-HT";
644 primary = 1; 644 primary = 1;
645 } 645 }
646 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n", 646 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
647 disp_name, hose->first_busno, hose->last_busno); 647 disp_name, hose->first_busno, hose->last_busno);
648 648
649 /* Interpret the "ranges" property */ 649 /* Interpret the "ranges" property */
650 /* This also maps the I/O region and sets isa_io/mem_base */ 650 /* This also maps the I/O region and sets isa_io/mem_base */
651 pmac_process_bridge_OF_ranges(hose, dev, primary); 651 pmac_process_bridge_OF_ranges(hose, dev, primary);
652 652
653 /* Fixup "bus-range" OF property */ 653 /* Fixup "bus-range" OF property */
654 fixup_bus_range(dev); 654 fixup_bus_range(dev);
655 655
656 return 0; 656 return 0;
657} 657}
diff --git a/arch/ppc64/kernel/pmac_setup.c b/arch/ppc64/kernel/pmac_setup.c
index e7f695dcd8c8..325426c7bed0 100644
--- a/arch/ppc64/kernel/pmac_setup.c
+++ b/arch/ppc64/kernel/pmac_setup.c
@@ -477,6 +477,18 @@ static int __init pmac_probe(int platform)
477 return 1; 477 return 1;
478} 478}
479 479
480static int pmac_probe_mode(struct pci_bus *bus)
481{
482 struct device_node *node = bus->sysdata;
483
484 /* We need to use normal PCI probing for the AGP bus,
485 since the device for the AGP bridge isn't in the tree. */
486 if (bus->self == NULL && device_is_compatible(node, "u3-agp"))
487 return PCI_PROBE_NORMAL;
488
489 return PCI_PROBE_DEVTREE;
490}
491
480struct machdep_calls __initdata pmac_md = { 492struct machdep_calls __initdata pmac_md = {
481#ifdef CONFIG_HOTPLUG_CPU 493#ifdef CONFIG_HOTPLUG_CPU
482 .cpu_die = generic_mach_cpu_die, 494 .cpu_die = generic_mach_cpu_die,
@@ -488,6 +500,7 @@ struct machdep_calls __initdata pmac_md = {
488 .init_IRQ = pmac_init_IRQ, 500 .init_IRQ = pmac_init_IRQ,
489 .get_irq = mpic_get_irq, 501 .get_irq = mpic_get_irq,
490 .pcibios_fixup = pmac_pcibios_fixup, 502 .pcibios_fixup = pmac_pcibios_fixup,
503 .pci_probe_mode = pmac_probe_mode,
491 .restart = pmac_restart, 504 .restart = pmac_restart,
492 .power_off = pmac_power_off, 505 .power_off = pmac_power_off,
493 .halt = pmac_halt, 506 .halt = pmac_halt,
diff --git a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c
index 7a7e027653ad..887005358eb1 100644
--- a/arch/ppc64/kernel/process.c
+++ b/arch/ppc64/kernel/process.c
@@ -54,6 +54,7 @@
54#include <asm/sections.h> 54#include <asm/sections.h>
55#include <asm/tlbflush.h> 55#include <asm/tlbflush.h>
56#include <asm/time.h> 56#include <asm/time.h>
57#include <asm/plpar_wrappers.h>
57 58
58#ifndef CONFIG_SMP 59#ifndef CONFIG_SMP
59struct task_struct *last_task_used_math = NULL; 60struct task_struct *last_task_used_math = NULL;
@@ -163,7 +164,30 @@ int dump_task_altivec(struct pt_regs *regs, elf_vrregset_t *vrregs)
163 164
164#endif /* CONFIG_ALTIVEC */ 165#endif /* CONFIG_ALTIVEC */
165 166
167static void set_dabr_spr(unsigned long val)
168{
169 mtspr(SPRN_DABR, val);
170}
171
172int set_dabr(unsigned long dabr)
173{
174 int ret = 0;
175
176 if (firmware_has_feature(FW_FEATURE_XDABR)) {
177 /* We want to catch accesses from kernel and userspace */
178 unsigned long flags = H_DABRX_KERNEL|H_DABRX_USER;
179 ret = plpar_set_xdabr(dabr, flags);
180 } else if (firmware_has_feature(FW_FEATURE_DABR)) {
181 ret = plpar_set_dabr(dabr);
182 } else {
183 set_dabr_spr(dabr);
184 }
185
186 return ret;
187}
188
166DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array); 189DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array);
190static DEFINE_PER_CPU(unsigned long, current_dabr);
167 191
168struct task_struct *__switch_to(struct task_struct *prev, 192struct task_struct *__switch_to(struct task_struct *prev,
169 struct task_struct *new) 193 struct task_struct *new)
@@ -198,6 +222,11 @@ struct task_struct *__switch_to(struct task_struct *prev,
198 new->thread.regs->msr |= MSR_VEC; 222 new->thread.regs->msr |= MSR_VEC;
199#endif /* CONFIG_ALTIVEC */ 223#endif /* CONFIG_ALTIVEC */
200 224
225 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) {
226 set_dabr(new->thread.dabr);
227 __get_cpu_var(current_dabr) = new->thread.dabr;
228 }
229
201 flush_tlb_pending(); 230 flush_tlb_pending();
202 231
203 new_thread = &new->thread; 232 new_thread = &new->thread;
@@ -334,6 +363,11 @@ void flush_thread(void)
334 last_task_used_altivec = NULL; 363 last_task_used_altivec = NULL;
335#endif /* CONFIG_ALTIVEC */ 364#endif /* CONFIG_ALTIVEC */
336#endif /* CONFIG_SMP */ 365#endif /* CONFIG_SMP */
366
367 if (current->thread.dabr) {
368 current->thread.dabr = 0;
369 set_dabr(0);
370 }
337} 371}
338 372
339void 373void
diff --git a/arch/ppc64/kernel/ptrace.c b/arch/ppc64/kernel/ptrace.c
index 2993f108d96d..85ed3188a91d 100644
--- a/arch/ppc64/kernel/ptrace.c
+++ b/arch/ppc64/kernel/ptrace.c
@@ -17,6 +17,7 @@
17 * this archive for more details. 17 * this archive for more details.
18 */ 18 */
19 19
20#include <linux/config.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/mm.h> 23#include <linux/mm.h>
@@ -206,6 +207,19 @@ int sys_ptrace(long request, long pid, long addr, long data)
206 break; 207 break;
207 } 208 }
208 209
210 case PTRACE_GET_DEBUGREG: {
211 ret = -EINVAL;
212 /* We only support one DABR and no IABRS at the moment */
213 if (addr > 0)
214 break;
215 ret = put_user(child->thread.dabr,
216 (unsigned long __user *)data);
217 break;
218 }
219
220 case PTRACE_SET_DEBUGREG:
221 ret = ptrace_set_debugreg(child, addr, data);
222
209 case PTRACE_DETACH: 223 case PTRACE_DETACH:
210 ret = ptrace_detach(child, data); 224 ret = ptrace_detach(child, data);
211 break; 225 break;
@@ -274,6 +288,20 @@ int sys_ptrace(long request, long pid, long addr, long data)
274 break; 288 break;
275 } 289 }
276 290
291#ifdef CONFIG_ALTIVEC
292 case PTRACE_GETVRREGS:
293 /* Get the child altivec register state. */
294 flush_altivec_to_thread(child);
295 ret = get_vrregs((unsigned long __user *)data, child);
296 break;
297
298 case PTRACE_SETVRREGS:
299 /* Set the child altivec register state. */
300 flush_altivec_to_thread(child);
301 ret = set_vrregs(child, (unsigned long __user *)data);
302 break;
303#endif
304
277 default: 305 default:
278 ret = ptrace_request(child, request, addr, data); 306 ret = ptrace_request(child, request, addr, data);
279 break; 307 break;
diff --git a/arch/ppc64/kernel/ptrace32.c b/arch/ppc64/kernel/ptrace32.c
index 16436426c7e2..fb8c22d6084a 100644
--- a/arch/ppc64/kernel/ptrace32.c
+++ b/arch/ppc64/kernel/ptrace32.c
@@ -17,6 +17,7 @@
17 * this archive for more details. 17 * this archive for more details.
18 */ 18 */
19 19
20#include <linux/config.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/mm.h> 23#include <linux/mm.h>
@@ -337,6 +338,19 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
337 break; 338 break;
338 } 339 }
339 340
341 case PTRACE_GET_DEBUGREG: {
342 ret = -EINVAL;
343 /* We only support one DABR and no IABRS at the moment */
344 if (addr > 0)
345 break;
346 ret = put_user(child->thread.dabr, (u32 __user *)data);
347 break;
348 }
349
350 case PTRACE_SET_DEBUGREG:
351 ret = ptrace_set_debugreg(child, addr, data);
352 break;
353
340 case PTRACE_DETACH: 354 case PTRACE_DETACH:
341 ret = ptrace_detach(child, data); 355 ret = ptrace_detach(child, data);
342 break; 356 break;
@@ -405,9 +419,23 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
405 break; 419 break;
406 } 420 }
407 421
408 case PTRACE_GETEVENTMSG: 422 case PTRACE_GETEVENTMSG:
409 ret = put_user(child->ptrace_message, (unsigned int __user *) data); 423 ret = put_user(child->ptrace_message, (unsigned int __user *) data);
410 break; 424 break;
425
426#ifdef CONFIG_ALTIVEC
427 case PTRACE_GETVRREGS:
428 /* Get the child altivec register state. */
429 flush_altivec_to_thread(child);
430 ret = get_vrregs((unsigned long __user *)data, child);
431 break;
432
433 case PTRACE_SETVRREGS:
434 /* Set the child altivec register state. */
435 flush_altivec_to_thread(child);
436 ret = set_vrregs(child, (unsigned long __user *)data);
437 break;
438#endif
411 439
412 default: 440 default:
413 ret = ptrace_request(child, request, addr, data); 441 ret = ptrace_request(child, request, addr, data);
diff --git a/arch/ppc64/kernel/ras.c b/arch/ppc64/kernel/ras.c
index 3c00f7bfc1b5..41b97dc9cc0a 100644
--- a/arch/ppc64/kernel/ras.c
+++ b/arch/ppc64/kernel/ras.c
@@ -59,8 +59,6 @@ char mce_data_buf[RTAS_ERROR_LOG_MAX]
59/* This is true if we are using the firmware NMI handler (typically LPAR) */ 59/* This is true if we are using the firmware NMI handler (typically LPAR) */
60extern int fwnmi_active; 60extern int fwnmi_active;
61 61
62extern void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr);
63
64static int ras_get_sensor_state_token; 62static int ras_get_sensor_state_token;
65static int ras_check_exception_token; 63static int ras_check_exception_token;
66 64
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
index bfa8791c9807..5ac48bd64891 100644
--- a/arch/ppc64/kernel/setup.c
+++ b/arch/ppc64/kernel/setup.c
@@ -1064,8 +1064,6 @@ void __init setup_arch(char **cmdline_p)
1064#define PPC64_LINUX_FUNCTION 0x0f000000 1064#define PPC64_LINUX_FUNCTION 0x0f000000
1065#define PPC64_IPL_MESSAGE 0xc0000000 1065#define PPC64_IPL_MESSAGE 0xc0000000
1066#define PPC64_TERM_MESSAGE 0xb0000000 1066#define PPC64_TERM_MESSAGE 0xb0000000
1067#define PPC64_ATTN_MESSAGE 0xa0000000
1068#define PPC64_DUMP_MESSAGE 0xd0000000
1069 1067
1070static void ppc64_do_msg(unsigned int src, const char *msg) 1068static void ppc64_do_msg(unsigned int src, const char *msg)
1071{ 1069{
@@ -1093,20 +1091,6 @@ void ppc64_terminate_msg(unsigned int src, const char *msg)
1093 printk("[terminate]%04x %s\n", src, msg); 1091 printk("[terminate]%04x %s\n", src, msg);
1094} 1092}
1095 1093
1096/* Print something that needs attention (device error, etc) */
1097void ppc64_attention_msg(unsigned int src, const char *msg)
1098{
1099 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_ATTN_MESSAGE|src, msg);
1100 printk("[attention]%04x %s\n", src, msg);
1101}
1102
1103/* Print a dump progress message. */
1104void ppc64_dump_msg(unsigned int src, const char *msg)
1105{
1106 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_DUMP_MESSAGE|src, msg);
1107 printk("[dump]%04x %s\n", src, msg);
1108}
1109
1110/* This should only be called on processor 0 during calibrate decr */ 1094/* This should only be called on processor 0 during calibrate decr */
1111void __init setup_default_decr(void) 1095void __init setup_default_decr(void)
1112{ 1096{
diff --git a/arch/ppc64/kernel/signal.c b/arch/ppc64/kernel/signal.c
index 49a79a55c32d..347112cca3c0 100644
--- a/arch/ppc64/kernel/signal.c
+++ b/arch/ppc64/kernel/signal.c
@@ -550,6 +550,15 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
550 /* Whee! Actually deliver the signal. */ 550 /* Whee! Actually deliver the signal. */
551 if (TRAP(regs) == 0x0C00) 551 if (TRAP(regs) == 0x0C00)
552 syscall_restart(regs, &ka); 552 syscall_restart(regs, &ka);
553
554 /*
555 * Reenable the DABR before delivering the signal to
556 * user space. The DABR will have been cleared if it
557 * triggered inside the kernel.
558 */
559 if (current->thread.dabr)
560 set_dabr(current->thread.dabr);
561
553 return handle_signal(signr, &ka, &info, oldset, regs); 562 return handle_signal(signr, &ka, &info, oldset, regs);
554 } 563 }
555 564
diff --git a/arch/ppc64/kernel/signal32.c b/arch/ppc64/kernel/signal32.c
index 46f4d6cc7fc9..a8b7a5a56bb4 100644
--- a/arch/ppc64/kernel/signal32.c
+++ b/arch/ppc64/kernel/signal32.c
@@ -970,6 +970,14 @@ int do_signal32(sigset_t *oldset, struct pt_regs *regs)
970 newsp = regs->gpr[1]; 970 newsp = regs->gpr[1];
971 newsp &= ~0xfUL; 971 newsp &= ~0xfUL;
972 972
973 /*
974 * Reenable the DABR before delivering the signal to
975 * user space. The DABR will have been cleared if it
976 * triggered inside the kernel.
977 */
978 if (current->thread.dabr)
979 set_dabr(current->thread.dabr);
980
973 /* Whee! Actually deliver the signal. */ 981 /* Whee! Actually deliver the signal. */
974 if (ka.sa.sa_flags & SA_SIGINFO) 982 if (ka.sa.sa_flags & SA_SIGINFO)
975 ret = handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp); 983 ret = handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp);
diff --git a/arch/ppc64/kernel/xics.c b/arch/ppc64/kernel/xics.c
index d9dc6f28d050..daf93885dcfa 100644
--- a/arch/ppc64/kernel/xics.c
+++ b/arch/ppc64/kernel/xics.c
@@ -38,7 +38,7 @@ static void xics_mask_and_ack_irq(unsigned int irq);
38static void xics_end_irq(unsigned int irq); 38static void xics_end_irq(unsigned int irq);
39static void xics_set_affinity(unsigned int irq_nr, cpumask_t cpumask); 39static void xics_set_affinity(unsigned int irq_nr, cpumask_t cpumask);
40 40
41struct hw_interrupt_type xics_pic = { 41static struct hw_interrupt_type xics_pic = {
42 .typename = " XICS ", 42 .typename = " XICS ",
43 .startup = xics_startup, 43 .startup = xics_startup,
44 .enable = xics_enable_irq, 44 .enable = xics_enable_irq,
@@ -48,7 +48,7 @@ struct hw_interrupt_type xics_pic = {
48 .set_affinity = xics_set_affinity 48 .set_affinity = xics_set_affinity
49}; 49};
50 50
51struct hw_interrupt_type xics_8259_pic = { 51static struct hw_interrupt_type xics_8259_pic = {
52 .typename = " XICS/8259", 52 .typename = " XICS/8259",
53 .ack = xics_mask_and_ack_irq, 53 .ack = xics_mask_and_ack_irq,
54}; 54};
@@ -89,9 +89,8 @@ static struct xics_ipl __iomem *xics_per_cpu[NR_CPUS];
89static int xics_irq_8259_cascade = 0; 89static int xics_irq_8259_cascade = 0;
90static int xics_irq_8259_cascade_real = 0; 90static int xics_irq_8259_cascade_real = 0;
91static unsigned int default_server = 0xFF; 91static unsigned int default_server = 0xFF;
92/* also referenced in smp.c... */ 92static unsigned int default_distrib_server = 0;
93unsigned int default_distrib_server = 0; 93static unsigned int interrupt_server_size = 8;
94unsigned int interrupt_server_size = 8;
95 94
96/* 95/*
97 * XICS only has a single IPI, so encode the messages per CPU 96 * XICS only has a single IPI, so encode the messages per CPU
@@ -99,10 +98,10 @@ unsigned int interrupt_server_size = 8;
99struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned; 98struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned;
100 99
101/* RTAS service tokens */ 100/* RTAS service tokens */
102int ibm_get_xive; 101static int ibm_get_xive;
103int ibm_set_xive; 102static int ibm_set_xive;
104int ibm_int_on; 103static int ibm_int_on;
105int ibm_int_off; 104static int ibm_int_off;
106 105
107typedef struct { 106typedef struct {
108 int (*xirr_info_get)(int cpu); 107 int (*xirr_info_get)(int cpu);
@@ -284,16 +283,17 @@ static void xics_enable_irq(unsigned int virq)
284 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 283 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server,
285 DEFAULT_PRIORITY); 284 DEFAULT_PRIORITY);
286 if (call_status != 0) { 285 if (call_status != 0) {
287 printk(KERN_ERR "xics_enable_irq: irq=%d: ibm_set_xive " 286 printk(KERN_ERR "xics_enable_irq: irq=%u: ibm_set_xive "
288 "returned %x\n", irq, call_status); 287 "returned %d\n", irq, call_status);
288 printk("set_xive %x, server %x\n", ibm_set_xive, server);
289 return; 289 return;
290 } 290 }
291 291
292 /* Now unmask the interrupt (often a no-op) */ 292 /* Now unmask the interrupt (often a no-op) */
293 call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq); 293 call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq);
294 if (call_status != 0) { 294 if (call_status != 0) {
295 printk(KERN_ERR "xics_enable_irq: irq=%d: ibm_int_on " 295 printk(KERN_ERR "xics_enable_irq: irq=%u: ibm_int_on "
296 "returned %x\n", irq, call_status); 296 "returned %d\n", irq, call_status);
297 return; 297 return;
298 } 298 }
299} 299}
@@ -308,8 +308,8 @@ static void xics_disable_real_irq(unsigned int irq)
308 308
309 call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq); 309 call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq);
310 if (call_status != 0) { 310 if (call_status != 0) {
311 printk(KERN_ERR "xics_disable_real_irq: irq=%d: " 311 printk(KERN_ERR "xics_disable_real_irq: irq=%u: "
312 "ibm_int_off returned %x\n", irq, call_status); 312 "ibm_int_off returned %d\n", irq, call_status);
313 return; 313 return;
314 } 314 }
315 315
@@ -317,8 +317,8 @@ static void xics_disable_real_irq(unsigned int irq)
317 /* Have to set XIVE to 0xff to be able to remove a slot */ 317 /* Have to set XIVE to 0xff to be able to remove a slot */
318 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff); 318 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff);
319 if (call_status != 0) { 319 if (call_status != 0) {
320 printk(KERN_ERR "xics_disable_irq: irq=%d: ibm_set_xive(0xff)" 320 printk(KERN_ERR "xics_disable_irq: irq=%u: ibm_set_xive(0xff)"
321 " returned %x\n", irq, call_status); 321 " returned %d\n", irq, call_status);
322 return; 322 return;
323 } 323 }
324} 324}
@@ -380,7 +380,7 @@ int xics_get_irq(struct pt_regs *regs)
380 if (irq == NO_IRQ) 380 if (irq == NO_IRQ)
381 irq = real_irq_to_virt_slowpath(vec); 381 irq = real_irq_to_virt_slowpath(vec);
382 if (irq == NO_IRQ) { 382 if (irq == NO_IRQ) {
383 printk(KERN_ERR "Interrupt %d (real) is invalid," 383 printk(KERN_ERR "Interrupt %u (real) is invalid,"
384 " disabling it.\n", vec); 384 " disabling it.\n", vec);
385 xics_disable_real_irq(vec); 385 xics_disable_real_irq(vec);
386 } else 386 } else
@@ -622,7 +622,7 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
622 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq); 622 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);
623 623
624 if (status) { 624 if (status) {
625 printk(KERN_ERR "xics_set_affinity: irq=%d ibm,get-xive " 625 printk(KERN_ERR "xics_set_affinity: irq=%u ibm,get-xive "
626 "returns %d\n", irq, status); 626 "returns %d\n", irq, status);
627 return; 627 return;
628 } 628 }
@@ -641,7 +641,7 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
641 irq, newmask, xics_status[1]); 641 irq, newmask, xics_status[1]);
642 642
643 if (status) { 643 if (status) {
644 printk(KERN_ERR "xics_set_affinity: irq=%d ibm,set-xive " 644 printk(KERN_ERR "xics_set_affinity: irq=%u ibm,set-xive "
645 "returns %d\n", irq, status); 645 "returns %d\n", irq, status);
646 return; 646 return;
647 } 647 }
@@ -720,7 +720,7 @@ void xics_migrate_irqs_away(void)
720 720
721 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq); 721 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);
722 if (status) { 722 if (status) {
723 printk(KERN_ERR "migrate_irqs_away: irq=%d " 723 printk(KERN_ERR "migrate_irqs_away: irq=%u "
724 "ibm,get-xive returns %d\n", 724 "ibm,get-xive returns %d\n",
725 virq, status); 725 virq, status);
726 goto unlock; 726 goto unlock;
@@ -734,7 +734,7 @@ void xics_migrate_irqs_away(void)
734 if (xics_status[0] != get_hard_smp_processor_id(cpu)) 734 if (xics_status[0] != get_hard_smp_processor_id(cpu))
735 goto unlock; 735 goto unlock;
736 736
737 printk(KERN_WARNING "IRQ %d affinity broken off cpu %u\n", 737 printk(KERN_WARNING "IRQ %u affinity broken off cpu %u\n",
738 virq, cpu); 738 virq, cpu);
739 739
740 /* Reset affinity to all cpus */ 740 /* Reset affinity to all cpus */
diff --git a/arch/ppc64/mm/fault.c b/arch/ppc64/mm/fault.c
index 772f0714a5b7..7fbc68bbb739 100644
--- a/arch/ppc64/mm/fault.c
+++ b/arch/ppc64/mm/fault.c
@@ -77,6 +77,28 @@ static int store_updates_sp(struct pt_regs *regs)
77 return 0; 77 return 0;
78} 78}
79 79
80static void do_dabr(struct pt_regs *regs, unsigned long error_code)
81{
82 siginfo_t info;
83
84 if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
85 11, SIGSEGV) == NOTIFY_STOP)
86 return;
87
88 if (debugger_dabr_match(regs))
89 return;
90
91 /* Clear the DABR */
92 set_dabr(0);
93
94 /* Deliver the signal to userspace */
95 info.si_signo = SIGTRAP;
96 info.si_errno = 0;
97 info.si_code = TRAP_HWBKPT;
98 info.si_addr = (void __user *)regs->nip;
99 force_sig_info(SIGTRAP, &info, current);
100}
101
80/* 102/*
81 * The error_code parameter is 103 * The error_code parameter is
82 * - DSISR for a non-SLB data access fault, 104 * - DSISR for a non-SLB data access fault,
@@ -111,12 +133,9 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
111 if (!user_mode(regs) && (address >= TASK_SIZE)) 133 if (!user_mode(regs) && (address >= TASK_SIZE))
112 return SIGSEGV; 134 return SIGSEGV;
113 135
114 if (error_code & DSISR_DABRMATCH) { 136 if (error_code & DSISR_DABRMATCH) {
115 if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, 137 do_dabr(regs, error_code);
116 11, SIGSEGV) == NOTIFY_STOP) 138 return 0;
117 return 0;
118 if (debugger_dabr_match(regs))
119 return 0;
120 } 139 }
121 140
122 if (in_atomic() || mm == NULL) { 141 if (in_atomic() || mm == NULL) {
diff --git a/arch/ppc64/xmon/privinst.h b/arch/ppc64/xmon/privinst.h
index 183c3e400258..02eb40dac0b3 100644
--- a/arch/ppc64/xmon/privinst.h
+++ b/arch/ppc64/xmon/privinst.h
@@ -46,7 +46,6 @@ GSETSPR(287, pvr)
46GSETSPR(1008, hid0) 46GSETSPR(1008, hid0)
47GSETSPR(1009, hid1) 47GSETSPR(1009, hid1)
48GSETSPR(1010, iabr) 48GSETSPR(1010, iabr)
49GSETSPR(1013, dabr)
50GSETSPR(1023, pir) 49GSETSPR(1023, pir)
51 50
52static inline void store_inst(void *p) 51static inline void store_inst(void *p)
diff --git a/arch/ppc64/xmon/xmon.c b/arch/ppc64/xmon/xmon.c
index 45908b10acd3..74e63a886a69 100644
--- a/arch/ppc64/xmon/xmon.c
+++ b/arch/ppc64/xmon/xmon.c
@@ -586,6 +586,8 @@ int xmon_dabr_match(struct pt_regs *regs)
586{ 586{
587 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF)) 587 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF))
588 return 0; 588 return 0;
589 if (dabr.enabled == 0)
590 return 0;
589 xmon_core(regs, 0); 591 xmon_core(regs, 0);
590 return 1; 592 return 1;
591} 593}
@@ -628,20 +630,6 @@ int xmon_fault_handler(struct pt_regs *regs)
628 return 0; 630 return 0;
629} 631}
630 632
631/* On systems with a hypervisor, we can't set the DABR
632 (data address breakpoint register) directly. */
633static void set_controlled_dabr(unsigned long val)
634{
635#ifdef CONFIG_PPC_PSERIES
636 if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
637 int rc = plpar_hcall_norets(H_SET_DABR, val);
638 if (rc != H_Success)
639 xmon_printf("Warning: setting DABR failed (%d)\n", rc);
640 } else
641#endif
642 set_dabr(val);
643}
644
645static struct bpt *at_breakpoint(unsigned long pc) 633static struct bpt *at_breakpoint(unsigned long pc)
646{ 634{
647 int i; 635 int i;
@@ -728,7 +716,7 @@ static void insert_bpts(void)
728static void insert_cpu_bpts(void) 716static void insert_cpu_bpts(void)
729{ 717{
730 if (dabr.enabled) 718 if (dabr.enabled)
731 set_controlled_dabr(dabr.address | (dabr.enabled & 7)); 719 set_dabr(dabr.address | (dabr.enabled & 7));
732 if (iabr && cpu_has_feature(CPU_FTR_IABR)) 720 if (iabr && cpu_has_feature(CPU_FTR_IABR))
733 set_iabr(iabr->address 721 set_iabr(iabr->address
734 | (iabr->enabled & (BP_IABR|BP_IABR_TE))); 722 | (iabr->enabled & (BP_IABR|BP_IABR_TE)));
@@ -756,7 +744,7 @@ static void remove_bpts(void)
756 744
757static void remove_cpu_bpts(void) 745static void remove_cpu_bpts(void)
758{ 746{
759 set_controlled_dabr(0); 747 set_dabr(0);
760 if (cpu_has_feature(CPU_FTR_IABR)) 748 if (cpu_has_feature(CPU_FTR_IABR))
761 set_iabr(0); 749 set_iabr(0);
762} 750}
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 18610cea03a2..ed877d0f27e6 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -678,7 +678,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, size
678 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count); 678 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
679 set_fs(old_fs); 679 set_fs(old_fs);
680 680
681 if (!ret && offset && put_user(of, offset)) 681 if (offset && put_user(of, offset))
682 return -EFAULT; 682 return -EFAULT;
683 683
684 return ret; 684 return ret;
diff --git a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile
index f4399c701b77..18c6e915d69b 100644
--- a/arch/x86_64/boot/Makefile
+++ b/arch/x86_64/boot/Makefile
@@ -46,7 +46,7 @@ cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
46$(obj)/bzImage: $(obj)/bootsect $(obj)/setup \ 46$(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
47 $(obj)/vmlinux.bin $(obj)/tools/build FORCE 47 $(obj)/vmlinux.bin $(obj)/tools/build FORCE
48 $(call if_changed,image) 48 $(call if_changed,image)
49 @echo 'Kernel: $@ is ready' 49 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
50 50
51$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE 51$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
52 $(call if_changed,objcopy) 52 $(call if_changed,objcopy)
diff --git a/arch/x86_64/boot/compressed/misc.c b/arch/x86_64/boot/compressed/misc.c
index b38d5b8b5fb8..0e10fd84c7cc 100644
--- a/arch/x86_64/boot/compressed/misc.c
+++ b/arch/x86_64/boot/compressed/misc.c
@@ -83,7 +83,7 @@ static unsigned char *real_mode; /* Pointer to real-mode data */
83#endif 83#endif
84#define SCREEN_INFO (*(struct screen_info *)(real_mode+0)) 84#define SCREEN_INFO (*(struct screen_info *)(real_mode+0))
85 85
86extern char input_data[]; 86extern unsigned char input_data[];
87extern int input_len; 87extern int input_len;
88 88
89static long bytes_out = 0; 89static long bytes_out = 0;
@@ -288,7 +288,7 @@ void setup_normal_output_buffer(void)
288#else 288#else
289 if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024) error("Less than 2MB of memory"); 289 if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024) error("Less than 2MB of memory");
290#endif 290#endif
291 output_data = (char *)__PHYSICAL_START; /* Normally Points to 1M */ 291 output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */
292 free_mem_end_ptr = (long)real_mode; 292 free_mem_end_ptr = (long)real_mode;
293} 293}
294 294
@@ -305,7 +305,7 @@ void setup_output_buffer_if_we_run_high(struct moveparams *mv)
305#else 305#else
306 if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory"); 306 if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory");
307#endif 307#endif
308 mv->low_buffer_start = output_data = (char *)LOW_BUFFER_START; 308 mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START;
309 low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX 309 low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX
310 ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff; 310 ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff;
311 low_buffer_size = low_buffer_end - LOW_BUFFER_START; 311 low_buffer_size = low_buffer_end - LOW_BUFFER_START;
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index bf57e2362bf4..f8db7e500fbf 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,11 +1,12 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc6-git3 3# Linux kernel version: 2.6.13-git11
4# Fri Aug 12 16:40:34 2005 4# Mon Sep 12 16:16:16 2005
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
8CONFIG_X86=y 8CONFIG_X86=y
9CONFIG_SEMAPHORE_SLEEPERS=y
9CONFIG_MMU=y 10CONFIG_MMU=y
10CONFIG_RWSEM_GENERIC_SPINLOCK=y 11CONFIG_RWSEM_GENERIC_SPINLOCK=y
11CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
@@ -13,6 +14,7 @@ CONFIG_X86_CMPXCHG=y
13CONFIG_EARLY_PRINTK=y 14CONFIG_EARLY_PRINTK=y
14CONFIG_GENERIC_ISA_DMA=y 15CONFIG_GENERIC_ISA_DMA=y
15CONFIG_GENERIC_IOMAP=y 16CONFIG_GENERIC_IOMAP=y
17CONFIG_ARCH_MAY_HAVE_PC_FDC=y
16 18
17# 19#
18# Code maturity level options 20# Code maturity level options
@@ -26,6 +28,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
26# General setup 28# General setup
27# 29#
28CONFIG_LOCALVERSION="" 30CONFIG_LOCALVERSION=""
31CONFIG_LOCALVERSION_AUTO=y
29CONFIG_SWAP=y 32CONFIG_SWAP=y
30CONFIG_SYSVIPC=y 33CONFIG_SYSVIPC=y
31CONFIG_POSIX_MQUEUE=y 34CONFIG_POSIX_MQUEUE=y
@@ -37,6 +40,7 @@ CONFIG_KOBJECT_UEVENT=y
37CONFIG_IKCONFIG=y 40CONFIG_IKCONFIG=y
38CONFIG_IKCONFIG_PROC=y 41CONFIG_IKCONFIG_PROC=y
39# CONFIG_CPUSETS is not set 42# CONFIG_CPUSETS is not set
43CONFIG_INITRAMFS_SOURCE=""
40# CONFIG_EMBEDDED is not set 44# CONFIG_EMBEDDED is not set
41CONFIG_KALLSYMS=y 45CONFIG_KALLSYMS=y
42CONFIG_KALLSYMS_ALL=y 46CONFIG_KALLSYMS_ALL=y
@@ -102,6 +106,7 @@ CONFIG_DISCONTIGMEM_MANUAL=y
102CONFIG_DISCONTIGMEM=y 106CONFIG_DISCONTIGMEM=y
103CONFIG_FLAT_NODE_MEM_MAP=y 107CONFIG_FLAT_NODE_MEM_MAP=y
104CONFIG_NEED_MULTIPLE_NODES=y 108CONFIG_NEED_MULTIPLE_NODES=y
109# CONFIG_SPARSEMEM_STATIC is not set
105CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 110CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
106CONFIG_HAVE_DEC_LOCK=y 111CONFIG_HAVE_DEC_LOCK=y
107CONFIG_NR_CPUS=32 112CONFIG_NR_CPUS=32
@@ -122,6 +127,7 @@ CONFIG_HZ=250
122CONFIG_GENERIC_HARDIRQS=y 127CONFIG_GENERIC_HARDIRQS=y
123CONFIG_GENERIC_IRQ_PROBE=y 128CONFIG_GENERIC_IRQ_PROBE=y
124CONFIG_ISA_DMA_API=y 129CONFIG_ISA_DMA_API=y
130CONFIG_GENERIC_PENDING_IRQ=y
125 131
126# 132#
127# Power management options 133# Power management options
@@ -194,7 +200,6 @@ CONFIG_UNORDERED_IO=y
194# CONFIG_PCIEPORTBUS is not set 200# CONFIG_PCIEPORTBUS is not set
195CONFIG_PCI_MSI=y 201CONFIG_PCI_MSI=y
196# CONFIG_PCI_LEGACY_PROC is not set 202# CONFIG_PCI_LEGACY_PROC is not set
197# CONFIG_PCI_NAMES is not set
198# CONFIG_PCI_DEBUG is not set 203# CONFIG_PCI_DEBUG is not set
199 204
200# 205#
@@ -234,7 +239,10 @@ CONFIG_INET=y
234CONFIG_IP_MULTICAST=y 239CONFIG_IP_MULTICAST=y
235# CONFIG_IP_ADVANCED_ROUTER is not set 240# CONFIG_IP_ADVANCED_ROUTER is not set
236CONFIG_IP_FIB_HASH=y 241CONFIG_IP_FIB_HASH=y
237# CONFIG_IP_PNP is not set 242CONFIG_IP_PNP=y
243CONFIG_IP_PNP_DHCP=y
244# CONFIG_IP_PNP_BOOTP is not set
245# CONFIG_IP_PNP_RARP is not set
238# CONFIG_NET_IPIP is not set 246# CONFIG_NET_IPIP is not set
239# CONFIG_NET_IPGRE is not set 247# CONFIG_NET_IPGRE is not set
240# CONFIG_IP_MROUTE is not set 248# CONFIG_IP_MROUTE is not set
@@ -244,8 +252,8 @@ CONFIG_IP_FIB_HASH=y
244# CONFIG_INET_ESP is not set 252# CONFIG_INET_ESP is not set
245# CONFIG_INET_IPCOMP is not set 253# CONFIG_INET_IPCOMP is not set
246# CONFIG_INET_TUNNEL is not set 254# CONFIG_INET_TUNNEL is not set
247CONFIG_IP_TCPDIAG=y 255CONFIG_INET_DIAG=y
248CONFIG_IP_TCPDIAG_IPV6=y 256CONFIG_INET_TCP_DIAG=y
249# CONFIG_TCP_CONG_ADVANCED is not set 257# CONFIG_TCP_CONG_ADVANCED is not set
250CONFIG_TCP_CONG_BIC=y 258CONFIG_TCP_CONG_BIC=y
251CONFIG_IPV6=y 259CONFIG_IPV6=y
@@ -258,6 +266,11 @@ CONFIG_IPV6=y
258# CONFIG_NETFILTER is not set 266# CONFIG_NETFILTER is not set
259 267
260# 268#
269# DCCP Configuration (EXPERIMENTAL)
270#
271# CONFIG_IP_DCCP is not set
272
273#
261# SCTP Configuration (EXPERIMENTAL) 274# SCTP Configuration (EXPERIMENTAL)
262# 275#
263# CONFIG_IP_SCTP is not set 276# CONFIG_IP_SCTP is not set
@@ -280,9 +293,11 @@ CONFIG_IPV6=y
280# Network testing 293# Network testing
281# 294#
282# CONFIG_NET_PKTGEN is not set 295# CONFIG_NET_PKTGEN is not set
296# CONFIG_NETFILTER_NETLINK is not set
283# CONFIG_HAMRADIO is not set 297# CONFIG_HAMRADIO is not set
284# CONFIG_IRDA is not set 298# CONFIG_IRDA is not set
285# CONFIG_BT is not set 299# CONFIG_BT is not set
300# CONFIG_IEEE80211 is not set
286 301
287# 302#
288# Device Drivers 303# Device Drivers
@@ -329,7 +344,6 @@ CONFIG_BLK_DEV_RAM=y
329CONFIG_BLK_DEV_RAM_COUNT=16 344CONFIG_BLK_DEV_RAM_COUNT=16
330CONFIG_BLK_DEV_RAM_SIZE=4096 345CONFIG_BLK_DEV_RAM_SIZE=4096
331CONFIG_BLK_DEV_INITRD=y 346CONFIG_BLK_DEV_INITRD=y
332CONFIG_INITRAMFS_SOURCE=""
333CONFIG_LBD=y 347CONFIG_LBD=y
334# CONFIG_CDROM_PKTCDVD is not set 348# CONFIG_CDROM_PKTCDVD is not set
335 349
@@ -409,6 +423,7 @@ CONFIG_IDEDMA_AUTO=y
409# 423#
410# SCSI device support 424# SCSI device support
411# 425#
426# CONFIG_RAID_ATTRS is not set
412CONFIG_SCSI=y 427CONFIG_SCSI=y
413# CONFIG_SCSI_PROC_FS is not set 428# CONFIG_SCSI_PROC_FS is not set
414 429
@@ -432,7 +447,7 @@ CONFIG_BLK_DEV_SD=y
432# 447#
433# SCSI Transport Attributes 448# SCSI Transport Attributes
434# 449#
435# CONFIG_SCSI_SPI_ATTRS is not set 450CONFIG_SCSI_SPI_ATTRS=y
436# CONFIG_SCSI_FC_ATTRS is not set 451# CONFIG_SCSI_FC_ATTRS is not set
437# CONFIG_SCSI_ISCSI_ATTRS is not set 452# CONFIG_SCSI_ISCSI_ATTRS is not set
438 453
@@ -458,6 +473,7 @@ CONFIG_SCSI_SATA=y
458# CONFIG_SCSI_SATA_AHCI is not set 473# CONFIG_SCSI_SATA_AHCI is not set
459# CONFIG_SCSI_SATA_SVW is not set 474# CONFIG_SCSI_SATA_SVW is not set
460CONFIG_SCSI_ATA_PIIX=y 475CONFIG_SCSI_ATA_PIIX=y
476# CONFIG_SCSI_SATA_MV is not set
461# CONFIG_SCSI_SATA_NV is not set 477# CONFIG_SCSI_SATA_NV is not set
462# CONFIG_SCSI_SATA_PROMISE is not set 478# CONFIG_SCSI_SATA_PROMISE is not set
463# CONFIG_SCSI_SATA_QSTOR is not set 479# CONFIG_SCSI_SATA_QSTOR is not set
@@ -537,6 +553,11 @@ CONFIG_TUN=y
537# CONFIG_ARCNET is not set 553# CONFIG_ARCNET is not set
538 554
539# 555#
556# PHY device support
557#
558# CONFIG_PHYLIB is not set
559
560#
540# Ethernet (10 or 100Mbit) 561# Ethernet (10 or 100Mbit)
541# 562#
542CONFIG_NET_ETHERNET=y 563CONFIG_NET_ETHERNET=y
@@ -586,6 +607,7 @@ CONFIG_E1000=y
586# CONFIG_HAMACHI is not set 607# CONFIG_HAMACHI is not set
587# CONFIG_YELLOWFIN is not set 608# CONFIG_YELLOWFIN is not set
588# CONFIG_R8169 is not set 609# CONFIG_R8169 is not set
610# CONFIG_SIS190 is not set
589# CONFIG_SKGE is not set 611# CONFIG_SKGE is not set
590# CONFIG_SK98LIN is not set 612# CONFIG_SK98LIN is not set
591# CONFIG_VIA_VELOCITY is not set 613# CONFIG_VIA_VELOCITY is not set
@@ -595,6 +617,7 @@ CONFIG_TIGON3=y
595# 617#
596# Ethernet (10000 Mbit) 618# Ethernet (10000 Mbit)
597# 619#
620# CONFIG_CHELSIO_T1 is not set
598# CONFIG_IXGB is not set 621# CONFIG_IXGB is not set
599CONFIG_S2IO=m 622CONFIG_S2IO=m
600# CONFIG_S2IO_NAPI is not set 623# CONFIG_S2IO_NAPI is not set
@@ -749,7 +772,6 @@ CONFIG_MAX_RAW_DEVS=256
749# I2C support 772# I2C support
750# 773#
751# CONFIG_I2C is not set 774# CONFIG_I2C is not set
752# CONFIG_I2C_SENSOR is not set
753 775
754# 776#
755# Dallas's 1-wire bus 777# Dallas's 1-wire bus
@@ -760,6 +782,7 @@ CONFIG_MAX_RAW_DEVS=256
760# Hardware Monitoring support 782# Hardware Monitoring support
761# 783#
762CONFIG_HWMON=y 784CONFIG_HWMON=y
785# CONFIG_HWMON_VID is not set
763# CONFIG_HWMON_DEBUG_CHIP is not set 786# CONFIG_HWMON_DEBUG_CHIP is not set
764 787
765# 788#
@@ -768,6 +791,10 @@ CONFIG_HWMON=y
768# CONFIG_IBM_ASM is not set 791# CONFIG_IBM_ASM is not set
769 792
770# 793#
794# Multimedia Capabilities Port drivers
795#
796
797#
771# Multimedia devices 798# Multimedia devices
772# 799#
773# CONFIG_VIDEO_DEV is not set 800# CONFIG_VIDEO_DEV is not set
@@ -858,9 +885,8 @@ CONFIG_USB_UHCI_HCD=y
858# 885#
859# USB Device Class drivers 886# USB Device Class drivers
860# 887#
861# CONFIG_USB_AUDIO is not set 888# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
862# CONFIG_USB_BLUETOOTH_TTY is not set 889# CONFIG_USB_BLUETOOTH_TTY is not set
863# CONFIG_USB_MIDI is not set
864# CONFIG_USB_ACM is not set 890# CONFIG_USB_ACM is not set
865CONFIG_USB_PRINTER=y 891CONFIG_USB_PRINTER=y
866 892
@@ -877,6 +903,7 @@ CONFIG_USB_STORAGE=y
877# CONFIG_USB_STORAGE_SDDR09 is not set 903# CONFIG_USB_STORAGE_SDDR09 is not set
878# CONFIG_USB_STORAGE_SDDR55 is not set 904# CONFIG_USB_STORAGE_SDDR55 is not set
879# CONFIG_USB_STORAGE_JUMPSHOT is not set 905# CONFIG_USB_STORAGE_JUMPSHOT is not set
906# CONFIG_USB_STORAGE_ONETOUCH is not set
880 907
881# 908#
882# USB Input Devices 909# USB Input Devices
@@ -893,6 +920,7 @@ CONFIG_USB_HIDINPUT=y
893# CONFIG_USB_MTOUCH is not set 920# CONFIG_USB_MTOUCH is not set
894# CONFIG_USB_ITMTOUCH is not set 921# CONFIG_USB_ITMTOUCH is not set
895# CONFIG_USB_EGALAX is not set 922# CONFIG_USB_EGALAX is not set
923# CONFIG_USB_YEALINK is not set
896# CONFIG_USB_XPAD is not set 924# CONFIG_USB_XPAD is not set
897# CONFIG_USB_ATI_REMOTE is not set 925# CONFIG_USB_ATI_REMOTE is not set
898# CONFIG_USB_KEYSPAN_REMOTE is not set 926# CONFIG_USB_KEYSPAN_REMOTE is not set
@@ -976,6 +1004,8 @@ CONFIG_USB_MON=y
976# Firmware Drivers 1004# Firmware Drivers
977# 1005#
978# CONFIG_EDD is not set 1006# CONFIG_EDD is not set
1007# CONFIG_DELL_RBU is not set
1008CONFIG_DCDBAS=m
979 1009
980# 1010#
981# File systems 1011# File systems
@@ -1000,10 +1030,6 @@ CONFIG_REISERFS_FS_POSIX_ACL=y
1000# CONFIG_REISERFS_FS_SECURITY is not set 1030# CONFIG_REISERFS_FS_SECURITY is not set
1001# CONFIG_JFS_FS is not set 1031# CONFIG_JFS_FS is not set
1002CONFIG_FS_POSIX_ACL=y 1032CONFIG_FS_POSIX_ACL=y
1003
1004#
1005# XFS support
1006#
1007# CONFIG_XFS_FS is not set 1033# CONFIG_XFS_FS is not set
1008# CONFIG_MINIX_FS is not set 1034# CONFIG_MINIX_FS is not set
1009# CONFIG_ROMFS_FS is not set 1035# CONFIG_ROMFS_FS is not set
@@ -1012,6 +1038,7 @@ CONFIG_INOTIFY=y
1012CONFIG_DNOTIFY=y 1038CONFIG_DNOTIFY=y
1013CONFIG_AUTOFS_FS=y 1039CONFIG_AUTOFS_FS=y
1014# CONFIG_AUTOFS4_FS is not set 1040# CONFIG_AUTOFS4_FS is not set
1041# CONFIG_FUSE_FS is not set
1015 1042
1016# 1043#
1017# CD-ROM/DVD Filesystems 1044# CD-ROM/DVD Filesystems
@@ -1037,12 +1064,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1037CONFIG_PROC_FS=y 1064CONFIG_PROC_FS=y
1038CONFIG_PROC_KCORE=y 1065CONFIG_PROC_KCORE=y
1039CONFIG_SYSFS=y 1066CONFIG_SYSFS=y
1040# CONFIG_DEVPTS_FS_XATTR is not set
1041CONFIG_TMPFS=y 1067CONFIG_TMPFS=y
1042# CONFIG_TMPFS_XATTR is not set
1043CONFIG_HUGETLBFS=y 1068CONFIG_HUGETLBFS=y
1044CONFIG_HUGETLB_PAGE=y 1069CONFIG_HUGETLB_PAGE=y
1045CONFIG_RAMFS=y 1070CONFIG_RAMFS=y
1071# CONFIG_RELAYFS_FS is not set
1046 1072
1047# 1073#
1048# Miscellaneous filesystems 1074# Miscellaneous filesystems
@@ -1074,6 +1100,7 @@ CONFIG_NFSD_V3=y
1074# CONFIG_NFSD_V3_ACL is not set 1100# CONFIG_NFSD_V3_ACL is not set
1075# CONFIG_NFSD_V4 is not set 1101# CONFIG_NFSD_V4 is not set
1076CONFIG_NFSD_TCP=y 1102CONFIG_NFSD_TCP=y
1103CONFIG_ROOT_NFS=y
1077CONFIG_LOCKD=y 1104CONFIG_LOCKD=y
1078CONFIG_LOCKD_V4=y 1105CONFIG_LOCKD_V4=y
1079CONFIG_EXPORTFS=y 1106CONFIG_EXPORTFS=y
@@ -1086,6 +1113,7 @@ CONFIG_SUNRPC=y
1086# CONFIG_NCP_FS is not set 1113# CONFIG_NCP_FS is not set
1087# CONFIG_CODA_FS is not set 1114# CONFIG_CODA_FS is not set
1088# CONFIG_AFS_FS is not set 1115# CONFIG_AFS_FS is not set
1116# CONFIG_9P_FS is not set
1089 1117
1090# 1118#
1091# Partition Types 1119# Partition Types
@@ -1150,6 +1178,7 @@ CONFIG_OPROFILE=y
1150CONFIG_DEBUG_KERNEL=y 1178CONFIG_DEBUG_KERNEL=y
1151CONFIG_MAGIC_SYSRQ=y 1179CONFIG_MAGIC_SYSRQ=y
1152CONFIG_LOG_BUF_SHIFT=18 1180CONFIG_LOG_BUF_SHIFT=18
1181CONFIG_DETECT_SOFTLOCKUP=y
1153# CONFIG_SCHEDSTATS is not set 1182# CONFIG_SCHEDSTATS is not set
1154# CONFIG_DEBUG_SLAB is not set 1183# CONFIG_DEBUG_SLAB is not set
1155# CONFIG_DEBUG_SPINLOCK is not set 1184# CONFIG_DEBUG_SPINLOCK is not set
@@ -1157,6 +1186,7 @@ CONFIG_LOG_BUF_SHIFT=18
1157# CONFIG_DEBUG_KOBJECT is not set 1186# CONFIG_DEBUG_KOBJECT is not set
1158# CONFIG_DEBUG_INFO is not set 1187# CONFIG_DEBUG_INFO is not set
1159CONFIG_DEBUG_FS=y 1188CONFIG_DEBUG_FS=y
1189# CONFIG_FRAME_POINTER is not set
1160CONFIG_INIT_DEBUG=y 1190CONFIG_INIT_DEBUG=y
1161# CONFIG_IOMMU_DEBUG is not set 1191# CONFIG_IOMMU_DEBUG is not set
1162CONFIG_KPROBES=y 1192CONFIG_KPROBES=y
@@ -1180,5 +1210,6 @@ CONFIG_KPROBES=y
1180# Library routines 1210# Library routines
1181# 1211#
1182# CONFIG_CRC_CCITT is not set 1212# CONFIG_CRC_CCITT is not set
1213# CONFIG_CRC16 is not set
1183CONFIG_CRC32=y 1214CONFIG_CRC32=y
1184# CONFIG_LIBCRC32C is not set 1215# CONFIG_LIBCRC32C is not set
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 5244f803203d..e0eb0c712fe9 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -55,20 +55,34 @@
55 * with the int 0x80 path. 55 * with the int 0x80 path.
56 */ 56 */
57ENTRY(ia32_sysenter_target) 57ENTRY(ia32_sysenter_target)
58 CFI_STARTPROC 58 CFI_STARTPROC simple
59 CFI_DEF_CFA rsp,0
60 CFI_REGISTER rsp,rbp
59 swapgs 61 swapgs
60 movq %gs:pda_kernelstack, %rsp 62 movq %gs:pda_kernelstack, %rsp
61 addq $(PDA_STACKOFFSET),%rsp 63 addq $(PDA_STACKOFFSET),%rsp
62 sti 64 sti
63 movl %ebp,%ebp /* zero extension */ 65 movl %ebp,%ebp /* zero extension */
64 pushq $__USER32_DS 66 pushq $__USER32_DS
67 CFI_ADJUST_CFA_OFFSET 8
68 /*CFI_REL_OFFSET ss,0*/
65 pushq %rbp 69 pushq %rbp
70 CFI_ADJUST_CFA_OFFSET 8
71 CFI_REL_OFFSET rsp,0
66 pushfq 72 pushfq
73 CFI_ADJUST_CFA_OFFSET 8
74 /*CFI_REL_OFFSET rflags,0*/
67 movl $VSYSCALL32_SYSEXIT, %r10d 75 movl $VSYSCALL32_SYSEXIT, %r10d
76 CFI_REGISTER rip,r10
68 pushq $__USER32_CS 77 pushq $__USER32_CS
78 CFI_ADJUST_CFA_OFFSET 8
79 /*CFI_REL_OFFSET cs,0*/
69 movl %eax, %eax 80 movl %eax, %eax
70 pushq %r10 81 pushq %r10
82 CFI_ADJUST_CFA_OFFSET 8
83 CFI_REL_OFFSET rip,0
71 pushq %rax 84 pushq %rax
85 CFI_ADJUST_CFA_OFFSET 8
72 cld 86 cld
73 SAVE_ARGS 0,0,1 87 SAVE_ARGS 0,0,1
74 /* no need to do an access_ok check here because rbp has been 88 /* no need to do an access_ok check here because rbp has been
@@ -79,6 +93,7 @@ ENTRY(ia32_sysenter_target)
79 .previous 93 .previous
80 GET_THREAD_INFO(%r10) 94 GET_THREAD_INFO(%r10)
81 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10) 95 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
96 CFI_REMEMBER_STATE
82 jnz sysenter_tracesys 97 jnz sysenter_tracesys
83sysenter_do_call: 98sysenter_do_call:
84 cmpl $(IA32_NR_syscalls),%eax 99 cmpl $(IA32_NR_syscalls),%eax
@@ -94,14 +109,20 @@ sysenter_do_call:
94 andl $~0x200,EFLAGS-R11(%rsp) 109 andl $~0x200,EFLAGS-R11(%rsp)
95 RESTORE_ARGS 1,24,1,1,1,1 110 RESTORE_ARGS 1,24,1,1,1,1
96 popfq 111 popfq
112 CFI_ADJUST_CFA_OFFSET -8
113 /*CFI_RESTORE rflags*/
97 popq %rcx /* User %esp */ 114 popq %rcx /* User %esp */
115 CFI_ADJUST_CFA_OFFSET -8
116 CFI_REGISTER rsp,rcx
98 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */ 117 movl $VSYSCALL32_SYSEXIT,%edx /* User %eip */
118 CFI_REGISTER rip,rdx
99 swapgs 119 swapgs
100 sti /* sti only takes effect after the next instruction */ 120 sti /* sti only takes effect after the next instruction */
101 /* sysexit */ 121 /* sysexit */
102 .byte 0xf, 0x35 122 .byte 0xf, 0x35
103 123
104sysenter_tracesys: 124sysenter_tracesys:
125 CFI_RESTORE_STATE
105 SAVE_REST 126 SAVE_REST
106 CLEAR_RREGS 127 CLEAR_RREGS
107 movq $-ENOSYS,RAX(%rsp) /* really needed? */ 128 movq $-ENOSYS,RAX(%rsp) /* really needed? */
@@ -140,21 +161,28 @@ sysenter_tracesys:
140 * with the int 0x80 path. 161 * with the int 0x80 path.
141 */ 162 */
142ENTRY(ia32_cstar_target) 163ENTRY(ia32_cstar_target)
143 CFI_STARTPROC 164 CFI_STARTPROC simple
165 CFI_DEF_CFA rsp,0
166 CFI_REGISTER rip,rcx
167 /*CFI_REGISTER rflags,r11*/
144 swapgs 168 swapgs
145 movl %esp,%r8d 169 movl %esp,%r8d
170 CFI_REGISTER rsp,r8
146 movq %gs:pda_kernelstack,%rsp 171 movq %gs:pda_kernelstack,%rsp
147 sti 172 sti
148 SAVE_ARGS 8,1,1 173 SAVE_ARGS 8,1,1
149 movl %eax,%eax /* zero extension */ 174 movl %eax,%eax /* zero extension */
150 movq %rax,ORIG_RAX-ARGOFFSET(%rsp) 175 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
151 movq %rcx,RIP-ARGOFFSET(%rsp) 176 movq %rcx,RIP-ARGOFFSET(%rsp)
177 CFI_REL_OFFSET rip,RIP-ARGOFFSET
152 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */ 178 movq %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
153 movl %ebp,%ecx 179 movl %ebp,%ecx
154 movq $__USER32_CS,CS-ARGOFFSET(%rsp) 180 movq $__USER32_CS,CS-ARGOFFSET(%rsp)
155 movq $__USER32_DS,SS-ARGOFFSET(%rsp) 181 movq $__USER32_DS,SS-ARGOFFSET(%rsp)
156 movq %r11,EFLAGS-ARGOFFSET(%rsp) 182 movq %r11,EFLAGS-ARGOFFSET(%rsp)
183 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
157 movq %r8,RSP-ARGOFFSET(%rsp) 184 movq %r8,RSP-ARGOFFSET(%rsp)
185 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
158 /* no need to do an access_ok check here because r8 has been 186 /* no need to do an access_ok check here because r8 has been
159 32bit zero extended */ 187 32bit zero extended */
160 /* hardware stack frame is complete now */ 188 /* hardware stack frame is complete now */
@@ -164,6 +192,7 @@ ENTRY(ia32_cstar_target)
164 .previous 192 .previous
165 GET_THREAD_INFO(%r10) 193 GET_THREAD_INFO(%r10)
166 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10) 194 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
195 CFI_REMEMBER_STATE
167 jnz cstar_tracesys 196 jnz cstar_tracesys
168cstar_do_call: 197cstar_do_call:
169 cmpl $IA32_NR_syscalls,%eax 198 cmpl $IA32_NR_syscalls,%eax
@@ -177,12 +206,16 @@ cstar_do_call:
177 jnz int_ret_from_sys_call 206 jnz int_ret_from_sys_call
178 RESTORE_ARGS 1,-ARG_SKIP,1,1,1 207 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
179 movl RIP-ARGOFFSET(%rsp),%ecx 208 movl RIP-ARGOFFSET(%rsp),%ecx
209 CFI_REGISTER rip,rcx
180 movl EFLAGS-ARGOFFSET(%rsp),%r11d 210 movl EFLAGS-ARGOFFSET(%rsp),%r11d
211 /*CFI_REGISTER rflags,r11*/
181 movl RSP-ARGOFFSET(%rsp),%esp 212 movl RSP-ARGOFFSET(%rsp),%esp
213 CFI_RESTORE rsp
182 swapgs 214 swapgs
183 sysretl 215 sysretl
184 216
185cstar_tracesys: 217cstar_tracesys:
218 CFI_RESTORE_STATE
186 SAVE_REST 219 SAVE_REST
187 CLEAR_RREGS 220 CLEAR_RREGS
188 movq $-ENOSYS,RAX(%rsp) /* really needed? */ 221 movq $-ENOSYS,RAX(%rsp) /* really needed? */
@@ -226,11 +259,18 @@ ia32_badarg:
226 */ 259 */
227 260
228ENTRY(ia32_syscall) 261ENTRY(ia32_syscall)
229 CFI_STARTPROC 262 CFI_STARTPROC simple
263 CFI_DEF_CFA rsp,SS+8-RIP
264 /*CFI_REL_OFFSET ss,SS-RIP*/
265 CFI_REL_OFFSET rsp,RSP-RIP
266 /*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
267 /*CFI_REL_OFFSET cs,CS-RIP*/
268 CFI_REL_OFFSET rip,RIP-RIP
230 swapgs 269 swapgs
231 sti 270 sti
232 movl %eax,%eax 271 movl %eax,%eax
233 pushq %rax 272 pushq %rax
273 CFI_ADJUST_CFA_OFFSET 8
234 cld 274 cld
235 /* note the registers are not zero extended to the sf. 275 /* note the registers are not zero extended to the sf.
236 this could be a problem. */ 276 this could be a problem. */
@@ -278,6 +318,8 @@ quiet_ni_syscall:
278 jmp ia32_ptregs_common 318 jmp ia32_ptregs_common
279 .endm 319 .endm
280 320
321 CFI_STARTPROC
322
281 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi 323 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
282 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi 324 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
283 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx 325 PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
@@ -290,8 +332,9 @@ quiet_ni_syscall:
290 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx 332 PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
291 333
292ENTRY(ia32_ptregs_common) 334ENTRY(ia32_ptregs_common)
293 CFI_STARTPROC
294 popq %r11 335 popq %r11
336 CFI_ADJUST_CFA_OFFSET -8
337 CFI_REGISTER rip, r11
295 SAVE_REST 338 SAVE_REST
296 call *%rax 339 call *%rax
297 RESTORE_REST 340 RESTORE_REST
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index 04d80406ce4f..5389df610e78 100644
--- a/arch/x86_64/ia32/sys_ia32.c
+++ b/arch/x86_64/ia32/sys_ia32.c
@@ -751,7 +751,7 @@ sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
751 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count); 751 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
752 set_fs(old_fs); 752 set_fs(old_fs);
753 753
754 if (!ret && offset && put_user(of, offset)) 754 if (offset && put_user(of, offset))
755 return -EFAULT; 755 return -EFAULT;
756 756
757 return ret; 757 return ret;
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
index 1579bdd0adcd..bcdd0a805fe7 100644
--- a/arch/x86_64/kernel/Makefile
+++ b/arch/x86_64/kernel/Makefile
@@ -46,3 +46,4 @@ microcode-$(subst m,y,$(CONFIG_MICROCODE)) += ../../i386/kernel/microcode.o
46intel_cacheinfo-y += ../../i386/kernel/cpu/intel_cacheinfo.o 46intel_cacheinfo-y += ../../i386/kernel/cpu/intel_cacheinfo.o
47quirks-y += ../../i386/kernel/quirks.o 47quirks-y += ../../i386/kernel/quirks.o
48i8237-y += ../../i386/kernel/i8237.o 48i8237-y += ../../i386/kernel/i8237.o
49msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o
diff --git a/arch/x86_64/kernel/acpi/sleep.c b/arch/x86_64/kernel/acpi/sleep.c
index 148f6f7ea315..867a0ebee177 100644
--- a/arch/x86_64/kernel/acpi/sleep.c
+++ b/arch/x86_64/kernel/acpi/sleep.c
@@ -34,7 +34,6 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/bootmem.h> 36#include <linux/bootmem.h>
37#include <linux/irq.h>
38#include <linux/acpi.h> 37#include <linux/acpi.h>
39#include <asm/mpspec.h> 38#include <asm/mpspec.h>
40#include <asm/io.h> 39#include <asm/io.h>
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index c9a6b812e926..962ad4823b6a 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -245,6 +245,8 @@ void __init iommu_hole_init(void)
245 245
246 if (aper_alloc) { 246 if (aper_alloc) {
247 /* Got the aperture from the AGP bridge */ 247 /* Got the aperture from the AGP bridge */
248 } else if (swiotlb && !valid_agp) {
249 /* Do nothing */
248 } else if ((!no_iommu && end_pfn >= 0xffffffff>>PAGE_SHIFT) || 250 } else if ((!no_iommu && end_pfn >= 0xffffffff>>PAGE_SHIFT) ||
249 force_iommu || 251 force_iommu ||
250 valid_agp || 252 valid_agp ||
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 375d369570ca..b6e7715d877f 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -18,7 +18,6 @@
18#include <linux/init.h> 18#include <linux/init.h>
19 19
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/irq.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/bootmem.h> 22#include <linux/bootmem.h>
24#include <linux/smp_lock.h> 23#include <linux/smp_lock.h>
@@ -109,11 +108,8 @@ void clear_local_APIC(void)
109 if (maxlvt >= 4) 108 if (maxlvt >= 4)
110 apic_write_around(APIC_LVTPC, APIC_LVT_MASKED); 109 apic_write_around(APIC_LVTPC, APIC_LVT_MASKED);
111 v = GET_APIC_VERSION(apic_read(APIC_LVR)); 110 v = GET_APIC_VERSION(apic_read(APIC_LVR));
112 if (APIC_INTEGRATED(v)) { /* !82489DX */ 111 apic_write(APIC_ESR, 0);
113 if (maxlvt > 3) /* Due to Pentium errata 3AP and 11AP. */ 112 apic_read(APIC_ESR);
114 apic_write(APIC_ESR, 0);
115 apic_read(APIC_ESR);
116 }
117} 113}
118 114
119void __init connect_bsp_APIC(void) 115void __init connect_bsp_APIC(void)
@@ -316,8 +312,6 @@ void __init init_bsp_APIC(void)
316 */ 312 */
317 apic_write_around(APIC_LVT0, APIC_DM_EXTINT); 313 apic_write_around(APIC_LVT0, APIC_DM_EXTINT);
318 value = APIC_DM_NMI; 314 value = APIC_DM_NMI;
319 if (!APIC_INTEGRATED(ver)) /* 82489DX */
320 value |= APIC_LVT_LEVEL_TRIGGER;
321 apic_write_around(APIC_LVT1, value); 315 apic_write_around(APIC_LVT1, value);
322} 316}
323 317
@@ -325,14 +319,6 @@ void __cpuinit setup_local_APIC (void)
325{ 319{
326 unsigned int value, ver, maxlvt; 320 unsigned int value, ver, maxlvt;
327 321
328 /* Pound the ESR really hard over the head with a big hammer - mbligh */
329 if (esr_disable) {
330 apic_write(APIC_ESR, 0);
331 apic_write(APIC_ESR, 0);
332 apic_write(APIC_ESR, 0);
333 apic_write(APIC_ESR, 0);
334 }
335
336 value = apic_read(APIC_LVR); 322 value = apic_read(APIC_LVR);
337 ver = GET_APIC_VERSION(value); 323 ver = GET_APIC_VERSION(value);
338 324
@@ -430,15 +416,11 @@ void __cpuinit setup_local_APIC (void)
430 value = APIC_DM_NMI; 416 value = APIC_DM_NMI;
431 else 417 else
432 value = APIC_DM_NMI | APIC_LVT_MASKED; 418 value = APIC_DM_NMI | APIC_LVT_MASKED;
433 if (!APIC_INTEGRATED(ver)) /* 82489DX */
434 value |= APIC_LVT_LEVEL_TRIGGER;
435 apic_write_around(APIC_LVT1, value); 419 apic_write_around(APIC_LVT1, value);
436 420
437 if (APIC_INTEGRATED(ver) && !esr_disable) { /* !82489DX */ 421 {
438 unsigned oldvalue; 422 unsigned oldvalue;
439 maxlvt = get_maxlvt(); 423 maxlvt = get_maxlvt();
440 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
441 apic_write(APIC_ESR, 0);
442 oldvalue = apic_read(APIC_ESR); 424 oldvalue = apic_read(APIC_ESR);
443 value = ERROR_APIC_VECTOR; // enables sending errors 425 value = ERROR_APIC_VECTOR; // enables sending errors
444 apic_write_around(APIC_LVTERR, value); 426 apic_write_around(APIC_LVTERR, value);
@@ -452,17 +434,6 @@ void __cpuinit setup_local_APIC (void)
452 apic_printk(APIC_VERBOSE, 434 apic_printk(APIC_VERBOSE,
453 "ESR value after enabling vector: %08x, after %08x\n", 435 "ESR value after enabling vector: %08x, after %08x\n",
454 oldvalue, value); 436 oldvalue, value);
455 } else {
456 if (esr_disable)
457 /*
458 * Something untraceble is creating bad interrupts on
459 * secondary quads ... for the moment, just leave the
460 * ESR disabled - we can't do anything useful with the
461 * errors anyway - mbligh
462 */
463 apic_printk(APIC_DEBUG, "Leaving ESR disabled.\n");
464 else
465 apic_printk(APIC_DEBUG, "No ESR for 82489DX.\n");
466 } 437 }
467 438
468 nmi_watchdog_default(); 439 nmi_watchdog_default();
@@ -650,8 +621,7 @@ void __init init_apic_mappings(void)
650 * Fetch the APIC ID of the BSP in case we have a 621 * Fetch the APIC ID of the BSP in case we have a
651 * default configuration (or the MP table is broken). 622 * default configuration (or the MP table is broken).
652 */ 623 */
653 if (boot_cpu_id == -1U) 624 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
654 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
655 625
656#ifdef CONFIG_X86_IO_APIC 626#ifdef CONFIG_X86_IO_APIC
657 { 627 {
@@ -693,8 +663,6 @@ static void __setup_APIC_LVTT(unsigned int clocks)
693 663
694 ver = GET_APIC_VERSION(apic_read(APIC_LVR)); 664 ver = GET_APIC_VERSION(apic_read(APIC_LVR));
695 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR; 665 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
696 if (!APIC_INTEGRATED(ver))
697 lvtt_value |= SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV);
698 apic_write_around(APIC_LVTT, lvtt_value); 666 apic_write_around(APIC_LVTT, lvtt_value);
699 667
700 /* 668 /*
@@ -1081,7 +1049,7 @@ int __init APIC_init_uniprocessor (void)
1081 1049
1082 connect_bsp_APIC(); 1050 connect_bsp_APIC();
1083 1051
1084 phys_cpu_present_map = physid_mask_of_physid(0); 1052 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
1085 apic_write_around(APIC_ID, boot_cpu_id); 1053 apic_write_around(APIC_ID, boot_cpu_id);
1086 1054
1087 setup_local_APIC(); 1055 setup_local_APIC();
diff --git a/arch/x86_64/kernel/asm-offsets.c b/arch/x86_64/kernel/asm-offsets.c
index 35b4c3fcbb37..aaa6d3833517 100644
--- a/arch/x86_64/kernel/asm-offsets.c
+++ b/arch/x86_64/kernel/asm-offsets.c
@@ -39,7 +39,6 @@ int main(void)
39 ENTRY(kernelstack); 39 ENTRY(kernelstack);
40 ENTRY(oldrsp); 40 ENTRY(oldrsp);
41 ENTRY(pcurrent); 41 ENTRY(pcurrent);
42 ENTRY(irqrsp);
43 ENTRY(irqcount); 42 ENTRY(irqcount);
44 ENTRY(cpunumber); 43 ENTRY(cpunumber);
45 ENTRY(irqstackptr); 44 ENTRY(irqstackptr);
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
index d7fa4248501c..535e04466079 100644
--- a/arch/x86_64/kernel/crash.c
+++ b/arch/x86_64/kernel/crash.c
@@ -11,7 +11,6 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/irq.h>
15#include <linux/reboot.h> 14#include <linux/reboot.h>
16#include <linux/kexec.h> 15#include <linux/kexec.h>
17 16
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index bb0ae18ec02b..eb7929eea7b3 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -131,7 +131,7 @@ void __init e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned lon
131 131
132 if (ei->type != E820_RAM || 132 if (ei->type != E820_RAM ||
133 ei->addr+ei->size <= start || 133 ei->addr+ei->size <= start ||
134 ei->addr > end) 134 ei->addr >= end)
135 continue; 135 continue;
136 136
137 addr = round_up(ei->addr, PAGE_SIZE); 137 addr = round_up(ei->addr, PAGE_SIZE);
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 9631c747c5e3..9cd968dd0f5a 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -5,6 +5,7 @@
5#include <linux/tty.h> 5#include <linux/tty.h>
6#include <asm/io.h> 6#include <asm/io.h>
7#include <asm/processor.h> 7#include <asm/processor.h>
8#include <asm/fcntl.h>
8 9
9/* Simple VGA output */ 10/* Simple VGA output */
10 11
@@ -158,6 +159,47 @@ static struct console early_serial_console = {
158 .index = -1, 159 .index = -1,
159}; 160};
160 161
162/* Console interface to a host file on AMD's SimNow! */
163
164static int simnow_fd;
165
166enum {
167 MAGIC1 = 0xBACCD00A,
168 MAGIC2 = 0xCA110000,
169 XOPEN = 5,
170 XWRITE = 4,
171};
172
173static noinline long simnow(long cmd, long a, long b, long c)
174{
175 long ret;
176 asm volatile("cpuid" :
177 "=a" (ret) :
178 "b" (a), "c" (b), "d" (c), "0" (MAGIC1), "D" (cmd + MAGIC2));
179 return ret;
180}
181
182void __init simnow_init(char *str)
183{
184 char *fn = "klog";
185 if (*str == '=')
186 fn = ++str;
187 /* error ignored */
188 simnow_fd = simnow(XOPEN, (unsigned long)fn, O_WRONLY|O_APPEND|O_CREAT, 0644);
189}
190
191static void simnow_write(struct console *con, const char *s, unsigned n)
192{
193 simnow(XWRITE, simnow_fd, (unsigned long)s, n);
194}
195
196static struct console simnow_console = {
197 .name = "simnow",
198 .write = simnow_write,
199 .flags = CON_PRINTBUFFER,
200 .index = -1,
201};
202
161/* Direct interface for emergencies */ 203/* Direct interface for emergencies */
162struct console *early_console = &early_vga_console; 204struct console *early_console = &early_vga_console;
163static int early_console_initialized = 0; 205static int early_console_initialized = 0;
@@ -205,6 +247,10 @@ int __init setup_early_printk(char *opt)
205 max_xpos = SCREEN_INFO.orig_video_cols; 247 max_xpos = SCREEN_INFO.orig_video_cols;
206 max_ypos = SCREEN_INFO.orig_video_lines; 248 max_ypos = SCREEN_INFO.orig_video_lines;
207 early_console = &early_vga_console; 249 early_console = &early_vga_console;
250 } else if (!strncmp(buf, "simnow", 6)) {
251 simnow_init(buf + 6);
252 early_console = &simnow_console;
253 keep_early = 1;
208 } 254 }
209 early_console_initialized = 1; 255 early_console_initialized = 1;
210 register_console(early_console); 256 register_console(early_console);
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 3620508c8bd9..7937971d1853 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -79,16 +79,19 @@
79 xorl %eax, %eax 79 xorl %eax, %eax
80 pushq %rax /* ss */ 80 pushq %rax /* ss */
81 CFI_ADJUST_CFA_OFFSET 8 81 CFI_ADJUST_CFA_OFFSET 8
82 /*CFI_REL_OFFSET ss,0*/
82 pushq %rax /* rsp */ 83 pushq %rax /* rsp */
83 CFI_ADJUST_CFA_OFFSET 8 84 CFI_ADJUST_CFA_OFFSET 8
84 CFI_OFFSET rip,0 85 CFI_REL_OFFSET rsp,0
85 pushq $(1<<9) /* eflags - interrupts on */ 86 pushq $(1<<9) /* eflags - interrupts on */
86 CFI_ADJUST_CFA_OFFSET 8 87 CFI_ADJUST_CFA_OFFSET 8
88 /*CFI_REL_OFFSET rflags,0*/
87 pushq $__KERNEL_CS /* cs */ 89 pushq $__KERNEL_CS /* cs */
88 CFI_ADJUST_CFA_OFFSET 8 90 CFI_ADJUST_CFA_OFFSET 8
91 /*CFI_REL_OFFSET cs,0*/
89 pushq \child_rip /* rip */ 92 pushq \child_rip /* rip */
90 CFI_ADJUST_CFA_OFFSET 8 93 CFI_ADJUST_CFA_OFFSET 8
91 CFI_OFFSET rip,0 94 CFI_REL_OFFSET rip,0
92 pushq %rax /* orig rax */ 95 pushq %rax /* orig rax */
93 CFI_ADJUST_CFA_OFFSET 8 96 CFI_ADJUST_CFA_OFFSET 8
94 .endm 97 .endm
@@ -98,32 +101,39 @@
98 CFI_ADJUST_CFA_OFFSET -(6*8) 101 CFI_ADJUST_CFA_OFFSET -(6*8)
99 .endm 102 .endm
100 103
101 .macro CFI_DEFAULT_STACK 104 .macro CFI_DEFAULT_STACK start=1
102 CFI_ADJUST_CFA_OFFSET (SS) 105 .if \start
103 CFI_OFFSET r15,R15-SS 106 CFI_STARTPROC simple
104 CFI_OFFSET r14,R14-SS 107 CFI_DEF_CFA rsp,SS+8
105 CFI_OFFSET r13,R13-SS 108 .else
106 CFI_OFFSET r12,R12-SS 109 CFI_DEF_CFA_OFFSET SS+8
107 CFI_OFFSET rbp,RBP-SS 110 .endif
108 CFI_OFFSET rbx,RBX-SS 111 CFI_REL_OFFSET r15,R15
109 CFI_OFFSET r11,R11-SS 112 CFI_REL_OFFSET r14,R14
110 CFI_OFFSET r10,R10-SS 113 CFI_REL_OFFSET r13,R13
111 CFI_OFFSET r9,R9-SS 114 CFI_REL_OFFSET r12,R12
112 CFI_OFFSET r8,R8-SS 115 CFI_REL_OFFSET rbp,RBP
113 CFI_OFFSET rax,RAX-SS 116 CFI_REL_OFFSET rbx,RBX
114 CFI_OFFSET rcx,RCX-SS 117 CFI_REL_OFFSET r11,R11
115 CFI_OFFSET rdx,RDX-SS 118 CFI_REL_OFFSET r10,R10
116 CFI_OFFSET rsi,RSI-SS 119 CFI_REL_OFFSET r9,R9
117 CFI_OFFSET rdi,RDI-SS 120 CFI_REL_OFFSET r8,R8
118 CFI_OFFSET rsp,RSP-SS 121 CFI_REL_OFFSET rax,RAX
119 CFI_OFFSET rip,RIP-SS 122 CFI_REL_OFFSET rcx,RCX
123 CFI_REL_OFFSET rdx,RDX
124 CFI_REL_OFFSET rsi,RSI
125 CFI_REL_OFFSET rdi,RDI
126 CFI_REL_OFFSET rip,RIP
127 /*CFI_REL_OFFSET cs,CS*/
128 /*CFI_REL_OFFSET rflags,EFLAGS*/
129 CFI_REL_OFFSET rsp,RSP
130 /*CFI_REL_OFFSET ss,SS*/
120 .endm 131 .endm
121/* 132/*
122 * A newly forked process directly context switches into this. 133 * A newly forked process directly context switches into this.
123 */ 134 */
124/* rdi: prev */ 135/* rdi: prev */
125ENTRY(ret_from_fork) 136ENTRY(ret_from_fork)
126 CFI_STARTPROC
127 CFI_DEFAULT_STACK 137 CFI_DEFAULT_STACK
128 call schedule_tail 138 call schedule_tail
129 GET_THREAD_INFO(%rcx) 139 GET_THREAD_INFO(%rcx)
@@ -172,16 +182,21 @@ rff_trace:
172 */ 182 */
173 183
174ENTRY(system_call) 184ENTRY(system_call)
175 CFI_STARTPROC 185 CFI_STARTPROC simple
186 CFI_DEF_CFA rsp,0
187 CFI_REGISTER rip,rcx
188 /*CFI_REGISTER rflags,r11*/
176 swapgs 189 swapgs
177 movq %rsp,%gs:pda_oldrsp 190 movq %rsp,%gs:pda_oldrsp
178 movq %gs:pda_kernelstack,%rsp 191 movq %gs:pda_kernelstack,%rsp
179 sti 192 sti
180 SAVE_ARGS 8,1 193 SAVE_ARGS 8,1
181 movq %rax,ORIG_RAX-ARGOFFSET(%rsp) 194 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
182 movq %rcx,RIP-ARGOFFSET(%rsp) 195 movq %rcx,RIP-ARGOFFSET(%rsp)
196 CFI_REL_OFFSET rip,RIP-ARGOFFSET
183 GET_THREAD_INFO(%rcx) 197 GET_THREAD_INFO(%rcx)
184 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx) 198 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx)
199 CFI_REMEMBER_STATE
185 jnz tracesys 200 jnz tracesys
186 cmpq $__NR_syscall_max,%rax 201 cmpq $__NR_syscall_max,%rax
187 ja badsys 202 ja badsys
@@ -201,9 +216,12 @@ sysret_check:
201 cli 216 cli
202 movl threadinfo_flags(%rcx),%edx 217 movl threadinfo_flags(%rcx),%edx
203 andl %edi,%edx 218 andl %edi,%edx
219 CFI_REMEMBER_STATE
204 jnz sysret_careful 220 jnz sysret_careful
205 movq RIP-ARGOFFSET(%rsp),%rcx 221 movq RIP-ARGOFFSET(%rsp),%rcx
222 CFI_REGISTER rip,rcx
206 RESTORE_ARGS 0,-ARG_SKIP,1 223 RESTORE_ARGS 0,-ARG_SKIP,1
224 /*CFI_REGISTER rflags,r11*/
207 movq %gs:pda_oldrsp,%rsp 225 movq %gs:pda_oldrsp,%rsp
208 swapgs 226 swapgs
209 sysretq 227 sysretq
@@ -211,12 +229,15 @@ sysret_check:
211 /* Handle reschedules */ 229 /* Handle reschedules */
212 /* edx: work, edi: workmask */ 230 /* edx: work, edi: workmask */
213sysret_careful: 231sysret_careful:
232 CFI_RESTORE_STATE
214 bt $TIF_NEED_RESCHED,%edx 233 bt $TIF_NEED_RESCHED,%edx
215 jnc sysret_signal 234 jnc sysret_signal
216 sti 235 sti
217 pushq %rdi 236 pushq %rdi
237 CFI_ADJUST_CFA_OFFSET 8
218 call schedule 238 call schedule
219 popq %rdi 239 popq %rdi
240 CFI_ADJUST_CFA_OFFSET -8
220 jmp sysret_check 241 jmp sysret_check
221 242
222 /* Handle a signal */ 243 /* Handle a signal */
@@ -234,8 +255,13 @@ sysret_signal:
2341: movl $_TIF_NEED_RESCHED,%edi 2551: movl $_TIF_NEED_RESCHED,%edi
235 jmp sysret_check 256 jmp sysret_check
236 257
258badsys:
259 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
260 jmp ret_from_sys_call
261
237 /* Do syscall tracing */ 262 /* Do syscall tracing */
238tracesys: 263tracesys:
264 CFI_RESTORE_STATE
239 SAVE_REST 265 SAVE_REST
240 movq $-ENOSYS,RAX(%rsp) 266 movq $-ENOSYS,RAX(%rsp)
241 FIXUP_TOP_OF_STACK %rdi 267 FIXUP_TOP_OF_STACK %rdi
@@ -254,16 +280,29 @@ tracesys:
254 RESTORE_TOP_OF_STACK %rbx 280 RESTORE_TOP_OF_STACK %rbx
255 RESTORE_REST 281 RESTORE_REST
256 jmp ret_from_sys_call 282 jmp ret_from_sys_call
283 CFI_ENDPROC
257 284
258badsys:
259 movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
260 jmp ret_from_sys_call
261
262/* 285/*
263 * Syscall return path ending with IRET. 286 * Syscall return path ending with IRET.
264 * Has correct top of stack, but partial stack frame. 287 * Has correct top of stack, but partial stack frame.
265 */ 288 */
266ENTRY(int_ret_from_sys_call) 289ENTRY(int_ret_from_sys_call)
290 CFI_STARTPROC simple
291 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
292 /*CFI_REL_OFFSET ss,SS-ARGOFFSET*/
293 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
294 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
295 /*CFI_REL_OFFSET cs,CS-ARGOFFSET*/
296 CFI_REL_OFFSET rip,RIP-ARGOFFSET
297 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
298 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
299 CFI_REL_OFFSET rax,RAX-ARGOFFSET
300 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
301 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
302 CFI_REL_OFFSET r8,R8-ARGOFFSET
303 CFI_REL_OFFSET r9,R9-ARGOFFSET
304 CFI_REL_OFFSET r10,R10-ARGOFFSET
305 CFI_REL_OFFSET r11,R11-ARGOFFSET
267 cli 306 cli
268 testl $3,CS-ARGOFFSET(%rsp) 307 testl $3,CS-ARGOFFSET(%rsp)
269 je retint_restore_args 308 je retint_restore_args
@@ -284,8 +323,10 @@ int_careful:
284 jnc int_very_careful 323 jnc int_very_careful
285 sti 324 sti
286 pushq %rdi 325 pushq %rdi
326 CFI_ADJUST_CFA_OFFSET 8
287 call schedule 327 call schedule
288 popq %rdi 328 popq %rdi
329 CFI_ADJUST_CFA_OFFSET -8
289 cli 330 cli
290 jmp int_with_check 331 jmp int_with_check
291 332
@@ -297,9 +338,11 @@ int_very_careful:
297 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edx 338 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edx
298 jz int_signal 339 jz int_signal
299 pushq %rdi 340 pushq %rdi
341 CFI_ADJUST_CFA_OFFSET 8
300 leaq 8(%rsp),%rdi # &ptregs -> arg1 342 leaq 8(%rsp),%rdi # &ptregs -> arg1
301 call syscall_trace_leave 343 call syscall_trace_leave
302 popq %rdi 344 popq %rdi
345 CFI_ADJUST_CFA_OFFSET -8
303 andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi 346 andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi
304 cli 347 cli
305 jmp int_restore_rest 348 jmp int_restore_rest
@@ -329,6 +372,8 @@ int_restore_rest:
329 jmp ptregscall_common 372 jmp ptregscall_common
330 .endm 373 .endm
331 374
375 CFI_STARTPROC
376
332 PTREGSCALL stub_clone, sys_clone, %r8 377 PTREGSCALL stub_clone, sys_clone, %r8
333 PTREGSCALL stub_fork, sys_fork, %rdi 378 PTREGSCALL stub_fork, sys_fork, %rdi
334 PTREGSCALL stub_vfork, sys_vfork, %rdi 379 PTREGSCALL stub_vfork, sys_vfork, %rdi
@@ -337,40 +382,49 @@ int_restore_rest:
337 PTREGSCALL stub_iopl, sys_iopl, %rsi 382 PTREGSCALL stub_iopl, sys_iopl, %rsi
338 383
339ENTRY(ptregscall_common) 384ENTRY(ptregscall_common)
340 CFI_STARTPROC
341 popq %r11 385 popq %r11
342 CFI_ADJUST_CFA_OFFSET -8 386 CFI_ADJUST_CFA_OFFSET -8
387 CFI_REGISTER rip, r11
343 SAVE_REST 388 SAVE_REST
344 movq %r11, %r15 389 movq %r11, %r15
390 CFI_REGISTER rip, r15
345 FIXUP_TOP_OF_STACK %r11 391 FIXUP_TOP_OF_STACK %r11
346 call *%rax 392 call *%rax
347 RESTORE_TOP_OF_STACK %r11 393 RESTORE_TOP_OF_STACK %r11
348 movq %r15, %r11 394 movq %r15, %r11
395 CFI_REGISTER rip, r11
349 RESTORE_REST 396 RESTORE_REST
350 pushq %r11 397 pushq %r11
351 CFI_ADJUST_CFA_OFFSET 8 398 CFI_ADJUST_CFA_OFFSET 8
399 CFI_REL_OFFSET rip, 0
352 ret 400 ret
353 CFI_ENDPROC 401 CFI_ENDPROC
354 402
355ENTRY(stub_execve) 403ENTRY(stub_execve)
356 CFI_STARTPROC 404 CFI_STARTPROC
357 popq %r11 405 popq %r11
358 CFI_ADJUST_CFA_OFFSET -8 406 CFI_ADJUST_CFA_OFFSET -8
407 CFI_REGISTER rip, r11
359 SAVE_REST 408 SAVE_REST
360 movq %r11, %r15 409 movq %r11, %r15
410 CFI_REGISTER rip, r15
361 FIXUP_TOP_OF_STACK %r11 411 FIXUP_TOP_OF_STACK %r11
362 call sys_execve 412 call sys_execve
363 GET_THREAD_INFO(%rcx) 413 GET_THREAD_INFO(%rcx)
364 bt $TIF_IA32,threadinfo_flags(%rcx) 414 bt $TIF_IA32,threadinfo_flags(%rcx)
415 CFI_REMEMBER_STATE
365 jc exec_32bit 416 jc exec_32bit
366 RESTORE_TOP_OF_STACK %r11 417 RESTORE_TOP_OF_STACK %r11
367 movq %r15, %r11 418 movq %r15, %r11
419 CFI_REGISTER rip, r11
368 RESTORE_REST 420 RESTORE_REST
369 push %r11 421 pushq %r11
422 CFI_ADJUST_CFA_OFFSET 8
423 CFI_REL_OFFSET rip, 0
370 ret 424 ret
371 425
372exec_32bit: 426exec_32bit:
373 CFI_ADJUST_CFA_OFFSET REST_SKIP 427 CFI_RESTORE_STATE
374 movq %rax,RAX(%rsp) 428 movq %rax,RAX(%rsp)
375 RESTORE_REST 429 RESTORE_REST
376 jmp int_ret_from_sys_call 430 jmp int_ret_from_sys_call
@@ -382,7 +436,8 @@ exec_32bit:
382 */ 436 */
383ENTRY(stub_rt_sigreturn) 437ENTRY(stub_rt_sigreturn)
384 CFI_STARTPROC 438 CFI_STARTPROC
385 addq $8, %rsp 439 addq $8, %rsp
440 CFI_ADJUST_CFA_OFFSET -8
386 SAVE_REST 441 SAVE_REST
387 movq %rsp,%rdi 442 movq %rsp,%rdi
388 FIXUP_TOP_OF_STACK %r11 443 FIXUP_TOP_OF_STACK %r11
@@ -392,6 +447,25 @@ ENTRY(stub_rt_sigreturn)
392 jmp int_ret_from_sys_call 447 jmp int_ret_from_sys_call
393 CFI_ENDPROC 448 CFI_ENDPROC
394 449
450/*
451 * initial frame state for interrupts and exceptions
452 */
453 .macro _frame ref
454 CFI_STARTPROC simple
455 CFI_DEF_CFA rsp,SS+8-\ref
456 /*CFI_REL_OFFSET ss,SS-\ref*/
457 CFI_REL_OFFSET rsp,RSP-\ref
458 /*CFI_REL_OFFSET rflags,EFLAGS-\ref*/
459 /*CFI_REL_OFFSET cs,CS-\ref*/
460 CFI_REL_OFFSET rip,RIP-\ref
461 .endm
462
463/* initial frame state for interrupts (and exceptions without error code) */
464#define INTR_FRAME _frame RIP
465/* initial frame state for exceptions with error code (and interrupts with
466 vector already pushed) */
467#define XCPT_FRAME _frame ORIG_RAX
468
395/* 469/*
396 * Interrupt entry/exit. 470 * Interrupt entry/exit.
397 * 471 *
@@ -402,10 +476,6 @@ ENTRY(stub_rt_sigreturn)
402 476
403/* 0(%rsp): interrupt number */ 477/* 0(%rsp): interrupt number */
404 .macro interrupt func 478 .macro interrupt func
405 CFI_STARTPROC simple
406 CFI_DEF_CFA rsp,(SS-RDI)
407 CFI_REL_OFFSET rsp,(RSP-ORIG_RAX)
408 CFI_REL_OFFSET rip,(RIP-ORIG_RAX)
409 cld 479 cld
410#ifdef CONFIG_DEBUG_INFO 480#ifdef CONFIG_DEBUG_INFO
411 SAVE_ALL 481 SAVE_ALL
@@ -425,23 +495,27 @@ ENTRY(stub_rt_sigreturn)
425 swapgs 495 swapgs
4261: incl %gs:pda_irqcount # RED-PEN should check preempt count 4961: incl %gs:pda_irqcount # RED-PEN should check preempt count
427 movq %gs:pda_irqstackptr,%rax 497 movq %gs:pda_irqstackptr,%rax
428 cmoveq %rax,%rsp 498 cmoveq %rax,%rsp /*todo This needs CFI annotation! */
429 pushq %rdi # save old stack 499 pushq %rdi # save old stack
500 CFI_ADJUST_CFA_OFFSET 8
430 call \func 501 call \func
431 .endm 502 .endm
432 503
433ENTRY(common_interrupt) 504ENTRY(common_interrupt)
505 XCPT_FRAME
434 interrupt do_IRQ 506 interrupt do_IRQ
435 /* 0(%rsp): oldrsp-ARGOFFSET */ 507 /* 0(%rsp): oldrsp-ARGOFFSET */
436ret_from_intr: 508ret_from_intr:
437 popq %rdi 509 popq %rdi
510 CFI_ADJUST_CFA_OFFSET -8
438 cli 511 cli
439 decl %gs:pda_irqcount 512 decl %gs:pda_irqcount
440#ifdef CONFIG_DEBUG_INFO 513#ifdef CONFIG_DEBUG_INFO
441 movq RBP(%rdi),%rbp 514 movq RBP(%rdi),%rbp
515 CFI_DEF_CFA_REGISTER rsp
442#endif 516#endif
443 leaq ARGOFFSET(%rdi),%rsp 517 leaq ARGOFFSET(%rdi),%rsp /*todo This needs CFI annotation! */
444exit_intr: 518exit_intr:
445 GET_THREAD_INFO(%rcx) 519 GET_THREAD_INFO(%rcx)
446 testl $3,CS-ARGOFFSET(%rsp) 520 testl $3,CS-ARGOFFSET(%rsp)
447 je retint_kernel 521 je retint_kernel
@@ -453,9 +527,10 @@ exit_intr:
453 */ 527 */
454retint_with_reschedule: 528retint_with_reschedule:
455 movl $_TIF_WORK_MASK,%edi 529 movl $_TIF_WORK_MASK,%edi
456retint_check: 530retint_check:
457 movl threadinfo_flags(%rcx),%edx 531 movl threadinfo_flags(%rcx),%edx
458 andl %edi,%edx 532 andl %edi,%edx
533 CFI_REMEMBER_STATE
459 jnz retint_careful 534 jnz retint_careful
460retint_swapgs: 535retint_swapgs:
461 swapgs 536 swapgs
@@ -476,14 +551,17 @@ bad_iret:
476 jmp do_exit 551 jmp do_exit
477 .previous 552 .previous
478 553
479 /* edi: workmask, edx: work */ 554 /* edi: workmask, edx: work */
480retint_careful: 555retint_careful:
556 CFI_RESTORE_STATE
481 bt $TIF_NEED_RESCHED,%edx 557 bt $TIF_NEED_RESCHED,%edx
482 jnc retint_signal 558 jnc retint_signal
483 sti 559 sti
484 pushq %rdi 560 pushq %rdi
561 CFI_ADJUST_CFA_OFFSET 8
485 call schedule 562 call schedule
486 popq %rdi 563 popq %rdi
564 CFI_ADJUST_CFA_OFFSET -8
487 GET_THREAD_INFO(%rcx) 565 GET_THREAD_INFO(%rcx)
488 cli 566 cli
489 jmp retint_check 567 jmp retint_check
@@ -523,7 +601,9 @@ retint_kernel:
523 * APIC interrupts. 601 * APIC interrupts.
524 */ 602 */
525 .macro apicinterrupt num,func 603 .macro apicinterrupt num,func
604 INTR_FRAME
526 pushq $\num-256 605 pushq $\num-256
606 CFI_ADJUST_CFA_OFFSET 8
527 interrupt \func 607 interrupt \func
528 jmp ret_from_intr 608 jmp ret_from_intr
529 CFI_ENDPROC 609 CFI_ENDPROC
@@ -536,8 +616,19 @@ ENTRY(thermal_interrupt)
536ENTRY(reschedule_interrupt) 616ENTRY(reschedule_interrupt)
537 apicinterrupt RESCHEDULE_VECTOR,smp_reschedule_interrupt 617 apicinterrupt RESCHEDULE_VECTOR,smp_reschedule_interrupt
538 618
539ENTRY(invalidate_interrupt) 619 .macro INVALIDATE_ENTRY num
540 apicinterrupt INVALIDATE_TLB_VECTOR,smp_invalidate_interrupt 620ENTRY(invalidate_interrupt\num)
621 apicinterrupt INVALIDATE_TLB_VECTOR_START+\num,smp_invalidate_interrupt
622 .endm
623
624 INVALIDATE_ENTRY 0
625 INVALIDATE_ENTRY 1
626 INVALIDATE_ENTRY 2
627 INVALIDATE_ENTRY 3
628 INVALIDATE_ENTRY 4
629 INVALIDATE_ENTRY 5
630 INVALIDATE_ENTRY 6
631 INVALIDATE_ENTRY 7
541 632
542ENTRY(call_function_interrupt) 633ENTRY(call_function_interrupt)
543 apicinterrupt CALL_FUNCTION_VECTOR,smp_call_function_interrupt 634 apicinterrupt CALL_FUNCTION_VECTOR,smp_call_function_interrupt
@@ -558,16 +649,23 @@ ENTRY(spurious_interrupt)
558 * Exception entry points. 649 * Exception entry points.
559 */ 650 */
560 .macro zeroentry sym 651 .macro zeroentry sym
652 INTR_FRAME
561 pushq $0 /* push error code/oldrax */ 653 pushq $0 /* push error code/oldrax */
654 CFI_ADJUST_CFA_OFFSET 8
562 pushq %rax /* push real oldrax to the rdi slot */ 655 pushq %rax /* push real oldrax to the rdi slot */
656 CFI_ADJUST_CFA_OFFSET 8
563 leaq \sym(%rip),%rax 657 leaq \sym(%rip),%rax
564 jmp error_entry 658 jmp error_entry
659 CFI_ENDPROC
565 .endm 660 .endm
566 661
567 .macro errorentry sym 662 .macro errorentry sym
663 XCPT_FRAME
568 pushq %rax 664 pushq %rax
665 CFI_ADJUST_CFA_OFFSET 8
569 leaq \sym(%rip),%rax 666 leaq \sym(%rip),%rax
570 jmp error_entry 667 jmp error_entry
668 CFI_ENDPROC
571 .endm 669 .endm
572 670
573 /* error code is on the stack already */ 671 /* error code is on the stack already */
@@ -594,10 +692,7 @@ ENTRY(spurious_interrupt)
594 * and the exception handler in %rax. 692 * and the exception handler in %rax.
595 */ 693 */
596ENTRY(error_entry) 694ENTRY(error_entry)
597 CFI_STARTPROC simple 695 _frame RDI
598 CFI_DEF_CFA rsp,(SS-RDI)
599 CFI_REL_OFFSET rsp,(RSP-RDI)
600 CFI_REL_OFFSET rip,(RIP-RDI)
601 /* rdi slot contains rax, oldrax contains error code */ 696 /* rdi slot contains rax, oldrax contains error code */
602 cld 697 cld
603 subq $14*8,%rsp 698 subq $14*8,%rsp
@@ -679,7 +774,9 @@ error_kernelspace:
679 /* Reload gs selector with exception handling */ 774 /* Reload gs selector with exception handling */
680 /* edi: new selector */ 775 /* edi: new selector */
681ENTRY(load_gs_index) 776ENTRY(load_gs_index)
777 CFI_STARTPROC
682 pushf 778 pushf
779 CFI_ADJUST_CFA_OFFSET 8
683 cli 780 cli
684 swapgs 781 swapgs
685gs_change: 782gs_change:
@@ -687,7 +784,9 @@ gs_change:
6872: mfence /* workaround */ 7842: mfence /* workaround */
688 swapgs 785 swapgs
689 popf 786 popf
787 CFI_ADJUST_CFA_OFFSET -8
690 ret 788 ret
789 CFI_ENDPROC
691 790
692 .section __ex_table,"a" 791 .section __ex_table,"a"
693 .align 8 792 .align 8
@@ -799,7 +898,7 @@ ENTRY(device_not_available)
799 898
800 /* runs on exception stack */ 899 /* runs on exception stack */
801KPROBE_ENTRY(debug) 900KPROBE_ENTRY(debug)
802 CFI_STARTPROC 901 INTR_FRAME
803 pushq $0 902 pushq $0
804 CFI_ADJUST_CFA_OFFSET 8 903 CFI_ADJUST_CFA_OFFSET 8
805 paranoidentry do_debug 904 paranoidentry do_debug
@@ -809,9 +908,9 @@ KPROBE_ENTRY(debug)
809 908
810 /* runs on exception stack */ 909 /* runs on exception stack */
811ENTRY(nmi) 910ENTRY(nmi)
812 CFI_STARTPROC 911 INTR_FRAME
813 pushq $-1 912 pushq $-1
814 CFI_ADJUST_CFA_OFFSET 8 913 CFI_ADJUST_CFA_OFFSET 8
815 paranoidentry do_nmi 914 paranoidentry do_nmi
816 /* 915 /*
817 * "Paranoid" exit path from exception stack. 916 * "Paranoid" exit path from exception stack.
@@ -877,7 +976,7 @@ ENTRY(reserved)
877 976
878 /* runs on exception stack */ 977 /* runs on exception stack */
879ENTRY(double_fault) 978ENTRY(double_fault)
880 CFI_STARTPROC 979 XCPT_FRAME
881 paranoidentry do_double_fault 980 paranoidentry do_double_fault
882 jmp paranoid_exit 981 jmp paranoid_exit
883 CFI_ENDPROC 982 CFI_ENDPROC
@@ -890,7 +989,7 @@ ENTRY(segment_not_present)
890 989
891 /* runs on exception stack */ 990 /* runs on exception stack */
892ENTRY(stack_segment) 991ENTRY(stack_segment)
893 CFI_STARTPROC 992 XCPT_FRAME
894 paranoidentry do_stack_segment 993 paranoidentry do_stack_segment
895 jmp paranoid_exit 994 jmp paranoid_exit
896 CFI_ENDPROC 995 CFI_ENDPROC
@@ -911,7 +1010,7 @@ ENTRY(spurious_interrupt_bug)
911#ifdef CONFIG_X86_MCE 1010#ifdef CONFIG_X86_MCE
912 /* runs on exception stack */ 1011 /* runs on exception stack */
913ENTRY(machine_check) 1012ENTRY(machine_check)
914 CFI_STARTPROC 1013 INTR_FRAME
915 pushq $0 1014 pushq $0
916 CFI_ADJUST_CFA_OFFSET 8 1015 CFI_ADJUST_CFA_OFFSET 8
917 paranoidentry do_machine_check 1016 paranoidentry do_machine_check
@@ -923,14 +1022,19 @@ ENTRY(call_debug)
923 zeroentry do_call_debug 1022 zeroentry do_call_debug
924 1023
925ENTRY(call_softirq) 1024ENTRY(call_softirq)
1025 CFI_STARTPROC
926 movq %gs:pda_irqstackptr,%rax 1026 movq %gs:pda_irqstackptr,%rax
927 pushq %r15 1027 pushq %r15
1028 CFI_ADJUST_CFA_OFFSET 8
928 movq %rsp,%r15 1029 movq %rsp,%r15
1030 CFI_DEF_CFA_REGISTER r15
929 incl %gs:pda_irqcount 1031 incl %gs:pda_irqcount
930 cmove %rax,%rsp 1032 cmove %rax,%rsp
931 call __do_softirq 1033 call __do_softirq
932 movq %r15,%rsp 1034 movq %r15,%rsp
1035 CFI_DEF_CFA_REGISTER rsp
933 decl %gs:pda_irqcount 1036 decl %gs:pda_irqcount
934 popq %r15 1037 popq %r15
1038 CFI_ADJUST_CFA_OFFSET -8
935 ret 1039 ret
936 1040 CFI_ENDPROC
diff --git a/arch/x86_64/kernel/genapic.c b/arch/x86_64/kernel/genapic.c
index b1c144f73149..7a64ea181788 100644
--- a/arch/x86_64/kernel/genapic.c
+++ b/arch/x86_64/kernel/genapic.c
@@ -45,7 +45,7 @@ void __init clustered_apic_check(void)
45 u8 clusters, max_cluster; 45 u8 clusters, max_cluster;
46 u8 id; 46 u8 id;
47 u8 cluster_cnt[NUM_APIC_CLUSTERS]; 47 u8 cluster_cnt[NUM_APIC_CLUSTERS];
48 int num_cpus = 0; 48 int max_apic = 0;
49 49
50#if defined(CONFIG_ACPI) 50#if defined(CONFIG_ACPI)
51 /* 51 /*
@@ -64,14 +64,15 @@ void __init clustered_apic_check(void)
64 id = bios_cpu_apicid[i]; 64 id = bios_cpu_apicid[i];
65 if (id == BAD_APICID) 65 if (id == BAD_APICID)
66 continue; 66 continue;
67 num_cpus++; 67 if (id > max_apic)
68 max_apic = id;
68 cluster_cnt[APIC_CLUSTERID(id)]++; 69 cluster_cnt[APIC_CLUSTERID(id)]++;
69 } 70 }
70 71
71 /* Don't use clustered mode on AMD platforms. */ 72 /* Don't use clustered mode on AMD platforms. */
72 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { 73 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
73 genapic = &apic_physflat; 74 genapic = &apic_physflat;
74#ifndef CONFIG_CPU_HOTPLUG 75#ifndef CONFIG_HOTPLUG_CPU
75 /* In the CPU hotplug case we cannot use broadcast mode 76 /* In the CPU hotplug case we cannot use broadcast mode
76 because that opens a race when a CPU is removed. 77 because that opens a race when a CPU is removed.
77 Stay at physflat mode in this case. 78 Stay at physflat mode in this case.
@@ -79,7 +80,7 @@ void __init clustered_apic_check(void)
79 we have ACPI platform support for CPU hotplug 80 we have ACPI platform support for CPU hotplug
80 we should detect hotplug capablity from ACPI tables and 81 we should detect hotplug capablity from ACPI tables and
81 only do this when really needed. -AK */ 82 only do this when really needed. -AK */
82 if (num_cpus <= 8) 83 if (max_apic <= 8)
83 genapic = &apic_flat; 84 genapic = &apic_flat;
84#endif 85#endif
85 goto print; 86 goto print;
@@ -103,9 +104,14 @@ void __init clustered_apic_check(void)
103 * (We don't use lowest priority delivery + HW APIC IRQ steering, so 104 * (We don't use lowest priority delivery + HW APIC IRQ steering, so
104 * can ignore the clustered logical case and go straight to physical.) 105 * can ignore the clustered logical case and go straight to physical.)
105 */ 106 */
106 if (clusters <= 1 && max_cluster <= 8 && cluster_cnt[0] == max_cluster) 107 if (clusters <= 1 && max_cluster <= 8 && cluster_cnt[0] == max_cluster) {
108#ifdef CONFIG_HOTPLUG_CPU
109 /* Don't use APIC shortcuts in CPU hotplug to avoid races */
110 genapic = &apic_physflat;
111#else
107 genapic = &apic_flat; 112 genapic = &apic_flat;
108 else 113#endif
114 } else
109 genapic = &apic_cluster; 115 genapic = &apic_cluster;
110 116
111print: 117print:
diff --git a/arch/x86_64/kernel/genapic_cluster.c b/arch/x86_64/kernel/genapic_cluster.c
index f6523dd1bc09..a472d62f899a 100644
--- a/arch/x86_64/kernel/genapic_cluster.c
+++ b/arch/x86_64/kernel/genapic_cluster.c
@@ -51,10 +51,10 @@ static void cluster_init_apic_ldr(void)
51 count = 3; 51 count = 3;
52 id = my_cluster | (1UL << count); 52 id = my_cluster | (1UL << count);
53 x86_cpu_to_log_apicid[smp_processor_id()] = id; 53 x86_cpu_to_log_apicid[smp_processor_id()] = id;
54 apic_write_around(APIC_DFR, APIC_DFR_CLUSTER); 54 apic_write(APIC_DFR, APIC_DFR_CLUSTER);
55 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; 55 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
56 val |= SET_APIC_LOGICAL_ID(id); 56 val |= SET_APIC_LOGICAL_ID(id);
57 apic_write_around(APIC_LDR, val); 57 apic_write(APIC_LDR, val);
58} 58}
59 59
60/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ 60/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */
diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c
index 6d57da96bf8c..9da3edb799ea 100644
--- a/arch/x86_64/kernel/genapic_flat.c
+++ b/arch/x86_64/kernel/genapic_flat.c
@@ -38,10 +38,10 @@ static void flat_init_apic_ldr(void)
38 num = smp_processor_id(); 38 num = smp_processor_id();
39 id = 1UL << num; 39 id = 1UL << num;
40 x86_cpu_to_log_apicid[num] = id; 40 x86_cpu_to_log_apicid[num] = id;
41 apic_write_around(APIC_DFR, APIC_DFR_FLAT); 41 apic_write(APIC_DFR, APIC_DFR_FLAT);
42 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; 42 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
43 val |= SET_APIC_LOGICAL_ID(id); 43 val |= SET_APIC_LOGICAL_ID(id);
44 apic_write_around(APIC_LDR, val); 44 apic_write(APIC_LDR, val);
45} 45}
46 46
47static void flat_send_IPI_mask(cpumask_t cpumask, int vector) 47static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
@@ -62,7 +62,7 @@ static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
62 * prepare target chip field 62 * prepare target chip field
63 */ 63 */
64 cfg = __prepare_ICR2(mask); 64 cfg = __prepare_ICR2(mask);
65 apic_write_around(APIC_ICR2, cfg); 65 apic_write(APIC_ICR2, cfg);
66 66
67 /* 67 /*
68 * program the ICR 68 * program the ICR
@@ -72,7 +72,7 @@ static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
72 /* 72 /*
73 * Send the IPI. The write to APIC_ICR fires this off. 73 * Send the IPI. The write to APIC_ICR fires this off.
74 */ 74 */
75 apic_write_around(APIC_ICR, cfg); 75 apic_write(APIC_ICR, cfg);
76 local_irq_restore(flags); 76 local_irq_restore(flags);
77} 77}
78 78
@@ -177,9 +177,9 @@ static unsigned int physflat_cpu_mask_to_apicid(cpumask_t cpumask)
177 177
178struct genapic apic_physflat = { 178struct genapic apic_physflat = {
179 .name = "physical flat", 179 .name = "physical flat",
180 .int_delivery_mode = dest_LowestPrio, 180 .int_delivery_mode = dest_Fixed,
181 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 181 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
182 .int_delivery_dest = APIC_DEST_PHYSICAL | APIC_DM_LOWEST, 182 .int_delivery_dest = APIC_DEST_PHYSICAL | APIC_DM_FIXED,
183 .target_cpus = physflat_target_cpus, 183 .target_cpus = physflat_target_cpus,
184 .apic_id_registered = flat_apic_id_registered, 184 .apic_id_registered = flat_apic_id_registered,
185 .init_apic_ldr = flat_init_apic_ldr,/*not needed, but shouldn't hurt*/ 185 .init_apic_ldr = flat_init_apic_ldr,/*not needed, but shouldn't hurt*/
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 98ff5eb32b9a..4592bf21fcaf 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -270,7 +270,7 @@ ENTRY(level3_kernel_pgt)
270.org 0x4000 270.org 0x4000
271ENTRY(level2_ident_pgt) 271ENTRY(level2_ident_pgt)
272 /* 40MB for bootup. */ 272 /* 40MB for bootup. */
273 .quad 0x0000000000000283 273 .quad 0x0000000000000183
274 .quad 0x0000000000200183 274 .quad 0x0000000000200183
275 .quad 0x0000000000400183 275 .quad 0x0000000000400183
276 .quad 0x0000000000600183 276 .quad 0x0000000000600183
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index a89169095129..b2a238b5a17e 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -18,15 +18,12 @@
18#include <asm/atomic.h> 18#include <asm/atomic.h>
19#include <asm/system.h> 19#include <asm/system.h>
20#include <asm/io.h> 20#include <asm/io.h>
21#include <asm/irq.h>
22#include <asm/hw_irq.h> 21#include <asm/hw_irq.h>
23#include <asm/pgtable.h> 22#include <asm/pgtable.h>
24#include <asm/delay.h> 23#include <asm/delay.h>
25#include <asm/desc.h> 24#include <asm/desc.h>
26#include <asm/apic.h> 25#include <asm/apic.h>
27 26
28#include <linux/irq.h>
29
30/* 27/*
31 * Common place to define all x86 IRQ vectors 28 * Common place to define all x86 IRQ vectors
32 * 29 *
@@ -486,7 +483,14 @@ void spurious_interrupt(void);
486void error_interrupt(void); 483void error_interrupt(void);
487void reschedule_interrupt(void); 484void reschedule_interrupt(void);
488void call_function_interrupt(void); 485void call_function_interrupt(void);
489void invalidate_interrupt(void); 486void invalidate_interrupt0(void);
487void invalidate_interrupt1(void);
488void invalidate_interrupt2(void);
489void invalidate_interrupt3(void);
490void invalidate_interrupt4(void);
491void invalidate_interrupt5(void);
492void invalidate_interrupt6(void);
493void invalidate_interrupt7(void);
490void thermal_interrupt(void); 494void thermal_interrupt(void);
491void i8254_timer_resume(void); 495void i8254_timer_resume(void);
492 496
@@ -562,8 +566,15 @@ void __init init_IRQ(void)
562 */ 566 */
563 set_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt); 567 set_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
564 568
565 /* IPI for invalidation */ 569 /* IPIs for invalidation */
566 set_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt); 570 set_intr_gate(INVALIDATE_TLB_VECTOR_START+0, invalidate_interrupt0);
571 set_intr_gate(INVALIDATE_TLB_VECTOR_START+1, invalidate_interrupt1);
572 set_intr_gate(INVALIDATE_TLB_VECTOR_START+2, invalidate_interrupt2);
573 set_intr_gate(INVALIDATE_TLB_VECTOR_START+3, invalidate_interrupt3);
574 set_intr_gate(INVALIDATE_TLB_VECTOR_START+4, invalidate_interrupt4);
575 set_intr_gate(INVALIDATE_TLB_VECTOR_START+5, invalidate_interrupt5);
576 set_intr_gate(INVALIDATE_TLB_VECTOR_START+6, invalidate_interrupt6);
577 set_intr_gate(INVALIDATE_TLB_VECTOR_START+7, invalidate_interrupt7);
567 578
568 /* IPI for generic function call */ 579 /* IPI for generic function call */
569 set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); 580 set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
diff --git a/arch/x86_64/kernel/init_task.c b/arch/x86_64/kernel/init_task.c
index c4dc91491157..e0ba5c1043fd 100644
--- a/arch/x86_64/kernel/init_task.c
+++ b/arch/x86_64/kernel/init_task.c
@@ -44,6 +44,6 @@ EXPORT_SYMBOL(init_task);
44 * section. Since TSS's are completely CPU-local, we want them 44 * section. Since TSS's are completely CPU-local, we want them
45 * on exact cacheline boundaries, to eliminate cacheline ping-pong. 45 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
46 */ 46 */
47DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_maxaligned_in_smp; 47DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_maxaligned_in_smp = INIT_TSS;
48 48
49#define ALIGN_TO_4K __attribute__((section(".data.init_task"))) 49#define ALIGN_TO_4K __attribute__((section(".data.init_task")))
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 5f1529be1237..522944a000ad 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/irq.h>
25#include <linux/interrupt.h> 24#include <linux/interrupt.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
@@ -45,6 +44,8 @@ int sis_apic_bug; /* not actually supported, dummy for compile */
45 44
46static int no_timer_check; 45static int no_timer_check;
47 46
47int disable_timer_pin_1 __initdata;
48
48static DEFINE_SPINLOCK(ioapic_lock); 49static DEFINE_SPINLOCK(ioapic_lock);
49 50
50/* 51/*
@@ -298,6 +299,15 @@ void __init check_ioapic(void)
298#endif 299#endif
299 /* RED-PEN skip them on mptables too? */ 300 /* RED-PEN skip them on mptables too? */
300 return; 301 return;
302 case PCI_VENDOR_ID_ATI:
303 /* All timer interrupts on atiixp
304 are doubled. Disable one. */
305 if (disable_timer_pin_1 == 0) {
306 disable_timer_pin_1 = 1;
307 printk(KERN_INFO
308 "ATI board detected. Disabling timer pin 1.\n");
309 }
310 return;
301 } 311 }
302 312
303 /* No multi-function device? */ 313 /* No multi-function device? */
@@ -1022,13 +1032,11 @@ void __apicdebuginit print_local_APIC(void * dummy)
1022 v = apic_read(APIC_TASKPRI); 1032 v = apic_read(APIC_TASKPRI);
1023 printk(KERN_DEBUG "... APIC TASKPRI: %08x (%02x)\n", v, v & APIC_TPRI_MASK); 1033 printk(KERN_DEBUG "... APIC TASKPRI: %08x (%02x)\n", v, v & APIC_TPRI_MASK);
1024 1034
1025 if (APIC_INTEGRATED(ver)) { /* !82489DX */ 1035 v = apic_read(APIC_ARBPRI);
1026 v = apic_read(APIC_ARBPRI); 1036 printk(KERN_DEBUG "... APIC ARBPRI: %08x (%02x)\n", v,
1027 printk(KERN_DEBUG "... APIC ARBPRI: %08x (%02x)\n", v, 1037 v & APIC_ARBPRI_MASK);
1028 v & APIC_ARBPRI_MASK); 1038 v = apic_read(APIC_PROCPRI);
1029 v = apic_read(APIC_PROCPRI); 1039 printk(KERN_DEBUG "... APIC PROCPRI: %08x\n", v);
1030 printk(KERN_DEBUG "... APIC PROCPRI: %08x\n", v);
1031 }
1032 1040
1033 v = apic_read(APIC_EOI); 1041 v = apic_read(APIC_EOI);
1034 printk(KERN_DEBUG "... APIC EOI: %08x\n", v); 1042 printk(KERN_DEBUG "... APIC EOI: %08x\n", v);
@@ -1048,12 +1056,8 @@ void __apicdebuginit print_local_APIC(void * dummy)
1048 printk(KERN_DEBUG "... APIC IRR field:\n"); 1056 printk(KERN_DEBUG "... APIC IRR field:\n");
1049 print_APIC_bitfield(APIC_IRR); 1057 print_APIC_bitfield(APIC_IRR);
1050 1058
1051 if (APIC_INTEGRATED(ver)) { /* !82489DX */ 1059 v = apic_read(APIC_ESR);
1052 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ 1060 printk(KERN_DEBUG "... APIC ESR: %08x\n", v);
1053 apic_write(APIC_ESR, 0);
1054 v = apic_read(APIC_ESR);
1055 printk(KERN_DEBUG "... APIC ESR: %08x\n", v);
1056 }
1057 1061
1058 v = apic_read(APIC_ICR); 1062 v = apic_read(APIC_ICR);
1059 printk(KERN_DEBUG "... APIC ICR: %08x\n", v); 1063 printk(KERN_DEBUG "... APIC ICR: %08x\n", v);
@@ -1665,6 +1669,8 @@ static inline void check_timer(void)
1665 setup_nmi(); 1669 setup_nmi();
1666 enable_8259A_irq(0); 1670 enable_8259A_irq(0);
1667 } 1671 }
1672 if (disable_timer_pin_1 > 0)
1673 clear_IO_APIC_pin(0, pin1);
1668 return; 1674 return;
1669 } 1675 }
1670 clear_IO_APIC_pin(0, pin1); 1676 clear_IO_APIC_pin(0, pin1);
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index 849a20aec7ca..d6a04a8320a3 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -99,7 +99,6 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
99 unsigned irq = regs->orig_rax & 0xff; 99 unsigned irq = regs->orig_rax & 0xff;
100 100
101 irq_enter(); 101 irq_enter();
102 BUG_ON(irq > 256);
103 102
104 __do_IRQ(irq, regs); 103 __do_IRQ(irq, regs);
105 irq_exit(); 104 irq_exit();
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 8aa56736cde3..969365c0771b 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -17,6 +17,7 @@
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/cpu.h> 18#include <linux/cpu.h>
19#include <linux/percpu.h> 19#include <linux/percpu.h>
20#include <linux/ctype.h>
20#include <asm/processor.h> 21#include <asm/processor.h>
21#include <asm/msr.h> 22#include <asm/msr.h>
22#include <asm/mce.h> 23#include <asm/mce.h>
@@ -56,15 +57,19 @@ void mce_log(struct mce *mce)
56 smp_wmb(); 57 smp_wmb();
57 for (;;) { 58 for (;;) {
58 entry = rcu_dereference(mcelog.next); 59 entry = rcu_dereference(mcelog.next);
59 /* When the buffer fills up discard new entries. Assume 60 for (;;) {
60 that the earlier errors are the more interesting. */ 61 /* When the buffer fills up discard new entries. Assume
61 if (entry >= MCE_LOG_LEN) { 62 that the earlier errors are the more interesting. */
62 set_bit(MCE_OVERFLOW, &mcelog.flags); 63 if (entry >= MCE_LOG_LEN) {
63 return; 64 set_bit(MCE_OVERFLOW, &mcelog.flags);
65 return;
66 }
67 /* Old left over entry. Skip. */
68 if (mcelog.entry[entry].finished) {
69 entry++;
70 continue;
71 }
64 } 72 }
65 /* Old left over entry. Skip. */
66 if (mcelog.entry[entry].finished)
67 continue;
68 smp_rmb(); 73 smp_rmb();
69 next = entry + 1; 74 next = entry + 1;
70 if (cmpxchg(&mcelog.next, entry, next) == entry) 75 if (cmpxchg(&mcelog.next, entry, next) == entry)
@@ -404,9 +409,15 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, loff
404 } 409 }
405 410
406 err = 0; 411 err = 0;
407 for (i = 0; i < next; i++) { 412 for (i = 0; i < next; i++) {
408 if (!mcelog.entry[i].finished) 413 unsigned long start = jiffies;
409 continue; 414 while (!mcelog.entry[i].finished) {
415 if (!time_before(jiffies, start + 2)) {
416 memset(mcelog.entry + i,0, sizeof(struct mce));
417 continue;
418 }
419 cpu_relax();
420 }
410 smp_rmb(); 421 smp_rmb();
411 err |= copy_to_user(buf, mcelog.entry + i, sizeof(struct mce)); 422 err |= copy_to_user(buf, mcelog.entry + i, sizeof(struct mce));
412 buf += sizeof(struct mce); 423 buf += sizeof(struct mce);
@@ -479,6 +490,7 @@ static int __init mcheck_disable(char *str)
479 490
480/* mce=off disables machine check. Note you can reenable it later 491/* mce=off disables machine check. Note you can reenable it later
481 using sysfs. 492 using sysfs.
493 mce=TOLERANCELEVEL (number, see above)
482 mce=bootlog Log MCEs from before booting. Disabled by default to work 494 mce=bootlog Log MCEs from before booting. Disabled by default to work
483 around buggy BIOS that leave bogus MCEs. */ 495 around buggy BIOS that leave bogus MCEs. */
484static int __init mcheck_enable(char *str) 496static int __init mcheck_enable(char *str)
@@ -489,6 +501,8 @@ static int __init mcheck_enable(char *str)
489 mce_dont_init = 1; 501 mce_dont_init = 1;
490 else if (!strcmp(str, "bootlog")) 502 else if (!strcmp(str, "bootlog"))
491 mce_bootlog = 1; 503 mce_bootlog = 1;
504 else if (isdigit(str[0]))
505 get_option(&str, &tolerant);
492 else 506 else
493 printk("mce= argument %s ignored. Please use /sys", str); 507 printk("mce= argument %s ignored. Please use /sys", str);
494 return 0; 508 return 0;
@@ -501,10 +515,12 @@ __setup("mce", mcheck_enable);
501 * Sysfs support 515 * Sysfs support
502 */ 516 */
503 517
504/* On resume clear all MCE state. Don't want to see leftovers from the BIOS. */ 518/* On resume clear all MCE state. Don't want to see leftovers from the BIOS.
519 Only one CPU is active at this time, the others get readded later using
520 CPU hotplug. */
505static int mce_resume(struct sys_device *dev) 521static int mce_resume(struct sys_device *dev)
506{ 522{
507 on_each_cpu(mce_init, NULL, 1, 1); 523 mce_init(NULL);
508 return 0; 524 return 0;
509} 525}
510 526
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 8d8ed6ae1d0c..f16d38d09daf 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/irq.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/config.h> 19#include <linux/config.h>
@@ -46,8 +45,6 @@ int acpi_found_madt;
46int apic_version [MAX_APICS]; 45int apic_version [MAX_APICS];
47unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; 46unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
48int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; 47int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
49unsigned char pci_bus_to_node [256];
50EXPORT_SYMBOL(pci_bus_to_node);
51 48
52static int mp_current_pci_id = 0; 49static int mp_current_pci_id = 0;
53/* I/O APIC entries */ 50/* I/O APIC entries */
@@ -705,7 +702,7 @@ void __init mp_register_lapic (
705 702
706 processor.mpc_type = MP_PROCESSOR; 703 processor.mpc_type = MP_PROCESSOR;
707 processor.mpc_apicid = id; 704 processor.mpc_apicid = id;
708 processor.mpc_apicver = 0x10; /* TBD: lapic version */ 705 processor.mpc_apicver = GET_APIC_VERSION(apic_read(APIC_LVR));
709 processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0); 706 processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
710 processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0); 707 processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
711 processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | 708 processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) |
diff --git a/arch/x86_64/kernel/msr.c b/arch/x86_64/kernel/msr.c
deleted file mode 100644
index 598953ab0154..000000000000
--- a/arch/x86_64/kernel/msr.c
+++ /dev/null
@@ -1,279 +0,0 @@
1/* ----------------------------------------------------------------------- *
2 *
3 * Copyright 2000 H. Peter Anvin - All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
8 * USA; either version 2 of the License, or (at your option) any later
9 * version; incorporated herein by reference.
10 *
11 * ----------------------------------------------------------------------- */
12
13/*
14 * msr.c
15 *
16 * x86 MSR access device
17 *
18 * This device is accessed by lseek() to the appropriate register number
19 * and then read/write in chunks of 8 bytes. A larger size means multiple
20 * reads or writes of the same register.
21 *
22 * This driver uses /dev/cpu/%d/msr where %d is the minor number, and on
23 * an SMP box will direct the access to CPU %d.
24 */
25
26#include <linux/module.h>
27#include <linux/config.h>
28
29#include <linux/types.h>
30#include <linux/errno.h>
31#include <linux/fcntl.h>
32#include <linux/init.h>
33#include <linux/poll.h>
34#include <linux/smp.h>
35#include <linux/smp_lock.h>
36#include <linux/major.h>
37#include <linux/fs.h>
38
39#include <asm/processor.h>
40#include <asm/msr.h>
41#include <asm/uaccess.h>
42#include <asm/system.h>
43
44/* Note: "err" is handled in a funny way below. Otherwise one version
45 of gcc or another breaks. */
46
47static inline int wrmsr_eio(u32 reg, u32 eax, u32 edx)
48{
49 int err;
50
51 asm volatile ("1: wrmsr\n"
52 "2:\n"
53 ".section .fixup,\"ax\"\n"
54 "3: movl %4,%0\n"
55 " jmp 2b\n"
56 ".previous\n"
57 ".section __ex_table,\"a\"\n"
58 " .align 8\n" " .quad 1b,3b\n" ".previous":"=&bDS" (err)
59 :"a"(eax), "d"(edx), "c"(reg), "i"(-EIO), "0"(0));
60
61 return err;
62}
63
64static inline int rdmsr_eio(u32 reg, u32 *eax, u32 *edx)
65{
66 int err;
67
68 asm volatile ("1: rdmsr\n"
69 "2:\n"
70 ".section .fixup,\"ax\"\n"
71 "3: movl %4,%0\n"
72 " jmp 2b\n"
73 ".previous\n"
74 ".section __ex_table,\"a\"\n"
75 " .align 8\n"
76 " .quad 1b,3b\n"
77 ".previous":"=&bDS" (err), "=a"(*eax), "=d"(*edx)
78 :"c"(reg), "i"(-EIO), "0"(0));
79
80 return err;
81}
82
83#ifdef CONFIG_SMP
84
85struct msr_command {
86 int cpu;
87 int err;
88 u32 reg;
89 u32 data[2];
90};
91
92static void msr_smp_wrmsr(void *cmd_block)
93{
94 struct msr_command *cmd = (struct msr_command *)cmd_block;
95
96 if (cmd->cpu == smp_processor_id())
97 cmd->err = wrmsr_eio(cmd->reg, cmd->data[0], cmd->data[1]);
98}
99
100static void msr_smp_rdmsr(void *cmd_block)
101{
102 struct msr_command *cmd = (struct msr_command *)cmd_block;
103
104 if (cmd->cpu == smp_processor_id())
105 cmd->err = rdmsr_eio(cmd->reg, &cmd->data[0], &cmd->data[1]);
106}
107
108static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
109{
110 struct msr_command cmd;
111 int ret;
112
113 preempt_disable();
114 if (cpu == smp_processor_id()) {
115 ret = wrmsr_eio(reg, eax, edx);
116 } else {
117 cmd.cpu = cpu;
118 cmd.reg = reg;
119 cmd.data[0] = eax;
120 cmd.data[1] = edx;
121
122 smp_call_function(msr_smp_wrmsr, &cmd, 1, 1);
123 ret = cmd.err;
124 }
125 preempt_enable();
126 return ret;
127}
128
129static inline int do_rdmsr(int cpu, u32 reg, u32 * eax, u32 * edx)
130{
131 struct msr_command cmd;
132 int ret;
133
134 preempt_disable();
135 if (cpu == smp_processor_id()) {
136 ret = rdmsr_eio(reg, eax, edx);
137 } else {
138 cmd.cpu = cpu;
139 cmd.reg = reg;
140
141 smp_call_function(msr_smp_rdmsr, &cmd, 1, 1);
142
143 *eax = cmd.data[0];
144 *edx = cmd.data[1];
145
146 ret = cmd.err;
147 }
148 preempt_enable();
149 return ret;
150}
151
152#else /* ! CONFIG_SMP */
153
154static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
155{
156 return wrmsr_eio(reg, eax, edx);
157}
158
159static inline int do_rdmsr(int cpu, u32 reg, u32 *eax, u32 *edx)
160{
161 return rdmsr_eio(reg, eax, edx);
162}
163
164#endif /* ! CONFIG_SMP */
165
166static loff_t msr_seek(struct file *file, loff_t offset, int orig)
167{
168 loff_t ret = -EINVAL;
169
170 lock_kernel();
171 switch (orig) {
172 case 0:
173 file->f_pos = offset;
174 ret = file->f_pos;
175 break;
176 case 1:
177 file->f_pos += offset;
178 ret = file->f_pos;
179 }
180 unlock_kernel();
181 return ret;
182}
183
184static ssize_t msr_read(struct file *file, char __user * buf,
185 size_t count, loff_t * ppos)
186{
187 u32 __user *tmp = (u32 __user *) buf;
188 u32 data[2];
189 size_t rv;
190 u32 reg = *ppos;
191 int cpu = iminor(file->f_dentry->d_inode);
192 int err;
193
194 if (count % 8)
195 return -EINVAL; /* Invalid chunk size */
196
197 for (rv = 0; count; count -= 8) {
198 err = do_rdmsr(cpu, reg, &data[0], &data[1]);
199 if (err)
200 return err;
201 if (copy_to_user(tmp, &data, 8))
202 return -EFAULT;
203 tmp += 2;
204 }
205
206 return ((char __user *)tmp) - buf;
207}
208
209static ssize_t msr_write(struct file *file, const char __user *buf,
210 size_t count, loff_t *ppos)
211{
212 const u32 __user *tmp = (const u32 __user *)buf;
213 u32 data[2];
214 size_t rv;
215 u32 reg = *ppos;
216 int cpu = iminor(file->f_dentry->d_inode);
217 int err;
218
219 if (count % 8)
220 return -EINVAL; /* Invalid chunk size */
221
222 for (rv = 0; count; count -= 8) {
223 if (copy_from_user(&data, tmp, 8))
224 return -EFAULT;
225 err = do_wrmsr(cpu, reg, data[0], data[1]);
226 if (err)
227 return err;
228 tmp += 2;
229 }
230
231 return ((char __user *)tmp) - buf;
232}
233
234static int msr_open(struct inode *inode, struct file *file)
235{
236 unsigned int cpu = iminor(file->f_dentry->d_inode);
237 struct cpuinfo_x86 *c = &(cpu_data)[cpu];
238
239 if (cpu >= NR_CPUS || !cpu_online(cpu))
240 return -ENXIO; /* No such CPU */
241 if (!cpu_has(c, X86_FEATURE_MSR))
242 return -EIO; /* MSR not supported */
243
244 return 0;
245}
246
247/*
248 * File operations we support
249 */
250static struct file_operations msr_fops = {
251 .owner = THIS_MODULE,
252 .llseek = msr_seek,
253 .read = msr_read,
254 .write = msr_write,
255 .open = msr_open,
256};
257
258static int __init msr_init(void)
259{
260 if (register_chrdev(MSR_MAJOR, "cpu/msr", &msr_fops)) {
261 printk(KERN_ERR "msr: unable to get major %d for msr\n",
262 MSR_MAJOR);
263 return -EBUSY;
264 }
265
266 return 0;
267}
268
269static void __exit msr_exit(void)
270{
271 unregister_chrdev(MSR_MAJOR, "cpu/msr");
272}
273
274module_init(msr_init);
275module_exit(msr_exit)
276
277MODULE_AUTHOR("H. Peter Anvin <hpa@zytor.com>");
278MODULE_DESCRIPTION("x86 generic MSR driver");
279MODULE_LICENSE("GPL");
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index caf164959e19..4388b8a5bae7 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/config.h> 15#include <linux/config.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/irq.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/bootmem.h> 18#include <linux/bootmem.h>
20#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
@@ -488,8 +487,8 @@ void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason)
488 == NOTIFY_STOP) { 487 == NOTIFY_STOP) {
489 local_set(&__get_cpu_var(alert_counter), 0); 488 local_set(&__get_cpu_var(alert_counter), 0);
490 return; 489 return;
491 } 490 }
492 die_nmi("NMI Watchdog detected LOCKUP on CPU%d", regs); 491 die_nmi("NMI Watchdog detected LOCKUP on CPU %d\n", regs);
493 } 492 }
494 } else { 493 } else {
495 __get_cpu_var(last_irq_sum) = sum; 494 __get_cpu_var(last_irq_sum) = sum;
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 57f35c68aa34..cf0a0315d586 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -191,11 +191,9 @@ static void *dma_alloc_pages(struct device *dev, unsigned gfp, unsigned order)
191{ 191{
192 struct page *page; 192 struct page *page;
193 int node; 193 int node;
194 if (dev->bus == &pci_bus_type) { 194 if (dev->bus == &pci_bus_type)
195 cpumask_t mask; 195 node = pcibus_to_node(to_pci_dev(dev)->bus);
196 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 196 else
197 node = cpu_to_node(first_cpu(mask));
198 } else
199 node = numa_node_id(); 197 node = numa_node_id();
200 page = alloc_pages_node(node, gfp, order); 198 page = alloc_pages_node(node, gfp, order);
201 return page ? page_address(page) : NULL; 199 return page ? page_address(page) : NULL;
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 8661f82ac70b..b5a89c0bdf59 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -32,7 +32,6 @@
32#include <linux/a.out.h> 32#include <linux/a.out.h>
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/irq.h>
36#include <linux/ptrace.h> 35#include <linux/ptrace.h>
37#include <linux/utsname.h> 36#include <linux/utsname.h>
38#include <linux/random.h> 37#include <linux/random.h>
@@ -123,6 +122,7 @@ static void poll_idle (void)
123 : : 122 : :
124 "i" (_TIF_NEED_RESCHED), 123 "i" (_TIF_NEED_RESCHED),
125 "m" (current_thread_info()->flags)); 124 "m" (current_thread_info()->flags));
125 clear_thread_flag(TIF_POLLING_NRFLAG);
126 } else { 126 } else {
127 set_need_resched(); 127 set_need_resched();
128 } 128 }
@@ -271,8 +271,11 @@ void __show_regs(struct pt_regs * regs)
271 271
272 printk("\n"); 272 printk("\n");
273 print_modules(); 273 print_modules();
274 printk("Pid: %d, comm: %.20s %s %s\n", 274 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
275 current->pid, current->comm, print_tainted(), system_utsname.release); 275 current->pid, current->comm, print_tainted(),
276 system_utsname.release,
277 (int)strcspn(system_utsname.version, " "),
278 system_utsname.version);
276 printk("RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->rip); 279 printk("RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->rip);
277 printk_address(regs->rip); 280 printk_address(regs->rip);
278 printk("\nRSP: %04lx:%016lx EFLAGS: %08lx\n", regs->ss, regs->rsp, regs->eflags); 281 printk("\nRSP: %04lx:%016lx EFLAGS: %08lx\n", regs->ss, regs->rsp, regs->eflags);
@@ -483,33 +486,6 @@ out:
483} 486}
484 487
485/* 488/*
486 * This function selects if the context switch from prev to next
487 * has to tweak the TSC disable bit in the cr4.
488 */
489static inline void disable_tsc(struct task_struct *prev_p,
490 struct task_struct *next_p)
491{
492 struct thread_info *prev, *next;
493
494 /*
495 * gcc should eliminate the ->thread_info dereference if
496 * has_secure_computing returns 0 at compile time (SECCOMP=n).
497 */
498 prev = prev_p->thread_info;
499 next = next_p->thread_info;
500
501 if (has_secure_computing(prev) || has_secure_computing(next)) {
502 /* slow path here */
503 if (has_secure_computing(prev) &&
504 !has_secure_computing(next)) {
505 write_cr4(read_cr4() & ~X86_CR4_TSD);
506 } else if (!has_secure_computing(prev) &&
507 has_secure_computing(next))
508 write_cr4(read_cr4() | X86_CR4_TSD);
509 }
510}
511
512/*
513 * This special macro can be used to load a debugging register 489 * This special macro can be used to load a debugging register
514 */ 490 */
515#define loaddebug(thread,r) set_debug(thread->debugreg ## r, r) 491#define loaddebug(thread,r) set_debug(thread->debugreg ## r, r)
@@ -627,8 +603,6 @@ struct task_struct *__switch_to(struct task_struct *prev_p, struct task_struct *
627 } 603 }
628 } 604 }
629 605
630 disable_tsc(prev_p, next_p);
631
632 return prev_p; 606 return prev_p;
633} 607}
634 608
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 9aec524be3eb..351d8d64c2fb 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -336,6 +336,11 @@ static __init void parse_cmdline_early (char ** cmdline_p)
336#endif 336#endif
337#endif 337#endif
338 338
339 if (!memcmp(from, "disable_timer_pin_1", 19))
340 disable_timer_pin_1 = 1;
341 if (!memcmp(from, "enable_timer_pin_1", 18))
342 disable_timer_pin_1 = -1;
343
339 if (!memcmp(from, "nolapic", 7) || 344 if (!memcmp(from, "nolapic", 7) ||
340 !memcmp(from, "disableapic", 11)) 345 !memcmp(from, "disableapic", 11))
341 disable_apic = 1; 346 disable_apic = 1;
@@ -755,6 +760,24 @@ static void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
755 } 760 }
756} 761}
757 762
763#ifdef CONFIG_NUMA
764static int nearby_node(int apicid)
765{
766 int i;
767 for (i = apicid - 1; i >= 0; i--) {
768 int node = apicid_to_node[i];
769 if (node != NUMA_NO_NODE && node_online(node))
770 return node;
771 }
772 for (i = apicid + 1; i < MAX_LOCAL_APIC; i++) {
773 int node = apicid_to_node[i];
774 if (node != NUMA_NO_NODE && node_online(node))
775 return node;
776 }
777 return first_node(node_online_map); /* Shouldn't happen */
778}
779#endif
780
758/* 781/*
759 * On a AMD dual core setup the lower bits of the APIC id distingush the cores. 782 * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
760 * Assumes number of cores is a power of two. 783 * Assumes number of cores is a power of two.
@@ -763,8 +786,11 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
763{ 786{
764#ifdef CONFIG_SMP 787#ifdef CONFIG_SMP
765 int cpu = smp_processor_id(); 788 int cpu = smp_processor_id();
766 int node = 0;
767 unsigned bits; 789 unsigned bits;
790#ifdef CONFIG_NUMA
791 int node = 0;
792 unsigned apicid = phys_proc_id[cpu];
793#endif
768 794
769 bits = 0; 795 bits = 0;
770 while ((1 << bits) < c->x86_num_cores) 796 while ((1 << bits) < c->x86_num_cores)
@@ -776,20 +802,32 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
776 phys_proc_id[cpu] >>= bits; 802 phys_proc_id[cpu] >>= bits;
777 803
778#ifdef CONFIG_NUMA 804#ifdef CONFIG_NUMA
779 /* When an ACPI SRAT table is available use the mappings from SRAT 805 node = phys_proc_id[cpu];
780 instead. */ 806 if (apicid_to_node[apicid] != NUMA_NO_NODE)
781 if (acpi_numa <= 0) { 807 node = apicid_to_node[apicid];
782 node = phys_proc_id[cpu]; 808 if (!node_online(node)) {
783 if (!node_online(node)) 809 /* Two possibilities here:
784 node = first_node(node_online_map); 810 - The CPU is missing memory and no node was created.
785 cpu_to_node[cpu] = node; 811 In that case try picking one from a nearby CPU
786 } else { 812 - The APIC IDs differ from the HyperTransport node IDs
787 node = cpu_to_node[cpu]; 813 which the K8 northbridge parsing fills in.
788 } 814 Assume they are all increased by a constant offset,
815 but in the same order as the HT nodeids.
816 If that doesn't result in a usable node fall back to the
817 path for the previous case. */
818 int ht_nodeid = apicid - (phys_proc_id[0] << bits);
819 if (ht_nodeid >= 0 &&
820 apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
821 node = apicid_to_node[ht_nodeid];
822 /* Pick a nearby node */
823 if (!node_online(node))
824 node = nearby_node(apicid);
825 }
826 cpu_to_node[cpu] = node;
827
828 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
829 cpu, c->x86_num_cores, node, cpu_core_id[cpu]);
789#endif 830#endif
790
791 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
792 cpu, c->x86_num_cores, node, cpu_core_id[cpu]);
793#endif 831#endif
794} 832}
795 833
@@ -909,6 +947,25 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
909 return 1; 947 return 1;
910} 948}
911 949
950static void srat_detect_node(void)
951{
952#ifdef CONFIG_NUMA
953 unsigned apicid, node;
954 int cpu = smp_processor_id();
955
956 /* Don't do the funky fallback heuristics the AMD version employs
957 for now. */
958 apicid = phys_proc_id[cpu];
959 node = apicid_to_node[apicid];
960 if (node == NUMA_NO_NODE)
961 node = 0;
962 cpu_to_node[cpu] = node;
963
964 if (acpi_numa > 0)
965 printk(KERN_INFO "CPU %d -> Node %d\n", cpu, node);
966#endif
967}
968
912static void __cpuinit init_intel(struct cpuinfo_x86 *c) 969static void __cpuinit init_intel(struct cpuinfo_x86 *c)
913{ 970{
914 /* Cache sizes */ 971 /* Cache sizes */
@@ -927,6 +984,8 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
927 if (c->x86 >= 15) 984 if (c->x86 >= 15)
928 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability); 985 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
929 c->x86_num_cores = intel_num_cpu_cores(c); 986 c->x86_num_cores = intel_num_cpu_cores(c);
987
988 srat_detect_node();
930} 989}
931 990
932static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) 991static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
index e3ffcacc8c90..bd33be24a386 100644
--- a/arch/x86_64/kernel/setup64.c
+++ b/arch/x86_64/kernel/setup64.c
@@ -94,7 +94,7 @@ void __init setup_per_cpu_areas(void)
94 size = PERCPU_ENOUGH_ROOM; 94 size = PERCPU_ENOUGH_ROOM;
95#endif 95#endif
96 96
97 for (i = 0; i < NR_CPUS; i++) { 97 for_each_cpu_mask (i, cpu_possible_map) {
98 char *ptr; 98 char *ptr;
99 99
100 if (!NODE_DATA(cpu_to_node(i))) { 100 if (!NODE_DATA(cpu_to_node(i))) {
@@ -119,7 +119,6 @@ void pda_init(int cpu)
119 asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0)); 119 asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
120 wrmsrl(MSR_GS_BASE, cpu_pda + cpu); 120 wrmsrl(MSR_GS_BASE, cpu_pda + cpu);
121 121
122 pda->me = pda;
123 pda->cpunumber = cpu; 122 pda->cpunumber = cpu;
124 pda->irqcount = -1; 123 pda->irqcount = -1;
125 pda->kernelstack = 124 pda->kernelstack =
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index e5958220d6b8..9db9dda161b4 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -12,7 +12,6 @@
12#include <linux/init.h> 12#include <linux/init.h>
13 13
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/irq.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/spinlock.h> 16#include <linux/spinlock.h>
18#include <linux/smp_lock.h> 17#include <linux/smp_lock.h>
@@ -29,6 +28,8 @@
29#include <asm/proto.h> 28#include <asm/proto.h>
30#include <asm/apicdef.h> 29#include <asm/apicdef.h>
31 30
31#define __cpuinit __init
32
32/* 33/*
33 * Smarter SMP flushing macros. 34 * Smarter SMP flushing macros.
34 * c/o Linus Torvalds. 35 * c/o Linus Torvalds.
@@ -37,19 +38,41 @@
37 * writing to user space from interrupts. (Its not allowed anyway). 38 * writing to user space from interrupts. (Its not allowed anyway).
38 * 39 *
39 * Optimizations Manfred Spraul <manfred@colorfullife.com> 40 * Optimizations Manfred Spraul <manfred@colorfullife.com>
41 *
42 * More scalable flush, from Andi Kleen
43 *
44 * To avoid global state use 8 different call vectors.
45 * Each CPU uses a specific vector to trigger flushes on other
46 * CPUs. Depending on the received vector the target CPUs look into
47 * the right per cpu variable for the flush data.
48 *
49 * With more than 8 CPUs they are hashed to the 8 available
50 * vectors. The limited global vector space forces us to this right now.
51 * In future when interrupts are split into per CPU domains this could be
52 * fixed, at the cost of triggering multiple IPIs in some cases.
40 */ 53 */
41 54
42static cpumask_t flush_cpumask; 55union smp_flush_state {
43static struct mm_struct * flush_mm; 56 struct {
44static unsigned long flush_va; 57 cpumask_t flush_cpumask;
45static DEFINE_SPINLOCK(tlbstate_lock); 58 struct mm_struct *flush_mm;
59 unsigned long flush_va;
46#define FLUSH_ALL -1ULL 60#define FLUSH_ALL -1ULL
61 spinlock_t tlbstate_lock;
62 };
63 char pad[SMP_CACHE_BYTES];
64} ____cacheline_aligned;
65
66/* State is put into the per CPU data section, but padded
67 to a full cache line because other CPUs can access it and we don't
68 want false sharing in the per cpu data segment. */
69static DEFINE_PER_CPU(union smp_flush_state, flush_state);
47 70
48/* 71/*
49 * We cannot call mmdrop() because we are in interrupt context, 72 * We cannot call mmdrop() because we are in interrupt context,
50 * instead update mm->cpu_vm_mask. 73 * instead update mm->cpu_vm_mask.
51 */ 74 */
52static inline void leave_mm (unsigned long cpu) 75static inline void leave_mm(int cpu)
53{ 76{
54 if (read_pda(mmu_state) == TLBSTATE_OK) 77 if (read_pda(mmu_state) == TLBSTATE_OK)
55 BUG(); 78 BUG();
@@ -101,15 +124,25 @@ static inline void leave_mm (unsigned long cpu)
101 * 124 *
102 * 1) Flush the tlb entries if the cpu uses the mm that's being flushed. 125 * 1) Flush the tlb entries if the cpu uses the mm that's being flushed.
103 * 2) Leave the mm if we are in the lazy tlb mode. 126 * 2) Leave the mm if we are in the lazy tlb mode.
127 *
128 * Interrupts are disabled.
104 */ 129 */
105 130
106asmlinkage void smp_invalidate_interrupt (void) 131asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs)
107{ 132{
108 unsigned long cpu; 133 int cpu;
134 int sender;
135 union smp_flush_state *f;
109 136
110 cpu = get_cpu(); 137 cpu = smp_processor_id();
138 /*
139 * orig_rax contains the interrupt vector - 256.
140 * Use that to determine where the sender put the data.
141 */
142 sender = regs->orig_rax + 256 - INVALIDATE_TLB_VECTOR_START;
143 f = &per_cpu(flush_state, sender);
111 144
112 if (!cpu_isset(cpu, flush_cpumask)) 145 if (!cpu_isset(cpu, f->flush_cpumask))
113 goto out; 146 goto out;
114 /* 147 /*
115 * This was a BUG() but until someone can quote me the 148 * This was a BUG() but until someone can quote me the
@@ -120,64 +153,63 @@ asmlinkage void smp_invalidate_interrupt (void)
120 * BUG(); 153 * BUG();
121 */ 154 */
122 155
123 if (flush_mm == read_pda(active_mm)) { 156 if (f->flush_mm == read_pda(active_mm)) {
124 if (read_pda(mmu_state) == TLBSTATE_OK) { 157 if (read_pda(mmu_state) == TLBSTATE_OK) {
125 if (flush_va == FLUSH_ALL) 158 if (f->flush_va == FLUSH_ALL)
126 local_flush_tlb(); 159 local_flush_tlb();
127 else 160 else
128 __flush_tlb_one(flush_va); 161 __flush_tlb_one(f->flush_va);
129 } else 162 } else
130 leave_mm(cpu); 163 leave_mm(cpu);
131 } 164 }
132out: 165out:
133 ack_APIC_irq(); 166 ack_APIC_irq();
134 cpu_clear(cpu, flush_cpumask); 167 cpu_clear(cpu, f->flush_cpumask);
135 put_cpu_no_resched();
136} 168}
137 169
138static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm, 170static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
139 unsigned long va) 171 unsigned long va)
140{ 172{
141 cpumask_t tmp; 173 int sender;
142 /* 174 union smp_flush_state *f;
143 * A couple of (to be removed) sanity checks:
144 *
145 * - we do not send IPIs to not-yet booted CPUs.
146 * - current CPU must not be in mask
147 * - mask must exist :)
148 */
149 BUG_ON(cpus_empty(cpumask));
150 cpus_and(tmp, cpumask, cpu_online_map);
151 BUG_ON(!cpus_equal(tmp, cpumask));
152 BUG_ON(cpu_isset(smp_processor_id(), cpumask));
153 if (!mm)
154 BUG();
155 175
156 /* 176 /* Caller has disabled preemption */
157 * I'm not happy about this global shared spinlock in the 177 sender = smp_processor_id() % NUM_INVALIDATE_TLB_VECTORS;
158 * MM hot path, but we'll see how contended it is. 178 f = &per_cpu(flush_state, sender);
159 * Temporarily this turns IRQs off, so that lockups are 179
160 * detected by the NMI watchdog. 180 /* Could avoid this lock when
161 */ 181 num_online_cpus() <= NUM_INVALIDATE_TLB_VECTORS, but it is
162 spin_lock(&tlbstate_lock); 182 probably not worth checking this for a cache-hot lock. */
163 183 spin_lock(&f->tlbstate_lock);
164 flush_mm = mm; 184
165 flush_va = va; 185 f->flush_mm = mm;
166 cpus_or(flush_cpumask, cpumask, flush_cpumask); 186 f->flush_va = va;
187 cpus_or(f->flush_cpumask, cpumask, f->flush_cpumask);
167 188
168 /* 189 /*
169 * We have to send the IPI only to 190 * We have to send the IPI only to
170 * CPUs affected. 191 * CPUs affected.
171 */ 192 */
172 send_IPI_mask(cpumask, INVALIDATE_TLB_VECTOR); 193 send_IPI_mask(cpumask, INVALIDATE_TLB_VECTOR_START + sender);
194
195 while (!cpus_empty(f->flush_cpumask))
196 cpu_relax();
173 197
174 while (!cpus_empty(flush_cpumask)) 198 f->flush_mm = NULL;
175 mb(); /* nothing. lockup detection does not belong here */; 199 f->flush_va = 0;
200 spin_unlock(&f->tlbstate_lock);
201}
176 202
177 flush_mm = NULL; 203int __cpuinit init_smp_flush(void)
178 flush_va = 0; 204{
179 spin_unlock(&tlbstate_lock); 205 int i;
206 for_each_cpu_mask(i, cpu_possible_map) {
207 spin_lock_init(&per_cpu(flush_state.tlbstate_lock, i));
208 }
209 return 0;
180} 210}
211
212core_initcall(init_smp_flush);
181 213
182void flush_tlb_current_task(void) 214void flush_tlb_current_task(void)
183{ 215{
@@ -295,8 +327,11 @@ void unlock_ipi_call_lock(void)
295/* 327/*
296 * this function sends a 'generic call function' IPI to one other CPU 328 * this function sends a 'generic call function' IPI to one other CPU
297 * in the system. 329 * in the system.
330 *
331 * cpu is a standard Linux logical CPU number.
298 */ 332 */
299static void __smp_call_function_single (int cpu, void (*func) (void *info), void *info, 333static void
334__smp_call_function_single(int cpu, void (*func) (void *info), void *info,
300 int nonatomic, int wait) 335 int nonatomic, int wait)
301{ 336{
302 struct call_data_struct data; 337 struct call_data_struct data;
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 4fb34b5cb1f9..e12d7baeb33e 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -44,7 +44,6 @@
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/kernel_stat.h> 45#include <linux/kernel_stat.h>
46#include <linux/smp_lock.h> 46#include <linux/smp_lock.h>
47#include <linux/irq.h>
48#include <linux/bootmem.h> 47#include <linux/bootmem.h>
49#include <linux/thread_info.h> 48#include <linux/thread_info.h>
50#include <linux/module.h> 49#include <linux/module.h>
@@ -58,6 +57,8 @@
58#include <asm/tlbflush.h> 57#include <asm/tlbflush.h>
59#include <asm/proto.h> 58#include <asm/proto.h>
60#include <asm/nmi.h> 59#include <asm/nmi.h>
60#include <asm/irq.h>
61#include <asm/hw_irq.h>
61 62
62/* Number of siblings per CPU package */ 63/* Number of siblings per CPU package */
63int smp_num_siblings = 1; 64int smp_num_siblings = 1;
@@ -413,8 +414,13 @@ void __cpuinit smp_callin(void)
413 414
414 /* 415 /*
415 * Get our bogomips. 416 * Get our bogomips.
417 *
418 * Need to enable IRQs because it can take longer and then
419 * the NMI watchdog might kill us.
416 */ 420 */
421 local_irq_enable();
417 calibrate_delay(); 422 calibrate_delay();
423 local_irq_disable();
418 Dprintk("Stack at about %p\n",&cpuid); 424 Dprintk("Stack at about %p\n",&cpuid);
419 425
420 disable_APIC_timer(); 426 disable_APIC_timer();
@@ -540,8 +546,8 @@ static void inquire_remote_apic(int apicid)
540 */ 546 */
541 apic_wait_icr_idle(); 547 apic_wait_icr_idle();
542 548
543 apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid)); 549 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
544 apic_write_around(APIC_ICR, APIC_DM_REMRD | regs[i]); 550 apic_write(APIC_ICR, APIC_DM_REMRD | regs[i]);
545 551
546 timeout = 0; 552 timeout = 0;
547 do { 553 do {
@@ -574,12 +580,12 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
574 /* 580 /*
575 * Turn INIT on target chip 581 * Turn INIT on target chip
576 */ 582 */
577 apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); 583 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
578 584
579 /* 585 /*
580 * Send IPI 586 * Send IPI
581 */ 587 */
582 apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT 588 apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT
583 | APIC_DM_INIT); 589 | APIC_DM_INIT);
584 590
585 Dprintk("Waiting for send to finish...\n"); 591 Dprintk("Waiting for send to finish...\n");
@@ -595,10 +601,10 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
595 Dprintk("Deasserting INIT.\n"); 601 Dprintk("Deasserting INIT.\n");
596 602
597 /* Target chip */ 603 /* Target chip */
598 apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); 604 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
599 605
600 /* Send IPI */ 606 /* Send IPI */
601 apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT); 607 apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT);
602 608
603 Dprintk("Waiting for send to finish...\n"); 609 Dprintk("Waiting for send to finish...\n");
604 timeout = 0; 610 timeout = 0;
@@ -610,16 +616,7 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
610 616
611 atomic_set(&init_deasserted, 1); 617 atomic_set(&init_deasserted, 1);
612 618
613 /* 619 num_starts = 2;
614 * Should we send STARTUP IPIs ?
615 *
616 * Determine this based on the APIC version.
617 * If we don't have an integrated APIC, don't send the STARTUP IPIs.
618 */
619 if (APIC_INTEGRATED(apic_version[phys_apicid]))
620 num_starts = 2;
621 else
622 num_starts = 0;
623 620
624 /* 621 /*
625 * Run STARTUP IPI loop. 622 * Run STARTUP IPI loop.
@@ -640,12 +637,11 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
640 */ 637 */
641 638
642 /* Target chip */ 639 /* Target chip */
643 apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); 640 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
644 641
645 /* Boot on the stack */ 642 /* Boot on the stack */
646 /* Kick the second */ 643 /* Kick the second */
647 apic_write_around(APIC_ICR, APIC_DM_STARTUP 644 apic_write(APIC_ICR, APIC_DM_STARTUP | (start_rip >> 12));
648 | (start_rip >> 12));
649 645
650 /* 646 /*
651 * Give the other CPU some time to accept the IPI. 647 * Give the other CPU some time to accept the IPI.
@@ -864,17 +860,6 @@ static __cpuinit void smp_cleanup_boot(void)
864 * Reset trampoline flag 860 * Reset trampoline flag
865 */ 861 */
866 *((volatile int *) phys_to_virt(0x467)) = 0; 862 *((volatile int *) phys_to_virt(0x467)) = 0;
867
868#ifndef CONFIG_HOTPLUG_CPU
869 /*
870 * Free pages reserved for SMP bootup.
871 * When you add hotplug CPU support later remove this
872 * Note there is more work to be done for later CPU bootup.
873 */
874
875 free_page((unsigned long) __va(PAGE_SIZE));
876 free_page((unsigned long) __va(SMP_TRAMPOLINE_BASE));
877#endif
878} 863}
879 864
880/* 865/*
diff --git a/arch/x86_64/kernel/suspend.c b/arch/x86_64/kernel/suspend.c
index 0612640d91b1..ebb9abf3ce6d 100644
--- a/arch/x86_64/kernel/suspend.c
+++ b/arch/x86_64/kernel/suspend.c
@@ -8,23 +8,8 @@
8 */ 8 */
9 9
10#include <linux/config.h> 10#include <linux/config.h>
11#include <linux/kernel.h> 11#include <linux/smp.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/types.h>
15#include <linux/spinlock.h>
16#include <linux/poll.h>
17#include <linux/delay.h>
18#include <linux/sysrq.h>
19#include <linux/proc_fs.h>
20#include <linux/irq.h>
21#include <linux/pm.h>
22#include <linux/device.h>
23#include <linux/suspend.h> 12#include <linux/suspend.h>
24#include <asm/uaccess.h>
25#include <asm/acpi.h>
26#include <asm/tlbflush.h>
27#include <asm/io.h>
28#include <asm/proto.h> 13#include <asm/proto.h>
29 14
30struct saved_context saved_context; 15struct saved_context saved_context;
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 7b6abe058253..2373cb8b8625 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -18,7 +18,6 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/mc146818rtc.h> 20#include <linux/mc146818rtc.h>
21#include <linux/irq.h>
22#include <linux/time.h> 21#include <linux/time.h>
23#include <linux/ioport.h> 22#include <linux/ioport.h>
24#include <linux/module.h> 23#include <linux/module.h>
@@ -937,7 +936,6 @@ void __init time_init(void)
937 vxtime.mode = VXTIME_TSC; 936 vxtime.mode = VXTIME_TSC;
938 vxtime.quot = (1000000L << 32) / vxtime_hz; 937 vxtime.quot = (1000000L << 32) / vxtime_hz;
939 vxtime.tsc_quot = (1000L << 32) / cpu_khz; 938 vxtime.tsc_quot = (1000L << 32) / cpu_khz;
940 vxtime.hz = vxtime_hz;
941 rdtscll_sync(&vxtime.last_tsc); 939 rdtscll_sync(&vxtime.last_tsc);
942 setup_irq(0, &irq0); 940 setup_irq(0, &irq0);
943 941
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index f238d6078a5a..b5e09e6b5536 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -47,9 +47,6 @@
47#include <asm/proto.h> 47#include <asm/proto.h>
48#include <asm/nmi.h> 48#include <asm/nmi.h>
49 49
50#include <linux/irq.h>
51
52
53extern struct gate_struct idt_table[256]; 50extern struct gate_struct idt_table[256];
54 51
55asmlinkage void divide_error(void); 52asmlinkage void divide_error(void);
@@ -324,13 +321,13 @@ void handle_BUG(struct pt_regs *regs)
324 if (__copy_from_user(&f, (struct bug_frame *) regs->rip, 321 if (__copy_from_user(&f, (struct bug_frame *) regs->rip,
325 sizeof(struct bug_frame))) 322 sizeof(struct bug_frame)))
326 return; 323 return;
327 if ((unsigned long)f.filename < __PAGE_OFFSET || 324 if (f.filename >= 0 ||
328 f.ud2[0] != 0x0f || f.ud2[1] != 0x0b) 325 f.ud2[0] != 0x0f || f.ud2[1] != 0x0b)
329 return; 326 return;
330 if (__get_user(tmp, f.filename)) 327 if (__get_user(tmp, (char *)(long)f.filename))
331 f.filename = "unmapped filename"; 328 f.filename = (int)(long)"unmapped filename";
332 printk("----------- [cut here ] --------- [please bite here ] ---------\n"); 329 printk("----------- [cut here ] --------- [please bite here ] ---------\n");
333 printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", f.filename, f.line); 330 printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", (char *)(long)f.filename, f.line);
334} 331}
335 332
336#ifdef CONFIG_BUG 333#ifdef CONFIG_BUG
@@ -343,30 +340,33 @@ void out_of_line_bug(void)
343static DEFINE_SPINLOCK(die_lock); 340static DEFINE_SPINLOCK(die_lock);
344static int die_owner = -1; 341static int die_owner = -1;
345 342
346void oops_begin(void) 343unsigned long oops_begin(void)
347{ 344{
348 int cpu = safe_smp_processor_id(); 345 int cpu = safe_smp_processor_id();
349 /* racy, but better than risking deadlock. */ 346 unsigned long flags;
350 local_irq_disable(); 347
348 /* racy, but better than risking deadlock. */
349 local_irq_save(flags);
351 if (!spin_trylock(&die_lock)) { 350 if (!spin_trylock(&die_lock)) {
352 if (cpu == die_owner) 351 if (cpu == die_owner)
353 /* nested oops. should stop eventually */; 352 /* nested oops. should stop eventually */;
354 else 353 else
355 spin_lock(&die_lock); 354 spin_lock(&die_lock);
356 } 355 }
357 die_owner = cpu; 356 die_owner = cpu;
358 console_verbose(); 357 console_verbose();
359 bust_spinlocks(1); 358 bust_spinlocks(1);
359 return flags;
360} 360}
361 361
362void oops_end(void) 362void oops_end(unsigned long flags)
363{ 363{
364 die_owner = -1; 364 die_owner = -1;
365 bust_spinlocks(0); 365 bust_spinlocks(0);
366 spin_unlock(&die_lock); 366 spin_unlock_irqrestore(&die_lock, flags);
367 if (panic_on_oops) 367 if (panic_on_oops)
368 panic("Oops"); 368 panic("Oops");
369} 369}
370 370
371void __die(const char * str, struct pt_regs * regs, long err) 371void __die(const char * str, struct pt_regs * regs, long err)
372{ 372{
@@ -392,10 +392,11 @@ void __die(const char * str, struct pt_regs * regs, long err)
392 392
393void die(const char * str, struct pt_regs * regs, long err) 393void die(const char * str, struct pt_regs * regs, long err)
394{ 394{
395 oops_begin(); 395 unsigned long flags = oops_begin();
396
396 handle_BUG(regs); 397 handle_BUG(regs);
397 __die(str, regs, err); 398 __die(str, regs, err);
398 oops_end(); 399 oops_end(flags);
399 do_exit(SIGSEGV); 400 do_exit(SIGSEGV);
400} 401}
401static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err) 402static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
@@ -406,7 +407,8 @@ static inline void die_if_kernel(const char * str, struct pt_regs * regs, long e
406 407
407void die_nmi(char *str, struct pt_regs *regs) 408void die_nmi(char *str, struct pt_regs *regs)
408{ 409{
409 oops_begin(); 410 unsigned long flags = oops_begin();
411
410 /* 412 /*
411 * We are in trouble anyway, lets at least try 413 * We are in trouble anyway, lets at least try
412 * to get a message out. 414 * to get a message out.
@@ -416,7 +418,7 @@ void die_nmi(char *str, struct pt_regs *regs)
416 if (panic_on_timeout || panic_on_oops) 418 if (panic_on_timeout || panic_on_oops)
417 panic("nmi watchdog"); 419 panic("nmi watchdog");
418 printk("console shuts up ...\n"); 420 printk("console shuts up ...\n");
419 oops_end(); 421 oops_end(flags);
420 do_exit(SIGSEGV); 422 do_exit(SIGSEGV);
421} 423}
422 424
@@ -790,13 +792,16 @@ asmlinkage void do_coprocessor_error(struct pt_regs *regs)
790 */ 792 */
791 cwd = get_fpu_cwd(task); 793 cwd = get_fpu_cwd(task);
792 swd = get_fpu_swd(task); 794 swd = get_fpu_swd(task);
793 switch (((~cwd) & swd & 0x3f) | (swd & 0x240)) { 795 switch (swd & ~cwd & 0x3f) {
794 case 0x000: 796 case 0x000:
795 default: 797 default:
796 break; 798 break;
797 case 0x001: /* Invalid Op */ 799 case 0x001: /* Invalid Op */
798 case 0x041: /* Stack Fault */ 800 /*
799 case 0x241: /* Stack Fault | Direction */ 801 * swd & 0x240 == 0x040: Stack Underflow
802 * swd & 0x240 == 0x240: Stack Overflow
803 * User must clear the SF bit (0x40) if set
804 */
800 info.si_code = FPE_FLTINV; 805 info.si_code = FPE_FLTINV;
801 break; 806 break;
802 case 0x002: /* Denormalize */ 807 case 0x002: /* Denormalize */
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index 2e5734425949..70a0bd16085f 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -107,7 +107,7 @@ static force_inline long time_syscall(long *t)
107 return secs; 107 return secs;
108} 108}
109 109
110static int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz) 110int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
111{ 111{
112 if (unlikely(!__sysctl_vsyscall)) 112 if (unlikely(!__sysctl_vsyscall))
113 return gettimeofday(tv,tz); 113 return gettimeofday(tv,tz);
@@ -120,7 +120,7 @@ static int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz
120 120
121/* This will break when the xtime seconds get inaccurate, but that is 121/* This will break when the xtime seconds get inaccurate, but that is
122 * unlikely */ 122 * unlikely */
123static time_t __vsyscall(1) vtime(time_t *t) 123time_t __vsyscall(1) vtime(time_t *t)
124{ 124{
125 if (unlikely(!__sysctl_vsyscall)) 125 if (unlikely(!__sysctl_vsyscall))
126 return time_syscall(t); 126 return time_syscall(t);
@@ -129,12 +129,12 @@ static time_t __vsyscall(1) vtime(time_t *t)
129 return __xtime.tv_sec; 129 return __xtime.tv_sec;
130} 130}
131 131
132static long __vsyscall(2) venosys_0(void) 132long __vsyscall(2) venosys_0(void)
133{ 133{
134 return -ENOSYS; 134 return -ENOSYS;
135} 135}
136 136
137static long __vsyscall(3) venosys_1(void) 137long __vsyscall(3) venosys_1(void)
138{ 138{
139 return -ENOSYS; 139 return -ENOSYS;
140} 140}
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 816732d8858c..b75b872ec154 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -221,12 +221,13 @@ int unhandled_signal(struct task_struct *tsk, int sig)
221static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs, 221static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
222 unsigned long error_code) 222 unsigned long error_code)
223{ 223{
224 oops_begin(); 224 unsigned long flags = oops_begin();
225
225 printk(KERN_ALERT "%s: Corrupted page table at address %lx\n", 226 printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
226 current->comm, address); 227 current->comm, address);
227 dump_pagetable(address); 228 dump_pagetable(address);
228 __die("Bad pagetable", regs, error_code); 229 __die("Bad pagetable", regs, error_code);
229 oops_end(); 230 oops_end(flags);
230 do_exit(SIGKILL); 231 do_exit(SIGKILL);
231} 232}
232 233
@@ -304,6 +305,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
304 unsigned long address; 305 unsigned long address;
305 const struct exception_table_entry *fixup; 306 const struct exception_table_entry *fixup;
306 int write; 307 int write;
308 unsigned long flags;
307 siginfo_t info; 309 siginfo_t info;
308 310
309#ifdef CONFIG_CHECKING 311#ifdef CONFIG_CHECKING
@@ -521,7 +523,7 @@ no_context:
521 * terminate things with extreme prejudice. 523 * terminate things with extreme prejudice.
522 */ 524 */
523 525
524 oops_begin(); 526 flags = oops_begin();
525 527
526 if (address < PAGE_SIZE) 528 if (address < PAGE_SIZE)
527 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference"); 529 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
@@ -534,7 +536,7 @@ no_context:
534 __die("Oops", regs, error_code); 536 __die("Oops", regs, error_code);
535 /* Executive summary in case the body of the oops scrolled away */ 537 /* Executive summary in case the body of the oops scrolled away */
536 printk(KERN_EMERG "CR2: %016lx\n", address); 538 printk(KERN_EMERG "CR2: %016lx\n", address);
537 oops_end(); 539 oops_end(flags);
538 do_exit(SIGKILL); 540 do_exit(SIGKILL);
539 541
540/* 542/*
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index aa4a5189ecee..e60a1a848de8 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -57,31 +57,31 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
57 57
58void show_mem(void) 58void show_mem(void)
59{ 59{
60 int i, total = 0, reserved = 0; 60 long i, total = 0, reserved = 0;
61 int shared = 0, cached = 0; 61 long shared = 0, cached = 0;
62 pg_data_t *pgdat; 62 pg_data_t *pgdat;
63 struct page *page; 63 struct page *page;
64 64
65 printk("Mem-info:\n"); 65 printk(KERN_INFO "Mem-info:\n");
66 show_free_areas(); 66 show_free_areas();
67 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 67 printk(KERN_INFO "Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
68 68
69 for_each_pgdat(pgdat) { 69 for_each_pgdat(pgdat) {
70 for (i = 0; i < pgdat->node_spanned_pages; ++i) { 70 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
71 page = pfn_to_page(pgdat->node_start_pfn + i); 71 page = pfn_to_page(pgdat->node_start_pfn + i);
72 total++; 72 total++;
73 if (PageReserved(page)) 73 if (PageReserved(page))
74 reserved++; 74 reserved++;
75 else if (PageSwapCache(page)) 75 else if (PageSwapCache(page))
76 cached++; 76 cached++;
77 else if (page_count(page)) 77 else if (page_count(page))
78 shared += page_count(page) - 1; 78 shared += page_count(page) - 1;
79 } 79 }
80 } 80 }
81 printk("%d pages of RAM\n", total); 81 printk(KERN_INFO "%lu pages of RAM\n", total);
82 printk("%d reserved pages\n",reserved); 82 printk(KERN_INFO "%lu reserved pages\n",reserved);
83 printk("%d pages shared\n",shared); 83 printk(KERN_INFO "%lu pages shared\n",shared);
84 printk("%d pages swap cached\n",cached); 84 printk(KERN_INFO "%lu pages swap cached\n",cached);
85} 85}
86 86
87/* References to section boundaries */ 87/* References to section boundaries */
@@ -381,41 +381,14 @@ void __init clear_kernel_mapping(unsigned long address, unsigned long size)
381 __flush_tlb_all(); 381 __flush_tlb_all();
382} 382}
383 383
384static inline int page_is_ram (unsigned long pagenr)
385{
386 int i;
387
388 for (i = 0; i < e820.nr_map; i++) {
389 unsigned long addr, end;
390
391 if (e820.map[i].type != E820_RAM) /* not usable memory */
392 continue;
393 /*
394 * !!!FIXME!!! Some BIOSen report areas as RAM that
395 * are not. Notably the 640->1Mb area. We need a sanity
396 * check here.
397 */
398 addr = (e820.map[i].addr+PAGE_SIZE-1) >> PAGE_SHIFT;
399 end = (e820.map[i].addr+e820.map[i].size) >> PAGE_SHIFT;
400 if ((pagenr >= addr) && (pagenr < end))
401 return 1;
402 }
403 return 0;
404}
405
406extern int swiotlb_force;
407
408static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules, 384static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
409 kcore_vsyscall; 385 kcore_vsyscall;
410 386
411void __init mem_init(void) 387void __init mem_init(void)
412{ 388{
413 int codesize, reservedpages, datasize, initsize; 389 long codesize, reservedpages, datasize, initsize;
414 int tmp;
415 390
416#ifdef CONFIG_SWIOTLB 391#ifdef CONFIG_SWIOTLB
417 if (swiotlb_force)
418 swiotlb = 1;
419 if (!iommu_aperture && 392 if (!iommu_aperture &&
420 (end_pfn >= 0xffffffff>>PAGE_SHIFT || force_iommu)) 393 (end_pfn >= 0xffffffff>>PAGE_SHIFT || force_iommu))
421 swiotlb = 1; 394 swiotlb = 1;
@@ -436,25 +409,11 @@ void __init mem_init(void)
436 409
437 /* this will put all low memory onto the freelists */ 410 /* this will put all low memory onto the freelists */
438#ifdef CONFIG_NUMA 411#ifdef CONFIG_NUMA
439 totalram_pages += numa_free_all_bootmem(); 412 totalram_pages = numa_free_all_bootmem();
440 tmp = 0;
441 /* should count reserved pages here for all nodes */
442#else 413#else
443 414 totalram_pages = free_all_bootmem();
444#ifdef CONFIG_FLATMEM
445 max_mapnr = end_pfn;
446 if (!mem_map) BUG();
447#endif
448
449 totalram_pages += free_all_bootmem();
450
451 for (tmp = 0; tmp < end_pfn; tmp++)
452 /*
453 * Only count reserved RAM pages
454 */
455 if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
456 reservedpages++;
457#endif 415#endif
416 reservedpages = end_pfn - totalram_pages - e820_hole_size(0, end_pfn);
458 417
459 after_bootmem = 1; 418 after_bootmem = 1;
460 419
@@ -471,7 +430,7 @@ void __init mem_init(void)
471 kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START, 430 kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
472 VSYSCALL_END - VSYSCALL_START); 431 VSYSCALL_END - VSYSCALL_START);
473 432
474 printk("Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, %dk init)\n", 433 printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, %ldk data, %ldk init)\n",
475 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), 434 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
476 end_pfn << (PAGE_SHIFT-10), 435 end_pfn << (PAGE_SHIFT-10),
477 codesize >> 10, 436 codesize >> 10,
diff --git a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
index ec35747aacd7..65417b040c1b 100644
--- a/arch/x86_64/mm/k8topology.c
+++ b/arch/x86_64/mm/k8topology.c
@@ -45,10 +45,12 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
45 unsigned long prevbase; 45 unsigned long prevbase;
46 struct node nodes[8]; 46 struct node nodes[8];
47 int nodeid, i, nb; 47 int nodeid, i, nb;
48 unsigned char nodeids[8];
48 int found = 0; 49 int found = 0;
49 u32 reg; 50 u32 reg;
50 unsigned numnodes; 51 unsigned numnodes;
51 nodemask_t nodes_parsed; 52 nodemask_t nodes_parsed;
53 unsigned dualcore = 0;
52 54
53 nodes_clear(nodes_parsed); 55 nodes_clear(nodes_parsed);
54 56
@@ -67,11 +69,15 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
67 prevbase = 0; 69 prevbase = 0;
68 for (i = 0; i < 8; i++) { 70 for (i = 0; i < 8; i++) {
69 unsigned long base,limit; 71 unsigned long base,limit;
70 72 u32 nodeid;
73
74 /* Undefined before E stepping, but hopefully 0 */
75 dualcore |= ((read_pci_config(0, nb, 3, 0xe8) >> 12) & 3) == 1;
71 base = read_pci_config(0, nb, 1, 0x40 + i*8); 76 base = read_pci_config(0, nb, 1, 0x40 + i*8);
72 limit = read_pci_config(0, nb, 1, 0x44 + i*8); 77 limit = read_pci_config(0, nb, 1, 0x44 + i*8);
73 78
74 nodeid = limit & 7; 79 nodeid = limit & 7;
80 nodeids[i] = nodeid;
75 if ((base & 3) == 0) { 81 if ((base & 3) == 0) {
76 if (i < numnodes) 82 if (i < numnodes)
77 printk("Skipping disabled node %d\n", i); 83 printk("Skipping disabled node %d\n", i);
@@ -157,8 +163,9 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
157 163
158 for (i = 0; i < 8; i++) { 164 for (i = 0; i < 8; i++) {
159 if (nodes[i].start != nodes[i].end) { 165 if (nodes[i].start != nodes[i].end) {
160 /* assume 1:1 NODE:CPU */ 166 nodeid = nodeids[i];
161 cpu_to_node[i] = i; 167 apicid_to_node[nodeid << dualcore] = i;
168 apicid_to_node[(nodeid << dualcore) + dualcore] = i;
162 setup_node_bootmem(i, nodes[i].start, nodes[i].end); 169 setup_node_bootmem(i, nodes[i].start, nodes[i].end);
163 } 170 }
164 } 171 }
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 04f7a33e144c..80a49d9bd8a7 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -28,8 +28,13 @@ bootmem_data_t plat_node_bdata[MAX_NUMNODES];
28int memnode_shift; 28int memnode_shift;
29u8 memnodemap[NODEMAPSIZE]; 29u8 memnodemap[NODEMAPSIZE];
30 30
31unsigned char cpu_to_node[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = NUMA_NO_NODE }; 31unsigned char cpu_to_node[NR_CPUS] __read_mostly = {
32cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly; 32 [0 ... NR_CPUS-1] = NUMA_NO_NODE
33};
34unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
35 [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
36};
37cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly;
33 38
34int numa_off __initdata; 39int numa_off __initdata;
35 40
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 8e3d097a9ddd..4b2e844c15a7 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -20,14 +20,20 @@
20 20
21static struct acpi_table_slit *acpi_slit; 21static struct acpi_table_slit *acpi_slit;
22 22
23/* Internal processor count */
24static unsigned int __initdata num_processors = 0;
25
26static nodemask_t nodes_parsed __initdata; 23static nodemask_t nodes_parsed __initdata;
27static nodemask_t nodes_found __initdata; 24static nodemask_t nodes_found __initdata;
28static struct node nodes[MAX_NUMNODES] __initdata; 25static struct node nodes[MAX_NUMNODES] __initdata;
29static __u8 pxm2node[256] = { [0 ... 255] = 0xff }; 26static __u8 pxm2node[256] = { [0 ... 255] = 0xff };
30 27
28static int node_to_pxm(int n);
29
30int pxm_to_node(int pxm)
31{
32 if ((unsigned)pxm >= 256)
33 return 0;
34 return pxm2node[pxm];
35}
36
31static __init int setup_node(int pxm) 37static __init int setup_node(int pxm)
32{ 38{
33 unsigned node = pxm2node[pxm]; 39 unsigned node = pxm2node[pxm];
@@ -44,14 +50,14 @@ static __init int setup_node(int pxm)
44static __init int conflicting_nodes(unsigned long start, unsigned long end) 50static __init int conflicting_nodes(unsigned long start, unsigned long end)
45{ 51{
46 int i; 52 int i;
47 for_each_online_node(i) { 53 for_each_node_mask(i, nodes_parsed) {
48 struct node *nd = &nodes[i]; 54 struct node *nd = &nodes[i];
49 if (nd->start == nd->end) 55 if (nd->start == nd->end)
50 continue; 56 continue;
51 if (nd->end > start && nd->start < end) 57 if (nd->end > start && nd->start < end)
52 return 1; 58 return i;
53 if (nd->end == end && nd->start == start) 59 if (nd->end == end && nd->start == start)
54 return 1; 60 return i;
55 } 61 }
56 return -1; 62 return -1;
57} 63}
@@ -75,8 +81,11 @@ static __init void cutoff_node(int i, unsigned long start, unsigned long end)
75 81
76static __init void bad_srat(void) 82static __init void bad_srat(void)
77{ 83{
84 int i;
78 printk(KERN_ERR "SRAT: SRAT not used.\n"); 85 printk(KERN_ERR "SRAT: SRAT not used.\n");
79 acpi_numa = -1; 86 acpi_numa = -1;
87 for (i = 0; i < MAX_LOCAL_APIC; i++)
88 apicid_to_node[i] = NUMA_NO_NODE;
80} 89}
81 90
82static __init inline int srat_disabled(void) 91static __init inline int srat_disabled(void)
@@ -104,18 +113,10 @@ acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
104 bad_srat(); 113 bad_srat();
105 return; 114 return;
106 } 115 }
107 if (num_processors >= NR_CPUS) { 116 apicid_to_node[pa->apic_id] = node;
108 printk(KERN_ERR "SRAT: Processor #%d (lapic %u) INVALID. (Max ID: %d).\n",
109 num_processors, pa->apic_id, NR_CPUS);
110 bad_srat();
111 return;
112 }
113 cpu_to_node[num_processors] = node;
114 acpi_numa = 1; 117 acpi_numa = 1;
115 printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> CPU %u -> Node %u\n", 118 printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> Node %u\n",
116 pxm, pa->apic_id, num_processors, node); 119 pxm, pa->apic_id, node);
117
118 num_processors++;
119} 120}
120 121
121/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */ 122/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
@@ -143,10 +144,15 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
143 printk(KERN_INFO "SRAT: hot plug zone found %lx - %lx \n", 144 printk(KERN_INFO "SRAT: hot plug zone found %lx - %lx \n",
144 start, end); 145 start, end);
145 i = conflicting_nodes(start, end); 146 i = conflicting_nodes(start, end);
146 if (i >= 0) { 147 if (i == node) {
148 printk(KERN_WARNING
149 "SRAT: Warning: PXM %d (%lx-%lx) overlaps with itself (%Lx-%Lx)\n",
150 pxm, start, end, nodes[i].start, nodes[i].end);
151 } else if (i >= 0) {
147 printk(KERN_ERR 152 printk(KERN_ERR
148 "SRAT: pxm %d overlap %lx-%lx with node %d(%Lx-%Lx)\n", 153 "SRAT: PXM %d (%lx-%lx) overlaps with PXM %d (%Lx-%Lx)\n",
149 pxm, start, end, i, nodes[i].start, nodes[i].end); 154 pxm, start, end, node_to_pxm(i),
155 nodes[i].start, nodes[i].end);
150 bad_srat(); 156 bad_srat();
151 return; 157 return;
152 } 158 }
@@ -174,6 +180,14 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
174 int i; 180 int i;
175 if (acpi_numa <= 0) 181 if (acpi_numa <= 0)
176 return -1; 182 return -1;
183
184 /* First clean up the node list */
185 for_each_node_mask(i, nodes_parsed) {
186 cutoff_node(i, start, end);
187 if (nodes[i].start == nodes[i].end)
188 node_clear(i, nodes_parsed);
189 }
190
177 memnode_shift = compute_hash_shift(nodes, nodes_weight(nodes_parsed)); 191 memnode_shift = compute_hash_shift(nodes, nodes_weight(nodes_parsed));
178 if (memnode_shift < 0) { 192 if (memnode_shift < 0) {
179 printk(KERN_ERR 193 printk(KERN_ERR
@@ -181,16 +195,10 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
181 bad_srat(); 195 bad_srat();
182 return -1; 196 return -1;
183 } 197 }
184 for (i = 0; i < MAX_NUMNODES; i++) { 198
185 if (!node_isset(i, nodes_parsed)) 199 /* Finally register nodes */
186 continue; 200 for_each_node_mask(i, nodes_parsed)
187 cutoff_node(i, start, end);
188 if (nodes[i].start == nodes[i].end) {
189 node_clear(i, nodes_parsed);
190 continue;
191 }
192 setup_node_bootmem(i, nodes[i].start, nodes[i].end); 201 setup_node_bootmem(i, nodes[i].start, nodes[i].end);
193 }
194 for (i = 0; i < NR_CPUS; i++) { 202 for (i = 0; i < NR_CPUS; i++) {
195 if (cpu_to_node[i] == NUMA_NO_NODE) 203 if (cpu_to_node[i] == NUMA_NO_NODE)
196 continue; 204 continue;
@@ -201,7 +209,7 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
201 return 0; 209 return 0;
202} 210}
203 211
204int node_to_pxm(int n) 212static int node_to_pxm(int n)
205{ 213{
206 int i; 214 int i;
207 if (pxm2node[n] == n) 215 if (pxm2node[n] == n)
diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c
index d80c323669e0..3acf60ded2a0 100644
--- a/arch/x86_64/pci/k8-bus.c
+++ b/arch/x86_64/pci/k8-bus.c
@@ -58,10 +58,16 @@ fill_mp_bus_to_cpumask(void)
58 for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus); 58 for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus);
59 j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus); 59 j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
60 j++) { 60 j++) {
61 int node = NODE_ID(nid); 61 struct pci_bus *bus;
62 long node = NODE_ID(nid);
63 /* Algorithm a bit dumb, but
64 it shouldn't matter here */
65 bus = pci_find_bus(0, j);
66 if (!bus)
67 continue;
62 if (!node_online(node)) 68 if (!node_online(node))
63 node = 0; 69 node = 0;
64 pci_bus_to_node[j] = node; 70 bus->sysdata = (void *)node;
65 } 71 }
66 } 72 }
67 } 73 }
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index 657e88aa0902..a0838c4a94e4 100644
--- a/arch/x86_64/pci/mmconfig.c
+++ b/arch/x86_64/pci/mmconfig.c
@@ -111,13 +111,6 @@ static int __init pci_mmcfg_init(void)
111 (pci_mmcfg_config[0].base_address == 0)) 111 (pci_mmcfg_config[0].base_address == 0))
112 return 0; 112 return 0;
113 113
114 /* Kludge for now. Don't use mmconfig on AMD systems because
115 those have some busses where mmconfig doesn't work,
116 and we don't parse ACPI MCFG well enough to handle that.
117 Remove when proper handling is added. */
118 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
119 return 0;
120
121 /* RED-PEN i386 doesn't do _nocache right now */ 114 /* RED-PEN i386 doesn't do _nocache right now */
122 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); 115 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
123 if (pci_mmcfg_virt == NULL) { 116 if (pci_mmcfg_virt == NULL) {