diff options
Diffstat (limited to 'arch/x86')
144 files changed, 2661 insertions, 3177 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 73f7fe8fd4d1..d6218e6c9824 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -133,7 +133,7 @@ config ARCH_HAS_CACHE_LINE_SIZE | |||
133 | def_bool y | 133 | def_bool y |
134 | 134 | ||
135 | config HAVE_SETUP_PER_CPU_AREA | 135 | config HAVE_SETUP_PER_CPU_AREA |
136 | def_bool X86_64_SMP || (X86_SMP && !X86_VOYAGER) | 136 | def_bool y |
137 | 137 | ||
138 | config HAVE_CPUMASK_OF_CPU_MAP | 138 | config HAVE_CPUMASK_OF_CPU_MAP |
139 | def_bool X86_64_SMP | 139 | def_bool X86_64_SMP |
@@ -391,6 +391,13 @@ config X86_RDC321X | |||
391 | as R-8610-(G). | 391 | as R-8610-(G). |
392 | If you don't have one of these chips, you should say N here. | 392 | If you don't have one of these chips, you should say N here. |
393 | 393 | ||
394 | config X86_UV | ||
395 | bool "SGI Ultraviolet" | ||
396 | depends on X86_64 | ||
397 | help | ||
398 | This option is needed in order to support SGI Ultraviolet systems. | ||
399 | If you don't have one of these, you should say N here. | ||
400 | |||
394 | config SCHED_OMIT_FRAME_POINTER | 401 | config SCHED_OMIT_FRAME_POINTER |
395 | def_bool y | 402 | def_bool y |
396 | prompt "Single-depth WCHAN output" | 403 | prompt "Single-depth WCHAN output" |
@@ -1340,13 +1347,17 @@ config SECCOMP | |||
1340 | 1347 | ||
1341 | If unsure, say Y. Only embedded should say N here. | 1348 | If unsure, say Y. Only embedded should say N here. |
1342 | 1349 | ||
1350 | config CC_STACKPROTECTOR_ALL | ||
1351 | bool | ||
1352 | |||
1343 | config CC_STACKPROTECTOR | 1353 | config CC_STACKPROTECTOR |
1344 | bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)" | 1354 | bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)" |
1345 | depends on X86_64 && EXPERIMENTAL && BROKEN | 1355 | depends on X86_64 |
1356 | select CC_STACKPROTECTOR_ALL | ||
1346 | help | 1357 | help |
1347 | This option turns on the -fstack-protector GCC feature. This | 1358 | This option turns on the -fstack-protector GCC feature. This |
1348 | feature puts, at the beginning of critical functions, a canary | 1359 | feature puts, at the beginning of functions, a canary value on |
1349 | value on the stack just before the return address, and validates | 1360 | the stack just before the return address, and validates |
1350 | the value just before actually returning. Stack based buffer | 1361 | the value just before actually returning. Stack based buffer |
1351 | overflows (that need to overwrite this return address) now also | 1362 | overflows (that need to overwrite this return address) now also |
1352 | overwrite the canary, which gets detected and the attack is then | 1363 | overwrite the canary, which gets detected and the attack is then |
@@ -1354,15 +1365,8 @@ config CC_STACKPROTECTOR | |||
1354 | 1365 | ||
1355 | This feature requires gcc version 4.2 or above, or a distribution | 1366 | This feature requires gcc version 4.2 or above, or a distribution |
1356 | gcc with the feature backported. Older versions are automatically | 1367 | gcc with the feature backported. Older versions are automatically |
1357 | detected and for those versions, this configuration option is ignored. | 1368 | detected and for those versions, this configuration option is |
1358 | 1369 | ignored. (and a warning is printed during bootup) | |
1359 | config CC_STACKPROTECTOR_ALL | ||
1360 | bool "Use stack-protector for all functions" | ||
1361 | depends on CC_STACKPROTECTOR | ||
1362 | help | ||
1363 | Normally, GCC only inserts the canary value protection for | ||
1364 | functions that use large-ish on-stack buffers. By enabling | ||
1365 | this option, GCC will be asked to do this for ALL functions. | ||
1366 | 1370 | ||
1367 | source kernel/Kconfig.hz | 1371 | source kernel/Kconfig.hz |
1368 | 1372 | ||
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu index 8078955845ae..8eb50ba9161e 100644 --- a/arch/x86/Kconfig.cpu +++ b/arch/x86/Kconfig.cpu | |||
@@ -292,25 +292,23 @@ config X86_CPU | |||
292 | # Define implied options from the CPU selection here | 292 | # Define implied options from the CPU selection here |
293 | config X86_L1_CACHE_BYTES | 293 | config X86_L1_CACHE_BYTES |
294 | int | 294 | int |
295 | default "128" if GENERIC_CPU || MPSC | 295 | default "128" if MPSC |
296 | default "64" if MK8 || MCORE2 | 296 | default "64" if GENERIC_CPU || MK8 || MCORE2 || X86_32 |
297 | depends on X86_64 | ||
298 | 297 | ||
299 | config X86_INTERNODE_CACHE_BYTES | 298 | config X86_INTERNODE_CACHE_BYTES |
300 | int | 299 | int |
301 | default "4096" if X86_VSMP | 300 | default "4096" if X86_VSMP |
302 | default X86_L1_CACHE_BYTES if !X86_VSMP | 301 | default X86_L1_CACHE_BYTES if !X86_VSMP |
303 | depends on X86_64 | ||
304 | 302 | ||
305 | config X86_CMPXCHG | 303 | config X86_CMPXCHG |
306 | def_bool X86_64 || (X86_32 && !M386) | 304 | def_bool X86_64 || (X86_32 && !M386) |
307 | 305 | ||
308 | config X86_L1_CACHE_SHIFT | 306 | config X86_L1_CACHE_SHIFT |
309 | int | 307 | int |
310 | default "7" if MPENTIUM4 || X86_GENERIC || GENERIC_CPU || MPSC | 308 | default "7" if MPENTIUM4 || MPSC |
311 | default "4" if X86_ELAN || M486 || M386 || MGEODEGX1 | 309 | default "4" if X86_ELAN || M486 || M386 || MGEODEGX1 |
312 | default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX | 310 | default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX |
313 | default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MVIAC7 | 311 | default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MVIAC7 || X86_GENERIC || GENERIC_CPU |
314 | 312 | ||
315 | config X86_XADD | 313 | config X86_XADD |
316 | def_bool y | 314 | def_bool y |
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 10d6cc3fd052..28f111461ca8 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug | |||
@@ -117,6 +117,7 @@ config DEBUG_RODATA | |||
117 | config DEBUG_RODATA_TEST | 117 | config DEBUG_RODATA_TEST |
118 | bool "Testcase for the DEBUG_RODATA feature" | 118 | bool "Testcase for the DEBUG_RODATA feature" |
119 | depends on DEBUG_RODATA | 119 | depends on DEBUG_RODATA |
120 | default y | ||
120 | help | 121 | help |
121 | This option enables a testcase for the DEBUG_RODATA | 122 | This option enables a testcase for the DEBUG_RODATA |
122 | feature as well as for the change_page_attr() infrastructure. | 123 | feature as well as for the change_page_attr() infrastructure. |
diff --git a/arch/x86/Makefile b/arch/x86/Makefile index d1a47adb5aec..cacee981d166 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile | |||
@@ -73,7 +73,7 @@ else | |||
73 | 73 | ||
74 | stackp := $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh | 74 | stackp := $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh |
75 | stackp-$(CONFIG_CC_STACKPROTECTOR) := $(shell $(stackp) \ | 75 | stackp-$(CONFIG_CC_STACKPROTECTOR) := $(shell $(stackp) \ |
76 | "$(CC)" -fstack-protector ) | 76 | "$(CC)" "-fstack-protector -DGCC_HAS_SP" ) |
77 | stackp-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(stackp) \ | 77 | stackp-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(stackp) \ |
78 | "$(CC)" -fstack-protector-all ) | 78 | "$(CC)" -fstack-protector-all ) |
79 | 79 | ||
diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c index 75115849af33..4a58c8ce3f69 100644 --- a/arch/x86/boot/video-vesa.c +++ b/arch/x86/boot/video-vesa.c | |||
@@ -269,9 +269,8 @@ void vesa_store_edid(void) | |||
269 | we genuinely have to assume all registers are destroyed here. */ | 269 | we genuinely have to assume all registers are destroyed here. */ |
270 | 270 | ||
271 | asm("pushw %%es; movw %2,%%es; "INT10"; popw %%es" | 271 | asm("pushw %%es; movw %2,%%es; "INT10"; popw %%es" |
272 | : "+a" (ax), "+b" (bx) | 272 | : "+a" (ax), "+b" (bx), "+c" (cx), "+D" (di) |
273 | : "c" (cx), "D" (di) | 273 | : : "esi", "edx"); |
274 | : "esi"); | ||
275 | 274 | ||
276 | if (ax != 0x004f) | 275 | if (ax != 0x004f) |
277 | return; /* No EDID */ | 276 | return; /* No EDID */ |
@@ -285,9 +284,9 @@ void vesa_store_edid(void) | |||
285 | dx = 0; /* EDID block number */ | 284 | dx = 0; /* EDID block number */ |
286 | di =(size_t) &boot_params.edid_info; /* (ES:)Pointer to block */ | 285 | di =(size_t) &boot_params.edid_info; /* (ES:)Pointer to block */ |
287 | asm(INT10 | 286 | asm(INT10 |
288 | : "+a" (ax), "+b" (bx), "+d" (dx), "=m" (boot_params.edid_info) | 287 | : "+a" (ax), "+b" (bx), "+d" (dx), "=m" (boot_params.edid_info), |
289 | : "c" (cx), "D" (di) | 288 | "+c" (cx), "+D" (di) |
290 | : "esi"); | 289 | : : "esi"); |
291 | #endif /* CONFIG_FIRMWARE_EDID */ | 290 | #endif /* CONFIG_FIRMWARE_EDID */ |
292 | } | 291 | } |
293 | 292 | ||
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig index b30a08ed8eb4..edba00d98ac3 100644 --- a/arch/x86/configs/i386_defconfig +++ b/arch/x86/configs/i386_defconfig | |||
@@ -1331,8 +1331,8 @@ CONFIG_I2C_I801=y | |||
1331 | # Miscellaneous I2C Chip support | 1331 | # Miscellaneous I2C Chip support |
1332 | # | 1332 | # |
1333 | # CONFIG_DS1682 is not set | 1333 | # CONFIG_DS1682 is not set |
1334 | # CONFIG_AT24 is not set | 1334 | # CONFIG_EEPROM_AT24 is not set |
1335 | # CONFIG_SENSORS_EEPROM is not set | 1335 | # CONFIG_EEPROM_LEGACY is not set |
1336 | # CONFIG_SENSORS_PCF8574 is not set | 1336 | # CONFIG_SENSORS_PCF8574 is not set |
1337 | # CONFIG_PCF8575 is not set | 1337 | # CONFIG_PCF8575 is not set |
1338 | # CONFIG_SENSORS_PCA9539 is not set | 1338 | # CONFIG_SENSORS_PCA9539 is not set |
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig index 0e7dbc0a3e46..322dd2748fc9 100644 --- a/arch/x86/configs/x86_64_defconfig +++ b/arch/x86/configs/x86_64_defconfig | |||
@@ -1311,8 +1311,8 @@ CONFIG_I2C_I801=y | |||
1311 | # Miscellaneous I2C Chip support | 1311 | # Miscellaneous I2C Chip support |
1312 | # | 1312 | # |
1313 | # CONFIG_DS1682 is not set | 1313 | # CONFIG_DS1682 is not set |
1314 | # CONFIG_AT24 is not set | 1314 | # CONFIG_EEPROM_AT24 is not set |
1315 | # CONFIG_SENSORS_EEPROM is not set | 1315 | # CONFIG_EEPROM_LEGACY is not set |
1316 | # CONFIG_SENSORS_PCF8574 is not set | 1316 | # CONFIG_SENSORS_PCF8574 is not set |
1317 | # CONFIG_PCF8575 is not set | 1317 | # CONFIG_PCF8575 is not set |
1318 | # CONFIG_SENSORS_PCA9539 is not set | 1318 | # CONFIG_SENSORS_PCA9539 is not set |
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index 9dabd00e9805..dd77ac0cac46 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c | |||
@@ -46,78 +46,83 @@ void signal_fault(struct pt_regs *regs, void __user *frame, char *where); | |||
46 | 46 | ||
47 | int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) | 47 | int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) |
48 | { | 48 | { |
49 | int err; | 49 | int err = 0; |
50 | 50 | ||
51 | if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t))) | 51 | if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t))) |
52 | return -EFAULT; | 52 | return -EFAULT; |
53 | 53 | ||
54 | /* If you change siginfo_t structure, please make sure that | 54 | put_user_try { |
55 | this code is fixed accordingly. | 55 | /* If you change siginfo_t structure, please make sure that |
56 | It should never copy any pad contained in the structure | 56 | this code is fixed accordingly. |
57 | to avoid security leaks, but must copy the generic | 57 | It should never copy any pad contained in the structure |
58 | 3 ints plus the relevant union member. */ | 58 | to avoid security leaks, but must copy the generic |
59 | err = __put_user(from->si_signo, &to->si_signo); | 59 | 3 ints plus the relevant union member. */ |
60 | err |= __put_user(from->si_errno, &to->si_errno); | 60 | put_user_ex(from->si_signo, &to->si_signo); |
61 | err |= __put_user((short)from->si_code, &to->si_code); | 61 | put_user_ex(from->si_errno, &to->si_errno); |
62 | 62 | put_user_ex((short)from->si_code, &to->si_code); | |
63 | if (from->si_code < 0) { | 63 | |
64 | err |= __put_user(from->si_pid, &to->si_pid); | 64 | if (from->si_code < 0) { |
65 | err |= __put_user(from->si_uid, &to->si_uid); | 65 | put_user_ex(from->si_pid, &to->si_pid); |
66 | err |= __put_user(ptr_to_compat(from->si_ptr), &to->si_ptr); | 66 | put_user_ex(from->si_uid, &to->si_uid); |
67 | } else { | 67 | put_user_ex(ptr_to_compat(from->si_ptr), &to->si_ptr); |
68 | /* | 68 | } else { |
69 | * First 32bits of unions are always present: | 69 | /* |
70 | * si_pid === si_band === si_tid === si_addr(LS half) | 70 | * First 32bits of unions are always present: |
71 | */ | 71 | * si_pid === si_band === si_tid === si_addr(LS half) |
72 | err |= __put_user(from->_sifields._pad[0], | 72 | */ |
73 | &to->_sifields._pad[0]); | 73 | put_user_ex(from->_sifields._pad[0], |
74 | switch (from->si_code >> 16) { | 74 | &to->_sifields._pad[0]); |
75 | case __SI_FAULT >> 16: | 75 | switch (from->si_code >> 16) { |
76 | break; | 76 | case __SI_FAULT >> 16: |
77 | case __SI_CHLD >> 16: | 77 | break; |
78 | err |= __put_user(from->si_utime, &to->si_utime); | 78 | case __SI_CHLD >> 16: |
79 | err |= __put_user(from->si_stime, &to->si_stime); | 79 | put_user_ex(from->si_utime, &to->si_utime); |
80 | err |= __put_user(from->si_status, &to->si_status); | 80 | put_user_ex(from->si_stime, &to->si_stime); |
81 | /* FALL THROUGH */ | 81 | put_user_ex(from->si_status, &to->si_status); |
82 | default: | 82 | /* FALL THROUGH */ |
83 | case __SI_KILL >> 16: | 83 | default: |
84 | err |= __put_user(from->si_uid, &to->si_uid); | 84 | case __SI_KILL >> 16: |
85 | break; | 85 | put_user_ex(from->si_uid, &to->si_uid); |
86 | case __SI_POLL >> 16: | 86 | break; |
87 | err |= __put_user(from->si_fd, &to->si_fd); | 87 | case __SI_POLL >> 16: |
88 | break; | 88 | put_user_ex(from->si_fd, &to->si_fd); |
89 | case __SI_TIMER >> 16: | 89 | break; |
90 | err |= __put_user(from->si_overrun, &to->si_overrun); | 90 | case __SI_TIMER >> 16: |
91 | err |= __put_user(ptr_to_compat(from->si_ptr), | 91 | put_user_ex(from->si_overrun, &to->si_overrun); |
92 | &to->si_ptr); | 92 | put_user_ex(ptr_to_compat(from->si_ptr), |
93 | break; | 93 | &to->si_ptr); |
94 | /* This is not generated by the kernel as of now. */ | 94 | break; |
95 | case __SI_RT >> 16: | 95 | /* This is not generated by the kernel as of now. */ |
96 | case __SI_MESGQ >> 16: | 96 | case __SI_RT >> 16: |
97 | err |= __put_user(from->si_uid, &to->si_uid); | 97 | case __SI_MESGQ >> 16: |
98 | err |= __put_user(from->si_int, &to->si_int); | 98 | put_user_ex(from->si_uid, &to->si_uid); |
99 | break; | 99 | put_user_ex(from->si_int, &to->si_int); |
100 | break; | ||
101 | } | ||
100 | } | 102 | } |
101 | } | 103 | } put_user_catch(err); |
104 | |||
102 | return err; | 105 | return err; |
103 | } | 106 | } |
104 | 107 | ||
105 | int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) | 108 | int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) |
106 | { | 109 | { |
107 | int err; | 110 | int err = 0; |
108 | u32 ptr32; | 111 | u32 ptr32; |
109 | 112 | ||
110 | if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t))) | 113 | if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t))) |
111 | return -EFAULT; | 114 | return -EFAULT; |
112 | 115 | ||
113 | err = __get_user(to->si_signo, &from->si_signo); | 116 | get_user_try { |
114 | err |= __get_user(to->si_errno, &from->si_errno); | 117 | get_user_ex(to->si_signo, &from->si_signo); |
115 | err |= __get_user(to->si_code, &from->si_code); | 118 | get_user_ex(to->si_errno, &from->si_errno); |
119 | get_user_ex(to->si_code, &from->si_code); | ||
116 | 120 | ||
117 | err |= __get_user(to->si_pid, &from->si_pid); | 121 | get_user_ex(to->si_pid, &from->si_pid); |
118 | err |= __get_user(to->si_uid, &from->si_uid); | 122 | get_user_ex(to->si_uid, &from->si_uid); |
119 | err |= __get_user(ptr32, &from->si_ptr); | 123 | get_user_ex(ptr32, &from->si_ptr); |
120 | to->si_ptr = compat_ptr(ptr32); | 124 | to->si_ptr = compat_ptr(ptr32); |
125 | } get_user_catch(err); | ||
121 | 126 | ||
122 | return err; | 127 | return err; |
123 | } | 128 | } |
@@ -142,17 +147,23 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr, | |||
142 | struct pt_regs *regs) | 147 | struct pt_regs *regs) |
143 | { | 148 | { |
144 | stack_t uss, uoss; | 149 | stack_t uss, uoss; |
145 | int ret; | 150 | int ret, err = 0; |
146 | mm_segment_t seg; | 151 | mm_segment_t seg; |
147 | 152 | ||
148 | if (uss_ptr) { | 153 | if (uss_ptr) { |
149 | u32 ptr; | 154 | u32 ptr; |
150 | 155 | ||
151 | memset(&uss, 0, sizeof(stack_t)); | 156 | memset(&uss, 0, sizeof(stack_t)); |
152 | if (!access_ok(VERIFY_READ, uss_ptr, sizeof(stack_ia32_t)) || | 157 | if (!access_ok(VERIFY_READ, uss_ptr, sizeof(stack_ia32_t))) |
153 | __get_user(ptr, &uss_ptr->ss_sp) || | 158 | return -EFAULT; |
154 | __get_user(uss.ss_flags, &uss_ptr->ss_flags) || | 159 | |
155 | __get_user(uss.ss_size, &uss_ptr->ss_size)) | 160 | get_user_try { |
161 | get_user_ex(ptr, &uss_ptr->ss_sp); | ||
162 | get_user_ex(uss.ss_flags, &uss_ptr->ss_flags); | ||
163 | get_user_ex(uss.ss_size, &uss_ptr->ss_size); | ||
164 | } get_user_catch(err); | ||
165 | |||
166 | if (err) | ||
156 | return -EFAULT; | 167 | return -EFAULT; |
157 | uss.ss_sp = compat_ptr(ptr); | 168 | uss.ss_sp = compat_ptr(ptr); |
158 | } | 169 | } |
@@ -161,10 +172,16 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr, | |||
161 | ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss, regs->sp); | 172 | ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss, regs->sp); |
162 | set_fs(seg); | 173 | set_fs(seg); |
163 | if (ret >= 0 && uoss_ptr) { | 174 | if (ret >= 0 && uoss_ptr) { |
164 | if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_ia32_t)) || | 175 | if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_ia32_t))) |
165 | __put_user(ptr_to_compat(uoss.ss_sp), &uoss_ptr->ss_sp) || | 176 | return -EFAULT; |
166 | __put_user(uoss.ss_flags, &uoss_ptr->ss_flags) || | 177 | |
167 | __put_user(uoss.ss_size, &uoss_ptr->ss_size)) | 178 | put_user_try { |
179 | put_user_ex(ptr_to_compat(uoss.ss_sp), &uoss_ptr->ss_sp); | ||
180 | put_user_ex(uoss.ss_flags, &uoss_ptr->ss_flags); | ||
181 | put_user_ex(uoss.ss_size, &uoss_ptr->ss_size); | ||
182 | } put_user_catch(err); | ||
183 | |||
184 | if (err) | ||
168 | ret = -EFAULT; | 185 | ret = -EFAULT; |
169 | } | 186 | } |
170 | return ret; | 187 | return ret; |
@@ -174,18 +191,18 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr, | |||
174 | * Do a signal return; undo the signal stack. | 191 | * Do a signal return; undo the signal stack. |
175 | */ | 192 | */ |
176 | #define COPY(x) { \ | 193 | #define COPY(x) { \ |
177 | err |= __get_user(regs->x, &sc->x); \ | 194 | get_user_ex(regs->x, &sc->x); \ |
178 | } | 195 | } |
179 | 196 | ||
180 | #define COPY_SEG_CPL3(seg) { \ | 197 | #define COPY_SEG_CPL3(seg) { \ |
181 | unsigned short tmp; \ | 198 | unsigned short tmp; \ |
182 | err |= __get_user(tmp, &sc->seg); \ | 199 | get_user_ex(tmp, &sc->seg); \ |
183 | regs->seg = tmp | 3; \ | 200 | regs->seg = tmp | 3; \ |
184 | } | 201 | } |
185 | 202 | ||
186 | #define RELOAD_SEG(seg) { \ | 203 | #define RELOAD_SEG(seg) { \ |
187 | unsigned int cur, pre; \ | 204 | unsigned int cur, pre; \ |
188 | err |= __get_user(pre, &sc->seg); \ | 205 | get_user_ex(pre, &sc->seg); \ |
189 | savesegment(seg, cur); \ | 206 | savesegment(seg, cur); \ |
190 | pre |= 3; \ | 207 | pre |= 3; \ |
191 | if (pre != cur) \ | 208 | if (pre != cur) \ |
@@ -209,39 +226,42 @@ static int ia32_restore_sigcontext(struct pt_regs *regs, | |||
209 | sc, sc->err, sc->ip, sc->cs, sc->flags); | 226 | sc, sc->err, sc->ip, sc->cs, sc->flags); |
210 | #endif | 227 | #endif |
211 | 228 | ||
212 | /* | 229 | get_user_try { |
213 | * Reload fs and gs if they have changed in the signal | 230 | /* |
214 | * handler. This does not handle long fs/gs base changes in | 231 | * Reload fs and gs if they have changed in the signal |
215 | * the handler, but does not clobber them at least in the | 232 | * handler. This does not handle long fs/gs base changes in |
216 | * normal case. | 233 | * the handler, but does not clobber them at least in the |
217 | */ | 234 | * normal case. |
218 | err |= __get_user(gs, &sc->gs); | 235 | */ |
219 | gs |= 3; | 236 | get_user_ex(gs, &sc->gs); |
220 | savesegment(gs, oldgs); | 237 | gs |= 3; |
221 | if (gs != oldgs) | 238 | savesegment(gs, oldgs); |
222 | load_gs_index(gs); | 239 | if (gs != oldgs) |
223 | 240 | load_gs_index(gs); | |
224 | RELOAD_SEG(fs); | 241 | |
225 | RELOAD_SEG(ds); | 242 | RELOAD_SEG(fs); |
226 | RELOAD_SEG(es); | 243 | RELOAD_SEG(ds); |
227 | 244 | RELOAD_SEG(es); | |
228 | COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); | 245 | |
229 | COPY(dx); COPY(cx); COPY(ip); | 246 | COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); |
230 | /* Don't touch extended registers */ | 247 | COPY(dx); COPY(cx); COPY(ip); |
231 | 248 | /* Don't touch extended registers */ | |
232 | COPY_SEG_CPL3(cs); | 249 | |
233 | COPY_SEG_CPL3(ss); | 250 | COPY_SEG_CPL3(cs); |
234 | 251 | COPY_SEG_CPL3(ss); | |
235 | err |= __get_user(tmpflags, &sc->flags); | 252 | |
236 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); | 253 | get_user_ex(tmpflags, &sc->flags); |
237 | /* disable syscall checks */ | 254 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); |
238 | regs->orig_ax = -1; | 255 | /* disable syscall checks */ |
239 | 256 | regs->orig_ax = -1; | |
240 | err |= __get_user(tmp, &sc->fpstate); | 257 | |
241 | buf = compat_ptr(tmp); | 258 | get_user_ex(tmp, &sc->fpstate); |
242 | err |= restore_i387_xstate_ia32(buf); | 259 | buf = compat_ptr(tmp); |
243 | 260 | err |= restore_i387_xstate_ia32(buf); | |
244 | err |= __get_user(*pax, &sc->ax); | 261 | |
262 | get_user_ex(*pax, &sc->ax); | ||
263 | } get_user_catch(err); | ||
264 | |||
245 | return err; | 265 | return err; |
246 | } | 266 | } |
247 | 267 | ||
@@ -319,36 +339,38 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, | |||
319 | { | 339 | { |
320 | int tmp, err = 0; | 340 | int tmp, err = 0; |
321 | 341 | ||
322 | savesegment(gs, tmp); | 342 | put_user_try { |
323 | err |= __put_user(tmp, (unsigned int __user *)&sc->gs); | 343 | savesegment(gs, tmp); |
324 | savesegment(fs, tmp); | 344 | put_user_ex(tmp, (unsigned int __user *)&sc->gs); |
325 | err |= __put_user(tmp, (unsigned int __user *)&sc->fs); | 345 | savesegment(fs, tmp); |
326 | savesegment(ds, tmp); | 346 | put_user_ex(tmp, (unsigned int __user *)&sc->fs); |
327 | err |= __put_user(tmp, (unsigned int __user *)&sc->ds); | 347 | savesegment(ds, tmp); |
328 | savesegment(es, tmp); | 348 | put_user_ex(tmp, (unsigned int __user *)&sc->ds); |
329 | err |= __put_user(tmp, (unsigned int __user *)&sc->es); | 349 | savesegment(es, tmp); |
330 | 350 | put_user_ex(tmp, (unsigned int __user *)&sc->es); | |
331 | err |= __put_user(regs->di, &sc->di); | 351 | |
332 | err |= __put_user(regs->si, &sc->si); | 352 | put_user_ex(regs->di, &sc->di); |
333 | err |= __put_user(regs->bp, &sc->bp); | 353 | put_user_ex(regs->si, &sc->si); |
334 | err |= __put_user(regs->sp, &sc->sp); | 354 | put_user_ex(regs->bp, &sc->bp); |
335 | err |= __put_user(regs->bx, &sc->bx); | 355 | put_user_ex(regs->sp, &sc->sp); |
336 | err |= __put_user(regs->dx, &sc->dx); | 356 | put_user_ex(regs->bx, &sc->bx); |
337 | err |= __put_user(regs->cx, &sc->cx); | 357 | put_user_ex(regs->dx, &sc->dx); |
338 | err |= __put_user(regs->ax, &sc->ax); | 358 | put_user_ex(regs->cx, &sc->cx); |
339 | err |= __put_user(current->thread.trap_no, &sc->trapno); | 359 | put_user_ex(regs->ax, &sc->ax); |
340 | err |= __put_user(current->thread.error_code, &sc->err); | 360 | put_user_ex(current->thread.trap_no, &sc->trapno); |
341 | err |= __put_user(regs->ip, &sc->ip); | 361 | put_user_ex(current->thread.error_code, &sc->err); |
342 | err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs); | 362 | put_user_ex(regs->ip, &sc->ip); |
343 | err |= __put_user(regs->flags, &sc->flags); | 363 | put_user_ex(regs->cs, (unsigned int __user *)&sc->cs); |
344 | err |= __put_user(regs->sp, &sc->sp_at_signal); | 364 | put_user_ex(regs->flags, &sc->flags); |
345 | err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss); | 365 | put_user_ex(regs->sp, &sc->sp_at_signal); |
346 | 366 | put_user_ex(regs->ss, (unsigned int __user *)&sc->ss); | |
347 | err |= __put_user(ptr_to_compat(fpstate), &sc->fpstate); | 367 | |
348 | 368 | put_user_ex(ptr_to_compat(fpstate), &sc->fpstate); | |
349 | /* non-iBCS2 extensions.. */ | 369 | |
350 | err |= __put_user(mask, &sc->oldmask); | 370 | /* non-iBCS2 extensions.. */ |
351 | err |= __put_user(current->thread.cr2, &sc->cr2); | 371 | put_user_ex(mask, &sc->oldmask); |
372 | put_user_ex(current->thread.cr2, &sc->cr2); | ||
373 | } put_user_catch(err); | ||
352 | 374 | ||
353 | return err; | 375 | return err; |
354 | } | 376 | } |
@@ -437,13 +459,17 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka, | |||
437 | else | 459 | else |
438 | restorer = &frame->retcode; | 460 | restorer = &frame->retcode; |
439 | } | 461 | } |
440 | err |= __put_user(ptr_to_compat(restorer), &frame->pretcode); | ||
441 | 462 | ||
442 | /* | 463 | put_user_try { |
443 | * These are actually not used anymore, but left because some | 464 | put_user_ex(ptr_to_compat(restorer), &frame->pretcode); |
444 | * gdb versions depend on them as a marker. | 465 | |
445 | */ | 466 | /* |
446 | err |= __put_user(*((u64 *)&code), (u64 *)frame->retcode); | 467 | * These are actually not used anymore, but left because some |
468 | * gdb versions depend on them as a marker. | ||
469 | */ | ||
470 | put_user_ex(*((u64 *)&code), (u64 *)frame->retcode); | ||
471 | } put_user_catch(err); | ||
472 | |||
447 | if (err) | 473 | if (err) |
448 | return -EFAULT; | 474 | return -EFAULT; |
449 | 475 | ||
@@ -496,41 +522,40 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
496 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 522 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
497 | return -EFAULT; | 523 | return -EFAULT; |
498 | 524 | ||
499 | err |= __put_user(sig, &frame->sig); | 525 | put_user_try { |
500 | err |= __put_user(ptr_to_compat(&frame->info), &frame->pinfo); | 526 | put_user_ex(sig, &frame->sig); |
501 | err |= __put_user(ptr_to_compat(&frame->uc), &frame->puc); | 527 | put_user_ex(ptr_to_compat(&frame->info), &frame->pinfo); |
502 | err |= copy_siginfo_to_user32(&frame->info, info); | 528 | put_user_ex(ptr_to_compat(&frame->uc), &frame->puc); |
503 | if (err) | 529 | err |= copy_siginfo_to_user32(&frame->info, info); |
504 | return -EFAULT; | ||
505 | 530 | ||
506 | /* Create the ucontext. */ | 531 | /* Create the ucontext. */ |
507 | if (cpu_has_xsave) | 532 | if (cpu_has_xsave) |
508 | err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags); | 533 | put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags); |
509 | else | 534 | else |
510 | err |= __put_user(0, &frame->uc.uc_flags); | 535 | put_user_ex(0, &frame->uc.uc_flags); |
511 | err |= __put_user(0, &frame->uc.uc_link); | 536 | put_user_ex(0, &frame->uc.uc_link); |
512 | err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); | 537 | put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); |
513 | err |= __put_user(sas_ss_flags(regs->sp), | 538 | put_user_ex(sas_ss_flags(regs->sp), |
514 | &frame->uc.uc_stack.ss_flags); | 539 | &frame->uc.uc_stack.ss_flags); |
515 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); | 540 | put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size); |
516 | err |= ia32_setup_sigcontext(&frame->uc.uc_mcontext, fpstate, | 541 | err |= ia32_setup_sigcontext(&frame->uc.uc_mcontext, fpstate, |
517 | regs, set->sig[0]); | 542 | regs, set->sig[0]); |
518 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 543 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
519 | if (err) | 544 | |
520 | return -EFAULT; | 545 | if (ka->sa.sa_flags & SA_RESTORER) |
546 | restorer = ka->sa.sa_restorer; | ||
547 | else | ||
548 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, | ||
549 | rt_sigreturn); | ||
550 | put_user_ex(ptr_to_compat(restorer), &frame->pretcode); | ||
551 | |||
552 | /* | ||
553 | * Not actually used anymore, but left because some gdb | ||
554 | * versions need it. | ||
555 | */ | ||
556 | put_user_ex(*((u64 *)&code), (u64 *)frame->retcode); | ||
557 | } put_user_catch(err); | ||
521 | 558 | ||
522 | if (ka->sa.sa_flags & SA_RESTORER) | ||
523 | restorer = ka->sa.sa_restorer; | ||
524 | else | ||
525 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, | ||
526 | rt_sigreturn); | ||
527 | err |= __put_user(ptr_to_compat(restorer), &frame->pretcode); | ||
528 | |||
529 | /* | ||
530 | * Not actually used anymore, but left because some gdb | ||
531 | * versions need it. | ||
532 | */ | ||
533 | err |= __put_user(*((u64 *)&code), (u64 *)frame->retcode); | ||
534 | if (err) | 559 | if (err) |
535 | return -EFAULT; | 560 | return -EFAULT; |
536 | 561 | ||
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S index 256b00b61892..9c79b2477008 100644 --- a/arch/x86/ia32/ia32entry.S +++ b/arch/x86/ia32/ia32entry.S | |||
@@ -112,8 +112,8 @@ ENTRY(ia32_sysenter_target) | |||
112 | CFI_DEF_CFA rsp,0 | 112 | CFI_DEF_CFA rsp,0 |
113 | CFI_REGISTER rsp,rbp | 113 | CFI_REGISTER rsp,rbp |
114 | SWAPGS_UNSAFE_STACK | 114 | SWAPGS_UNSAFE_STACK |
115 | movq %gs:pda_kernelstack, %rsp | 115 | movq PER_CPU_VAR(kernel_stack), %rsp |
116 | addq $(PDA_STACKOFFSET),%rsp | 116 | addq $(KERNEL_STACK_OFFSET),%rsp |
117 | /* | 117 | /* |
118 | * No need to follow this irqs on/off section: the syscall | 118 | * No need to follow this irqs on/off section: the syscall |
119 | * disabled irqs, here we enable it straight after entry: | 119 | * disabled irqs, here we enable it straight after entry: |
@@ -273,13 +273,13 @@ ENDPROC(ia32_sysenter_target) | |||
273 | ENTRY(ia32_cstar_target) | 273 | ENTRY(ia32_cstar_target) |
274 | CFI_STARTPROC32 simple | 274 | CFI_STARTPROC32 simple |
275 | CFI_SIGNAL_FRAME | 275 | CFI_SIGNAL_FRAME |
276 | CFI_DEF_CFA rsp,PDA_STACKOFFSET | 276 | CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET |
277 | CFI_REGISTER rip,rcx | 277 | CFI_REGISTER rip,rcx |
278 | /*CFI_REGISTER rflags,r11*/ | 278 | /*CFI_REGISTER rflags,r11*/ |
279 | SWAPGS_UNSAFE_STACK | 279 | SWAPGS_UNSAFE_STACK |
280 | movl %esp,%r8d | 280 | movl %esp,%r8d |
281 | CFI_REGISTER rsp,r8 | 281 | CFI_REGISTER rsp,r8 |
282 | movq %gs:pda_kernelstack,%rsp | 282 | movq PER_CPU_VAR(kernel_stack),%rsp |
283 | /* | 283 | /* |
284 | * No need to follow this irqs on/off section: the syscall | 284 | * No need to follow this irqs on/off section: the syscall |
285 | * disabled irqs and here we enable it straight after entry: | 285 | * disabled irqs and here we enable it straight after entry: |
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index a9f8a814a1f7..4a8e80cdcfa5 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild | |||
@@ -22,4 +22,3 @@ unifdef-y += unistd_32.h | |||
22 | unifdef-y += unistd_64.h | 22 | unifdef-y += unistd_64.h |
23 | unifdef-y += vm86.h | 23 | unifdef-y += vm86.h |
24 | unifdef-y += vsyscall.h | 24 | unifdef-y += vsyscall.h |
25 | unifdef-y += swab.h | ||
diff --git a/arch/x86/include/asm/apicnum.h b/arch/x86/include/asm/apicnum.h new file mode 100644 index 000000000000..82f613c607ce --- /dev/null +++ b/arch/x86/include/asm/apicnum.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _ASM_X86_APICNUM_H | ||
2 | #define _ASM_X86_APICNUM_H | ||
3 | |||
4 | /* define MAX_IO_APICS */ | ||
5 | #ifdef CONFIG_X86_32 | ||
6 | # define MAX_IO_APICS 64 | ||
7 | #else | ||
8 | # define MAX_IO_APICS 128 | ||
9 | # define MAX_LOCAL_APIC 32768 | ||
10 | #endif | ||
11 | |||
12 | #endif /* _ASM_X86_APICNUM_H */ | ||
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index e02a359d2aa5..02b47a603fc8 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h | |||
@@ -3,6 +3,9 @@ | |||
3 | 3 | ||
4 | /* | 4 | /* |
5 | * Copyright 1992, Linus Torvalds. | 5 | * Copyright 1992, Linus Torvalds. |
6 | * | ||
7 | * Note: inlines with more than a single statement should be marked | ||
8 | * __always_inline to avoid problems with older gcc's inlining heuristics. | ||
6 | */ | 9 | */ |
7 | 10 | ||
8 | #ifndef _LINUX_BITOPS_H | 11 | #ifndef _LINUX_BITOPS_H |
@@ -53,7 +56,8 @@ | |||
53 | * Note that @nr may be almost arbitrarily large; this function is not | 56 | * Note that @nr may be almost arbitrarily large; this function is not |
54 | * restricted to acting on a single-word quantity. | 57 | * restricted to acting on a single-word quantity. |
55 | */ | 58 | */ |
56 | static inline void set_bit(unsigned int nr, volatile unsigned long *addr) | 59 | static __always_inline void |
60 | set_bit(unsigned int nr, volatile unsigned long *addr) | ||
57 | { | 61 | { |
58 | if (IS_IMMEDIATE(nr)) { | 62 | if (IS_IMMEDIATE(nr)) { |
59 | asm volatile(LOCK_PREFIX "orb %1,%0" | 63 | asm volatile(LOCK_PREFIX "orb %1,%0" |
@@ -90,7 +94,8 @@ static inline void __set_bit(int nr, volatile unsigned long *addr) | |||
90 | * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() | 94 | * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() |
91 | * in order to ensure changes are visible on other processors. | 95 | * in order to ensure changes are visible on other processors. |
92 | */ | 96 | */ |
93 | static inline void clear_bit(int nr, volatile unsigned long *addr) | 97 | static __always_inline void |
98 | clear_bit(int nr, volatile unsigned long *addr) | ||
94 | { | 99 | { |
95 | if (IS_IMMEDIATE(nr)) { | 100 | if (IS_IMMEDIATE(nr)) { |
96 | asm volatile(LOCK_PREFIX "andb %1,%0" | 101 | asm volatile(LOCK_PREFIX "andb %1,%0" |
@@ -204,7 +209,8 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr) | |||
204 | * | 209 | * |
205 | * This is the same as test_and_set_bit on x86. | 210 | * This is the same as test_and_set_bit on x86. |
206 | */ | 211 | */ |
207 | static inline int test_and_set_bit_lock(int nr, volatile unsigned long *addr) | 212 | static __always_inline int |
213 | test_and_set_bit_lock(int nr, volatile unsigned long *addr) | ||
208 | { | 214 | { |
209 | return test_and_set_bit(nr, addr); | 215 | return test_and_set_bit(nr, addr); |
210 | } | 216 | } |
@@ -300,7 +306,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr) | |||
300 | return oldbit; | 306 | return oldbit; |
301 | } | 307 | } |
302 | 308 | ||
303 | static inline int constant_test_bit(unsigned int nr, const volatile unsigned long *addr) | 309 | static __always_inline int constant_test_bit(unsigned int nr, const volatile unsigned long *addr) |
304 | { | 310 | { |
305 | return ((1UL << (nr % BITS_PER_LONG)) & | 311 | return ((1UL << (nr % BITS_PER_LONG)) & |
306 | (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0; | 312 | (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0; |
diff --git a/arch/x86/include/asm/byteorder.h b/arch/x86/include/asm/byteorder.h index 7c49917e3d9d..b13a7a88f3eb 100644 --- a/arch/x86/include/asm/byteorder.h +++ b/arch/x86/include/asm/byteorder.h | |||
@@ -1,7 +1,6 @@ | |||
1 | #ifndef _ASM_X86_BYTEORDER_H | 1 | #ifndef _ASM_X86_BYTEORDER_H |
2 | #define _ASM_X86_BYTEORDER_H | 2 | #define _ASM_X86_BYTEORDER_H |
3 | 3 | ||
4 | #include <asm/swab.h> | ||
5 | #include <linux/byteorder/little_endian.h> | 4 | #include <linux/byteorder/little_endian.h> |
6 | 5 | ||
7 | #endif /* _ASM_X86_BYTEORDER_H */ | 6 | #endif /* _ASM_X86_BYTEORDER_H */ |
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index bae482df6039..f03b23e32864 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h | |||
@@ -7,6 +7,20 @@ | |||
7 | #include <linux/nodemask.h> | 7 | #include <linux/nodemask.h> |
8 | #include <linux/percpu.h> | 8 | #include <linux/percpu.h> |
9 | 9 | ||
10 | #ifdef CONFIG_SMP | ||
11 | |||
12 | extern void prefill_possible_map(void); | ||
13 | |||
14 | #else /* CONFIG_SMP */ | ||
15 | |||
16 | static inline void prefill_possible_map(void) {} | ||
17 | |||
18 | #define cpu_physical_id(cpu) boot_cpu_physical_apicid | ||
19 | #define safe_smp_processor_id() 0 | ||
20 | #define stack_smp_processor_id() 0 | ||
21 | |||
22 | #endif /* CONFIG_SMP */ | ||
23 | |||
10 | struct x86_cpu { | 24 | struct x86_cpu { |
11 | struct cpu cpu; | 25 | struct cpu cpu; |
12 | }; | 26 | }; |
@@ -17,4 +31,11 @@ extern void arch_unregister_cpu(int); | |||
17 | #endif | 31 | #endif |
18 | 32 | ||
19 | DECLARE_PER_CPU(int, cpu_state); | 33 | DECLARE_PER_CPU(int, cpu_state); |
34 | |||
35 | #ifdef CONFIG_X86_HAS_BOOT_CPU_ID | ||
36 | extern unsigned char boot_cpu_id; | ||
37 | #else | ||
38 | #define boot_cpu_id 0 | ||
39 | #endif | ||
40 | |||
20 | #endif /* _ASM_X86_CPU_H */ | 41 | #endif /* _ASM_X86_CPU_H */ |
diff --git a/arch/x86/include/asm/cpumask.h b/arch/x86/include/asm/cpumask.h new file mode 100644 index 000000000000..a7f3c75f8ad7 --- /dev/null +++ b/arch/x86/include/asm/cpumask.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef _ASM_X86_CPUMASK_H | ||
2 | #define _ASM_X86_CPUMASK_H | ||
3 | #ifndef __ASSEMBLY__ | ||
4 | #include <linux/cpumask.h> | ||
5 | |||
6 | #ifdef CONFIG_X86_64 | ||
7 | |||
8 | extern cpumask_var_t cpu_callin_mask; | ||
9 | extern cpumask_var_t cpu_callout_mask; | ||
10 | extern cpumask_var_t cpu_initialized_mask; | ||
11 | extern cpumask_var_t cpu_sibling_setup_mask; | ||
12 | |||
13 | extern void setup_cpu_local_masks(void); | ||
14 | |||
15 | #else /* CONFIG_X86_32 */ | ||
16 | |||
17 | extern cpumask_t cpu_callin_map; | ||
18 | extern cpumask_t cpu_callout_map; | ||
19 | extern cpumask_t cpu_initialized; | ||
20 | extern cpumask_t cpu_sibling_setup_map; | ||
21 | |||
22 | #define cpu_callin_mask ((struct cpumask *)&cpu_callin_map) | ||
23 | #define cpu_callout_mask ((struct cpumask *)&cpu_callout_map) | ||
24 | #define cpu_initialized_mask ((struct cpumask *)&cpu_initialized) | ||
25 | #define cpu_sibling_setup_mask ((struct cpumask *)&cpu_sibling_setup_map) | ||
26 | |||
27 | static inline void setup_cpu_local_masks(void) { } | ||
28 | |||
29 | #endif /* CONFIG_X86_32 */ | ||
30 | |||
31 | #endif /* __ASSEMBLY__ */ | ||
32 | #endif /* _ASM_X86_CPUMASK_H */ | ||
diff --git a/arch/x86/include/asm/current.h b/arch/x86/include/asm/current.h index 0930b4f8d672..c68c361697e1 100644 --- a/arch/x86/include/asm/current.h +++ b/arch/x86/include/asm/current.h | |||
@@ -1,39 +1,21 @@ | |||
1 | #ifndef _ASM_X86_CURRENT_H | 1 | #ifndef _ASM_X86_CURRENT_H |
2 | #define _ASM_X86_CURRENT_H | 2 | #define _ASM_X86_CURRENT_H |
3 | 3 | ||
4 | #ifdef CONFIG_X86_32 | ||
5 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
6 | #include <asm/percpu.h> | 5 | #include <asm/percpu.h> |
7 | 6 | ||
7 | #ifndef __ASSEMBLY__ | ||
8 | struct task_struct; | 8 | struct task_struct; |
9 | 9 | ||
10 | DECLARE_PER_CPU(struct task_struct *, current_task); | 10 | DECLARE_PER_CPU(struct task_struct *, current_task); |
11 | static __always_inline struct task_struct *get_current(void) | ||
12 | { | ||
13 | return x86_read_percpu(current_task); | ||
14 | } | ||
15 | |||
16 | #else /* X86_32 */ | ||
17 | |||
18 | #ifndef __ASSEMBLY__ | ||
19 | #include <asm/pda.h> | ||
20 | |||
21 | struct task_struct; | ||
22 | 11 | ||
23 | static __always_inline struct task_struct *get_current(void) | 12 | static __always_inline struct task_struct *get_current(void) |
24 | { | 13 | { |
25 | return read_pda(pcurrent); | 14 | return percpu_read(current_task); |
26 | } | 15 | } |
27 | 16 | ||
28 | #else /* __ASSEMBLY__ */ | 17 | #define current get_current() |
29 | |||
30 | #include <asm/asm-offsets.h> | ||
31 | #define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg | ||
32 | 18 | ||
33 | #endif /* __ASSEMBLY__ */ | 19 | #endif /* __ASSEMBLY__ */ |
34 | 20 | ||
35 | #endif /* X86_32 */ | ||
36 | |||
37 | #define current get_current() | ||
38 | |||
39 | #endif /* _ASM_X86_CURRENT_H */ | 21 | #endif /* _ASM_X86_CURRENT_H */ |
diff --git a/arch/x86/include/asm/genapic_32.h b/arch/x86/include/asm/genapic_32.h index 2c05b737ee22..4334502d3664 100644 --- a/arch/x86/include/asm/genapic_32.h +++ b/arch/x86/include/asm/genapic_32.h | |||
@@ -138,11 +138,4 @@ struct genapic { | |||
138 | extern struct genapic *genapic; | 138 | extern struct genapic *genapic; |
139 | extern void es7000_update_genapic_to_cluster(void); | 139 | extern void es7000_update_genapic_to_cluster(void); |
140 | 140 | ||
141 | enum uv_system_type {UV_NONE, UV_LEGACY_APIC, UV_X2APIC, UV_NON_UNIQUE_APIC}; | ||
142 | #define get_uv_system_type() UV_NONE | ||
143 | #define is_uv_system() 0 | ||
144 | #define uv_wakeup_secondary(a, b) 1 | ||
145 | #define uv_system_init() do {} while (0) | ||
146 | |||
147 | |||
148 | #endif /* _ASM_X86_GENAPIC_32_H */ | 141 | #endif /* _ASM_X86_GENAPIC_32_H */ |
diff --git a/arch/x86/include/asm/genapic_64.h b/arch/x86/include/asm/genapic_64.h index adf32fb56aa6..7bb092c59055 100644 --- a/arch/x86/include/asm/genapic_64.h +++ b/arch/x86/include/asm/genapic_64.h | |||
@@ -51,15 +51,9 @@ extern struct genapic apic_x2apic_phys; | |||
51 | extern int acpi_madt_oem_check(char *, char *); | 51 | extern int acpi_madt_oem_check(char *, char *); |
52 | 52 | ||
53 | extern void apic_send_IPI_self(int vector); | 53 | extern void apic_send_IPI_self(int vector); |
54 | enum uv_system_type {UV_NONE, UV_LEGACY_APIC, UV_X2APIC, UV_NON_UNIQUE_APIC}; | ||
55 | extern enum uv_system_type get_uv_system_type(void); | ||
56 | extern int is_uv_system(void); | ||
57 | 54 | ||
58 | extern struct genapic apic_x2apic_uv_x; | 55 | extern struct genapic apic_x2apic_uv_x; |
59 | DECLARE_PER_CPU(int, x2apic_extra_bits); | 56 | DECLARE_PER_CPU(int, x2apic_extra_bits); |
60 | extern void uv_cpu_init(void); | ||
61 | extern void uv_system_init(void); | ||
62 | extern int uv_wakeup_secondary(int phys_apicid, unsigned int start_rip); | ||
63 | 57 | ||
64 | extern void setup_apic_routing(void); | 58 | extern void setup_apic_routing(void); |
65 | 59 | ||
diff --git a/arch/x86/include/asm/hardirq.h b/arch/x86/include/asm/hardirq.h index 000787df66e6..176f058e7159 100644 --- a/arch/x86/include/asm/hardirq.h +++ b/arch/x86/include/asm/hardirq.h | |||
@@ -1,11 +1,52 @@ | |||
1 | #ifdef CONFIG_X86_32 | 1 | #ifndef _ASM_X86_HARDIRQ_H |
2 | # include "hardirq_32.h" | 2 | #define _ASM_X86_HARDIRQ_H |
3 | #else | 3 | |
4 | # include "hardirq_64.h" | 4 | #include <linux/threads.h> |
5 | #include <linux/irq.h> | ||
6 | |||
7 | typedef struct { | ||
8 | unsigned int __softirq_pending; | ||
9 | unsigned int __nmi_count; /* arch dependent */ | ||
10 | unsigned int irq0_irqs; | ||
11 | #ifdef CONFIG_X86_LOCAL_APIC | ||
12 | unsigned int apic_timer_irqs; /* arch dependent */ | ||
13 | unsigned int irq_spurious_count; | ||
14 | #endif | ||
15 | #ifdef CONFIG_SMP | ||
16 | unsigned int irq_resched_count; | ||
17 | unsigned int irq_call_count; | ||
18 | unsigned int irq_tlb_count; | ||
19 | #endif | ||
20 | #ifdef CONFIG_X86_MCE | ||
21 | unsigned int irq_thermal_count; | ||
22 | # ifdef CONFIG_X86_64 | ||
23 | unsigned int irq_threshold_count; | ||
24 | # endif | ||
5 | #endif | 25 | #endif |
26 | } ____cacheline_aligned irq_cpustat_t; | ||
27 | |||
28 | DECLARE_PER_CPU(irq_cpustat_t, irq_stat); | ||
29 | |||
30 | /* We can have at most NR_VECTORS irqs routed to a cpu at a time */ | ||
31 | #define MAX_HARDIRQS_PER_CPU NR_VECTORS | ||
32 | |||
33 | #define __ARCH_IRQ_STAT | ||
34 | |||
35 | #define inc_irq_stat(member) percpu_add(irq_stat.member, 1) | ||
36 | |||
37 | #define local_softirq_pending() percpu_read(irq_stat.__softirq_pending) | ||
38 | |||
39 | #define __ARCH_SET_SOFTIRQ_PENDING | ||
40 | |||
41 | #define set_softirq_pending(x) percpu_write(irq_stat.__softirq_pending, (x)) | ||
42 | #define or_softirq_pending(x) percpu_or(irq_stat.__softirq_pending, (x)) | ||
43 | |||
44 | extern void ack_bad_irq(unsigned int irq); | ||
6 | 45 | ||
7 | extern u64 arch_irq_stat_cpu(unsigned int cpu); | 46 | extern u64 arch_irq_stat_cpu(unsigned int cpu); |
8 | #define arch_irq_stat_cpu arch_irq_stat_cpu | 47 | #define arch_irq_stat_cpu arch_irq_stat_cpu |
9 | 48 | ||
10 | extern u64 arch_irq_stat(void); | 49 | extern u64 arch_irq_stat(void); |
11 | #define arch_irq_stat arch_irq_stat | 50 | #define arch_irq_stat arch_irq_stat |
51 | |||
52 | #endif /* _ASM_X86_HARDIRQ_H */ | ||
diff --git a/arch/x86/include/asm/hardirq_32.h b/arch/x86/include/asm/hardirq_32.h deleted file mode 100644 index cf7954d1405f..000000000000 --- a/arch/x86/include/asm/hardirq_32.h +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #ifndef _ASM_X86_HARDIRQ_32_H | ||
2 | #define _ASM_X86_HARDIRQ_32_H | ||
3 | |||
4 | #include <linux/threads.h> | ||
5 | #include <linux/irq.h> | ||
6 | |||
7 | typedef struct { | ||
8 | unsigned int __softirq_pending; | ||
9 | unsigned long idle_timestamp; | ||
10 | unsigned int __nmi_count; /* arch dependent */ | ||
11 | unsigned int apic_timer_irqs; /* arch dependent */ | ||
12 | unsigned int irq0_irqs; | ||
13 | unsigned int irq_resched_count; | ||
14 | unsigned int irq_call_count; | ||
15 | unsigned int irq_tlb_count; | ||
16 | unsigned int irq_thermal_count; | ||
17 | unsigned int irq_spurious_count; | ||
18 | } ____cacheline_aligned irq_cpustat_t; | ||
19 | |||
20 | DECLARE_PER_CPU(irq_cpustat_t, irq_stat); | ||
21 | |||
22 | #define __ARCH_IRQ_STAT | ||
23 | #define __IRQ_STAT(cpu, member) (per_cpu(irq_stat, cpu).member) | ||
24 | |||
25 | #define inc_irq_stat(member) (__get_cpu_var(irq_stat).member++) | ||
26 | |||
27 | void ack_bad_irq(unsigned int irq); | ||
28 | #include <linux/irq_cpustat.h> | ||
29 | |||
30 | #endif /* _ASM_X86_HARDIRQ_32_H */ | ||
diff --git a/arch/x86/include/asm/hardirq_64.h b/arch/x86/include/asm/hardirq_64.h deleted file mode 100644 index b5a6b5d56704..000000000000 --- a/arch/x86/include/asm/hardirq_64.h +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | #ifndef _ASM_X86_HARDIRQ_64_H | ||
2 | #define _ASM_X86_HARDIRQ_64_H | ||
3 | |||
4 | #include <linux/threads.h> | ||
5 | #include <linux/irq.h> | ||
6 | #include <asm/pda.h> | ||
7 | #include <asm/apic.h> | ||
8 | |||
9 | /* We can have at most NR_VECTORS irqs routed to a cpu at a time */ | ||
10 | #define MAX_HARDIRQS_PER_CPU NR_VECTORS | ||
11 | |||
12 | #define __ARCH_IRQ_STAT 1 | ||
13 | |||
14 | #define inc_irq_stat(member) add_pda(member, 1) | ||
15 | |||
16 | #define local_softirq_pending() read_pda(__softirq_pending) | ||
17 | |||
18 | #define __ARCH_SET_SOFTIRQ_PENDING 1 | ||
19 | |||
20 | #define set_softirq_pending(x) write_pda(__softirq_pending, (x)) | ||
21 | #define or_softirq_pending(x) or_pda(__softirq_pending, (x)) | ||
22 | |||
23 | extern void ack_bad_irq(unsigned int irq); | ||
24 | |||
25 | #endif /* _ASM_X86_HARDIRQ_64_H */ | ||
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 05cfed4485fa..bcf7ea4e1367 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h | |||
@@ -91,7 +91,7 @@ extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr); | |||
91 | 91 | ||
92 | extern int ioremap_change_attr(unsigned long vaddr, unsigned long size, | 92 | extern int ioremap_change_attr(unsigned long vaddr, unsigned long size, |
93 | unsigned long prot_val); | 93 | unsigned long prot_val); |
94 | extern void __iomem *ioremap_wc(unsigned long offset, unsigned long size); | 94 | extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size); |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * early_ioremap() and early_iounmap() are for temporary early boot-time | 97 | * early_ioremap() and early_iounmap() are for temporary early boot-time |
@@ -99,7 +99,6 @@ extern void __iomem *ioremap_wc(unsigned long offset, unsigned long size); | |||
99 | * A boot-time mapping is currently limited to at most 16 pages. | 99 | * A boot-time mapping is currently limited to at most 16 pages. |
100 | */ | 100 | */ |
101 | extern void early_ioremap_init(void); | 101 | extern void early_ioremap_init(void); |
102 | extern void early_ioremap_clear(void); | ||
103 | extern void early_ioremap_reset(void); | 102 | extern void early_ioremap_reset(void); |
104 | extern void __iomem *early_ioremap(unsigned long offset, unsigned long size); | 103 | extern void __iomem *early_ioremap(unsigned long offset, unsigned long size); |
105 | extern void __iomem *early_memremap(unsigned long offset, unsigned long size); | 104 | extern void __iomem *early_memremap(unsigned long offset, unsigned long size); |
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h index 7a1f44ac1f17..08ec793aa043 100644 --- a/arch/x86/include/asm/io_apic.h +++ b/arch/x86/include/asm/io_apic.h | |||
@@ -114,38 +114,16 @@ struct IR_IO_APIC_route_entry { | |||
114 | extern int nr_ioapics; | 114 | extern int nr_ioapics; |
115 | extern int nr_ioapic_registers[MAX_IO_APICS]; | 115 | extern int nr_ioapic_registers[MAX_IO_APICS]; |
116 | 116 | ||
117 | /* | ||
118 | * MP-BIOS irq configuration table structures: | ||
119 | */ | ||
120 | |||
121 | #define MP_MAX_IOAPIC_PIN 127 | 117 | #define MP_MAX_IOAPIC_PIN 127 |
122 | 118 | ||
123 | struct mp_config_ioapic { | ||
124 | unsigned long mp_apicaddr; | ||
125 | unsigned int mp_apicid; | ||
126 | unsigned char mp_type; | ||
127 | unsigned char mp_apicver; | ||
128 | unsigned char mp_flags; | ||
129 | }; | ||
130 | |||
131 | struct mp_config_intsrc { | ||
132 | unsigned int mp_dstapic; | ||
133 | unsigned char mp_type; | ||
134 | unsigned char mp_irqtype; | ||
135 | unsigned short mp_irqflag; | ||
136 | unsigned char mp_srcbus; | ||
137 | unsigned char mp_srcbusirq; | ||
138 | unsigned char mp_dstirq; | ||
139 | }; | ||
140 | |||
141 | /* I/O APIC entries */ | 119 | /* I/O APIC entries */ |
142 | extern struct mp_config_ioapic mp_ioapics[MAX_IO_APICS]; | 120 | extern struct mpc_ioapic mp_ioapics[MAX_IO_APICS]; |
143 | 121 | ||
144 | /* # of MP IRQ source entries */ | 122 | /* # of MP IRQ source entries */ |
145 | extern int mp_irq_entries; | 123 | extern int mp_irq_entries; |
146 | 124 | ||
147 | /* MP IRQ source entries */ | 125 | /* MP IRQ source entries */ |
148 | extern struct mp_config_intsrc mp_irqs[MAX_IRQ_SOURCES]; | 126 | extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES]; |
149 | 127 | ||
150 | /* non-0 if default (table-less) MP configuration */ | 128 | /* non-0 if default (table-less) MP configuration */ |
151 | extern int mpc_default_type; | 129 | extern int mpc_default_type; |
diff --git a/arch/x86/include/asm/irq_regs.h b/arch/x86/include/asm/irq_regs.h index 89c898ab298b..77843225b7ea 100644 --- a/arch/x86/include/asm/irq_regs.h +++ b/arch/x86/include/asm/irq_regs.h | |||
@@ -1,5 +1,31 @@ | |||
1 | #ifdef CONFIG_X86_32 | 1 | /* |
2 | # include "irq_regs_32.h" | 2 | * Per-cpu current frame pointer - the location of the last exception frame on |
3 | #else | 3 | * the stack, stored in the per-cpu area. |
4 | # include "irq_regs_64.h" | 4 | * |
5 | #endif | 5 | * Jeremy Fitzhardinge <jeremy@goop.org> |
6 | */ | ||
7 | #ifndef _ASM_X86_IRQ_REGS_H | ||
8 | #define _ASM_X86_IRQ_REGS_H | ||
9 | |||
10 | #include <asm/percpu.h> | ||
11 | |||
12 | #define ARCH_HAS_OWN_IRQ_REGS | ||
13 | |||
14 | DECLARE_PER_CPU(struct pt_regs *, irq_regs); | ||
15 | |||
16 | static inline struct pt_regs *get_irq_regs(void) | ||
17 | { | ||
18 | return percpu_read(irq_regs); | ||
19 | } | ||
20 | |||
21 | static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs) | ||
22 | { | ||
23 | struct pt_regs *old_regs; | ||
24 | |||
25 | old_regs = get_irq_regs(); | ||
26 | percpu_write(irq_regs, new_regs); | ||
27 | |||
28 | return old_regs; | ||
29 | } | ||
30 | |||
31 | #endif /* _ASM_X86_IRQ_REGS_32_H */ | ||
diff --git a/arch/x86/include/asm/irq_regs_32.h b/arch/x86/include/asm/irq_regs_32.h deleted file mode 100644 index 86afd7473457..000000000000 --- a/arch/x86/include/asm/irq_regs_32.h +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /* | ||
2 | * Per-cpu current frame pointer - the location of the last exception frame on | ||
3 | * the stack, stored in the per-cpu area. | ||
4 | * | ||
5 | * Jeremy Fitzhardinge <jeremy@goop.org> | ||
6 | */ | ||
7 | #ifndef _ASM_X86_IRQ_REGS_32_H | ||
8 | #define _ASM_X86_IRQ_REGS_32_H | ||
9 | |||
10 | #include <asm/percpu.h> | ||
11 | |||
12 | #define ARCH_HAS_OWN_IRQ_REGS | ||
13 | |||
14 | DECLARE_PER_CPU(struct pt_regs *, irq_regs); | ||
15 | |||
16 | static inline struct pt_regs *get_irq_regs(void) | ||
17 | { | ||
18 | return x86_read_percpu(irq_regs); | ||
19 | } | ||
20 | |||
21 | static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs) | ||
22 | { | ||
23 | struct pt_regs *old_regs; | ||
24 | |||
25 | old_regs = get_irq_regs(); | ||
26 | x86_write_percpu(irq_regs, new_regs); | ||
27 | |||
28 | return old_regs; | ||
29 | } | ||
30 | |||
31 | #endif /* _ASM_X86_IRQ_REGS_32_H */ | ||
diff --git a/arch/x86/include/asm/irq_regs_64.h b/arch/x86/include/asm/irq_regs_64.h deleted file mode 100644 index 3dd9c0b70270..000000000000 --- a/arch/x86/include/asm/irq_regs_64.h +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | #include <asm-generic/irq_regs.h> | ||
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h index f7ff65032b9d..9a83a10a5d51 100644 --- a/arch/x86/include/asm/irq_vectors.h +++ b/arch/x86/include/asm/irq_vectors.h | |||
@@ -49,31 +49,33 @@ | |||
49 | * some of the following vectors are 'rare', they are merged | 49 | * some of the following vectors are 'rare', they are merged |
50 | * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. | 50 | * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. |
51 | * TLB, reschedule and local APIC vectors are performance-critical. | 51 | * TLB, reschedule and local APIC vectors are performance-critical. |
52 | * | ||
53 | * Vectors 0xf0-0xfa are free (reserved for future Linux use). | ||
54 | */ | 52 | */ |
55 | #ifdef CONFIG_X86_32 | 53 | #ifdef CONFIG_X86_32 |
56 | 54 | ||
57 | # define SPURIOUS_APIC_VECTOR 0xff | 55 | # define SPURIOUS_APIC_VECTOR 0xff |
58 | # define ERROR_APIC_VECTOR 0xfe | 56 | # define ERROR_APIC_VECTOR 0xfe |
59 | # define INVALIDATE_TLB_VECTOR 0xfd | 57 | # define RESCHEDULE_VECTOR 0xfd |
60 | # define RESCHEDULE_VECTOR 0xfc | 58 | # define CALL_FUNCTION_VECTOR 0xfc |
61 | # define CALL_FUNCTION_VECTOR 0xfb | 59 | # define CALL_FUNCTION_SINGLE_VECTOR 0xfb |
62 | # define CALL_FUNCTION_SINGLE_VECTOR 0xfa | 60 | # define THERMAL_APIC_VECTOR 0xfa |
63 | # define THERMAL_APIC_VECTOR 0xf0 | 61 | /* 0xf8 - 0xf9 : free */ |
62 | # define INVALIDATE_TLB_VECTOR_END 0xf7 | ||
63 | # define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */ | ||
64 | |||
65 | # define NUM_INVALIDATE_TLB_VECTORS 8 | ||
64 | 66 | ||
65 | #else | 67 | #else |
66 | 68 | ||
67 | #define SPURIOUS_APIC_VECTOR 0xff | 69 | # define SPURIOUS_APIC_VECTOR 0xff |
68 | #define ERROR_APIC_VECTOR 0xfe | 70 | # define ERROR_APIC_VECTOR 0xfe |
69 | #define RESCHEDULE_VECTOR 0xfd | 71 | # define RESCHEDULE_VECTOR 0xfd |
70 | #define CALL_FUNCTION_VECTOR 0xfc | 72 | # define CALL_FUNCTION_VECTOR 0xfc |
71 | #define CALL_FUNCTION_SINGLE_VECTOR 0xfb | 73 | # define CALL_FUNCTION_SINGLE_VECTOR 0xfb |
72 | #define THERMAL_APIC_VECTOR 0xfa | 74 | # define THERMAL_APIC_VECTOR 0xfa |
73 | #define THRESHOLD_APIC_VECTOR 0xf9 | 75 | # define THRESHOLD_APIC_VECTOR 0xf9 |
74 | #define UV_BAU_MESSAGE 0xf8 | 76 | # define UV_BAU_MESSAGE 0xf8 |
75 | #define INVALIDATE_TLB_VECTOR_END 0xf7 | 77 | # define INVALIDATE_TLB_VECTOR_END 0xf7 |
76 | #define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */ | 78 | # define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */ |
77 | 79 | ||
78 | #define NUM_INVALIDATE_TLB_VECTORS 8 | 80 | #define NUM_INVALIDATE_TLB_VECTORS 8 |
79 | 81 | ||
@@ -105,6 +107,8 @@ | |||
105 | 107 | ||
106 | #if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_VOYAGER) | 108 | #if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_VOYAGER) |
107 | 109 | ||
110 | #include <asm/apicnum.h> /* need MAX_IO_APICS */ | ||
111 | |||
108 | #ifndef CONFIG_SPARSE_IRQ | 112 | #ifndef CONFIG_SPARSE_IRQ |
109 | # if NR_CPUS < MAX_IO_APICS | 113 | # if NR_CPUS < MAX_IO_APICS |
110 | # define NR_IRQS (NR_VECTORS + (32 * NR_CPUS)) | 114 | # define NR_IRQS (NR_VECTORS + (32 * NR_CPUS)) |
@@ -112,11 +116,12 @@ | |||
112 | # define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS)) | 116 | # define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS)) |
113 | # endif | 117 | # endif |
114 | #else | 118 | #else |
115 | # if (8 * NR_CPUS) > (32 * MAX_IO_APICS) | 119 | |
116 | # define NR_IRQS (NR_VECTORS + (8 * NR_CPUS)) | 120 | # define NR_IRQS \ |
117 | # else | 121 | ((8 * NR_CPUS) > (32 * MAX_IO_APICS) ? \ |
118 | # define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS)) | 122 | (NR_VECTORS + (8 * NR_CPUS)) : \ |
119 | # endif | 123 | (NR_VECTORS + (32 * MAX_IO_APICS))) \ |
124 | |||
120 | #endif | 125 | #endif |
121 | 126 | ||
122 | #elif defined(CONFIG_X86_VOYAGER) | 127 | #elif defined(CONFIG_X86_VOYAGER) |
diff --git a/arch/x86/include/asm/mach-default/entry_arch.h b/arch/x86/include/asm/mach-default/entry_arch.h index 6b1add8e31dd..6fa399ad1de2 100644 --- a/arch/x86/include/asm/mach-default/entry_arch.h +++ b/arch/x86/include/asm/mach-default/entry_arch.h | |||
@@ -11,10 +11,26 @@ | |||
11 | */ | 11 | */ |
12 | #ifdef CONFIG_X86_SMP | 12 | #ifdef CONFIG_X86_SMP |
13 | BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) | 13 | BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) |
14 | BUILD_INTERRUPT(invalidate_interrupt,INVALIDATE_TLB_VECTOR) | ||
15 | BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) | 14 | BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) |
16 | BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR) | 15 | BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR) |
17 | BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR) | 16 | BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR) |
17 | |||
18 | BUILD_INTERRUPT3(invalidate_interrupt0,INVALIDATE_TLB_VECTOR_START+0, | ||
19 | smp_invalidate_interrupt) | ||
20 | BUILD_INTERRUPT3(invalidate_interrupt1,INVALIDATE_TLB_VECTOR_START+1, | ||
21 | smp_invalidate_interrupt) | ||
22 | BUILD_INTERRUPT3(invalidate_interrupt2,INVALIDATE_TLB_VECTOR_START+2, | ||
23 | smp_invalidate_interrupt) | ||
24 | BUILD_INTERRUPT3(invalidate_interrupt3,INVALIDATE_TLB_VECTOR_START+3, | ||
25 | smp_invalidate_interrupt) | ||
26 | BUILD_INTERRUPT3(invalidate_interrupt4,INVALIDATE_TLB_VECTOR_START+4, | ||
27 | smp_invalidate_interrupt) | ||
28 | BUILD_INTERRUPT3(invalidate_interrupt5,INVALIDATE_TLB_VECTOR_START+5, | ||
29 | smp_invalidate_interrupt) | ||
30 | BUILD_INTERRUPT3(invalidate_interrupt6,INVALIDATE_TLB_VECTOR_START+6, | ||
31 | smp_invalidate_interrupt) | ||
32 | BUILD_INTERRUPT3(invalidate_interrupt7,INVALIDATE_TLB_VECTOR_START+7, | ||
33 | smp_invalidate_interrupt) | ||
18 | #endif | 34 | #endif |
19 | 35 | ||
20 | /* | 36 | /* |
diff --git a/arch/x86/include/asm/mach-default/mach_wakecpu.h b/arch/x86/include/asm/mach-default/mach_wakecpu.h index ceb013660146..89897a6a65b9 100644 --- a/arch/x86/include/asm/mach-default/mach_wakecpu.h +++ b/arch/x86/include/asm/mach-default/mach_wakecpu.h | |||
@@ -24,7 +24,13 @@ static inline void restore_NMI_vector(unsigned short *high, unsigned short *low) | |||
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | #ifdef CONFIG_SMP | ||
27 | extern void __inquire_remote_apic(int apicid); | 28 | extern void __inquire_remote_apic(int apicid); |
29 | #else /* CONFIG_SMP */ | ||
30 | static inline void __inquire_remote_apic(int apicid) | ||
31 | { | ||
32 | } | ||
33 | #endif /* CONFIG_SMP */ | ||
28 | 34 | ||
29 | static inline void inquire_remote_apic(int apicid) | 35 | static inline void inquire_remote_apic(int apicid) |
30 | { | 36 | { |
diff --git a/arch/x86/include/asm/mach-rdc321x/gpio.h b/arch/x86/include/asm/mach-rdc321x/gpio.h deleted file mode 100644 index c210ab5788b0..000000000000 --- a/arch/x86/include/asm/mach-rdc321x/gpio.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | #ifndef _ASM_X86_MACH_RDC321X_GPIO_H | ||
2 | #define _ASM_X86_MACH_RDC321X_GPIO_H | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | |||
6 | extern int rdc_gpio_get_value(unsigned gpio); | ||
7 | extern void rdc_gpio_set_value(unsigned gpio, int value); | ||
8 | extern int rdc_gpio_direction_input(unsigned gpio); | ||
9 | extern int rdc_gpio_direction_output(unsigned gpio, int value); | ||
10 | extern int rdc_gpio_request(unsigned gpio, const char *label); | ||
11 | extern void rdc_gpio_free(unsigned gpio); | ||
12 | extern void __init rdc321x_gpio_setup(void); | ||
13 | |||
14 | /* Wrappers for the arch-neutral GPIO API */ | ||
15 | |||
16 | static inline int gpio_request(unsigned gpio, const char *label) | ||
17 | { | ||
18 | return rdc_gpio_request(gpio, label); | ||
19 | } | ||
20 | |||
21 | static inline void gpio_free(unsigned gpio) | ||
22 | { | ||
23 | might_sleep(); | ||
24 | rdc_gpio_free(gpio); | ||
25 | } | ||
26 | |||
27 | static inline int gpio_direction_input(unsigned gpio) | ||
28 | { | ||
29 | return rdc_gpio_direction_input(gpio); | ||
30 | } | ||
31 | |||
32 | static inline int gpio_direction_output(unsigned gpio, int value) | ||
33 | { | ||
34 | return rdc_gpio_direction_output(gpio, value); | ||
35 | } | ||
36 | |||
37 | static inline int gpio_get_value(unsigned gpio) | ||
38 | { | ||
39 | return rdc_gpio_get_value(gpio); | ||
40 | } | ||
41 | |||
42 | static inline void gpio_set_value(unsigned gpio, int value) | ||
43 | { | ||
44 | rdc_gpio_set_value(gpio, value); | ||
45 | } | ||
46 | |||
47 | static inline int gpio_to_irq(unsigned gpio) | ||
48 | { | ||
49 | return gpio; | ||
50 | } | ||
51 | |||
52 | static inline int irq_to_gpio(unsigned irq) | ||
53 | { | ||
54 | return irq; | ||
55 | } | ||
56 | |||
57 | /* For cansleep */ | ||
58 | #include <asm-generic/gpio.h> | ||
59 | |||
60 | #endif /* _ASM_X86_MACH_RDC321X_GPIO_H */ | ||
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 8aeeb3fd73db..52948df9cd1d 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h | |||
@@ -21,11 +21,54 @@ static inline void paravirt_activate_mm(struct mm_struct *prev, | |||
21 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm); | 21 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm); |
22 | void destroy_context(struct mm_struct *mm); | 22 | void destroy_context(struct mm_struct *mm); |
23 | 23 | ||
24 | #ifdef CONFIG_X86_32 | 24 | |
25 | # include "mmu_context_32.h" | 25 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) |
26 | #else | 26 | { |
27 | # include "mmu_context_64.h" | 27 | #ifdef CONFIG_SMP |
28 | if (percpu_read(cpu_tlbstate.state) == TLBSTATE_OK) | ||
29 | percpu_write(cpu_tlbstate.state, TLBSTATE_LAZY); | ||
30 | #endif | ||
31 | } | ||
32 | |||
33 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | ||
34 | struct task_struct *tsk) | ||
35 | { | ||
36 | unsigned cpu = smp_processor_id(); | ||
37 | |||
38 | if (likely(prev != next)) { | ||
39 | /* stop flush ipis for the previous mm */ | ||
40 | cpu_clear(cpu, prev->cpu_vm_mask); | ||
41 | #ifdef CONFIG_SMP | ||
42 | percpu_write(cpu_tlbstate.state, TLBSTATE_OK); | ||
43 | percpu_write(cpu_tlbstate.active_mm, next); | ||
28 | #endif | 44 | #endif |
45 | cpu_set(cpu, next->cpu_vm_mask); | ||
46 | |||
47 | /* Re-load page tables */ | ||
48 | load_cr3(next->pgd); | ||
49 | |||
50 | /* | ||
51 | * load the LDT, if the LDT is different: | ||
52 | */ | ||
53 | if (unlikely(prev->context.ldt != next->context.ldt)) | ||
54 | load_LDT_nolock(&next->context); | ||
55 | } | ||
56 | #ifdef CONFIG_SMP | ||
57 | else { | ||
58 | percpu_write(cpu_tlbstate.state, TLBSTATE_OK); | ||
59 | BUG_ON(percpu_read(cpu_tlbstate.active_mm) != next); | ||
60 | |||
61 | if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { | ||
62 | /* We were in lazy tlb mode and leave_mm disabled | ||
63 | * tlb flush IPI delivery. We must reload CR3 | ||
64 | * to make sure to use no freed page tables. | ||
65 | */ | ||
66 | load_cr3(next->pgd); | ||
67 | load_LDT_nolock(&next->context); | ||
68 | } | ||
69 | } | ||
70 | #endif | ||
71 | } | ||
29 | 72 | ||
30 | #define activate_mm(prev, next) \ | 73 | #define activate_mm(prev, next) \ |
31 | do { \ | 74 | do { \ |
@@ -33,5 +76,17 @@ do { \ | |||
33 | switch_mm((prev), (next), NULL); \ | 76 | switch_mm((prev), (next), NULL); \ |
34 | } while (0); | 77 | } while (0); |
35 | 78 | ||
79 | #ifdef CONFIG_X86_32 | ||
80 | #define deactivate_mm(tsk, mm) \ | ||
81 | do { \ | ||
82 | loadsegment(gs, 0); \ | ||
83 | } while (0) | ||
84 | #else | ||
85 | #define deactivate_mm(tsk, mm) \ | ||
86 | do { \ | ||
87 | load_gs_index(0); \ | ||
88 | loadsegment(fs, 0); \ | ||
89 | } while (0) | ||
90 | #endif | ||
36 | 91 | ||
37 | #endif /* _ASM_X86_MMU_CONTEXT_H */ | 92 | #endif /* _ASM_X86_MMU_CONTEXT_H */ |
diff --git a/arch/x86/include/asm/mmu_context_32.h b/arch/x86/include/asm/mmu_context_32.h deleted file mode 100644 index 7e98ce1d2c0e..000000000000 --- a/arch/x86/include/asm/mmu_context_32.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | #ifndef _ASM_X86_MMU_CONTEXT_32_H | ||
2 | #define _ASM_X86_MMU_CONTEXT_32_H | ||
3 | |||
4 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | ||
5 | { | ||
6 | #ifdef CONFIG_SMP | ||
7 | if (x86_read_percpu(cpu_tlbstate.state) == TLBSTATE_OK) | ||
8 | x86_write_percpu(cpu_tlbstate.state, TLBSTATE_LAZY); | ||
9 | #endif | ||
10 | } | ||
11 | |||
12 | static inline void switch_mm(struct mm_struct *prev, | ||
13 | struct mm_struct *next, | ||
14 | struct task_struct *tsk) | ||
15 | { | ||
16 | int cpu = smp_processor_id(); | ||
17 | |||
18 | if (likely(prev != next)) { | ||
19 | /* stop flush ipis for the previous mm */ | ||
20 | cpu_clear(cpu, prev->cpu_vm_mask); | ||
21 | #ifdef CONFIG_SMP | ||
22 | x86_write_percpu(cpu_tlbstate.state, TLBSTATE_OK); | ||
23 | x86_write_percpu(cpu_tlbstate.active_mm, next); | ||
24 | #endif | ||
25 | cpu_set(cpu, next->cpu_vm_mask); | ||
26 | |||
27 | /* Re-load page tables */ | ||
28 | load_cr3(next->pgd); | ||
29 | |||
30 | /* | ||
31 | * load the LDT, if the LDT is different: | ||
32 | */ | ||
33 | if (unlikely(prev->context.ldt != next->context.ldt)) | ||
34 | load_LDT_nolock(&next->context); | ||
35 | } | ||
36 | #ifdef CONFIG_SMP | ||
37 | else { | ||
38 | x86_write_percpu(cpu_tlbstate.state, TLBSTATE_OK); | ||
39 | BUG_ON(x86_read_percpu(cpu_tlbstate.active_mm) != next); | ||
40 | |||
41 | if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { | ||
42 | /* We were in lazy tlb mode and leave_mm disabled | ||
43 | * tlb flush IPI delivery. We must reload %cr3. | ||
44 | */ | ||
45 | load_cr3(next->pgd); | ||
46 | load_LDT_nolock(&next->context); | ||
47 | } | ||
48 | } | ||
49 | #endif | ||
50 | } | ||
51 | |||
52 | #define deactivate_mm(tsk, mm) \ | ||
53 | asm("movl %0,%%gs": :"r" (0)); | ||
54 | |||
55 | #endif /* _ASM_X86_MMU_CONTEXT_32_H */ | ||
diff --git a/arch/x86/include/asm/mmu_context_64.h b/arch/x86/include/asm/mmu_context_64.h deleted file mode 100644 index 677d36e9540a..000000000000 --- a/arch/x86/include/asm/mmu_context_64.h +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | #ifndef _ASM_X86_MMU_CONTEXT_64_H | ||
2 | #define _ASM_X86_MMU_CONTEXT_64_H | ||
3 | |||
4 | #include <asm/pda.h> | ||
5 | |||
6 | static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | ||
7 | { | ||
8 | #ifdef CONFIG_SMP | ||
9 | if (read_pda(mmu_state) == TLBSTATE_OK) | ||
10 | write_pda(mmu_state, TLBSTATE_LAZY); | ||
11 | #endif | ||
12 | } | ||
13 | |||
14 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | ||
15 | struct task_struct *tsk) | ||
16 | { | ||
17 | unsigned cpu = smp_processor_id(); | ||
18 | if (likely(prev != next)) { | ||
19 | /* stop flush ipis for the previous mm */ | ||
20 | cpu_clear(cpu, prev->cpu_vm_mask); | ||
21 | #ifdef CONFIG_SMP | ||
22 | write_pda(mmu_state, TLBSTATE_OK); | ||
23 | write_pda(active_mm, next); | ||
24 | #endif | ||
25 | cpu_set(cpu, next->cpu_vm_mask); | ||
26 | load_cr3(next->pgd); | ||
27 | |||
28 | if (unlikely(next->context.ldt != prev->context.ldt)) | ||
29 | load_LDT_nolock(&next->context); | ||
30 | } | ||
31 | #ifdef CONFIG_SMP | ||
32 | else { | ||
33 | write_pda(mmu_state, TLBSTATE_OK); | ||
34 | if (read_pda(active_mm) != next) | ||
35 | BUG(); | ||
36 | if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { | ||
37 | /* We were in lazy tlb mode and leave_mm disabled | ||
38 | * tlb flush IPI delivery. We must reload CR3 | ||
39 | * to make sure to use no freed page tables. | ||
40 | */ | ||
41 | load_cr3(next->pgd); | ||
42 | load_LDT_nolock(&next->context); | ||
43 | } | ||
44 | } | ||
45 | #endif | ||
46 | } | ||
47 | |||
48 | #define deactivate_mm(tsk, mm) \ | ||
49 | do { \ | ||
50 | load_gs_index(0); \ | ||
51 | asm volatile("movl %0,%%fs"::"r"(0)); \ | ||
52 | } while (0) | ||
53 | |||
54 | #endif /* _ASM_X86_MMU_CONTEXT_64_H */ | ||
diff --git a/arch/x86/include/asm/mpspec_def.h b/arch/x86/include/asm/mpspec_def.h index 59568bc4767f..4a7f96d7c188 100644 --- a/arch/x86/include/asm/mpspec_def.h +++ b/arch/x86/include/asm/mpspec_def.h | |||
@@ -24,17 +24,18 @@ | |||
24 | # endif | 24 | # endif |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | struct intel_mp_floating { | 27 | /* Intel MP Floating Pointer Structure */ |
28 | char mpf_signature[4]; /* "_MP_" */ | 28 | struct mpf_intel { |
29 | unsigned int mpf_physptr; /* Configuration table address */ | 29 | char signature[4]; /* "_MP_" */ |
30 | unsigned char mpf_length; /* Our length (paragraphs) */ | 30 | unsigned int physptr; /* Configuration table address */ |
31 | unsigned char mpf_specification;/* Specification version */ | 31 | unsigned char length; /* Our length (paragraphs) */ |
32 | unsigned char mpf_checksum; /* Checksum (makes sum 0) */ | 32 | unsigned char specification; /* Specification version */ |
33 | unsigned char mpf_feature1; /* Standard or configuration ? */ | 33 | unsigned char checksum; /* Checksum (makes sum 0) */ |
34 | unsigned char mpf_feature2; /* Bit7 set for IMCR|PIC */ | 34 | unsigned char feature1; /* Standard or configuration ? */ |
35 | unsigned char mpf_feature3; /* Unused (0) */ | 35 | unsigned char feature2; /* Bit7 set for IMCR|PIC */ |
36 | unsigned char mpf_feature4; /* Unused (0) */ | 36 | unsigned char feature3; /* Unused (0) */ |
37 | unsigned char mpf_feature5; /* Unused (0) */ | 37 | unsigned char feature4; /* Unused (0) */ |
38 | unsigned char feature5; /* Unused (0) */ | ||
38 | }; | 39 | }; |
39 | 40 | ||
40 | #define MPC_SIGNATURE "PCMP" | 41 | #define MPC_SIGNATURE "PCMP" |
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index cb58643947b9..358acc59ae04 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h | |||
@@ -202,6 +202,35 @@ | |||
202 | #define MSR_IA32_THERM_STATUS 0x0000019c | 202 | #define MSR_IA32_THERM_STATUS 0x0000019c |
203 | #define MSR_IA32_MISC_ENABLE 0x000001a0 | 203 | #define MSR_IA32_MISC_ENABLE 0x000001a0 |
204 | 204 | ||
205 | /* MISC_ENABLE bits: architectural */ | ||
206 | #define MSR_IA32_MISC_ENABLE_FAST_STRING (1ULL << 0) | ||
207 | #define MSR_IA32_MISC_ENABLE_TCC (1ULL << 1) | ||
208 | #define MSR_IA32_MISC_ENABLE_EMON (1ULL << 7) | ||
209 | #define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL (1ULL << 11) | ||
210 | #define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL (1ULL << 12) | ||
211 | #define MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP (1ULL << 16) | ||
212 | #define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << 18) | ||
213 | #define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << 22) | ||
214 | #define MSR_IA32_MISC_ENABLE_XTPR_DISABLE (1ULL << 23) | ||
215 | #define MSR_IA32_MISC_ENABLE_XD_DISABLE (1ULL << 34) | ||
216 | |||
217 | /* MISC_ENABLE bits: model-specific, meaning may vary from core to core */ | ||
218 | #define MSR_IA32_MISC_ENABLE_X87_COMPAT (1ULL << 2) | ||
219 | #define MSR_IA32_MISC_ENABLE_TM1 (1ULL << 3) | ||
220 | #define MSR_IA32_MISC_ENABLE_SPLIT_LOCK_DISABLE (1ULL << 4) | ||
221 | #define MSR_IA32_MISC_ENABLE_L3CACHE_DISABLE (1ULL << 6) | ||
222 | #define MSR_IA32_MISC_ENABLE_SUPPRESS_LOCK (1ULL << 8) | ||
223 | #define MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE (1ULL << 9) | ||
224 | #define MSR_IA32_MISC_ENABLE_FERR (1ULL << 10) | ||
225 | #define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX (1ULL << 10) | ||
226 | #define MSR_IA32_MISC_ENABLE_TM2 (1ULL << 13) | ||
227 | #define MSR_IA32_MISC_ENABLE_ADJ_PREF_DISABLE (1ULL << 19) | ||
228 | #define MSR_IA32_MISC_ENABLE_SPEEDSTEP_LOCK (1ULL << 20) | ||
229 | #define MSR_IA32_MISC_ENABLE_L1D_CONTEXT (1ULL << 24) | ||
230 | #define MSR_IA32_MISC_ENABLE_DCU_PREF_DISABLE (1ULL << 37) | ||
231 | #define MSR_IA32_MISC_ENABLE_TURBO_DISABLE (1ULL << 38) | ||
232 | #define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE (1ULL << 39) | ||
233 | |||
205 | /* Intel Model 6 */ | 234 | /* Intel Model 6 */ |
206 | #define MSR_P6_EVNTSEL0 0x00000186 | 235 | #define MSR_P6_EVNTSEL0 0x00000186 |
207 | #define MSR_P6_EVNTSEL1 0x00000187 | 236 | #define MSR_P6_EVNTSEL1 0x00000187 |
diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h index cb988aab716d..14080d22edb3 100644 --- a/arch/x86/include/asm/mtrr.h +++ b/arch/x86/include/asm/mtrr.h | |||
@@ -58,15 +58,15 @@ struct mtrr_gentry { | |||
58 | #endif /* !__i386__ */ | 58 | #endif /* !__i386__ */ |
59 | 59 | ||
60 | struct mtrr_var_range { | 60 | struct mtrr_var_range { |
61 | u32 base_lo; | 61 | __u32 base_lo; |
62 | u32 base_hi; | 62 | __u32 base_hi; |
63 | u32 mask_lo; | 63 | __u32 mask_lo; |
64 | u32 mask_hi; | 64 | __u32 mask_hi; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | /* In the Intel processor's MTRR interface, the MTRR type is always held in | 67 | /* In the Intel processor's MTRR interface, the MTRR type is always held in |
68 | an 8 bit field: */ | 68 | an 8 bit field: */ |
69 | typedef u8 mtrr_type; | 69 | typedef __u8 mtrr_type; |
70 | 70 | ||
71 | #define MTRR_NUM_FIXED_RANGES 88 | 71 | #define MTRR_NUM_FIXED_RANGES 88 |
72 | #define MTRR_MAX_VAR_RANGES 256 | 72 | #define MTRR_MAX_VAR_RANGES 256 |
diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h index e9873a2e8695..6b9810859daf 100644 --- a/arch/x86/include/asm/page.h +++ b/arch/x86/include/asm/page.h | |||
@@ -147,7 +147,7 @@ static inline pteval_t native_pte_val(pte_t pte) | |||
147 | return pte.pte; | 147 | return pte.pte; |
148 | } | 148 | } |
149 | 149 | ||
150 | static inline pteval_t native_pte_flags(pte_t pte) | 150 | static inline pteval_t pte_flags(pte_t pte) |
151 | { | 151 | { |
152 | return native_pte_val(pte) & PTE_FLAGS_MASK; | 152 | return native_pte_val(pte) & PTE_FLAGS_MASK; |
153 | } | 153 | } |
@@ -173,7 +173,6 @@ static inline pteval_t native_pte_flags(pte_t pte) | |||
173 | #endif | 173 | #endif |
174 | 174 | ||
175 | #define pte_val(x) native_pte_val(x) | 175 | #define pte_val(x) native_pte_val(x) |
176 | #define pte_flags(x) native_pte_flags(x) | ||
177 | #define __pte(x) native_make_pte(x) | 176 | #define __pte(x) native_make_pte(x) |
178 | 177 | ||
179 | #endif /* CONFIG_PARAVIRT */ | 178 | #endif /* CONFIG_PARAVIRT */ |
diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h index 5ebca29f44f0..e27fdbe5f9e4 100644 --- a/arch/x86/include/asm/page_64.h +++ b/arch/x86/include/asm/page_64.h | |||
@@ -13,8 +13,8 @@ | |||
13 | #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1) | 13 | #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1) |
14 | #define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER) | 14 | #define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER) |
15 | 15 | ||
16 | #define IRQSTACK_ORDER 2 | 16 | #define IRQ_STACK_ORDER 2 |
17 | #define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER) | 17 | #define IRQ_STACK_SIZE (PAGE_SIZE << IRQ_STACK_ORDER) |
18 | 18 | ||
19 | #define STACKFAULT_STACK 1 | 19 | #define STACKFAULT_STACK 1 |
20 | #define DOUBLEFAULT_STACK 2 | 20 | #define DOUBLEFAULT_STACK 2 |
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index ba3e2ff6aedc..7e674ea80f0d 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h | |||
@@ -244,7 +244,8 @@ struct pv_mmu_ops { | |||
244 | void (*flush_tlb_user)(void); | 244 | void (*flush_tlb_user)(void); |
245 | void (*flush_tlb_kernel)(void); | 245 | void (*flush_tlb_kernel)(void); |
246 | void (*flush_tlb_single)(unsigned long addr); | 246 | void (*flush_tlb_single)(unsigned long addr); |
247 | void (*flush_tlb_others)(const cpumask_t *cpus, struct mm_struct *mm, | 247 | void (*flush_tlb_others)(const struct cpumask *cpus, |
248 | struct mm_struct *mm, | ||
248 | unsigned long va); | 249 | unsigned long va); |
249 | 250 | ||
250 | /* Hooks for allocating and freeing a pagetable top-level */ | 251 | /* Hooks for allocating and freeing a pagetable top-level */ |
@@ -279,7 +280,6 @@ struct pv_mmu_ops { | |||
279 | pte_t *ptep, pte_t pte); | 280 | pte_t *ptep, pte_t pte); |
280 | 281 | ||
281 | pteval_t (*pte_val)(pte_t); | 282 | pteval_t (*pte_val)(pte_t); |
282 | pteval_t (*pte_flags)(pte_t); | ||
283 | pte_t (*make_pte)(pteval_t pte); | 283 | pte_t (*make_pte)(pteval_t pte); |
284 | 284 | ||
285 | pgdval_t (*pgd_val)(pgd_t); | 285 | pgdval_t (*pgd_val)(pgd_t); |
@@ -984,10 +984,11 @@ static inline void __flush_tlb_single(unsigned long addr) | |||
984 | PVOP_VCALL1(pv_mmu_ops.flush_tlb_single, addr); | 984 | PVOP_VCALL1(pv_mmu_ops.flush_tlb_single, addr); |
985 | } | 985 | } |
986 | 986 | ||
987 | static inline void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm, | 987 | static inline void flush_tlb_others(const struct cpumask *cpumask, |
988 | struct mm_struct *mm, | ||
988 | unsigned long va) | 989 | unsigned long va) |
989 | { | 990 | { |
990 | PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va); | 991 | PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, cpumask, mm, va); |
991 | } | 992 | } |
992 | 993 | ||
993 | static inline int paravirt_pgd_alloc(struct mm_struct *mm) | 994 | static inline int paravirt_pgd_alloc(struct mm_struct *mm) |
@@ -1084,23 +1085,6 @@ static inline pteval_t pte_val(pte_t pte) | |||
1084 | return ret; | 1085 | return ret; |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | static inline pteval_t pte_flags(pte_t pte) | ||
1088 | { | ||
1089 | pteval_t ret; | ||
1090 | |||
1091 | if (sizeof(pteval_t) > sizeof(long)) | ||
1092 | ret = PVOP_CALL2(pteval_t, pv_mmu_ops.pte_flags, | ||
1093 | pte.pte, (u64)pte.pte >> 32); | ||
1094 | else | ||
1095 | ret = PVOP_CALL1(pteval_t, pv_mmu_ops.pte_flags, | ||
1096 | pte.pte); | ||
1097 | |||
1098 | #ifdef CONFIG_PARAVIRT_DEBUG | ||
1099 | BUG_ON(ret & PTE_PFN_MASK); | ||
1100 | #endif | ||
1101 | return ret; | ||
1102 | } | ||
1103 | |||
1104 | static inline pgd_t __pgd(pgdval_t val) | 1088 | static inline pgd_t __pgd(pgdval_t val) |
1105 | { | 1089 | { |
1106 | pgdval_t ret; | 1090 | pgdval_t ret; |
@@ -1389,8 +1373,6 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx, | |||
1389 | void _paravirt_nop(void); | 1373 | void _paravirt_nop(void); |
1390 | #define paravirt_nop ((void *)_paravirt_nop) | 1374 | #define paravirt_nop ((void *)_paravirt_nop) |
1391 | 1375 | ||
1392 | void paravirt_use_bytelocks(void); | ||
1393 | |||
1394 | #ifdef CONFIG_SMP | 1376 | #ifdef CONFIG_SMP |
1395 | 1377 | ||
1396 | static inline int __raw_spin_is_locked(struct raw_spinlock *lock) | 1378 | static inline int __raw_spin_is_locked(struct raw_spinlock *lock) |
diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h index b8493b3b9890..9709fdff6615 100644 --- a/arch/x86/include/asm/pat.h +++ b/arch/x86/include/asm/pat.h | |||
@@ -5,10 +5,8 @@ | |||
5 | 5 | ||
6 | #ifdef CONFIG_X86_PAT | 6 | #ifdef CONFIG_X86_PAT |
7 | extern int pat_enabled; | 7 | extern int pat_enabled; |
8 | extern void validate_pat_support(struct cpuinfo_x86 *c); | ||
9 | #else | 8 | #else |
10 | static const int pat_enabled; | 9 | static const int pat_enabled; |
11 | static inline void validate_pat_support(struct cpuinfo_x86 *c) { } | ||
12 | #endif | 10 | #endif |
13 | 11 | ||
14 | extern void pat_init(void); | 12 | extern void pat_init(void); |
@@ -17,6 +15,4 @@ extern int reserve_memtype(u64 start, u64 end, | |||
17 | unsigned long req_type, unsigned long *ret_type); | 15 | unsigned long req_type, unsigned long *ret_type); |
18 | extern int free_memtype(u64 start, u64 end); | 16 | extern int free_memtype(u64 start, u64 end); |
19 | 17 | ||
20 | extern void pat_disable(char *reason); | ||
21 | |||
22 | #endif /* _ASM_X86_PAT_H */ | 18 | #endif /* _ASM_X86_PAT_H */ |
diff --git a/arch/x86/include/asm/pda.h b/arch/x86/include/asm/pda.h deleted file mode 100644 index 2fbfff88df37..000000000000 --- a/arch/x86/include/asm/pda.h +++ /dev/null | |||
@@ -1,137 +0,0 @@ | |||
1 | #ifndef _ASM_X86_PDA_H | ||
2 | #define _ASM_X86_PDA_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | #include <linux/stddef.h> | ||
6 | #include <linux/types.h> | ||
7 | #include <linux/cache.h> | ||
8 | #include <asm/page.h> | ||
9 | |||
10 | /* Per processor datastructure. %gs points to it while the kernel runs */ | ||
11 | struct x8664_pda { | ||
12 | struct task_struct *pcurrent; /* 0 Current process */ | ||
13 | unsigned long data_offset; /* 8 Per cpu data offset from linker | ||
14 | address */ | ||
15 | unsigned long kernelstack; /* 16 top of kernel stack for current */ | ||
16 | unsigned long oldrsp; /* 24 user rsp for system call */ | ||
17 | int irqcount; /* 32 Irq nesting counter. Starts -1 */ | ||
18 | unsigned int cpunumber; /* 36 Logical CPU number */ | ||
19 | #ifdef CONFIG_CC_STACKPROTECTOR | ||
20 | unsigned long stack_canary; /* 40 stack canary value */ | ||
21 | /* gcc-ABI: this canary MUST be at | ||
22 | offset 40!!! */ | ||
23 | #endif | ||
24 | char *irqstackptr; | ||
25 | short nodenumber; /* number of current node (32k max) */ | ||
26 | short in_bootmem; /* pda lives in bootmem */ | ||
27 | unsigned int __softirq_pending; | ||
28 | unsigned int __nmi_count; /* number of NMI on this CPUs */ | ||
29 | short mmu_state; | ||
30 | short isidle; | ||
31 | struct mm_struct *active_mm; | ||
32 | unsigned apic_timer_irqs; | ||
33 | unsigned irq0_irqs; | ||
34 | unsigned irq_resched_count; | ||
35 | unsigned irq_call_count; | ||
36 | unsigned irq_tlb_count; | ||
37 | unsigned irq_thermal_count; | ||
38 | unsigned irq_threshold_count; | ||
39 | unsigned irq_spurious_count; | ||
40 | } ____cacheline_aligned_in_smp; | ||
41 | |||
42 | extern struct x8664_pda **_cpu_pda; | ||
43 | extern void pda_init(int); | ||
44 | |||
45 | #define cpu_pda(i) (_cpu_pda[i]) | ||
46 | |||
47 | /* | ||
48 | * There is no fast way to get the base address of the PDA, all the accesses | ||
49 | * have to mention %fs/%gs. So it needs to be done this Torvaldian way. | ||
50 | */ | ||
51 | extern void __bad_pda_field(void) __attribute__((noreturn)); | ||
52 | |||
53 | /* | ||
54 | * proxy_pda doesn't actually exist, but tell gcc it is accessed for | ||
55 | * all PDA accesses so it gets read/write dependencies right. | ||
56 | */ | ||
57 | extern struct x8664_pda _proxy_pda; | ||
58 | |||
59 | #define pda_offset(field) offsetof(struct x8664_pda, field) | ||
60 | |||
61 | #define pda_to_op(op, field, val) \ | ||
62 | do { \ | ||
63 | typedef typeof(_proxy_pda.field) T__; \ | ||
64 | if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \ | ||
65 | switch (sizeof(_proxy_pda.field)) { \ | ||
66 | case 2: \ | ||
67 | asm(op "w %1,%%gs:%c2" : \ | ||
68 | "+m" (_proxy_pda.field) : \ | ||
69 | "ri" ((T__)val), \ | ||
70 | "i"(pda_offset(field))); \ | ||
71 | break; \ | ||
72 | case 4: \ | ||
73 | asm(op "l %1,%%gs:%c2" : \ | ||
74 | "+m" (_proxy_pda.field) : \ | ||
75 | "ri" ((T__)val), \ | ||
76 | "i" (pda_offset(field))); \ | ||
77 | break; \ | ||
78 | case 8: \ | ||
79 | asm(op "q %1,%%gs:%c2": \ | ||
80 | "+m" (_proxy_pda.field) : \ | ||
81 | "ri" ((T__)val), \ | ||
82 | "i"(pda_offset(field))); \ | ||
83 | break; \ | ||
84 | default: \ | ||
85 | __bad_pda_field(); \ | ||
86 | } \ | ||
87 | } while (0) | ||
88 | |||
89 | #define pda_from_op(op, field) \ | ||
90 | ({ \ | ||
91 | typeof(_proxy_pda.field) ret__; \ | ||
92 | switch (sizeof(_proxy_pda.field)) { \ | ||
93 | case 2: \ | ||
94 | asm(op "w %%gs:%c1,%0" : \ | ||
95 | "=r" (ret__) : \ | ||
96 | "i" (pda_offset(field)), \ | ||
97 | "m" (_proxy_pda.field)); \ | ||
98 | break; \ | ||
99 | case 4: \ | ||
100 | asm(op "l %%gs:%c1,%0": \ | ||
101 | "=r" (ret__): \ | ||
102 | "i" (pda_offset(field)), \ | ||
103 | "m" (_proxy_pda.field)); \ | ||
104 | break; \ | ||
105 | case 8: \ | ||
106 | asm(op "q %%gs:%c1,%0": \ | ||
107 | "=r" (ret__) : \ | ||
108 | "i" (pda_offset(field)), \ | ||
109 | "m" (_proxy_pda.field)); \ | ||
110 | break; \ | ||
111 | default: \ | ||
112 | __bad_pda_field(); \ | ||
113 | } \ | ||
114 | ret__; \ | ||
115 | }) | ||
116 | |||
117 | #define read_pda(field) pda_from_op("mov", field) | ||
118 | #define write_pda(field, val) pda_to_op("mov", field, val) | ||
119 | #define add_pda(field, val) pda_to_op("add", field, val) | ||
120 | #define sub_pda(field, val) pda_to_op("sub", field, val) | ||
121 | #define or_pda(field, val) pda_to_op("or", field, val) | ||
122 | |||
123 | /* This is not atomic against other CPUs -- CPU preemption needs to be off */ | ||
124 | #define test_and_clear_bit_pda(bit, field) \ | ||
125 | ({ \ | ||
126 | int old__; \ | ||
127 | asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \ | ||
128 | : "=r" (old__), "+m" (_proxy_pda.field) \ | ||
129 | : "dIr" (bit), "i" (pda_offset(field)) : "memory");\ | ||
130 | old__; \ | ||
131 | }) | ||
132 | |||
133 | #endif | ||
134 | |||
135 | #define PDA_STACKOFFSET (5*8) | ||
136 | |||
137 | #endif /* _ASM_X86_PDA_H */ | ||
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index ece72053ba63..0b64af4f13ac 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h | |||
@@ -2,53 +2,12 @@ | |||
2 | #define _ASM_X86_PERCPU_H | 2 | #define _ASM_X86_PERCPU_H |
3 | 3 | ||
4 | #ifdef CONFIG_X86_64 | 4 | #ifdef CONFIG_X86_64 |
5 | #include <linux/compiler.h> | 5 | #define __percpu_seg gs |
6 | 6 | #define __percpu_mov_op movq | |
7 | /* Same as asm-generic/percpu.h, except that we store the per cpu offset | 7 | #else |
8 | in the PDA. Longer term the PDA and every per cpu variable | 8 | #define __percpu_seg fs |
9 | should be just put into a single section and referenced directly | 9 | #define __percpu_mov_op movl |
10 | from %gs */ | ||
11 | |||
12 | #ifdef CONFIG_SMP | ||
13 | #include <asm/pda.h> | ||
14 | |||
15 | #define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset) | ||
16 | #define __my_cpu_offset read_pda(data_offset) | ||
17 | |||
18 | #define per_cpu_offset(x) (__per_cpu_offset(x)) | ||
19 | |||
20 | #endif | 10 | #endif |
21 | #include <asm-generic/percpu.h> | ||
22 | |||
23 | DECLARE_PER_CPU(struct x8664_pda, pda); | ||
24 | |||
25 | /* | ||
26 | * These are supposed to be implemented as a single instruction which | ||
27 | * operates on the per-cpu data base segment. x86-64 doesn't have | ||
28 | * that yet, so this is a fairly inefficient workaround for the | ||
29 | * meantime. The single instruction is atomic with respect to | ||
30 | * preemption and interrupts, so we need to explicitly disable | ||
31 | * interrupts here to achieve the same effect. However, because it | ||
32 | * can be used from within interrupt-disable/enable, we can't actually | ||
33 | * disable interrupts; disabling preemption is enough. | ||
34 | */ | ||
35 | #define x86_read_percpu(var) \ | ||
36 | ({ \ | ||
37 | typeof(per_cpu_var(var)) __tmp; \ | ||
38 | preempt_disable(); \ | ||
39 | __tmp = __get_cpu_var(var); \ | ||
40 | preempt_enable(); \ | ||
41 | __tmp; \ | ||
42 | }) | ||
43 | |||
44 | #define x86_write_percpu(var, val) \ | ||
45 | do { \ | ||
46 | preempt_disable(); \ | ||
47 | __get_cpu_var(var) = (val); \ | ||
48 | preempt_enable(); \ | ||
49 | } while(0) | ||
50 | |||
51 | #else /* CONFIG_X86_64 */ | ||
52 | 11 | ||
53 | #ifdef __ASSEMBLY__ | 12 | #ifdef __ASSEMBLY__ |
54 | 13 | ||
@@ -65,47 +24,26 @@ DECLARE_PER_CPU(struct x8664_pda, pda); | |||
65 | * PER_CPU(cpu_gdt_descr, %ebx) | 24 | * PER_CPU(cpu_gdt_descr, %ebx) |
66 | */ | 25 | */ |
67 | #ifdef CONFIG_SMP | 26 | #ifdef CONFIG_SMP |
68 | #define PER_CPU(var, reg) \ | 27 | #define PER_CPU(var, reg) \ |
69 | movl %fs:per_cpu__##this_cpu_off, reg; \ | 28 | __percpu_mov_op %__percpu_seg:per_cpu__this_cpu_off, reg; \ |
70 | lea per_cpu__##var(reg), reg | 29 | lea per_cpu__##var(reg), reg |
71 | #define PER_CPU_VAR(var) %fs:per_cpu__##var | 30 | #define PER_CPU_VAR(var) %__percpu_seg:per_cpu__##var |
72 | #else /* ! SMP */ | 31 | #else /* ! SMP */ |
73 | #define PER_CPU(var, reg) \ | 32 | #define PER_CPU(var, reg) \ |
74 | movl $per_cpu__##var, reg | 33 | __percpu_mov_op $per_cpu__##var, reg |
75 | #define PER_CPU_VAR(var) per_cpu__##var | 34 | #define PER_CPU_VAR(var) per_cpu__##var |
76 | #endif /* SMP */ | 35 | #endif /* SMP */ |
77 | 36 | ||
78 | #else /* ...!ASSEMBLY */ | 37 | #else /* ...!ASSEMBLY */ |
79 | 38 | ||
80 | /* | 39 | #include <linux/stringify.h> |
81 | * PER_CPU finds an address of a per-cpu variable. | ||
82 | * | ||
83 | * Args: | ||
84 | * var - variable name | ||
85 | * cpu - 32bit register containing the current CPU number | ||
86 | * | ||
87 | * The resulting address is stored in the "cpu" argument. | ||
88 | * | ||
89 | * Example: | ||
90 | * PER_CPU(cpu_gdt_descr, %ebx) | ||
91 | */ | ||
92 | #ifdef CONFIG_SMP | ||
93 | |||
94 | #define __my_cpu_offset x86_read_percpu(this_cpu_off) | ||
95 | 40 | ||
96 | /* fs segment starts at (positive) offset == __per_cpu_offset[cpu] */ | 41 | #ifdef CONFIG_SMP |
97 | #define __percpu_seg "%%fs:" | 42 | #define __percpu_arg(x) "%%"__stringify(__percpu_seg)":%P" #x |
98 | 43 | #define __my_cpu_offset percpu_read(this_cpu_off) | |
99 | #else /* !SMP */ | 44 | #else |
100 | 45 | #define __percpu_arg(x) "%" #x | |
101 | #define __percpu_seg "" | 46 | #endif |
102 | |||
103 | #endif /* SMP */ | ||
104 | |||
105 | #include <asm-generic/percpu.h> | ||
106 | |||
107 | /* We can use this directly for local CPU (faster). */ | ||
108 | DECLARE_PER_CPU(unsigned long, this_cpu_off); | ||
109 | 47 | ||
110 | /* For arch-specific code, we can use direct single-insn ops (they | 48 | /* For arch-specific code, we can use direct single-insn ops (they |
111 | * don't give an lvalue though). */ | 49 | * don't give an lvalue though). */ |
@@ -120,20 +58,25 @@ do { \ | |||
120 | } \ | 58 | } \ |
121 | switch (sizeof(var)) { \ | 59 | switch (sizeof(var)) { \ |
122 | case 1: \ | 60 | case 1: \ |
123 | asm(op "b %1,"__percpu_seg"%0" \ | 61 | asm(op "b %1,"__percpu_arg(0) \ |
124 | : "+m" (var) \ | 62 | : "+m" (var) \ |
125 | : "ri" ((T__)val)); \ | 63 | : "ri" ((T__)val)); \ |
126 | break; \ | 64 | break; \ |
127 | case 2: \ | 65 | case 2: \ |
128 | asm(op "w %1,"__percpu_seg"%0" \ | 66 | asm(op "w %1,"__percpu_arg(0) \ |
129 | : "+m" (var) \ | 67 | : "+m" (var) \ |
130 | : "ri" ((T__)val)); \ | 68 | : "ri" ((T__)val)); \ |
131 | break; \ | 69 | break; \ |
132 | case 4: \ | 70 | case 4: \ |
133 | asm(op "l %1,"__percpu_seg"%0" \ | 71 | asm(op "l %1,"__percpu_arg(0) \ |
134 | : "+m" (var) \ | 72 | : "+m" (var) \ |
135 | : "ri" ((T__)val)); \ | 73 | : "ri" ((T__)val)); \ |
136 | break; \ | 74 | break; \ |
75 | case 8: \ | ||
76 | asm(op "q %1,"__percpu_arg(0) \ | ||
77 | : "+m" (var) \ | ||
78 | : "re" ((T__)val)); \ | ||
79 | break; \ | ||
137 | default: __bad_percpu_size(); \ | 80 | default: __bad_percpu_size(); \ |
138 | } \ | 81 | } \ |
139 | } while (0) | 82 | } while (0) |
@@ -143,17 +86,22 @@ do { \ | |||
143 | typeof(var) ret__; \ | 86 | typeof(var) ret__; \ |
144 | switch (sizeof(var)) { \ | 87 | switch (sizeof(var)) { \ |
145 | case 1: \ | 88 | case 1: \ |
146 | asm(op "b "__percpu_seg"%1,%0" \ | 89 | asm(op "b "__percpu_arg(1)",%0" \ |
147 | : "=r" (ret__) \ | 90 | : "=r" (ret__) \ |
148 | : "m" (var)); \ | 91 | : "m" (var)); \ |
149 | break; \ | 92 | break; \ |
150 | case 2: \ | 93 | case 2: \ |
151 | asm(op "w "__percpu_seg"%1,%0" \ | 94 | asm(op "w "__percpu_arg(1)",%0" \ |
152 | : "=r" (ret__) \ | 95 | : "=r" (ret__) \ |
153 | : "m" (var)); \ | 96 | : "m" (var)); \ |
154 | break; \ | 97 | break; \ |
155 | case 4: \ | 98 | case 4: \ |
156 | asm(op "l "__percpu_seg"%1,%0" \ | 99 | asm(op "l "__percpu_arg(1)",%0" \ |
100 | : "=r" (ret__) \ | ||
101 | : "m" (var)); \ | ||
102 | break; \ | ||
103 | case 8: \ | ||
104 | asm(op "q "__percpu_arg(1)",%0" \ | ||
157 | : "=r" (ret__) \ | 105 | : "=r" (ret__) \ |
158 | : "m" (var)); \ | 106 | : "m" (var)); \ |
159 | break; \ | 107 | break; \ |
@@ -162,13 +110,30 @@ do { \ | |||
162 | ret__; \ | 110 | ret__; \ |
163 | }) | 111 | }) |
164 | 112 | ||
165 | #define x86_read_percpu(var) percpu_from_op("mov", per_cpu__##var) | 113 | #define percpu_read(var) percpu_from_op("mov", per_cpu__##var) |
166 | #define x86_write_percpu(var, val) percpu_to_op("mov", per_cpu__##var, val) | 114 | #define percpu_write(var, val) percpu_to_op("mov", per_cpu__##var, val) |
167 | #define x86_add_percpu(var, val) percpu_to_op("add", per_cpu__##var, val) | 115 | #define percpu_add(var, val) percpu_to_op("add", per_cpu__##var, val) |
168 | #define x86_sub_percpu(var, val) percpu_to_op("sub", per_cpu__##var, val) | 116 | #define percpu_sub(var, val) percpu_to_op("sub", per_cpu__##var, val) |
169 | #define x86_or_percpu(var, val) percpu_to_op("or", per_cpu__##var, val) | 117 | #define percpu_and(var, val) percpu_to_op("and", per_cpu__##var, val) |
118 | #define percpu_or(var, val) percpu_to_op("or", per_cpu__##var, val) | ||
119 | #define percpu_xor(var, val) percpu_to_op("xor", per_cpu__##var, val) | ||
120 | |||
121 | /* This is not atomic against other CPUs -- CPU preemption needs to be off */ | ||
122 | #define x86_test_and_clear_bit_percpu(bit, var) \ | ||
123 | ({ \ | ||
124 | int old__; \ | ||
125 | asm volatile("btr %2,"__percpu_arg(1)"\n\tsbbl %0,%0" \ | ||
126 | : "=r" (old__), "+m" (per_cpu__##var) \ | ||
127 | : "dIr" (bit)); \ | ||
128 | old__; \ | ||
129 | }) | ||
130 | |||
131 | #include <asm-generic/percpu.h> | ||
132 | |||
133 | /* We can use this directly for local CPU (faster). */ | ||
134 | DECLARE_PER_CPU(unsigned long, this_cpu_off); | ||
135 | |||
170 | #endif /* !__ASSEMBLY__ */ | 136 | #endif /* !__ASSEMBLY__ */ |
171 | #endif /* !CONFIG_X86_64 */ | ||
172 | 137 | ||
173 | #ifdef CONFIG_SMP | 138 | #ifdef CONFIG_SMP |
174 | 139 | ||
@@ -195,9 +160,9 @@ do { \ | |||
195 | #define early_per_cpu_ptr(_name) (_name##_early_ptr) | 160 | #define early_per_cpu_ptr(_name) (_name##_early_ptr) |
196 | #define early_per_cpu_map(_name, _idx) (_name##_early_map[_idx]) | 161 | #define early_per_cpu_map(_name, _idx) (_name##_early_map[_idx]) |
197 | #define early_per_cpu(_name, _cpu) \ | 162 | #define early_per_cpu(_name, _cpu) \ |
198 | (early_per_cpu_ptr(_name) ? \ | 163 | *(early_per_cpu_ptr(_name) ? \ |
199 | early_per_cpu_ptr(_name)[_cpu] : \ | 164 | &early_per_cpu_ptr(_name)[_cpu] : \ |
200 | per_cpu(_name, _cpu)) | 165 | &per_cpu(_name, _cpu)) |
201 | 166 | ||
202 | #else /* !CONFIG_SMP */ | 167 | #else /* !CONFIG_SMP */ |
203 | #define DEFINE_EARLY_PER_CPU(_type, _name, _initvalue) \ | 168 | #define DEFINE_EARLY_PER_CPU(_type, _name, _initvalue) \ |
diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h index cb7c151a8bff..dd14c54ac718 100644 --- a/arch/x86/include/asm/pgalloc.h +++ b/arch/x86/include/asm/pgalloc.h | |||
@@ -42,6 +42,7 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) | |||
42 | 42 | ||
43 | static inline void pte_free(struct mm_struct *mm, struct page *pte) | 43 | static inline void pte_free(struct mm_struct *mm, struct page *pte) |
44 | { | 44 | { |
45 | pgtable_page_dtor(pte); | ||
45 | __free_page(pte); | 46 | __free_page(pte); |
46 | } | 47 | } |
47 | 48 | ||
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 83e69f4a37f0..6ceaef08486f 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -240,64 +240,78 @@ static inline int pmd_large(pmd_t pte) | |||
240 | (_PAGE_PSE | _PAGE_PRESENT); | 240 | (_PAGE_PSE | _PAGE_PRESENT); |
241 | } | 241 | } |
242 | 242 | ||
243 | static inline pte_t pte_set_flags(pte_t pte, pteval_t set) | ||
244 | { | ||
245 | pteval_t v = native_pte_val(pte); | ||
246 | |||
247 | return native_make_pte(v | set); | ||
248 | } | ||
249 | |||
250 | static inline pte_t pte_clear_flags(pte_t pte, pteval_t clear) | ||
251 | { | ||
252 | pteval_t v = native_pte_val(pte); | ||
253 | |||
254 | return native_make_pte(v & ~clear); | ||
255 | } | ||
256 | |||
243 | static inline pte_t pte_mkclean(pte_t pte) | 257 | static inline pte_t pte_mkclean(pte_t pte) |
244 | { | 258 | { |
245 | return __pte(pte_val(pte) & ~_PAGE_DIRTY); | 259 | return pte_clear_flags(pte, _PAGE_DIRTY); |
246 | } | 260 | } |
247 | 261 | ||
248 | static inline pte_t pte_mkold(pte_t pte) | 262 | static inline pte_t pte_mkold(pte_t pte) |
249 | { | 263 | { |
250 | return __pte(pte_val(pte) & ~_PAGE_ACCESSED); | 264 | return pte_clear_flags(pte, _PAGE_ACCESSED); |
251 | } | 265 | } |
252 | 266 | ||
253 | static inline pte_t pte_wrprotect(pte_t pte) | 267 | static inline pte_t pte_wrprotect(pte_t pte) |
254 | { | 268 | { |
255 | return __pte(pte_val(pte) & ~_PAGE_RW); | 269 | return pte_clear_flags(pte, _PAGE_RW); |
256 | } | 270 | } |
257 | 271 | ||
258 | static inline pte_t pte_mkexec(pte_t pte) | 272 | static inline pte_t pte_mkexec(pte_t pte) |
259 | { | 273 | { |
260 | return __pte(pte_val(pte) & ~_PAGE_NX); | 274 | return pte_clear_flags(pte, _PAGE_NX); |
261 | } | 275 | } |
262 | 276 | ||
263 | static inline pte_t pte_mkdirty(pte_t pte) | 277 | static inline pte_t pte_mkdirty(pte_t pte) |
264 | { | 278 | { |
265 | return __pte(pte_val(pte) | _PAGE_DIRTY); | 279 | return pte_set_flags(pte, _PAGE_DIRTY); |
266 | } | 280 | } |
267 | 281 | ||
268 | static inline pte_t pte_mkyoung(pte_t pte) | 282 | static inline pte_t pte_mkyoung(pte_t pte) |
269 | { | 283 | { |
270 | return __pte(pte_val(pte) | _PAGE_ACCESSED); | 284 | return pte_set_flags(pte, _PAGE_ACCESSED); |
271 | } | 285 | } |
272 | 286 | ||
273 | static inline pte_t pte_mkwrite(pte_t pte) | 287 | static inline pte_t pte_mkwrite(pte_t pte) |
274 | { | 288 | { |
275 | return __pte(pte_val(pte) | _PAGE_RW); | 289 | return pte_set_flags(pte, _PAGE_RW); |
276 | } | 290 | } |
277 | 291 | ||
278 | static inline pte_t pte_mkhuge(pte_t pte) | 292 | static inline pte_t pte_mkhuge(pte_t pte) |
279 | { | 293 | { |
280 | return __pte(pte_val(pte) | _PAGE_PSE); | 294 | return pte_set_flags(pte, _PAGE_PSE); |
281 | } | 295 | } |
282 | 296 | ||
283 | static inline pte_t pte_clrhuge(pte_t pte) | 297 | static inline pte_t pte_clrhuge(pte_t pte) |
284 | { | 298 | { |
285 | return __pte(pte_val(pte) & ~_PAGE_PSE); | 299 | return pte_clear_flags(pte, _PAGE_PSE); |
286 | } | 300 | } |
287 | 301 | ||
288 | static inline pte_t pte_mkglobal(pte_t pte) | 302 | static inline pte_t pte_mkglobal(pte_t pte) |
289 | { | 303 | { |
290 | return __pte(pte_val(pte) | _PAGE_GLOBAL); | 304 | return pte_set_flags(pte, _PAGE_GLOBAL); |
291 | } | 305 | } |
292 | 306 | ||
293 | static inline pte_t pte_clrglobal(pte_t pte) | 307 | static inline pte_t pte_clrglobal(pte_t pte) |
294 | { | 308 | { |
295 | return __pte(pte_val(pte) & ~_PAGE_GLOBAL); | 309 | return pte_clear_flags(pte, _PAGE_GLOBAL); |
296 | } | 310 | } |
297 | 311 | ||
298 | static inline pte_t pte_mkspecial(pte_t pte) | 312 | static inline pte_t pte_mkspecial(pte_t pte) |
299 | { | 313 | { |
300 | return __pte(pte_val(pte) | _PAGE_SPECIAL); | 314 | return pte_set_flags(pte, _PAGE_SPECIAL); |
301 | } | 315 | } |
302 | 316 | ||
303 | extern pteval_t __supported_pte_mask; | 317 | extern pteval_t __supported_pte_mask; |
@@ -341,6 +355,25 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot) | |||
341 | 355 | ||
342 | #define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) | 356 | #define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) |
343 | 357 | ||
358 | static inline int is_new_memtype_allowed(unsigned long flags, | ||
359 | unsigned long new_flags) | ||
360 | { | ||
361 | /* | ||
362 | * Certain new memtypes are not allowed with certain | ||
363 | * requested memtype: | ||
364 | * - request is uncached, return cannot be write-back | ||
365 | * - request is write-combine, return cannot be write-back | ||
366 | */ | ||
367 | if ((flags == _PAGE_CACHE_UC_MINUS && | ||
368 | new_flags == _PAGE_CACHE_WB) || | ||
369 | (flags == _PAGE_CACHE_WC && | ||
370 | new_flags == _PAGE_CACHE_WB)) { | ||
371 | return 0; | ||
372 | } | ||
373 | |||
374 | return 1; | ||
375 | } | ||
376 | |||
344 | #ifndef __ASSEMBLY__ | 377 | #ifndef __ASSEMBLY__ |
345 | /* Indicate that x86 has its own track and untrack pfn vma functions */ | 378 | /* Indicate that x86 has its own track and untrack pfn vma functions */ |
346 | #define __HAVE_PFNMAP_TRACKING | 379 | #define __HAVE_PFNMAP_TRACKING |
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h index ba09289accaa..1df9637dfda3 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <asm/processor.h> | 11 | #include <asm/processor.h> |
12 | #include <linux/bitops.h> | 12 | #include <linux/bitops.h> |
13 | #include <linux/threads.h> | 13 | #include <linux/threads.h> |
14 | #include <asm/pda.h> | ||
15 | 14 | ||
16 | extern pud_t level3_kernel_pgt[512]; | 15 | extern pud_t level3_kernel_pgt[512]; |
17 | extern pud_t level3_ident_pgt[512]; | 16 | extern pud_t level3_ident_pgt[512]; |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 091cd8855f2e..84afa0d4d717 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -73,7 +73,7 @@ struct cpuinfo_x86 { | |||
73 | char pad0; | 73 | char pad0; |
74 | #else | 74 | #else |
75 | /* Number of 4K pages in DTLB/ITLB combined(in pages): */ | 75 | /* Number of 4K pages in DTLB/ITLB combined(in pages): */ |
76 | int x86_tlbsize; | 76 | int x86_tlbsize; |
77 | __u8 x86_virt_bits; | 77 | __u8 x86_virt_bits; |
78 | __u8 x86_phys_bits; | 78 | __u8 x86_phys_bits; |
79 | #endif | 79 | #endif |
@@ -378,6 +378,22 @@ union thread_xstate { | |||
378 | 378 | ||
379 | #ifdef CONFIG_X86_64 | 379 | #ifdef CONFIG_X86_64 |
380 | DECLARE_PER_CPU(struct orig_ist, orig_ist); | 380 | DECLARE_PER_CPU(struct orig_ist, orig_ist); |
381 | |||
382 | union irq_stack_union { | ||
383 | char irq_stack[IRQ_STACK_SIZE]; | ||
384 | /* | ||
385 | * GCC hardcodes the stack canary as %gs:40. Since the | ||
386 | * irq_stack is the object at %gs:0, we reserve the bottom | ||
387 | * 48 bytes of the irq stack for the canary. | ||
388 | */ | ||
389 | struct { | ||
390 | char gs_base[40]; | ||
391 | unsigned long stack_canary; | ||
392 | }; | ||
393 | }; | ||
394 | |||
395 | DECLARE_PER_CPU(union irq_stack_union, irq_stack_union); | ||
396 | DECLARE_PER_CPU(char *, irq_stack_ptr); | ||
381 | #endif | 397 | #endif |
382 | 398 | ||
383 | extern void print_cpu_info(struct cpuinfo_x86 *); | 399 | extern void print_cpu_info(struct cpuinfo_x86 *); |
@@ -754,7 +770,6 @@ extern struct desc_ptr early_gdt_descr; | |||
754 | extern void cpu_set_gdt(int); | 770 | extern void cpu_set_gdt(int); |
755 | extern void switch_to_new_gdt(void); | 771 | extern void switch_to_new_gdt(void); |
756 | extern void cpu_init(void); | 772 | extern void cpu_init(void); |
757 | extern void init_gdt(int cpu); | ||
758 | 773 | ||
759 | static inline unsigned long get_debugctlmsr(void) | 774 | static inline unsigned long get_debugctlmsr(void) |
760 | { | 775 | { |
diff --git a/arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h b/arch/x86/include/asm/rdc321x_defs.h index c8e9c8bed3d0..c8e9c8bed3d0 100644 --- a/arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h +++ b/arch/x86/include/asm/rdc321x_defs.h | |||
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index 29d31c0d13d6..45b40278b582 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h | |||
@@ -98,7 +98,6 @@ extern unsigned long init_pg_tables_start; | |||
98 | extern unsigned long init_pg_tables_end; | 98 | extern unsigned long init_pg_tables_end; |
99 | 99 | ||
100 | #else | 100 | #else |
101 | void __init x86_64_init_pda(void); | ||
102 | void __init x86_64_start_kernel(char *real_mode); | 101 | void __init x86_64_start_kernel(char *real_mode); |
103 | void __init x86_64_start_reservations(char *real_mode_data); | 102 | void __init x86_64_start_reservations(char *real_mode_data); |
104 | 103 | ||
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 19953df61c52..45ef8a1b9d7c 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h | |||
@@ -15,34 +15,8 @@ | |||
15 | # include <asm/io_apic.h> | 15 | # include <asm/io_apic.h> |
16 | # endif | 16 | # endif |
17 | #endif | 17 | #endif |
18 | #include <asm/pda.h> | ||
19 | #include <asm/thread_info.h> | 18 | #include <asm/thread_info.h> |
20 | 19 | #include <asm/cpumask.h> | |
21 | #ifdef CONFIG_X86_64 | ||
22 | |||
23 | extern cpumask_var_t cpu_callin_mask; | ||
24 | extern cpumask_var_t cpu_callout_mask; | ||
25 | extern cpumask_var_t cpu_initialized_mask; | ||
26 | extern cpumask_var_t cpu_sibling_setup_mask; | ||
27 | |||
28 | #else /* CONFIG_X86_32 */ | ||
29 | |||
30 | extern cpumask_t cpu_callin_map; | ||
31 | extern cpumask_t cpu_callout_map; | ||
32 | extern cpumask_t cpu_initialized; | ||
33 | extern cpumask_t cpu_sibling_setup_map; | ||
34 | |||
35 | #define cpu_callin_mask ((struct cpumask *)&cpu_callin_map) | ||
36 | #define cpu_callout_mask ((struct cpumask *)&cpu_callout_map) | ||
37 | #define cpu_initialized_mask ((struct cpumask *)&cpu_initialized) | ||
38 | #define cpu_sibling_setup_mask ((struct cpumask *)&cpu_sibling_setup_map) | ||
39 | |||
40 | #endif /* CONFIG_X86_32 */ | ||
41 | |||
42 | extern void (*mtrr_hook)(void); | ||
43 | extern void zap_low_mappings(void); | ||
44 | |||
45 | extern int __cpuinit get_local_pda(int cpu); | ||
46 | 20 | ||
47 | extern int smp_num_siblings; | 21 | extern int smp_num_siblings; |
48 | extern unsigned int num_processors; | 22 | extern unsigned int num_processors; |
@@ -50,9 +24,7 @@ extern unsigned int num_processors; | |||
50 | DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); | 24 | DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); |
51 | DECLARE_PER_CPU(cpumask_t, cpu_core_map); | 25 | DECLARE_PER_CPU(cpumask_t, cpu_core_map); |
52 | DECLARE_PER_CPU(u16, cpu_llc_id); | 26 | DECLARE_PER_CPU(u16, cpu_llc_id); |
53 | #ifdef CONFIG_X86_32 | ||
54 | DECLARE_PER_CPU(int, cpu_number); | 27 | DECLARE_PER_CPU(int, cpu_number); |
55 | #endif | ||
56 | 28 | ||
57 | static inline struct cpumask *cpu_sibling_mask(int cpu) | 29 | static inline struct cpumask *cpu_sibling_mask(int cpu) |
58 | { | 30 | { |
@@ -167,8 +139,6 @@ void play_dead_common(void); | |||
167 | void native_send_call_func_ipi(const struct cpumask *mask); | 139 | void native_send_call_func_ipi(const struct cpumask *mask); |
168 | void native_send_call_func_single_ipi(int cpu); | 140 | void native_send_call_func_single_ipi(int cpu); |
169 | 141 | ||
170 | extern void prefill_possible_map(void); | ||
171 | |||
172 | void smp_store_cpu_info(int id); | 142 | void smp_store_cpu_info(int id); |
173 | #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) | 143 | #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) |
174 | 144 | ||
@@ -177,10 +147,6 @@ static inline int num_booting_cpus(void) | |||
177 | { | 147 | { |
178 | return cpumask_weight(cpu_callout_mask); | 148 | return cpumask_weight(cpu_callout_mask); |
179 | } | 149 | } |
180 | #else | ||
181 | static inline void prefill_possible_map(void) | ||
182 | { | ||
183 | } | ||
184 | #endif /* CONFIG_SMP */ | 150 | #endif /* CONFIG_SMP */ |
185 | 151 | ||
186 | extern unsigned disabled_cpus __cpuinitdata; | 152 | extern unsigned disabled_cpus __cpuinitdata; |
@@ -191,11 +157,11 @@ extern unsigned disabled_cpus __cpuinitdata; | |||
191 | * from the initial startup. We map APIC_BASE very early in page_setup(), | 157 | * from the initial startup. We map APIC_BASE very early in page_setup(), |
192 | * so this is correct in the x86 case. | 158 | * so this is correct in the x86 case. |
193 | */ | 159 | */ |
194 | #define raw_smp_processor_id() (x86_read_percpu(cpu_number)) | 160 | #define raw_smp_processor_id() (percpu_read(cpu_number)) |
195 | extern int safe_smp_processor_id(void); | 161 | extern int safe_smp_processor_id(void); |
196 | 162 | ||
197 | #elif defined(CONFIG_X86_64_SMP) | 163 | #elif defined(CONFIG_X86_64_SMP) |
198 | #define raw_smp_processor_id() read_pda(cpunumber) | 164 | #define raw_smp_processor_id() (percpu_read(cpu_number)) |
199 | 165 | ||
200 | #define stack_smp_processor_id() \ | 166 | #define stack_smp_processor_id() \ |
201 | ({ \ | 167 | ({ \ |
@@ -205,10 +171,6 @@ extern int safe_smp_processor_id(void); | |||
205 | }) | 171 | }) |
206 | #define safe_smp_processor_id() smp_processor_id() | 172 | #define safe_smp_processor_id() smp_processor_id() |
207 | 173 | ||
208 | #else /* !CONFIG_X86_32_SMP && !CONFIG_X86_64_SMP */ | ||
209 | #define cpu_physical_id(cpu) boot_cpu_physical_apicid | ||
210 | #define safe_smp_processor_id() 0 | ||
211 | #define stack_smp_processor_id() 0 | ||
212 | #endif | 174 | #endif |
213 | 175 | ||
214 | #ifdef CONFIG_X86_LOCAL_APIC | 176 | #ifdef CONFIG_X86_LOCAL_APIC |
@@ -251,11 +213,5 @@ static inline int hard_smp_processor_id(void) | |||
251 | 213 | ||
252 | #endif /* CONFIG_X86_LOCAL_APIC */ | 214 | #endif /* CONFIG_X86_LOCAL_APIC */ |
253 | 215 | ||
254 | #ifdef CONFIG_X86_HAS_BOOT_CPU_ID | ||
255 | extern unsigned char boot_cpu_id; | ||
256 | #else | ||
257 | #define boot_cpu_id 0 | ||
258 | #endif | ||
259 | |||
260 | #endif /* __ASSEMBLY__ */ | 216 | #endif /* __ASSEMBLY__ */ |
261 | #endif /* _ASM_X86_SMP_H */ | 217 | #endif /* _ASM_X86_SMP_H */ |
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h index d17c91981da2..139b4249a5ec 100644 --- a/arch/x86/include/asm/spinlock.h +++ b/arch/x86/include/asm/spinlock.h | |||
@@ -172,70 +172,8 @@ static inline int __ticket_spin_is_contended(raw_spinlock_t *lock) | |||
172 | return (((tmp >> TICKET_SHIFT) - tmp) & ((1 << TICKET_SHIFT) - 1)) > 1; | 172 | return (((tmp >> TICKET_SHIFT) - tmp) & ((1 << TICKET_SHIFT) - 1)) > 1; |
173 | } | 173 | } |
174 | 174 | ||
175 | #ifdef CONFIG_PARAVIRT | 175 | #ifndef CONFIG_PARAVIRT |
176 | /* | ||
177 | * Define virtualization-friendly old-style lock byte lock, for use in | ||
178 | * pv_lock_ops if desired. | ||
179 | * | ||
180 | * This differs from the pre-2.6.24 spinlock by always using xchgb | ||
181 | * rather than decb to take the lock; this allows it to use a | ||
182 | * zero-initialized lock structure. It also maintains a 1-byte | ||
183 | * contention counter, so that we can implement | ||
184 | * __byte_spin_is_contended. | ||
185 | */ | ||
186 | struct __byte_spinlock { | ||
187 | s8 lock; | ||
188 | s8 spinners; | ||
189 | }; | ||
190 | |||
191 | static inline int __byte_spin_is_locked(raw_spinlock_t *lock) | ||
192 | { | ||
193 | struct __byte_spinlock *bl = (struct __byte_spinlock *)lock; | ||
194 | return bl->lock != 0; | ||
195 | } | ||
196 | |||
197 | static inline int __byte_spin_is_contended(raw_spinlock_t *lock) | ||
198 | { | ||
199 | struct __byte_spinlock *bl = (struct __byte_spinlock *)lock; | ||
200 | return bl->spinners != 0; | ||
201 | } | ||
202 | |||
203 | static inline void __byte_spin_lock(raw_spinlock_t *lock) | ||
204 | { | ||
205 | struct __byte_spinlock *bl = (struct __byte_spinlock *)lock; | ||
206 | s8 val = 1; | ||
207 | |||
208 | asm("1: xchgb %1, %0\n" | ||
209 | " test %1,%1\n" | ||
210 | " jz 3f\n" | ||
211 | " " LOCK_PREFIX "incb %2\n" | ||
212 | "2: rep;nop\n" | ||
213 | " cmpb $1, %0\n" | ||
214 | " je 2b\n" | ||
215 | " " LOCK_PREFIX "decb %2\n" | ||
216 | " jmp 1b\n" | ||
217 | "3:" | ||
218 | : "+m" (bl->lock), "+q" (val), "+m" (bl->spinners): : "memory"); | ||
219 | } | ||
220 | |||
221 | static inline int __byte_spin_trylock(raw_spinlock_t *lock) | ||
222 | { | ||
223 | struct __byte_spinlock *bl = (struct __byte_spinlock *)lock; | ||
224 | u8 old = 1; | ||
225 | |||
226 | asm("xchgb %1,%0" | ||
227 | : "+m" (bl->lock), "+q" (old) : : "memory"); | ||
228 | 176 | ||
229 | return old == 0; | ||
230 | } | ||
231 | |||
232 | static inline void __byte_spin_unlock(raw_spinlock_t *lock) | ||
233 | { | ||
234 | struct __byte_spinlock *bl = (struct __byte_spinlock *)lock; | ||
235 | smp_wmb(); | ||
236 | bl->lock = 0; | ||
237 | } | ||
238 | #else /* !CONFIG_PARAVIRT */ | ||
239 | static inline int __raw_spin_is_locked(raw_spinlock_t *lock) | 177 | static inline int __raw_spin_is_locked(raw_spinlock_t *lock) |
240 | { | 178 | { |
241 | return __ticket_spin_is_locked(lock); | 179 | return __ticket_spin_is_locked(lock); |
@@ -267,7 +205,7 @@ static __always_inline void __raw_spin_lock_flags(raw_spinlock_t *lock, | |||
267 | __raw_spin_lock(lock); | 205 | __raw_spin_lock(lock); |
268 | } | 206 | } |
269 | 207 | ||
270 | #endif /* CONFIG_PARAVIRT */ | 208 | #endif |
271 | 209 | ||
272 | static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock) | 210 | static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock) |
273 | { | 211 | { |
@@ -329,8 +267,7 @@ static inline int __raw_read_trylock(raw_rwlock_t *lock) | |||
329 | { | 267 | { |
330 | atomic_t *count = (atomic_t *)lock; | 268 | atomic_t *count = (atomic_t *)lock; |
331 | 269 | ||
332 | atomic_dec(count); | 270 | if (atomic_dec_return(count) >= 0) |
333 | if (atomic_read(count) >= 0) | ||
334 | return 1; | 271 | return 1; |
335 | atomic_inc(count); | 272 | atomic_inc(count); |
336 | return 0; | 273 | return 0; |
diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h new file mode 100644 index 000000000000..36a700acaf2b --- /dev/null +++ b/arch/x86/include/asm/stackprotector.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef _ASM_STACKPROTECTOR_H | ||
2 | #define _ASM_STACKPROTECTOR_H 1 | ||
3 | |||
4 | #include <asm/tsc.h> | ||
5 | #include <asm/processor.h> | ||
6 | |||
7 | /* | ||
8 | * Initialize the stackprotector canary value. | ||
9 | * | ||
10 | * NOTE: this must only be called from functions that never return, | ||
11 | * and it must always be inlined. | ||
12 | */ | ||
13 | static __always_inline void boot_init_stack_canary(void) | ||
14 | { | ||
15 | u64 canary; | ||
16 | u64 tsc; | ||
17 | |||
18 | /* | ||
19 | * Build time only check to make sure the stack_canary is at | ||
20 | * offset 40 in the pda; this is a gcc ABI requirement | ||
21 | */ | ||
22 | BUILD_BUG_ON(offsetof(union irq_stack_union, stack_canary) != 40); | ||
23 | |||
24 | /* | ||
25 | * We both use the random pool and the current TSC as a source | ||
26 | * of randomness. The TSC only matters for very early init, | ||
27 | * there it already has some randomness on most systems. Later | ||
28 | * on during the bootup the random pool has true entropy too. | ||
29 | */ | ||
30 | get_random_bytes(&canary, sizeof(canary)); | ||
31 | tsc = __native_read_tsc(); | ||
32 | canary += tsc + (tsc << 32UL); | ||
33 | |||
34 | current->stack_canary = canary; | ||
35 | percpu_write(irq_stack_union.stack_canary, canary); | ||
36 | } | ||
37 | |||
38 | #endif | ||
diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h index 9c6797c3e56c..c0b0bda754ee 100644 --- a/arch/x86/include/asm/syscalls.h +++ b/arch/x86/include/asm/syscalls.h | |||
@@ -40,7 +40,7 @@ asmlinkage int sys_sigaction(int, const struct old_sigaction __user *, | |||
40 | struct old_sigaction __user *); | 40 | struct old_sigaction __user *); |
41 | asmlinkage int sys_sigaltstack(unsigned long); | 41 | asmlinkage int sys_sigaltstack(unsigned long); |
42 | asmlinkage unsigned long sys_sigreturn(unsigned long); | 42 | asmlinkage unsigned long sys_sigreturn(unsigned long); |
43 | asmlinkage int sys_rt_sigreturn(struct pt_regs); | 43 | asmlinkage int sys_rt_sigreturn(unsigned long); |
44 | 44 | ||
45 | /* kernel/ioport.c */ | 45 | /* kernel/ioport.c */ |
46 | asmlinkage long sys_iopl(unsigned long); | 46 | asmlinkage long sys_iopl(unsigned long); |
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h index 8e626ea33a1a..c22383743f36 100644 --- a/arch/x86/include/asm/system.h +++ b/arch/x86/include/asm/system.h | |||
@@ -86,27 +86,44 @@ do { \ | |||
86 | , "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", \ | 86 | , "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", \ |
87 | "r12", "r13", "r14", "r15" | 87 | "r12", "r13", "r14", "r15" |
88 | 88 | ||
89 | #ifdef CONFIG_CC_STACKPROTECTOR | ||
90 | #define __switch_canary \ | ||
91 | "movq %P[task_canary](%%rsi),%%r8\n\t" \ | ||
92 | "movq %%r8,"__percpu_arg([gs_canary])"\n\t" | ||
93 | #define __switch_canary_oparam \ | ||
94 | , [gs_canary] "=m" (per_cpu_var(irq_stack_union.stack_canary)) | ||
95 | #define __switch_canary_iparam \ | ||
96 | , [task_canary] "i" (offsetof(struct task_struct, stack_canary)) | ||
97 | #else /* CC_STACKPROTECTOR */ | ||
98 | #define __switch_canary | ||
99 | #define __switch_canary_oparam | ||
100 | #define __switch_canary_iparam | ||
101 | #endif /* CC_STACKPROTECTOR */ | ||
102 | |||
89 | /* Save restore flags to clear handle leaking NT */ | 103 | /* Save restore flags to clear handle leaking NT */ |
90 | #define switch_to(prev, next, last) \ | 104 | #define switch_to(prev, next, last) \ |
91 | asm volatile(SAVE_CONTEXT \ | 105 | asm volatile(SAVE_CONTEXT \ |
92 | "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \ | 106 | "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \ |
93 | "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \ | 107 | "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \ |
94 | "call __switch_to\n\t" \ | 108 | "call __switch_to\n\t" \ |
95 | ".globl thread_return\n" \ | 109 | ".globl thread_return\n" \ |
96 | "thread_return:\n\t" \ | 110 | "thread_return:\n\t" \ |
97 | "movq %%gs:%P[pda_pcurrent],%%rsi\n\t" \ | 111 | "movq "__percpu_arg([current_task])",%%rsi\n\t" \ |
112 | __switch_canary \ | ||
98 | "movq %P[thread_info](%%rsi),%%r8\n\t" \ | 113 | "movq %P[thread_info](%%rsi),%%r8\n\t" \ |
99 | LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \ | ||
100 | "movq %%rax,%%rdi\n\t" \ | 114 | "movq %%rax,%%rdi\n\t" \ |
101 | "jc ret_from_fork\n\t" \ | 115 | "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \ |
116 | "jnz ret_from_fork\n\t" \ | ||
102 | RESTORE_CONTEXT \ | 117 | RESTORE_CONTEXT \ |
103 | : "=a" (last) \ | 118 | : "=a" (last) \ |
119 | __switch_canary_oparam \ | ||
104 | : [next] "S" (next), [prev] "D" (prev), \ | 120 | : [next] "S" (next), [prev] "D" (prev), \ |
105 | [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \ | 121 | [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \ |
106 | [ti_flags] "i" (offsetof(struct thread_info, flags)), \ | 122 | [ti_flags] "i" (offsetof(struct thread_info, flags)), \ |
107 | [tif_fork] "i" (TIF_FORK), \ | 123 | [_tif_fork] "i" (_TIF_FORK), \ |
108 | [thread_info] "i" (offsetof(struct task_struct, stack)), \ | 124 | [thread_info] "i" (offsetof(struct task_struct, stack)), \ |
109 | [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \ | 125 | [current_task] "m" (per_cpu_var(current_task)) \ |
126 | __switch_canary_iparam \ | ||
110 | : "memory", "cc" __EXTRA_CLOBBER) | 127 | : "memory", "cc" __EXTRA_CLOBBER) |
111 | #endif | 128 | #endif |
112 | 129 | ||
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 98789647baa9..df9d5f78385e 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h | |||
@@ -40,6 +40,7 @@ struct thread_info { | |||
40 | */ | 40 | */ |
41 | __u8 supervisor_stack[0]; | 41 | __u8 supervisor_stack[0]; |
42 | #endif | 42 | #endif |
43 | int uaccess_err; | ||
43 | }; | 44 | }; |
44 | 45 | ||
45 | #define INIT_THREAD_INFO(tsk) \ | 46 | #define INIT_THREAD_INFO(tsk) \ |
@@ -194,25 +195,21 @@ static inline struct thread_info *current_thread_info(void) | |||
194 | 195 | ||
195 | #else /* X86_32 */ | 196 | #else /* X86_32 */ |
196 | 197 | ||
197 | #include <asm/pda.h> | 198 | #include <asm/percpu.h> |
199 | #define KERNEL_STACK_OFFSET (5*8) | ||
198 | 200 | ||
199 | /* | 201 | /* |
200 | * macros/functions for gaining access to the thread information structure | 202 | * macros/functions for gaining access to the thread information structure |
201 | * preempt_count needs to be 1 initially, until the scheduler is functional. | 203 | * preempt_count needs to be 1 initially, until the scheduler is functional. |
202 | */ | 204 | */ |
203 | #ifndef __ASSEMBLY__ | 205 | #ifndef __ASSEMBLY__ |
204 | static inline struct thread_info *current_thread_info(void) | 206 | DECLARE_PER_CPU(unsigned long, kernel_stack); |
205 | { | ||
206 | struct thread_info *ti; | ||
207 | ti = (void *)(read_pda(kernelstack) + PDA_STACKOFFSET - THREAD_SIZE); | ||
208 | return ti; | ||
209 | } | ||
210 | 207 | ||
211 | /* do not use in interrupt context */ | 208 | static inline struct thread_info *current_thread_info(void) |
212 | static inline struct thread_info *stack_thread_info(void) | ||
213 | { | 209 | { |
214 | struct thread_info *ti; | 210 | struct thread_info *ti; |
215 | asm("andq %%rsp,%0; " : "=r" (ti) : "0" (~(THREAD_SIZE - 1))); | 211 | ti = (void *)(percpu_read(kernel_stack) + |
212 | KERNEL_STACK_OFFSET - THREAD_SIZE); | ||
216 | return ti; | 213 | return ti; |
217 | } | 214 | } |
218 | 215 | ||
@@ -220,8 +217,8 @@ static inline struct thread_info *stack_thread_info(void) | |||
220 | 217 | ||
221 | /* how to get the thread information struct from ASM */ | 218 | /* how to get the thread information struct from ASM */ |
222 | #define GET_THREAD_INFO(reg) \ | 219 | #define GET_THREAD_INFO(reg) \ |
223 | movq %gs:pda_kernelstack,reg ; \ | 220 | movq PER_CPU_VAR(kernel_stack),reg ; \ |
224 | subq $(THREAD_SIZE-PDA_STACKOFFSET),reg | 221 | subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg |
225 | 222 | ||
226 | #endif | 223 | #endif |
227 | 224 | ||
diff --git a/arch/x86/include/asm/timex.h b/arch/x86/include/asm/timex.h index 1287dc1347d6..b5c9d45c981f 100644 --- a/arch/x86/include/asm/timex.h +++ b/arch/x86/include/asm/timex.h | |||
@@ -1,18 +1,13 @@ | |||
1 | /* x86 architecture timex specifications */ | ||
2 | #ifndef _ASM_X86_TIMEX_H | 1 | #ifndef _ASM_X86_TIMEX_H |
3 | #define _ASM_X86_TIMEX_H | 2 | #define _ASM_X86_TIMEX_H |
4 | 3 | ||
5 | #include <asm/processor.h> | 4 | #include <asm/processor.h> |
6 | #include <asm/tsc.h> | 5 | #include <asm/tsc.h> |
7 | 6 | ||
8 | #ifdef CONFIG_X86_ELAN | 7 | /* The PIT ticks at this frequency (in HZ): */ |
9 | # define PIT_TICK_RATE 1189200 /* AMD Elan has different frequency! */ | 8 | #define PIT_TICK_RATE 1193182 |
10 | #elif defined(CONFIG_X86_RDC321X) | 9 | |
11 | # define PIT_TICK_RATE 1041667 /* Underlying HZ for R8610 */ | 10 | #define CLOCK_TICK_RATE PIT_TICK_RATE |
12 | #else | ||
13 | # define PIT_TICK_RATE 1193182 /* Underlying HZ */ | ||
14 | #endif | ||
15 | #define CLOCK_TICK_RATE PIT_TICK_RATE | ||
16 | 11 | ||
17 | #define ARCH_HAS_READ_CURRENT_TIMER | 12 | #define ARCH_HAS_READ_CURRENT_TIMER |
18 | 13 | ||
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 0e7bbb549116..d3539f998f88 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h | |||
@@ -113,7 +113,7 @@ static inline void flush_tlb_range(struct vm_area_struct *vma, | |||
113 | __flush_tlb(); | 113 | __flush_tlb(); |
114 | } | 114 | } |
115 | 115 | ||
116 | static inline void native_flush_tlb_others(const cpumask_t *cpumask, | 116 | static inline void native_flush_tlb_others(const struct cpumask *cpumask, |
117 | struct mm_struct *mm, | 117 | struct mm_struct *mm, |
118 | unsigned long va) | 118 | unsigned long va) |
119 | { | 119 | { |
@@ -142,31 +142,28 @@ static inline void flush_tlb_range(struct vm_area_struct *vma, | |||
142 | flush_tlb_mm(vma->vm_mm); | 142 | flush_tlb_mm(vma->vm_mm); |
143 | } | 143 | } |
144 | 144 | ||
145 | void native_flush_tlb_others(const cpumask_t *cpumask, struct mm_struct *mm, | 145 | void native_flush_tlb_others(const struct cpumask *cpumask, |
146 | unsigned long va); | 146 | struct mm_struct *mm, unsigned long va); |
147 | 147 | ||
148 | #define TLBSTATE_OK 1 | 148 | #define TLBSTATE_OK 1 |
149 | #define TLBSTATE_LAZY 2 | 149 | #define TLBSTATE_LAZY 2 |
150 | 150 | ||
151 | #ifdef CONFIG_X86_32 | ||
152 | struct tlb_state { | 151 | struct tlb_state { |
153 | struct mm_struct *active_mm; | 152 | struct mm_struct *active_mm; |
154 | int state; | 153 | int state; |
155 | char __cacheline_padding[L1_CACHE_BYTES-8]; | ||
156 | }; | 154 | }; |
157 | DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate); | 155 | DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate); |
158 | 156 | ||
159 | void reset_lazy_tlbstate(void); | ||
160 | #else | ||
161 | static inline void reset_lazy_tlbstate(void) | 157 | static inline void reset_lazy_tlbstate(void) |
162 | { | 158 | { |
159 | percpu_write(cpu_tlbstate.state, 0); | ||
160 | percpu_write(cpu_tlbstate.active_mm, &init_mm); | ||
163 | } | 161 | } |
164 | #endif | ||
165 | 162 | ||
166 | #endif /* SMP */ | 163 | #endif /* SMP */ |
167 | 164 | ||
168 | #ifndef CONFIG_PARAVIRT | 165 | #ifndef CONFIG_PARAVIRT |
169 | #define flush_tlb_others(mask, mm, va) native_flush_tlb_others(&mask, mm, va) | 166 | #define flush_tlb_others(mask, mm, va) native_flush_tlb_others(mask, mm, va) |
170 | #endif | 167 | #endif |
171 | 168 | ||
172 | static inline void flush_tlb_kernel_range(unsigned long start, | 169 | static inline void flush_tlb_kernel_range(unsigned long start, |
@@ -175,4 +172,6 @@ static inline void flush_tlb_kernel_range(unsigned long start, | |||
175 | flush_tlb_all(); | 172 | flush_tlb_all(); |
176 | } | 173 | } |
177 | 174 | ||
175 | extern void zap_low_mappings(void); | ||
176 | |||
178 | #endif /* _ASM_X86_TLBFLUSH_H */ | 177 | #endif /* _ASM_X86_TLBFLUSH_H */ |
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index 4e2f2e0aab27..77cfb2cfb386 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h | |||
@@ -74,6 +74,8 @@ static inline const struct cpumask *cpumask_of_node(int node) | |||
74 | return &node_to_cpumask_map[node]; | 74 | return &node_to_cpumask_map[node]; |
75 | } | 75 | } |
76 | 76 | ||
77 | static inline void setup_node_to_cpumask_map(void) { } | ||
78 | |||
77 | #else /* CONFIG_X86_64 */ | 79 | #else /* CONFIG_X86_64 */ |
78 | 80 | ||
79 | /* Mappings between node number and cpus on that node. */ | 81 | /* Mappings between node number and cpus on that node. */ |
@@ -83,7 +85,8 @@ extern cpumask_t *node_to_cpumask_map; | |||
83 | DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map); | 85 | DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map); |
84 | 86 | ||
85 | /* Returns the number of the current Node. */ | 87 | /* Returns the number of the current Node. */ |
86 | #define numa_node_id() read_pda(nodenumber) | 88 | DECLARE_PER_CPU(int, node_number); |
89 | #define numa_node_id() percpu_read(node_number) | ||
87 | 90 | ||
88 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | 91 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS |
89 | extern int cpu_to_node(int cpu); | 92 | extern int cpu_to_node(int cpu); |
@@ -102,10 +105,7 @@ static inline int cpu_to_node(int cpu) | |||
102 | /* Same function but used if called before per_cpu areas are setup */ | 105 | /* Same function but used if called before per_cpu areas are setup */ |
103 | static inline int early_cpu_to_node(int cpu) | 106 | static inline int early_cpu_to_node(int cpu) |
104 | { | 107 | { |
105 | if (early_per_cpu_ptr(x86_cpu_to_node_map)) | 108 | return early_per_cpu(x86_cpu_to_node_map, cpu); |
106 | return early_per_cpu_ptr(x86_cpu_to_node_map)[cpu]; | ||
107 | |||
108 | return per_cpu(x86_cpu_to_node_map, cpu); | ||
109 | } | 109 | } |
110 | 110 | ||
111 | /* Returns a pointer to the cpumask of CPUs on Node 'node'. */ | 111 | /* Returns a pointer to the cpumask of CPUs on Node 'node'. */ |
@@ -122,6 +122,8 @@ static inline cpumask_t node_to_cpumask(int node) | |||
122 | 122 | ||
123 | #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ | 123 | #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ |
124 | 124 | ||
125 | extern void setup_node_to_cpumask_map(void); | ||
126 | |||
125 | /* | 127 | /* |
126 | * Replace default node_to_cpumask_ptr with optimized version | 128 | * Replace default node_to_cpumask_ptr with optimized version |
127 | * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)" | 129 | * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)" |
@@ -192,9 +194,20 @@ extern int __node_distance(int, int); | |||
192 | 194 | ||
193 | #else /* !CONFIG_NUMA */ | 195 | #else /* !CONFIG_NUMA */ |
194 | 196 | ||
195 | #define numa_node_id() 0 | 197 | static inline int numa_node_id(void) |
196 | #define cpu_to_node(cpu) 0 | 198 | { |
197 | #define early_cpu_to_node(cpu) 0 | 199 | return 0; |
200 | } | ||
201 | |||
202 | static inline int cpu_to_node(int cpu) | ||
203 | { | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static inline int early_cpu_to_node(int cpu) | ||
208 | { | ||
209 | return 0; | ||
210 | } | ||
198 | 211 | ||
199 | static inline const cpumask_t *cpumask_of_node(int node) | 212 | static inline const cpumask_t *cpumask_of_node(int node) |
200 | { | 213 | { |
@@ -209,6 +222,8 @@ static inline int node_to_first_cpu(int node) | |||
209 | return first_cpu(cpu_online_map); | 222 | return first_cpu(cpu_online_map); |
210 | } | 223 | } |
211 | 224 | ||
225 | static inline void setup_node_to_cpumask_map(void) { } | ||
226 | |||
212 | /* | 227 | /* |
213 | * Replace default node_to_cpumask_ptr with optimized version | 228 | * Replace default node_to_cpumask_ptr with optimized version |
214 | * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)" | 229 | * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)" |
diff --git a/arch/x86/include/asm/trampoline.h b/arch/x86/include/asm/trampoline.h index 780ba0ab94f9..90f06c25221d 100644 --- a/arch/x86/include/asm/trampoline.h +++ b/arch/x86/include/asm/trampoline.h | |||
@@ -13,6 +13,7 @@ extern unsigned char *trampoline_base; | |||
13 | 13 | ||
14 | extern unsigned long init_rsp; | 14 | extern unsigned long init_rsp; |
15 | extern unsigned long initial_code; | 15 | extern unsigned long initial_code; |
16 | extern unsigned long initial_gs; | ||
16 | 17 | ||
17 | #define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE) | 18 | #define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE) |
18 | #define TRAMPOLINE_BASE 0x6000 | 19 | #define TRAMPOLINE_BASE 0x6000 |
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 4340055b7559..0ec6de4bcb0b 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h | |||
@@ -121,7 +121,7 @@ extern int __get_user_bad(void); | |||
121 | 121 | ||
122 | #define __get_user_x(size, ret, x, ptr) \ | 122 | #define __get_user_x(size, ret, x, ptr) \ |
123 | asm volatile("call __get_user_" #size \ | 123 | asm volatile("call __get_user_" #size \ |
124 | : "=a" (ret),"=d" (x) \ | 124 | : "=a" (ret), "=d" (x) \ |
125 | : "0" (ptr)) \ | 125 | : "0" (ptr)) \ |
126 | 126 | ||
127 | /* Careful: we have to cast the result to the type of the pointer | 127 | /* Careful: we have to cast the result to the type of the pointer |
@@ -181,12 +181,12 @@ extern int __get_user_bad(void); | |||
181 | 181 | ||
182 | #define __put_user_x(size, x, ptr, __ret_pu) \ | 182 | #define __put_user_x(size, x, ptr, __ret_pu) \ |
183 | asm volatile("call __put_user_" #size : "=a" (__ret_pu) \ | 183 | asm volatile("call __put_user_" #size : "=a" (__ret_pu) \ |
184 | :"0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx") | 184 | : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx") |
185 | 185 | ||
186 | 186 | ||
187 | 187 | ||
188 | #ifdef CONFIG_X86_32 | 188 | #ifdef CONFIG_X86_32 |
189 | #define __put_user_u64(x, addr, err) \ | 189 | #define __put_user_asm_u64(x, addr, err) \ |
190 | asm volatile("1: movl %%eax,0(%2)\n" \ | 190 | asm volatile("1: movl %%eax,0(%2)\n" \ |
191 | "2: movl %%edx,4(%2)\n" \ | 191 | "2: movl %%edx,4(%2)\n" \ |
192 | "3:\n" \ | 192 | "3:\n" \ |
@@ -199,12 +199,22 @@ extern int __get_user_bad(void); | |||
199 | : "=r" (err) \ | 199 | : "=r" (err) \ |
200 | : "A" (x), "r" (addr), "i" (-EFAULT), "0" (err)) | 200 | : "A" (x), "r" (addr), "i" (-EFAULT), "0" (err)) |
201 | 201 | ||
202 | #define __put_user_asm_ex_u64(x, addr) \ | ||
203 | asm volatile("1: movl %%eax,0(%1)\n" \ | ||
204 | "2: movl %%edx,4(%1)\n" \ | ||
205 | "3:\n" \ | ||
206 | _ASM_EXTABLE(1b, 2b - 1b) \ | ||
207 | _ASM_EXTABLE(2b, 3b - 2b) \ | ||
208 | : : "A" (x), "r" (addr)) | ||
209 | |||
202 | #define __put_user_x8(x, ptr, __ret_pu) \ | 210 | #define __put_user_x8(x, ptr, __ret_pu) \ |
203 | asm volatile("call __put_user_8" : "=a" (__ret_pu) \ | 211 | asm volatile("call __put_user_8" : "=a" (__ret_pu) \ |
204 | : "A" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx") | 212 | : "A" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx") |
205 | #else | 213 | #else |
206 | #define __put_user_u64(x, ptr, retval) \ | 214 | #define __put_user_asm_u64(x, ptr, retval) \ |
207 | __put_user_asm(x, ptr, retval, "q", "", "Zr", -EFAULT) | 215 | __put_user_asm(x, ptr, retval, "q", "", "Zr", -EFAULT) |
216 | #define __put_user_asm_ex_u64(x, addr) \ | ||
217 | __put_user_asm_ex(x, addr, "q", "", "Zr") | ||
208 | #define __put_user_x8(x, ptr, __ret_pu) __put_user_x(8, x, ptr, __ret_pu) | 218 | #define __put_user_x8(x, ptr, __ret_pu) __put_user_x(8, x, ptr, __ret_pu) |
209 | #endif | 219 | #endif |
210 | 220 | ||
@@ -276,10 +286,31 @@ do { \ | |||
276 | __put_user_asm(x, ptr, retval, "w", "w", "ir", errret); \ | 286 | __put_user_asm(x, ptr, retval, "w", "w", "ir", errret); \ |
277 | break; \ | 287 | break; \ |
278 | case 4: \ | 288 | case 4: \ |
279 | __put_user_asm(x, ptr, retval, "l", "k", "ir", errret);\ | 289 | __put_user_asm(x, ptr, retval, "l", "k", "ir", errret); \ |
280 | break; \ | 290 | break; \ |
281 | case 8: \ | 291 | case 8: \ |
282 | __put_user_u64((__typeof__(*ptr))(x), ptr, retval); \ | 292 | __put_user_asm_u64((__typeof__(*ptr))(x), ptr, retval); \ |
293 | break; \ | ||
294 | default: \ | ||
295 | __put_user_bad(); \ | ||
296 | } \ | ||
297 | } while (0) | ||
298 | |||
299 | #define __put_user_size_ex(x, ptr, size) \ | ||
300 | do { \ | ||
301 | __chk_user_ptr(ptr); \ | ||
302 | switch (size) { \ | ||
303 | case 1: \ | ||
304 | __put_user_asm_ex(x, ptr, "b", "b", "iq"); \ | ||
305 | break; \ | ||
306 | case 2: \ | ||
307 | __put_user_asm_ex(x, ptr, "w", "w", "ir"); \ | ||
308 | break; \ | ||
309 | case 4: \ | ||
310 | __put_user_asm_ex(x, ptr, "l", "k", "ir"); \ | ||
311 | break; \ | ||
312 | case 8: \ | ||
313 | __put_user_asm_ex_u64((__typeof__(*ptr))(x), ptr); \ | ||
283 | break; \ | 314 | break; \ |
284 | default: \ | 315 | default: \ |
285 | __put_user_bad(); \ | 316 | __put_user_bad(); \ |
@@ -311,9 +342,12 @@ do { \ | |||
311 | 342 | ||
312 | #ifdef CONFIG_X86_32 | 343 | #ifdef CONFIG_X86_32 |
313 | #define __get_user_asm_u64(x, ptr, retval, errret) (x) = __get_user_bad() | 344 | #define __get_user_asm_u64(x, ptr, retval, errret) (x) = __get_user_bad() |
345 | #define __get_user_asm_ex_u64(x, ptr) (x) = __get_user_bad() | ||
314 | #else | 346 | #else |
315 | #define __get_user_asm_u64(x, ptr, retval, errret) \ | 347 | #define __get_user_asm_u64(x, ptr, retval, errret) \ |
316 | __get_user_asm(x, ptr, retval, "q", "", "=r", errret) | 348 | __get_user_asm(x, ptr, retval, "q", "", "=r", errret) |
349 | #define __get_user_asm_ex_u64(x, ptr) \ | ||
350 | __get_user_asm_ex(x, ptr, "q", "", "=r") | ||
317 | #endif | 351 | #endif |
318 | 352 | ||
319 | #define __get_user_size(x, ptr, size, retval, errret) \ | 353 | #define __get_user_size(x, ptr, size, retval, errret) \ |
@@ -350,6 +384,33 @@ do { \ | |||
350 | : "=r" (err), ltype(x) \ | 384 | : "=r" (err), ltype(x) \ |
351 | : "m" (__m(addr)), "i" (errret), "0" (err)) | 385 | : "m" (__m(addr)), "i" (errret), "0" (err)) |
352 | 386 | ||
387 | #define __get_user_size_ex(x, ptr, size) \ | ||
388 | do { \ | ||
389 | __chk_user_ptr(ptr); \ | ||
390 | switch (size) { \ | ||
391 | case 1: \ | ||
392 | __get_user_asm_ex(x, ptr, "b", "b", "=q"); \ | ||
393 | break; \ | ||
394 | case 2: \ | ||
395 | __get_user_asm_ex(x, ptr, "w", "w", "=r"); \ | ||
396 | break; \ | ||
397 | case 4: \ | ||
398 | __get_user_asm_ex(x, ptr, "l", "k", "=r"); \ | ||
399 | break; \ | ||
400 | case 8: \ | ||
401 | __get_user_asm_ex_u64(x, ptr); \ | ||
402 | break; \ | ||
403 | default: \ | ||
404 | (x) = __get_user_bad(); \ | ||
405 | } \ | ||
406 | } while (0) | ||
407 | |||
408 | #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \ | ||
409 | asm volatile("1: mov"itype" %1,%"rtype"0\n" \ | ||
410 | "2:\n" \ | ||
411 | _ASM_EXTABLE(1b, 2b - 1b) \ | ||
412 | : ltype(x) : "m" (__m(addr))) | ||
413 | |||
353 | #define __put_user_nocheck(x, ptr, size) \ | 414 | #define __put_user_nocheck(x, ptr, size) \ |
354 | ({ \ | 415 | ({ \ |
355 | int __pu_err; \ | 416 | int __pu_err; \ |
@@ -385,6 +446,26 @@ struct __large_struct { unsigned long buf[100]; }; | |||
385 | _ASM_EXTABLE(1b, 3b) \ | 446 | _ASM_EXTABLE(1b, 3b) \ |
386 | : "=r"(err) \ | 447 | : "=r"(err) \ |
387 | : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err)) | 448 | : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err)) |
449 | |||
450 | #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \ | ||
451 | asm volatile("1: mov"itype" %"rtype"0,%1\n" \ | ||
452 | "2:\n" \ | ||
453 | _ASM_EXTABLE(1b, 2b - 1b) \ | ||
454 | : : ltype(x), "m" (__m(addr))) | ||
455 | |||
456 | /* | ||
457 | * uaccess_try and catch | ||
458 | */ | ||
459 | #define uaccess_try do { \ | ||
460 | int prev_err = current_thread_info()->uaccess_err; \ | ||
461 | current_thread_info()->uaccess_err = 0; \ | ||
462 | barrier(); | ||
463 | |||
464 | #define uaccess_catch(err) \ | ||
465 | (err) |= current_thread_info()->uaccess_err; \ | ||
466 | current_thread_info()->uaccess_err = prev_err; \ | ||
467 | } while (0) | ||
468 | |||
388 | /** | 469 | /** |
389 | * __get_user: - Get a simple variable from user space, with less checking. | 470 | * __get_user: - Get a simple variable from user space, with less checking. |
390 | * @x: Variable to store result. | 471 | * @x: Variable to store result. |
@@ -408,6 +489,7 @@ struct __large_struct { unsigned long buf[100]; }; | |||
408 | 489 | ||
409 | #define __get_user(x, ptr) \ | 490 | #define __get_user(x, ptr) \ |
410 | __get_user_nocheck((x), (ptr), sizeof(*(ptr))) | 491 | __get_user_nocheck((x), (ptr), sizeof(*(ptr))) |
492 | |||
411 | /** | 493 | /** |
412 | * __put_user: - Write a simple value into user space, with less checking. | 494 | * __put_user: - Write a simple value into user space, with less checking. |
413 | * @x: Value to copy to user space. | 495 | * @x: Value to copy to user space. |
@@ -435,6 +517,27 @@ struct __large_struct { unsigned long buf[100]; }; | |||
435 | #define __put_user_unaligned __put_user | 517 | #define __put_user_unaligned __put_user |
436 | 518 | ||
437 | /* | 519 | /* |
520 | * {get|put}_user_try and catch | ||
521 | * | ||
522 | * get_user_try { | ||
523 | * get_user_ex(...); | ||
524 | * } get_user_catch(err) | ||
525 | */ | ||
526 | #define get_user_try uaccess_try | ||
527 | #define get_user_catch(err) uaccess_catch(err) | ||
528 | #define put_user_try uaccess_try | ||
529 | #define put_user_catch(err) uaccess_catch(err) | ||
530 | |||
531 | #define get_user_ex(x, ptr) do { \ | ||
532 | unsigned long __gue_val; \ | ||
533 | __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \ | ||
534 | (x) = (__force __typeof__(*(ptr)))__gue_val; \ | ||
535 | } while (0) | ||
536 | |||
537 | #define put_user_ex(x, ptr) \ | ||
538 | __put_user_size_ex((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) | ||
539 | |||
540 | /* | ||
438 | * movsl can be slow when source and dest are not both 8-byte aligned | 541 | * movsl can be slow when source and dest are not both 8-byte aligned |
439 | */ | 542 | */ |
440 | #ifdef CONFIG_X86_INTEL_USERCOPY | 543 | #ifdef CONFIG_X86_INTEL_USERCOPY |
diff --git a/arch/x86/include/asm/uv/uv.h b/arch/x86/include/asm/uv/uv.h new file mode 100644 index 000000000000..8ac1d7e312f3 --- /dev/null +++ b/arch/x86/include/asm/uv/uv.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef _ASM_X86_UV_UV_H | ||
2 | #define _ASM_X86_UV_UV_H | ||
3 | |||
4 | enum uv_system_type {UV_NONE, UV_LEGACY_APIC, UV_X2APIC, UV_NON_UNIQUE_APIC}; | ||
5 | |||
6 | #ifdef CONFIG_X86_UV | ||
7 | |||
8 | extern enum uv_system_type get_uv_system_type(void); | ||
9 | extern int is_uv_system(void); | ||
10 | extern void uv_cpu_init(void); | ||
11 | extern void uv_system_init(void); | ||
12 | extern int uv_wakeup_secondary(int phys_apicid, unsigned int start_rip); | ||
13 | extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, | ||
14 | struct mm_struct *mm, | ||
15 | unsigned long va, | ||
16 | unsigned int cpu); | ||
17 | |||
18 | #else /* X86_UV */ | ||
19 | |||
20 | static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; } | ||
21 | static inline int is_uv_system(void) { return 0; } | ||
22 | static inline void uv_cpu_init(void) { } | ||
23 | static inline void uv_system_init(void) { } | ||
24 | static inline int uv_wakeup_secondary(int phys_apicid, unsigned int start_rip) | ||
25 | { return 1; } | ||
26 | static inline const struct cpumask * | ||
27 | uv_flush_tlb_others(const struct cpumask *cpumask, struct mm_struct *mm, | ||
28 | unsigned long va, unsigned int cpu) | ||
29 | { return cpumask; } | ||
30 | |||
31 | #endif /* X86_UV */ | ||
32 | |||
33 | #endif /* _ASM_X86_UV_UV_H */ | ||
diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h index 50423c7b56b2..9b0e61bf7a88 100644 --- a/arch/x86/include/asm/uv/uv_bau.h +++ b/arch/x86/include/asm/uv/uv_bau.h | |||
@@ -325,7 +325,6 @@ static inline void bau_cpubits_clear(struct bau_local_cpumask *dstp, int nbits) | |||
325 | #define cpubit_isset(cpu, bau_local_cpumask) \ | 325 | #define cpubit_isset(cpu, bau_local_cpumask) \ |
326 | test_bit((cpu), (bau_local_cpumask).bits) | 326 | test_bit((cpu), (bau_local_cpumask).bits) |
327 | 327 | ||
328 | extern int uv_flush_tlb_others(cpumask_t *, struct mm_struct *, unsigned long); | ||
329 | extern void uv_bau_message_intr1(void); | 328 | extern void uv_bau_message_intr1(void); |
330 | extern void uv_bau_timeout_intr1(void); | 329 | extern void uv_bau_timeout_intr1(void); |
331 | 330 | ||
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index d364df03c1d6..37fa30bada17 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
@@ -23,11 +23,12 @@ nostackp := $(call cc-option, -fno-stack-protector) | |||
23 | CFLAGS_vsyscall_64.o := $(PROFILING) -g0 $(nostackp) | 23 | CFLAGS_vsyscall_64.o := $(PROFILING) -g0 $(nostackp) |
24 | CFLAGS_hpet.o := $(nostackp) | 24 | CFLAGS_hpet.o := $(nostackp) |
25 | CFLAGS_tsc.o := $(nostackp) | 25 | CFLAGS_tsc.o := $(nostackp) |
26 | CFLAGS_paravirt.o := $(nostackp) | ||
26 | 27 | ||
27 | obj-y := process_$(BITS).o signal.o entry_$(BITS).o | 28 | obj-y := process_$(BITS).o signal.o entry_$(BITS).o |
28 | obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o | 29 | obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o |
29 | obj-y += time_$(BITS).o ioport.o ldt.o dumpstack.o | 30 | obj-y += time_$(BITS).o ioport.o ldt.o dumpstack.o |
30 | obj-y += setup.o i8259.o irqinit_$(BITS).o setup_percpu.o | 31 | obj-y += setup.o i8259.o irqinit_$(BITS).o |
31 | obj-$(CONFIG_X86_VISWS) += visws_quirks.o | 32 | obj-$(CONFIG_X86_VISWS) += visws_quirks.o |
32 | obj-$(CONFIG_X86_32) += probe_roms_32.o | 33 | obj-$(CONFIG_X86_32) += probe_roms_32.o |
33 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o | 34 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o |
@@ -57,9 +58,9 @@ obj-$(CONFIG_PCI) += early-quirks.o | |||
57 | apm-y := apm_32.o | 58 | apm-y := apm_32.o |
58 | obj-$(CONFIG_APM) += apm.o | 59 | obj-$(CONFIG_APM) += apm.o |
59 | obj-$(CONFIG_X86_SMP) += smp.o | 60 | obj-$(CONFIG_X86_SMP) += smp.o |
60 | obj-$(CONFIG_X86_SMP) += smpboot.o tsc_sync.o ipi.o tlb_$(BITS).o | 61 | obj-$(CONFIG_X86_SMP) += smpboot.o tsc_sync.o ipi.o |
61 | obj-$(CONFIG_X86_32_SMP) += smpcommon.o | 62 | obj-$(CONFIG_SMP) += setup_percpu.o |
62 | obj-$(CONFIG_X86_64_SMP) += tsc_sync.o smpcommon.o | 63 | obj-$(CONFIG_X86_64_SMP) += tsc_sync.o |
63 | obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o | 64 | obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o |
64 | obj-$(CONFIG_X86_MPPARSE) += mpparse.o | 65 | obj-$(CONFIG_X86_MPPARSE) += mpparse.o |
65 | obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o | 66 | obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o |
@@ -114,10 +115,11 @@ obj-$(CONFIG_SWIOTLB) += pci-swiotlb_64.o # NB rename without _64 | |||
114 | ### | 115 | ### |
115 | # 64 bit specific files | 116 | # 64 bit specific files |
116 | ifeq ($(CONFIG_X86_64),y) | 117 | ifeq ($(CONFIG_X86_64),y) |
117 | obj-y += genapic_64.o genapic_flat_64.o genx2apic_uv_x.o tlb_uv.o | 118 | obj-y += genapic_64.o genapic_flat_64.o |
118 | obj-y += bios_uv.o uv_irq.o uv_sysfs.o | ||
119 | obj-y += genx2apic_cluster.o | 119 | obj-y += genx2apic_cluster.o |
120 | obj-y += genx2apic_phys.o | 120 | obj-y += genx2apic_phys.o |
121 | obj-$(CONFIG_X86_UV) += genx2apic_uv_x.o tlb_uv.o | ||
122 | obj-$(CONFIG_X86_UV) += bios_uv.o uv_irq.o uv_sysfs.o | ||
121 | obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o | 123 | obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o |
122 | obj-$(CONFIG_AUDIT) += audit_64.o | 124 | obj-$(CONFIG_AUDIT) += audit_64.o |
123 | 125 | ||
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index d37593c2f438..4cb5964f1499 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -912,8 +912,8 @@ static u8 __init uniq_ioapic_id(u8 id) | |||
912 | DECLARE_BITMAP(used, 256); | 912 | DECLARE_BITMAP(used, 256); |
913 | bitmap_zero(used, 256); | 913 | bitmap_zero(used, 256); |
914 | for (i = 0; i < nr_ioapics; i++) { | 914 | for (i = 0; i < nr_ioapics; i++) { |
915 | struct mp_config_ioapic *ia = &mp_ioapics[i]; | 915 | struct mpc_ioapic *ia = &mp_ioapics[i]; |
916 | __set_bit(ia->mp_apicid, used); | 916 | __set_bit(ia->apicid, used); |
917 | } | 917 | } |
918 | if (!test_bit(id, used)) | 918 | if (!test_bit(id, used)) |
919 | return id; | 919 | return id; |
@@ -945,47 +945,47 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base) | |||
945 | 945 | ||
946 | idx = nr_ioapics; | 946 | idx = nr_ioapics; |
947 | 947 | ||
948 | mp_ioapics[idx].mp_type = MP_IOAPIC; | 948 | mp_ioapics[idx].type = MP_IOAPIC; |
949 | mp_ioapics[idx].mp_flags = MPC_APIC_USABLE; | 949 | mp_ioapics[idx].flags = MPC_APIC_USABLE; |
950 | mp_ioapics[idx].mp_apicaddr = address; | 950 | mp_ioapics[idx].apicaddr = address; |
951 | 951 | ||
952 | set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); | 952 | set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); |
953 | mp_ioapics[idx].mp_apicid = uniq_ioapic_id(id); | 953 | mp_ioapics[idx].apicid = uniq_ioapic_id(id); |
954 | #ifdef CONFIG_X86_32 | 954 | #ifdef CONFIG_X86_32 |
955 | mp_ioapics[idx].mp_apicver = io_apic_get_version(idx); | 955 | mp_ioapics[idx].apicver = io_apic_get_version(idx); |
956 | #else | 956 | #else |
957 | mp_ioapics[idx].mp_apicver = 0; | 957 | mp_ioapics[idx].apicver = 0; |
958 | #endif | 958 | #endif |
959 | /* | 959 | /* |
960 | * Build basic GSI lookup table to facilitate gsi->io_apic lookups | 960 | * Build basic GSI lookup table to facilitate gsi->io_apic lookups |
961 | * and to prevent reprogramming of IOAPIC pins (PCI GSIs). | 961 | * and to prevent reprogramming of IOAPIC pins (PCI GSIs). |
962 | */ | 962 | */ |
963 | mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mp_apicid; | 963 | mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].apicid; |
964 | mp_ioapic_routing[idx].gsi_base = gsi_base; | 964 | mp_ioapic_routing[idx].gsi_base = gsi_base; |
965 | mp_ioapic_routing[idx].gsi_end = gsi_base + | 965 | mp_ioapic_routing[idx].gsi_end = gsi_base + |
966 | io_apic_get_redir_entries(idx); | 966 | io_apic_get_redir_entries(idx); |
967 | 967 | ||
968 | printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%lx, " | 968 | printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, " |
969 | "GSI %d-%d\n", idx, mp_ioapics[idx].mp_apicid, | 969 | "GSI %d-%d\n", idx, mp_ioapics[idx].apicid, |
970 | mp_ioapics[idx].mp_apicver, mp_ioapics[idx].mp_apicaddr, | 970 | mp_ioapics[idx].apicver, mp_ioapics[idx].apicaddr, |
971 | mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end); | 971 | mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end); |
972 | 972 | ||
973 | nr_ioapics++; | 973 | nr_ioapics++; |
974 | } | 974 | } |
975 | 975 | ||
976 | static void assign_to_mp_irq(struct mp_config_intsrc *m, | 976 | static void assign_to_mp_irq(struct mpc_intsrc *m, |
977 | struct mp_config_intsrc *mp_irq) | 977 | struct mpc_intsrc *mp_irq) |
978 | { | 978 | { |
979 | memcpy(mp_irq, m, sizeof(struct mp_config_intsrc)); | 979 | memcpy(mp_irq, m, sizeof(struct mpc_intsrc)); |
980 | } | 980 | } |
981 | 981 | ||
982 | static int mp_irq_cmp(struct mp_config_intsrc *mp_irq, | 982 | static int mp_irq_cmp(struct mpc_intsrc *mp_irq, |
983 | struct mp_config_intsrc *m) | 983 | struct mpc_intsrc *m) |
984 | { | 984 | { |
985 | return memcmp(mp_irq, m, sizeof(struct mp_config_intsrc)); | 985 | return memcmp(mp_irq, m, sizeof(struct mpc_intsrc)); |
986 | } | 986 | } |
987 | 987 | ||
988 | static void save_mp_irq(struct mp_config_intsrc *m) | 988 | static void save_mp_irq(struct mpc_intsrc *m) |
989 | { | 989 | { |
990 | int i; | 990 | int i; |
991 | 991 | ||
@@ -1003,7 +1003,7 @@ void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi) | |||
1003 | { | 1003 | { |
1004 | int ioapic; | 1004 | int ioapic; |
1005 | int pin; | 1005 | int pin; |
1006 | struct mp_config_intsrc mp_irq; | 1006 | struct mpc_intsrc mp_irq; |
1007 | 1007 | ||
1008 | /* | 1008 | /* |
1009 | * Convert 'gsi' to 'ioapic.pin'. | 1009 | * Convert 'gsi' to 'ioapic.pin'. |
@@ -1021,13 +1021,13 @@ void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi) | |||
1021 | if ((bus_irq == 0) && (trigger == 3)) | 1021 | if ((bus_irq == 0) && (trigger == 3)) |
1022 | trigger = 1; | 1022 | trigger = 1; |
1023 | 1023 | ||
1024 | mp_irq.mp_type = MP_INTSRC; | 1024 | mp_irq.type = MP_INTSRC; |
1025 | mp_irq.mp_irqtype = mp_INT; | 1025 | mp_irq.irqtype = mp_INT; |
1026 | mp_irq.mp_irqflag = (trigger << 2) | polarity; | 1026 | mp_irq.irqflag = (trigger << 2) | polarity; |
1027 | mp_irq.mp_srcbus = MP_ISA_BUS; | 1027 | mp_irq.srcbus = MP_ISA_BUS; |
1028 | mp_irq.mp_srcbusirq = bus_irq; /* IRQ */ | 1028 | mp_irq.srcbusirq = bus_irq; /* IRQ */ |
1029 | mp_irq.mp_dstapic = mp_ioapics[ioapic].mp_apicid; /* APIC ID */ | 1029 | mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */ |
1030 | mp_irq.mp_dstirq = pin; /* INTIN# */ | 1030 | mp_irq.dstirq = pin; /* INTIN# */ |
1031 | 1031 | ||
1032 | save_mp_irq(&mp_irq); | 1032 | save_mp_irq(&mp_irq); |
1033 | } | 1033 | } |
@@ -1037,7 +1037,7 @@ void __init mp_config_acpi_legacy_irqs(void) | |||
1037 | int i; | 1037 | int i; |
1038 | int ioapic; | 1038 | int ioapic; |
1039 | unsigned int dstapic; | 1039 | unsigned int dstapic; |
1040 | struct mp_config_intsrc mp_irq; | 1040 | struct mpc_intsrc mp_irq; |
1041 | 1041 | ||
1042 | #if defined (CONFIG_MCA) || defined (CONFIG_EISA) | 1042 | #if defined (CONFIG_MCA) || defined (CONFIG_EISA) |
1043 | /* | 1043 | /* |
@@ -1062,7 +1062,7 @@ void __init mp_config_acpi_legacy_irqs(void) | |||
1062 | ioapic = mp_find_ioapic(0); | 1062 | ioapic = mp_find_ioapic(0); |
1063 | if (ioapic < 0) | 1063 | if (ioapic < 0) |
1064 | return; | 1064 | return; |
1065 | dstapic = mp_ioapics[ioapic].mp_apicid; | 1065 | dstapic = mp_ioapics[ioapic].apicid; |
1066 | 1066 | ||
1067 | /* | 1067 | /* |
1068 | * Use the default configuration for the IRQs 0-15. Unless | 1068 | * Use the default configuration for the IRQs 0-15. Unless |
@@ -1072,16 +1072,14 @@ void __init mp_config_acpi_legacy_irqs(void) | |||
1072 | int idx; | 1072 | int idx; |
1073 | 1073 | ||
1074 | for (idx = 0; idx < mp_irq_entries; idx++) { | 1074 | for (idx = 0; idx < mp_irq_entries; idx++) { |
1075 | struct mp_config_intsrc *irq = mp_irqs + idx; | 1075 | struct mpc_intsrc *irq = mp_irqs + idx; |
1076 | 1076 | ||
1077 | /* Do we already have a mapping for this ISA IRQ? */ | 1077 | /* Do we already have a mapping for this ISA IRQ? */ |
1078 | if (irq->mp_srcbus == MP_ISA_BUS | 1078 | if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i) |
1079 | && irq->mp_srcbusirq == i) | ||
1080 | break; | 1079 | break; |
1081 | 1080 | ||
1082 | /* Do we already have a mapping for this IOAPIC pin */ | 1081 | /* Do we already have a mapping for this IOAPIC pin */ |
1083 | if (irq->mp_dstapic == dstapic && | 1082 | if (irq->dstapic == dstapic && irq->dstirq == i) |
1084 | irq->mp_dstirq == i) | ||
1085 | break; | 1083 | break; |
1086 | } | 1084 | } |
1087 | 1085 | ||
@@ -1090,13 +1088,13 @@ void __init mp_config_acpi_legacy_irqs(void) | |||
1090 | continue; /* IRQ already used */ | 1088 | continue; /* IRQ already used */ |
1091 | } | 1089 | } |
1092 | 1090 | ||
1093 | mp_irq.mp_type = MP_INTSRC; | 1091 | mp_irq.type = MP_INTSRC; |
1094 | mp_irq.mp_irqflag = 0; /* Conforming */ | 1092 | mp_irq.irqflag = 0; /* Conforming */ |
1095 | mp_irq.mp_srcbus = MP_ISA_BUS; | 1093 | mp_irq.srcbus = MP_ISA_BUS; |
1096 | mp_irq.mp_dstapic = dstapic; | 1094 | mp_irq.dstapic = dstapic; |
1097 | mp_irq.mp_irqtype = mp_INT; | 1095 | mp_irq.irqtype = mp_INT; |
1098 | mp_irq.mp_srcbusirq = i; /* Identity mapped */ | 1096 | mp_irq.srcbusirq = i; /* Identity mapped */ |
1099 | mp_irq.mp_dstirq = i; | 1097 | mp_irq.dstirq = i; |
1100 | 1098 | ||
1101 | save_mp_irq(&mp_irq); | 1099 | save_mp_irq(&mp_irq); |
1102 | } | 1100 | } |
@@ -1207,22 +1205,22 @@ int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin, | |||
1207 | u32 gsi, int triggering, int polarity) | 1205 | u32 gsi, int triggering, int polarity) |
1208 | { | 1206 | { |
1209 | #ifdef CONFIG_X86_MPPARSE | 1207 | #ifdef CONFIG_X86_MPPARSE |
1210 | struct mp_config_intsrc mp_irq; | 1208 | struct mpc_intsrc mp_irq; |
1211 | int ioapic; | 1209 | int ioapic; |
1212 | 1210 | ||
1213 | if (!acpi_ioapic) | 1211 | if (!acpi_ioapic) |
1214 | return 0; | 1212 | return 0; |
1215 | 1213 | ||
1216 | /* print the entry should happen on mptable identically */ | 1214 | /* print the entry should happen on mptable identically */ |
1217 | mp_irq.mp_type = MP_INTSRC; | 1215 | mp_irq.type = MP_INTSRC; |
1218 | mp_irq.mp_irqtype = mp_INT; | 1216 | mp_irq.irqtype = mp_INT; |
1219 | mp_irq.mp_irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) | | 1217 | mp_irq.irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) | |
1220 | (polarity == ACPI_ACTIVE_HIGH ? 1 : 3); | 1218 | (polarity == ACPI_ACTIVE_HIGH ? 1 : 3); |
1221 | mp_irq.mp_srcbus = number; | 1219 | mp_irq.srcbus = number; |
1222 | mp_irq.mp_srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3); | 1220 | mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3); |
1223 | ioapic = mp_find_ioapic(gsi); | 1221 | ioapic = mp_find_ioapic(gsi); |
1224 | mp_irq.mp_dstapic = mp_ioapic_routing[ioapic].apic_id; | 1222 | mp_irq.dstapic = mp_ioapic_routing[ioapic].apic_id; |
1225 | mp_irq.mp_dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base; | 1223 | mp_irq.dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base; |
1226 | 1224 | ||
1227 | save_mp_irq(&mp_irq); | 1225 | save_mp_irq(&mp_irq); |
1228 | #endif | 1226 | #endif |
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index 707c1f6f95fa..4abff454c55b 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c | |||
@@ -101,6 +101,7 @@ int acpi_save_state_mem(void) | |||
101 | stack_start.sp = temp_stack + sizeof(temp_stack); | 101 | stack_start.sp = temp_stack + sizeof(temp_stack); |
102 | early_gdt_descr.address = | 102 | early_gdt_descr.address = |
103 | (unsigned long)get_cpu_gdt_table(smp_processor_id()); | 103 | (unsigned long)get_cpu_gdt_table(smp_processor_id()); |
104 | initial_gs = per_cpu_offset(smp_processor_id()); | ||
104 | #endif | 105 | #endif |
105 | initial_code = (unsigned long)wakeup_long64; | 106 | initial_code = (unsigned long)wakeup_long64; |
106 | saved_magic = 0x123456789abcdef0; | 107 | saved_magic = 0x123456789abcdef0; |
diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 566a08466b19..c6f15647eba9 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <asm/proto.h> | 47 | #include <asm/proto.h> |
48 | #include <asm/apic.h> | 48 | #include <asm/apic.h> |
49 | #include <asm/i8259.h> | 49 | #include <asm/i8259.h> |
50 | #include <asm/smp.h> | ||
50 | 51 | ||
51 | #include <mach_apic.h> | 52 | #include <mach_apic.h> |
52 | #include <mach_apicdef.h> | 53 | #include <mach_apicdef.h> |
@@ -59,6 +60,24 @@ | |||
59 | # error SPURIOUS_APIC_VECTOR definition error | 60 | # error SPURIOUS_APIC_VECTOR definition error |
60 | #endif | 61 | #endif |
61 | 62 | ||
63 | unsigned int num_processors; | ||
64 | unsigned disabled_cpus __cpuinitdata; | ||
65 | /* Processor that is doing the boot up */ | ||
66 | unsigned int boot_cpu_physical_apicid = -1U; | ||
67 | EXPORT_SYMBOL(boot_cpu_physical_apicid); | ||
68 | unsigned int max_physical_apicid; | ||
69 | |||
70 | /* Bitmask of physically existing CPUs */ | ||
71 | physid_mask_t phys_cpu_present_map; | ||
72 | |||
73 | /* | ||
74 | * Map cpu index to physical APIC ID | ||
75 | */ | ||
76 | DEFINE_EARLY_PER_CPU(u16, x86_cpu_to_apicid, BAD_APICID); | ||
77 | DEFINE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid, BAD_APICID); | ||
78 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid); | ||
79 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid); | ||
80 | |||
62 | #ifdef CONFIG_X86_32 | 81 | #ifdef CONFIG_X86_32 |
63 | /* | 82 | /* |
64 | * Knob to control our willingness to enable the local APIC. | 83 | * Knob to control our willingness to enable the local APIC. |
@@ -894,6 +913,10 @@ void disable_local_APIC(void) | |||
894 | { | 913 | { |
895 | unsigned int value; | 914 | unsigned int value; |
896 | 915 | ||
916 | /* APIC hasn't been mapped yet */ | ||
917 | if (!apic_phys) | ||
918 | return; | ||
919 | |||
897 | clear_local_APIC(); | 920 | clear_local_APIC(); |
898 | 921 | ||
899 | /* | 922 | /* |
@@ -1125,6 +1148,13 @@ void __cpuinit setup_local_APIC(void) | |||
1125 | unsigned int value; | 1148 | unsigned int value; |
1126 | int i, j; | 1149 | int i, j; |
1127 | 1150 | ||
1151 | if (disable_apic) { | ||
1152 | #ifdef CONFIG_X86_IO_APIC | ||
1153 | disable_ioapic_setup(); | ||
1154 | #endif | ||
1155 | return; | ||
1156 | } | ||
1157 | |||
1128 | #ifdef CONFIG_X86_32 | 1158 | #ifdef CONFIG_X86_32 |
1129 | /* Pound the ESR really hard over the head with a big hammer - mbligh */ | 1159 | /* Pound the ESR really hard over the head with a big hammer - mbligh */ |
1130 | if (lapic_is_integrated() && esr_disable) { | 1160 | if (lapic_is_integrated() && esr_disable) { |
@@ -1565,11 +1595,11 @@ int apic_version[MAX_APICS]; | |||
1565 | 1595 | ||
1566 | int __init APIC_init_uniprocessor(void) | 1596 | int __init APIC_init_uniprocessor(void) |
1567 | { | 1597 | { |
1568 | #ifdef CONFIG_X86_64 | ||
1569 | if (disable_apic) { | 1598 | if (disable_apic) { |
1570 | pr_info("Apic disabled\n"); | 1599 | pr_info("Apic disabled\n"); |
1571 | return -1; | 1600 | return -1; |
1572 | } | 1601 | } |
1602 | #ifdef CONFIG_X86_64 | ||
1573 | if (!cpu_has_apic) { | 1603 | if (!cpu_has_apic) { |
1574 | disable_apic = 1; | 1604 | disable_apic = 1; |
1575 | pr_info("Apic disabled by BIOS\n"); | 1605 | pr_info("Apic disabled by BIOS\n"); |
@@ -1832,6 +1862,11 @@ void __cpuinit generic_processor_info(int apicid, int version) | |||
1832 | num_processors++; | 1862 | num_processors++; |
1833 | cpu = cpumask_next_zero(-1, cpu_present_mask); | 1863 | cpu = cpumask_next_zero(-1, cpu_present_mask); |
1834 | 1864 | ||
1865 | if (version != apic_version[boot_cpu_physical_apicid]) | ||
1866 | WARN_ONCE(1, | ||
1867 | "ACPI: apic version mismatch, bootcpu: %x cpu %d: %x\n", | ||
1868 | apic_version[boot_cpu_physical_apicid], cpu, version); | ||
1869 | |||
1835 | physid_set(apicid, phys_cpu_present_map); | 1870 | physid_set(apicid, phys_cpu_present_map); |
1836 | if (apicid == boot_cpu_physical_apicid) { | 1871 | if (apicid == boot_cpu_physical_apicid) { |
1837 | /* | 1872 | /* |
@@ -1867,17 +1902,8 @@ void __cpuinit generic_processor_info(int apicid, int version) | |||
1867 | #endif | 1902 | #endif |
1868 | 1903 | ||
1869 | #if defined(CONFIG_X86_SMP) || defined(CONFIG_X86_64) | 1904 | #if defined(CONFIG_X86_SMP) || defined(CONFIG_X86_64) |
1870 | /* are we being called early in kernel startup? */ | 1905 | early_per_cpu(x86_cpu_to_apicid, cpu) = apicid; |
1871 | if (early_per_cpu_ptr(x86_cpu_to_apicid)) { | 1906 | early_per_cpu(x86_bios_cpu_apicid, cpu) = apicid; |
1872 | u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid); | ||
1873 | u16 *bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid); | ||
1874 | |||
1875 | cpu_to_apicid[cpu] = apicid; | ||
1876 | bios_cpu_apicid[cpu] = apicid; | ||
1877 | } else { | ||
1878 | per_cpu(x86_cpu_to_apicid, cpu) = apicid; | ||
1879 | per_cpu(x86_bios_cpu_apicid, cpu) = apicid; | ||
1880 | } | ||
1881 | #endif | 1907 | #endif |
1882 | 1908 | ||
1883 | set_cpu_possible(cpu, true); | 1909 | set_cpu_possible(cpu, true); |
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c index 1d41d3f1edbc..8793ab33e2c1 100644 --- a/arch/x86/kernel/asm-offsets_64.c +++ b/arch/x86/kernel/asm-offsets_64.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/hardirq.h> | 11 | #include <linux/hardirq.h> |
12 | #include <linux/suspend.h> | 12 | #include <linux/suspend.h> |
13 | #include <linux/kbuild.h> | 13 | #include <linux/kbuild.h> |
14 | #include <asm/pda.h> | ||
15 | #include <asm/processor.h> | 14 | #include <asm/processor.h> |
16 | #include <asm/segment.h> | 15 | #include <asm/segment.h> |
17 | #include <asm/thread_info.h> | 16 | #include <asm/thread_info.h> |
@@ -48,16 +47,6 @@ int main(void) | |||
48 | #endif | 47 | #endif |
49 | BLANK(); | 48 | BLANK(); |
50 | #undef ENTRY | 49 | #undef ENTRY |
51 | #define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry)) | ||
52 | ENTRY(kernelstack); | ||
53 | ENTRY(oldrsp); | ||
54 | ENTRY(pcurrent); | ||
55 | ENTRY(irqcount); | ||
56 | ENTRY(cpunumber); | ||
57 | ENTRY(irqstackptr); | ||
58 | ENTRY(data_offset); | ||
59 | BLANK(); | ||
60 | #undef ENTRY | ||
61 | #ifdef CONFIG_PARAVIRT | 50 | #ifdef CONFIG_PARAVIRT |
62 | BLANK(); | 51 | BLANK(); |
63 | OFFSET(PARAVIRT_enabled, pv_info, paravirt_enabled); | 52 | OFFSET(PARAVIRT_enabled, pv_info, paravirt_enabled); |
diff --git a/arch/x86/kernel/cpu/addon_cpuid_features.c b/arch/x86/kernel/cpu/addon_cpuid_features.c index 2cf23634b6d9..4e581fdc0a5a 100644 --- a/arch/x86/kernel/cpu/addon_cpuid_features.c +++ b/arch/x86/kernel/cpu/addon_cpuid_features.c | |||
@@ -143,37 +143,3 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) | |||
143 | return; | 143 | return; |
144 | #endif | 144 | #endif |
145 | } | 145 | } |
146 | |||
147 | #ifdef CONFIG_X86_PAT | ||
148 | void __cpuinit validate_pat_support(struct cpuinfo_x86 *c) | ||
149 | { | ||
150 | if (!cpu_has_pat) | ||
151 | pat_disable("PAT not supported by CPU."); | ||
152 | |||
153 | switch (c->x86_vendor) { | ||
154 | case X86_VENDOR_INTEL: | ||
155 | /* | ||
156 | * There is a known erratum on Pentium III and Core Solo | ||
157 | * and Core Duo CPUs. | ||
158 | * " Page with PAT set to WC while associated MTRR is UC | ||
159 | * may consolidate to UC " | ||
160 | * Because of this erratum, it is better to stick with | ||
161 | * setting WC in MTRR rather than using PAT on these CPUs. | ||
162 | * | ||
163 | * Enable PAT WC only on P4, Core 2 or later CPUs. | ||
164 | */ | ||
165 | if (c->x86 > 0x6 || (c->x86 == 6 && c->x86_model >= 15)) | ||
166 | return; | ||
167 | |||
168 | pat_disable("PAT WC disabled due to known CPU erratum."); | ||
169 | return; | ||
170 | |||
171 | case X86_VENDOR_AMD: | ||
172 | case X86_VENDOR_CENTAUR: | ||
173 | case X86_VENDOR_TRANSMETA: | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | pat_disable("PAT disabled. Not yet verified on this CPU type."); | ||
178 | } | ||
179 | #endif | ||
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 83492b1f93b1..275e2cb43b91 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -21,14 +21,16 @@ | |||
21 | #include <asm/asm.h> | 21 | #include <asm/asm.h> |
22 | #include <asm/numa.h> | 22 | #include <asm/numa.h> |
23 | #include <asm/smp.h> | 23 | #include <asm/smp.h> |
24 | #include <asm/cpu.h> | ||
25 | #include <asm/cpumask.h> | ||
24 | #ifdef CONFIG_X86_LOCAL_APIC | 26 | #ifdef CONFIG_X86_LOCAL_APIC |
25 | #include <asm/mpspec.h> | 27 | #include <asm/mpspec.h> |
26 | #include <asm/apic.h> | 28 | #include <asm/apic.h> |
27 | #include <mach_apic.h> | 29 | #include <mach_apic.h> |
28 | #include <asm/genapic.h> | 30 | #include <asm/genapic.h> |
31 | #include <asm/uv/uv.h> | ||
29 | #endif | 32 | #endif |
30 | 33 | ||
31 | #include <asm/pda.h> | ||
32 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
33 | #include <asm/processor.h> | 35 | #include <asm/processor.h> |
34 | #include <asm/desc.h> | 36 | #include <asm/desc.h> |
@@ -50,6 +52,15 @@ cpumask_var_t cpu_initialized_mask; | |||
50 | /* representing cpus for which sibling maps can be computed */ | 52 | /* representing cpus for which sibling maps can be computed */ |
51 | cpumask_var_t cpu_sibling_setup_mask; | 53 | cpumask_var_t cpu_sibling_setup_mask; |
52 | 54 | ||
55 | /* correctly size the local cpu masks */ | ||
56 | void __init setup_cpu_local_masks(void) | ||
57 | { | ||
58 | alloc_bootmem_cpumask_var(&cpu_initialized_mask); | ||
59 | alloc_bootmem_cpumask_var(&cpu_callin_mask); | ||
60 | alloc_bootmem_cpumask_var(&cpu_callout_mask); | ||
61 | alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); | ||
62 | } | ||
63 | |||
53 | #else /* CONFIG_X86_32 */ | 64 | #else /* CONFIG_X86_32 */ |
54 | 65 | ||
55 | cpumask_t cpu_callin_map; | 66 | cpumask_t cpu_callin_map; |
@@ -62,23 +73,23 @@ cpumask_t cpu_sibling_setup_map; | |||
62 | 73 | ||
63 | static struct cpu_dev *this_cpu __cpuinitdata; | 74 | static struct cpu_dev *this_cpu __cpuinitdata; |
64 | 75 | ||
76 | DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | ||
65 | #ifdef CONFIG_X86_64 | 77 | #ifdef CONFIG_X86_64 |
66 | /* We need valid kernel segments for data and code in long mode too | 78 | /* |
67 | * IRET will check the segment types kkeil 2000/10/28 | 79 | * We need valid kernel segments for data and code in long mode too |
68 | * Also sysret mandates a special GDT layout | 80 | * IRET will check the segment types kkeil 2000/10/28 |
69 | */ | 81 | * Also sysret mandates a special GDT layout |
70 | /* The TLS descriptors are currently at a different place compared to i386. | 82 | * |
71 | Hopefully nobody expects them at a fixed place (Wine?) */ | 83 | * The TLS descriptors are currently at a different place compared to i386. |
72 | DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { | 84 | * Hopefully nobody expects them at a fixed place (Wine?) |
85 | */ | ||
73 | [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } }, | 86 | [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } }, |
74 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00af9b00 } } }, | 87 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00af9b00 } } }, |
75 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9300 } } }, | 88 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9300 } } }, |
76 | [GDT_ENTRY_DEFAULT_USER32_CS] = { { { 0x0000ffff, 0x00cffb00 } } }, | 89 | [GDT_ENTRY_DEFAULT_USER32_CS] = { { { 0x0000ffff, 0x00cffb00 } } }, |
77 | [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff300 } } }, | 90 | [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff300 } } }, |
78 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00affb00 } } }, | 91 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00affb00 } } }, |
79 | } }; | ||
80 | #else | 92 | #else |
81 | DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | ||
82 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00cf9a00 } } }, | 93 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00cf9a00 } } }, |
83 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9200 } } }, | 94 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9200 } } }, |
84 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00cffa00 } } }, | 95 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00cffa00 } } }, |
@@ -110,9 +121,9 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | |||
110 | [GDT_ENTRY_APMBIOS_BASE+2] = { { { 0x0000ffff, 0x00409200 } } }, | 121 | [GDT_ENTRY_APMBIOS_BASE+2] = { { { 0x0000ffff, 0x00409200 } } }, |
111 | 122 | ||
112 | [GDT_ENTRY_ESPFIX_SS] = { { { 0x00000000, 0x00c09200 } } }, | 123 | [GDT_ENTRY_ESPFIX_SS] = { { { 0x00000000, 0x00c09200 } } }, |
113 | [GDT_ENTRY_PERCPU] = { { { 0x00000000, 0x00000000 } } }, | 124 | [GDT_ENTRY_PERCPU] = { { { 0x0000ffff, 0x00cf9200 } } }, |
114 | } }; | ||
115 | #endif | 125 | #endif |
126 | } }; | ||
116 | EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); | 127 | EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); |
117 | 128 | ||
118 | #ifdef CONFIG_X86_32 | 129 | #ifdef CONFIG_X86_32 |
@@ -213,6 +224,49 @@ static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c) | |||
213 | #endif | 224 | #endif |
214 | 225 | ||
215 | /* | 226 | /* |
227 | * Some CPU features depend on higher CPUID levels, which may not always | ||
228 | * be available due to CPUID level capping or broken virtualization | ||
229 | * software. Add those features to this table to auto-disable them. | ||
230 | */ | ||
231 | struct cpuid_dependent_feature { | ||
232 | u32 feature; | ||
233 | u32 level; | ||
234 | }; | ||
235 | static const struct cpuid_dependent_feature __cpuinitconst | ||
236 | cpuid_dependent_features[] = { | ||
237 | { X86_FEATURE_MWAIT, 0x00000005 }, | ||
238 | { X86_FEATURE_DCA, 0x00000009 }, | ||
239 | { X86_FEATURE_XSAVE, 0x0000000d }, | ||
240 | { 0, 0 } | ||
241 | }; | ||
242 | |||
243 | static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) | ||
244 | { | ||
245 | const struct cpuid_dependent_feature *df; | ||
246 | for (df = cpuid_dependent_features; df->feature; df++) { | ||
247 | /* | ||
248 | * Note: cpuid_level is set to -1 if unavailable, but | ||
249 | * extended_extended_level is set to 0 if unavailable | ||
250 | * and the legitimate extended levels are all negative | ||
251 | * when signed; hence the weird messing around with | ||
252 | * signs here... | ||
253 | */ | ||
254 | if (cpu_has(c, df->feature) && | ||
255 | ((s32)df->feature < 0 ? | ||
256 | (u32)df->feature > (u32)c->extended_cpuid_level : | ||
257 | (s32)df->feature > (s32)c->cpuid_level)) { | ||
258 | clear_cpu_cap(c, df->feature); | ||
259 | if (warn) | ||
260 | printk(KERN_WARNING | ||
261 | "CPU: CPU feature %s disabled " | ||
262 | "due to lack of CPUID level 0x%x\n", | ||
263 | x86_cap_flags[df->feature], | ||
264 | df->level); | ||
265 | } | ||
266 | } | ||
267 | } | ||
268 | |||
269 | /* | ||
216 | * Naming convention should be: <Name> [(<Codename>)] | 270 | * Naming convention should be: <Name> [(<Codename>)] |
217 | * This table only is used unless init_<vendor>() below doesn't set it; | 271 | * This table only is used unless init_<vendor>() below doesn't set it; |
218 | * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used | 272 | * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used |
@@ -247,12 +301,17 @@ __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata; | |||
247 | void switch_to_new_gdt(void) | 301 | void switch_to_new_gdt(void) |
248 | { | 302 | { |
249 | struct desc_ptr gdt_descr; | 303 | struct desc_ptr gdt_descr; |
304 | int cpu = smp_processor_id(); | ||
250 | 305 | ||
251 | gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id()); | 306 | gdt_descr.address = (long)get_cpu_gdt_table(cpu); |
252 | gdt_descr.size = GDT_SIZE - 1; | 307 | gdt_descr.size = GDT_SIZE - 1; |
253 | load_gdt(&gdt_descr); | 308 | load_gdt(&gdt_descr); |
309 | /* Reload the per-cpu base */ | ||
254 | #ifdef CONFIG_X86_32 | 310 | #ifdef CONFIG_X86_32 |
255 | asm("mov %0, %%fs" : : "r" (__KERNEL_PERCPU) : "memory"); | 311 | loadsegment(fs, __KERNEL_PERCPU); |
312 | #else | ||
313 | loadsegment(gs, 0); | ||
314 | wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu)); | ||
256 | #endif | 315 | #endif |
257 | } | 316 | } |
258 | 317 | ||
@@ -570,11 +629,10 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) | |||
570 | if (this_cpu->c_early_init) | 629 | if (this_cpu->c_early_init) |
571 | this_cpu->c_early_init(c); | 630 | this_cpu->c_early_init(c); |
572 | 631 | ||
573 | validate_pat_support(c); | ||
574 | |||
575 | #ifdef CONFIG_SMP | 632 | #ifdef CONFIG_SMP |
576 | c->cpu_index = boot_cpu_id; | 633 | c->cpu_index = boot_cpu_id; |
577 | #endif | 634 | #endif |
635 | filter_cpuid_features(c, false); | ||
578 | } | 636 | } |
579 | 637 | ||
580 | void __init early_cpu_init(void) | 638 | void __init early_cpu_init(void) |
@@ -708,6 +766,9 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) | |||
708 | * we do "generic changes." | 766 | * we do "generic changes." |
709 | */ | 767 | */ |
710 | 768 | ||
769 | /* Filter out anything that depends on CPUID levels we don't have */ | ||
770 | filter_cpuid_features(c, true); | ||
771 | |||
711 | /* If the model name is still unset, do table lookup. */ | 772 | /* If the model name is still unset, do table lookup. */ |
712 | if (!c->x86_model_id[0]) { | 773 | if (!c->x86_model_id[0]) { |
713 | char *p; | 774 | char *p; |
@@ -877,54 +938,26 @@ static __init int setup_disablecpuid(char *arg) | |||
877 | __setup("clearcpuid=", setup_disablecpuid); | 938 | __setup("clearcpuid=", setup_disablecpuid); |
878 | 939 | ||
879 | #ifdef CONFIG_X86_64 | 940 | #ifdef CONFIG_X86_64 |
880 | struct x8664_pda **_cpu_pda __read_mostly; | ||
881 | EXPORT_SYMBOL(_cpu_pda); | ||
882 | |||
883 | struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table }; | 941 | struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table }; |
884 | 942 | ||
885 | static char boot_cpu_stack[IRQSTACKSIZE] __page_aligned_bss; | 943 | DEFINE_PER_CPU_FIRST(union irq_stack_union, |
886 | 944 | irq_stack_union) __aligned(PAGE_SIZE); | |
887 | void __cpuinit pda_init(int cpu) | 945 | #ifdef CONFIG_SMP |
888 | { | 946 | DEFINE_PER_CPU(char *, irq_stack_ptr); /* will be set during per cpu init */ |
889 | struct x8664_pda *pda = cpu_pda(cpu); | 947 | #else |
948 | DEFINE_PER_CPU(char *, irq_stack_ptr) = | ||
949 | per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE - 64; | ||
950 | #endif | ||
890 | 951 | ||
891 | /* Setup up data that may be needed in __get_free_pages early */ | 952 | DEFINE_PER_CPU(unsigned long, kernel_stack) = |
892 | loadsegment(fs, 0); | 953 | (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE; |
893 | loadsegment(gs, 0); | 954 | EXPORT_PER_CPU_SYMBOL(kernel_stack); |
894 | /* Memory clobbers used to order PDA accessed */ | ||
895 | mb(); | ||
896 | wrmsrl(MSR_GS_BASE, pda); | ||
897 | mb(); | ||
898 | |||
899 | pda->cpunumber = cpu; | ||
900 | pda->irqcount = -1; | ||
901 | pda->kernelstack = (unsigned long)stack_thread_info() - | ||
902 | PDA_STACKOFFSET + THREAD_SIZE; | ||
903 | pda->active_mm = &init_mm; | ||
904 | pda->mmu_state = 0; | ||
905 | |||
906 | if (cpu == 0) { | ||
907 | /* others are initialized in smpboot.c */ | ||
908 | pda->pcurrent = &init_task; | ||
909 | pda->irqstackptr = boot_cpu_stack; | ||
910 | pda->irqstackptr += IRQSTACKSIZE - 64; | ||
911 | } else { | ||
912 | if (!pda->irqstackptr) { | ||
913 | pda->irqstackptr = (char *) | ||
914 | __get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER); | ||
915 | if (!pda->irqstackptr) | ||
916 | panic("cannot allocate irqstack for cpu %d", | ||
917 | cpu); | ||
918 | pda->irqstackptr += IRQSTACKSIZE - 64; | ||
919 | } | ||
920 | 955 | ||
921 | if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE) | 956 | DEFINE_PER_CPU(unsigned int, irq_count) = -1; |
922 | pda->nodenumber = cpu_to_node(cpu); | ||
923 | } | ||
924 | } | ||
925 | 957 | ||
926 | static char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + | 958 | static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks |
927 | DEBUG_STKSZ] __page_aligned_bss; | 959 | [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]) |
960 | __aligned(PAGE_SIZE); | ||
928 | 961 | ||
929 | extern asmlinkage void ignore_sysret(void); | 962 | extern asmlinkage void ignore_sysret(void); |
930 | 963 | ||
@@ -982,15 +1015,14 @@ void __cpuinit cpu_init(void) | |||
982 | struct tss_struct *t = &per_cpu(init_tss, cpu); | 1015 | struct tss_struct *t = &per_cpu(init_tss, cpu); |
983 | struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu); | 1016 | struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu); |
984 | unsigned long v; | 1017 | unsigned long v; |
985 | char *estacks = NULL; | ||
986 | struct task_struct *me; | 1018 | struct task_struct *me; |
987 | int i; | 1019 | int i; |
988 | 1020 | ||
989 | /* CPU 0 is initialised in head64.c */ | 1021 | #ifdef CONFIG_NUMA |
990 | if (cpu != 0) | 1022 | if (cpu != 0 && percpu_read(node_number) == 0 && |
991 | pda_init(cpu); | 1023 | cpu_to_node(cpu) != NUMA_NO_NODE) |
992 | else | 1024 | percpu_write(node_number, cpu_to_node(cpu)); |
993 | estacks = boot_exception_stacks; | 1025 | #endif |
994 | 1026 | ||
995 | me = current; | 1027 | me = current; |
996 | 1028 | ||
@@ -1007,6 +1039,8 @@ void __cpuinit cpu_init(void) | |||
1007 | */ | 1039 | */ |
1008 | 1040 | ||
1009 | switch_to_new_gdt(); | 1041 | switch_to_new_gdt(); |
1042 | loadsegment(fs, 0); | ||
1043 | |||
1010 | load_idt((const struct desc_ptr *)&idt_descr); | 1044 | load_idt((const struct desc_ptr *)&idt_descr); |
1011 | 1045 | ||
1012 | memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8); | 1046 | memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8); |
@@ -1024,18 +1058,13 @@ void __cpuinit cpu_init(void) | |||
1024 | * set up and load the per-CPU TSS | 1058 | * set up and load the per-CPU TSS |
1025 | */ | 1059 | */ |
1026 | if (!orig_ist->ist[0]) { | 1060 | if (!orig_ist->ist[0]) { |
1027 | static const unsigned int order[N_EXCEPTION_STACKS] = { | 1061 | static const unsigned int sizes[N_EXCEPTION_STACKS] = { |
1028 | [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER, | 1062 | [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ, |
1029 | [DEBUG_STACK - 1] = DEBUG_STACK_ORDER | 1063 | [DEBUG_STACK - 1] = DEBUG_STKSZ |
1030 | }; | 1064 | }; |
1065 | char *estacks = per_cpu(exception_stacks, cpu); | ||
1031 | for (v = 0; v < N_EXCEPTION_STACKS; v++) { | 1066 | for (v = 0; v < N_EXCEPTION_STACKS; v++) { |
1032 | if (cpu) { | 1067 | estacks += sizes[v]; |
1033 | estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]); | ||
1034 | if (!estacks) | ||
1035 | panic("Cannot allocate exception " | ||
1036 | "stack %ld %d\n", v, cpu); | ||
1037 | } | ||
1038 | estacks += PAGE_SIZE << order[v]; | ||
1039 | orig_ist->ist[v] = t->x86_tss.ist[v] = | 1068 | orig_ist->ist[v] = t->x86_tss.ist[v] = |
1040 | (unsigned long)estacks; | 1069 | (unsigned long)estacks; |
1041 | } | 1070 | } |
@@ -1069,22 +1098,19 @@ void __cpuinit cpu_init(void) | |||
1069 | */ | 1098 | */ |
1070 | if (kgdb_connected && arch_kgdb_ops.correct_hw_break) | 1099 | if (kgdb_connected && arch_kgdb_ops.correct_hw_break) |
1071 | arch_kgdb_ops.correct_hw_break(); | 1100 | arch_kgdb_ops.correct_hw_break(); |
1072 | else { | 1101 | else |
1073 | #endif | 1102 | #endif |
1074 | /* | 1103 | { |
1075 | * Clear all 6 debug registers: | 1104 | /* |
1076 | */ | 1105 | * Clear all 6 debug registers: |
1077 | 1106 | */ | |
1078 | set_debugreg(0UL, 0); | 1107 | set_debugreg(0UL, 0); |
1079 | set_debugreg(0UL, 1); | 1108 | set_debugreg(0UL, 1); |
1080 | set_debugreg(0UL, 2); | 1109 | set_debugreg(0UL, 2); |
1081 | set_debugreg(0UL, 3); | 1110 | set_debugreg(0UL, 3); |
1082 | set_debugreg(0UL, 6); | 1111 | set_debugreg(0UL, 6); |
1083 | set_debugreg(0UL, 7); | 1112 | set_debugreg(0UL, 7); |
1084 | #ifdef CONFIG_KGDB | ||
1085 | /* If the kgdb is connected no debug regs should be altered. */ | ||
1086 | } | 1113 | } |
1087 | #endif | ||
1088 | 1114 | ||
1089 | fpu_init(); | 1115 | fpu_init(); |
1090 | 1116 | ||
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index 06fcd8f9323c..4b1c319d30c3 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | |||
@@ -145,7 +145,7 @@ typedef union { | |||
145 | 145 | ||
146 | struct drv_cmd { | 146 | struct drv_cmd { |
147 | unsigned int type; | 147 | unsigned int type; |
148 | cpumask_var_t mask; | 148 | const struct cpumask *mask; |
149 | drv_addr_union addr; | 149 | drv_addr_union addr; |
150 | u32 val; | 150 | u32 val; |
151 | }; | 151 | }; |
@@ -231,15 +231,9 @@ static u32 get_cur_val(const struct cpumask *mask) | |||
231 | return 0; | 231 | return 0; |
232 | } | 232 | } |
233 | 233 | ||
234 | if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL))) | 234 | cmd.mask = mask; |
235 | return 0; | ||
236 | |||
237 | cpumask_copy(cmd.mask, mask); | ||
238 | |||
239 | drv_read(&cmd); | 235 | drv_read(&cmd); |
240 | 236 | ||
241 | free_cpumask_var(cmd.mask); | ||
242 | |||
243 | dprintk("get_cur_val = %u\n", cmd.val); | 237 | dprintk("get_cur_val = %u\n", cmd.val); |
244 | 238 | ||
245 | return cmd.val; | 239 | return cmd.val; |
@@ -369,7 +363,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) | |||
369 | return freq; | 363 | return freq; |
370 | } | 364 | } |
371 | 365 | ||
372 | static unsigned int check_freqs(const cpumask_t *mask, unsigned int freq, | 366 | static unsigned int check_freqs(const struct cpumask *mask, unsigned int freq, |
373 | struct acpi_cpufreq_data *data) | 367 | struct acpi_cpufreq_data *data) |
374 | { | 368 | { |
375 | unsigned int cur_freq; | 369 | unsigned int cur_freq; |
@@ -404,9 +398,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
404 | return -ENODEV; | 398 | return -ENODEV; |
405 | } | 399 | } |
406 | 400 | ||
407 | if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL))) | ||
408 | return -ENOMEM; | ||
409 | |||
410 | perf = data->acpi_data; | 401 | perf = data->acpi_data; |
411 | result = cpufreq_frequency_table_target(policy, | 402 | result = cpufreq_frequency_table_target(policy, |
412 | data->freq_table, | 403 | data->freq_table, |
@@ -451,9 +442,9 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
451 | 442 | ||
452 | /* cpufreq holds the hotplug lock, so we are safe from here on */ | 443 | /* cpufreq holds the hotplug lock, so we are safe from here on */ |
453 | if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY) | 444 | if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY) |
454 | cpumask_and(cmd.mask, cpu_online_mask, policy->cpus); | 445 | cmd.mask = policy->cpus; |
455 | else | 446 | else |
456 | cpumask_copy(cmd.mask, cpumask_of(policy->cpu)); | 447 | cmd.mask = cpumask_of(policy->cpu); |
457 | 448 | ||
458 | freqs.old = perf->states[perf->state].core_frequency * 1000; | 449 | freqs.old = perf->states[perf->state].core_frequency * 1000; |
459 | freqs.new = data->freq_table[next_state].frequency; | 450 | freqs.new = data->freq_table[next_state].frequency; |
@@ -480,7 +471,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
480 | perf->state = next_perf_state; | 471 | perf->state = next_perf_state; |
481 | 472 | ||
482 | out: | 473 | out: |
483 | free_cpumask_var(cmd.mask); | ||
484 | return result; | 474 | return result; |
485 | } | 475 | } |
486 | 476 | ||
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 8ea6929e974c..5deefae9064d 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
@@ -29,6 +29,19 @@ | |||
29 | 29 | ||
30 | static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) | 30 | static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) |
31 | { | 31 | { |
32 | /* Unmask CPUID levels if masked: */ | ||
33 | if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) { | ||
34 | u64 misc_enable; | ||
35 | |||
36 | rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable); | ||
37 | |||
38 | if (misc_enable & MSR_IA32_MISC_ENABLE_LIMIT_CPUID) { | ||
39 | misc_enable &= ~MSR_IA32_MISC_ENABLE_LIMIT_CPUID; | ||
40 | wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable); | ||
41 | c->cpuid_level = cpuid_eax(0); | ||
42 | } | ||
43 | } | ||
44 | |||
32 | if ((c->x86 == 0xf && c->x86_model >= 0x03) || | 45 | if ((c->x86 == 0xf && c->x86_model >= 0x03) || |
33 | (c->x86 == 0x6 && c->x86_model >= 0x0e)) | 46 | (c->x86 == 0x6 && c->x86_model >= 0x0e)) |
34 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | 47 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); |
@@ -50,6 +63,18 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) | |||
50 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); | 63 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); |
51 | } | 64 | } |
52 | 65 | ||
66 | /* | ||
67 | * There is a known erratum on Pentium III and Core Solo | ||
68 | * and Core Duo CPUs. | ||
69 | * " Page with PAT set to WC while associated MTRR is UC | ||
70 | * may consolidate to UC " | ||
71 | * Because of this erratum, it is better to stick with | ||
72 | * setting WC in MTRR rather than using PAT on these CPUs. | ||
73 | * | ||
74 | * Enable PAT WC only on P4, Core 2 or later CPUs. | ||
75 | */ | ||
76 | if (c->x86 == 6 && c->x86_model < 15) | ||
77 | clear_cpu_cap(c, X86_FEATURE_PAT); | ||
53 | } | 78 | } |
54 | 79 | ||
55 | #ifdef CONFIG_X86_32 | 80 | #ifdef CONFIG_X86_32 |
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index 48533d77be78..58527a9fc404 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
@@ -132,7 +132,16 @@ struct _cpuid4_info { | |||
132 | union _cpuid4_leaf_ecx ecx; | 132 | union _cpuid4_leaf_ecx ecx; |
133 | unsigned long size; | 133 | unsigned long size; |
134 | unsigned long can_disable; | 134 | unsigned long can_disable; |
135 | cpumask_t shared_cpu_map; /* future?: only cpus/node is needed */ | 135 | DECLARE_BITMAP(shared_cpu_map, NR_CPUS); |
136 | }; | ||
137 | |||
138 | /* subset of above _cpuid4_info w/o shared_cpu_map */ | ||
139 | struct _cpuid4_info_regs { | ||
140 | union _cpuid4_leaf_eax eax; | ||
141 | union _cpuid4_leaf_ebx ebx; | ||
142 | union _cpuid4_leaf_ecx ecx; | ||
143 | unsigned long size; | ||
144 | unsigned long can_disable; | ||
136 | }; | 145 | }; |
137 | 146 | ||
138 | #ifdef CONFIG_PCI | 147 | #ifdef CONFIG_PCI |
@@ -263,7 +272,7 @@ amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, | |||
263 | } | 272 | } |
264 | 273 | ||
265 | static void __cpuinit | 274 | static void __cpuinit |
266 | amd_check_l3_disable(int index, struct _cpuid4_info *this_leaf) | 275 | amd_check_l3_disable(int index, struct _cpuid4_info_regs *this_leaf) |
267 | { | 276 | { |
268 | if (index < 3) | 277 | if (index < 3) |
269 | return; | 278 | return; |
@@ -271,7 +280,8 @@ amd_check_l3_disable(int index, struct _cpuid4_info *this_leaf) | |||
271 | } | 280 | } |
272 | 281 | ||
273 | static int | 282 | static int |
274 | __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) | 283 | __cpuinit cpuid4_cache_lookup_regs(int index, |
284 | struct _cpuid4_info_regs *this_leaf) | ||
275 | { | 285 | { |
276 | union _cpuid4_leaf_eax eax; | 286 | union _cpuid4_leaf_eax eax; |
277 | union _cpuid4_leaf_ebx ebx; | 287 | union _cpuid4_leaf_ebx ebx; |
@@ -299,6 +309,15 @@ __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) | |||
299 | return 0; | 309 | return 0; |
300 | } | 310 | } |
301 | 311 | ||
312 | static int | ||
313 | __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) | ||
314 | { | ||
315 | struct _cpuid4_info_regs *leaf_regs = | ||
316 | (struct _cpuid4_info_regs *)this_leaf; | ||
317 | |||
318 | return cpuid4_cache_lookup_regs(index, leaf_regs); | ||
319 | } | ||
320 | |||
302 | static int __cpuinit find_num_cache_leaves(void) | 321 | static int __cpuinit find_num_cache_leaves(void) |
303 | { | 322 | { |
304 | unsigned int eax, ebx, ecx, edx; | 323 | unsigned int eax, ebx, ecx, edx; |
@@ -338,11 +357,10 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) | |||
338 | * parameters cpuid leaf to find the cache details | 357 | * parameters cpuid leaf to find the cache details |
339 | */ | 358 | */ |
340 | for (i = 0; i < num_cache_leaves; i++) { | 359 | for (i = 0; i < num_cache_leaves; i++) { |
341 | struct _cpuid4_info this_leaf; | 360 | struct _cpuid4_info_regs this_leaf; |
342 | |||
343 | int retval; | 361 | int retval; |
344 | 362 | ||
345 | retval = cpuid4_cache_lookup(i, &this_leaf); | 363 | retval = cpuid4_cache_lookup_regs(i, &this_leaf); |
346 | if (retval >= 0) { | 364 | if (retval >= 0) { |
347 | switch(this_leaf.eax.split.level) { | 365 | switch(this_leaf.eax.split.level) { |
348 | case 1: | 366 | case 1: |
@@ -491,17 +509,20 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) | |||
491 | num_threads_sharing = 1 + this_leaf->eax.split.num_threads_sharing; | 509 | num_threads_sharing = 1 + this_leaf->eax.split.num_threads_sharing; |
492 | 510 | ||
493 | if (num_threads_sharing == 1) | 511 | if (num_threads_sharing == 1) |
494 | cpu_set(cpu, this_leaf->shared_cpu_map); | 512 | cpumask_set_cpu(cpu, to_cpumask(this_leaf->shared_cpu_map)); |
495 | else { | 513 | else { |
496 | index_msb = get_count_order(num_threads_sharing); | 514 | index_msb = get_count_order(num_threads_sharing); |
497 | 515 | ||
498 | for_each_online_cpu(i) { | 516 | for_each_online_cpu(i) { |
499 | if (cpu_data(i).apicid >> index_msb == | 517 | if (cpu_data(i).apicid >> index_msb == |
500 | c->apicid >> index_msb) { | 518 | c->apicid >> index_msb) { |
501 | cpu_set(i, this_leaf->shared_cpu_map); | 519 | cpumask_set_cpu(i, |
520 | to_cpumask(this_leaf->shared_cpu_map)); | ||
502 | if (i != cpu && per_cpu(cpuid4_info, i)) { | 521 | if (i != cpu && per_cpu(cpuid4_info, i)) { |
503 | sibling_leaf = CPUID4_INFO_IDX(i, index); | 522 | sibling_leaf = |
504 | cpu_set(cpu, sibling_leaf->shared_cpu_map); | 523 | CPUID4_INFO_IDX(i, index); |
524 | cpumask_set_cpu(cpu, to_cpumask( | ||
525 | sibling_leaf->shared_cpu_map)); | ||
505 | } | 526 | } |
506 | } | 527 | } |
507 | } | 528 | } |
@@ -513,9 +534,10 @@ static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index) | |||
513 | int sibling; | 534 | int sibling; |
514 | 535 | ||
515 | this_leaf = CPUID4_INFO_IDX(cpu, index); | 536 | this_leaf = CPUID4_INFO_IDX(cpu, index); |
516 | for_each_cpu_mask_nr(sibling, this_leaf->shared_cpu_map) { | 537 | for_each_cpu(sibling, to_cpumask(this_leaf->shared_cpu_map)) { |
517 | sibling_leaf = CPUID4_INFO_IDX(sibling, index); | 538 | sibling_leaf = CPUID4_INFO_IDX(sibling, index); |
518 | cpu_clear(cpu, sibling_leaf->shared_cpu_map); | 539 | cpumask_clear_cpu(cpu, |
540 | to_cpumask(sibling_leaf->shared_cpu_map)); | ||
519 | } | 541 | } |
520 | } | 542 | } |
521 | #else | 543 | #else |
@@ -620,8 +642,9 @@ static ssize_t show_shared_cpu_map_func(struct _cpuid4_info *this_leaf, | |||
620 | int n = 0; | 642 | int n = 0; |
621 | 643 | ||
622 | if (len > 1) { | 644 | if (len > 1) { |
623 | cpumask_t *mask = &this_leaf->shared_cpu_map; | 645 | const struct cpumask *mask; |
624 | 646 | ||
647 | mask = to_cpumask(this_leaf->shared_cpu_map); | ||
625 | n = type? | 648 | n = type? |
626 | cpulist_scnprintf(buf, len-2, mask) : | 649 | cpulist_scnprintf(buf, len-2, mask) : |
627 | cpumask_scnprintf(buf, len-2, mask); | 650 | cpumask_scnprintf(buf, len-2, mask); |
@@ -684,7 +707,8 @@ static struct pci_dev *get_k8_northbridge(int node) | |||
684 | 707 | ||
685 | static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf) | 708 | static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf) |
686 | { | 709 | { |
687 | int node = cpu_to_node(first_cpu(this_leaf->shared_cpu_map)); | 710 | const struct cpumask *mask = to_cpumask(this_leaf->shared_cpu_map); |
711 | int node = cpu_to_node(cpumask_first(mask)); | ||
688 | struct pci_dev *dev = NULL; | 712 | struct pci_dev *dev = NULL; |
689 | ssize_t ret = 0; | 713 | ssize_t ret = 0; |
690 | int i; | 714 | int i; |
@@ -718,7 +742,8 @@ static ssize_t | |||
718 | store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf, | 742 | store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf, |
719 | size_t count) | 743 | size_t count) |
720 | { | 744 | { |
721 | int node = cpu_to_node(first_cpu(this_leaf->shared_cpu_map)); | 745 | const struct cpumask *mask = to_cpumask(this_leaf->shared_cpu_map); |
746 | int node = cpu_to_node(cpumask_first(mask)); | ||
722 | struct pci_dev *dev = NULL; | 747 | struct pci_dev *dev = NULL; |
723 | unsigned int ret, index, val; | 748 | unsigned int ret, index, val; |
724 | 749 | ||
@@ -863,7 +888,7 @@ err_out: | |||
863 | return -ENOMEM; | 888 | return -ENOMEM; |
864 | } | 889 | } |
865 | 890 | ||
866 | static cpumask_t cache_dev_map = CPU_MASK_NONE; | 891 | static DECLARE_BITMAP(cache_dev_map, NR_CPUS); |
867 | 892 | ||
868 | /* Add/Remove cache interface for CPU device */ | 893 | /* Add/Remove cache interface for CPU device */ |
869 | static int __cpuinit cache_add_dev(struct sys_device * sys_dev) | 894 | static int __cpuinit cache_add_dev(struct sys_device * sys_dev) |
@@ -903,7 +928,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev) | |||
903 | } | 928 | } |
904 | kobject_uevent(&(this_object->kobj), KOBJ_ADD); | 929 | kobject_uevent(&(this_object->kobj), KOBJ_ADD); |
905 | } | 930 | } |
906 | cpu_set(cpu, cache_dev_map); | 931 | cpumask_set_cpu(cpu, to_cpumask(cache_dev_map)); |
907 | 932 | ||
908 | kobject_uevent(per_cpu(cache_kobject, cpu), KOBJ_ADD); | 933 | kobject_uevent(per_cpu(cache_kobject, cpu), KOBJ_ADD); |
909 | return 0; | 934 | return 0; |
@@ -916,9 +941,9 @@ static void __cpuinit cache_remove_dev(struct sys_device * sys_dev) | |||
916 | 941 | ||
917 | if (per_cpu(cpuid4_info, cpu) == NULL) | 942 | if (per_cpu(cpuid4_info, cpu) == NULL) |
918 | return; | 943 | return; |
919 | if (!cpu_isset(cpu, cache_dev_map)) | 944 | if (!cpumask_test_cpu(cpu, to_cpumask(cache_dev_map))) |
920 | return; | 945 | return; |
921 | cpu_clear(cpu, cache_dev_map); | 946 | cpumask_clear_cpu(cpu, to_cpumask(cache_dev_map)); |
922 | 947 | ||
923 | for (i = 0; i < num_cache_leaves; i++) | 948 | for (i = 0; i < num_cache_leaves; i++) |
924 | kobject_put(&(INDEX_KOBJECT_PTR(cpu,i)->kobj)); | 949 | kobject_put(&(INDEX_KOBJECT_PTR(cpu,i)->kobj)); |
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd_64.c b/arch/x86/kernel/cpu/mcheck/mce_amd_64.c index 8ae8c4ff094d..4772e91e8246 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd_64.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd_64.c | |||
@@ -67,7 +67,7 @@ static struct threshold_block threshold_defaults = { | |||
67 | struct threshold_bank { | 67 | struct threshold_bank { |
68 | struct kobject *kobj; | 68 | struct kobject *kobj; |
69 | struct threshold_block *blocks; | 69 | struct threshold_block *blocks; |
70 | cpumask_t cpus; | 70 | cpumask_var_t cpus; |
71 | }; | 71 | }; |
72 | static DEFINE_PER_CPU(struct threshold_bank *, threshold_banks[NR_BANKS]); | 72 | static DEFINE_PER_CPU(struct threshold_bank *, threshold_banks[NR_BANKS]); |
73 | 73 | ||
@@ -481,7 +481,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
481 | 481 | ||
482 | #ifdef CONFIG_SMP | 482 | #ifdef CONFIG_SMP |
483 | if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */ | 483 | if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */ |
484 | i = first_cpu(per_cpu(cpu_core_map, cpu)); | 484 | i = cpumask_first(&per_cpu(cpu_core_map, cpu)); |
485 | 485 | ||
486 | /* first core not up yet */ | 486 | /* first core not up yet */ |
487 | if (cpu_data(i).cpu_core_id) | 487 | if (cpu_data(i).cpu_core_id) |
@@ -501,7 +501,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
501 | if (err) | 501 | if (err) |
502 | goto out; | 502 | goto out; |
503 | 503 | ||
504 | b->cpus = per_cpu(cpu_core_map, cpu); | 504 | cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu)); |
505 | per_cpu(threshold_banks, cpu)[bank] = b; | 505 | per_cpu(threshold_banks, cpu)[bank] = b; |
506 | goto out; | 506 | goto out; |
507 | } | 507 | } |
@@ -512,15 +512,20 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
512 | err = -ENOMEM; | 512 | err = -ENOMEM; |
513 | goto out; | 513 | goto out; |
514 | } | 514 | } |
515 | if (!alloc_cpumask_var(&b->cpus, GFP_KERNEL)) { | ||
516 | kfree(b); | ||
517 | err = -ENOMEM; | ||
518 | goto out; | ||
519 | } | ||
515 | 520 | ||
516 | b->kobj = kobject_create_and_add(name, &per_cpu(device_mce, cpu).kobj); | 521 | b->kobj = kobject_create_and_add(name, &per_cpu(device_mce, cpu).kobj); |
517 | if (!b->kobj) | 522 | if (!b->kobj) |
518 | goto out_free; | 523 | goto out_free; |
519 | 524 | ||
520 | #ifndef CONFIG_SMP | 525 | #ifndef CONFIG_SMP |
521 | b->cpus = CPU_MASK_ALL; | 526 | cpumask_setall(b->cpus); |
522 | #else | 527 | #else |
523 | b->cpus = per_cpu(cpu_core_map, cpu); | 528 | cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu)); |
524 | #endif | 529 | #endif |
525 | 530 | ||
526 | per_cpu(threshold_banks, cpu)[bank] = b; | 531 | per_cpu(threshold_banks, cpu)[bank] = b; |
@@ -529,7 +534,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
529 | if (err) | 534 | if (err) |
530 | goto out_free; | 535 | goto out_free; |
531 | 536 | ||
532 | for_each_cpu_mask_nr(i, b->cpus) { | 537 | for_each_cpu(i, b->cpus) { |
533 | if (i == cpu) | 538 | if (i == cpu) |
534 | continue; | 539 | continue; |
535 | 540 | ||
@@ -545,6 +550,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
545 | 550 | ||
546 | out_free: | 551 | out_free: |
547 | per_cpu(threshold_banks, cpu)[bank] = NULL; | 552 | per_cpu(threshold_banks, cpu)[bank] = NULL; |
553 | free_cpumask_var(b->cpus); | ||
548 | kfree(b); | 554 | kfree(b); |
549 | out: | 555 | out: |
550 | return err; | 556 | return err; |
@@ -619,7 +625,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank) | |||
619 | #endif | 625 | #endif |
620 | 626 | ||
621 | /* remove all sibling symlinks before unregistering */ | 627 | /* remove all sibling symlinks before unregistering */ |
622 | for_each_cpu_mask_nr(i, b->cpus) { | 628 | for_each_cpu(i, b->cpus) { |
623 | if (i == cpu) | 629 | if (i == cpu) |
624 | continue; | 630 | continue; |
625 | 631 | ||
@@ -632,6 +638,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank) | |||
632 | free_out: | 638 | free_out: |
633 | kobject_del(b->kobj); | 639 | kobject_del(b->kobj); |
634 | kobject_put(b->kobj); | 640 | kobject_put(b->kobj); |
641 | free_cpumask_var(b->cpus); | ||
635 | kfree(b); | 642 | kfree(b); |
636 | per_cpu(threshold_banks, cpu)[bank] = NULL; | 643 | per_cpu(threshold_banks, cpu)[bank] = NULL; |
637 | } | 644 | } |
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel_64.c b/arch/x86/kernel/cpu/mcheck/mce_intel_64.c index 4b48f251fd39..5e8c79e748a6 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_intel_64.c +++ b/arch/x86/kernel/cpu/mcheck/mce_intel_64.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/interrupt.h> | 7 | #include <linux/interrupt.h> |
8 | #include <linux/percpu.h> | 8 | #include <linux/percpu.h> |
9 | #include <asm/processor.h> | 9 | #include <asm/processor.h> |
10 | #include <asm/apic.h> | ||
10 | #include <asm/msr.h> | 11 | #include <asm/msr.h> |
11 | #include <asm/mce.h> | 12 | #include <asm/mce.h> |
12 | #include <asm/hw_irq.h> | 13 | #include <asm/hw_irq.h> |
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index b59ddcc88cd8..0c0a455fe95c 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c | |||
@@ -33,11 +33,13 @@ u64 mtrr_tom2; | |||
33 | struct mtrr_state_type mtrr_state = {}; | 33 | struct mtrr_state_type mtrr_state = {}; |
34 | EXPORT_SYMBOL_GPL(mtrr_state); | 34 | EXPORT_SYMBOL_GPL(mtrr_state); |
35 | 35 | ||
36 | #undef MODULE_PARAM_PREFIX | 36 | static int __initdata mtrr_show; |
37 | #define MODULE_PARAM_PREFIX "mtrr." | 37 | static int __init mtrr_debug(char *opt) |
38 | 38 | { | |
39 | static int mtrr_show; | 39 | mtrr_show = 1; |
40 | module_param_named(show, mtrr_show, bool, 0); | 40 | return 0; |
41 | } | ||
42 | early_param("mtrr.show", mtrr_debug); | ||
41 | 43 | ||
42 | /* | 44 | /* |
43 | * Returns the effective MTRR type for the region | 45 | * Returns the effective MTRR type for the region |
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index c689d19e35ab..11b93cabdf78 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <asm/apic.h> | 24 | #include <asm/apic.h> |
25 | #include <asm/hpet.h> | 25 | #include <asm/hpet.h> |
26 | #include <linux/kdebug.h> | 26 | #include <linux/kdebug.h> |
27 | #include <asm/smp.h> | 27 | #include <asm/cpu.h> |
28 | #include <asm/reboot.h> | 28 | #include <asm/reboot.h> |
29 | #include <asm/virtext.h> | 29 | #include <asm/virtext.h> |
30 | 30 | ||
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c index c302d0707048..d35db5993fd6 100644 --- a/arch/x86/kernel/dumpstack_64.c +++ b/arch/x86/kernel/dumpstack_64.c | |||
@@ -106,7 +106,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, | |||
106 | const struct stacktrace_ops *ops, void *data) | 106 | const struct stacktrace_ops *ops, void *data) |
107 | { | 107 | { |
108 | const unsigned cpu = get_cpu(); | 108 | const unsigned cpu = get_cpu(); |
109 | unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr; | 109 | unsigned long *irq_stack_end = |
110 | (unsigned long *)per_cpu(irq_stack_ptr, cpu); | ||
110 | unsigned used = 0; | 111 | unsigned used = 0; |
111 | struct thread_info *tinfo; | 112 | struct thread_info *tinfo; |
112 | int graph = 0; | 113 | int graph = 0; |
@@ -160,23 +161,23 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, | |||
160 | stack = (unsigned long *) estack_end[-2]; | 161 | stack = (unsigned long *) estack_end[-2]; |
161 | continue; | 162 | continue; |
162 | } | 163 | } |
163 | if (irqstack_end) { | 164 | if (irq_stack_end) { |
164 | unsigned long *irqstack; | 165 | unsigned long *irq_stack; |
165 | irqstack = irqstack_end - | 166 | irq_stack = irq_stack_end - |
166 | (IRQSTACKSIZE - 64) / sizeof(*irqstack); | 167 | (IRQ_STACK_SIZE - 64) / sizeof(*irq_stack); |
167 | 168 | ||
168 | if (stack >= irqstack && stack < irqstack_end) { | 169 | if (stack >= irq_stack && stack < irq_stack_end) { |
169 | if (ops->stack(data, "IRQ") < 0) | 170 | if (ops->stack(data, "IRQ") < 0) |
170 | break; | 171 | break; |
171 | bp = print_context_stack(tinfo, stack, bp, | 172 | bp = print_context_stack(tinfo, stack, bp, |
172 | ops, data, irqstack_end, &graph); | 173 | ops, data, irq_stack_end, &graph); |
173 | /* | 174 | /* |
174 | * We link to the next stack (which would be | 175 | * We link to the next stack (which would be |
175 | * the process stack normally) the last | 176 | * the process stack normally) the last |
176 | * pointer (index -1 to end) in the IRQ stack: | 177 | * pointer (index -1 to end) in the IRQ stack: |
177 | */ | 178 | */ |
178 | stack = (unsigned long *) (irqstack_end[-1]); | 179 | stack = (unsigned long *) (irq_stack_end[-1]); |
179 | irqstack_end = NULL; | 180 | irq_stack_end = NULL; |
180 | ops->stack(data, "EOI"); | 181 | ops->stack(data, "EOI"); |
181 | continue; | 182 | continue; |
182 | } | 183 | } |
@@ -199,10 +200,10 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, | |||
199 | unsigned long *stack; | 200 | unsigned long *stack; |
200 | int i; | 201 | int i; |
201 | const int cpu = smp_processor_id(); | 202 | const int cpu = smp_processor_id(); |
202 | unsigned long *irqstack_end = | 203 | unsigned long *irq_stack_end = |
203 | (unsigned long *) (cpu_pda(cpu)->irqstackptr); | 204 | (unsigned long *)(per_cpu(irq_stack_ptr, cpu)); |
204 | unsigned long *irqstack = | 205 | unsigned long *irq_stack = |
205 | (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE); | 206 | (unsigned long *)(per_cpu(irq_stack_ptr, cpu) - IRQ_STACK_SIZE); |
206 | 207 | ||
207 | /* | 208 | /* |
208 | * debugging aid: "show_stack(NULL, NULL);" prints the | 209 | * debugging aid: "show_stack(NULL, NULL);" prints the |
@@ -218,9 +219,9 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, | |||
218 | 219 | ||
219 | stack = sp; | 220 | stack = sp; |
220 | for (i = 0; i < kstack_depth_to_print; i++) { | 221 | for (i = 0; i < kstack_depth_to_print; i++) { |
221 | if (stack >= irqstack && stack <= irqstack_end) { | 222 | if (stack >= irq_stack && stack <= irq_stack_end) { |
222 | if (stack == irqstack_end) { | 223 | if (stack == irq_stack_end) { |
223 | stack = (unsigned long *) (irqstack_end[-1]); | 224 | stack = (unsigned long *) (irq_stack_end[-1]); |
224 | printk(" <EOI> "); | 225 | printk(" <EOI> "); |
225 | } | 226 | } |
226 | } else { | 227 | } else { |
@@ -241,7 +242,7 @@ void show_registers(struct pt_regs *regs) | |||
241 | int i; | 242 | int i; |
242 | unsigned long sp; | 243 | unsigned long sp; |
243 | const int cpu = smp_processor_id(); | 244 | const int cpu = smp_processor_id(); |
244 | struct task_struct *cur = cpu_pda(cpu)->pcurrent; | 245 | struct task_struct *cur = current; |
245 | 246 | ||
246 | sp = regs->sp; | 247 | sp = regs->sp; |
247 | printk("CPU %d ", cpu); | 248 | printk("CPU %d ", cpu); |
diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c index 1119d247fe11..b205272ad394 100644 --- a/arch/x86/kernel/efi.c +++ b/arch/x86/kernel/efi.c | |||
@@ -366,10 +366,12 @@ void __init efi_init(void) | |||
366 | SMBIOS_TABLE_GUID)) { | 366 | SMBIOS_TABLE_GUID)) { |
367 | efi.smbios = config_tables[i].table; | 367 | efi.smbios = config_tables[i].table; |
368 | printk(" SMBIOS=0x%lx ", config_tables[i].table); | 368 | printk(" SMBIOS=0x%lx ", config_tables[i].table); |
369 | #ifdef CONFIG_X86_UV | ||
369 | } else if (!efi_guidcmp(config_tables[i].guid, | 370 | } else if (!efi_guidcmp(config_tables[i].guid, |
370 | UV_SYSTEM_TABLE_GUID)) { | 371 | UV_SYSTEM_TABLE_GUID)) { |
371 | efi.uv_systab = config_tables[i].table; | 372 | efi.uv_systab = config_tables[i].table; |
372 | printk(" UVsystab=0x%lx ", config_tables[i].table); | 373 | printk(" UVsystab=0x%lx ", config_tables[i].table); |
374 | #endif | ||
373 | } else if (!efi_guidcmp(config_tables[i].guid, | 375 | } else if (!efi_guidcmp(config_tables[i].guid, |
374 | HCDP_TABLE_GUID)) { | 376 | HCDP_TABLE_GUID)) { |
375 | efi.hcdp = config_tables[i].table; | 377 | efi.hcdp = config_tables[i].table; |
diff --git a/arch/x86/kernel/efi_64.c b/arch/x86/kernel/efi_64.c index 652c5287215f..a4ee29127fdf 100644 --- a/arch/x86/kernel/efi_64.c +++ b/arch/x86/kernel/efi_64.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <asm/proto.h> | 36 | #include <asm/proto.h> |
37 | #include <asm/efi.h> | 37 | #include <asm/efi.h> |
38 | #include <asm/cacheflush.h> | 38 | #include <asm/cacheflush.h> |
39 | #include <asm/fixmap.h> | ||
39 | 40 | ||
40 | static pgd_t save_pgd __initdata; | 41 | static pgd_t save_pgd __initdata; |
41 | static unsigned long efi_flags __initdata; | 42 | static unsigned long efi_flags __initdata; |
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S index d6f0490a7391..a0b91aac72a1 100644 --- a/arch/x86/kernel/entry_32.S +++ b/arch/x86/kernel/entry_32.S | |||
@@ -672,7 +672,7 @@ common_interrupt: | |||
672 | ENDPROC(common_interrupt) | 672 | ENDPROC(common_interrupt) |
673 | CFI_ENDPROC | 673 | CFI_ENDPROC |
674 | 674 | ||
675 | #define BUILD_INTERRUPT(name, nr) \ | 675 | #define BUILD_INTERRUPT3(name, nr, fn) \ |
676 | ENTRY(name) \ | 676 | ENTRY(name) \ |
677 | RING0_INT_FRAME; \ | 677 | RING0_INT_FRAME; \ |
678 | pushl $~(nr); \ | 678 | pushl $~(nr); \ |
@@ -680,11 +680,13 @@ ENTRY(name) \ | |||
680 | SAVE_ALL; \ | 680 | SAVE_ALL; \ |
681 | TRACE_IRQS_OFF \ | 681 | TRACE_IRQS_OFF \ |
682 | movl %esp,%eax; \ | 682 | movl %esp,%eax; \ |
683 | call smp_##name; \ | 683 | call fn; \ |
684 | jmp ret_from_intr; \ | 684 | jmp ret_from_intr; \ |
685 | CFI_ENDPROC; \ | 685 | CFI_ENDPROC; \ |
686 | ENDPROC(name) | 686 | ENDPROC(name) |
687 | 687 | ||
688 | #define BUILD_INTERRUPT(name, nr) BUILD_INTERRUPT3(name, nr, smp_##name) | ||
689 | |||
688 | /* The include is where all of the SMP etc. interrupts come from */ | 690 | /* The include is where all of the SMP etc. interrupts come from */ |
689 | #include "entry_arch.h" | 691 | #include "entry_arch.h" |
690 | 692 | ||
@@ -1203,7 +1205,6 @@ nmi_stack_correct: | |||
1203 | pushl %eax | 1205 | pushl %eax |
1204 | CFI_ADJUST_CFA_OFFSET 4 | 1206 | CFI_ADJUST_CFA_OFFSET 4 |
1205 | SAVE_ALL | 1207 | SAVE_ALL |
1206 | TRACE_IRQS_OFF | ||
1207 | xorl %edx,%edx # zero error code | 1208 | xorl %edx,%edx # zero error code |
1208 | movl %esp,%eax # pt_regs pointer | 1209 | movl %esp,%eax # pt_regs pointer |
1209 | call do_nmi | 1210 | call do_nmi |
@@ -1244,7 +1245,6 @@ nmi_espfix_stack: | |||
1244 | pushl %eax | 1245 | pushl %eax |
1245 | CFI_ADJUST_CFA_OFFSET 4 | 1246 | CFI_ADJUST_CFA_OFFSET 4 |
1246 | SAVE_ALL | 1247 | SAVE_ALL |
1247 | TRACE_IRQS_OFF | ||
1248 | FIXUP_ESPFIX_STACK # %eax == %esp | 1248 | FIXUP_ESPFIX_STACK # %eax == %esp |
1249 | xorl %edx,%edx # zero error code | 1249 | xorl %edx,%edx # zero error code |
1250 | call do_nmi | 1250 | call do_nmi |
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index e28c7a987793..82801fd2e931 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <asm/irqflags.h> | 52 | #include <asm/irqflags.h> |
53 | #include <asm/paravirt.h> | 53 | #include <asm/paravirt.h> |
54 | #include <asm/ftrace.h> | 54 | #include <asm/ftrace.h> |
55 | #include <asm/percpu.h> | ||
55 | 56 | ||
56 | /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ | 57 | /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ |
57 | #include <linux/elf-em.h> | 58 | #include <linux/elf-em.h> |
@@ -209,7 +210,7 @@ ENTRY(native_usergs_sysret64) | |||
209 | 210 | ||
210 | /* %rsp:at FRAMEEND */ | 211 | /* %rsp:at FRAMEEND */ |
211 | .macro FIXUP_TOP_OF_STACK tmp offset=0 | 212 | .macro FIXUP_TOP_OF_STACK tmp offset=0 |
212 | movq %gs:pda_oldrsp,\tmp | 213 | movq PER_CPU_VAR(old_rsp),\tmp |
213 | movq \tmp,RSP+\offset(%rsp) | 214 | movq \tmp,RSP+\offset(%rsp) |
214 | movq $__USER_DS,SS+\offset(%rsp) | 215 | movq $__USER_DS,SS+\offset(%rsp) |
215 | movq $__USER_CS,CS+\offset(%rsp) | 216 | movq $__USER_CS,CS+\offset(%rsp) |
@@ -220,7 +221,7 @@ ENTRY(native_usergs_sysret64) | |||
220 | 221 | ||
221 | .macro RESTORE_TOP_OF_STACK tmp offset=0 | 222 | .macro RESTORE_TOP_OF_STACK tmp offset=0 |
222 | movq RSP+\offset(%rsp),\tmp | 223 | movq RSP+\offset(%rsp),\tmp |
223 | movq \tmp,%gs:pda_oldrsp | 224 | movq \tmp,PER_CPU_VAR(old_rsp) |
224 | movq EFLAGS+\offset(%rsp),\tmp | 225 | movq EFLAGS+\offset(%rsp),\tmp |
225 | movq \tmp,R11+\offset(%rsp) | 226 | movq \tmp,R11+\offset(%rsp) |
226 | .endm | 227 | .endm |
@@ -336,15 +337,15 @@ ENTRY(save_args) | |||
336 | je 1f | 337 | je 1f |
337 | SWAPGS | 338 | SWAPGS |
338 | /* | 339 | /* |
339 | * irqcount is used to check if a CPU is already on an interrupt stack | 340 | * irq_count is used to check if a CPU is already on an interrupt stack |
340 | * or not. While this is essentially redundant with preempt_count it is | 341 | * or not. While this is essentially redundant with preempt_count it is |
341 | * a little cheaper to use a separate counter in the PDA (short of | 342 | * a little cheaper to use a separate counter in the PDA (short of |
342 | * moving irq_enter into assembly, which would be too much work) | 343 | * moving irq_enter into assembly, which would be too much work) |
343 | */ | 344 | */ |
344 | 1: incl %gs:pda_irqcount | 345 | 1: incl PER_CPU_VAR(irq_count) |
345 | jne 2f | 346 | jne 2f |
346 | popq_cfi %rax /* move return address... */ | 347 | popq_cfi %rax /* move return address... */ |
347 | mov %gs:pda_irqstackptr,%rsp | 348 | mov PER_CPU_VAR(irq_stack_ptr),%rsp |
348 | EMPTY_FRAME 0 | 349 | EMPTY_FRAME 0 |
349 | pushq_cfi %rax /* ... to the new stack */ | 350 | pushq_cfi %rax /* ... to the new stack */ |
350 | /* | 351 | /* |
@@ -408,6 +409,8 @@ END(save_paranoid) | |||
408 | ENTRY(ret_from_fork) | 409 | ENTRY(ret_from_fork) |
409 | DEFAULT_FRAME | 410 | DEFAULT_FRAME |
410 | 411 | ||
412 | LOCK ; btr $TIF_FORK,TI_flags(%r8) | ||
413 | |||
411 | push kernel_eflags(%rip) | 414 | push kernel_eflags(%rip) |
412 | CFI_ADJUST_CFA_OFFSET 8 | 415 | CFI_ADJUST_CFA_OFFSET 8 |
413 | popf # reset kernel eflags | 416 | popf # reset kernel eflags |
@@ -467,7 +470,7 @@ END(ret_from_fork) | |||
467 | ENTRY(system_call) | 470 | ENTRY(system_call) |
468 | CFI_STARTPROC simple | 471 | CFI_STARTPROC simple |
469 | CFI_SIGNAL_FRAME | 472 | CFI_SIGNAL_FRAME |
470 | CFI_DEF_CFA rsp,PDA_STACKOFFSET | 473 | CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET |
471 | CFI_REGISTER rip,rcx | 474 | CFI_REGISTER rip,rcx |
472 | /*CFI_REGISTER rflags,r11*/ | 475 | /*CFI_REGISTER rflags,r11*/ |
473 | SWAPGS_UNSAFE_STACK | 476 | SWAPGS_UNSAFE_STACK |
@@ -478,8 +481,8 @@ ENTRY(system_call) | |||
478 | */ | 481 | */ |
479 | ENTRY(system_call_after_swapgs) | 482 | ENTRY(system_call_after_swapgs) |
480 | 483 | ||
481 | movq %rsp,%gs:pda_oldrsp | 484 | movq %rsp,PER_CPU_VAR(old_rsp) |
482 | movq %gs:pda_kernelstack,%rsp | 485 | movq PER_CPU_VAR(kernel_stack),%rsp |
483 | /* | 486 | /* |
484 | * No need to follow this irqs off/on section - it's straight | 487 | * No need to follow this irqs off/on section - it's straight |
485 | * and short: | 488 | * and short: |
@@ -522,7 +525,7 @@ sysret_check: | |||
522 | CFI_REGISTER rip,rcx | 525 | CFI_REGISTER rip,rcx |
523 | RESTORE_ARGS 0,-ARG_SKIP,1 | 526 | RESTORE_ARGS 0,-ARG_SKIP,1 |
524 | /*CFI_REGISTER rflags,r11*/ | 527 | /*CFI_REGISTER rflags,r11*/ |
525 | movq %gs:pda_oldrsp, %rsp | 528 | movq PER_CPU_VAR(old_rsp), %rsp |
526 | USERGS_SYSRET64 | 529 | USERGS_SYSRET64 |
527 | 530 | ||
528 | CFI_RESTORE_STATE | 531 | CFI_RESTORE_STATE |
@@ -832,11 +835,11 @@ common_interrupt: | |||
832 | XCPT_FRAME | 835 | XCPT_FRAME |
833 | addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */ | 836 | addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */ |
834 | interrupt do_IRQ | 837 | interrupt do_IRQ |
835 | /* 0(%rsp): oldrsp-ARGOFFSET */ | 838 | /* 0(%rsp): old_rsp-ARGOFFSET */ |
836 | ret_from_intr: | 839 | ret_from_intr: |
837 | DISABLE_INTERRUPTS(CLBR_NONE) | 840 | DISABLE_INTERRUPTS(CLBR_NONE) |
838 | TRACE_IRQS_OFF | 841 | TRACE_IRQS_OFF |
839 | decl %gs:pda_irqcount | 842 | decl PER_CPU_VAR(irq_count) |
840 | leaveq | 843 | leaveq |
841 | CFI_DEF_CFA_REGISTER rsp | 844 | CFI_DEF_CFA_REGISTER rsp |
842 | CFI_ADJUST_CFA_OFFSET -8 | 845 | CFI_ADJUST_CFA_OFFSET -8 |
@@ -981,8 +984,10 @@ apicinterrupt IRQ_MOVE_CLEANUP_VECTOR \ | |||
981 | irq_move_cleanup_interrupt smp_irq_move_cleanup_interrupt | 984 | irq_move_cleanup_interrupt smp_irq_move_cleanup_interrupt |
982 | #endif | 985 | #endif |
983 | 986 | ||
987 | #ifdef CONFIG_X86_UV | ||
984 | apicinterrupt UV_BAU_MESSAGE \ | 988 | apicinterrupt UV_BAU_MESSAGE \ |
985 | uv_bau_message_intr1 uv_bau_message_interrupt | 989 | uv_bau_message_intr1 uv_bau_message_interrupt |
990 | #endif | ||
986 | apicinterrupt LOCAL_TIMER_VECTOR \ | 991 | apicinterrupt LOCAL_TIMER_VECTOR \ |
987 | apic_timer_interrupt smp_apic_timer_interrupt | 992 | apic_timer_interrupt smp_apic_timer_interrupt |
988 | 993 | ||
@@ -1072,10 +1077,10 @@ ENTRY(\sym) | |||
1072 | TRACE_IRQS_OFF | 1077 | TRACE_IRQS_OFF |
1073 | movq %rsp,%rdi /* pt_regs pointer */ | 1078 | movq %rsp,%rdi /* pt_regs pointer */ |
1074 | xorl %esi,%esi /* no error code */ | 1079 | xorl %esi,%esi /* no error code */ |
1075 | movq %gs:pda_data_offset, %rbp | 1080 | PER_CPU(init_tss, %rbp) |
1076 | subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) | 1081 | subq $EXCEPTION_STKSZ, TSS_ist + (\ist - 1) * 8(%rbp) |
1077 | call \do_sym | 1082 | call \do_sym |
1078 | addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) | 1083 | addq $EXCEPTION_STKSZ, TSS_ist + (\ist - 1) * 8(%rbp) |
1079 | jmp paranoid_exit /* %ebx: no swapgs flag */ | 1084 | jmp paranoid_exit /* %ebx: no swapgs flag */ |
1080 | CFI_ENDPROC | 1085 | CFI_ENDPROC |
1081 | END(\sym) | 1086 | END(\sym) |
@@ -1259,14 +1264,14 @@ ENTRY(call_softirq) | |||
1259 | CFI_REL_OFFSET rbp,0 | 1264 | CFI_REL_OFFSET rbp,0 |
1260 | mov %rsp,%rbp | 1265 | mov %rsp,%rbp |
1261 | CFI_DEF_CFA_REGISTER rbp | 1266 | CFI_DEF_CFA_REGISTER rbp |
1262 | incl %gs:pda_irqcount | 1267 | incl PER_CPU_VAR(irq_count) |
1263 | cmove %gs:pda_irqstackptr,%rsp | 1268 | cmove PER_CPU_VAR(irq_stack_ptr),%rsp |
1264 | push %rbp # backlink for old unwinder | 1269 | push %rbp # backlink for old unwinder |
1265 | call __do_softirq | 1270 | call __do_softirq |
1266 | leaveq | 1271 | leaveq |
1267 | CFI_DEF_CFA_REGISTER rsp | 1272 | CFI_DEF_CFA_REGISTER rsp |
1268 | CFI_ADJUST_CFA_OFFSET -8 | 1273 | CFI_ADJUST_CFA_OFFSET -8 |
1269 | decl %gs:pda_irqcount | 1274 | decl PER_CPU_VAR(irq_count) |
1270 | ret | 1275 | ret |
1271 | CFI_ENDPROC | 1276 | CFI_ENDPROC |
1272 | END(call_softirq) | 1277 | END(call_softirq) |
@@ -1296,15 +1301,15 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs) | |||
1296 | movq %rdi, %rsp # we don't return, adjust the stack frame | 1301 | movq %rdi, %rsp # we don't return, adjust the stack frame |
1297 | CFI_ENDPROC | 1302 | CFI_ENDPROC |
1298 | DEFAULT_FRAME | 1303 | DEFAULT_FRAME |
1299 | 11: incl %gs:pda_irqcount | 1304 | 11: incl PER_CPU_VAR(irq_count) |
1300 | movq %rsp,%rbp | 1305 | movq %rsp,%rbp |
1301 | CFI_DEF_CFA_REGISTER rbp | 1306 | CFI_DEF_CFA_REGISTER rbp |
1302 | cmovzq %gs:pda_irqstackptr,%rsp | 1307 | cmovzq PER_CPU_VAR(irq_stack_ptr),%rsp |
1303 | pushq %rbp # backlink for old unwinder | 1308 | pushq %rbp # backlink for old unwinder |
1304 | call xen_evtchn_do_upcall | 1309 | call xen_evtchn_do_upcall |
1305 | popq %rsp | 1310 | popq %rsp |
1306 | CFI_DEF_CFA_REGISTER rsp | 1311 | CFI_DEF_CFA_REGISTER rsp |
1307 | decl %gs:pda_irqcount | 1312 | decl PER_CPU_VAR(irq_count) |
1308 | jmp error_exit | 1313 | jmp error_exit |
1309 | CFI_ENDPROC | 1314 | CFI_ENDPROC |
1310 | END(do_hypervisor_callback) | 1315 | END(do_hypervisor_callback) |
diff --git a/arch/x86/kernel/genapic_64.c b/arch/x86/kernel/genapic_64.c index 2bced78b0b8e..e656c2721154 100644 --- a/arch/x86/kernel/genapic_64.c +++ b/arch/x86/kernel/genapic_64.c | |||
@@ -32,7 +32,9 @@ extern struct genapic apic_x2apic_cluster; | |||
32 | struct genapic __read_mostly *genapic = &apic_flat; | 32 | struct genapic __read_mostly *genapic = &apic_flat; |
33 | 33 | ||
34 | static struct genapic *apic_probe[] __initdata = { | 34 | static struct genapic *apic_probe[] __initdata = { |
35 | #ifdef CONFIG_X86_UV | ||
35 | &apic_x2apic_uv_x, | 36 | &apic_x2apic_uv_x, |
37 | #endif | ||
36 | &apic_x2apic_phys, | 38 | &apic_x2apic_phys, |
37 | &apic_x2apic_cluster, | 39 | &apic_x2apic_cluster, |
38 | &apic_physflat, | 40 | &apic_physflat, |
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c index b193e082f6ce..bfe36249145c 100644 --- a/arch/x86/kernel/genx2apic_uv_x.c +++ b/arch/x86/kernel/genx2apic_uv_x.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <asm/ipi.h> | 25 | #include <asm/ipi.h> |
26 | #include <asm/genapic.h> | 26 | #include <asm/genapic.h> |
27 | #include <asm/pgtable.h> | 27 | #include <asm/pgtable.h> |
28 | #include <asm/uv/uv.h> | ||
28 | #include <asm/uv/uv_mmrs.h> | 29 | #include <asm/uv/uv_mmrs.h> |
29 | #include <asm/uv/uv_hub.h> | 30 | #include <asm/uv/uv_hub.h> |
30 | #include <asm/uv/bios.h> | 31 | #include <asm/uv/bios.h> |
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index b9a4d8c4b935..f5b272247690 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c | |||
@@ -26,27 +26,6 @@ | |||
26 | #include <asm/bios_ebda.h> | 26 | #include <asm/bios_ebda.h> |
27 | #include <asm/trampoline.h> | 27 | #include <asm/trampoline.h> |
28 | 28 | ||
29 | /* boot cpu pda */ | ||
30 | static struct x8664_pda _boot_cpu_pda; | ||
31 | |||
32 | #ifdef CONFIG_SMP | ||
33 | /* | ||
34 | * We install an empty cpu_pda pointer table to indicate to early users | ||
35 | * (numa_set_node) that the cpu_pda pointer table for cpus other than | ||
36 | * the boot cpu is not yet setup. | ||
37 | */ | ||
38 | static struct x8664_pda *__cpu_pda[NR_CPUS] __initdata; | ||
39 | #else | ||
40 | static struct x8664_pda *__cpu_pda[NR_CPUS] __read_mostly; | ||
41 | #endif | ||
42 | |||
43 | void __init x86_64_init_pda(void) | ||
44 | { | ||
45 | _cpu_pda = __cpu_pda; | ||
46 | cpu_pda(0) = &_boot_cpu_pda; | ||
47 | pda_init(0); | ||
48 | } | ||
49 | |||
50 | static void __init zap_identity_mappings(void) | 29 | static void __init zap_identity_mappings(void) |
51 | { | 30 | { |
52 | pgd_t *pgd = pgd_offset_k(0UL); | 31 | pgd_t *pgd = pgd_offset_k(0UL); |
@@ -112,8 +91,6 @@ void __init x86_64_start_kernel(char * real_mode_data) | |||
112 | if (console_loglevel == 10) | 91 | if (console_loglevel == 10) |
113 | early_printk("Kernel alive\n"); | 92 | early_printk("Kernel alive\n"); |
114 | 93 | ||
115 | x86_64_init_pda(); | ||
116 | |||
117 | x86_64_start_reservations(real_mode_data); | 94 | x86_64_start_reservations(real_mode_data); |
118 | } | 95 | } |
119 | 96 | ||
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index e835b4eea70b..722464c520cf 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S | |||
@@ -429,12 +429,14 @@ is386: movl $2,%ecx # set MP | |||
429 | ljmp $(__KERNEL_CS),$1f | 429 | ljmp $(__KERNEL_CS),$1f |
430 | 1: movl $(__KERNEL_DS),%eax # reload all the segment registers | 430 | 1: movl $(__KERNEL_DS),%eax # reload all the segment registers |
431 | movl %eax,%ss # after changing gdt. | 431 | movl %eax,%ss # after changing gdt. |
432 | movl %eax,%fs # gets reset once there's real percpu | ||
433 | 432 | ||
434 | movl $(__USER_DS),%eax # DS/ES contains default USER segment | 433 | movl $(__USER_DS),%eax # DS/ES contains default USER segment |
435 | movl %eax,%ds | 434 | movl %eax,%ds |
436 | movl %eax,%es | 435 | movl %eax,%es |
437 | 436 | ||
437 | movl $(__KERNEL_PERCPU), %eax | ||
438 | movl %eax,%fs # set this cpu's percpu | ||
439 | |||
438 | xorl %eax,%eax # Clear GS and LDT | 440 | xorl %eax,%eax # Clear GS and LDT |
439 | movl %eax,%gs | 441 | movl %eax,%gs |
440 | lldt %ax | 442 | lldt %ax |
@@ -446,8 +448,6 @@ is386: movl $2,%ecx # set MP | |||
446 | movb $1, ready | 448 | movb $1, ready |
447 | cmpb $0,%cl # the first CPU calls start_kernel | 449 | cmpb $0,%cl # the first CPU calls start_kernel |
448 | je 1f | 450 | je 1f |
449 | movl $(__KERNEL_PERCPU), %eax | ||
450 | movl %eax,%fs # set this cpu's percpu | ||
451 | movl (stack_start), %esp | 451 | movl (stack_start), %esp |
452 | 1: | 452 | 1: |
453 | #endif /* CONFIG_SMP */ | 453 | #endif /* CONFIG_SMP */ |
@@ -548,12 +548,8 @@ early_fault: | |||
548 | pushl %eax | 548 | pushl %eax |
549 | pushl %edx /* trapno */ | 549 | pushl %edx /* trapno */ |
550 | pushl $fault_msg | 550 | pushl $fault_msg |
551 | #ifdef CONFIG_EARLY_PRINTK | ||
552 | call early_printk | ||
553 | #else | ||
554 | call printk | 551 | call printk |
555 | #endif | 552 | #endif |
556 | #endif | ||
557 | call dump_stack | 553 | call dump_stack |
558 | hlt_loop: | 554 | hlt_loop: |
559 | hlt | 555 | hlt |
@@ -580,11 +576,10 @@ ignore_int: | |||
580 | pushl 32(%esp) | 576 | pushl 32(%esp) |
581 | pushl 40(%esp) | 577 | pushl 40(%esp) |
582 | pushl $int_msg | 578 | pushl $int_msg |
583 | #ifdef CONFIG_EARLY_PRINTK | ||
584 | call early_printk | ||
585 | #else | ||
586 | call printk | 579 | call printk |
587 | #endif | 580 | |
581 | call dump_stack | ||
582 | |||
588 | addl $(5*4),%esp | 583 | addl $(5*4),%esp |
589 | popl %ds | 584 | popl %ds |
590 | popl %es | 585 | popl %es |
@@ -660,7 +655,7 @@ early_recursion_flag: | |||
660 | .long 0 | 655 | .long 0 |
661 | 656 | ||
662 | int_msg: | 657 | int_msg: |
663 | .asciz "Unknown interrupt or fault at EIP %p %p %p\n" | 658 | .asciz "Unknown interrupt or fault at: %p %p %p\n" |
664 | 659 | ||
665 | fault_msg: | 660 | fault_msg: |
666 | /* fault info: */ | 661 | /* fault info: */ |
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 0e275d495563..a0a2b5ca9b7d 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <asm/msr.h> | 19 | #include <asm/msr.h> |
20 | #include <asm/cache.h> | 20 | #include <asm/cache.h> |
21 | #include <asm/processor-flags.h> | 21 | #include <asm/processor-flags.h> |
22 | #include <asm/percpu.h> | ||
22 | 23 | ||
23 | #ifdef CONFIG_PARAVIRT | 24 | #ifdef CONFIG_PARAVIRT |
24 | #include <asm/asm-offsets.h> | 25 | #include <asm/asm-offsets.h> |
@@ -204,6 +205,19 @@ ENTRY(secondary_startup_64) | |||
204 | pushq $0 | 205 | pushq $0 |
205 | popfq | 206 | popfq |
206 | 207 | ||
208 | #ifdef CONFIG_SMP | ||
209 | /* | ||
210 | * Fix up static pointers that need __per_cpu_load added. The assembler | ||
211 | * is unable to do this directly. This is only needed for the boot cpu. | ||
212 | * These values are set up with the correct base addresses by C code for | ||
213 | * secondary cpus. | ||
214 | */ | ||
215 | movq initial_gs(%rip), %rax | ||
216 | cmpl $0, per_cpu__cpu_number(%rax) | ||
217 | jne 1f | ||
218 | addq %rax, early_gdt_descr_base(%rip) | ||
219 | 1: | ||
220 | #endif | ||
207 | /* | 221 | /* |
208 | * We must switch to a new descriptor in kernel space for the GDT | 222 | * We must switch to a new descriptor in kernel space for the GDT |
209 | * because soon the kernel won't have access anymore to the userspace | 223 | * because soon the kernel won't have access anymore to the userspace |
@@ -226,12 +240,15 @@ ENTRY(secondary_startup_64) | |||
226 | movl %eax,%fs | 240 | movl %eax,%fs |
227 | movl %eax,%gs | 241 | movl %eax,%gs |
228 | 242 | ||
229 | /* | 243 | /* Set up %gs. |
230 | * Setup up a dummy PDA. this is just for some early bootup code | 244 | * |
231 | * that does in_interrupt() | 245 | * The base of %gs always points to the bottom of the irqstack |
232 | */ | 246 | * union. If the stack protector canary is enabled, it is |
247 | * located at %gs:40. Note that, on SMP, the boot cpu uses | ||
248 | * init data section till per cpu areas are set up. | ||
249 | */ | ||
233 | movl $MSR_GS_BASE,%ecx | 250 | movl $MSR_GS_BASE,%ecx |
234 | movq $empty_zero_page,%rax | 251 | movq initial_gs(%rip),%rax |
235 | movq %rax,%rdx | 252 | movq %rax,%rdx |
236 | shrq $32,%rdx | 253 | shrq $32,%rdx |
237 | wrmsr | 254 | wrmsr |
@@ -257,6 +274,12 @@ ENTRY(secondary_startup_64) | |||
257 | .align 8 | 274 | .align 8 |
258 | ENTRY(initial_code) | 275 | ENTRY(initial_code) |
259 | .quad x86_64_start_kernel | 276 | .quad x86_64_start_kernel |
277 | ENTRY(initial_gs) | ||
278 | #ifdef CONFIG_SMP | ||
279 | .quad __per_cpu_load | ||
280 | #else | ||
281 | .quad PER_CPU_VAR(irq_stack_union) | ||
282 | #endif | ||
260 | __FINITDATA | 283 | __FINITDATA |
261 | 284 | ||
262 | ENTRY(stack_start) | 285 | ENTRY(stack_start) |
@@ -401,7 +424,8 @@ NEXT_PAGE(level2_spare_pgt) | |||
401 | .globl early_gdt_descr | 424 | .globl early_gdt_descr |
402 | early_gdt_descr: | 425 | early_gdt_descr: |
403 | .word GDT_ENTRIES*8-1 | 426 | .word GDT_ENTRIES*8-1 |
404 | .quad per_cpu__gdt_page | 427 | early_gdt_descr_base: |
428 | .quad per_cpu__gdt_page | ||
405 | 429 | ||
406 | ENTRY(phys_base) | 430 | ENTRY(phys_base) |
407 | /* This must match the first entry in level2_kernel_pgt */ | 431 | /* This must match the first entry in level2_kernel_pgt */ |
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index cd759ad90690..64d5ad0b8add 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c | |||
@@ -628,11 +628,12 @@ static int hpet_cpuhp_notify(struct notifier_block *n, | |||
628 | 628 | ||
629 | switch (action & 0xf) { | 629 | switch (action & 0xf) { |
630 | case CPU_ONLINE: | 630 | case CPU_ONLINE: |
631 | INIT_DELAYED_WORK(&work.work, hpet_work); | 631 | INIT_DELAYED_WORK_ON_STACK(&work.work, hpet_work); |
632 | init_completion(&work.complete); | 632 | init_completion(&work.complete); |
633 | /* FIXME: add schedule_work_on() */ | 633 | /* FIXME: add schedule_work_on() */ |
634 | schedule_delayed_work_on(cpu, &work.work, 0); | 634 | schedule_delayed_work_on(cpu, &work.work, 0); |
635 | wait_for_completion(&work.complete); | 635 | wait_for_completion(&work.complete); |
636 | destroy_timer_on_stack(&work.work.timer); | ||
636 | break; | 637 | break; |
637 | case CPU_DEAD: | 638 | case CPU_DEAD: |
638 | if (hdev) { | 639 | if (hdev) { |
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c index 1c4a1302536c..bfb7d734062a 100644 --- a/arch/x86/kernel/io_apic.c +++ b/arch/x86/kernel/io_apic.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <asm/idle.h> | 46 | #include <asm/idle.h> |
47 | #include <asm/io.h> | 47 | #include <asm/io.h> |
48 | #include <asm/smp.h> | 48 | #include <asm/smp.h> |
49 | #include <asm/cpu.h> | ||
49 | #include <asm/desc.h> | 50 | #include <asm/desc.h> |
50 | #include <asm/proto.h> | 51 | #include <asm/proto.h> |
51 | #include <asm/acpi.h> | 52 | #include <asm/acpi.h> |
@@ -82,11 +83,11 @@ static DEFINE_SPINLOCK(vector_lock); | |||
82 | int nr_ioapic_registers[MAX_IO_APICS]; | 83 | int nr_ioapic_registers[MAX_IO_APICS]; |
83 | 84 | ||
84 | /* I/O APIC entries */ | 85 | /* I/O APIC entries */ |
85 | struct mp_config_ioapic mp_ioapics[MAX_IO_APICS]; | 86 | struct mpc_ioapic mp_ioapics[MAX_IO_APICS]; |
86 | int nr_ioapics; | 87 | int nr_ioapics; |
87 | 88 | ||
88 | /* MP IRQ source entries */ | 89 | /* MP IRQ source entries */ |
89 | struct mp_config_intsrc mp_irqs[MAX_IRQ_SOURCES]; | 90 | struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES]; |
90 | 91 | ||
91 | /* # of MP IRQ source entries */ | 92 | /* # of MP IRQ source entries */ |
92 | int mp_irq_entries; | 93 | int mp_irq_entries; |
@@ -356,7 +357,7 @@ set_extra_move_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
356 | 357 | ||
357 | if (!cfg->move_in_progress) { | 358 | if (!cfg->move_in_progress) { |
358 | /* it means that domain is not changed */ | 359 | /* it means that domain is not changed */ |
359 | if (!cpumask_intersects(&desc->affinity, mask)) | 360 | if (!cpumask_intersects(desc->affinity, mask)) |
360 | cfg->move_desc_pending = 1; | 361 | cfg->move_desc_pending = 1; |
361 | } | 362 | } |
362 | } | 363 | } |
@@ -386,7 +387,7 @@ struct io_apic { | |||
386 | static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx) | 387 | static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx) |
387 | { | 388 | { |
388 | return (void __iomem *) __fix_to_virt(FIX_IO_APIC_BASE_0 + idx) | 389 | return (void __iomem *) __fix_to_virt(FIX_IO_APIC_BASE_0 + idx) |
389 | + (mp_ioapics[idx].mp_apicaddr & ~PAGE_MASK); | 390 | + (mp_ioapics[idx].apicaddr & ~PAGE_MASK); |
390 | } | 391 | } |
391 | 392 | ||
392 | static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) | 393 | static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) |
@@ -579,9 +580,9 @@ set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) | |||
579 | if (assign_irq_vector(irq, cfg, mask)) | 580 | if (assign_irq_vector(irq, cfg, mask)) |
580 | return BAD_APICID; | 581 | return BAD_APICID; |
581 | 582 | ||
582 | cpumask_and(&desc->affinity, cfg->domain, mask); | 583 | cpumask_and(desc->affinity, cfg->domain, mask); |
583 | set_extra_move_desc(desc, mask); | 584 | set_extra_move_desc(desc, mask); |
584 | return cpu_mask_to_apicid_and(&desc->affinity, cpu_online_mask); | 585 | return cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask); |
585 | } | 586 | } |
586 | 587 | ||
587 | static void | 588 | static void |
@@ -944,10 +945,10 @@ static int find_irq_entry(int apic, int pin, int type) | |||
944 | int i; | 945 | int i; |
945 | 946 | ||
946 | for (i = 0; i < mp_irq_entries; i++) | 947 | for (i = 0; i < mp_irq_entries; i++) |
947 | if (mp_irqs[i].mp_irqtype == type && | 948 | if (mp_irqs[i].irqtype == type && |
948 | (mp_irqs[i].mp_dstapic == mp_ioapics[apic].mp_apicid || | 949 | (mp_irqs[i].dstapic == mp_ioapics[apic].apicid || |
949 | mp_irqs[i].mp_dstapic == MP_APIC_ALL) && | 950 | mp_irqs[i].dstapic == MP_APIC_ALL) && |
950 | mp_irqs[i].mp_dstirq == pin) | 951 | mp_irqs[i].dstirq == pin) |
951 | return i; | 952 | return i; |
952 | 953 | ||
953 | return -1; | 954 | return -1; |
@@ -961,13 +962,13 @@ static int __init find_isa_irq_pin(int irq, int type) | |||
961 | int i; | 962 | int i; |
962 | 963 | ||
963 | for (i = 0; i < mp_irq_entries; i++) { | 964 | for (i = 0; i < mp_irq_entries; i++) { |
964 | int lbus = mp_irqs[i].mp_srcbus; | 965 | int lbus = mp_irqs[i].srcbus; |
965 | 966 | ||
966 | if (test_bit(lbus, mp_bus_not_pci) && | 967 | if (test_bit(lbus, mp_bus_not_pci) && |
967 | (mp_irqs[i].mp_irqtype == type) && | 968 | (mp_irqs[i].irqtype == type) && |
968 | (mp_irqs[i].mp_srcbusirq == irq)) | 969 | (mp_irqs[i].srcbusirq == irq)) |
969 | 970 | ||
970 | return mp_irqs[i].mp_dstirq; | 971 | return mp_irqs[i].dstirq; |
971 | } | 972 | } |
972 | return -1; | 973 | return -1; |
973 | } | 974 | } |
@@ -977,17 +978,17 @@ static int __init find_isa_irq_apic(int irq, int type) | |||
977 | int i; | 978 | int i; |
978 | 979 | ||
979 | for (i = 0; i < mp_irq_entries; i++) { | 980 | for (i = 0; i < mp_irq_entries; i++) { |
980 | int lbus = mp_irqs[i].mp_srcbus; | 981 | int lbus = mp_irqs[i].srcbus; |
981 | 982 | ||
982 | if (test_bit(lbus, mp_bus_not_pci) && | 983 | if (test_bit(lbus, mp_bus_not_pci) && |
983 | (mp_irqs[i].mp_irqtype == type) && | 984 | (mp_irqs[i].irqtype == type) && |
984 | (mp_irqs[i].mp_srcbusirq == irq)) | 985 | (mp_irqs[i].srcbusirq == irq)) |
985 | break; | 986 | break; |
986 | } | 987 | } |
987 | if (i < mp_irq_entries) { | 988 | if (i < mp_irq_entries) { |
988 | int apic; | 989 | int apic; |
989 | for(apic = 0; apic < nr_ioapics; apic++) { | 990 | for(apic = 0; apic < nr_ioapics; apic++) { |
990 | if (mp_ioapics[apic].mp_apicid == mp_irqs[i].mp_dstapic) | 991 | if (mp_ioapics[apic].apicid == mp_irqs[i].dstapic) |
991 | return apic; | 992 | return apic; |
992 | } | 993 | } |
993 | } | 994 | } |
@@ -1012,23 +1013,23 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin) | |||
1012 | return -1; | 1013 | return -1; |
1013 | } | 1014 | } |
1014 | for (i = 0; i < mp_irq_entries; i++) { | 1015 | for (i = 0; i < mp_irq_entries; i++) { |
1015 | int lbus = mp_irqs[i].mp_srcbus; | 1016 | int lbus = mp_irqs[i].srcbus; |
1016 | 1017 | ||
1017 | for (apic = 0; apic < nr_ioapics; apic++) | 1018 | for (apic = 0; apic < nr_ioapics; apic++) |
1018 | if (mp_ioapics[apic].mp_apicid == mp_irqs[i].mp_dstapic || | 1019 | if (mp_ioapics[apic].apicid == mp_irqs[i].dstapic || |
1019 | mp_irqs[i].mp_dstapic == MP_APIC_ALL) | 1020 | mp_irqs[i].dstapic == MP_APIC_ALL) |
1020 | break; | 1021 | break; |
1021 | 1022 | ||
1022 | if (!test_bit(lbus, mp_bus_not_pci) && | 1023 | if (!test_bit(lbus, mp_bus_not_pci) && |
1023 | !mp_irqs[i].mp_irqtype && | 1024 | !mp_irqs[i].irqtype && |
1024 | (bus == lbus) && | 1025 | (bus == lbus) && |
1025 | (slot == ((mp_irqs[i].mp_srcbusirq >> 2) & 0x1f))) { | 1026 | (slot == ((mp_irqs[i].srcbusirq >> 2) & 0x1f))) { |
1026 | int irq = pin_2_irq(i,apic,mp_irqs[i].mp_dstirq); | 1027 | int irq = pin_2_irq(i, apic, mp_irqs[i].dstirq); |
1027 | 1028 | ||
1028 | if (!(apic || IO_APIC_IRQ(irq))) | 1029 | if (!(apic || IO_APIC_IRQ(irq))) |
1029 | continue; | 1030 | continue; |
1030 | 1031 | ||
1031 | if (pin == (mp_irqs[i].mp_srcbusirq & 3)) | 1032 | if (pin == (mp_irqs[i].srcbusirq & 3)) |
1032 | return irq; | 1033 | return irq; |
1033 | /* | 1034 | /* |
1034 | * Use the first all-but-pin matching entry as a | 1035 | * Use the first all-but-pin matching entry as a |
@@ -1071,7 +1072,7 @@ static int EISA_ELCR(unsigned int irq) | |||
1071 | * EISA conforming in the MP table, that means its trigger type must | 1072 | * EISA conforming in the MP table, that means its trigger type must |
1072 | * be read in from the ELCR */ | 1073 | * be read in from the ELCR */ |
1073 | 1074 | ||
1074 | #define default_EISA_trigger(idx) (EISA_ELCR(mp_irqs[idx].mp_srcbusirq)) | 1075 | #define default_EISA_trigger(idx) (EISA_ELCR(mp_irqs[idx].srcbusirq)) |
1075 | #define default_EISA_polarity(idx) default_ISA_polarity(idx) | 1076 | #define default_EISA_polarity(idx) default_ISA_polarity(idx) |
1076 | 1077 | ||
1077 | /* PCI interrupts are always polarity one level triggered, | 1078 | /* PCI interrupts are always polarity one level triggered, |
@@ -1088,13 +1089,13 @@ static int EISA_ELCR(unsigned int irq) | |||
1088 | 1089 | ||
1089 | static int MPBIOS_polarity(int idx) | 1090 | static int MPBIOS_polarity(int idx) |
1090 | { | 1091 | { |
1091 | int bus = mp_irqs[idx].mp_srcbus; | 1092 | int bus = mp_irqs[idx].srcbus; |
1092 | int polarity; | 1093 | int polarity; |
1093 | 1094 | ||
1094 | /* | 1095 | /* |
1095 | * Determine IRQ line polarity (high active or low active): | 1096 | * Determine IRQ line polarity (high active or low active): |
1096 | */ | 1097 | */ |
1097 | switch (mp_irqs[idx].mp_irqflag & 3) | 1098 | switch (mp_irqs[idx].irqflag & 3) |
1098 | { | 1099 | { |
1099 | case 0: /* conforms, ie. bus-type dependent polarity */ | 1100 | case 0: /* conforms, ie. bus-type dependent polarity */ |
1100 | if (test_bit(bus, mp_bus_not_pci)) | 1101 | if (test_bit(bus, mp_bus_not_pci)) |
@@ -1130,13 +1131,13 @@ static int MPBIOS_polarity(int idx) | |||
1130 | 1131 | ||
1131 | static int MPBIOS_trigger(int idx) | 1132 | static int MPBIOS_trigger(int idx) |
1132 | { | 1133 | { |
1133 | int bus = mp_irqs[idx].mp_srcbus; | 1134 | int bus = mp_irqs[idx].srcbus; |
1134 | int trigger; | 1135 | int trigger; |
1135 | 1136 | ||
1136 | /* | 1137 | /* |
1137 | * Determine IRQ trigger mode (edge or level sensitive): | 1138 | * Determine IRQ trigger mode (edge or level sensitive): |
1138 | */ | 1139 | */ |
1139 | switch ((mp_irqs[idx].mp_irqflag>>2) & 3) | 1140 | switch ((mp_irqs[idx].irqflag>>2) & 3) |
1140 | { | 1141 | { |
1141 | case 0: /* conforms, ie. bus-type dependent */ | 1142 | case 0: /* conforms, ie. bus-type dependent */ |
1142 | if (test_bit(bus, mp_bus_not_pci)) | 1143 | if (test_bit(bus, mp_bus_not_pci)) |
@@ -1214,16 +1215,16 @@ int (*ioapic_renumber_irq)(int ioapic, int irq); | |||
1214 | static int pin_2_irq(int idx, int apic, int pin) | 1215 | static int pin_2_irq(int idx, int apic, int pin) |
1215 | { | 1216 | { |
1216 | int irq, i; | 1217 | int irq, i; |
1217 | int bus = mp_irqs[idx].mp_srcbus; | 1218 | int bus = mp_irqs[idx].srcbus; |
1218 | 1219 | ||
1219 | /* | 1220 | /* |
1220 | * Debugging check, we are in big trouble if this message pops up! | 1221 | * Debugging check, we are in big trouble if this message pops up! |
1221 | */ | 1222 | */ |
1222 | if (mp_irqs[idx].mp_dstirq != pin) | 1223 | if (mp_irqs[idx].dstirq != pin) |
1223 | printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n"); | 1224 | printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n"); |
1224 | 1225 | ||
1225 | if (test_bit(bus, mp_bus_not_pci)) { | 1226 | if (test_bit(bus, mp_bus_not_pci)) { |
1226 | irq = mp_irqs[idx].mp_srcbusirq; | 1227 | irq = mp_irqs[idx].srcbusirq; |
1227 | } else { | 1228 | } else { |
1228 | /* | 1229 | /* |
1229 | * PCI IRQs are mapped in order | 1230 | * PCI IRQs are mapped in order |
@@ -1566,14 +1567,14 @@ static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, struct irq_de | |||
1566 | apic_printk(APIC_VERBOSE,KERN_DEBUG | 1567 | apic_printk(APIC_VERBOSE,KERN_DEBUG |
1567 | "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " | 1568 | "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " |
1568 | "IRQ %d Mode:%i Active:%i)\n", | 1569 | "IRQ %d Mode:%i Active:%i)\n", |
1569 | apic, mp_ioapics[apic].mp_apicid, pin, cfg->vector, | 1570 | apic, mp_ioapics[apic].apicid, pin, cfg->vector, |
1570 | irq, trigger, polarity); | 1571 | irq, trigger, polarity); |
1571 | 1572 | ||
1572 | 1573 | ||
1573 | if (setup_ioapic_entry(mp_ioapics[apic].mp_apicid, irq, &entry, | 1574 | if (setup_ioapic_entry(mp_ioapics[apic].apicid, irq, &entry, |
1574 | dest, trigger, polarity, cfg->vector)) { | 1575 | dest, trigger, polarity, cfg->vector)) { |
1575 | printk("Failed to setup ioapic entry for ioapic %d, pin %d\n", | 1576 | printk("Failed to setup ioapic entry for ioapic %d, pin %d\n", |
1576 | mp_ioapics[apic].mp_apicid, pin); | 1577 | mp_ioapics[apic].apicid, pin); |
1577 | __clear_irq_vector(irq, cfg); | 1578 | __clear_irq_vector(irq, cfg); |
1578 | return; | 1579 | return; |
1579 | } | 1580 | } |
@@ -1604,12 +1605,10 @@ static void __init setup_IO_APIC_irqs(void) | |||
1604 | notcon = 1; | 1605 | notcon = 1; |
1605 | apic_printk(APIC_VERBOSE, | 1606 | apic_printk(APIC_VERBOSE, |
1606 | KERN_DEBUG " %d-%d", | 1607 | KERN_DEBUG " %d-%d", |
1607 | mp_ioapics[apic].mp_apicid, | 1608 | mp_ioapics[apic].apicid, pin); |
1608 | pin); | ||
1609 | } else | 1609 | } else |
1610 | apic_printk(APIC_VERBOSE, " %d-%d", | 1610 | apic_printk(APIC_VERBOSE, " %d-%d", |
1611 | mp_ioapics[apic].mp_apicid, | 1611 | mp_ioapics[apic].apicid, pin); |
1612 | pin); | ||
1613 | continue; | 1612 | continue; |
1614 | } | 1613 | } |
1615 | if (notcon) { | 1614 | if (notcon) { |
@@ -1699,7 +1698,7 @@ __apicdebuginit(void) print_IO_APIC(void) | |||
1699 | printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries); | 1698 | printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries); |
1700 | for (i = 0; i < nr_ioapics; i++) | 1699 | for (i = 0; i < nr_ioapics; i++) |
1701 | printk(KERN_DEBUG "number of IO-APIC #%d registers: %d.\n", | 1700 | printk(KERN_DEBUG "number of IO-APIC #%d registers: %d.\n", |
1702 | mp_ioapics[i].mp_apicid, nr_ioapic_registers[i]); | 1701 | mp_ioapics[i].apicid, nr_ioapic_registers[i]); |
1703 | 1702 | ||
1704 | /* | 1703 | /* |
1705 | * We are a bit conservative about what we expect. We have to | 1704 | * We are a bit conservative about what we expect. We have to |
@@ -1719,7 +1718,7 @@ __apicdebuginit(void) print_IO_APIC(void) | |||
1719 | spin_unlock_irqrestore(&ioapic_lock, flags); | 1718 | spin_unlock_irqrestore(&ioapic_lock, flags); |
1720 | 1719 | ||
1721 | printk("\n"); | 1720 | printk("\n"); |
1722 | printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].mp_apicid); | 1721 | printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].apicid); |
1723 | printk(KERN_DEBUG ".... register #00: %08X\n", reg_00.raw); | 1722 | printk(KERN_DEBUG ".... register #00: %08X\n", reg_00.raw); |
1724 | printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID); | 1723 | printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID); |
1725 | printk(KERN_DEBUG "....... : Delivery Type: %X\n", reg_00.bits.delivery_type); | 1724 | printk(KERN_DEBUG "....... : Delivery Type: %X\n", reg_00.bits.delivery_type); |
@@ -2121,14 +2120,14 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
2121 | reg_00.raw = io_apic_read(apic, 0); | 2120 | reg_00.raw = io_apic_read(apic, 0); |
2122 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2121 | spin_unlock_irqrestore(&ioapic_lock, flags); |
2123 | 2122 | ||
2124 | old_id = mp_ioapics[apic].mp_apicid; | 2123 | old_id = mp_ioapics[apic].apicid; |
2125 | 2124 | ||
2126 | if (mp_ioapics[apic].mp_apicid >= get_physical_broadcast()) { | 2125 | if (mp_ioapics[apic].apicid >= get_physical_broadcast()) { |
2127 | printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n", | 2126 | printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n", |
2128 | apic, mp_ioapics[apic].mp_apicid); | 2127 | apic, mp_ioapics[apic].apicid); |
2129 | printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", | 2128 | printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", |
2130 | reg_00.bits.ID); | 2129 | reg_00.bits.ID); |
2131 | mp_ioapics[apic].mp_apicid = reg_00.bits.ID; | 2130 | mp_ioapics[apic].apicid = reg_00.bits.ID; |
2132 | } | 2131 | } |
2133 | 2132 | ||
2134 | /* | 2133 | /* |
@@ -2137,9 +2136,9 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
2137 | * 'stuck on smp_invalidate_needed IPI wait' messages. | 2136 | * 'stuck on smp_invalidate_needed IPI wait' messages. |
2138 | */ | 2137 | */ |
2139 | if (check_apicid_used(phys_id_present_map, | 2138 | if (check_apicid_used(phys_id_present_map, |
2140 | mp_ioapics[apic].mp_apicid)) { | 2139 | mp_ioapics[apic].apicid)) { |
2141 | printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n", | 2140 | printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n", |
2142 | apic, mp_ioapics[apic].mp_apicid); | 2141 | apic, mp_ioapics[apic].apicid); |
2143 | for (i = 0; i < get_physical_broadcast(); i++) | 2142 | for (i = 0; i < get_physical_broadcast(); i++) |
2144 | if (!physid_isset(i, phys_id_present_map)) | 2143 | if (!physid_isset(i, phys_id_present_map)) |
2145 | break; | 2144 | break; |
@@ -2148,13 +2147,13 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
2148 | printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", | 2147 | printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", |
2149 | i); | 2148 | i); |
2150 | physid_set(i, phys_id_present_map); | 2149 | physid_set(i, phys_id_present_map); |
2151 | mp_ioapics[apic].mp_apicid = i; | 2150 | mp_ioapics[apic].apicid = i; |
2152 | } else { | 2151 | } else { |
2153 | physid_mask_t tmp; | 2152 | physid_mask_t tmp; |
2154 | tmp = apicid_to_cpu_present(mp_ioapics[apic].mp_apicid); | 2153 | tmp = apicid_to_cpu_present(mp_ioapics[apic].apicid); |
2155 | apic_printk(APIC_VERBOSE, "Setting %d in the " | 2154 | apic_printk(APIC_VERBOSE, "Setting %d in the " |
2156 | "phys_id_present_map\n", | 2155 | "phys_id_present_map\n", |
2157 | mp_ioapics[apic].mp_apicid); | 2156 | mp_ioapics[apic].apicid); |
2158 | physids_or(phys_id_present_map, phys_id_present_map, tmp); | 2157 | physids_or(phys_id_present_map, phys_id_present_map, tmp); |
2159 | } | 2158 | } |
2160 | 2159 | ||
@@ -2163,11 +2162,11 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
2163 | * We need to adjust the IRQ routing table | 2162 | * We need to adjust the IRQ routing table |
2164 | * if the ID changed. | 2163 | * if the ID changed. |
2165 | */ | 2164 | */ |
2166 | if (old_id != mp_ioapics[apic].mp_apicid) | 2165 | if (old_id != mp_ioapics[apic].apicid) |
2167 | for (i = 0; i < mp_irq_entries; i++) | 2166 | for (i = 0; i < mp_irq_entries; i++) |
2168 | if (mp_irqs[i].mp_dstapic == old_id) | 2167 | if (mp_irqs[i].dstapic == old_id) |
2169 | mp_irqs[i].mp_dstapic | 2168 | mp_irqs[i].dstapic |
2170 | = mp_ioapics[apic].mp_apicid; | 2169 | = mp_ioapics[apic].apicid; |
2171 | 2170 | ||
2172 | /* | 2171 | /* |
2173 | * Read the right value from the MPC table and | 2172 | * Read the right value from the MPC table and |
@@ -2175,9 +2174,9 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
2175 | */ | 2174 | */ |
2176 | apic_printk(APIC_VERBOSE, KERN_INFO | 2175 | apic_printk(APIC_VERBOSE, KERN_INFO |
2177 | "...changing IO-APIC physical APIC ID to %d ...", | 2176 | "...changing IO-APIC physical APIC ID to %d ...", |
2178 | mp_ioapics[apic].mp_apicid); | 2177 | mp_ioapics[apic].apicid); |
2179 | 2178 | ||
2180 | reg_00.bits.ID = mp_ioapics[apic].mp_apicid; | 2179 | reg_00.bits.ID = mp_ioapics[apic].apicid; |
2181 | spin_lock_irqsave(&ioapic_lock, flags); | 2180 | spin_lock_irqsave(&ioapic_lock, flags); |
2182 | io_apic_write(apic, 0, reg_00.raw); | 2181 | io_apic_write(apic, 0, reg_00.raw); |
2183 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2182 | spin_unlock_irqrestore(&ioapic_lock, flags); |
@@ -2188,7 +2187,7 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
2188 | spin_lock_irqsave(&ioapic_lock, flags); | 2187 | spin_lock_irqsave(&ioapic_lock, flags); |
2189 | reg_00.raw = io_apic_read(apic, 0); | 2188 | reg_00.raw = io_apic_read(apic, 0); |
2190 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2189 | spin_unlock_irqrestore(&ioapic_lock, flags); |
2191 | if (reg_00.bits.ID != mp_ioapics[apic].mp_apicid) | 2190 | if (reg_00.bits.ID != mp_ioapics[apic].apicid) |
2192 | printk("could not set ID!\n"); | 2191 | printk("could not set ID!\n"); |
2193 | else | 2192 | else |
2194 | apic_printk(APIC_VERBOSE, " ok.\n"); | 2193 | apic_printk(APIC_VERBOSE, " ok.\n"); |
@@ -2383,7 +2382,7 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
2383 | if (cfg->move_in_progress) | 2382 | if (cfg->move_in_progress) |
2384 | send_cleanup_vector(cfg); | 2383 | send_cleanup_vector(cfg); |
2385 | 2384 | ||
2386 | cpumask_copy(&desc->affinity, mask); | 2385 | cpumask_copy(desc->affinity, mask); |
2387 | } | 2386 | } |
2388 | 2387 | ||
2389 | static int migrate_irq_remapped_level_desc(struct irq_desc *desc) | 2388 | static int migrate_irq_remapped_level_desc(struct irq_desc *desc) |
@@ -2405,11 +2404,11 @@ static int migrate_irq_remapped_level_desc(struct irq_desc *desc) | |||
2405 | } | 2404 | } |
2406 | 2405 | ||
2407 | /* everthing is clear. we have right of way */ | 2406 | /* everthing is clear. we have right of way */ |
2408 | migrate_ioapic_irq_desc(desc, &desc->pending_mask); | 2407 | migrate_ioapic_irq_desc(desc, desc->pending_mask); |
2409 | 2408 | ||
2410 | ret = 0; | 2409 | ret = 0; |
2411 | desc->status &= ~IRQ_MOVE_PENDING; | 2410 | desc->status &= ~IRQ_MOVE_PENDING; |
2412 | cpumask_clear(&desc->pending_mask); | 2411 | cpumask_clear(desc->pending_mask); |
2413 | 2412 | ||
2414 | unmask: | 2413 | unmask: |
2415 | unmask_IO_APIC_irq_desc(desc); | 2414 | unmask_IO_APIC_irq_desc(desc); |
@@ -2434,7 +2433,7 @@ static void ir_irq_migration(struct work_struct *work) | |||
2434 | continue; | 2433 | continue; |
2435 | } | 2434 | } |
2436 | 2435 | ||
2437 | desc->chip->set_affinity(irq, &desc->pending_mask); | 2436 | desc->chip->set_affinity(irq, desc->pending_mask); |
2438 | spin_unlock_irqrestore(&desc->lock, flags); | 2437 | spin_unlock_irqrestore(&desc->lock, flags); |
2439 | } | 2438 | } |
2440 | } | 2439 | } |
@@ -2448,7 +2447,7 @@ static void set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, | |||
2448 | { | 2447 | { |
2449 | if (desc->status & IRQ_LEVEL) { | 2448 | if (desc->status & IRQ_LEVEL) { |
2450 | desc->status |= IRQ_MOVE_PENDING; | 2449 | desc->status |= IRQ_MOVE_PENDING; |
2451 | cpumask_copy(&desc->pending_mask, mask); | 2450 | cpumask_copy(desc->pending_mask, mask); |
2452 | migrate_irq_remapped_level_desc(desc); | 2451 | migrate_irq_remapped_level_desc(desc); |
2453 | return; | 2452 | return; |
2454 | } | 2453 | } |
@@ -2516,7 +2515,7 @@ static void irq_complete_move(struct irq_desc **descp) | |||
2516 | 2515 | ||
2517 | /* domain has not changed, but affinity did */ | 2516 | /* domain has not changed, but affinity did */ |
2518 | me = smp_processor_id(); | 2517 | me = smp_processor_id(); |
2519 | if (cpu_isset(me, desc->affinity)) { | 2518 | if (cpumask_test_cpu(me, desc->affinity)) { |
2520 | *descp = desc = move_irq_desc(desc, me); | 2519 | *descp = desc = move_irq_desc(desc, me); |
2521 | /* get the new one */ | 2520 | /* get the new one */ |
2522 | cfg = desc->chip_data; | 2521 | cfg = desc->chip_data; |
@@ -3117,8 +3116,8 @@ static int ioapic_resume(struct sys_device *dev) | |||
3117 | 3116 | ||
3118 | spin_lock_irqsave(&ioapic_lock, flags); | 3117 | spin_lock_irqsave(&ioapic_lock, flags); |
3119 | reg_00.raw = io_apic_read(dev->id, 0); | 3118 | reg_00.raw = io_apic_read(dev->id, 0); |
3120 | if (reg_00.bits.ID != mp_ioapics[dev->id].mp_apicid) { | 3119 | if (reg_00.bits.ID != mp_ioapics[dev->id].apicid) { |
3121 | reg_00.bits.ID = mp_ioapics[dev->id].mp_apicid; | 3120 | reg_00.bits.ID = mp_ioapics[dev->id].apicid; |
3122 | io_apic_write(dev->id, 0, reg_00.raw); | 3121 | io_apic_write(dev->id, 0, reg_00.raw); |
3123 | } | 3122 | } |
3124 | spin_unlock_irqrestore(&ioapic_lock, flags); | 3123 | spin_unlock_irqrestore(&ioapic_lock, flags); |
@@ -3183,7 +3182,7 @@ unsigned int create_irq_nr(unsigned int irq_want) | |||
3183 | 3182 | ||
3184 | irq = 0; | 3183 | irq = 0; |
3185 | spin_lock_irqsave(&vector_lock, flags); | 3184 | spin_lock_irqsave(&vector_lock, flags); |
3186 | for (new = irq_want; new < NR_IRQS; new++) { | 3185 | for (new = irq_want; new < nr_irqs; new++) { |
3187 | if (platform_legacy_irq(new)) | 3186 | if (platform_legacy_irq(new)) |
3188 | continue; | 3187 | continue; |
3189 | 3188 | ||
@@ -3258,6 +3257,9 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms | |||
3258 | int err; | 3257 | int err; |
3259 | unsigned dest; | 3258 | unsigned dest; |
3260 | 3259 | ||
3260 | if (disable_apic) | ||
3261 | return -ENXIO; | ||
3262 | |||
3261 | cfg = irq_cfg(irq); | 3263 | cfg = irq_cfg(irq); |
3262 | err = assign_irq_vector(irq, cfg, TARGET_CPUS); | 3264 | err = assign_irq_vector(irq, cfg, TARGET_CPUS); |
3263 | if (err) | 3265 | if (err) |
@@ -3463,40 +3465,6 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq) | |||
3463 | return 0; | 3465 | return 0; |
3464 | } | 3466 | } |
3465 | 3467 | ||
3466 | int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc) | ||
3467 | { | ||
3468 | unsigned int irq; | ||
3469 | int ret; | ||
3470 | unsigned int irq_want; | ||
3471 | |||
3472 | irq_want = nr_irqs_gsi; | ||
3473 | irq = create_irq_nr(irq_want); | ||
3474 | if (irq == 0) | ||
3475 | return -1; | ||
3476 | |||
3477 | #ifdef CONFIG_INTR_REMAP | ||
3478 | if (!intr_remapping_enabled) | ||
3479 | goto no_ir; | ||
3480 | |||
3481 | ret = msi_alloc_irte(dev, irq, 1); | ||
3482 | if (ret < 0) | ||
3483 | goto error; | ||
3484 | no_ir: | ||
3485 | #endif | ||
3486 | ret = setup_msi_irq(dev, msidesc, irq); | ||
3487 | if (ret < 0) { | ||
3488 | destroy_irq(irq); | ||
3489 | return ret; | ||
3490 | } | ||
3491 | return 0; | ||
3492 | |||
3493 | #ifdef CONFIG_INTR_REMAP | ||
3494 | error: | ||
3495 | destroy_irq(irq); | ||
3496 | return ret; | ||
3497 | #endif | ||
3498 | } | ||
3499 | |||
3500 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | 3468 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) |
3501 | { | 3469 | { |
3502 | unsigned int irq; | 3470 | unsigned int irq; |
@@ -3726,6 +3694,9 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) | |||
3726 | struct irq_cfg *cfg; | 3694 | struct irq_cfg *cfg; |
3727 | int err; | 3695 | int err; |
3728 | 3696 | ||
3697 | if (disable_apic) | ||
3698 | return -ENXIO; | ||
3699 | |||
3729 | cfg = irq_cfg(irq); | 3700 | cfg = irq_cfg(irq); |
3730 | err = assign_irq_vector(irq, cfg, TARGET_CPUS); | 3701 | err = assign_irq_vector(irq, cfg, TARGET_CPUS); |
3731 | if (!err) { | 3702 | if (!err) { |
@@ -3760,7 +3731,7 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) | |||
3760 | } | 3731 | } |
3761 | #endif /* CONFIG_HT_IRQ */ | 3732 | #endif /* CONFIG_HT_IRQ */ |
3762 | 3733 | ||
3763 | #ifdef CONFIG_X86_64 | 3734 | #ifdef CONFIG_X86_UV |
3764 | /* | 3735 | /* |
3765 | * Re-target the irq to the specified CPU and enable the specified MMR located | 3736 | * Re-target the irq to the specified CPU and enable the specified MMR located |
3766 | * on the specified blade to allow the sending of MSIs to the specified CPU. | 3737 | * on the specified blade to allow the sending of MSIs to the specified CPU. |
@@ -3850,6 +3821,22 @@ void __init probe_nr_irqs_gsi(void) | |||
3850 | nr_irqs_gsi = nr; | 3821 | nr_irqs_gsi = nr; |
3851 | } | 3822 | } |
3852 | 3823 | ||
3824 | #ifdef CONFIG_SPARSE_IRQ | ||
3825 | int __init arch_probe_nr_irqs(void) | ||
3826 | { | ||
3827 | int nr; | ||
3828 | |||
3829 | nr = ((8 * nr_cpu_ids) > (32 * nr_ioapics) ? | ||
3830 | (NR_VECTORS + (8 * nr_cpu_ids)) : | ||
3831 | (NR_VECTORS + (32 * nr_ioapics))); | ||
3832 | |||
3833 | if (nr < nr_irqs && nr > nr_irqs_gsi) | ||
3834 | nr_irqs = nr; | ||
3835 | |||
3836 | return 0; | ||
3837 | } | ||
3838 | #endif | ||
3839 | |||
3853 | /* -------------------------------------------------------------------------- | 3840 | /* -------------------------------------------------------------------------- |
3854 | ACPI-based IOAPIC Configuration | 3841 | ACPI-based IOAPIC Configuration |
3855 | -------------------------------------------------------------------------- */ | 3842 | -------------------------------------------------------------------------- */ |
@@ -3984,8 +3971,8 @@ int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity) | |||
3984 | return -1; | 3971 | return -1; |
3985 | 3972 | ||
3986 | for (i = 0; i < mp_irq_entries; i++) | 3973 | for (i = 0; i < mp_irq_entries; i++) |
3987 | if (mp_irqs[i].mp_irqtype == mp_INT && | 3974 | if (mp_irqs[i].irqtype == mp_INT && |
3988 | mp_irqs[i].mp_srcbusirq == bus_irq) | 3975 | mp_irqs[i].srcbusirq == bus_irq) |
3989 | break; | 3976 | break; |
3990 | if (i >= mp_irq_entries) | 3977 | if (i >= mp_irq_entries) |
3991 | return -1; | 3978 | return -1; |
@@ -4039,7 +4026,7 @@ void __init setup_ioapic_dest(void) | |||
4039 | */ | 4026 | */ |
4040 | if (desc->status & | 4027 | if (desc->status & |
4041 | (IRQ_NO_BALANCING | IRQ_AFFINITY_SET)) | 4028 | (IRQ_NO_BALANCING | IRQ_AFFINITY_SET)) |
4042 | mask = &desc->affinity; | 4029 | mask = desc->affinity; |
4043 | else | 4030 | else |
4044 | mask = TARGET_CPUS; | 4031 | mask = TARGET_CPUS; |
4045 | 4032 | ||
@@ -4100,7 +4087,7 @@ void __init ioapic_init_mappings(void) | |||
4100 | ioapic_res = ioapic_setup_resources(); | 4087 | ioapic_res = ioapic_setup_resources(); |
4101 | for (i = 0; i < nr_ioapics; i++) { | 4088 | for (i = 0; i < nr_ioapics; i++) { |
4102 | if (smp_found_config) { | 4089 | if (smp_found_config) { |
4103 | ioapic_phys = mp_ioapics[i].mp_apicaddr; | 4090 | ioapic_phys = mp_ioapics[i].apicaddr; |
4104 | #ifdef CONFIG_X86_32 | 4091 | #ifdef CONFIG_X86_32 |
4105 | if (!ioapic_phys) { | 4092 | if (!ioapic_phys) { |
4106 | printk(KERN_ERR | 4093 | printk(KERN_ERR |
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 3973e2df7f87..8b30d0c2512c 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c | |||
@@ -36,11 +36,7 @@ void ack_bad_irq(unsigned int irq) | |||
36 | #endif | 36 | #endif |
37 | } | 37 | } |
38 | 38 | ||
39 | #ifdef CONFIG_X86_32 | 39 | #define irq_stats(x) (&per_cpu(irq_stat, x)) |
40 | # define irq_stats(x) (&per_cpu(irq_stat, x)) | ||
41 | #else | ||
42 | # define irq_stats(x) cpu_pda(x) | ||
43 | #endif | ||
44 | /* | 40 | /* |
45 | * /proc/interrupts printing: | 41 | * /proc/interrupts printing: |
46 | */ | 42 | */ |
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c index 74b9ff7341e9..e0f29be8ab0b 100644 --- a/arch/x86/kernel/irq_32.c +++ b/arch/x86/kernel/irq_32.c | |||
@@ -248,7 +248,7 @@ void fixup_irqs(void) | |||
248 | if (irq == 2) | 248 | if (irq == 2) |
249 | continue; | 249 | continue; |
250 | 250 | ||
251 | affinity = &desc->affinity; | 251 | affinity = desc->affinity; |
252 | if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) { | 252 | if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) { |
253 | printk("Breaking affinity for irq %i\n", irq); | 253 | printk("Breaking affinity for irq %i\n", irq); |
254 | affinity = cpu_all_mask; | 254 | affinity = cpu_all_mask; |
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c index 63c88e6ec025..018963aa6ee3 100644 --- a/arch/x86/kernel/irq_64.c +++ b/arch/x86/kernel/irq_64.c | |||
@@ -18,6 +18,13 @@ | |||
18 | #include <linux/smp.h> | 18 | #include <linux/smp.h> |
19 | #include <asm/io_apic.h> | 19 | #include <asm/io_apic.h> |
20 | #include <asm/idle.h> | 20 | #include <asm/idle.h> |
21 | #include <asm/apic.h> | ||
22 | |||
23 | DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); | ||
24 | EXPORT_PER_CPU_SYMBOL(irq_stat); | ||
25 | |||
26 | DEFINE_PER_CPU(struct pt_regs *, irq_regs); | ||
27 | EXPORT_PER_CPU_SYMBOL(irq_regs); | ||
21 | 28 | ||
22 | /* | 29 | /* |
23 | * Probabilistic stack overflow check: | 30 | * Probabilistic stack overflow check: |
@@ -100,7 +107,7 @@ void fixup_irqs(void) | |||
100 | /* interrupt's are disabled at this point */ | 107 | /* interrupt's are disabled at this point */ |
101 | spin_lock(&desc->lock); | 108 | spin_lock(&desc->lock); |
102 | 109 | ||
103 | affinity = &desc->affinity; | 110 | affinity = desc->affinity; |
104 | if (!irq_has_action(irq) || | 111 | if (!irq_has_action(irq) || |
105 | cpumask_equal(affinity, cpu_online_mask)) { | 112 | cpumask_equal(affinity, cpu_online_mask)) { |
106 | spin_unlock(&desc->lock); | 113 | spin_unlock(&desc->lock); |
diff --git a/arch/x86/kernel/irqinit_32.c b/arch/x86/kernel/irqinit_32.c index 1507ad4e674d..bf629cadec1a 100644 --- a/arch/x86/kernel/irqinit_32.c +++ b/arch/x86/kernel/irqinit_32.c | |||
@@ -149,8 +149,15 @@ void __init native_init_IRQ(void) | |||
149 | */ | 149 | */ |
150 | alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt); | 150 | alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt); |
151 | 151 | ||
152 | /* IPI for invalidation */ | 152 | /* IPIs for invalidation */ |
153 | alloc_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt); | 153 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+0, invalidate_interrupt0); |
154 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+1, invalidate_interrupt1); | ||
155 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+2, invalidate_interrupt2); | ||
156 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+3, invalidate_interrupt3); | ||
157 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+4, invalidate_interrupt4); | ||
158 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+5, invalidate_interrupt5); | ||
159 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+6, invalidate_interrupt6); | ||
160 | alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+7, invalidate_interrupt7); | ||
154 | 161 | ||
155 | /* IPI for generic function call */ | 162 | /* IPI for generic function call */ |
156 | alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); | 163 | alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); |
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c index 884d985b8b82..e948b28a5a9a 100644 --- a/arch/x86/kernel/kprobes.c +++ b/arch/x86/kernel/kprobes.c | |||
@@ -446,7 +446,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, | |||
446 | static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs, | 446 | static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs, |
447 | struct kprobe_ctlblk *kcb) | 447 | struct kprobe_ctlblk *kcb) |
448 | { | 448 | { |
449 | #if !defined(CONFIG_PREEMPT) || defined(CONFIG_PM) | 449 | #if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER) |
450 | if (p->ainsn.boostable == 1 && !p->post_handler) { | 450 | if (p->ainsn.boostable == 1 && !p->post_handler) { |
451 | /* Boost up -- we can execute copied instructions directly */ | 451 | /* Boost up -- we can execute copied instructions directly */ |
452 | reset_current_kprobe(); | 452 | reset_current_kprobe(); |
diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c index b7f4c929e615..5e9f4fc51385 100644 --- a/arch/x86/kernel/microcode_intel.c +++ b/arch/x86/kernel/microcode_intel.c | |||
@@ -87,9 +87,9 @@ | |||
87 | #include <linux/cpu.h> | 87 | #include <linux/cpu.h> |
88 | #include <linux/firmware.h> | 88 | #include <linux/firmware.h> |
89 | #include <linux/platform_device.h> | 89 | #include <linux/platform_device.h> |
90 | #include <linux/uaccess.h> | ||
90 | 91 | ||
91 | #include <asm/msr.h> | 92 | #include <asm/msr.h> |
92 | #include <asm/uaccess.h> | ||
93 | #include <asm/processor.h> | 93 | #include <asm/processor.h> |
94 | #include <asm/microcode.h> | 94 | #include <asm/microcode.h> |
95 | 95 | ||
@@ -196,7 +196,7 @@ static inline int update_match_cpu(struct cpu_signature *csig, int sig, int pf) | |||
196 | return (!sigmatch(sig, csig->sig, pf, csig->pf)) ? 0 : 1; | 196 | return (!sigmatch(sig, csig->sig, pf, csig->pf)) ? 0 : 1; |
197 | } | 197 | } |
198 | 198 | ||
199 | static inline int | 199 | static inline int |
200 | update_match_revision(struct microcode_header_intel *mc_header, int rev) | 200 | update_match_revision(struct microcode_header_intel *mc_header, int rev) |
201 | { | 201 | { |
202 | return (mc_header->rev <= rev) ? 0 : 1; | 202 | return (mc_header->rev <= rev) ? 0 : 1; |
@@ -442,8 +442,8 @@ static int request_microcode_fw(int cpu, struct device *device) | |||
442 | return ret; | 442 | return ret; |
443 | } | 443 | } |
444 | 444 | ||
445 | ret = generic_load_microcode(cpu, (void*)firmware->data, firmware->size, | 445 | ret = generic_load_microcode(cpu, (void *)firmware->data, |
446 | &get_ucode_fw); | 446 | firmware->size, &get_ucode_fw); |
447 | 447 | ||
448 | release_firmware(firmware); | 448 | release_firmware(firmware); |
449 | 449 | ||
@@ -460,7 +460,7 @@ static int request_microcode_user(int cpu, const void __user *buf, size_t size) | |||
460 | /* We should bind the task to the CPU */ | 460 | /* We should bind the task to the CPU */ |
461 | BUG_ON(cpu != raw_smp_processor_id()); | 461 | BUG_ON(cpu != raw_smp_processor_id()); |
462 | 462 | ||
463 | return generic_load_microcode(cpu, (void*)buf, size, &get_ucode_user); | 463 | return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user); |
464 | } | 464 | } |
465 | 465 | ||
466 | static void microcode_fini_cpu(int cpu) | 466 | static void microcode_fini_cpu(int cpu) |
diff --git a/arch/x86/kernel/module_32.c b/arch/x86/kernel/module_32.c index 3db0a5442eb1..0edd819050e7 100644 --- a/arch/x86/kernel/module_32.c +++ b/arch/x86/kernel/module_32.c | |||
@@ -42,7 +42,7 @@ void module_free(struct module *mod, void *module_region) | |||
42 | { | 42 | { |
43 | vfree(module_region); | 43 | vfree(module_region); |
44 | /* FIXME: If module_region == mod->init_region, trim exception | 44 | /* FIXME: If module_region == mod->init_region, trim exception |
45 | table entries. */ | 45 | table entries. */ |
46 | } | 46 | } |
47 | 47 | ||
48 | /* We don't need anything special. */ | 48 | /* We don't need anything special. */ |
@@ -113,13 +113,13 @@ int module_finalize(const Elf_Ehdr *hdr, | |||
113 | *para = NULL; | 113 | *para = NULL; |
114 | char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | 114 | char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; |
115 | 115 | ||
116 | for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { | 116 | for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { |
117 | if (!strcmp(".text", secstrings + s->sh_name)) | 117 | if (!strcmp(".text", secstrings + s->sh_name)) |
118 | text = s; | 118 | text = s; |
119 | if (!strcmp(".altinstructions", secstrings + s->sh_name)) | 119 | if (!strcmp(".altinstructions", secstrings + s->sh_name)) |
120 | alt = s; | 120 | alt = s; |
121 | if (!strcmp(".smp_locks", secstrings + s->sh_name)) | 121 | if (!strcmp(".smp_locks", secstrings + s->sh_name)) |
122 | locks= s; | 122 | locks = s; |
123 | if (!strcmp(".parainstructions", secstrings + s->sh_name)) | 123 | if (!strcmp(".parainstructions", secstrings + s->sh_name)) |
124 | para = s; | 124 | para = s; |
125 | } | 125 | } |
diff --git a/arch/x86/kernel/module_64.c b/arch/x86/kernel/module_64.c index 6ba87830d4b1..c23880b90b5c 100644 --- a/arch/x86/kernel/module_64.c +++ b/arch/x86/kernel/module_64.c | |||
@@ -30,14 +30,14 @@ | |||
30 | #include <asm/page.h> | 30 | #include <asm/page.h> |
31 | #include <asm/pgtable.h> | 31 | #include <asm/pgtable.h> |
32 | 32 | ||
33 | #define DEBUGP(fmt...) | 33 | #define DEBUGP(fmt...) |
34 | 34 | ||
35 | #ifndef CONFIG_UML | 35 | #ifndef CONFIG_UML |
36 | void module_free(struct module *mod, void *module_region) | 36 | void module_free(struct module *mod, void *module_region) |
37 | { | 37 | { |
38 | vfree(module_region); | 38 | vfree(module_region); |
39 | /* FIXME: If module_region == mod->init_region, trim exception | 39 | /* FIXME: If module_region == mod->init_region, trim exception |
40 | table entries. */ | 40 | table entries. */ |
41 | } | 41 | } |
42 | 42 | ||
43 | void *module_alloc(unsigned long size) | 43 | void *module_alloc(unsigned long size) |
@@ -77,7 +77,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, | |||
77 | Elf64_Rela *rel = (void *)sechdrs[relsec].sh_addr; | 77 | Elf64_Rela *rel = (void *)sechdrs[relsec].sh_addr; |
78 | Elf64_Sym *sym; | 78 | Elf64_Sym *sym; |
79 | void *loc; | 79 | void *loc; |
80 | u64 val; | 80 | u64 val; |
81 | 81 | ||
82 | DEBUGP("Applying relocate section %u to %u\n", relsec, | 82 | DEBUGP("Applying relocate section %u to %u\n", relsec, |
83 | sechdrs[relsec].sh_info); | 83 | sechdrs[relsec].sh_info); |
@@ -91,11 +91,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, | |||
91 | sym = (Elf64_Sym *)sechdrs[symindex].sh_addr | 91 | sym = (Elf64_Sym *)sechdrs[symindex].sh_addr |
92 | + ELF64_R_SYM(rel[i].r_info); | 92 | + ELF64_R_SYM(rel[i].r_info); |
93 | 93 | ||
94 | DEBUGP("type %d st_value %Lx r_addend %Lx loc %Lx\n", | 94 | DEBUGP("type %d st_value %Lx r_addend %Lx loc %Lx\n", |
95 | (int)ELF64_R_TYPE(rel[i].r_info), | 95 | (int)ELF64_R_TYPE(rel[i].r_info), |
96 | sym->st_value, rel[i].r_addend, (u64)loc); | 96 | sym->st_value, rel[i].r_addend, (u64)loc); |
97 | 97 | ||
98 | val = sym->st_value + rel[i].r_addend; | 98 | val = sym->st_value + rel[i].r_addend; |
99 | 99 | ||
100 | switch (ELF64_R_TYPE(rel[i].r_info)) { | 100 | switch (ELF64_R_TYPE(rel[i].r_info)) { |
101 | case R_X86_64_NONE: | 101 | case R_X86_64_NONE: |
@@ -113,16 +113,16 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, | |||
113 | if ((s64)val != *(s32 *)loc) | 113 | if ((s64)val != *(s32 *)loc) |
114 | goto overflow; | 114 | goto overflow; |
115 | break; | 115 | break; |
116 | case R_X86_64_PC32: | 116 | case R_X86_64_PC32: |
117 | val -= (u64)loc; | 117 | val -= (u64)loc; |
118 | *(u32 *)loc = val; | 118 | *(u32 *)loc = val; |
119 | #if 0 | 119 | #if 0 |
120 | if ((s64)val != *(s32 *)loc) | 120 | if ((s64)val != *(s32 *)loc) |
121 | goto overflow; | 121 | goto overflow; |
122 | #endif | 122 | #endif |
123 | break; | 123 | break; |
124 | default: | 124 | default: |
125 | printk(KERN_ERR "module %s: Unknown rela relocation: %Lu\n", | 125 | printk(KERN_ERR "module %s: Unknown rela relocation: %llu\n", |
126 | me->name, ELF64_R_TYPE(rel[i].r_info)); | 126 | me->name, ELF64_R_TYPE(rel[i].r_info)); |
127 | return -ENOEXEC; | 127 | return -ENOEXEC; |
128 | } | 128 | } |
@@ -130,7 +130,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, | |||
130 | return 0; | 130 | return 0; |
131 | 131 | ||
132 | overflow: | 132 | overflow: |
133 | printk(KERN_ERR "overflow in relocation type %d val %Lx\n", | 133 | printk(KERN_ERR "overflow in relocation type %d val %Lx\n", |
134 | (int)ELF64_R_TYPE(rel[i].r_info), val); | 134 | (int)ELF64_R_TYPE(rel[i].r_info), val); |
135 | printk(KERN_ERR "`%s' likely not compiled with -mcmodel=kernel\n", | 135 | printk(KERN_ERR "`%s' likely not compiled with -mcmodel=kernel\n", |
136 | me->name); | 136 | me->name); |
@@ -143,13 +143,13 @@ int apply_relocate(Elf_Shdr *sechdrs, | |||
143 | unsigned int relsec, | 143 | unsigned int relsec, |
144 | struct module *me) | 144 | struct module *me) |
145 | { | 145 | { |
146 | printk("non add relocation not supported\n"); | 146 | printk(KERN_ERR "non add relocation not supported\n"); |
147 | return -ENOSYS; | 147 | return -ENOSYS; |
148 | } | 148 | } |
149 | 149 | ||
150 | int module_finalize(const Elf_Ehdr *hdr, | 150 | int module_finalize(const Elf_Ehdr *hdr, |
151 | const Elf_Shdr *sechdrs, | 151 | const Elf_Shdr *sechdrs, |
152 | struct module *me) | 152 | struct module *me) |
153 | { | 153 | { |
154 | const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL, | 154 | const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL, |
155 | *para = NULL; | 155 | *para = NULL; |
@@ -161,7 +161,7 @@ int module_finalize(const Elf_Ehdr *hdr, | |||
161 | if (!strcmp(".altinstructions", secstrings + s->sh_name)) | 161 | if (!strcmp(".altinstructions", secstrings + s->sh_name)) |
162 | alt = s; | 162 | alt = s; |
163 | if (!strcmp(".smp_locks", secstrings + s->sh_name)) | 163 | if (!strcmp(".smp_locks", secstrings + s->sh_name)) |
164 | locks= s; | 164 | locks = s; |
165 | if (!strcmp(".parainstructions", secstrings + s->sh_name)) | 165 | if (!strcmp(".parainstructions", secstrings + s->sh_name)) |
166 | para = s; | 166 | para = s; |
167 | } | 167 | } |
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index c0601c2848a1..fa6bb263892e 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <asm/e820.h> | 27 | #include <asm/e820.h> |
28 | #include <asm/trampoline.h> | 28 | #include <asm/trampoline.h> |
29 | #include <asm/setup.h> | 29 | #include <asm/setup.h> |
30 | #include <asm/smp.h> | ||
30 | 31 | ||
31 | #include <mach_apic.h> | 32 | #include <mach_apic.h> |
32 | #ifdef CONFIG_X86_32 | 33 | #ifdef CONFIG_X86_32 |
@@ -143,11 +144,11 @@ static void __init MP_ioapic_info(struct mpc_ioapic *m) | |||
143 | if (bad_ioapic(m->apicaddr)) | 144 | if (bad_ioapic(m->apicaddr)) |
144 | return; | 145 | return; |
145 | 146 | ||
146 | mp_ioapics[nr_ioapics].mp_apicaddr = m->apicaddr; | 147 | mp_ioapics[nr_ioapics].apicaddr = m->apicaddr; |
147 | mp_ioapics[nr_ioapics].mp_apicid = m->apicid; | 148 | mp_ioapics[nr_ioapics].apicid = m->apicid; |
148 | mp_ioapics[nr_ioapics].mp_type = m->type; | 149 | mp_ioapics[nr_ioapics].type = m->type; |
149 | mp_ioapics[nr_ioapics].mp_apicver = m->apicver; | 150 | mp_ioapics[nr_ioapics].apicver = m->apicver; |
150 | mp_ioapics[nr_ioapics].mp_flags = m->flags; | 151 | mp_ioapics[nr_ioapics].flags = m->flags; |
151 | nr_ioapics++; | 152 | nr_ioapics++; |
152 | } | 153 | } |
153 | 154 | ||
@@ -159,55 +160,55 @@ static void print_MP_intsrc_info(struct mpc_intsrc *m) | |||
159 | m->srcbusirq, m->dstapic, m->dstirq); | 160 | m->srcbusirq, m->dstapic, m->dstirq); |
160 | } | 161 | } |
161 | 162 | ||
162 | static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq) | 163 | static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq) |
163 | { | 164 | { |
164 | apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," | 165 | apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," |
165 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", | 166 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", |
166 | mp_irq->mp_irqtype, mp_irq->mp_irqflag & 3, | 167 | mp_irq->irqtype, mp_irq->irqflag & 3, |
167 | (mp_irq->mp_irqflag >> 2) & 3, mp_irq->mp_srcbus, | 168 | (mp_irq->irqflag >> 2) & 3, mp_irq->srcbus, |
168 | mp_irq->mp_srcbusirq, mp_irq->mp_dstapic, mp_irq->mp_dstirq); | 169 | mp_irq->srcbusirq, mp_irq->dstapic, mp_irq->dstirq); |
169 | } | 170 | } |
170 | 171 | ||
171 | static void __init assign_to_mp_irq(struct mpc_intsrc *m, | 172 | static void __init assign_to_mp_irq(struct mpc_intsrc *m, |
172 | struct mp_config_intsrc *mp_irq) | 173 | struct mpc_intsrc *mp_irq) |
173 | { | 174 | { |
174 | mp_irq->mp_dstapic = m->dstapic; | 175 | mp_irq->dstapic = m->dstapic; |
175 | mp_irq->mp_type = m->type; | 176 | mp_irq->type = m->type; |
176 | mp_irq->mp_irqtype = m->irqtype; | 177 | mp_irq->irqtype = m->irqtype; |
177 | mp_irq->mp_irqflag = m->irqflag; | 178 | mp_irq->irqflag = m->irqflag; |
178 | mp_irq->mp_srcbus = m->srcbus; | 179 | mp_irq->srcbus = m->srcbus; |
179 | mp_irq->mp_srcbusirq = m->srcbusirq; | 180 | mp_irq->srcbusirq = m->srcbusirq; |
180 | mp_irq->mp_dstirq = m->dstirq; | 181 | mp_irq->dstirq = m->dstirq; |
181 | } | 182 | } |
182 | 183 | ||
183 | static void __init assign_to_mpc_intsrc(struct mp_config_intsrc *mp_irq, | 184 | static void __init assign_to_mpc_intsrc(struct mpc_intsrc *mp_irq, |
184 | struct mpc_intsrc *m) | 185 | struct mpc_intsrc *m) |
185 | { | 186 | { |
186 | m->dstapic = mp_irq->mp_dstapic; | 187 | m->dstapic = mp_irq->dstapic; |
187 | m->type = mp_irq->mp_type; | 188 | m->type = mp_irq->type; |
188 | m->irqtype = mp_irq->mp_irqtype; | 189 | m->irqtype = mp_irq->irqtype; |
189 | m->irqflag = mp_irq->mp_irqflag; | 190 | m->irqflag = mp_irq->irqflag; |
190 | m->srcbus = mp_irq->mp_srcbus; | 191 | m->srcbus = mp_irq->srcbus; |
191 | m->srcbusirq = mp_irq->mp_srcbusirq; | 192 | m->srcbusirq = mp_irq->srcbusirq; |
192 | m->dstirq = mp_irq->mp_dstirq; | 193 | m->dstirq = mp_irq->dstirq; |
193 | } | 194 | } |
194 | 195 | ||
195 | static int __init mp_irq_mpc_intsrc_cmp(struct mp_config_intsrc *mp_irq, | 196 | static int __init mp_irq_mpc_intsrc_cmp(struct mpc_intsrc *mp_irq, |
196 | struct mpc_intsrc *m) | 197 | struct mpc_intsrc *m) |
197 | { | 198 | { |
198 | if (mp_irq->mp_dstapic != m->dstapic) | 199 | if (mp_irq->dstapic != m->dstapic) |
199 | return 1; | 200 | return 1; |
200 | if (mp_irq->mp_type != m->type) | 201 | if (mp_irq->type != m->type) |
201 | return 2; | 202 | return 2; |
202 | if (mp_irq->mp_irqtype != m->irqtype) | 203 | if (mp_irq->irqtype != m->irqtype) |
203 | return 3; | 204 | return 3; |
204 | if (mp_irq->mp_irqflag != m->irqflag) | 205 | if (mp_irq->irqflag != m->irqflag) |
205 | return 4; | 206 | return 4; |
206 | if (mp_irq->mp_srcbus != m->srcbus) | 207 | if (mp_irq->srcbus != m->srcbus) |
207 | return 5; | 208 | return 5; |
208 | if (mp_irq->mp_srcbusirq != m->srcbusirq) | 209 | if (mp_irq->srcbusirq != m->srcbusirq) |
209 | return 6; | 210 | return 6; |
210 | if (mp_irq->mp_dstirq != m->dstirq) | 211 | if (mp_irq->dstirq != m->dstirq) |
211 | return 7; | 212 | return 7; |
212 | 213 | ||
213 | return 0; | 214 | return 0; |
@@ -416,7 +417,7 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type) | |||
416 | intsrc.type = MP_INTSRC; | 417 | intsrc.type = MP_INTSRC; |
417 | intsrc.irqflag = 0; /* conforming */ | 418 | intsrc.irqflag = 0; /* conforming */ |
418 | intsrc.srcbus = 0; | 419 | intsrc.srcbus = 0; |
419 | intsrc.dstapic = mp_ioapics[0].mp_apicid; | 420 | intsrc.dstapic = mp_ioapics[0].apicid; |
420 | 421 | ||
421 | intsrc.irqtype = mp_INT; | 422 | intsrc.irqtype = mp_INT; |
422 | 423 | ||
@@ -569,14 +570,14 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type) | |||
569 | } | 570 | } |
570 | } | 571 | } |
571 | 572 | ||
572 | static struct intel_mp_floating *mpf_found; | 573 | static struct mpf_intel *mpf_found; |
573 | 574 | ||
574 | /* | 575 | /* |
575 | * Scan the memory blocks for an SMP configuration block. | 576 | * Scan the memory blocks for an SMP configuration block. |
576 | */ | 577 | */ |
577 | static void __init __get_smp_config(unsigned int early) | 578 | static void __init __get_smp_config(unsigned int early) |
578 | { | 579 | { |
579 | struct intel_mp_floating *mpf = mpf_found; | 580 | struct mpf_intel *mpf = mpf_found; |
580 | 581 | ||
581 | if (!mpf) | 582 | if (!mpf) |
582 | return; | 583 | return; |
@@ -597,9 +598,9 @@ static void __init __get_smp_config(unsigned int early) | |||
597 | } | 598 | } |
598 | 599 | ||
599 | printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", | 600 | printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", |
600 | mpf->mpf_specification); | 601 | mpf->specification); |
601 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) | 602 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) |
602 | if (mpf->mpf_feature2 & (1 << 7)) { | 603 | if (mpf->feature2 & (1 << 7)) { |
603 | printk(KERN_INFO " IMCR and PIC compatibility mode.\n"); | 604 | printk(KERN_INFO " IMCR and PIC compatibility mode.\n"); |
604 | pic_mode = 1; | 605 | pic_mode = 1; |
605 | } else { | 606 | } else { |
@@ -610,7 +611,7 @@ static void __init __get_smp_config(unsigned int early) | |||
610 | /* | 611 | /* |
611 | * Now see if we need to read further. | 612 | * Now see if we need to read further. |
612 | */ | 613 | */ |
613 | if (mpf->mpf_feature1 != 0) { | 614 | if (mpf->feature1 != 0) { |
614 | if (early) { | 615 | if (early) { |
615 | /* | 616 | /* |
616 | * local APIC has default address | 617 | * local APIC has default address |
@@ -620,16 +621,16 @@ static void __init __get_smp_config(unsigned int early) | |||
620 | } | 621 | } |
621 | 622 | ||
622 | printk(KERN_INFO "Default MP configuration #%d\n", | 623 | printk(KERN_INFO "Default MP configuration #%d\n", |
623 | mpf->mpf_feature1); | 624 | mpf->feature1); |
624 | construct_default_ISA_mptable(mpf->mpf_feature1); | 625 | construct_default_ISA_mptable(mpf->feature1); |
625 | 626 | ||
626 | } else if (mpf->mpf_physptr) { | 627 | } else if (mpf->physptr) { |
627 | 628 | ||
628 | /* | 629 | /* |
629 | * Read the physical hardware table. Anything here will | 630 | * Read the physical hardware table. Anything here will |
630 | * override the defaults. | 631 | * override the defaults. |
631 | */ | 632 | */ |
632 | if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr), early)) { | 633 | if (!smp_read_mpc(phys_to_virt(mpf->physptr), early)) { |
633 | #ifdef CONFIG_X86_LOCAL_APIC | 634 | #ifdef CONFIG_X86_LOCAL_APIC |
634 | smp_found_config = 0; | 635 | smp_found_config = 0; |
635 | #endif | 636 | #endif |
@@ -687,19 +688,19 @@ static int __init smp_scan_config(unsigned long base, unsigned long length, | |||
687 | unsigned reserve) | 688 | unsigned reserve) |
688 | { | 689 | { |
689 | unsigned int *bp = phys_to_virt(base); | 690 | unsigned int *bp = phys_to_virt(base); |
690 | struct intel_mp_floating *mpf; | 691 | struct mpf_intel *mpf; |
691 | 692 | ||
692 | apic_printk(APIC_VERBOSE, "Scan SMP from %p for %ld bytes.\n", | 693 | apic_printk(APIC_VERBOSE, "Scan SMP from %p for %ld bytes.\n", |
693 | bp, length); | 694 | bp, length); |
694 | BUILD_BUG_ON(sizeof(*mpf) != 16); | 695 | BUILD_BUG_ON(sizeof(*mpf) != 16); |
695 | 696 | ||
696 | while (length > 0) { | 697 | while (length > 0) { |
697 | mpf = (struct intel_mp_floating *)bp; | 698 | mpf = (struct mpf_intel *)bp; |
698 | if ((*bp == SMP_MAGIC_IDENT) && | 699 | if ((*bp == SMP_MAGIC_IDENT) && |
699 | (mpf->mpf_length == 1) && | 700 | (mpf->length == 1) && |
700 | !mpf_checksum((unsigned char *)bp, 16) && | 701 | !mpf_checksum((unsigned char *)bp, 16) && |
701 | ((mpf->mpf_specification == 1) | 702 | ((mpf->specification == 1) |
702 | || (mpf->mpf_specification == 4))) { | 703 | || (mpf->specification == 4))) { |
703 | #ifdef CONFIG_X86_LOCAL_APIC | 704 | #ifdef CONFIG_X86_LOCAL_APIC |
704 | smp_found_config = 1; | 705 | smp_found_config = 1; |
705 | #endif | 706 | #endif |
@@ -712,7 +713,7 @@ static int __init smp_scan_config(unsigned long base, unsigned long length, | |||
712 | return 1; | 713 | return 1; |
713 | reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE, | 714 | reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE, |
714 | BOOTMEM_DEFAULT); | 715 | BOOTMEM_DEFAULT); |
715 | if (mpf->mpf_physptr) { | 716 | if (mpf->physptr) { |
716 | unsigned long size = PAGE_SIZE; | 717 | unsigned long size = PAGE_SIZE; |
717 | #ifdef CONFIG_X86_32 | 718 | #ifdef CONFIG_X86_32 |
718 | /* | 719 | /* |
@@ -721,14 +722,14 @@ static int __init smp_scan_config(unsigned long base, unsigned long length, | |||
721 | * the bottom is mapped now. | 722 | * the bottom is mapped now. |
722 | * PC-9800's MPC table places on the very last | 723 | * PC-9800's MPC table places on the very last |
723 | * of physical memory; so that simply reserving | 724 | * of physical memory; so that simply reserving |
724 | * PAGE_SIZE from mpg->mpf_physptr yields BUG() | 725 | * PAGE_SIZE from mpf->physptr yields BUG() |
725 | * in reserve_bootmem. | 726 | * in reserve_bootmem. |
726 | */ | 727 | */ |
727 | unsigned long end = max_low_pfn * PAGE_SIZE; | 728 | unsigned long end = max_low_pfn * PAGE_SIZE; |
728 | if (mpf->mpf_physptr + size > end) | 729 | if (mpf->physptr + size > end) |
729 | size = end - mpf->mpf_physptr; | 730 | size = end - mpf->physptr; |
730 | #endif | 731 | #endif |
731 | reserve_bootmem_generic(mpf->mpf_physptr, size, | 732 | reserve_bootmem_generic(mpf->physptr, size, |
732 | BOOTMEM_DEFAULT); | 733 | BOOTMEM_DEFAULT); |
733 | } | 734 | } |
734 | 735 | ||
@@ -808,15 +809,15 @@ static int __init get_MP_intsrc_index(struct mpc_intsrc *m) | |||
808 | /* not legacy */ | 809 | /* not legacy */ |
809 | 810 | ||
810 | for (i = 0; i < mp_irq_entries; i++) { | 811 | for (i = 0; i < mp_irq_entries; i++) { |
811 | if (mp_irqs[i].mp_irqtype != mp_INT) | 812 | if (mp_irqs[i].irqtype != mp_INT) |
812 | continue; | 813 | continue; |
813 | 814 | ||
814 | if (mp_irqs[i].mp_irqflag != 0x0f) | 815 | if (mp_irqs[i].irqflag != 0x0f) |
815 | continue; | 816 | continue; |
816 | 817 | ||
817 | if (mp_irqs[i].mp_srcbus != m->srcbus) | 818 | if (mp_irqs[i].srcbus != m->srcbus) |
818 | continue; | 819 | continue; |
819 | if (mp_irqs[i].mp_srcbusirq != m->srcbusirq) | 820 | if (mp_irqs[i].srcbusirq != m->srcbusirq) |
820 | continue; | 821 | continue; |
821 | if (irq_used[i]) { | 822 | if (irq_used[i]) { |
822 | /* already claimed */ | 823 | /* already claimed */ |
@@ -921,10 +922,10 @@ static int __init replace_intsrc_all(struct mpc_table *mpc, | |||
921 | if (irq_used[i]) | 922 | if (irq_used[i]) |
922 | continue; | 923 | continue; |
923 | 924 | ||
924 | if (mp_irqs[i].mp_irqtype != mp_INT) | 925 | if (mp_irqs[i].irqtype != mp_INT) |
925 | continue; | 926 | continue; |
926 | 927 | ||
927 | if (mp_irqs[i].mp_irqflag != 0x0f) | 928 | if (mp_irqs[i].irqflag != 0x0f) |
928 | continue; | 929 | continue; |
929 | 930 | ||
930 | if (nr_m_spare > 0) { | 931 | if (nr_m_spare > 0) { |
@@ -1000,7 +1001,7 @@ static int __init update_mp_table(void) | |||
1000 | { | 1001 | { |
1001 | char str[16]; | 1002 | char str[16]; |
1002 | char oem[10]; | 1003 | char oem[10]; |
1003 | struct intel_mp_floating *mpf; | 1004 | struct mpf_intel *mpf; |
1004 | struct mpc_table *mpc, *mpc_new; | 1005 | struct mpc_table *mpc, *mpc_new; |
1005 | 1006 | ||
1006 | if (!enable_update_mptable) | 1007 | if (!enable_update_mptable) |
@@ -1013,19 +1014,19 @@ static int __init update_mp_table(void) | |||
1013 | /* | 1014 | /* |
1014 | * Now see if we need to go further. | 1015 | * Now see if we need to go further. |
1015 | */ | 1016 | */ |
1016 | if (mpf->mpf_feature1 != 0) | 1017 | if (mpf->feature1 != 0) |
1017 | return 0; | 1018 | return 0; |
1018 | 1019 | ||
1019 | if (!mpf->mpf_physptr) | 1020 | if (!mpf->physptr) |
1020 | return 0; | 1021 | return 0; |
1021 | 1022 | ||
1022 | mpc = phys_to_virt(mpf->mpf_physptr); | 1023 | mpc = phys_to_virt(mpf->physptr); |
1023 | 1024 | ||
1024 | if (!smp_check_mpc(mpc, oem, str)) | 1025 | if (!smp_check_mpc(mpc, oem, str)) |
1025 | return 0; | 1026 | return 0; |
1026 | 1027 | ||
1027 | printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf)); | 1028 | printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf)); |
1028 | printk(KERN_INFO "mpf_physptr: %x\n", mpf->mpf_physptr); | 1029 | printk(KERN_INFO "physptr: %x\n", mpf->physptr); |
1029 | 1030 | ||
1030 | if (mpc_new_phys && mpc->length > mpc_new_length) { | 1031 | if (mpc_new_phys && mpc->length > mpc_new_length) { |
1031 | mpc_new_phys = 0; | 1032 | mpc_new_phys = 0; |
@@ -1046,23 +1047,23 @@ static int __init update_mp_table(void) | |||
1046 | } | 1047 | } |
1047 | printk(KERN_INFO "use in-positon replacing\n"); | 1048 | printk(KERN_INFO "use in-positon replacing\n"); |
1048 | } else { | 1049 | } else { |
1049 | mpf->mpf_physptr = mpc_new_phys; | 1050 | mpf->physptr = mpc_new_phys; |
1050 | mpc_new = phys_to_virt(mpc_new_phys); | 1051 | mpc_new = phys_to_virt(mpc_new_phys); |
1051 | memcpy(mpc_new, mpc, mpc->length); | 1052 | memcpy(mpc_new, mpc, mpc->length); |
1052 | mpc = mpc_new; | 1053 | mpc = mpc_new; |
1053 | /* check if we can modify that */ | 1054 | /* check if we can modify that */ |
1054 | if (mpc_new_phys - mpf->mpf_physptr) { | 1055 | if (mpc_new_phys - mpf->physptr) { |
1055 | struct intel_mp_floating *mpf_new; | 1056 | struct mpf_intel *mpf_new; |
1056 | /* steal 16 bytes from [0, 1k) */ | 1057 | /* steal 16 bytes from [0, 1k) */ |
1057 | printk(KERN_INFO "mpf new: %x\n", 0x400 - 16); | 1058 | printk(KERN_INFO "mpf new: %x\n", 0x400 - 16); |
1058 | mpf_new = phys_to_virt(0x400 - 16); | 1059 | mpf_new = phys_to_virt(0x400 - 16); |
1059 | memcpy(mpf_new, mpf, 16); | 1060 | memcpy(mpf_new, mpf, 16); |
1060 | mpf = mpf_new; | 1061 | mpf = mpf_new; |
1061 | mpf->mpf_physptr = mpc_new_phys; | 1062 | mpf->physptr = mpc_new_phys; |
1062 | } | 1063 | } |
1063 | mpf->mpf_checksum = 0; | 1064 | mpf->checksum = 0; |
1064 | mpf->mpf_checksum -= mpf_checksum((unsigned char *)mpf, 16); | 1065 | mpf->checksum -= mpf_checksum((unsigned char *)mpf, 16); |
1065 | printk(KERN_INFO "mpf_physptr new: %x\n", mpf->mpf_physptr); | 1066 | printk(KERN_INFO "physptr new: %x\n", mpf->physptr); |
1066 | } | 1067 | } |
1067 | 1068 | ||
1068 | /* | 1069 | /* |
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 726266695b2c..3cf3413ec626 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c | |||
@@ -35,10 +35,10 @@ | |||
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/cpu.h> | 36 | #include <linux/cpu.h> |
37 | #include <linux/notifier.h> | 37 | #include <linux/notifier.h> |
38 | #include <linux/uaccess.h> | ||
38 | 39 | ||
39 | #include <asm/processor.h> | 40 | #include <asm/processor.h> |
40 | #include <asm/msr.h> | 41 | #include <asm/msr.h> |
41 | #include <asm/uaccess.h> | ||
42 | #include <asm/system.h> | 42 | #include <asm/system.h> |
43 | 43 | ||
44 | static struct class *msr_class; | 44 | static struct class *msr_class; |
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 7228979f1e7f..23b6d9e6e4f5 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c | |||
@@ -61,11 +61,7 @@ static int endflag __initdata; | |||
61 | 61 | ||
62 | static inline unsigned int get_nmi_count(int cpu) | 62 | static inline unsigned int get_nmi_count(int cpu) |
63 | { | 63 | { |
64 | #ifdef CONFIG_X86_64 | 64 | return per_cpu(irq_stat, cpu).__nmi_count; |
65 | return cpu_pda(cpu)->__nmi_count; | ||
66 | #else | ||
67 | return nmi_count(cpu); | ||
68 | #endif | ||
69 | } | 65 | } |
70 | 66 | ||
71 | static inline int mce_in_progress(void) | 67 | static inline int mce_in_progress(void) |
@@ -82,12 +78,8 @@ static inline int mce_in_progress(void) | |||
82 | */ | 78 | */ |
83 | static inline unsigned int get_timer_irqs(int cpu) | 79 | static inline unsigned int get_timer_irqs(int cpu) |
84 | { | 80 | { |
85 | #ifdef CONFIG_X86_64 | ||
86 | return read_pda(apic_timer_irqs) + read_pda(irq0_irqs); | ||
87 | #else | ||
88 | return per_cpu(irq_stat, cpu).apic_timer_irqs + | 81 | return per_cpu(irq_stat, cpu).apic_timer_irqs + |
89 | per_cpu(irq_stat, cpu).irq0_irqs; | 82 | per_cpu(irq_stat, cpu).irq0_irqs; |
90 | #endif | ||
91 | } | 83 | } |
92 | 84 | ||
93 | #ifdef CONFIG_SMP | 85 | #ifdef CONFIG_SMP |
diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c index 95777b0faa73..3a7c5a44082e 100644 --- a/arch/x86/kernel/paravirt-spinlocks.c +++ b/arch/x86/kernel/paravirt-spinlocks.c | |||
@@ -26,13 +26,3 @@ struct pv_lock_ops pv_lock_ops = { | |||
26 | }; | 26 | }; |
27 | EXPORT_SYMBOL(pv_lock_ops); | 27 | EXPORT_SYMBOL(pv_lock_ops); |
28 | 28 | ||
29 | void __init paravirt_use_bytelocks(void) | ||
30 | { | ||
31 | #ifdef CONFIG_SMP | ||
32 | pv_lock_ops.spin_is_locked = __byte_spin_is_locked; | ||
33 | pv_lock_ops.spin_is_contended = __byte_spin_is_contended; | ||
34 | pv_lock_ops.spin_lock = __byte_spin_lock; | ||
35 | pv_lock_ops.spin_trylock = __byte_spin_trylock; | ||
36 | pv_lock_ops.spin_unlock = __byte_spin_unlock; | ||
37 | #endif | ||
38 | } | ||
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index e4c8fb608873..202514be5923 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c | |||
@@ -435,7 +435,6 @@ struct pv_mmu_ops pv_mmu_ops = { | |||
435 | #endif /* PAGETABLE_LEVELS >= 3 */ | 435 | #endif /* PAGETABLE_LEVELS >= 3 */ |
436 | 436 | ||
437 | .pte_val = native_pte_val, | 437 | .pte_val = native_pte_val, |
438 | .pte_flags = native_pte_flags, | ||
439 | .pgd_val = native_pgd_val, | 438 | .pgd_val = native_pgd_val, |
440 | 439 | ||
441 | .make_pte = native_make_pte, | 440 | .make_pte = native_make_pte, |
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index a546f55c77b4..1a1ae8edc40c 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c | |||
@@ -66,9 +66,6 @@ asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); | |||
66 | DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; | 66 | DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; |
67 | EXPORT_PER_CPU_SYMBOL(current_task); | 67 | EXPORT_PER_CPU_SYMBOL(current_task); |
68 | 68 | ||
69 | DEFINE_PER_CPU(int, cpu_number); | ||
70 | EXPORT_PER_CPU_SYMBOL(cpu_number); | ||
71 | |||
72 | /* | 69 | /* |
73 | * Return saved PC of a blocked thread. | 70 | * Return saved PC of a blocked thread. |
74 | */ | 71 | */ |
@@ -111,7 +108,6 @@ void cpu_idle(void) | |||
111 | play_dead(); | 108 | play_dead(); |
112 | 109 | ||
113 | local_irq_disable(); | 110 | local_irq_disable(); |
114 | __get_cpu_var(irq_stat).idle_timestamp = jiffies; | ||
115 | /* Don't trace irqs off for idle */ | 111 | /* Don't trace irqs off for idle */ |
116 | stop_critical_timings(); | 112 | stop_critical_timings(); |
117 | pm_idle(); | 113 | pm_idle(); |
@@ -591,7 +587,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) | |||
591 | if (prev->gs | next->gs) | 587 | if (prev->gs | next->gs) |
592 | loadsegment(gs, next->gs); | 588 | loadsegment(gs, next->gs); |
593 | 589 | ||
594 | x86_write_percpu(current_task, next_p); | 590 | percpu_write(current_task, next_p); |
595 | 591 | ||
596 | return prev_p; | 592 | return prev_p; |
597 | } | 593 | } |
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 416fb9282f4f..c422eebb0c58 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <stdarg.h> | 17 | #include <stdarg.h> |
18 | 18 | ||
19 | #include <linux/stackprotector.h> | ||
19 | #include <linux/cpu.h> | 20 | #include <linux/cpu.h> |
20 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
21 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
@@ -46,7 +47,6 @@ | |||
46 | #include <asm/processor.h> | 47 | #include <asm/processor.h> |
47 | #include <asm/i387.h> | 48 | #include <asm/i387.h> |
48 | #include <asm/mmu_context.h> | 49 | #include <asm/mmu_context.h> |
49 | #include <asm/pda.h> | ||
50 | #include <asm/prctl.h> | 50 | #include <asm/prctl.h> |
51 | #include <asm/desc.h> | 51 | #include <asm/desc.h> |
52 | #include <asm/proto.h> | 52 | #include <asm/proto.h> |
@@ -57,6 +57,12 @@ | |||
57 | 57 | ||
58 | asmlinkage extern void ret_from_fork(void); | 58 | asmlinkage extern void ret_from_fork(void); |
59 | 59 | ||
60 | DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; | ||
61 | EXPORT_PER_CPU_SYMBOL(current_task); | ||
62 | |||
63 | DEFINE_PER_CPU(unsigned long, old_rsp); | ||
64 | static DEFINE_PER_CPU(unsigned char, is_idle); | ||
65 | |||
60 | unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED; | 66 | unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED; |
61 | 67 | ||
62 | static ATOMIC_NOTIFIER_HEAD(idle_notifier); | 68 | static ATOMIC_NOTIFIER_HEAD(idle_notifier); |
@@ -75,13 +81,13 @@ EXPORT_SYMBOL_GPL(idle_notifier_unregister); | |||
75 | 81 | ||
76 | void enter_idle(void) | 82 | void enter_idle(void) |
77 | { | 83 | { |
78 | write_pda(isidle, 1); | 84 | percpu_write(is_idle, 1); |
79 | atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL); | 85 | atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL); |
80 | } | 86 | } |
81 | 87 | ||
82 | static void __exit_idle(void) | 88 | static void __exit_idle(void) |
83 | { | 89 | { |
84 | if (test_and_clear_bit_pda(0, isidle) == 0) | 90 | if (x86_test_and_clear_bit_percpu(0, is_idle) == 0) |
85 | return; | 91 | return; |
86 | atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL); | 92 | atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL); |
87 | } | 93 | } |
@@ -111,6 +117,17 @@ static inline void play_dead(void) | |||
111 | void cpu_idle(void) | 117 | void cpu_idle(void) |
112 | { | 118 | { |
113 | current_thread_info()->status |= TS_POLLING; | 119 | current_thread_info()->status |= TS_POLLING; |
120 | |||
121 | /* | ||
122 | * If we're the non-boot CPU, nothing set the PDA stack | ||
123 | * canary up for us - and if we are the boot CPU we have | ||
124 | * a 0 stack canary. This is a good place for updating | ||
125 | * it, as we wont ever return from this function (so the | ||
126 | * invalid canaries already on the stack wont ever | ||
127 | * trigger): | ||
128 | */ | ||
129 | boot_init_stack_canary(); | ||
130 | |||
114 | /* endless idle loop with no priority at all */ | 131 | /* endless idle loop with no priority at all */ |
115 | while (1) { | 132 | while (1) { |
116 | tick_nohz_stop_sched_tick(1); | 133 | tick_nohz_stop_sched_tick(1); |
@@ -392,7 +409,7 @@ start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp) | |||
392 | load_gs_index(0); | 409 | load_gs_index(0); |
393 | regs->ip = new_ip; | 410 | regs->ip = new_ip; |
394 | regs->sp = new_sp; | 411 | regs->sp = new_sp; |
395 | write_pda(oldrsp, new_sp); | 412 | percpu_write(old_rsp, new_sp); |
396 | regs->cs = __USER_CS; | 413 | regs->cs = __USER_CS; |
397 | regs->ss = __USER_DS; | 414 | regs->ss = __USER_DS; |
398 | regs->flags = 0x200; | 415 | regs->flags = 0x200; |
@@ -613,21 +630,13 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) | |||
613 | /* | 630 | /* |
614 | * Switch the PDA and FPU contexts. | 631 | * Switch the PDA and FPU contexts. |
615 | */ | 632 | */ |
616 | prev->usersp = read_pda(oldrsp); | 633 | prev->usersp = percpu_read(old_rsp); |
617 | write_pda(oldrsp, next->usersp); | 634 | percpu_write(old_rsp, next->usersp); |
618 | write_pda(pcurrent, next_p); | 635 | percpu_write(current_task, next_p); |
619 | 636 | ||
620 | write_pda(kernelstack, | 637 | percpu_write(kernel_stack, |
621 | (unsigned long)task_stack_page(next_p) + | 638 | (unsigned long)task_stack_page(next_p) + |
622 | THREAD_SIZE - PDA_STACKOFFSET); | 639 | THREAD_SIZE - KERNEL_STACK_OFFSET); |
623 | #ifdef CONFIG_CC_STACKPROTECTOR | ||
624 | write_pda(stack_canary, next_p->stack_canary); | ||
625 | /* | ||
626 | * Build time only check to make sure the stack_canary is at | ||
627 | * offset 40 in the pda; this is a gcc ABI requirement | ||
628 | */ | ||
629 | BUILD_BUG_ON(offsetof(struct x8664_pda, stack_canary) != 40); | ||
630 | #endif | ||
631 | 640 | ||
632 | /* | 641 | /* |
633 | * Now maybe reload the debug registers and handle I/O bitmaps | 642 | * Now maybe reload the debug registers and handle I/O bitmaps |
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 2b46eb41643b..f8536fee5c12 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <asm/reboot.h> | 14 | #include <asm/reboot.h> |
15 | #include <asm/pci_x86.h> | 15 | #include <asm/pci_x86.h> |
16 | #include <asm/virtext.h> | 16 | #include <asm/virtext.h> |
17 | #include <asm/cpu.h> | ||
17 | 18 | ||
18 | #ifdef CONFIG_X86_32 | 19 | #ifdef CONFIG_X86_32 |
19 | # include <linux/dmi.h> | 20 | # include <linux/dmi.h> |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index ae0d8042cf69..f41c4486c270 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -89,7 +89,7 @@ | |||
89 | 89 | ||
90 | #include <asm/system.h> | 90 | #include <asm/system.h> |
91 | #include <asm/vsyscall.h> | 91 | #include <asm/vsyscall.h> |
92 | #include <asm/smp.h> | 92 | #include <asm/cpu.h> |
93 | #include <asm/desc.h> | 93 | #include <asm/desc.h> |
94 | #include <asm/dma.h> | 94 | #include <asm/dma.h> |
95 | #include <asm/iommu.h> | 95 | #include <asm/iommu.h> |
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c index 55c46074eba0..0d1e7ac439f4 100644 --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c | |||
@@ -13,145 +13,46 @@ | |||
13 | #include <asm/mpspec.h> | 13 | #include <asm/mpspec.h> |
14 | #include <asm/apicdef.h> | 14 | #include <asm/apicdef.h> |
15 | #include <asm/highmem.h> | 15 | #include <asm/highmem.h> |
16 | #include <asm/proto.h> | ||
17 | #include <asm/cpumask.h> | ||
18 | #include <asm/cpu.h> | ||
16 | 19 | ||
17 | #ifdef CONFIG_X86_LOCAL_APIC | 20 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS |
18 | unsigned int num_processors; | 21 | # define DBG(x...) printk(KERN_DEBUG x) |
19 | unsigned disabled_cpus __cpuinitdata; | ||
20 | /* Processor that is doing the boot up */ | ||
21 | unsigned int boot_cpu_physical_apicid = -1U; | ||
22 | EXPORT_SYMBOL(boot_cpu_physical_apicid); | ||
23 | unsigned int max_physical_apicid; | ||
24 | |||
25 | /* Bitmask of physically existing CPUs */ | ||
26 | physid_mask_t phys_cpu_present_map; | ||
27 | #endif | ||
28 | |||
29 | /* map cpu index to physical APIC ID */ | ||
30 | DEFINE_EARLY_PER_CPU(u16, x86_cpu_to_apicid, BAD_APICID); | ||
31 | DEFINE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid, BAD_APICID); | ||
32 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid); | ||
33 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid); | ||
34 | |||
35 | #if defined(CONFIG_NUMA) && defined(CONFIG_X86_64) | ||
36 | #define X86_64_NUMA 1 | ||
37 | |||
38 | /* map cpu index to node index */ | ||
39 | DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE); | ||
40 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map); | ||
41 | |||
42 | /* which logical CPUs are on which nodes */ | ||
43 | cpumask_t *node_to_cpumask_map; | ||
44 | EXPORT_SYMBOL(node_to_cpumask_map); | ||
45 | |||
46 | /* setup node_to_cpumask_map */ | ||
47 | static void __init setup_node_to_cpumask_map(void); | ||
48 | |||
49 | #else | 22 | #else |
50 | static inline void setup_node_to_cpumask_map(void) { } | 23 | # define DBG(x...) |
51 | #endif | 24 | #endif |
52 | 25 | ||
53 | #if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_X86_SMP) | 26 | DEFINE_PER_CPU(int, cpu_number); |
54 | /* | 27 | EXPORT_PER_CPU_SYMBOL(cpu_number); |
55 | * Copy data used in early init routines from the initial arrays to the | ||
56 | * per cpu data areas. These arrays then become expendable and the | ||
57 | * *_early_ptr's are zeroed indicating that the static arrays are gone. | ||
58 | */ | ||
59 | static void __init setup_per_cpu_maps(void) | ||
60 | { | ||
61 | int cpu; | ||
62 | 28 | ||
63 | for_each_possible_cpu(cpu) { | 29 | #ifdef CONFIG_X86_64 |
64 | per_cpu(x86_cpu_to_apicid, cpu) = | 30 | #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load) |
65 | early_per_cpu_map(x86_cpu_to_apicid, cpu); | 31 | #else |
66 | per_cpu(x86_bios_cpu_apicid, cpu) = | 32 | #define BOOT_PERCPU_OFFSET 0 |
67 | early_per_cpu_map(x86_bios_cpu_apicid, cpu); | ||
68 | #ifdef X86_64_NUMA | ||
69 | per_cpu(x86_cpu_to_node_map, cpu) = | ||
70 | early_per_cpu_map(x86_cpu_to_node_map, cpu); | ||
71 | #endif | 33 | #endif |
72 | } | ||
73 | 34 | ||
74 | /* indicate the early static arrays will soon be gone */ | 35 | DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET; |
75 | early_per_cpu_ptr(x86_cpu_to_apicid) = NULL; | 36 | EXPORT_PER_CPU_SYMBOL(this_cpu_off); |
76 | early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL; | ||
77 | #ifdef X86_64_NUMA | ||
78 | early_per_cpu_ptr(x86_cpu_to_node_map) = NULL; | ||
79 | #endif | ||
80 | } | ||
81 | 37 | ||
82 | #ifdef CONFIG_X86_32 | 38 | unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = { |
83 | /* | 39 | [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET, |
84 | * Great future not-so-futuristic plan: make i386 and x86_64 do it | 40 | }; |
85 | * the same way | ||
86 | */ | ||
87 | unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; | ||
88 | EXPORT_SYMBOL(__per_cpu_offset); | 41 | EXPORT_SYMBOL(__per_cpu_offset); |
89 | static inline void setup_cpu_pda_map(void) { } | ||
90 | |||
91 | #elif !defined(CONFIG_SMP) | ||
92 | static inline void setup_cpu_pda_map(void) { } | ||
93 | |||
94 | #else /* CONFIG_SMP && CONFIG_X86_64 */ | ||
95 | |||
96 | /* | ||
97 | * Allocate cpu_pda pointer table and array via alloc_bootmem. | ||
98 | */ | ||
99 | static void __init setup_cpu_pda_map(void) | ||
100 | { | ||
101 | char *pda; | ||
102 | struct x8664_pda **new_cpu_pda; | ||
103 | unsigned long size; | ||
104 | int cpu; | ||
105 | |||
106 | size = roundup(sizeof(struct x8664_pda), cache_line_size()); | ||
107 | |||
108 | /* allocate cpu_pda array and pointer table */ | ||
109 | { | ||
110 | unsigned long tsize = nr_cpu_ids * sizeof(void *); | ||
111 | unsigned long asize = size * (nr_cpu_ids - 1); | ||
112 | 42 | ||
113 | tsize = roundup(tsize, cache_line_size()); | 43 | static inline void setup_percpu_segment(int cpu) |
114 | new_cpu_pda = alloc_bootmem(tsize + asize); | ||
115 | pda = (char *)new_cpu_pda + tsize; | ||
116 | } | ||
117 | |||
118 | /* initialize pointer table to static pda's */ | ||
119 | for_each_possible_cpu(cpu) { | ||
120 | if (cpu == 0) { | ||
121 | /* leave boot cpu pda in place */ | ||
122 | new_cpu_pda[0] = cpu_pda(0); | ||
123 | continue; | ||
124 | } | ||
125 | new_cpu_pda[cpu] = (struct x8664_pda *)pda; | ||
126 | new_cpu_pda[cpu]->in_bootmem = 1; | ||
127 | pda += size; | ||
128 | } | ||
129 | |||
130 | /* point to new pointer table */ | ||
131 | _cpu_pda = new_cpu_pda; | ||
132 | } | ||
133 | |||
134 | #endif /* CONFIG_SMP && CONFIG_X86_64 */ | ||
135 | |||
136 | #ifdef CONFIG_X86_64 | ||
137 | |||
138 | /* correctly size the local cpu masks */ | ||
139 | static void setup_cpu_local_masks(void) | ||
140 | { | 44 | { |
141 | alloc_bootmem_cpumask_var(&cpu_initialized_mask); | 45 | #ifdef CONFIG_X86_32 |
142 | alloc_bootmem_cpumask_var(&cpu_callin_mask); | 46 | struct desc_struct gdt; |
143 | alloc_bootmem_cpumask_var(&cpu_callout_mask); | ||
144 | alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); | ||
145 | } | ||
146 | |||
147 | #else /* CONFIG_X86_32 */ | ||
148 | 47 | ||
149 | static inline void setup_cpu_local_masks(void) | 48 | pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF, |
150 | { | 49 | 0x2 | DESCTYPE_S, 0x8); |
50 | gdt.s = 1; | ||
51 | write_gdt_entry(get_cpu_gdt_table(cpu), | ||
52 | GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S); | ||
53 | #endif | ||
151 | } | 54 | } |
152 | 55 | ||
153 | #endif /* CONFIG_X86_32 */ | ||
154 | |||
155 | /* | 56 | /* |
156 | * Great future plan: | 57 | * Great future plan: |
157 | * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data. | 58 | * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data. |
@@ -159,18 +60,12 @@ static inline void setup_cpu_local_masks(void) | |||
159 | */ | 60 | */ |
160 | void __init setup_per_cpu_areas(void) | 61 | void __init setup_per_cpu_areas(void) |
161 | { | 62 | { |
162 | ssize_t size, old_size; | 63 | ssize_t size; |
163 | char *ptr; | 64 | char *ptr; |
164 | int cpu; | 65 | int cpu; |
165 | unsigned long align = 1; | ||
166 | |||
167 | /* Setup cpu_pda map */ | ||
168 | setup_cpu_pda_map(); | ||
169 | 66 | ||
170 | /* Copy section for each CPU (we discard the original) */ | 67 | /* Copy section for each CPU (we discard the original) */ |
171 | old_size = PERCPU_ENOUGH_ROOM; | 68 | size = roundup(PERCPU_ENOUGH_ROOM, PAGE_SIZE); |
172 | align = max_t(unsigned long, PAGE_SIZE, align); | ||
173 | size = roundup(old_size, align); | ||
174 | 69 | ||
175 | pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n", | 70 | pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n", |
176 | NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids); | 71 | NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids); |
@@ -179,30 +74,67 @@ void __init setup_per_cpu_areas(void) | |||
179 | 74 | ||
180 | for_each_possible_cpu(cpu) { | 75 | for_each_possible_cpu(cpu) { |
181 | #ifndef CONFIG_NEED_MULTIPLE_NODES | 76 | #ifndef CONFIG_NEED_MULTIPLE_NODES |
182 | ptr = __alloc_bootmem(size, align, | 77 | ptr = alloc_bootmem_pages(size); |
183 | __pa(MAX_DMA_ADDRESS)); | ||
184 | #else | 78 | #else |
185 | int node = early_cpu_to_node(cpu); | 79 | int node = early_cpu_to_node(cpu); |
186 | if (!node_online(node) || !NODE_DATA(node)) { | 80 | if (!node_online(node) || !NODE_DATA(node)) { |
187 | ptr = __alloc_bootmem(size, align, | 81 | ptr = alloc_bootmem_pages(size); |
188 | __pa(MAX_DMA_ADDRESS)); | ||
189 | pr_info("cpu %d has no node %d or node-local memory\n", | 82 | pr_info("cpu %d has no node %d or node-local memory\n", |
190 | cpu, node); | 83 | cpu, node); |
191 | pr_debug("per cpu data for cpu%d at %016lx\n", | 84 | pr_debug("per cpu data for cpu%d at %016lx\n", |
192 | cpu, __pa(ptr)); | 85 | cpu, __pa(ptr)); |
193 | } else { | 86 | } else { |
194 | ptr = __alloc_bootmem_node(NODE_DATA(node), size, align, | 87 | ptr = alloc_bootmem_pages_node(NODE_DATA(node), size); |
195 | __pa(MAX_DMA_ADDRESS)); | ||
196 | pr_debug("per cpu data for cpu%d on node%d at %016lx\n", | 88 | pr_debug("per cpu data for cpu%d on node%d at %016lx\n", |
197 | cpu, node, __pa(ptr)); | 89 | cpu, node, __pa(ptr)); |
198 | } | 90 | } |
199 | #endif | 91 | #endif |
92 | |||
93 | memcpy(ptr, __per_cpu_load, __per_cpu_end - __per_cpu_start); | ||
200 | per_cpu_offset(cpu) = ptr - __per_cpu_start; | 94 | per_cpu_offset(cpu) = ptr - __per_cpu_start; |
201 | memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); | 95 | per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu); |
96 | per_cpu(cpu_number, cpu) = cpu; | ||
97 | setup_percpu_segment(cpu); | ||
98 | /* | ||
99 | * Copy data used in early init routines from the | ||
100 | * initial arrays to the per cpu data areas. These | ||
101 | * arrays then become expendable and the *_early_ptr's | ||
102 | * are zeroed indicating that the static arrays are | ||
103 | * gone. | ||
104 | */ | ||
105 | #ifdef CONFIG_X86_LOCAL_APIC | ||
106 | per_cpu(x86_cpu_to_apicid, cpu) = | ||
107 | early_per_cpu_map(x86_cpu_to_apicid, cpu); | ||
108 | per_cpu(x86_bios_cpu_apicid, cpu) = | ||
109 | early_per_cpu_map(x86_bios_cpu_apicid, cpu); | ||
110 | #endif | ||
111 | #ifdef CONFIG_X86_64 | ||
112 | per_cpu(irq_stack_ptr, cpu) = | ||
113 | per_cpu(irq_stack_union.irq_stack, cpu) + | ||
114 | IRQ_STACK_SIZE - 64; | ||
115 | #ifdef CONFIG_NUMA | ||
116 | per_cpu(x86_cpu_to_node_map, cpu) = | ||
117 | early_per_cpu_map(x86_cpu_to_node_map, cpu); | ||
118 | #endif | ||
119 | #endif | ||
120 | /* | ||
121 | * Up to this point, the boot CPU has been using .data.init | ||
122 | * area. Reload any changed state for the boot CPU. | ||
123 | */ | ||
124 | if (cpu == boot_cpu_id) | ||
125 | switch_to_new_gdt(); | ||
126 | |||
127 | DBG("PERCPU: cpu %4d %p\n", cpu, ptr); | ||
202 | } | 128 | } |
203 | 129 | ||
204 | /* Setup percpu data maps */ | 130 | /* indicate the early static arrays will soon be gone */ |
205 | setup_per_cpu_maps(); | 131 | #ifdef CONFIG_X86_LOCAL_APIC |
132 | early_per_cpu_ptr(x86_cpu_to_apicid) = NULL; | ||
133 | early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL; | ||
134 | #endif | ||
135 | #if defined(CONFIG_X86_64) && defined(CONFIG_NUMA) | ||
136 | early_per_cpu_ptr(x86_cpu_to_node_map) = NULL; | ||
137 | #endif | ||
206 | 138 | ||
207 | /* Setup node to cpumask map */ | 139 | /* Setup node to cpumask map */ |
208 | setup_node_to_cpumask_map(); | 140 | setup_node_to_cpumask_map(); |
@@ -210,199 +142,3 @@ void __init setup_per_cpu_areas(void) | |||
210 | /* Setup cpu initialized, callin, callout masks */ | 142 | /* Setup cpu initialized, callin, callout masks */ |
211 | setup_cpu_local_masks(); | 143 | setup_cpu_local_masks(); |
212 | } | 144 | } |
213 | |||
214 | #endif | ||
215 | |||
216 | #ifdef X86_64_NUMA | ||
217 | |||
218 | /* | ||
219 | * Allocate node_to_cpumask_map based on number of available nodes | ||
220 | * Requires node_possible_map to be valid. | ||
221 | * | ||
222 | * Note: node_to_cpumask() is not valid until after this is done. | ||
223 | */ | ||
224 | static void __init setup_node_to_cpumask_map(void) | ||
225 | { | ||
226 | unsigned int node, num = 0; | ||
227 | cpumask_t *map; | ||
228 | |||
229 | /* setup nr_node_ids if not done yet */ | ||
230 | if (nr_node_ids == MAX_NUMNODES) { | ||
231 | for_each_node_mask(node, node_possible_map) | ||
232 | num = node; | ||
233 | nr_node_ids = num + 1; | ||
234 | } | ||
235 | |||
236 | /* allocate the map */ | ||
237 | map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t)); | ||
238 | |||
239 | pr_debug("Node to cpumask map at %p for %d nodes\n", | ||
240 | map, nr_node_ids); | ||
241 | |||
242 | /* node_to_cpumask() will now work */ | ||
243 | node_to_cpumask_map = map; | ||
244 | } | ||
245 | |||
246 | void __cpuinit numa_set_node(int cpu, int node) | ||
247 | { | ||
248 | int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map); | ||
249 | |||
250 | if (cpu_pda(cpu) && node != NUMA_NO_NODE) | ||
251 | cpu_pda(cpu)->nodenumber = node; | ||
252 | |||
253 | if (cpu_to_node_map) | ||
254 | cpu_to_node_map[cpu] = node; | ||
255 | |||
256 | else if (per_cpu_offset(cpu)) | ||
257 | per_cpu(x86_cpu_to_node_map, cpu) = node; | ||
258 | |||
259 | else | ||
260 | pr_debug("Setting node for non-present cpu %d\n", cpu); | ||
261 | } | ||
262 | |||
263 | void __cpuinit numa_clear_node(int cpu) | ||
264 | { | ||
265 | numa_set_node(cpu, NUMA_NO_NODE); | ||
266 | } | ||
267 | |||
268 | #ifndef CONFIG_DEBUG_PER_CPU_MAPS | ||
269 | |||
270 | void __cpuinit numa_add_cpu(int cpu) | ||
271 | { | ||
272 | cpu_set(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); | ||
273 | } | ||
274 | |||
275 | void __cpuinit numa_remove_cpu(int cpu) | ||
276 | { | ||
277 | cpu_clear(cpu, node_to_cpumask_map[cpu_to_node(cpu)]); | ||
278 | } | ||
279 | |||
280 | #else /* CONFIG_DEBUG_PER_CPU_MAPS */ | ||
281 | |||
282 | /* | ||
283 | * --------- debug versions of the numa functions --------- | ||
284 | */ | ||
285 | static void __cpuinit numa_set_cpumask(int cpu, int enable) | ||
286 | { | ||
287 | int node = cpu_to_node(cpu); | ||
288 | cpumask_t *mask; | ||
289 | char buf[64]; | ||
290 | |||
291 | if (node_to_cpumask_map == NULL) { | ||
292 | printk(KERN_ERR "node_to_cpumask_map NULL\n"); | ||
293 | dump_stack(); | ||
294 | return; | ||
295 | } | ||
296 | |||
297 | mask = &node_to_cpumask_map[node]; | ||
298 | if (enable) | ||
299 | cpu_set(cpu, *mask); | ||
300 | else | ||
301 | cpu_clear(cpu, *mask); | ||
302 | |||
303 | cpulist_scnprintf(buf, sizeof(buf), mask); | ||
304 | printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", | ||
305 | enable ? "numa_add_cpu" : "numa_remove_cpu", cpu, node, buf); | ||
306 | } | ||
307 | |||
308 | void __cpuinit numa_add_cpu(int cpu) | ||
309 | { | ||
310 | numa_set_cpumask(cpu, 1); | ||
311 | } | ||
312 | |||
313 | void __cpuinit numa_remove_cpu(int cpu) | ||
314 | { | ||
315 | numa_set_cpumask(cpu, 0); | ||
316 | } | ||
317 | |||
318 | int cpu_to_node(int cpu) | ||
319 | { | ||
320 | if (early_per_cpu_ptr(x86_cpu_to_node_map)) { | ||
321 | printk(KERN_WARNING | ||
322 | "cpu_to_node(%d): usage too early!\n", cpu); | ||
323 | dump_stack(); | ||
324 | return early_per_cpu_ptr(x86_cpu_to_node_map)[cpu]; | ||
325 | } | ||
326 | return per_cpu(x86_cpu_to_node_map, cpu); | ||
327 | } | ||
328 | EXPORT_SYMBOL(cpu_to_node); | ||
329 | |||
330 | /* | ||
331 | * Same function as cpu_to_node() but used if called before the | ||
332 | * per_cpu areas are setup. | ||
333 | */ | ||
334 | int early_cpu_to_node(int cpu) | ||
335 | { | ||
336 | if (early_per_cpu_ptr(x86_cpu_to_node_map)) | ||
337 | return early_per_cpu_ptr(x86_cpu_to_node_map)[cpu]; | ||
338 | |||
339 | if (!per_cpu_offset(cpu)) { | ||
340 | printk(KERN_WARNING | ||
341 | "early_cpu_to_node(%d): no per_cpu area!\n", cpu); | ||
342 | dump_stack(); | ||
343 | return NUMA_NO_NODE; | ||
344 | } | ||
345 | return per_cpu(x86_cpu_to_node_map, cpu); | ||
346 | } | ||
347 | |||
348 | |||
349 | /* empty cpumask */ | ||
350 | static const cpumask_t cpu_mask_none; | ||
351 | |||
352 | /* | ||
353 | * Returns a pointer to the bitmask of CPUs on Node 'node'. | ||
354 | */ | ||
355 | const cpumask_t *cpumask_of_node(int node) | ||
356 | { | ||
357 | if (node_to_cpumask_map == NULL) { | ||
358 | printk(KERN_WARNING | ||
359 | "cpumask_of_node(%d): no node_to_cpumask_map!\n", | ||
360 | node); | ||
361 | dump_stack(); | ||
362 | return (const cpumask_t *)&cpu_online_map; | ||
363 | } | ||
364 | if (node >= nr_node_ids) { | ||
365 | printk(KERN_WARNING | ||
366 | "cpumask_of_node(%d): node > nr_node_ids(%d)\n", | ||
367 | node, nr_node_ids); | ||
368 | dump_stack(); | ||
369 | return &cpu_mask_none; | ||
370 | } | ||
371 | return &node_to_cpumask_map[node]; | ||
372 | } | ||
373 | EXPORT_SYMBOL(cpumask_of_node); | ||
374 | |||
375 | /* | ||
376 | * Returns a bitmask of CPUs on Node 'node'. | ||
377 | * | ||
378 | * Side note: this function creates the returned cpumask on the stack | ||
379 | * so with a high NR_CPUS count, excessive stack space is used. The | ||
380 | * node_to_cpumask_ptr function should be used whenever possible. | ||
381 | */ | ||
382 | cpumask_t node_to_cpumask(int node) | ||
383 | { | ||
384 | if (node_to_cpumask_map == NULL) { | ||
385 | printk(KERN_WARNING | ||
386 | "node_to_cpumask(%d): no node_to_cpumask_map!\n", node); | ||
387 | dump_stack(); | ||
388 | return cpu_online_map; | ||
389 | } | ||
390 | if (node >= nr_node_ids) { | ||
391 | printk(KERN_WARNING | ||
392 | "node_to_cpumask(%d): node > nr_node_ids(%d)\n", | ||
393 | node, nr_node_ids); | ||
394 | dump_stack(); | ||
395 | return cpu_mask_none; | ||
396 | } | ||
397 | return node_to_cpumask_map[node]; | ||
398 | } | ||
399 | EXPORT_SYMBOL(node_to_cpumask); | ||
400 | |||
401 | /* | ||
402 | * --------- end of debug versions of the numa functions --------- | ||
403 | */ | ||
404 | |||
405 | #endif /* CONFIG_DEBUG_PER_CPU_MAPS */ | ||
406 | |||
407 | #endif /* X86_64_NUMA */ | ||
408 | |||
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 89bb7668041d..7fc78b019815 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c | |||
@@ -51,24 +51,24 @@ | |||
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #define COPY(x) { \ | 53 | #define COPY(x) { \ |
54 | err |= __get_user(regs->x, &sc->x); \ | 54 | get_user_ex(regs->x, &sc->x); \ |
55 | } | 55 | } |
56 | 56 | ||
57 | #define COPY_SEG(seg) { \ | 57 | #define COPY_SEG(seg) { \ |
58 | unsigned short tmp; \ | 58 | unsigned short tmp; \ |
59 | err |= __get_user(tmp, &sc->seg); \ | 59 | get_user_ex(tmp, &sc->seg); \ |
60 | regs->seg = tmp; \ | 60 | regs->seg = tmp; \ |
61 | } | 61 | } |
62 | 62 | ||
63 | #define COPY_SEG_CPL3(seg) { \ | 63 | #define COPY_SEG_CPL3(seg) { \ |
64 | unsigned short tmp; \ | 64 | unsigned short tmp; \ |
65 | err |= __get_user(tmp, &sc->seg); \ | 65 | get_user_ex(tmp, &sc->seg); \ |
66 | regs->seg = tmp | 3; \ | 66 | regs->seg = tmp | 3; \ |
67 | } | 67 | } |
68 | 68 | ||
69 | #define GET_SEG(seg) { \ | 69 | #define GET_SEG(seg) { \ |
70 | unsigned short tmp; \ | 70 | unsigned short tmp; \ |
71 | err |= __get_user(tmp, &sc->seg); \ | 71 | get_user_ex(tmp, &sc->seg); \ |
72 | loadsegment(seg, tmp); \ | 72 | loadsegment(seg, tmp); \ |
73 | } | 73 | } |
74 | 74 | ||
@@ -83,45 +83,49 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | |||
83 | /* Always make any pending restarted system calls return -EINTR */ | 83 | /* Always make any pending restarted system calls return -EINTR */ |
84 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 84 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
85 | 85 | ||
86 | get_user_try { | ||
87 | |||
86 | #ifdef CONFIG_X86_32 | 88 | #ifdef CONFIG_X86_32 |
87 | GET_SEG(gs); | 89 | GET_SEG(gs); |
88 | COPY_SEG(fs); | 90 | COPY_SEG(fs); |
89 | COPY_SEG(es); | 91 | COPY_SEG(es); |
90 | COPY_SEG(ds); | 92 | COPY_SEG(ds); |
91 | #endif /* CONFIG_X86_32 */ | 93 | #endif /* CONFIG_X86_32 */ |
92 | 94 | ||
93 | COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); | 95 | COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); |
94 | COPY(dx); COPY(cx); COPY(ip); | 96 | COPY(dx); COPY(cx); COPY(ip); |
95 | 97 | ||
96 | #ifdef CONFIG_X86_64 | 98 | #ifdef CONFIG_X86_64 |
97 | COPY(r8); | 99 | COPY(r8); |
98 | COPY(r9); | 100 | COPY(r9); |
99 | COPY(r10); | 101 | COPY(r10); |
100 | COPY(r11); | 102 | COPY(r11); |
101 | COPY(r12); | 103 | COPY(r12); |
102 | COPY(r13); | 104 | COPY(r13); |
103 | COPY(r14); | 105 | COPY(r14); |
104 | COPY(r15); | 106 | COPY(r15); |
105 | #endif /* CONFIG_X86_64 */ | 107 | #endif /* CONFIG_X86_64 */ |
106 | 108 | ||
107 | #ifdef CONFIG_X86_32 | 109 | #ifdef CONFIG_X86_32 |
108 | COPY_SEG_CPL3(cs); | 110 | COPY_SEG_CPL3(cs); |
109 | COPY_SEG_CPL3(ss); | 111 | COPY_SEG_CPL3(ss); |
110 | #else /* !CONFIG_X86_32 */ | 112 | #else /* !CONFIG_X86_32 */ |
111 | /* Kernel saves and restores only the CS segment register on signals, | 113 | /* Kernel saves and restores only the CS segment register on signals, |
112 | * which is the bare minimum needed to allow mixed 32/64-bit code. | 114 | * which is the bare minimum needed to allow mixed 32/64-bit code. |
113 | * App's signal handler can save/restore other segments if needed. */ | 115 | * App's signal handler can save/restore other segments if needed. */ |
114 | COPY_SEG_CPL3(cs); | 116 | COPY_SEG_CPL3(cs); |
115 | #endif /* CONFIG_X86_32 */ | 117 | #endif /* CONFIG_X86_32 */ |
116 | 118 | ||
117 | err |= __get_user(tmpflags, &sc->flags); | 119 | get_user_ex(tmpflags, &sc->flags); |
118 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); | 120 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); |
119 | regs->orig_ax = -1; /* disable syscall checks */ | 121 | regs->orig_ax = -1; /* disable syscall checks */ |
122 | |||
123 | get_user_ex(buf, &sc->fpstate); | ||
124 | err |= restore_i387_xstate(buf); | ||
120 | 125 | ||
121 | err |= __get_user(buf, &sc->fpstate); | 126 | get_user_ex(*pax, &sc->ax); |
122 | err |= restore_i387_xstate(buf); | 127 | } get_user_catch(err); |
123 | 128 | ||
124 | err |= __get_user(*pax, &sc->ax); | ||
125 | return err; | 129 | return err; |
126 | } | 130 | } |
127 | 131 | ||
@@ -131,57 +135,60 @@ setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate, | |||
131 | { | 135 | { |
132 | int err = 0; | 136 | int err = 0; |
133 | 137 | ||
138 | put_user_try { | ||
139 | |||
134 | #ifdef CONFIG_X86_32 | 140 | #ifdef CONFIG_X86_32 |
135 | { | 141 | { |
136 | unsigned int tmp; | 142 | unsigned int tmp; |
137 | 143 | ||
138 | savesegment(gs, tmp); | 144 | savesegment(gs, tmp); |
139 | err |= __put_user(tmp, (unsigned int __user *)&sc->gs); | 145 | put_user_ex(tmp, (unsigned int __user *)&sc->gs); |
140 | } | 146 | } |
141 | err |= __put_user(regs->fs, (unsigned int __user *)&sc->fs); | 147 | put_user_ex(regs->fs, (unsigned int __user *)&sc->fs); |
142 | err |= __put_user(regs->es, (unsigned int __user *)&sc->es); | 148 | put_user_ex(regs->es, (unsigned int __user *)&sc->es); |
143 | err |= __put_user(regs->ds, (unsigned int __user *)&sc->ds); | 149 | put_user_ex(regs->ds, (unsigned int __user *)&sc->ds); |
144 | #endif /* CONFIG_X86_32 */ | 150 | #endif /* CONFIG_X86_32 */ |
145 | 151 | ||
146 | err |= __put_user(regs->di, &sc->di); | 152 | put_user_ex(regs->di, &sc->di); |
147 | err |= __put_user(regs->si, &sc->si); | 153 | put_user_ex(regs->si, &sc->si); |
148 | err |= __put_user(regs->bp, &sc->bp); | 154 | put_user_ex(regs->bp, &sc->bp); |
149 | err |= __put_user(regs->sp, &sc->sp); | 155 | put_user_ex(regs->sp, &sc->sp); |
150 | err |= __put_user(regs->bx, &sc->bx); | 156 | put_user_ex(regs->bx, &sc->bx); |
151 | err |= __put_user(regs->dx, &sc->dx); | 157 | put_user_ex(regs->dx, &sc->dx); |
152 | err |= __put_user(regs->cx, &sc->cx); | 158 | put_user_ex(regs->cx, &sc->cx); |
153 | err |= __put_user(regs->ax, &sc->ax); | 159 | put_user_ex(regs->ax, &sc->ax); |
154 | #ifdef CONFIG_X86_64 | 160 | #ifdef CONFIG_X86_64 |
155 | err |= __put_user(regs->r8, &sc->r8); | 161 | put_user_ex(regs->r8, &sc->r8); |
156 | err |= __put_user(regs->r9, &sc->r9); | 162 | put_user_ex(regs->r9, &sc->r9); |
157 | err |= __put_user(regs->r10, &sc->r10); | 163 | put_user_ex(regs->r10, &sc->r10); |
158 | err |= __put_user(regs->r11, &sc->r11); | 164 | put_user_ex(regs->r11, &sc->r11); |
159 | err |= __put_user(regs->r12, &sc->r12); | 165 | put_user_ex(regs->r12, &sc->r12); |
160 | err |= __put_user(regs->r13, &sc->r13); | 166 | put_user_ex(regs->r13, &sc->r13); |
161 | err |= __put_user(regs->r14, &sc->r14); | 167 | put_user_ex(regs->r14, &sc->r14); |
162 | err |= __put_user(regs->r15, &sc->r15); | 168 | put_user_ex(regs->r15, &sc->r15); |
163 | #endif /* CONFIG_X86_64 */ | 169 | #endif /* CONFIG_X86_64 */ |
164 | 170 | ||
165 | err |= __put_user(current->thread.trap_no, &sc->trapno); | 171 | put_user_ex(current->thread.trap_no, &sc->trapno); |
166 | err |= __put_user(current->thread.error_code, &sc->err); | 172 | put_user_ex(current->thread.error_code, &sc->err); |
167 | err |= __put_user(regs->ip, &sc->ip); | 173 | put_user_ex(regs->ip, &sc->ip); |
168 | #ifdef CONFIG_X86_32 | 174 | #ifdef CONFIG_X86_32 |
169 | err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs); | 175 | put_user_ex(regs->cs, (unsigned int __user *)&sc->cs); |
170 | err |= __put_user(regs->flags, &sc->flags); | 176 | put_user_ex(regs->flags, &sc->flags); |
171 | err |= __put_user(regs->sp, &sc->sp_at_signal); | 177 | put_user_ex(regs->sp, &sc->sp_at_signal); |
172 | err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss); | 178 | put_user_ex(regs->ss, (unsigned int __user *)&sc->ss); |
173 | #else /* !CONFIG_X86_32 */ | 179 | #else /* !CONFIG_X86_32 */ |
174 | err |= __put_user(regs->flags, &sc->flags); | 180 | put_user_ex(regs->flags, &sc->flags); |
175 | err |= __put_user(regs->cs, &sc->cs); | 181 | put_user_ex(regs->cs, &sc->cs); |
176 | err |= __put_user(0, &sc->gs); | 182 | put_user_ex(0, &sc->gs); |
177 | err |= __put_user(0, &sc->fs); | 183 | put_user_ex(0, &sc->fs); |
178 | #endif /* CONFIG_X86_32 */ | 184 | #endif /* CONFIG_X86_32 */ |
179 | 185 | ||
180 | err |= __put_user(fpstate, &sc->fpstate); | 186 | put_user_ex(fpstate, &sc->fpstate); |
181 | 187 | ||
182 | /* non-iBCS2 extensions.. */ | 188 | /* non-iBCS2 extensions.. */ |
183 | err |= __put_user(mask, &sc->oldmask); | 189 | put_user_ex(mask, &sc->oldmask); |
184 | err |= __put_user(current->thread.cr2, &sc->cr2); | 190 | put_user_ex(current->thread.cr2, &sc->cr2); |
191 | } put_user_catch(err); | ||
185 | 192 | ||
186 | return err; | 193 | return err; |
187 | } | 194 | } |
@@ -336,43 +343,41 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
336 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 343 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
337 | return -EFAULT; | 344 | return -EFAULT; |
338 | 345 | ||
339 | err |= __put_user(sig, &frame->sig); | 346 | put_user_try { |
340 | err |= __put_user(&frame->info, &frame->pinfo); | 347 | put_user_ex(sig, &frame->sig); |
341 | err |= __put_user(&frame->uc, &frame->puc); | 348 | put_user_ex(&frame->info, &frame->pinfo); |
342 | err |= copy_siginfo_to_user(&frame->info, info); | 349 | put_user_ex(&frame->uc, &frame->puc); |
343 | if (err) | 350 | err |= copy_siginfo_to_user(&frame->info, info); |
344 | return -EFAULT; | ||
345 | |||
346 | /* Create the ucontext. */ | ||
347 | if (cpu_has_xsave) | ||
348 | err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags); | ||
349 | else | ||
350 | err |= __put_user(0, &frame->uc.uc_flags); | ||
351 | err |= __put_user(0, &frame->uc.uc_link); | ||
352 | err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); | ||
353 | err |= __put_user(sas_ss_flags(regs->sp), | ||
354 | &frame->uc.uc_stack.ss_flags); | ||
355 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); | ||
356 | err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate, | ||
357 | regs, set->sig[0]); | ||
358 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | ||
359 | if (err) | ||
360 | return -EFAULT; | ||
361 | 351 | ||
362 | /* Set up to return from userspace. */ | 352 | /* Create the ucontext. */ |
363 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); | 353 | if (cpu_has_xsave) |
364 | if (ka->sa.sa_flags & SA_RESTORER) | 354 | put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags); |
365 | restorer = ka->sa.sa_restorer; | 355 | else |
366 | err |= __put_user(restorer, &frame->pretcode); | 356 | put_user_ex(0, &frame->uc.uc_flags); |
357 | put_user_ex(0, &frame->uc.uc_link); | ||
358 | put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); | ||
359 | put_user_ex(sas_ss_flags(regs->sp), | ||
360 | &frame->uc.uc_stack.ss_flags); | ||
361 | put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size); | ||
362 | err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate, | ||
363 | regs, set->sig[0]); | ||
364 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | ||
365 | |||
366 | /* Set up to return from userspace. */ | ||
367 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); | ||
368 | if (ka->sa.sa_flags & SA_RESTORER) | ||
369 | restorer = ka->sa.sa_restorer; | ||
370 | put_user_ex(restorer, &frame->pretcode); | ||
367 | 371 | ||
368 | /* | 372 | /* |
369 | * This is movl $__NR_rt_sigreturn, %ax ; int $0x80 | 373 | * This is movl $__NR_rt_sigreturn, %ax ; int $0x80 |
370 | * | 374 | * |
371 | * WE DO NOT USE IT ANY MORE! It's only left here for historical | 375 | * WE DO NOT USE IT ANY MORE! It's only left here for historical |
372 | * reasons and because gdb uses it as a signature to notice | 376 | * reasons and because gdb uses it as a signature to notice |
373 | * signal handler stack frames. | 377 | * signal handler stack frames. |
374 | */ | 378 | */ |
375 | err |= __put_user(*((u64 *)&rt_retcode), (u64 *)frame->retcode); | 379 | put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode); |
380 | } put_user_catch(err); | ||
376 | 381 | ||
377 | if (err) | 382 | if (err) |
378 | return -EFAULT; | 383 | return -EFAULT; |
@@ -436,28 +441,30 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
436 | return -EFAULT; | 441 | return -EFAULT; |
437 | } | 442 | } |
438 | 443 | ||
439 | /* Create the ucontext. */ | 444 | put_user_try { |
440 | if (cpu_has_xsave) | 445 | /* Create the ucontext. */ |
441 | err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags); | 446 | if (cpu_has_xsave) |
442 | else | 447 | put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags); |
443 | err |= __put_user(0, &frame->uc.uc_flags); | 448 | else |
444 | err |= __put_user(0, &frame->uc.uc_link); | 449 | put_user_ex(0, &frame->uc.uc_flags); |
445 | err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); | 450 | put_user_ex(0, &frame->uc.uc_link); |
446 | err |= __put_user(sas_ss_flags(regs->sp), | 451 | put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); |
447 | &frame->uc.uc_stack.ss_flags); | 452 | put_user_ex(sas_ss_flags(regs->sp), |
448 | err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size); | 453 | &frame->uc.uc_stack.ss_flags); |
449 | err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]); | 454 | put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size); |
450 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 455 | err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]); |
451 | 456 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | |
452 | /* Set up to return from userspace. If provided, use a stub | 457 | |
453 | already in userspace. */ | 458 | /* Set up to return from userspace. If provided, use a stub |
454 | /* x86-64 should always use SA_RESTORER. */ | 459 | already in userspace. */ |
455 | if (ka->sa.sa_flags & SA_RESTORER) { | 460 | /* x86-64 should always use SA_RESTORER. */ |
456 | err |= __put_user(ka->sa.sa_restorer, &frame->pretcode); | 461 | if (ka->sa.sa_flags & SA_RESTORER) { |
457 | } else { | 462 | put_user_ex(ka->sa.sa_restorer, &frame->pretcode); |
458 | /* could use a vstub here */ | 463 | } else { |
459 | return -EFAULT; | 464 | /* could use a vstub here */ |
460 | } | 465 | err |= -EFAULT; |
466 | } | ||
467 | } put_user_catch(err); | ||
461 | 468 | ||
462 | if (err) | 469 | if (err) |
463 | return -EFAULT; | 470 | return -EFAULT; |
@@ -509,31 +516,41 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, | |||
509 | struct old_sigaction __user *oact) | 516 | struct old_sigaction __user *oact) |
510 | { | 517 | { |
511 | struct k_sigaction new_ka, old_ka; | 518 | struct k_sigaction new_ka, old_ka; |
512 | int ret; | 519 | int ret = 0; |
513 | 520 | ||
514 | if (act) { | 521 | if (act) { |
515 | old_sigset_t mask; | 522 | old_sigset_t mask; |
516 | 523 | ||
517 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || | 524 | if (!access_ok(VERIFY_READ, act, sizeof(*act))) |
518 | __get_user(new_ka.sa.sa_handler, &act->sa_handler) || | ||
519 | __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) | ||
520 | return -EFAULT; | 525 | return -EFAULT; |
521 | 526 | ||
522 | __get_user(new_ka.sa.sa_flags, &act->sa_flags); | 527 | get_user_try { |
523 | __get_user(mask, &act->sa_mask); | 528 | get_user_ex(new_ka.sa.sa_handler, &act->sa_handler); |
529 | get_user_ex(new_ka.sa.sa_flags, &act->sa_flags); | ||
530 | get_user_ex(mask, &act->sa_mask); | ||
531 | get_user_ex(new_ka.sa.sa_restorer, &act->sa_restorer); | ||
532 | } get_user_catch(ret); | ||
533 | |||
534 | if (ret) | ||
535 | return -EFAULT; | ||
524 | siginitset(&new_ka.sa.sa_mask, mask); | 536 | siginitset(&new_ka.sa.sa_mask, mask); |
525 | } | 537 | } |
526 | 538 | ||
527 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); | 539 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
528 | 540 | ||
529 | if (!ret && oact) { | 541 | if (!ret && oact) { |
530 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || | 542 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact))) |
531 | __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || | ||
532 | __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) | ||
533 | return -EFAULT; | 543 | return -EFAULT; |
534 | 544 | ||
535 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags); | 545 | put_user_try { |
536 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); | 546 | put_user_ex(old_ka.sa.sa_handler, &oact->sa_handler); |
547 | put_user_ex(old_ka.sa.sa_flags, &oact->sa_flags); | ||
548 | put_user_ex(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); | ||
549 | put_user_ex(old_ka.sa.sa_restorer, &oact->sa_restorer); | ||
550 | } put_user_catch(ret); | ||
551 | |||
552 | if (ret) | ||
553 | return -EFAULT; | ||
537 | } | 554 | } |
538 | 555 | ||
539 | return ret; | 556 | return ret; |
@@ -632,9 +649,16 @@ badframe: | |||
632 | } | 649 | } |
633 | 650 | ||
634 | #ifdef CONFIG_X86_32 | 651 | #ifdef CONFIG_X86_32 |
635 | asmlinkage int sys_rt_sigreturn(struct pt_regs regs) | 652 | /* |
653 | * Note: do not pass in pt_regs directly as with tail-call optimization | ||
654 | * GCC will incorrectly stomp on the caller's frame and corrupt user-space | ||
655 | * register state: | ||
656 | */ | ||
657 | asmlinkage int sys_rt_sigreturn(unsigned long __unused) | ||
636 | { | 658 | { |
637 | return do_rt_sigreturn(®s); | 659 | struct pt_regs *regs = (struct pt_regs *)&__unused; |
660 | |||
661 | return do_rt_sigreturn(regs); | ||
638 | } | 662 | } |
639 | #else /* !CONFIG_X86_32 */ | 663 | #else /* !CONFIG_X86_32 */ |
640 | asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) | 664 | asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index bb1a3b1fc87f..f9dbcff43546 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include <asm/nmi.h> | 53 | #include <asm/nmi.h> |
54 | #include <asm/irq.h> | 54 | #include <asm/irq.h> |
55 | #include <asm/idle.h> | 55 | #include <asm/idle.h> |
56 | #include <asm/smp.h> | ||
57 | #include <asm/trampoline.h> | 56 | #include <asm/trampoline.h> |
58 | #include <asm/cpu.h> | 57 | #include <asm/cpu.h> |
59 | #include <asm/numa.h> | 58 | #include <asm/numa.h> |
@@ -63,6 +62,7 @@ | |||
63 | #include <asm/vmi.h> | 62 | #include <asm/vmi.h> |
64 | #include <asm/genapic.h> | 63 | #include <asm/genapic.h> |
65 | #include <asm/setup.h> | 64 | #include <asm/setup.h> |
65 | #include <asm/uv/uv.h> | ||
66 | #include <linux/mc146818rtc.h> | 66 | #include <linux/mc146818rtc.h> |
67 | 67 | ||
68 | #include <mach_apic.h> | 68 | #include <mach_apic.h> |
@@ -745,52 +745,6 @@ static void __cpuinit do_fork_idle(struct work_struct *work) | |||
745 | complete(&c_idle->done); | 745 | complete(&c_idle->done); |
746 | } | 746 | } |
747 | 747 | ||
748 | #ifdef CONFIG_X86_64 | ||
749 | |||
750 | /* __ref because it's safe to call free_bootmem when after_bootmem == 0. */ | ||
751 | static void __ref free_bootmem_pda(struct x8664_pda *oldpda) | ||
752 | { | ||
753 | if (!after_bootmem) | ||
754 | free_bootmem((unsigned long)oldpda, sizeof(*oldpda)); | ||
755 | } | ||
756 | |||
757 | /* | ||
758 | * Allocate node local memory for the AP pda. | ||
759 | * | ||
760 | * Must be called after the _cpu_pda pointer table is initialized. | ||
761 | */ | ||
762 | int __cpuinit get_local_pda(int cpu) | ||
763 | { | ||
764 | struct x8664_pda *oldpda, *newpda; | ||
765 | unsigned long size = sizeof(struct x8664_pda); | ||
766 | int node = cpu_to_node(cpu); | ||
767 | |||
768 | if (cpu_pda(cpu) && !cpu_pda(cpu)->in_bootmem) | ||
769 | return 0; | ||
770 | |||
771 | oldpda = cpu_pda(cpu); | ||
772 | newpda = kmalloc_node(size, GFP_ATOMIC, node); | ||
773 | if (!newpda) { | ||
774 | printk(KERN_ERR "Could not allocate node local PDA " | ||
775 | "for CPU %d on node %d\n", cpu, node); | ||
776 | |||
777 | if (oldpda) | ||
778 | return 0; /* have a usable pda */ | ||
779 | else | ||
780 | return -1; | ||
781 | } | ||
782 | |||
783 | if (oldpda) { | ||
784 | memcpy(newpda, oldpda, size); | ||
785 | free_bootmem_pda(oldpda); | ||
786 | } | ||
787 | |||
788 | newpda->in_bootmem = 0; | ||
789 | cpu_pda(cpu) = newpda; | ||
790 | return 0; | ||
791 | } | ||
792 | #endif /* CONFIG_X86_64 */ | ||
793 | |||
794 | static int __cpuinit do_boot_cpu(int apicid, int cpu) | 748 | static int __cpuinit do_boot_cpu(int apicid, int cpu) |
795 | /* | 749 | /* |
796 | * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad | 750 | * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad |
@@ -808,16 +762,6 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu) | |||
808 | }; | 762 | }; |
809 | INIT_WORK(&c_idle.work, do_fork_idle); | 763 | INIT_WORK(&c_idle.work, do_fork_idle); |
810 | 764 | ||
811 | #ifdef CONFIG_X86_64 | ||
812 | /* Allocate node local memory for AP pdas */ | ||
813 | if (cpu > 0) { | ||
814 | boot_error = get_local_pda(cpu); | ||
815 | if (boot_error) | ||
816 | goto restore_state; | ||
817 | /* if can't get pda memory, can't start cpu */ | ||
818 | } | ||
819 | #endif | ||
820 | |||
821 | alternatives_smp_switch(1); | 765 | alternatives_smp_switch(1); |
822 | 766 | ||
823 | c_idle.idle = get_idle_for_cpu(cpu); | 767 | c_idle.idle = get_idle_for_cpu(cpu); |
@@ -847,14 +791,16 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu) | |||
847 | 791 | ||
848 | set_idle_for_cpu(cpu, c_idle.idle); | 792 | set_idle_for_cpu(cpu, c_idle.idle); |
849 | do_rest: | 793 | do_rest: |
850 | #ifdef CONFIG_X86_32 | ||
851 | per_cpu(current_task, cpu) = c_idle.idle; | 794 | per_cpu(current_task, cpu) = c_idle.idle; |
852 | init_gdt(cpu); | 795 | #ifdef CONFIG_X86_32 |
853 | /* Stack for startup_32 can be just as for start_secondary onwards */ | 796 | /* Stack for startup_32 can be just as for start_secondary onwards */ |
854 | irq_ctx_init(cpu); | 797 | irq_ctx_init(cpu); |
855 | #else | 798 | #else |
856 | cpu_pda(cpu)->pcurrent = c_idle.idle; | ||
857 | clear_tsk_thread_flag(c_idle.idle, TIF_FORK); | 799 | clear_tsk_thread_flag(c_idle.idle, TIF_FORK); |
800 | initial_gs = per_cpu_offset(cpu); | ||
801 | per_cpu(kernel_stack, cpu) = | ||
802 | (unsigned long)task_stack_page(c_idle.idle) - | ||
803 | KERNEL_STACK_OFFSET + THREAD_SIZE; | ||
858 | #endif | 804 | #endif |
859 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); | 805 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); |
860 | initial_code = (unsigned long)start_secondary; | 806 | initial_code = (unsigned long)start_secondary; |
@@ -931,9 +877,7 @@ do_rest: | |||
931 | inquire_remote_apic(apicid); | 877 | inquire_remote_apic(apicid); |
932 | } | 878 | } |
933 | } | 879 | } |
934 | #ifdef CONFIG_X86_64 | 880 | |
935 | restore_state: | ||
936 | #endif | ||
937 | if (boot_error) { | 881 | if (boot_error) { |
938 | /* Try to put things back the way they were before ... */ | 882 | /* Try to put things back the way they were before ... */ |
939 | numa_remove_cpu(cpu); /* was set by numa_add_cpu */ | 883 | numa_remove_cpu(cpu); /* was set by numa_add_cpu */ |
@@ -1125,6 +1069,7 @@ static int __init smp_sanity_check(unsigned max_cpus) | |||
1125 | printk(KERN_ERR "... forcing use of dummy APIC emulation." | 1069 | printk(KERN_ERR "... forcing use of dummy APIC emulation." |
1126 | "(tell your hw vendor)\n"); | 1070 | "(tell your hw vendor)\n"); |
1127 | smpboot_clear_io_apic(); | 1071 | smpboot_clear_io_apic(); |
1072 | disable_ioapic_setup(); | ||
1128 | return -1; | 1073 | return -1; |
1129 | } | 1074 | } |
1130 | 1075 | ||
@@ -1240,9 +1185,6 @@ out: | |||
1240 | void __init native_smp_prepare_boot_cpu(void) | 1185 | void __init native_smp_prepare_boot_cpu(void) |
1241 | { | 1186 | { |
1242 | int me = smp_processor_id(); | 1187 | int me = smp_processor_id(); |
1243 | #ifdef CONFIG_X86_32 | ||
1244 | init_gdt(me); | ||
1245 | #endif | ||
1246 | switch_to_new_gdt(); | 1188 | switch_to_new_gdt(); |
1247 | /* already set me in cpu_online_mask in boot_cpu_init() */ | 1189 | /* already set me in cpu_online_mask in boot_cpu_init() */ |
1248 | cpumask_set_cpu(me, cpu_callout_mask); | 1190 | cpumask_set_cpu(me, cpu_callout_mask); |
diff --git a/arch/x86/kernel/smpcommon.c b/arch/x86/kernel/smpcommon.c deleted file mode 100644 index 397e309839dd..000000000000 --- a/arch/x86/kernel/smpcommon.c +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | /* | ||
2 | * SMP stuff which is common to all sub-architectures. | ||
3 | */ | ||
4 | #include <linux/module.h> | ||
5 | #include <asm/smp.h> | ||
6 | |||
7 | #ifdef CONFIG_X86_32 | ||
8 | DEFINE_PER_CPU(unsigned long, this_cpu_off); | ||
9 | EXPORT_PER_CPU_SYMBOL(this_cpu_off); | ||
10 | |||
11 | /* | ||
12 | * Initialize the CPU's GDT. This is either the boot CPU doing itself | ||
13 | * (still using the master per-cpu area), or a CPU doing it for a | ||
14 | * secondary which will soon come up. | ||
15 | */ | ||
16 | __cpuinit void init_gdt(int cpu) | ||
17 | { | ||
18 | struct desc_struct gdt; | ||
19 | |||
20 | pack_descriptor(&gdt, __per_cpu_offset[cpu], 0xFFFFF, | ||
21 | 0x2 | DESCTYPE_S, 0x8); | ||
22 | gdt.s = 1; | ||
23 | |||
24 | write_gdt_entry(get_cpu_gdt_table(cpu), | ||
25 | GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S); | ||
26 | |||
27 | per_cpu(this_cpu_off, cpu) = __per_cpu_offset[cpu]; | ||
28 | per_cpu(cpu_number, cpu) = cpu; | ||
29 | } | ||
30 | #endif | ||
diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S index d44395ff34c3..e2e86a08f31d 100644 --- a/arch/x86/kernel/syscall_table_32.S +++ b/arch/x86/kernel/syscall_table_32.S | |||
@@ -88,7 +88,7 @@ ENTRY(sys_call_table) | |||
88 | .long sys_uselib | 88 | .long sys_uselib |
89 | .long sys_swapon | 89 | .long sys_swapon |
90 | .long sys_reboot | 90 | .long sys_reboot |
91 | .long old_readdir | 91 | .long sys_old_readdir |
92 | .long old_mmap /* 90 */ | 92 | .long old_mmap /* 90 */ |
93 | .long sys_munmap | 93 | .long sys_munmap |
94 | .long sys_truncate | 94 | .long sys_truncate |
diff --git a/arch/x86/kernel/tlb_32.c b/arch/x86/kernel/tlb_32.c deleted file mode 100644 index ce5054642247..000000000000 --- a/arch/x86/kernel/tlb_32.c +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | #include <linux/spinlock.h> | ||
2 | #include <linux/cpu.h> | ||
3 | #include <linux/interrupt.h> | ||
4 | |||
5 | #include <asm/tlbflush.h> | ||
6 | |||
7 | DEFINE_PER_CPU(struct tlb_state, cpu_tlbstate) | ||
8 | ____cacheline_aligned = { &init_mm, 0, }; | ||
9 | |||
10 | /* must come after the send_IPI functions above for inlining */ | ||
11 | #include <mach_ipi.h> | ||
12 | |||
13 | /* | ||
14 | * Smarter SMP flushing macros. | ||
15 | * c/o Linus Torvalds. | ||
16 | * | ||
17 | * These mean you can really definitely utterly forget about | ||
18 | * writing to user space from interrupts. (Its not allowed anyway). | ||
19 | * | ||
20 | * Optimizations Manfred Spraul <manfred@colorfullife.com> | ||
21 | */ | ||
22 | |||
23 | static cpumask_t flush_cpumask; | ||
24 | static struct mm_struct *flush_mm; | ||
25 | static unsigned long flush_va; | ||
26 | static DEFINE_SPINLOCK(tlbstate_lock); | ||
27 | |||
28 | /* | ||
29 | * We cannot call mmdrop() because we are in interrupt context, | ||
30 | * instead update mm->cpu_vm_mask. | ||
31 | * | ||
32 | * We need to reload %cr3 since the page tables may be going | ||
33 | * away from under us.. | ||
34 | */ | ||
35 | void leave_mm(int cpu) | ||
36 | { | ||
37 | BUG_ON(x86_read_percpu(cpu_tlbstate.state) == TLBSTATE_OK); | ||
38 | cpu_clear(cpu, x86_read_percpu(cpu_tlbstate.active_mm)->cpu_vm_mask); | ||
39 | load_cr3(swapper_pg_dir); | ||
40 | } | ||
41 | EXPORT_SYMBOL_GPL(leave_mm); | ||
42 | |||
43 | /* | ||
44 | * | ||
45 | * The flush IPI assumes that a thread switch happens in this order: | ||
46 | * [cpu0: the cpu that switches] | ||
47 | * 1) switch_mm() either 1a) or 1b) | ||
48 | * 1a) thread switch to a different mm | ||
49 | * 1a1) cpu_clear(cpu, old_mm->cpu_vm_mask); | ||
50 | * Stop ipi delivery for the old mm. This is not synchronized with | ||
51 | * the other cpus, but smp_invalidate_interrupt ignore flush ipis | ||
52 | * for the wrong mm, and in the worst case we perform a superfluous | ||
53 | * tlb flush. | ||
54 | * 1a2) set cpu_tlbstate to TLBSTATE_OK | ||
55 | * Now the smp_invalidate_interrupt won't call leave_mm if cpu0 | ||
56 | * was in lazy tlb mode. | ||
57 | * 1a3) update cpu_tlbstate[].active_mm | ||
58 | * Now cpu0 accepts tlb flushes for the new mm. | ||
59 | * 1a4) cpu_set(cpu, new_mm->cpu_vm_mask); | ||
60 | * Now the other cpus will send tlb flush ipis. | ||
61 | * 1a4) change cr3. | ||
62 | * 1b) thread switch without mm change | ||
63 | * cpu_tlbstate[].active_mm is correct, cpu0 already handles | ||
64 | * flush ipis. | ||
65 | * 1b1) set cpu_tlbstate to TLBSTATE_OK | ||
66 | * 1b2) test_and_set the cpu bit in cpu_vm_mask. | ||
67 | * Atomically set the bit [other cpus will start sending flush ipis], | ||
68 | * and test the bit. | ||
69 | * 1b3) if the bit was 0: leave_mm was called, flush the tlb. | ||
70 | * 2) switch %%esp, ie current | ||
71 | * | ||
72 | * The interrupt must handle 2 special cases: | ||
73 | * - cr3 is changed before %%esp, ie. it cannot use current->{active_,}mm. | ||
74 | * - the cpu performs speculative tlb reads, i.e. even if the cpu only | ||
75 | * runs in kernel space, the cpu could load tlb entries for user space | ||
76 | * pages. | ||
77 | * | ||
78 | * The good news is that cpu_tlbstate is local to each cpu, no | ||
79 | * write/read ordering problems. | ||
80 | */ | ||
81 | |||
82 | /* | ||
83 | * TLB flush IPI: | ||
84 | * | ||
85 | * 1) Flush the tlb entries if the cpu uses the mm that's being flushed. | ||
86 | * 2) Leave the mm if we are in the lazy tlb mode. | ||
87 | */ | ||
88 | |||
89 | void smp_invalidate_interrupt(struct pt_regs *regs) | ||
90 | { | ||
91 | unsigned long cpu; | ||
92 | |||
93 | cpu = get_cpu(); | ||
94 | |||
95 | if (!cpu_isset(cpu, flush_cpumask)) | ||
96 | goto out; | ||
97 | /* | ||
98 | * This was a BUG() but until someone can quote me the | ||
99 | * line from the intel manual that guarantees an IPI to | ||
100 | * multiple CPUs is retried _only_ on the erroring CPUs | ||
101 | * its staying as a return | ||
102 | * | ||
103 | * BUG(); | ||
104 | */ | ||
105 | |||
106 | if (flush_mm == x86_read_percpu(cpu_tlbstate.active_mm)) { | ||
107 | if (x86_read_percpu(cpu_tlbstate.state) == TLBSTATE_OK) { | ||
108 | if (flush_va == TLB_FLUSH_ALL) | ||
109 | local_flush_tlb(); | ||
110 | else | ||
111 | __flush_tlb_one(flush_va); | ||
112 | } else | ||
113 | leave_mm(cpu); | ||
114 | } | ||
115 | ack_APIC_irq(); | ||
116 | smp_mb__before_clear_bit(); | ||
117 | cpu_clear(cpu, flush_cpumask); | ||
118 | smp_mb__after_clear_bit(); | ||
119 | out: | ||
120 | put_cpu_no_resched(); | ||
121 | inc_irq_stat(irq_tlb_count); | ||
122 | } | ||
123 | |||
124 | void native_flush_tlb_others(const cpumask_t *cpumaskp, struct mm_struct *mm, | ||
125 | unsigned long va) | ||
126 | { | ||
127 | cpumask_t cpumask = *cpumaskp; | ||
128 | |||
129 | /* | ||
130 | * A couple of (to be removed) sanity checks: | ||
131 | * | ||
132 | * - current CPU must not be in mask | ||
133 | * - mask must exist :) | ||
134 | */ | ||
135 | BUG_ON(cpus_empty(cpumask)); | ||
136 | BUG_ON(cpu_isset(smp_processor_id(), cpumask)); | ||
137 | BUG_ON(!mm); | ||
138 | |||
139 | #ifdef CONFIG_HOTPLUG_CPU | ||
140 | /* If a CPU which we ran on has gone down, OK. */ | ||
141 | cpus_and(cpumask, cpumask, cpu_online_map); | ||
142 | if (unlikely(cpus_empty(cpumask))) | ||
143 | return; | ||
144 | #endif | ||
145 | |||
146 | /* | ||
147 | * i'm not happy about this global shared spinlock in the | ||
148 | * MM hot path, but we'll see how contended it is. | ||
149 | * AK: x86-64 has a faster method that could be ported. | ||
150 | */ | ||
151 | spin_lock(&tlbstate_lock); | ||
152 | |||
153 | flush_mm = mm; | ||
154 | flush_va = va; | ||
155 | cpus_or(flush_cpumask, cpumask, flush_cpumask); | ||
156 | |||
157 | /* | ||
158 | * Make the above memory operations globally visible before | ||
159 | * sending the IPI. | ||
160 | */ | ||
161 | smp_mb(); | ||
162 | /* | ||
163 | * We have to send the IPI only to | ||
164 | * CPUs affected. | ||
165 | */ | ||
166 | send_IPI_mask(&cpumask, INVALIDATE_TLB_VECTOR); | ||
167 | |||
168 | while (!cpus_empty(flush_cpumask)) | ||
169 | /* nothing. lockup detection does not belong here */ | ||
170 | cpu_relax(); | ||
171 | |||
172 | flush_mm = NULL; | ||
173 | flush_va = 0; | ||
174 | spin_unlock(&tlbstate_lock); | ||
175 | } | ||
176 | |||
177 | void flush_tlb_current_task(void) | ||
178 | { | ||
179 | struct mm_struct *mm = current->mm; | ||
180 | cpumask_t cpu_mask; | ||
181 | |||
182 | preempt_disable(); | ||
183 | cpu_mask = mm->cpu_vm_mask; | ||
184 | cpu_clear(smp_processor_id(), cpu_mask); | ||
185 | |||
186 | local_flush_tlb(); | ||
187 | if (!cpus_empty(cpu_mask)) | ||
188 | flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL); | ||
189 | preempt_enable(); | ||
190 | } | ||
191 | |||
192 | void flush_tlb_mm(struct mm_struct *mm) | ||
193 | { | ||
194 | cpumask_t cpu_mask; | ||
195 | |||
196 | preempt_disable(); | ||
197 | cpu_mask = mm->cpu_vm_mask; | ||
198 | cpu_clear(smp_processor_id(), cpu_mask); | ||
199 | |||
200 | if (current->active_mm == mm) { | ||
201 | if (current->mm) | ||
202 | local_flush_tlb(); | ||
203 | else | ||
204 | leave_mm(smp_processor_id()); | ||
205 | } | ||
206 | if (!cpus_empty(cpu_mask)) | ||
207 | flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL); | ||
208 | |||
209 | preempt_enable(); | ||
210 | } | ||
211 | |||
212 | void flush_tlb_page(struct vm_area_struct *vma, unsigned long va) | ||
213 | { | ||
214 | struct mm_struct *mm = vma->vm_mm; | ||
215 | cpumask_t cpu_mask; | ||
216 | |||
217 | preempt_disable(); | ||
218 | cpu_mask = mm->cpu_vm_mask; | ||
219 | cpu_clear(smp_processor_id(), cpu_mask); | ||
220 | |||
221 | if (current->active_mm == mm) { | ||
222 | if (current->mm) | ||
223 | __flush_tlb_one(va); | ||
224 | else | ||
225 | leave_mm(smp_processor_id()); | ||
226 | } | ||
227 | |||
228 | if (!cpus_empty(cpu_mask)) | ||
229 | flush_tlb_others(cpu_mask, mm, va); | ||
230 | |||
231 | preempt_enable(); | ||
232 | } | ||
233 | EXPORT_SYMBOL(flush_tlb_page); | ||
234 | |||
235 | static void do_flush_tlb_all(void *info) | ||
236 | { | ||
237 | unsigned long cpu = smp_processor_id(); | ||
238 | |||
239 | __flush_tlb_all(); | ||
240 | if (x86_read_percpu(cpu_tlbstate.state) == TLBSTATE_LAZY) | ||
241 | leave_mm(cpu); | ||
242 | } | ||
243 | |||
244 | void flush_tlb_all(void) | ||
245 | { | ||
246 | on_each_cpu(do_flush_tlb_all, NULL, 1); | ||
247 | } | ||
248 | |||
249 | void reset_lazy_tlbstate(void) | ||
250 | { | ||
251 | int cpu = raw_smp_processor_id(); | ||
252 | |||
253 | per_cpu(cpu_tlbstate, cpu).state = 0; | ||
254 | per_cpu(cpu_tlbstate, cpu).active_mm = &init_mm; | ||
255 | } | ||
256 | |||
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c index f885023167e0..89fce1b6d01f 100644 --- a/arch/x86/kernel/tlb_uv.c +++ b/arch/x86/kernel/tlb_uv.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | 12 | ||
13 | #include <asm/mmu_context.h> | 13 | #include <asm/mmu_context.h> |
14 | #include <asm/uv/uv.h> | ||
14 | #include <asm/uv/uv_mmrs.h> | 15 | #include <asm/uv/uv_mmrs.h> |
15 | #include <asm/uv/uv_hub.h> | 16 | #include <asm/uv/uv_hub.h> |
16 | #include <asm/uv/uv_bau.h> | 17 | #include <asm/uv/uv_bau.h> |
@@ -200,6 +201,7 @@ static int uv_wait_completion(struct bau_desc *bau_desc, | |||
200 | destination_timeouts = 0; | 201 | destination_timeouts = 0; |
201 | } | 202 | } |
202 | } | 203 | } |
204 | cpu_relax(); | ||
203 | } | 205 | } |
204 | return FLUSH_COMPLETE; | 206 | return FLUSH_COMPLETE; |
205 | } | 207 | } |
@@ -209,14 +211,15 @@ static int uv_wait_completion(struct bau_desc *bau_desc, | |||
209 | * | 211 | * |
210 | * Send a broadcast and wait for a broadcast message to complete. | 212 | * Send a broadcast and wait for a broadcast message to complete. |
211 | * | 213 | * |
212 | * The cpumaskp mask contains the cpus the broadcast was sent to. | 214 | * The flush_mask contains the cpus the broadcast was sent to. |
213 | * | 215 | * |
214 | * Returns 1 if all remote flushing was done. The mask is zeroed. | 216 | * Returns NULL if all remote flushing was done. The mask is zeroed. |
215 | * Returns 0 if some remote flushing remains to be done. The mask is left | 217 | * Returns @flush_mask if some remote flushing remains to be done. The |
216 | * unchanged. | 218 | * mask will have some bits still set. |
217 | */ | 219 | */ |
218 | int uv_flush_send_and_wait(int cpu, int this_blade, struct bau_desc *bau_desc, | 220 | const struct cpumask *uv_flush_send_and_wait(int cpu, int this_blade, |
219 | cpumask_t *cpumaskp) | 221 | struct bau_desc *bau_desc, |
222 | struct cpumask *flush_mask) | ||
220 | { | 223 | { |
221 | int completion_status = 0; | 224 | int completion_status = 0; |
222 | int right_shift; | 225 | int right_shift; |
@@ -263,59 +266,69 @@ int uv_flush_send_and_wait(int cpu, int this_blade, struct bau_desc *bau_desc, | |||
263 | * Success, so clear the remote cpu's from the mask so we don't | 266 | * Success, so clear the remote cpu's from the mask so we don't |
264 | * use the IPI method of shootdown on them. | 267 | * use the IPI method of shootdown on them. |
265 | */ | 268 | */ |
266 | for_each_cpu_mask(bit, *cpumaskp) { | 269 | for_each_cpu(bit, flush_mask) { |
267 | blade = uv_cpu_to_blade_id(bit); | 270 | blade = uv_cpu_to_blade_id(bit); |
268 | if (blade == this_blade) | 271 | if (blade == this_blade) |
269 | continue; | 272 | continue; |
270 | cpu_clear(bit, *cpumaskp); | 273 | cpumask_clear_cpu(bit, flush_mask); |
271 | } | 274 | } |
272 | if (!cpus_empty(*cpumaskp)) | 275 | if (!cpumask_empty(flush_mask)) |
273 | return 0; | 276 | return flush_mask; |
274 | return 1; | 277 | return NULL; |
275 | } | 278 | } |
276 | 279 | ||
277 | /** | 280 | /** |
278 | * uv_flush_tlb_others - globally purge translation cache of a virtual | 281 | * uv_flush_tlb_others - globally purge translation cache of a virtual |
279 | * address or all TLB's | 282 | * address or all TLB's |
280 | * @cpumaskp: mask of all cpu's in which the address is to be removed | 283 | * @cpumask: mask of all cpu's in which the address is to be removed |
281 | * @mm: mm_struct containing virtual address range | 284 | * @mm: mm_struct containing virtual address range |
282 | * @va: virtual address to be removed (or TLB_FLUSH_ALL for all TLB's on cpu) | 285 | * @va: virtual address to be removed (or TLB_FLUSH_ALL for all TLB's on cpu) |
286 | * @cpu: the current cpu | ||
283 | * | 287 | * |
284 | * This is the entry point for initiating any UV global TLB shootdown. | 288 | * This is the entry point for initiating any UV global TLB shootdown. |
285 | * | 289 | * |
286 | * Purges the translation caches of all specified processors of the given | 290 | * Purges the translation caches of all specified processors of the given |
287 | * virtual address, or purges all TLB's on specified processors. | 291 | * virtual address, or purges all TLB's on specified processors. |
288 | * | 292 | * |
289 | * The caller has derived the cpumaskp from the mm_struct and has subtracted | 293 | * The caller has derived the cpumask from the mm_struct. This function |
290 | * the local cpu from the mask. This function is called only if there | 294 | * is called only if there are bits set in the mask. (e.g. flush_tlb_page()) |
291 | * are bits set in the mask. (e.g. flush_tlb_page()) | ||
292 | * | 295 | * |
293 | * The cpumaskp is converted into a nodemask of the nodes containing | 296 | * The cpumask is converted into a nodemask of the nodes containing |
294 | * the cpus. | 297 | * the cpus. |
295 | * | 298 | * |
296 | * Returns 1 if all remote flushing was done. | 299 | * Note that this function should be called with preemption disabled. |
297 | * Returns 0 if some remote flushing remains to be done. | 300 | * |
301 | * Returns NULL if all remote flushing was done. | ||
302 | * Returns pointer to cpumask if some remote flushing remains to be | ||
303 | * done. The returned pointer is valid till preemption is re-enabled. | ||
298 | */ | 304 | */ |
299 | int uv_flush_tlb_others(cpumask_t *cpumaskp, struct mm_struct *mm, | 305 | const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, |
300 | unsigned long va) | 306 | struct mm_struct *mm, |
307 | unsigned long va, unsigned int cpu) | ||
301 | { | 308 | { |
309 | static DEFINE_PER_CPU(cpumask_t, flush_tlb_mask); | ||
310 | struct cpumask *flush_mask = &__get_cpu_var(flush_tlb_mask); | ||
302 | int i; | 311 | int i; |
303 | int bit; | 312 | int bit; |
304 | int blade; | 313 | int blade; |
305 | int cpu; | 314 | int uv_cpu; |
306 | int this_blade; | 315 | int this_blade; |
307 | int locals = 0; | 316 | int locals = 0; |
308 | struct bau_desc *bau_desc; | 317 | struct bau_desc *bau_desc; |
309 | 318 | ||
310 | cpu = uv_blade_processor_id(); | 319 | WARN_ON(!in_atomic()); |
320 | |||
321 | cpumask_andnot(flush_mask, cpumask, cpumask_of(cpu)); | ||
322 | |||
323 | uv_cpu = uv_blade_processor_id(); | ||
311 | this_blade = uv_numa_blade_id(); | 324 | this_blade = uv_numa_blade_id(); |
312 | bau_desc = __get_cpu_var(bau_control).descriptor_base; | 325 | bau_desc = __get_cpu_var(bau_control).descriptor_base; |
313 | bau_desc += UV_ITEMS_PER_DESCRIPTOR * cpu; | 326 | bau_desc += UV_ITEMS_PER_DESCRIPTOR * uv_cpu; |
314 | 327 | ||
315 | bau_nodes_clear(&bau_desc->distribution, UV_DISTRIBUTION_SIZE); | 328 | bau_nodes_clear(&bau_desc->distribution, UV_DISTRIBUTION_SIZE); |
316 | 329 | ||
317 | i = 0; | 330 | i = 0; |
318 | for_each_cpu_mask(bit, *cpumaskp) { | 331 | for_each_cpu(bit, flush_mask) { |
319 | blade = uv_cpu_to_blade_id(bit); | 332 | blade = uv_cpu_to_blade_id(bit); |
320 | BUG_ON(blade > (UV_DISTRIBUTION_SIZE - 1)); | 333 | BUG_ON(blade > (UV_DISTRIBUTION_SIZE - 1)); |
321 | if (blade == this_blade) { | 334 | if (blade == this_blade) { |
@@ -330,17 +343,17 @@ int uv_flush_tlb_others(cpumask_t *cpumaskp, struct mm_struct *mm, | |||
330 | * no off_node flushing; return status for local node | 343 | * no off_node flushing; return status for local node |
331 | */ | 344 | */ |
332 | if (locals) | 345 | if (locals) |
333 | return 0; | 346 | return flush_mask; |
334 | else | 347 | else |
335 | return 1; | 348 | return NULL; |
336 | } | 349 | } |
337 | __get_cpu_var(ptcstats).requestor++; | 350 | __get_cpu_var(ptcstats).requestor++; |
338 | __get_cpu_var(ptcstats).ntargeted += i; | 351 | __get_cpu_var(ptcstats).ntargeted += i; |
339 | 352 | ||
340 | bau_desc->payload.address = va; | 353 | bau_desc->payload.address = va; |
341 | bau_desc->payload.sending_cpu = smp_processor_id(); | 354 | bau_desc->payload.sending_cpu = cpu; |
342 | 355 | ||
343 | return uv_flush_send_and_wait(cpu, this_blade, bau_desc, cpumaskp); | 356 | return uv_flush_send_and_wait(uv_cpu, this_blade, bau_desc, flush_mask); |
344 | } | 357 | } |
345 | 358 | ||
346 | /* | 359 | /* |
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 98c2d055284b..ed5aee5f3fcc 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #ifdef CONFIG_X86_64 | 59 | #ifdef CONFIG_X86_64 |
60 | #include <asm/pgalloc.h> | 60 | #include <asm/pgalloc.h> |
61 | #include <asm/proto.h> | 61 | #include <asm/proto.h> |
62 | #include <asm/pda.h> | ||
63 | #else | 62 | #else |
64 | #include <asm/processor-flags.h> | 63 | #include <asm/processor-flags.h> |
65 | #include <asm/arch_hooks.h> | 64 | #include <asm/arch_hooks.h> |
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c index 23206ba16874..1d3302cc2ddf 100644 --- a/arch/x86/kernel/vmi_32.c +++ b/arch/x86/kernel/vmi_32.c | |||
@@ -858,7 +858,7 @@ void __init vmi_init(void) | |||
858 | #endif | 858 | #endif |
859 | } | 859 | } |
860 | 860 | ||
861 | void vmi_activate(void) | 861 | void __init vmi_activate(void) |
862 | { | 862 | { |
863 | unsigned long flags; | 863 | unsigned long flags; |
864 | 864 | ||
diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S index 82c67559dde7..3eba7f7bac05 100644 --- a/arch/x86/kernel/vmlinux_32.lds.S +++ b/arch/x86/kernel/vmlinux_32.lds.S | |||
@@ -178,14 +178,7 @@ SECTIONS | |||
178 | __initramfs_end = .; | 178 | __initramfs_end = .; |
179 | } | 179 | } |
180 | #endif | 180 | #endif |
181 | . = ALIGN(PAGE_SIZE); | 181 | PERCPU(PAGE_SIZE) |
182 | .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { | ||
183 | __per_cpu_start = .; | ||
184 | *(.data.percpu.page_aligned) | ||
185 | *(.data.percpu) | ||
186 | *(.data.percpu.shared_aligned) | ||
187 | __per_cpu_end = .; | ||
188 | } | ||
189 | . = ALIGN(PAGE_SIZE); | 182 | . = ALIGN(PAGE_SIZE); |
190 | /* freed after init ends here */ | 183 | /* freed after init ends here */ |
191 | 184 | ||
diff --git a/arch/x86/kernel/vmlinux_64.lds.S b/arch/x86/kernel/vmlinux_64.lds.S index 1a614c0e6bef..c9740996430a 100644 --- a/arch/x86/kernel/vmlinux_64.lds.S +++ b/arch/x86/kernel/vmlinux_64.lds.S | |||
@@ -5,6 +5,7 @@ | |||
5 | #define LOAD_OFFSET __START_KERNEL_map | 5 | #define LOAD_OFFSET __START_KERNEL_map |
6 | 6 | ||
7 | #include <asm-generic/vmlinux.lds.h> | 7 | #include <asm-generic/vmlinux.lds.h> |
8 | #include <asm/asm-offsets.h> | ||
8 | #include <asm/page.h> | 9 | #include <asm/page.h> |
9 | 10 | ||
10 | #undef i386 /* in case the preprocessor is a 32bit one */ | 11 | #undef i386 /* in case the preprocessor is a 32bit one */ |
@@ -13,12 +14,14 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") | |||
13 | OUTPUT_ARCH(i386:x86-64) | 14 | OUTPUT_ARCH(i386:x86-64) |
14 | ENTRY(phys_startup_64) | 15 | ENTRY(phys_startup_64) |
15 | jiffies_64 = jiffies; | 16 | jiffies_64 = jiffies; |
16 | _proxy_pda = 1; | ||
17 | PHDRS { | 17 | PHDRS { |
18 | text PT_LOAD FLAGS(5); /* R_E */ | 18 | text PT_LOAD FLAGS(5); /* R_E */ |
19 | data PT_LOAD FLAGS(7); /* RWE */ | 19 | data PT_LOAD FLAGS(7); /* RWE */ |
20 | user PT_LOAD FLAGS(7); /* RWE */ | 20 | user PT_LOAD FLAGS(7); /* RWE */ |
21 | data.init PT_LOAD FLAGS(7); /* RWE */ | 21 | data.init PT_LOAD FLAGS(7); /* RWE */ |
22 | #ifdef CONFIG_SMP | ||
23 | percpu PT_LOAD FLAGS(7); /* RWE */ | ||
24 | #endif | ||
22 | note PT_NOTE FLAGS(0); /* ___ */ | 25 | note PT_NOTE FLAGS(0); /* ___ */ |
23 | } | 26 | } |
24 | SECTIONS | 27 | SECTIONS |
@@ -208,14 +211,28 @@ SECTIONS | |||
208 | __initramfs_end = .; | 211 | __initramfs_end = .; |
209 | #endif | 212 | #endif |
210 | 213 | ||
214 | #ifdef CONFIG_SMP | ||
215 | /* | ||
216 | * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the | ||
217 | * output PHDR, so the next output section - __data_nosave - should | ||
218 | * switch it back to data.init. Also, pda should be at the head of | ||
219 | * percpu area. Preallocate it and define the percpu offset symbol | ||
220 | * so that it can be accessed as a percpu variable. | ||
221 | */ | ||
222 | . = ALIGN(PAGE_SIZE); | ||
223 | PERCPU_VADDR(0, :percpu) | ||
224 | #else | ||
211 | PERCPU(PAGE_SIZE) | 225 | PERCPU(PAGE_SIZE) |
226 | #endif | ||
212 | 227 | ||
213 | . = ALIGN(PAGE_SIZE); | 228 | . = ALIGN(PAGE_SIZE); |
214 | __init_end = .; | 229 | __init_end = .; |
215 | 230 | ||
216 | . = ALIGN(PAGE_SIZE); | 231 | . = ALIGN(PAGE_SIZE); |
217 | __nosave_begin = .; | 232 | __nosave_begin = .; |
218 | .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) } | 233 | .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { |
234 | *(.data.nosave) | ||
235 | } :data.init /* switch back to data.init, see PERCPU_VADDR() above */ | ||
219 | . = ALIGN(PAGE_SIZE); | 236 | . = ALIGN(PAGE_SIZE); |
220 | __nosave_end = .; | 237 | __nosave_end = .; |
221 | 238 | ||
@@ -244,3 +261,8 @@ SECTIONS | |||
244 | */ | 261 | */ |
245 | ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), | 262 | ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), |
246 | "kernel image bigger than KERNEL_IMAGE_SIZE") | 263 | "kernel image bigger than KERNEL_IMAGE_SIZE") |
264 | |||
265 | #ifdef CONFIG_SMP | ||
266 | ASSERT((per_cpu__irq_stack_union == 0), | ||
267 | "irq_stack_union is not at start of per-cpu area"); | ||
268 | #endif | ||
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c index 695e426aa354..3909e3ba5ce3 100644 --- a/arch/x86/kernel/x8664_ksyms_64.c +++ b/arch/x86/kernel/x8664_ksyms_64.c | |||
@@ -58,5 +58,3 @@ EXPORT_SYMBOL(__memcpy); | |||
58 | EXPORT_SYMBOL(empty_zero_page); | 58 | EXPORT_SYMBOL(empty_zero_page); |
59 | EXPORT_SYMBOL(init_level4_pgt); | 59 | EXPORT_SYMBOL(init_level4_pgt); |
60 | EXPORT_SYMBOL(load_gs_index); | 60 | EXPORT_SYMBOL(load_gs_index); |
61 | |||
62 | EXPORT_SYMBOL(_proxy_pda); | ||
diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c index 4a20b2f9a381..7c8ca91bb9ec 100644 --- a/arch/x86/lib/usercopy_32.c +++ b/arch/x86/lib/usercopy_32.c | |||
@@ -56,7 +56,7 @@ do { \ | |||
56 | " jmp 2b\n" \ | 56 | " jmp 2b\n" \ |
57 | ".previous\n" \ | 57 | ".previous\n" \ |
58 | _ASM_EXTABLE(0b,3b) \ | 58 | _ASM_EXTABLE(0b,3b) \ |
59 | : "=d"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1), \ | 59 | : "=&d"(res), "=&c"(count), "=&a" (__d0), "=&S" (__d1), \ |
60 | "=&D" (__d2) \ | 60 | "=&D" (__d2) \ |
61 | : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ | 61 | : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ |
62 | : "memory"); \ | 62 | : "memory"); \ |
@@ -218,7 +218,7 @@ long strnlen_user(const char __user *s, long n) | |||
218 | " .align 4\n" | 218 | " .align 4\n" |
219 | " .long 0b,2b\n" | 219 | " .long 0b,2b\n" |
220 | ".previous" | 220 | ".previous" |
221 | :"=r" (n), "=D" (s), "=a" (res), "=c" (tmp) | 221 | :"=&r" (n), "=&D" (s), "=&a" (res), "=&c" (tmp) |
222 | :"0" (n), "1" (s), "2" (0), "3" (mask) | 222 | :"0" (n), "1" (s), "2" (0), "3" (mask) |
223 | :"cc"); | 223 | :"cc"); |
224 | return res & mask; | 224 | return res & mask; |
diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c index 64d6c84e6353..ec13cb5f17ed 100644 --- a/arch/x86/lib/usercopy_64.c +++ b/arch/x86/lib/usercopy_64.c | |||
@@ -32,7 +32,7 @@ do { \ | |||
32 | " jmp 2b\n" \ | 32 | " jmp 2b\n" \ |
33 | ".previous\n" \ | 33 | ".previous\n" \ |
34 | _ASM_EXTABLE(0b,3b) \ | 34 | _ASM_EXTABLE(0b,3b) \ |
35 | : "=r"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1), \ | 35 | : "=&r"(res), "=&c"(count), "=&a" (__d0), "=&S" (__d1), \ |
36 | "=&D" (__d2) \ | 36 | "=&D" (__d2) \ |
37 | : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ | 37 | : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ |
38 | : "memory"); \ | 38 | : "memory"); \ |
@@ -86,7 +86,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size) | |||
86 | ".previous\n" | 86 | ".previous\n" |
87 | _ASM_EXTABLE(0b,3b) | 87 | _ASM_EXTABLE(0b,3b) |
88 | _ASM_EXTABLE(1b,2b) | 88 | _ASM_EXTABLE(1b,2b) |
89 | : [size8] "=c"(size), [dst] "=&D" (__d0) | 89 | : [size8] "=&c"(size), [dst] "=&D" (__d0) |
90 | : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr), | 90 | : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr), |
91 | [zero] "r" (0UL), [eight] "r" (8UL)); | 91 | [zero] "r" (0UL), [eight] "r" (8UL)); |
92 | return size; | 92 | return size; |
diff --git a/arch/x86/mach-rdc321x/Makefile b/arch/x86/mach-rdc321x/Makefile deleted file mode 100644 index 8325b4ca431c..000000000000 --- a/arch/x86/mach-rdc321x/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for the RDC321x specific parts of the kernel | ||
3 | # | ||
4 | obj-$(CONFIG_X86_RDC321X) := gpio.o platform.o | ||
5 | |||
diff --git a/arch/x86/mach-rdc321x/gpio.c b/arch/x86/mach-rdc321x/gpio.c deleted file mode 100644 index 247f33d3a407..000000000000 --- a/arch/x86/mach-rdc321x/gpio.c +++ /dev/null | |||
@@ -1,194 +0,0 @@ | |||
1 | /* | ||
2 | * GPIO support for RDC SoC R3210/R8610 | ||
3 | * | ||
4 | * Copyright (C) 2007, Florian Fainelli <florian@openwrt.org> | ||
5 | * Copyright (C) 2008, Volker Weiss <dev@tintuc.de> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | |||
24 | #include <linux/spinlock.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/module.h> | ||
28 | |||
29 | #include <asm/gpio.h> | ||
30 | #include <asm/mach-rdc321x/rdc321x_defs.h> | ||
31 | |||
32 | |||
33 | /* spin lock to protect our private copy of GPIO data register plus | ||
34 | the access to PCI conf registers. */ | ||
35 | static DEFINE_SPINLOCK(gpio_lock); | ||
36 | |||
37 | /* copy of GPIO data registers */ | ||
38 | static u32 gpio_data_reg1; | ||
39 | static u32 gpio_data_reg2; | ||
40 | |||
41 | static u32 gpio_request_data[2]; | ||
42 | |||
43 | |||
44 | static inline void rdc321x_conf_write(unsigned addr, u32 value) | ||
45 | { | ||
46 | outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR); | ||
47 | outl(value, RDC3210_CFGREG_DATA); | ||
48 | } | ||
49 | |||
50 | static inline void rdc321x_conf_or(unsigned addr, u32 value) | ||
51 | { | ||
52 | outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR); | ||
53 | value |= inl(RDC3210_CFGREG_DATA); | ||
54 | outl(value, RDC3210_CFGREG_DATA); | ||
55 | } | ||
56 | |||
57 | static inline u32 rdc321x_conf_read(unsigned addr) | ||
58 | { | ||
59 | outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR); | ||
60 | |||
61 | return inl(RDC3210_CFGREG_DATA); | ||
62 | } | ||
63 | |||
64 | /* configure pin as GPIO */ | ||
65 | static void rdc321x_configure_gpio(unsigned gpio) | ||
66 | { | ||
67 | unsigned long flags; | ||
68 | |||
69 | spin_lock_irqsave(&gpio_lock, flags); | ||
70 | rdc321x_conf_or(gpio < 32 | ||
71 | ? RDC321X_GPIO_CTRL_REG1 : RDC321X_GPIO_CTRL_REG2, | ||
72 | 1 << (gpio & 0x1f)); | ||
73 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
74 | } | ||
75 | |||
76 | /* initially setup the 2 copies of the gpio data registers. | ||
77 | This function must be called by the platform setup code. */ | ||
78 | void __init rdc321x_gpio_setup() | ||
79 | { | ||
80 | /* this might not be, what others (BIOS, bootloader, etc.) | ||
81 | wrote to these registers before, but it's a good guess. Still | ||
82 | better than just using 0xffffffff. */ | ||
83 | |||
84 | gpio_data_reg1 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG1); | ||
85 | gpio_data_reg2 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG2); | ||
86 | } | ||
87 | |||
88 | /* determine, if gpio number is valid */ | ||
89 | static inline int rdc321x_is_gpio(unsigned gpio) | ||
90 | { | ||
91 | return gpio <= RDC321X_MAX_GPIO; | ||
92 | } | ||
93 | |||
94 | /* request GPIO */ | ||
95 | int rdc_gpio_request(unsigned gpio, const char *label) | ||
96 | { | ||
97 | unsigned long flags; | ||
98 | |||
99 | if (!rdc321x_is_gpio(gpio)) | ||
100 | return -EINVAL; | ||
101 | |||
102 | spin_lock_irqsave(&gpio_lock, flags); | ||
103 | if (gpio_request_data[(gpio & 0x20) ? 1 : 0] & (1 << (gpio & 0x1f))) | ||
104 | goto inuse; | ||
105 | gpio_request_data[(gpio & 0x20) ? 1 : 0] |= (1 << (gpio & 0x1f)); | ||
106 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
107 | |||
108 | return 0; | ||
109 | inuse: | ||
110 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
111 | return -EINVAL; | ||
112 | } | ||
113 | EXPORT_SYMBOL(rdc_gpio_request); | ||
114 | |||
115 | /* release previously-claimed GPIO */ | ||
116 | void rdc_gpio_free(unsigned gpio) | ||
117 | { | ||
118 | unsigned long flags; | ||
119 | |||
120 | if (!rdc321x_is_gpio(gpio)) | ||
121 | return; | ||
122 | |||
123 | spin_lock_irqsave(&gpio_lock, flags); | ||
124 | gpio_request_data[(gpio & 0x20) ? 1 : 0] &= ~(1 << (gpio & 0x1f)); | ||
125 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
126 | } | ||
127 | EXPORT_SYMBOL(rdc_gpio_free); | ||
128 | |||
129 | /* read GPIO pin */ | ||
130 | int rdc_gpio_get_value(unsigned gpio) | ||
131 | { | ||
132 | u32 reg; | ||
133 | unsigned long flags; | ||
134 | |||
135 | spin_lock_irqsave(&gpio_lock, flags); | ||
136 | reg = rdc321x_conf_read(gpio < 32 | ||
137 | ? RDC321X_GPIO_DATA_REG1 : RDC321X_GPIO_DATA_REG2); | ||
138 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
139 | |||
140 | return (1 << (gpio & 0x1f)) & reg ? 1 : 0; | ||
141 | } | ||
142 | EXPORT_SYMBOL(rdc_gpio_get_value); | ||
143 | |||
144 | /* set GPIO pin to value */ | ||
145 | void rdc_gpio_set_value(unsigned gpio, int value) | ||
146 | { | ||
147 | unsigned long flags; | ||
148 | u32 reg; | ||
149 | |||
150 | reg = 1 << (gpio & 0x1f); | ||
151 | if (gpio < 32) { | ||
152 | spin_lock_irqsave(&gpio_lock, flags); | ||
153 | if (value) | ||
154 | gpio_data_reg1 |= reg; | ||
155 | else | ||
156 | gpio_data_reg1 &= ~reg; | ||
157 | rdc321x_conf_write(RDC321X_GPIO_DATA_REG1, gpio_data_reg1); | ||
158 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
159 | } else { | ||
160 | spin_lock_irqsave(&gpio_lock, flags); | ||
161 | if (value) | ||
162 | gpio_data_reg2 |= reg; | ||
163 | else | ||
164 | gpio_data_reg2 &= ~reg; | ||
165 | rdc321x_conf_write(RDC321X_GPIO_DATA_REG2, gpio_data_reg2); | ||
166 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
167 | } | ||
168 | } | ||
169 | EXPORT_SYMBOL(rdc_gpio_set_value); | ||
170 | |||
171 | /* configure GPIO pin as input */ | ||
172 | int rdc_gpio_direction_input(unsigned gpio) | ||
173 | { | ||
174 | if (!rdc321x_is_gpio(gpio)) | ||
175 | return -EINVAL; | ||
176 | |||
177 | rdc321x_configure_gpio(gpio); | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | EXPORT_SYMBOL(rdc_gpio_direction_input); | ||
182 | |||
183 | /* configure GPIO pin as output and set value */ | ||
184 | int rdc_gpio_direction_output(unsigned gpio, int value) | ||
185 | { | ||
186 | if (!rdc321x_is_gpio(gpio)) | ||
187 | return -EINVAL; | ||
188 | |||
189 | gpio_set_value(gpio, value); | ||
190 | rdc321x_configure_gpio(gpio); | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | EXPORT_SYMBOL(rdc_gpio_direction_output); | ||
diff --git a/arch/x86/mach-rdc321x/platform.c b/arch/x86/mach-rdc321x/platform.c deleted file mode 100644 index 4f4e50c3ad3b..000000000000 --- a/arch/x86/mach-rdc321x/platform.c +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* | ||
2 | * Generic RDC321x platform devices | ||
3 | * | ||
4 | * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the | ||
18 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | * Boston, MA 02110-1301, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/list.h> | ||
26 | #include <linux/device.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/leds.h> | ||
29 | |||
30 | #include <asm/gpio.h> | ||
31 | |||
32 | /* LEDS */ | ||
33 | static struct gpio_led default_leds[] = { | ||
34 | { .name = "rdc:dmz", .gpio = 1, }, | ||
35 | }; | ||
36 | |||
37 | static struct gpio_led_platform_data rdc321x_led_data = { | ||
38 | .num_leds = ARRAY_SIZE(default_leds), | ||
39 | .leds = default_leds, | ||
40 | }; | ||
41 | |||
42 | static struct platform_device rdc321x_leds = { | ||
43 | .name = "leds-gpio", | ||
44 | .id = -1, | ||
45 | .dev = { | ||
46 | .platform_data = &rdc321x_led_data, | ||
47 | } | ||
48 | }; | ||
49 | |||
50 | /* Watchdog */ | ||
51 | static struct platform_device rdc321x_wdt = { | ||
52 | .name = "rdc321x-wdt", | ||
53 | .id = -1, | ||
54 | .num_resources = 0, | ||
55 | }; | ||
56 | |||
57 | static struct platform_device *rdc321x_devs[] = { | ||
58 | &rdc321x_leds, | ||
59 | &rdc321x_wdt | ||
60 | }; | ||
61 | |||
62 | static int __init rdc_board_setup(void) | ||
63 | { | ||
64 | rdc321x_gpio_setup(); | ||
65 | |||
66 | return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs)); | ||
67 | } | ||
68 | |||
69 | arch_initcall(rdc_board_setup); | ||
diff --git a/arch/x86/mach-voyager/setup.c b/arch/x86/mach-voyager/setup.c index a580b9562e76..0ade62555ff3 100644 --- a/arch/x86/mach-voyager/setup.c +++ b/arch/x86/mach-voyager/setup.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <asm/e820.h> | 9 | #include <asm/e820.h> |
10 | #include <asm/io.h> | 10 | #include <asm/io.h> |
11 | #include <asm/setup.h> | 11 | #include <asm/setup.h> |
12 | #include <asm/cpu.h> | ||
12 | 13 | ||
13 | void __init pre_intr_init_hook(void) | 14 | void __init pre_intr_init_hook(void) |
14 | { | 15 | { |
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c index 9840b7ec749a..331cd6d56483 100644 --- a/arch/x86/mach-voyager/voyager_smp.c +++ b/arch/x86/mach-voyager/voyager_smp.c | |||
@@ -402,7 +402,7 @@ void __init find_smp_config(void) | |||
402 | VOYAGER_SUS_IN_CONTROL_PORT); | 402 | VOYAGER_SUS_IN_CONTROL_PORT); |
403 | 403 | ||
404 | current_thread_info()->cpu = boot_cpu_id; | 404 | current_thread_info()->cpu = boot_cpu_id; |
405 | x86_write_percpu(cpu_number, boot_cpu_id); | 405 | percpu_write(cpu_number, boot_cpu_id); |
406 | } | 406 | } |
407 | 407 | ||
408 | /* | 408 | /* |
@@ -530,7 +530,6 @@ static void __init do_boot_cpu(__u8 cpu) | |||
530 | /* init_tasks (in sched.c) is indexed logically */ | 530 | /* init_tasks (in sched.c) is indexed logically */ |
531 | stack_start.sp = (void *)idle->thread.sp; | 531 | stack_start.sp = (void *)idle->thread.sp; |
532 | 532 | ||
533 | init_gdt(cpu); | ||
534 | per_cpu(current_task, cpu) = idle; | 533 | per_cpu(current_task, cpu) = idle; |
535 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); | 534 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); |
536 | irq_ctx_init(cpu); | 535 | irq_ctx_init(cpu); |
@@ -1747,7 +1746,6 @@ static void __init voyager_smp_prepare_cpus(unsigned int max_cpus) | |||
1747 | 1746 | ||
1748 | static void __cpuinit voyager_smp_prepare_boot_cpu(void) | 1747 | static void __cpuinit voyager_smp_prepare_boot_cpu(void) |
1749 | { | 1748 | { |
1750 | init_gdt(smp_processor_id()); | ||
1751 | switch_to_new_gdt(); | 1749 | switch_to_new_gdt(); |
1752 | 1750 | ||
1753 | cpu_set(smp_processor_id(), cpu_online_map); | 1751 | cpu_set(smp_processor_id(), cpu_online_map); |
@@ -1780,7 +1778,6 @@ static void __init voyager_smp_cpus_done(unsigned int max_cpus) | |||
1780 | void __init smp_setup_processor_id(void) | 1778 | void __init smp_setup_processor_id(void) |
1781 | { | 1779 | { |
1782 | current_thread_info()->cpu = hard_smp_processor_id(); | 1780 | current_thread_info()->cpu = hard_smp_processor_id(); |
1783 | x86_write_percpu(cpu_number, hard_smp_processor_id()); | ||
1784 | } | 1781 | } |
1785 | 1782 | ||
1786 | static void voyager_send_call_func(cpumask_t callmask) | 1783 | static void voyager_send_call_func(cpumask_t callmask) |
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index d8cc96a2738f..9f05157220f5 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile | |||
@@ -1,6 +1,8 @@ | |||
1 | obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ | 1 | obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ |
2 | pat.o pgtable.o gup.o | 2 | pat.o pgtable.o gup.o |
3 | 3 | ||
4 | obj-$(CONFIG_X86_SMP) += tlb.o | ||
5 | |||
4 | obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o | 6 | obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o |
5 | 7 | ||
6 | obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o | 8 | obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o |
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c index 7e8db53528a7..61b41ca3b5a2 100644 --- a/arch/x86/mm/extable.c +++ b/arch/x86/mm/extable.c | |||
@@ -23,6 +23,12 @@ int fixup_exception(struct pt_regs *regs) | |||
23 | 23 | ||
24 | fixup = search_exception_tables(regs->ip); | 24 | fixup = search_exception_tables(regs->ip); |
25 | if (fixup) { | 25 | if (fixup) { |
26 | /* If fixup is less than 16, it means uaccess error */ | ||
27 | if (fixup->fixup < 16) { | ||
28 | current_thread_info()->uaccess_err = -EFAULT; | ||
29 | regs->ip += fixup->fixup; | ||
30 | return 1; | ||
31 | } | ||
26 | regs->ip = fixup->fixup; | 32 | regs->ip = fixup->fixup; |
27 | return 1; | 33 | return 1; |
28 | } | 34 | } |
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9e268b6b204e..d3eee74f830a 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/kprobes.h> | 26 | #include <linux/kprobes.h> |
27 | #include <linux/uaccess.h> | 27 | #include <linux/uaccess.h> |
28 | #include <linux/kdebug.h> | 28 | #include <linux/kdebug.h> |
29 | #include <linux/magic.h> | ||
29 | 30 | ||
30 | #include <asm/system.h> | 31 | #include <asm/system.h> |
31 | #include <asm/desc.h> | 32 | #include <asm/desc.h> |
@@ -91,8 +92,8 @@ static inline int notify_page_fault(struct pt_regs *regs) | |||
91 | * | 92 | * |
92 | * Opcode checker based on code by Richard Brunner | 93 | * Opcode checker based on code by Richard Brunner |
93 | */ | 94 | */ |
94 | static int is_prefetch(struct pt_regs *regs, unsigned long addr, | 95 | static int is_prefetch(struct pt_regs *regs, unsigned long error_code, |
95 | unsigned long error_code) | 96 | unsigned long addr) |
96 | { | 97 | { |
97 | unsigned char *instr; | 98 | unsigned char *instr; |
98 | int scan_more = 1; | 99 | int scan_more = 1; |
@@ -409,17 +410,16 @@ static void show_fault_oops(struct pt_regs *regs, unsigned long error_code, | |||
409 | } | 410 | } |
410 | 411 | ||
411 | #ifdef CONFIG_X86_64 | 412 | #ifdef CONFIG_X86_64 |
412 | static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs, | 413 | static noinline void pgtable_bad(struct pt_regs *regs, |
413 | unsigned long error_code) | 414 | unsigned long error_code, unsigned long address) |
414 | { | 415 | { |
415 | unsigned long flags = oops_begin(); | 416 | unsigned long flags = oops_begin(); |
416 | int sig = SIGKILL; | 417 | int sig = SIGKILL; |
417 | struct task_struct *tsk; | 418 | struct task_struct *tsk = current; |
418 | 419 | ||
419 | printk(KERN_ALERT "%s: Corrupted page table at address %lx\n", | 420 | printk(KERN_ALERT "%s: Corrupted page table at address %lx\n", |
420 | current->comm, address); | 421 | tsk->comm, address); |
421 | dump_pagetable(address); | 422 | dump_pagetable(address); |
422 | tsk = current; | ||
423 | tsk->thread.cr2 = address; | 423 | tsk->thread.cr2 = address; |
424 | tsk->thread.trap_no = 14; | 424 | tsk->thread.trap_no = 14; |
425 | tsk->thread.error_code = error_code; | 425 | tsk->thread.error_code = error_code; |
@@ -429,6 +429,196 @@ static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs, | |||
429 | } | 429 | } |
430 | #endif | 430 | #endif |
431 | 431 | ||
432 | static noinline void no_context(struct pt_regs *regs, | ||
433 | unsigned long error_code, unsigned long address) | ||
434 | { | ||
435 | struct task_struct *tsk = current; | ||
436 | unsigned long *stackend; | ||
437 | |||
438 | #ifdef CONFIG_X86_64 | ||
439 | unsigned long flags; | ||
440 | int sig; | ||
441 | #endif | ||
442 | |||
443 | /* Are we prepared to handle this kernel fault? */ | ||
444 | if (fixup_exception(regs)) | ||
445 | return; | ||
446 | |||
447 | /* | ||
448 | * X86_32 | ||
449 | * Valid to do another page fault here, because if this fault | ||
450 | * had been triggered by is_prefetch fixup_exception would have | ||
451 | * handled it. | ||
452 | * | ||
453 | * X86_64 | ||
454 | * Hall of shame of CPU/BIOS bugs. | ||
455 | */ | ||
456 | if (is_prefetch(regs, error_code, address)) | ||
457 | return; | ||
458 | |||
459 | if (is_errata93(regs, address)) | ||
460 | return; | ||
461 | |||
462 | /* | ||
463 | * Oops. The kernel tried to access some bad page. We'll have to | ||
464 | * terminate things with extreme prejudice. | ||
465 | */ | ||
466 | #ifdef CONFIG_X86_32 | ||
467 | bust_spinlocks(1); | ||
468 | #else | ||
469 | flags = oops_begin(); | ||
470 | #endif | ||
471 | |||
472 | show_fault_oops(regs, error_code, address); | ||
473 | |||
474 | stackend = end_of_stack(tsk); | ||
475 | if (*stackend != STACK_END_MAGIC) | ||
476 | printk(KERN_ALERT "Thread overran stack, or stack corrupted\n"); | ||
477 | |||
478 | tsk->thread.cr2 = address; | ||
479 | tsk->thread.trap_no = 14; | ||
480 | tsk->thread.error_code = error_code; | ||
481 | |||
482 | #ifdef CONFIG_X86_32 | ||
483 | die("Oops", regs, error_code); | ||
484 | bust_spinlocks(0); | ||
485 | do_exit(SIGKILL); | ||
486 | #else | ||
487 | sig = SIGKILL; | ||
488 | if (__die("Oops", regs, error_code)) | ||
489 | sig = 0; | ||
490 | /* Executive summary in case the body of the oops scrolled away */ | ||
491 | printk(KERN_EMERG "CR2: %016lx\n", address); | ||
492 | oops_end(flags, regs, sig); | ||
493 | #endif | ||
494 | } | ||
495 | |||
496 | static void __bad_area_nosemaphore(struct pt_regs *regs, | ||
497 | unsigned long error_code, unsigned long address, | ||
498 | int si_code) | ||
499 | { | ||
500 | struct task_struct *tsk = current; | ||
501 | |||
502 | /* User mode accesses just cause a SIGSEGV */ | ||
503 | if (error_code & PF_USER) { | ||
504 | /* | ||
505 | * It's possible to have interrupts off here. | ||
506 | */ | ||
507 | local_irq_enable(); | ||
508 | |||
509 | /* | ||
510 | * Valid to do another page fault here because this one came | ||
511 | * from user space. | ||
512 | */ | ||
513 | if (is_prefetch(regs, error_code, address)) | ||
514 | return; | ||
515 | |||
516 | if (is_errata100(regs, address)) | ||
517 | return; | ||
518 | |||
519 | if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) && | ||
520 | printk_ratelimit()) { | ||
521 | printk( | ||
522 | "%s%s[%d]: segfault at %lx ip %p sp %p error %lx", | ||
523 | task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG, | ||
524 | tsk->comm, task_pid_nr(tsk), address, | ||
525 | (void *) regs->ip, (void *) regs->sp, error_code); | ||
526 | print_vma_addr(" in ", regs->ip); | ||
527 | printk("\n"); | ||
528 | } | ||
529 | |||
530 | tsk->thread.cr2 = address; | ||
531 | /* Kernel addresses are always protection faults */ | ||
532 | tsk->thread.error_code = error_code | (address >= TASK_SIZE); | ||
533 | tsk->thread.trap_no = 14; | ||
534 | force_sig_info_fault(SIGSEGV, si_code, address, tsk); | ||
535 | return; | ||
536 | } | ||
537 | |||
538 | if (is_f00f_bug(regs, address)) | ||
539 | return; | ||
540 | |||
541 | no_context(regs, error_code, address); | ||
542 | } | ||
543 | |||
544 | static noinline void bad_area_nosemaphore(struct pt_regs *regs, | ||
545 | unsigned long error_code, unsigned long address) | ||
546 | { | ||
547 | __bad_area_nosemaphore(regs, error_code, address, SEGV_MAPERR); | ||
548 | } | ||
549 | |||
550 | static void __bad_area(struct pt_regs *regs, | ||
551 | unsigned long error_code, unsigned long address, | ||
552 | int si_code) | ||
553 | { | ||
554 | struct mm_struct *mm = current->mm; | ||
555 | |||
556 | /* | ||
557 | * Something tried to access memory that isn't in our memory map.. | ||
558 | * Fix it, but check if it's kernel or user first.. | ||
559 | */ | ||
560 | up_read(&mm->mmap_sem); | ||
561 | |||
562 | __bad_area_nosemaphore(regs, error_code, address, si_code); | ||
563 | } | ||
564 | |||
565 | static noinline void bad_area(struct pt_regs *regs, | ||
566 | unsigned long error_code, unsigned long address) | ||
567 | { | ||
568 | __bad_area(regs, error_code, address, SEGV_MAPERR); | ||
569 | } | ||
570 | |||
571 | static noinline void bad_area_access_error(struct pt_regs *regs, | ||
572 | unsigned long error_code, unsigned long address) | ||
573 | { | ||
574 | __bad_area(regs, error_code, address, SEGV_ACCERR); | ||
575 | } | ||
576 | |||
577 | /* TODO: fixup for "mm-invoke-oom-killer-from-page-fault.patch" */ | ||
578 | static void out_of_memory(struct pt_regs *regs, | ||
579 | unsigned long error_code, unsigned long address) | ||
580 | { | ||
581 | /* | ||
582 | * We ran out of memory, call the OOM killer, and return the userspace | ||
583 | * (which will retry the fault, or kill us if we got oom-killed). | ||
584 | */ | ||
585 | up_read(¤t->mm->mmap_sem); | ||
586 | pagefault_out_of_memory(); | ||
587 | } | ||
588 | |||
589 | static void do_sigbus(struct pt_regs *regs, | ||
590 | unsigned long error_code, unsigned long address) | ||
591 | { | ||
592 | struct task_struct *tsk = current; | ||
593 | struct mm_struct *mm = tsk->mm; | ||
594 | |||
595 | up_read(&mm->mmap_sem); | ||
596 | |||
597 | /* Kernel mode? Handle exceptions or die */ | ||
598 | if (!(error_code & PF_USER)) | ||
599 | no_context(regs, error_code, address); | ||
600 | #ifdef CONFIG_X86_32 | ||
601 | /* User space => ok to do another page fault */ | ||
602 | if (is_prefetch(regs, error_code, address)) | ||
603 | return; | ||
604 | #endif | ||
605 | tsk->thread.cr2 = address; | ||
606 | tsk->thread.error_code = error_code; | ||
607 | tsk->thread.trap_no = 14; | ||
608 | force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk); | ||
609 | } | ||
610 | |||
611 | static noinline void mm_fault_error(struct pt_regs *regs, | ||
612 | unsigned long error_code, unsigned long address, unsigned int fault) | ||
613 | { | ||
614 | if (fault & VM_FAULT_OOM) | ||
615 | out_of_memory(regs, error_code, address); | ||
616 | else if (fault & VM_FAULT_SIGBUS) | ||
617 | do_sigbus(regs, error_code, address); | ||
618 | else | ||
619 | BUG(); | ||
620 | } | ||
621 | |||
432 | static int spurious_fault_check(unsigned long error_code, pte_t *pte) | 622 | static int spurious_fault_check(unsigned long error_code, pte_t *pte) |
433 | { | 623 | { |
434 | if ((error_code & PF_WRITE) && !pte_write(*pte)) | 624 | if ((error_code & PF_WRITE) && !pte_write(*pte)) |
@@ -448,8 +638,8 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte) | |||
448 | * There are no security implications to leaving a stale TLB when | 638 | * There are no security implications to leaving a stale TLB when |
449 | * increasing the permissions on a page. | 639 | * increasing the permissions on a page. |
450 | */ | 640 | */ |
451 | static int spurious_fault(unsigned long address, | 641 | static noinline int spurious_fault(unsigned long error_code, |
452 | unsigned long error_code) | 642 | unsigned long address) |
453 | { | 643 | { |
454 | pgd_t *pgd; | 644 | pgd_t *pgd; |
455 | pud_t *pud; | 645 | pud_t *pud; |
@@ -494,7 +684,7 @@ static int spurious_fault(unsigned long address, | |||
494 | * | 684 | * |
495 | * This assumes no large pages in there. | 685 | * This assumes no large pages in there. |
496 | */ | 686 | */ |
497 | static int vmalloc_fault(unsigned long address) | 687 | static noinline int vmalloc_fault(unsigned long address) |
498 | { | 688 | { |
499 | #ifdef CONFIG_X86_32 | 689 | #ifdef CONFIG_X86_32 |
500 | unsigned long pgd_paddr; | 690 | unsigned long pgd_paddr; |
@@ -534,7 +724,7 @@ static int vmalloc_fault(unsigned long address) | |||
534 | happen within a race in page table update. In the later | 724 | happen within a race in page table update. In the later |
535 | case just flush. */ | 725 | case just flush. */ |
536 | 726 | ||
537 | pgd = pgd_offset(current->mm ?: &init_mm, address); | 727 | pgd = pgd_offset(current->active_mm, address); |
538 | pgd_ref = pgd_offset_k(address); | 728 | pgd_ref = pgd_offset_k(address); |
539 | if (pgd_none(*pgd_ref)) | 729 | if (pgd_none(*pgd_ref)) |
540 | return -1; | 730 | return -1; |
@@ -573,6 +763,25 @@ static int vmalloc_fault(unsigned long address) | |||
573 | 763 | ||
574 | int show_unhandled_signals = 1; | 764 | int show_unhandled_signals = 1; |
575 | 765 | ||
766 | static inline int access_error(unsigned long error_code, int write, | ||
767 | struct vm_area_struct *vma) | ||
768 | { | ||
769 | if (write) { | ||
770 | /* write, present and write, not present */ | ||
771 | if (unlikely(!(vma->vm_flags & VM_WRITE))) | ||
772 | return 1; | ||
773 | } else if (unlikely(error_code & PF_PROT)) { | ||
774 | /* read, present */ | ||
775 | return 1; | ||
776 | } else { | ||
777 | /* read, not present */ | ||
778 | if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))) | ||
779 | return 1; | ||
780 | } | ||
781 | |||
782 | return 0; | ||
783 | } | ||
784 | |||
576 | /* | 785 | /* |
577 | * This routine handles page faults. It determines the address, | 786 | * This routine handles page faults. It determines the address, |
578 | * and the problem, and then passes it off to one of the appropriate | 787 | * and the problem, and then passes it off to one of the appropriate |
@@ -583,16 +792,12 @@ asmlinkage | |||
583 | #endif | 792 | #endif |
584 | void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) | 793 | void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) |
585 | { | 794 | { |
795 | unsigned long address; | ||
586 | struct task_struct *tsk; | 796 | struct task_struct *tsk; |
587 | struct mm_struct *mm; | 797 | struct mm_struct *mm; |
588 | struct vm_area_struct *vma; | 798 | struct vm_area_struct *vma; |
589 | unsigned long address; | 799 | int write; |
590 | int write, si_code; | ||
591 | int fault; | 800 | int fault; |
592 | #ifdef CONFIG_X86_64 | ||
593 | unsigned long flags; | ||
594 | int sig; | ||
595 | #endif | ||
596 | 801 | ||
597 | tsk = current; | 802 | tsk = current; |
598 | mm = tsk->mm; | 803 | mm = tsk->mm; |
@@ -601,9 +806,7 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
601 | /* get the address */ | 806 | /* get the address */ |
602 | address = read_cr2(); | 807 | address = read_cr2(); |
603 | 808 | ||
604 | si_code = SEGV_MAPERR; | 809 | if (unlikely(notify_page_fault(regs))) |
605 | |||
606 | if (notify_page_fault(regs)) | ||
607 | return; | 810 | return; |
608 | if (unlikely(kmmio_fault(regs, address))) | 811 | if (unlikely(kmmio_fault(regs, address))) |
609 | return; | 812 | return; |
@@ -631,17 +834,17 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
631 | return; | 834 | return; |
632 | 835 | ||
633 | /* Can handle a stale RO->RW TLB */ | 836 | /* Can handle a stale RO->RW TLB */ |
634 | if (spurious_fault(address, error_code)) | 837 | if (spurious_fault(error_code, address)) |
635 | return; | 838 | return; |
636 | 839 | ||
637 | /* | 840 | /* |
638 | * Don't take the mm semaphore here. If we fixup a prefetch | 841 | * Don't take the mm semaphore here. If we fixup a prefetch |
639 | * fault we could otherwise deadlock. | 842 | * fault we could otherwise deadlock. |
640 | */ | 843 | */ |
641 | goto bad_area_nosemaphore; | 844 | bad_area_nosemaphore(regs, error_code, address); |
845 | return; | ||
642 | } | 846 | } |
643 | 847 | ||
644 | |||
645 | /* | 848 | /* |
646 | * It's safe to allow irq's after cr2 has been saved and the | 849 | * It's safe to allow irq's after cr2 has been saved and the |
647 | * vmalloc fault has been handled. | 850 | * vmalloc fault has been handled. |
@@ -657,15 +860,17 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
657 | 860 | ||
658 | #ifdef CONFIG_X86_64 | 861 | #ifdef CONFIG_X86_64 |
659 | if (unlikely(error_code & PF_RSVD)) | 862 | if (unlikely(error_code & PF_RSVD)) |
660 | pgtable_bad(address, regs, error_code); | 863 | pgtable_bad(regs, error_code, address); |
661 | #endif | 864 | #endif |
662 | 865 | ||
663 | /* | 866 | /* |
664 | * If we're in an interrupt, have no user context or are running in an | 867 | * If we're in an interrupt, have no user context or are running in an |
665 | * atomic region then we must not take the fault. | 868 | * atomic region then we must not take the fault. |
666 | */ | 869 | */ |
667 | if (unlikely(in_atomic() || !mm)) | 870 | if (unlikely(in_atomic() || !mm)) { |
668 | goto bad_area_nosemaphore; | 871 | bad_area_nosemaphore(regs, error_code, address); |
872 | return; | ||
873 | } | ||
669 | 874 | ||
670 | /* | 875 | /* |
671 | * When running in the kernel we expect faults to occur only to | 876 | * When running in the kernel we expect faults to occur only to |
@@ -683,20 +888,26 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
683 | * source. If this is invalid we can skip the address space check, | 888 | * source. If this is invalid we can skip the address space check, |
684 | * thus avoiding the deadlock. | 889 | * thus avoiding the deadlock. |
685 | */ | 890 | */ |
686 | if (!down_read_trylock(&mm->mmap_sem)) { | 891 | if (unlikely(!down_read_trylock(&mm->mmap_sem))) { |
687 | if ((error_code & PF_USER) == 0 && | 892 | if ((error_code & PF_USER) == 0 && |
688 | !search_exception_tables(regs->ip)) | 893 | !search_exception_tables(regs->ip)) { |
689 | goto bad_area_nosemaphore; | 894 | bad_area_nosemaphore(regs, error_code, address); |
895 | return; | ||
896 | } | ||
690 | down_read(&mm->mmap_sem); | 897 | down_read(&mm->mmap_sem); |
691 | } | 898 | } |
692 | 899 | ||
693 | vma = find_vma(mm, address); | 900 | vma = find_vma(mm, address); |
694 | if (!vma) | 901 | if (unlikely(!vma)) { |
695 | goto bad_area; | 902 | bad_area(regs, error_code, address); |
696 | if (vma->vm_start <= address) | 903 | return; |
904 | } | ||
905 | if (likely(vma->vm_start <= address)) | ||
697 | goto good_area; | 906 | goto good_area; |
698 | if (!(vma->vm_flags & VM_GROWSDOWN)) | 907 | if (unlikely(!(vma->vm_flags & VM_GROWSDOWN))) { |
699 | goto bad_area; | 908 | bad_area(regs, error_code, address); |
909 | return; | ||
910 | } | ||
700 | if (error_code & PF_USER) { | 911 | if (error_code & PF_USER) { |
701 | /* | 912 | /* |
702 | * Accessing the stack below %sp is always a bug. | 913 | * Accessing the stack below %sp is always a bug. |
@@ -704,31 +915,25 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
704 | * and pusha to work. ("enter $65535,$31" pushes | 915 | * and pusha to work. ("enter $65535,$31" pushes |
705 | * 32 pointers and then decrements %sp by 65535.) | 916 | * 32 pointers and then decrements %sp by 65535.) |
706 | */ | 917 | */ |
707 | if (address + 65536 + 32 * sizeof(unsigned long) < regs->sp) | 918 | if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) { |
708 | goto bad_area; | 919 | bad_area(regs, error_code, address); |
920 | return; | ||
921 | } | ||
709 | } | 922 | } |
710 | if (expand_stack(vma, address)) | 923 | if (unlikely(expand_stack(vma, address))) { |
711 | goto bad_area; | 924 | bad_area(regs, error_code, address); |
712 | /* | 925 | return; |
713 | * Ok, we have a good vm_area for this memory access, so | 926 | } |
714 | * we can handle it.. | 927 | |
715 | */ | 928 | /* |
929 | * Ok, we have a good vm_area for this memory access, so | ||
930 | * we can handle it.. | ||
931 | */ | ||
716 | good_area: | 932 | good_area: |
717 | si_code = SEGV_ACCERR; | 933 | write = error_code & PF_WRITE; |
718 | write = 0; | 934 | if (unlikely(access_error(error_code, write, vma))) { |
719 | switch (error_code & (PF_PROT|PF_WRITE)) { | 935 | bad_area_access_error(regs, error_code, address); |
720 | default: /* 3: write, present */ | 936 | return; |
721 | /* fall through */ | ||
722 | case PF_WRITE: /* write, not present */ | ||
723 | if (!(vma->vm_flags & VM_WRITE)) | ||
724 | goto bad_area; | ||
725 | write++; | ||
726 | break; | ||
727 | case PF_PROT: /* read, present */ | ||
728 | goto bad_area; | ||
729 | case 0: /* read, not present */ | ||
730 | if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))) | ||
731 | goto bad_area; | ||
732 | } | 937 | } |
733 | 938 | ||
734 | /* | 939 | /* |
@@ -738,11 +943,8 @@ good_area: | |||
738 | */ | 943 | */ |
739 | fault = handle_mm_fault(mm, vma, address, write); | 944 | fault = handle_mm_fault(mm, vma, address, write); |
740 | if (unlikely(fault & VM_FAULT_ERROR)) { | 945 | if (unlikely(fault & VM_FAULT_ERROR)) { |
741 | if (fault & VM_FAULT_OOM) | 946 | mm_fault_error(regs, error_code, address, fault); |
742 | goto out_of_memory; | 947 | return; |
743 | else if (fault & VM_FAULT_SIGBUS) | ||
744 | goto do_sigbus; | ||
745 | BUG(); | ||
746 | } | 948 | } |
747 | if (fault & VM_FAULT_MAJOR) | 949 | if (fault & VM_FAULT_MAJOR) |
748 | tsk->maj_flt++; | 950 | tsk->maj_flt++; |
@@ -760,128 +962,6 @@ good_area: | |||
760 | } | 962 | } |
761 | #endif | 963 | #endif |
762 | up_read(&mm->mmap_sem); | 964 | up_read(&mm->mmap_sem); |
763 | return; | ||
764 | |||
765 | /* | ||
766 | * Something tried to access memory that isn't in our memory map.. | ||
767 | * Fix it, but check if it's kernel or user first.. | ||
768 | */ | ||
769 | bad_area: | ||
770 | up_read(&mm->mmap_sem); | ||
771 | |||
772 | bad_area_nosemaphore: | ||
773 | /* User mode accesses just cause a SIGSEGV */ | ||
774 | if (error_code & PF_USER) { | ||
775 | /* | ||
776 | * It's possible to have interrupts off here. | ||
777 | */ | ||
778 | local_irq_enable(); | ||
779 | |||
780 | /* | ||
781 | * Valid to do another page fault here because this one came | ||
782 | * from user space. | ||
783 | */ | ||
784 | if (is_prefetch(regs, address, error_code)) | ||
785 | return; | ||
786 | |||
787 | if (is_errata100(regs, address)) | ||
788 | return; | ||
789 | |||
790 | if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) && | ||
791 | printk_ratelimit()) { | ||
792 | printk( | ||
793 | "%s%s[%d]: segfault at %lx ip %p sp %p error %lx", | ||
794 | task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG, | ||
795 | tsk->comm, task_pid_nr(tsk), address, | ||
796 | (void *) regs->ip, (void *) regs->sp, error_code); | ||
797 | print_vma_addr(" in ", regs->ip); | ||
798 | printk("\n"); | ||
799 | } | ||
800 | |||
801 | tsk->thread.cr2 = address; | ||
802 | /* Kernel addresses are always protection faults */ | ||
803 | tsk->thread.error_code = error_code | (address >= TASK_SIZE); | ||
804 | tsk->thread.trap_no = 14; | ||
805 | force_sig_info_fault(SIGSEGV, si_code, address, tsk); | ||
806 | return; | ||
807 | } | ||
808 | |||
809 | if (is_f00f_bug(regs, address)) | ||
810 | return; | ||
811 | |||
812 | no_context: | ||
813 | /* Are we prepared to handle this kernel fault? */ | ||
814 | if (fixup_exception(regs)) | ||
815 | return; | ||
816 | |||
817 | /* | ||
818 | * X86_32 | ||
819 | * Valid to do another page fault here, because if this fault | ||
820 | * had been triggered by is_prefetch fixup_exception would have | ||
821 | * handled it. | ||
822 | * | ||
823 | * X86_64 | ||
824 | * Hall of shame of CPU/BIOS bugs. | ||
825 | */ | ||
826 | if (is_prefetch(regs, address, error_code)) | ||
827 | return; | ||
828 | |||
829 | if (is_errata93(regs, address)) | ||
830 | return; | ||
831 | |||
832 | /* | ||
833 | * Oops. The kernel tried to access some bad page. We'll have to | ||
834 | * terminate things with extreme prejudice. | ||
835 | */ | ||
836 | #ifdef CONFIG_X86_32 | ||
837 | bust_spinlocks(1); | ||
838 | #else | ||
839 | flags = oops_begin(); | ||
840 | #endif | ||
841 | |||
842 | show_fault_oops(regs, error_code, address); | ||
843 | |||
844 | tsk->thread.cr2 = address; | ||
845 | tsk->thread.trap_no = 14; | ||
846 | tsk->thread.error_code = error_code; | ||
847 | |||
848 | #ifdef CONFIG_X86_32 | ||
849 | die("Oops", regs, error_code); | ||
850 | bust_spinlocks(0); | ||
851 | do_exit(SIGKILL); | ||
852 | #else | ||
853 | sig = SIGKILL; | ||
854 | if (__die("Oops", regs, error_code)) | ||
855 | sig = 0; | ||
856 | /* Executive summary in case the body of the oops scrolled away */ | ||
857 | printk(KERN_EMERG "CR2: %016lx\n", address); | ||
858 | oops_end(flags, regs, sig); | ||
859 | #endif | ||
860 | |||
861 | out_of_memory: | ||
862 | /* | ||
863 | * We ran out of memory, call the OOM killer, and return the userspace | ||
864 | * (which will retry the fault, or kill us if we got oom-killed). | ||
865 | */ | ||
866 | up_read(&mm->mmap_sem); | ||
867 | pagefault_out_of_memory(); | ||
868 | return; | ||
869 | |||
870 | do_sigbus: | ||
871 | up_read(&mm->mmap_sem); | ||
872 | |||
873 | /* Kernel mode? Handle exceptions or die */ | ||
874 | if (!(error_code & PF_USER)) | ||
875 | goto no_context; | ||
876 | #ifdef CONFIG_X86_32 | ||
877 | /* User space => ok to do another page fault */ | ||
878 | if (is_prefetch(regs, address, error_code)) | ||
879 | return; | ||
880 | #endif | ||
881 | tsk->thread.cr2 = address; | ||
882 | tsk->thread.error_code = error_code; | ||
883 | tsk->thread.trap_no = 14; | ||
884 | force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk); | ||
885 | } | 965 | } |
886 | 966 | ||
887 | DEFINE_SPINLOCK(pgd_lock); | 967 | DEFINE_SPINLOCK(pgd_lock); |
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 88f1b10de3be..00263bf07a88 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <asm/paravirt.h> | 49 | #include <asm/paravirt.h> |
50 | #include <asm/setup.h> | 50 | #include <asm/setup.h> |
51 | #include <asm/cacheflush.h> | 51 | #include <asm/cacheflush.h> |
52 | #include <asm/smp.h> | ||
53 | 52 | ||
54 | unsigned int __VMALLOC_RESERVE = 128 << 20; | 53 | unsigned int __VMALLOC_RESERVE = 128 << 20; |
55 | 54 | ||
@@ -138,6 +137,47 @@ static pte_t * __init one_page_table_init(pmd_t *pmd) | |||
138 | return pte_offset_kernel(pmd, 0); | 137 | return pte_offset_kernel(pmd, 0); |
139 | } | 138 | } |
140 | 139 | ||
140 | static pte_t *__init page_table_kmap_check(pte_t *pte, pmd_t *pmd, | ||
141 | unsigned long vaddr, pte_t *lastpte) | ||
142 | { | ||
143 | #ifdef CONFIG_HIGHMEM | ||
144 | /* | ||
145 | * Something (early fixmap) may already have put a pte | ||
146 | * page here, which causes the page table allocation | ||
147 | * to become nonlinear. Attempt to fix it, and if it | ||
148 | * is still nonlinear then we have to bug. | ||
149 | */ | ||
150 | int pmd_idx_kmap_begin = fix_to_virt(FIX_KMAP_END) >> PMD_SHIFT; | ||
151 | int pmd_idx_kmap_end = fix_to_virt(FIX_KMAP_BEGIN) >> PMD_SHIFT; | ||
152 | |||
153 | if (pmd_idx_kmap_begin != pmd_idx_kmap_end | ||
154 | && (vaddr >> PMD_SHIFT) >= pmd_idx_kmap_begin | ||
155 | && (vaddr >> PMD_SHIFT) <= pmd_idx_kmap_end | ||
156 | && ((__pa(pte) >> PAGE_SHIFT) < table_start | ||
157 | || (__pa(pte) >> PAGE_SHIFT) >= table_end)) { | ||
158 | pte_t *newpte; | ||
159 | int i; | ||
160 | |||
161 | BUG_ON(after_init_bootmem); | ||
162 | newpte = alloc_low_page(); | ||
163 | for (i = 0; i < PTRS_PER_PTE; i++) | ||
164 | set_pte(newpte + i, pte[i]); | ||
165 | |||
166 | paravirt_alloc_pte(&init_mm, __pa(newpte) >> PAGE_SHIFT); | ||
167 | set_pmd(pmd, __pmd(__pa(newpte)|_PAGE_TABLE)); | ||
168 | BUG_ON(newpte != pte_offset_kernel(pmd, 0)); | ||
169 | __flush_tlb_all(); | ||
170 | |||
171 | paravirt_release_pte(__pa(pte) >> PAGE_SHIFT); | ||
172 | pte = newpte; | ||
173 | } | ||
174 | BUG_ON(vaddr < fix_to_virt(FIX_KMAP_BEGIN - 1) | ||
175 | && vaddr > fix_to_virt(FIX_KMAP_END) | ||
176 | && lastpte && lastpte + PTRS_PER_PTE != pte); | ||
177 | #endif | ||
178 | return pte; | ||
179 | } | ||
180 | |||
141 | /* | 181 | /* |
142 | * This function initializes a certain range of kernel virtual memory | 182 | * This function initializes a certain range of kernel virtual memory |
143 | * with new bootmem page tables, everywhere page tables are missing in | 183 | * with new bootmem page tables, everywhere page tables are missing in |
@@ -154,6 +194,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base) | |||
154 | unsigned long vaddr; | 194 | unsigned long vaddr; |
155 | pgd_t *pgd; | 195 | pgd_t *pgd; |
156 | pmd_t *pmd; | 196 | pmd_t *pmd; |
197 | pte_t *pte = NULL; | ||
157 | 198 | ||
158 | vaddr = start; | 199 | vaddr = start; |
159 | pgd_idx = pgd_index(vaddr); | 200 | pgd_idx = pgd_index(vaddr); |
@@ -165,7 +206,8 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base) | |||
165 | pmd = pmd + pmd_index(vaddr); | 206 | pmd = pmd + pmd_index(vaddr); |
166 | for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end); | 207 | for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end); |
167 | pmd++, pmd_idx++) { | 208 | pmd++, pmd_idx++) { |
168 | one_page_table_init(pmd); | 209 | pte = page_table_kmap_check(one_page_table_init(pmd), |
210 | pmd, vaddr, pte); | ||
169 | 211 | ||
170 | vaddr += PMD_SIZE; | 212 | vaddr += PMD_SIZE; |
171 | } | 213 | } |
@@ -508,7 +550,6 @@ static void __init early_ioremap_page_table_range_init(pgd_t *pgd_base) | |||
508 | * Fixed mappings, only the page table structure has to be | 550 | * Fixed mappings, only the page table structure has to be |
509 | * created - mappings will be set by set_fixmap(): | 551 | * created - mappings will be set by set_fixmap(): |
510 | */ | 552 | */ |
511 | early_ioremap_clear(); | ||
512 | vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; | 553 | vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; |
513 | end = (FIXADDR_TOP + PMD_SIZE - 1) & PMD_MASK; | 554 | end = (FIXADDR_TOP + PMD_SIZE - 1) & PMD_MASK; |
514 | page_table_range_init(vaddr, end, pgd_base); | 555 | page_table_range_init(vaddr, end, pgd_base); |
@@ -801,7 +842,7 @@ static void __init find_early_table_space(unsigned long end, int use_pse) | |||
801 | tables += PAGE_ALIGN(ptes * sizeof(pte_t)); | 842 | tables += PAGE_ALIGN(ptes * sizeof(pte_t)); |
802 | 843 | ||
803 | /* for fixmap */ | 844 | /* for fixmap */ |
804 | tables += PAGE_SIZE * 2; | 845 | tables += PAGE_ALIGN(__end_of_fixed_addresses * sizeof(pte_t)); |
805 | 846 | ||
806 | /* | 847 | /* |
807 | * RED-PEN putting page tables only on node 0 could | 848 | * RED-PEN putting page tables only on node 0 could |
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 23f68e77ad1f..e6d36b490250 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c | |||
@@ -596,7 +596,7 @@ static void __init init_gbpages(void) | |||
596 | direct_gbpages = 0; | 596 | direct_gbpages = 0; |
597 | } | 597 | } |
598 | 598 | ||
599 | static unsigned long __init kernel_physical_mapping_init(unsigned long start, | 599 | static unsigned long __meminit kernel_physical_mapping_init(unsigned long start, |
600 | unsigned long end, | 600 | unsigned long end, |
601 | unsigned long page_size_mask) | 601 | unsigned long page_size_mask) |
602 | { | 602 | { |
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c index d0151d8ce452..ca53224fc56c 100644 --- a/arch/x86/mm/iomap_32.c +++ b/arch/x86/mm/iomap_32.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <asm/iomap.h> | 19 | #include <asm/iomap.h> |
20 | #include <asm/pat.h> | ||
20 | #include <linux/module.h> | 21 | #include <linux/module.h> |
21 | 22 | ||
22 | /* Map 'pfn' using fixed map 'type' and protections 'prot' | 23 | /* Map 'pfn' using fixed map 'type' and protections 'prot' |
@@ -29,6 +30,15 @@ iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) | |||
29 | 30 | ||
30 | pagefault_disable(); | 31 | pagefault_disable(); |
31 | 32 | ||
33 | /* | ||
34 | * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS. | ||
35 | * PAGE_KERNEL_WC maps to PWT, which translates to uncached if the | ||
36 | * MTRR is UC or WC. UC_MINUS gets the real intention, of the | ||
37 | * user, which is "WC if the MTRR is WC, UC if you can't do that." | ||
38 | */ | ||
39 | if (!pat_enabled && pgprot_val(prot) == pgprot_val(PAGE_KERNEL_WC)) | ||
40 | prot = PAGE_KERNEL_UC_MINUS; | ||
41 | |||
32 | idx = type + KM_TYPE_NR*smp_processor_id(); | 42 | idx = type + KM_TYPE_NR*smp_processor_id(); |
33 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); | 43 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); |
34 | set_pte(kmap_pte-idx, pfn_pte(pfn, prot)); | 44 | set_pte(kmap_pte-idx, pfn_pte(pfn, prot)); |
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index bd85d42819e1..1448bcb7f22f 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
@@ -367,7 +367,7 @@ EXPORT_SYMBOL(ioremap_nocache); | |||
367 | * | 367 | * |
368 | * Must be freed with iounmap. | 368 | * Must be freed with iounmap. |
369 | */ | 369 | */ |
370 | void __iomem *ioremap_wc(unsigned long phys_addr, unsigned long size) | 370 | void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size) |
371 | { | 371 | { |
372 | if (pat_enabled) | 372 | if (pat_enabled) |
373 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC, | 373 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC, |
@@ -557,34 +557,9 @@ void __init early_ioremap_init(void) | |||
557 | } | 557 | } |
558 | } | 558 | } |
559 | 559 | ||
560 | void __init early_ioremap_clear(void) | ||
561 | { | ||
562 | pmd_t *pmd; | ||
563 | |||
564 | if (early_ioremap_debug) | ||
565 | printk(KERN_INFO "early_ioremap_clear()\n"); | ||
566 | |||
567 | pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN)); | ||
568 | pmd_clear(pmd); | ||
569 | paravirt_release_pte(__pa(bm_pte) >> PAGE_SHIFT); | ||
570 | __flush_tlb_all(); | ||
571 | } | ||
572 | |||
573 | void __init early_ioremap_reset(void) | 560 | void __init early_ioremap_reset(void) |
574 | { | 561 | { |
575 | enum fixed_addresses idx; | ||
576 | unsigned long addr, phys; | ||
577 | pte_t *pte; | ||
578 | |||
579 | after_paging_init = 1; | 562 | after_paging_init = 1; |
580 | for (idx = FIX_BTMAP_BEGIN; idx >= FIX_BTMAP_END; idx--) { | ||
581 | addr = fix_to_virt(idx); | ||
582 | pte = early_ioremap_pte(addr); | ||
583 | if (pte_present(*pte)) { | ||
584 | phys = pte_val(*pte) & PAGE_MASK; | ||
585 | set_fixmap(idx, phys); | ||
586 | } | ||
587 | } | ||
588 | } | 563 | } |
589 | 564 | ||
590 | static void __init __early_set_fixmap(enum fixed_addresses idx, | 565 | static void __init __early_set_fixmap(enum fixed_addresses idx, |
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index 71a14f89f89e..08d140fbc31b 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c | |||
@@ -20,6 +20,12 @@ | |||
20 | #include <asm/acpi.h> | 20 | #include <asm/acpi.h> |
21 | #include <asm/k8.h> | 21 | #include <asm/k8.h> |
22 | 22 | ||
23 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
24 | # define DBG(x...) printk(KERN_DEBUG x) | ||
25 | #else | ||
26 | # define DBG(x...) | ||
27 | #endif | ||
28 | |||
23 | struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; | 29 | struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; |
24 | EXPORT_SYMBOL(node_data); | 30 | EXPORT_SYMBOL(node_data); |
25 | 31 | ||
@@ -33,6 +39,21 @@ int numa_off __initdata; | |||
33 | static unsigned long __initdata nodemap_addr; | 39 | static unsigned long __initdata nodemap_addr; |
34 | static unsigned long __initdata nodemap_size; | 40 | static unsigned long __initdata nodemap_size; |
35 | 41 | ||
42 | DEFINE_PER_CPU(int, node_number) = 0; | ||
43 | EXPORT_PER_CPU_SYMBOL(node_number); | ||
44 | |||
45 | /* | ||
46 | * Map cpu index to node index | ||
47 | */ | ||
48 | DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE); | ||
49 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map); | ||
50 | |||
51 | /* | ||
52 | * Which logical CPUs are on which nodes | ||
53 | */ | ||
54 | cpumask_t *node_to_cpumask_map; | ||
55 | EXPORT_SYMBOL(node_to_cpumask_map); | ||
56 | |||
36 | /* | 57 | /* |
37 | * Given a shift value, try to populate memnodemap[] | 58 | * Given a shift value, try to populate memnodemap[] |
38 | * Returns : | 59 | * Returns : |
@@ -640,3 +661,199 @@ void __init init_cpu_to_node(void) | |||
640 | #endif | 661 | #endif |
641 | 662 | ||
642 | 663 | ||
664 | /* | ||
665 | * Allocate node_to_cpumask_map based on number of available nodes | ||
666 | * Requires node_possible_map to be valid. | ||
667 | * | ||
668 | * Note: node_to_cpumask() is not valid until after this is done. | ||
669 | * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.) | ||
670 | */ | ||
671 | void __init setup_node_to_cpumask_map(void) | ||
672 | { | ||
673 | unsigned int node, num = 0; | ||
674 | cpumask_t *map; | ||
675 | |||
676 | /* setup nr_node_ids if not done yet */ | ||
677 | if (nr_node_ids == MAX_NUMNODES) { | ||
678 | for_each_node_mask(node, node_possible_map) | ||
679 | num = node; | ||
680 | nr_node_ids = num + 1; | ||
681 | } | ||
682 | |||
683 | /* allocate the map */ | ||
684 | map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t)); | ||
685 | DBG("node_to_cpumask_map at %p for %d nodes\n", map, nr_node_ids); | ||
686 | |||
687 | pr_debug("Node to cpumask map at %p for %d nodes\n", | ||
688 | map, nr_node_ids); | ||
689 | |||
690 | /* node_to_cpumask() will now work */ | ||
691 | node_to_cpumask_map = map; | ||
692 | } | ||
693 | |||
694 | void __cpuinit numa_set_node(int cpu, int node) | ||
695 | { | ||
696 | int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map); | ||
697 | |||
698 | /* early setting, no percpu area yet */ | ||
699 | if (cpu_to_node_map) { | ||
700 | cpu_to_node_map[cpu] = node; | ||
701 | return; | ||
702 | } | ||
703 | |||
704 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
705 | if (cpu >= nr_cpu_ids || !per_cpu_offset(cpu)) { | ||
706 | printk(KERN_ERR "numa_set_node: invalid cpu# (%d)\n", cpu); | ||
707 | dump_stack(); | ||
708 | return; | ||
709 | } | ||
710 | #endif | ||
711 | per_cpu(x86_cpu_to_node_map, cpu) = node; | ||
712 | |||
713 | if (node != NUMA_NO_NODE) | ||
714 | per_cpu(node_number, cpu) = node; | ||
715 | } | ||
716 | |||
717 | void __cpuinit numa_clear_node(int cpu) | ||
718 | { | ||
719 | numa_set_node(cpu, NUMA_NO_NODE); | ||
720 | } | ||
721 | |||
722 | #ifndef CONFIG_DEBUG_PER_CPU_MAPS | ||
723 | |||
724 | void __cpuinit numa_add_cpu(int cpu) | ||
725 | { | ||
726 | cpu_set(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); | ||
727 | } | ||
728 | |||
729 | void __cpuinit numa_remove_cpu(int cpu) | ||
730 | { | ||
731 | cpu_clear(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); | ||
732 | } | ||
733 | |||
734 | #else /* CONFIG_DEBUG_PER_CPU_MAPS */ | ||
735 | |||
736 | /* | ||
737 | * --------- debug versions of the numa functions --------- | ||
738 | */ | ||
739 | static void __cpuinit numa_set_cpumask(int cpu, int enable) | ||
740 | { | ||
741 | int node = early_cpu_to_node(cpu); | ||
742 | cpumask_t *mask; | ||
743 | char buf[64]; | ||
744 | |||
745 | if (node_to_cpumask_map == NULL) { | ||
746 | printk(KERN_ERR "node_to_cpumask_map NULL\n"); | ||
747 | dump_stack(); | ||
748 | return; | ||
749 | } | ||
750 | |||
751 | mask = &node_to_cpumask_map[node]; | ||
752 | if (enable) | ||
753 | cpu_set(cpu, *mask); | ||
754 | else | ||
755 | cpu_clear(cpu, *mask); | ||
756 | |||
757 | cpulist_scnprintf(buf, sizeof(buf), mask); | ||
758 | printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", | ||
759 | enable ? "numa_add_cpu" : "numa_remove_cpu", cpu, node, buf); | ||
760 | } | ||
761 | |||
762 | void __cpuinit numa_add_cpu(int cpu) | ||
763 | { | ||
764 | numa_set_cpumask(cpu, 1); | ||
765 | } | ||
766 | |||
767 | void __cpuinit numa_remove_cpu(int cpu) | ||
768 | { | ||
769 | numa_set_cpumask(cpu, 0); | ||
770 | } | ||
771 | |||
772 | int cpu_to_node(int cpu) | ||
773 | { | ||
774 | if (early_per_cpu_ptr(x86_cpu_to_node_map)) { | ||
775 | printk(KERN_WARNING | ||
776 | "cpu_to_node(%d): usage too early!\n", cpu); | ||
777 | dump_stack(); | ||
778 | return early_per_cpu_ptr(x86_cpu_to_node_map)[cpu]; | ||
779 | } | ||
780 | return per_cpu(x86_cpu_to_node_map, cpu); | ||
781 | } | ||
782 | EXPORT_SYMBOL(cpu_to_node); | ||
783 | |||
784 | /* | ||
785 | * Same function as cpu_to_node() but used if called before the | ||
786 | * per_cpu areas are setup. | ||
787 | */ | ||
788 | int early_cpu_to_node(int cpu) | ||
789 | { | ||
790 | if (early_per_cpu_ptr(x86_cpu_to_node_map)) | ||
791 | return early_per_cpu_ptr(x86_cpu_to_node_map)[cpu]; | ||
792 | |||
793 | if (!per_cpu_offset(cpu)) { | ||
794 | printk(KERN_WARNING | ||
795 | "early_cpu_to_node(%d): no per_cpu area!\n", cpu); | ||
796 | dump_stack(); | ||
797 | return NUMA_NO_NODE; | ||
798 | } | ||
799 | return per_cpu(x86_cpu_to_node_map, cpu); | ||
800 | } | ||
801 | |||
802 | |||
803 | /* empty cpumask */ | ||
804 | static const cpumask_t cpu_mask_none; | ||
805 | |||
806 | /* | ||
807 | * Returns a pointer to the bitmask of CPUs on Node 'node'. | ||
808 | */ | ||
809 | const cpumask_t *cpumask_of_node(int node) | ||
810 | { | ||
811 | if (node_to_cpumask_map == NULL) { | ||
812 | printk(KERN_WARNING | ||
813 | "cpumask_of_node(%d): no node_to_cpumask_map!\n", | ||
814 | node); | ||
815 | dump_stack(); | ||
816 | return (const cpumask_t *)&cpu_online_map; | ||
817 | } | ||
818 | if (node >= nr_node_ids) { | ||
819 | printk(KERN_WARNING | ||
820 | "cpumask_of_node(%d): node > nr_node_ids(%d)\n", | ||
821 | node, nr_node_ids); | ||
822 | dump_stack(); | ||
823 | return &cpu_mask_none; | ||
824 | } | ||
825 | return &node_to_cpumask_map[node]; | ||
826 | } | ||
827 | EXPORT_SYMBOL(cpumask_of_node); | ||
828 | |||
829 | /* | ||
830 | * Returns a bitmask of CPUs on Node 'node'. | ||
831 | * | ||
832 | * Side note: this function creates the returned cpumask on the stack | ||
833 | * so with a high NR_CPUS count, excessive stack space is used. The | ||
834 | * node_to_cpumask_ptr function should be used whenever possible. | ||
835 | */ | ||
836 | cpumask_t node_to_cpumask(int node) | ||
837 | { | ||
838 | if (node_to_cpumask_map == NULL) { | ||
839 | printk(KERN_WARNING | ||
840 | "node_to_cpumask(%d): no node_to_cpumask_map!\n", node); | ||
841 | dump_stack(); | ||
842 | return cpu_online_map; | ||
843 | } | ||
844 | if (node >= nr_node_ids) { | ||
845 | printk(KERN_WARNING | ||
846 | "node_to_cpumask(%d): node > nr_node_ids(%d)\n", | ||
847 | node, nr_node_ids); | ||
848 | dump_stack(); | ||
849 | return cpu_mask_none; | ||
850 | } | ||
851 | return node_to_cpumask_map[node]; | ||
852 | } | ||
853 | EXPORT_SYMBOL(node_to_cpumask); | ||
854 | |||
855 | /* | ||
856 | * --------- end of debug versions of the numa functions --------- | ||
857 | */ | ||
858 | |||
859 | #endif /* CONFIG_DEBUG_PER_CPU_MAPS */ | ||
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index e89d24815f26..84ba74820ad6 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -534,6 +534,36 @@ out_unlock: | |||
534 | return 0; | 534 | return 0; |
535 | } | 535 | } |
536 | 536 | ||
537 | static int __cpa_process_fault(struct cpa_data *cpa, unsigned long vaddr, | ||
538 | int primary) | ||
539 | { | ||
540 | /* | ||
541 | * Ignore all non primary paths. | ||
542 | */ | ||
543 | if (!primary) | ||
544 | return 0; | ||
545 | |||
546 | /* | ||
547 | * Ignore the NULL PTE for kernel identity mapping, as it is expected | ||
548 | * to have holes. | ||
549 | * Also set numpages to '1' indicating that we processed cpa req for | ||
550 | * one virtual address page and its pfn. TBD: numpages can be set based | ||
551 | * on the initial value and the level returned by lookup_address(). | ||
552 | */ | ||
553 | if (within(vaddr, PAGE_OFFSET, | ||
554 | PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT))) { | ||
555 | cpa->numpages = 1; | ||
556 | cpa->pfn = __pa(vaddr) >> PAGE_SHIFT; | ||
557 | return 0; | ||
558 | } else { | ||
559 | WARN(1, KERN_WARNING "CPA: called for zero pte. " | ||
560 | "vaddr = %lx cpa->vaddr = %lx\n", vaddr, | ||
561 | *cpa->vaddr); | ||
562 | |||
563 | return -EFAULT; | ||
564 | } | ||
565 | } | ||
566 | |||
537 | static int __change_page_attr(struct cpa_data *cpa, int primary) | 567 | static int __change_page_attr(struct cpa_data *cpa, int primary) |
538 | { | 568 | { |
539 | unsigned long address; | 569 | unsigned long address; |
@@ -549,17 +579,11 @@ static int __change_page_attr(struct cpa_data *cpa, int primary) | |||
549 | repeat: | 579 | repeat: |
550 | kpte = lookup_address(address, &level); | 580 | kpte = lookup_address(address, &level); |
551 | if (!kpte) | 581 | if (!kpte) |
552 | return 0; | 582 | return __cpa_process_fault(cpa, address, primary); |
553 | 583 | ||
554 | old_pte = *kpte; | 584 | old_pte = *kpte; |
555 | if (!pte_val(old_pte)) { | 585 | if (!pte_val(old_pte)) |
556 | if (!primary) | 586 | return __cpa_process_fault(cpa, address, primary); |
557 | return 0; | ||
558 | WARN(1, KERN_WARNING "CPA: called for zero pte. " | ||
559 | "vaddr = %lx cpa->vaddr = %lx\n", address, | ||
560 | *cpa->vaddr); | ||
561 | return -EINVAL; | ||
562 | } | ||
563 | 587 | ||
564 | if (level == PG_LEVEL_4K) { | 588 | if (level == PG_LEVEL_4K) { |
565 | pte_t new_pte; | 589 | pte_t new_pte; |
@@ -657,12 +681,7 @@ static int cpa_process_alias(struct cpa_data *cpa) | |||
657 | vaddr = *cpa->vaddr; | 681 | vaddr = *cpa->vaddr; |
658 | 682 | ||
659 | if (!(within(vaddr, PAGE_OFFSET, | 683 | if (!(within(vaddr, PAGE_OFFSET, |
660 | PAGE_OFFSET + (max_low_pfn_mapped << PAGE_SHIFT)) | 684 | PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT)))) { |
661 | #ifdef CONFIG_X86_64 | ||
662 | || within(vaddr, PAGE_OFFSET + (1UL<<32), | ||
663 | PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT)) | ||
664 | #endif | ||
665 | )) { | ||
666 | 685 | ||
667 | alias_cpa = *cpa; | 686 | alias_cpa = *cpa; |
668 | temp_cpa_vaddr = (unsigned long) __va(cpa->pfn << PAGE_SHIFT); | 687 | temp_cpa_vaddr = (unsigned long) __va(cpa->pfn << PAGE_SHIFT); |
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 85cbd3cd3723..9127e31c7268 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #ifdef CONFIG_X86_PAT | 30 | #ifdef CONFIG_X86_PAT |
31 | int __read_mostly pat_enabled = 1; | 31 | int __read_mostly pat_enabled = 1; |
32 | 32 | ||
33 | void __cpuinit pat_disable(char *reason) | 33 | void __cpuinit pat_disable(const char *reason) |
34 | { | 34 | { |
35 | pat_enabled = 0; | 35 | pat_enabled = 0; |
36 | printk(KERN_INFO "%s\n", reason); | 36 | printk(KERN_INFO "%s\n", reason); |
@@ -42,6 +42,11 @@ static int __init nopat(char *str) | |||
42 | return 0; | 42 | return 0; |
43 | } | 43 | } |
44 | early_param("nopat", nopat); | 44 | early_param("nopat", nopat); |
45 | #else | ||
46 | static inline void pat_disable(const char *reason) | ||
47 | { | ||
48 | (void)reason; | ||
49 | } | ||
45 | #endif | 50 | #endif |
46 | 51 | ||
47 | 52 | ||
@@ -78,16 +83,20 @@ void pat_init(void) | |||
78 | if (!pat_enabled) | 83 | if (!pat_enabled) |
79 | return; | 84 | return; |
80 | 85 | ||
81 | /* Paranoia check. */ | 86 | if (!cpu_has_pat) { |
82 | if (!cpu_has_pat && boot_pat_state) { | 87 | if (!boot_pat_state) { |
83 | /* | 88 | pat_disable("PAT not supported by CPU."); |
84 | * If this happens we are on a secondary CPU, but | 89 | return; |
85 | * switched to PAT on the boot CPU. We have no way to | 90 | } else { |
86 | * undo PAT. | 91 | /* |
87 | */ | 92 | * If this happens we are on a secondary CPU, but |
88 | printk(KERN_ERR "PAT enabled, " | 93 | * switched to PAT on the boot CPU. We have no way to |
89 | "but not supported by secondary CPU\n"); | 94 | * undo PAT. |
90 | BUG(); | 95 | */ |
96 | printk(KERN_ERR "PAT enabled, " | ||
97 | "but not supported by secondary CPU\n"); | ||
98 | BUG(); | ||
99 | } | ||
91 | } | 100 | } |
92 | 101 | ||
93 | /* Set PWT to Write-Combining. All other bits stay the same */ | 102 | /* Set PWT to Write-Combining. All other bits stay the same */ |
@@ -333,11 +342,23 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, | |||
333 | req_type & _PAGE_CACHE_MASK); | 342 | req_type & _PAGE_CACHE_MASK); |
334 | } | 343 | } |
335 | 344 | ||
336 | is_range_ram = pagerange_is_ram(start, end); | 345 | if (new_type) |
337 | if (is_range_ram == 1) | 346 | *new_type = actual_type; |
338 | return reserve_ram_pages_type(start, end, req_type, new_type); | 347 | |
339 | else if (is_range_ram < 0) | 348 | /* |
340 | return -EINVAL; | 349 | * For legacy reasons, some parts of the physical address range in the |
350 | * legacy 1MB region is treated as non-RAM (even when listed as RAM in | ||
351 | * the e820 tables). So we will track the memory attributes of this | ||
352 | * legacy 1MB region using the linear memtype_list always. | ||
353 | */ | ||
354 | if (end >= ISA_END_ADDRESS) { | ||
355 | is_range_ram = pagerange_is_ram(start, end); | ||
356 | if (is_range_ram == 1) | ||
357 | return reserve_ram_pages_type(start, end, req_type, | ||
358 | new_type); | ||
359 | else if (is_range_ram < 0) | ||
360 | return -EINVAL; | ||
361 | } | ||
341 | 362 | ||
342 | new = kmalloc(sizeof(struct memtype), GFP_KERNEL); | 363 | new = kmalloc(sizeof(struct memtype), GFP_KERNEL); |
343 | if (!new) | 364 | if (!new) |
@@ -347,9 +368,6 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, | |||
347 | new->end = end; | 368 | new->end = end; |
348 | new->type = actual_type; | 369 | new->type = actual_type; |
349 | 370 | ||
350 | if (new_type) | ||
351 | *new_type = actual_type; | ||
352 | |||
353 | spin_lock(&memtype_lock); | 371 | spin_lock(&memtype_lock); |
354 | 372 | ||
355 | if (cached_entry && start >= cached_start) | 373 | if (cached_entry && start >= cached_start) |
@@ -437,11 +455,19 @@ int free_memtype(u64 start, u64 end) | |||
437 | if (is_ISA_range(start, end - 1)) | 455 | if (is_ISA_range(start, end - 1)) |
438 | return 0; | 456 | return 0; |
439 | 457 | ||
440 | is_range_ram = pagerange_is_ram(start, end); | 458 | /* |
441 | if (is_range_ram == 1) | 459 | * For legacy reasons, some parts of the physical address range in the |
442 | return free_ram_pages_type(start, end); | 460 | * legacy 1MB region is treated as non-RAM (even when listed as RAM in |
443 | else if (is_range_ram < 0) | 461 | * the e820 tables). So we will track the memory attributes of this |
444 | return -EINVAL; | 462 | * legacy 1MB region using the linear memtype_list always. |
463 | */ | ||
464 | if (end >= ISA_END_ADDRESS) { | ||
465 | is_range_ram = pagerange_is_ram(start, end); | ||
466 | if (is_range_ram == 1) | ||
467 | return free_ram_pages_type(start, end); | ||
468 | else if (is_range_ram < 0) | ||
469 | return -EINVAL; | ||
470 | } | ||
445 | 471 | ||
446 | spin_lock(&memtype_lock); | 472 | spin_lock(&memtype_lock); |
447 | list_for_each_entry(entry, &memtype_list, nd) { | 473 | list_for_each_entry(entry, &memtype_list, nd) { |
@@ -601,12 +627,13 @@ void unmap_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot) | |||
601 | * Reserved non RAM regions only and after successful reserve_memtype, | 627 | * Reserved non RAM regions only and after successful reserve_memtype, |
602 | * this func also keeps identity mapping (if any) in sync with this new prot. | 628 | * this func also keeps identity mapping (if any) in sync with this new prot. |
603 | */ | 629 | */ |
604 | static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t vma_prot) | 630 | static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot, |
631 | int strict_prot) | ||
605 | { | 632 | { |
606 | int is_ram = 0; | 633 | int is_ram = 0; |
607 | int id_sz, ret; | 634 | int id_sz, ret; |
608 | unsigned long flags; | 635 | unsigned long flags; |
609 | unsigned long want_flags = (pgprot_val(vma_prot) & _PAGE_CACHE_MASK); | 636 | unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK); |
610 | 637 | ||
611 | is_ram = pagerange_is_ram(paddr, paddr + size); | 638 | is_ram = pagerange_is_ram(paddr, paddr + size); |
612 | 639 | ||
@@ -625,15 +652,24 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t vma_prot) | |||
625 | return ret; | 652 | return ret; |
626 | 653 | ||
627 | if (flags != want_flags) { | 654 | if (flags != want_flags) { |
628 | free_memtype(paddr, paddr + size); | 655 | if (strict_prot || !is_new_memtype_allowed(want_flags, flags)) { |
629 | printk(KERN_ERR | 656 | free_memtype(paddr, paddr + size); |
630 | "%s:%d map pfn expected mapping type %s for %Lx-%Lx, got %s\n", | 657 | printk(KERN_ERR "%s:%d map pfn expected mapping type %s" |
631 | current->comm, current->pid, | 658 | " for %Lx-%Lx, got %s\n", |
632 | cattr_name(want_flags), | 659 | current->comm, current->pid, |
633 | (unsigned long long)paddr, | 660 | cattr_name(want_flags), |
634 | (unsigned long long)(paddr + size), | 661 | (unsigned long long)paddr, |
635 | cattr_name(flags)); | 662 | (unsigned long long)(paddr + size), |
636 | return -EINVAL; | 663 | cattr_name(flags)); |
664 | return -EINVAL; | ||
665 | } | ||
666 | /* | ||
667 | * We allow returning different type than the one requested in | ||
668 | * non strict case. | ||
669 | */ | ||
670 | *vma_prot = __pgprot((pgprot_val(*vma_prot) & | ||
671 | (~_PAGE_CACHE_MASK)) | | ||
672 | flags); | ||
637 | } | 673 | } |
638 | 674 | ||
639 | /* Need to keep identity mapping in sync */ | 675 | /* Need to keep identity mapping in sync */ |
@@ -689,6 +725,7 @@ int track_pfn_vma_copy(struct vm_area_struct *vma) | |||
689 | unsigned long vma_start = vma->vm_start; | 725 | unsigned long vma_start = vma->vm_start; |
690 | unsigned long vma_end = vma->vm_end; | 726 | unsigned long vma_end = vma->vm_end; |
691 | unsigned long vma_size = vma_end - vma_start; | 727 | unsigned long vma_size = vma_end - vma_start; |
728 | pgprot_t pgprot; | ||
692 | 729 | ||
693 | if (!pat_enabled) | 730 | if (!pat_enabled) |
694 | return 0; | 731 | return 0; |
@@ -702,7 +739,8 @@ int track_pfn_vma_copy(struct vm_area_struct *vma) | |||
702 | WARN_ON_ONCE(1); | 739 | WARN_ON_ONCE(1); |
703 | return -EINVAL; | 740 | return -EINVAL; |
704 | } | 741 | } |
705 | return reserve_pfn_range(paddr, vma_size, __pgprot(prot)); | 742 | pgprot = __pgprot(prot); |
743 | return reserve_pfn_range(paddr, vma_size, &pgprot, 1); | ||
706 | } | 744 | } |
707 | 745 | ||
708 | /* reserve entire vma page by page, using pfn and prot from pte */ | 746 | /* reserve entire vma page by page, using pfn and prot from pte */ |
@@ -710,7 +748,8 @@ int track_pfn_vma_copy(struct vm_area_struct *vma) | |||
710 | if (follow_phys(vma, vma_start + i, 0, &prot, &paddr)) | 748 | if (follow_phys(vma, vma_start + i, 0, &prot, &paddr)) |
711 | continue; | 749 | continue; |
712 | 750 | ||
713 | retval = reserve_pfn_range(paddr, PAGE_SIZE, __pgprot(prot)); | 751 | pgprot = __pgprot(prot); |
752 | retval = reserve_pfn_range(paddr, PAGE_SIZE, &pgprot, 1); | ||
714 | if (retval) | 753 | if (retval) |
715 | goto cleanup_ret; | 754 | goto cleanup_ret; |
716 | } | 755 | } |
@@ -741,7 +780,7 @@ cleanup_ret: | |||
741 | * Note that this function can be called with caller trying to map only a | 780 | * Note that this function can be called with caller trying to map only a |
742 | * subrange/page inside the vma. | 781 | * subrange/page inside the vma. |
743 | */ | 782 | */ |
744 | int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t prot, | 783 | int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t *prot, |
745 | unsigned long pfn, unsigned long size) | 784 | unsigned long pfn, unsigned long size) |
746 | { | 785 | { |
747 | int retval = 0; | 786 | int retval = 0; |
@@ -758,14 +797,14 @@ int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t prot, | |||
758 | if (is_linear_pfn_mapping(vma)) { | 797 | if (is_linear_pfn_mapping(vma)) { |
759 | /* reserve the whole chunk starting from vm_pgoff */ | 798 | /* reserve the whole chunk starting from vm_pgoff */ |
760 | paddr = (resource_size_t)vma->vm_pgoff << PAGE_SHIFT; | 799 | paddr = (resource_size_t)vma->vm_pgoff << PAGE_SHIFT; |
761 | return reserve_pfn_range(paddr, vma_size, prot); | 800 | return reserve_pfn_range(paddr, vma_size, prot, 0); |
762 | } | 801 | } |
763 | 802 | ||
764 | /* reserve page by page using pfn and size */ | 803 | /* reserve page by page using pfn and size */ |
765 | base_paddr = (resource_size_t)pfn << PAGE_SHIFT; | 804 | base_paddr = (resource_size_t)pfn << PAGE_SHIFT; |
766 | for (i = 0; i < size; i += PAGE_SIZE) { | 805 | for (i = 0; i < size; i += PAGE_SIZE) { |
767 | paddr = base_paddr + i; | 806 | paddr = base_paddr + i; |
768 | retval = reserve_pfn_range(paddr, PAGE_SIZE, prot); | 807 | retval = reserve_pfn_range(paddr, PAGE_SIZE, prot, 0); |
769 | if (retval) | 808 | if (retval) |
770 | goto cleanup_ret; | 809 | goto cleanup_ret; |
771 | } | 810 | } |
diff --git a/arch/x86/mm/srat_64.c b/arch/x86/mm/srat_64.c index 09737c8af074..15df1baee100 100644 --- a/arch/x86/mm/srat_64.c +++ b/arch/x86/mm/srat_64.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/numa.h> | 21 | #include <asm/numa.h> |
22 | #include <asm/e820.h> | 22 | #include <asm/e820.h> |
23 | #include <asm/genapic.h> | 23 | #include <asm/genapic.h> |
24 | #include <asm/uv/uv.h> | ||
24 | 25 | ||
25 | int acpi_numa __initdata; | 26 | int acpi_numa __initdata; |
26 | 27 | ||
diff --git a/arch/x86/kernel/tlb_64.c b/arch/x86/mm/tlb.c index f8be6f1d2e48..72a6d4ebe34d 100644 --- a/arch/x86/kernel/tlb_64.c +++ b/arch/x86/mm/tlb.c | |||
@@ -1,22 +1,18 @@ | |||
1 | #include <linux/init.h> | 1 | #include <linux/init.h> |
2 | 2 | ||
3 | #include <linux/mm.h> | 3 | #include <linux/mm.h> |
4 | #include <linux/delay.h> | ||
5 | #include <linux/spinlock.h> | 4 | #include <linux/spinlock.h> |
6 | #include <linux/smp.h> | 5 | #include <linux/smp.h> |
7 | #include <linux/kernel_stat.h> | ||
8 | #include <linux/mc146818rtc.h> | ||
9 | #include <linux/interrupt.h> | 6 | #include <linux/interrupt.h> |
7 | #include <linux/module.h> | ||
10 | 8 | ||
11 | #include <asm/mtrr.h> | ||
12 | #include <asm/pgalloc.h> | ||
13 | #include <asm/tlbflush.h> | 9 | #include <asm/tlbflush.h> |
14 | #include <asm/mmu_context.h> | 10 | #include <asm/mmu_context.h> |
15 | #include <asm/proto.h> | 11 | #include <asm/apic.h> |
16 | #include <asm/apicdef.h> | 12 | #include <asm/uv/uv.h> |
17 | #include <asm/idle.h> | 13 | |
18 | #include <asm/uv/uv_hub.h> | 14 | DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) |
19 | #include <asm/uv/uv_bau.h> | 15 | = { &init_mm, 0, }; |
20 | 16 | ||
21 | #include <mach_ipi.h> | 17 | #include <mach_ipi.h> |
22 | /* | 18 | /* |
@@ -33,7 +29,7 @@ | |||
33 | * To avoid global state use 8 different call vectors. | 29 | * To avoid global state use 8 different call vectors. |
34 | * Each CPU uses a specific vector to trigger flushes on other | 30 | * Each CPU uses a specific vector to trigger flushes on other |
35 | * CPUs. Depending on the received vector the target CPUs look into | 31 | * CPUs. Depending on the received vector the target CPUs look into |
36 | * the right per cpu variable for the flush data. | 32 | * the right array slot for the flush data. |
37 | * | 33 | * |
38 | * With more than 8 CPUs they are hashed to the 8 available | 34 | * With more than 8 CPUs they are hashed to the 8 available |
39 | * vectors. The limited global vector space forces us to this right now. | 35 | * vectors. The limited global vector space forces us to this right now. |
@@ -43,18 +39,18 @@ | |||
43 | 39 | ||
44 | union smp_flush_state { | 40 | union smp_flush_state { |
45 | struct { | 41 | struct { |
46 | cpumask_t flush_cpumask; | ||
47 | struct mm_struct *flush_mm; | 42 | struct mm_struct *flush_mm; |
48 | unsigned long flush_va; | 43 | unsigned long flush_va; |
49 | spinlock_t tlbstate_lock; | 44 | spinlock_t tlbstate_lock; |
45 | DECLARE_BITMAP(flush_cpumask, NR_CPUS); | ||
50 | }; | 46 | }; |
51 | char pad[SMP_CACHE_BYTES]; | 47 | char pad[CONFIG_X86_INTERNODE_CACHE_BYTES]; |
52 | } ____cacheline_aligned; | 48 | } ____cacheline_internodealigned_in_smp; |
53 | 49 | ||
54 | /* State is put into the per CPU data section, but padded | 50 | /* State is put into the per CPU data section, but padded |
55 | to a full cache line because other CPUs can access it and we don't | 51 | to a full cache line because other CPUs can access it and we don't |
56 | want false sharing in the per cpu data segment. */ | 52 | want false sharing in the per cpu data segment. */ |
57 | static DEFINE_PER_CPU(union smp_flush_state, flush_state); | 53 | static union smp_flush_state flush_state[NUM_INVALIDATE_TLB_VECTORS]; |
58 | 54 | ||
59 | /* | 55 | /* |
60 | * We cannot call mmdrop() because we are in interrupt context, | 56 | * We cannot call mmdrop() because we are in interrupt context, |
@@ -62,9 +58,9 @@ static DEFINE_PER_CPU(union smp_flush_state, flush_state); | |||
62 | */ | 58 | */ |
63 | void leave_mm(int cpu) | 59 | void leave_mm(int cpu) |
64 | { | 60 | { |
65 | if (read_pda(mmu_state) == TLBSTATE_OK) | 61 | if (percpu_read(cpu_tlbstate.state) == TLBSTATE_OK) |
66 | BUG(); | 62 | BUG(); |
67 | cpu_clear(cpu, read_pda(active_mm)->cpu_vm_mask); | 63 | cpu_clear(cpu, percpu_read(cpu_tlbstate.active_mm)->cpu_vm_mask); |
68 | load_cr3(swapper_pg_dir); | 64 | load_cr3(swapper_pg_dir); |
69 | } | 65 | } |
70 | EXPORT_SYMBOL_GPL(leave_mm); | 66 | EXPORT_SYMBOL_GPL(leave_mm); |
@@ -117,10 +113,20 @@ EXPORT_SYMBOL_GPL(leave_mm); | |||
117 | * Interrupts are disabled. | 113 | * Interrupts are disabled. |
118 | */ | 114 | */ |
119 | 115 | ||
120 | asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs) | 116 | /* |
117 | * FIXME: use of asmlinkage is not consistent. On x86_64 it's noop | ||
118 | * but still used for documentation purpose but the usage is slightly | ||
119 | * inconsistent. On x86_32, asmlinkage is regparm(0) but interrupt | ||
120 | * entry calls in with the first parameter in %eax. Maybe define | ||
121 | * intrlinkage? | ||
122 | */ | ||
123 | #ifdef CONFIG_X86_64 | ||
124 | asmlinkage | ||
125 | #endif | ||
126 | void smp_invalidate_interrupt(struct pt_regs *regs) | ||
121 | { | 127 | { |
122 | int cpu; | 128 | unsigned int cpu; |
123 | int sender; | 129 | unsigned int sender; |
124 | union smp_flush_state *f; | 130 | union smp_flush_state *f; |
125 | 131 | ||
126 | cpu = smp_processor_id(); | 132 | cpu = smp_processor_id(); |
@@ -129,9 +135,9 @@ asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs) | |||
129 | * Use that to determine where the sender put the data. | 135 | * Use that to determine where the sender put the data. |
130 | */ | 136 | */ |
131 | sender = ~regs->orig_ax - INVALIDATE_TLB_VECTOR_START; | 137 | sender = ~regs->orig_ax - INVALIDATE_TLB_VECTOR_START; |
132 | f = &per_cpu(flush_state, sender); | 138 | f = &flush_state[sender]; |
133 | 139 | ||
134 | if (!cpu_isset(cpu, f->flush_cpumask)) | 140 | if (!cpumask_test_cpu(cpu, to_cpumask(f->flush_cpumask))) |
135 | goto out; | 141 | goto out; |
136 | /* | 142 | /* |
137 | * This was a BUG() but until someone can quote me the | 143 | * This was a BUG() but until someone can quote me the |
@@ -142,8 +148,8 @@ asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs) | |||
142 | * BUG(); | 148 | * BUG(); |
143 | */ | 149 | */ |
144 | 150 | ||
145 | if (f->flush_mm == read_pda(active_mm)) { | 151 | if (f->flush_mm == percpu_read(cpu_tlbstate.active_mm)) { |
146 | if (read_pda(mmu_state) == TLBSTATE_OK) { | 152 | if (percpu_read(cpu_tlbstate.state) == TLBSTATE_OK) { |
147 | if (f->flush_va == TLB_FLUSH_ALL) | 153 | if (f->flush_va == TLB_FLUSH_ALL) |
148 | local_flush_tlb(); | 154 | local_flush_tlb(); |
149 | else | 155 | else |
@@ -153,23 +159,21 @@ asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs) | |||
153 | } | 159 | } |
154 | out: | 160 | out: |
155 | ack_APIC_irq(); | 161 | ack_APIC_irq(); |
156 | cpu_clear(cpu, f->flush_cpumask); | 162 | smp_mb__before_clear_bit(); |
163 | cpumask_clear_cpu(cpu, to_cpumask(f->flush_cpumask)); | ||
164 | smp_mb__after_clear_bit(); | ||
157 | inc_irq_stat(irq_tlb_count); | 165 | inc_irq_stat(irq_tlb_count); |
158 | } | 166 | } |
159 | 167 | ||
160 | void native_flush_tlb_others(const cpumask_t *cpumaskp, struct mm_struct *mm, | 168 | static void flush_tlb_others_ipi(const struct cpumask *cpumask, |
161 | unsigned long va) | 169 | struct mm_struct *mm, unsigned long va) |
162 | { | 170 | { |
163 | int sender; | 171 | unsigned int sender; |
164 | union smp_flush_state *f; | 172 | union smp_flush_state *f; |
165 | cpumask_t cpumask = *cpumaskp; | ||
166 | |||
167 | if (is_uv_system() && uv_flush_tlb_others(&cpumask, mm, va)) | ||
168 | return; | ||
169 | 173 | ||
170 | /* Caller has disabled preemption */ | 174 | /* Caller has disabled preemption */ |
171 | sender = smp_processor_id() % NUM_INVALIDATE_TLB_VECTORS; | 175 | sender = smp_processor_id() % NUM_INVALIDATE_TLB_VECTORS; |
172 | f = &per_cpu(flush_state, sender); | 176 | f = &flush_state[sender]; |
173 | 177 | ||
174 | /* | 178 | /* |
175 | * Could avoid this lock when | 179 | * Could avoid this lock when |
@@ -180,7 +184,8 @@ void native_flush_tlb_others(const cpumask_t *cpumaskp, struct mm_struct *mm, | |||
180 | 184 | ||
181 | f->flush_mm = mm; | 185 | f->flush_mm = mm; |
182 | f->flush_va = va; | 186 | f->flush_va = va; |
183 | cpus_or(f->flush_cpumask, cpumask, f->flush_cpumask); | 187 | cpumask_andnot(to_cpumask(f->flush_cpumask), |
188 | cpumask, cpumask_of(smp_processor_id())); | ||
184 | 189 | ||
185 | /* | 190 | /* |
186 | * Make the above memory operations globally visible before | 191 | * Make the above memory operations globally visible before |
@@ -191,9 +196,10 @@ void native_flush_tlb_others(const cpumask_t *cpumaskp, struct mm_struct *mm, | |||
191 | * We have to send the IPI only to | 196 | * We have to send the IPI only to |
192 | * CPUs affected. | 197 | * CPUs affected. |
193 | */ | 198 | */ |
194 | send_IPI_mask(&cpumask, INVALIDATE_TLB_VECTOR_START + sender); | 199 | send_IPI_mask(to_cpumask(f->flush_cpumask), |
200 | INVALIDATE_TLB_VECTOR_START + sender); | ||
195 | 201 | ||
196 | while (!cpus_empty(f->flush_cpumask)) | 202 | while (!cpumask_empty(to_cpumask(f->flush_cpumask))) |
197 | cpu_relax(); | 203 | cpu_relax(); |
198 | 204 | ||
199 | f->flush_mm = NULL; | 205 | f->flush_mm = NULL; |
@@ -201,12 +207,28 @@ void native_flush_tlb_others(const cpumask_t *cpumaskp, struct mm_struct *mm, | |||
201 | spin_unlock(&f->tlbstate_lock); | 207 | spin_unlock(&f->tlbstate_lock); |
202 | } | 208 | } |
203 | 209 | ||
210 | void native_flush_tlb_others(const struct cpumask *cpumask, | ||
211 | struct mm_struct *mm, unsigned long va) | ||
212 | { | ||
213 | if (is_uv_system()) { | ||
214 | unsigned int cpu; | ||
215 | |||
216 | cpu = get_cpu(); | ||
217 | cpumask = uv_flush_tlb_others(cpumask, mm, va, cpu); | ||
218 | if (cpumask) | ||
219 | flush_tlb_others_ipi(cpumask, mm, va); | ||
220 | put_cpu(); | ||
221 | return; | ||
222 | } | ||
223 | flush_tlb_others_ipi(cpumask, mm, va); | ||
224 | } | ||
225 | |||
204 | static int __cpuinit init_smp_flush(void) | 226 | static int __cpuinit init_smp_flush(void) |
205 | { | 227 | { |
206 | int i; | 228 | int i; |
207 | 229 | ||
208 | for_each_possible_cpu(i) | 230 | for (i = 0; i < ARRAY_SIZE(flush_state); i++) |
209 | spin_lock_init(&per_cpu(flush_state, i).tlbstate_lock); | 231 | spin_lock_init(&flush_state[i].tlbstate_lock); |
210 | 232 | ||
211 | return 0; | 233 | return 0; |
212 | } | 234 | } |
@@ -215,25 +237,18 @@ core_initcall(init_smp_flush); | |||
215 | void flush_tlb_current_task(void) | 237 | void flush_tlb_current_task(void) |
216 | { | 238 | { |
217 | struct mm_struct *mm = current->mm; | 239 | struct mm_struct *mm = current->mm; |
218 | cpumask_t cpu_mask; | ||
219 | 240 | ||
220 | preempt_disable(); | 241 | preempt_disable(); |
221 | cpu_mask = mm->cpu_vm_mask; | ||
222 | cpu_clear(smp_processor_id(), cpu_mask); | ||
223 | 242 | ||
224 | local_flush_tlb(); | 243 | local_flush_tlb(); |
225 | if (!cpus_empty(cpu_mask)) | 244 | if (cpumask_any_but(&mm->cpu_vm_mask, smp_processor_id()) < nr_cpu_ids) |
226 | flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL); | 245 | flush_tlb_others(&mm->cpu_vm_mask, mm, TLB_FLUSH_ALL); |
227 | preempt_enable(); | 246 | preempt_enable(); |
228 | } | 247 | } |
229 | 248 | ||
230 | void flush_tlb_mm(struct mm_struct *mm) | 249 | void flush_tlb_mm(struct mm_struct *mm) |
231 | { | 250 | { |
232 | cpumask_t cpu_mask; | ||
233 | |||
234 | preempt_disable(); | 251 | preempt_disable(); |
235 | cpu_mask = mm->cpu_vm_mask; | ||
236 | cpu_clear(smp_processor_id(), cpu_mask); | ||
237 | 252 | ||
238 | if (current->active_mm == mm) { | 253 | if (current->active_mm == mm) { |
239 | if (current->mm) | 254 | if (current->mm) |
@@ -241,8 +256,8 @@ void flush_tlb_mm(struct mm_struct *mm) | |||
241 | else | 256 | else |
242 | leave_mm(smp_processor_id()); | 257 | leave_mm(smp_processor_id()); |
243 | } | 258 | } |
244 | if (!cpus_empty(cpu_mask)) | 259 | if (cpumask_any_but(&mm->cpu_vm_mask, smp_processor_id()) < nr_cpu_ids) |
245 | flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL); | 260 | flush_tlb_others(&mm->cpu_vm_mask, mm, TLB_FLUSH_ALL); |
246 | 261 | ||
247 | preempt_enable(); | 262 | preempt_enable(); |
248 | } | 263 | } |
@@ -250,11 +265,8 @@ void flush_tlb_mm(struct mm_struct *mm) | |||
250 | void flush_tlb_page(struct vm_area_struct *vma, unsigned long va) | 265 | void flush_tlb_page(struct vm_area_struct *vma, unsigned long va) |
251 | { | 266 | { |
252 | struct mm_struct *mm = vma->vm_mm; | 267 | struct mm_struct *mm = vma->vm_mm; |
253 | cpumask_t cpu_mask; | ||
254 | 268 | ||
255 | preempt_disable(); | 269 | preempt_disable(); |
256 | cpu_mask = mm->cpu_vm_mask; | ||
257 | cpu_clear(smp_processor_id(), cpu_mask); | ||
258 | 270 | ||
259 | if (current->active_mm == mm) { | 271 | if (current->active_mm == mm) { |
260 | if (current->mm) | 272 | if (current->mm) |
@@ -263,8 +275,8 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long va) | |||
263 | leave_mm(smp_processor_id()); | 275 | leave_mm(smp_processor_id()); |
264 | } | 276 | } |
265 | 277 | ||
266 | if (!cpus_empty(cpu_mask)) | 278 | if (cpumask_any_but(&mm->cpu_vm_mask, smp_processor_id()) < nr_cpu_ids) |
267 | flush_tlb_others(cpu_mask, mm, va); | 279 | flush_tlb_others(&mm->cpu_vm_mask, mm, va); |
268 | 280 | ||
269 | preempt_enable(); | 281 | preempt_enable(); |
270 | } | 282 | } |
@@ -274,7 +286,7 @@ static void do_flush_tlb_all(void *info) | |||
274 | unsigned long cpu = smp_processor_id(); | 286 | unsigned long cpu = smp_processor_id(); |
275 | 287 | ||
276 | __flush_tlb_all(); | 288 | __flush_tlb_all(); |
277 | if (read_pda(mmu_state) == TLBSTATE_LAZY) | 289 | if (percpu_read(cpu_tlbstate.state) == TLBSTATE_LAZY) |
278 | leave_mm(cpu); | 290 | leave_mm(cpu); |
279 | } | 291 | } |
280 | 292 | ||
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index f884740da318..5ead808dd70c 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -314,17 +314,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | |||
314 | return retval; | 314 | return retval; |
315 | 315 | ||
316 | if (flags != new_flags) { | 316 | if (flags != new_flags) { |
317 | /* | 317 | if (!is_new_memtype_allowed(flags, new_flags)) { |
318 | * Do not fallback to certain memory types with certain | ||
319 | * requested type: | ||
320 | * - request is uncached, return cannot be write-back | ||
321 | * - request is uncached, return cannot be write-combine | ||
322 | * - request is write-combine, return cannot be write-back | ||
323 | */ | ||
324 | if ((flags == _PAGE_CACHE_UC_MINUS && | ||
325 | (new_flags == _PAGE_CACHE_WB)) || | ||
326 | (flags == _PAGE_CACHE_WC && | ||
327 | new_flags == _PAGE_CACHE_WB)) { | ||
328 | free_memtype(addr, addr+len); | 318 | free_memtype(addr, addr+len); |
329 | return -EINVAL; | 319 | return -EINVAL; |
330 | } | 320 | } |
diff --git a/arch/x86/scripts/strip-symbols b/arch/x86/scripts/strip-symbols deleted file mode 100644 index a2f1ccb827c7..000000000000 --- a/arch/x86/scripts/strip-symbols +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | __cpu_vendor_dev_X86_VENDOR_* | ||
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index bea215230b20..6b3f7eef57e3 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -634,35 +634,27 @@ static void xen_flush_tlb_single(unsigned long addr) | |||
634 | preempt_enable(); | 634 | preempt_enable(); |
635 | } | 635 | } |
636 | 636 | ||
637 | static void xen_flush_tlb_others(const cpumask_t *cpus, struct mm_struct *mm, | 637 | static void xen_flush_tlb_others(const struct cpumask *cpus, |
638 | unsigned long va) | 638 | struct mm_struct *mm, unsigned long va) |
639 | { | 639 | { |
640 | struct { | 640 | struct { |
641 | struct mmuext_op op; | 641 | struct mmuext_op op; |
642 | cpumask_t mask; | 642 | DECLARE_BITMAP(mask, NR_CPUS); |
643 | } *args; | 643 | } *args; |
644 | cpumask_t cpumask = *cpus; | ||
645 | struct multicall_space mcs; | 644 | struct multicall_space mcs; |
646 | 645 | ||
647 | /* | 646 | BUG_ON(cpumask_empty(cpus)); |
648 | * A couple of (to be removed) sanity checks: | ||
649 | * | ||
650 | * - current CPU must not be in mask | ||
651 | * - mask must exist :) | ||
652 | */ | ||
653 | BUG_ON(cpus_empty(cpumask)); | ||
654 | BUG_ON(cpu_isset(smp_processor_id(), cpumask)); | ||
655 | BUG_ON(!mm); | 647 | BUG_ON(!mm); |
656 | 648 | ||
657 | /* If a CPU which we ran on has gone down, OK. */ | ||
658 | cpus_and(cpumask, cpumask, cpu_online_map); | ||
659 | if (cpus_empty(cpumask)) | ||
660 | return; | ||
661 | |||
662 | mcs = xen_mc_entry(sizeof(*args)); | 649 | mcs = xen_mc_entry(sizeof(*args)); |
663 | args = mcs.args; | 650 | args = mcs.args; |
664 | args->mask = cpumask; | 651 | args->op.arg2.vcpumask = to_cpumask(args->mask); |
665 | args->op.arg2.vcpumask = &args->mask; | 652 | |
653 | /* Remove us, and any offline CPUS. */ | ||
654 | cpumask_and(to_cpumask(args->mask), cpus, cpu_online_mask); | ||
655 | cpumask_clear_cpu(smp_processor_id(), to_cpumask(args->mask)); | ||
656 | if (unlikely(cpumask_empty(to_cpumask(args->mask)))) | ||
657 | goto issue; | ||
666 | 658 | ||
667 | if (va == TLB_FLUSH_ALL) { | 659 | if (va == TLB_FLUSH_ALL) { |
668 | args->op.cmd = MMUEXT_TLB_FLUSH_MULTI; | 660 | args->op.cmd = MMUEXT_TLB_FLUSH_MULTI; |
@@ -673,6 +665,7 @@ static void xen_flush_tlb_others(const cpumask_t *cpus, struct mm_struct *mm, | |||
673 | 665 | ||
674 | MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF); | 666 | MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF); |
675 | 667 | ||
668 | issue: | ||
676 | xen_mc_issue(PARAVIRT_LAZY_MMU); | 669 | xen_mc_issue(PARAVIRT_LAZY_MMU); |
677 | } | 670 | } |
678 | 671 | ||
@@ -702,17 +695,17 @@ static void xen_write_cr0(unsigned long cr0) | |||
702 | 695 | ||
703 | static void xen_write_cr2(unsigned long cr2) | 696 | static void xen_write_cr2(unsigned long cr2) |
704 | { | 697 | { |
705 | x86_read_percpu(xen_vcpu)->arch.cr2 = cr2; | 698 | percpu_read(xen_vcpu)->arch.cr2 = cr2; |
706 | } | 699 | } |
707 | 700 | ||
708 | static unsigned long xen_read_cr2(void) | 701 | static unsigned long xen_read_cr2(void) |
709 | { | 702 | { |
710 | return x86_read_percpu(xen_vcpu)->arch.cr2; | 703 | return percpu_read(xen_vcpu)->arch.cr2; |
711 | } | 704 | } |
712 | 705 | ||
713 | static unsigned long xen_read_cr2_direct(void) | 706 | static unsigned long xen_read_cr2_direct(void) |
714 | { | 707 | { |
715 | return x86_read_percpu(xen_vcpu_info.arch.cr2); | 708 | return percpu_read(xen_vcpu_info.arch.cr2); |
716 | } | 709 | } |
717 | 710 | ||
718 | static void xen_write_cr4(unsigned long cr4) | 711 | static void xen_write_cr4(unsigned long cr4) |
@@ -725,12 +718,12 @@ static void xen_write_cr4(unsigned long cr4) | |||
725 | 718 | ||
726 | static unsigned long xen_read_cr3(void) | 719 | static unsigned long xen_read_cr3(void) |
727 | { | 720 | { |
728 | return x86_read_percpu(xen_cr3); | 721 | return percpu_read(xen_cr3); |
729 | } | 722 | } |
730 | 723 | ||
731 | static void set_current_cr3(void *v) | 724 | static void set_current_cr3(void *v) |
732 | { | 725 | { |
733 | x86_write_percpu(xen_current_cr3, (unsigned long)v); | 726 | percpu_write(xen_current_cr3, (unsigned long)v); |
734 | } | 727 | } |
735 | 728 | ||
736 | static void __xen_write_cr3(bool kernel, unsigned long cr3) | 729 | static void __xen_write_cr3(bool kernel, unsigned long cr3) |
@@ -755,7 +748,7 @@ static void __xen_write_cr3(bool kernel, unsigned long cr3) | |||
755 | MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); | 748 | MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); |
756 | 749 | ||
757 | if (kernel) { | 750 | if (kernel) { |
758 | x86_write_percpu(xen_cr3, cr3); | 751 | percpu_write(xen_cr3, cr3); |
759 | 752 | ||
760 | /* Update xen_current_cr3 once the batch has actually | 753 | /* Update xen_current_cr3 once the batch has actually |
761 | been submitted. */ | 754 | been submitted. */ |
@@ -771,7 +764,7 @@ static void xen_write_cr3(unsigned long cr3) | |||
771 | 764 | ||
772 | /* Update while interrupts are disabled, so its atomic with | 765 | /* Update while interrupts are disabled, so its atomic with |
773 | respect to ipis */ | 766 | respect to ipis */ |
774 | x86_write_percpu(xen_cr3, cr3); | 767 | percpu_write(xen_cr3, cr3); |
775 | 768 | ||
776 | __xen_write_cr3(true, cr3); | 769 | __xen_write_cr3(true, cr3); |
777 | 770 | ||
@@ -1314,7 +1307,6 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = { | |||
1314 | .ptep_modify_prot_commit = __ptep_modify_prot_commit, | 1307 | .ptep_modify_prot_commit = __ptep_modify_prot_commit, |
1315 | 1308 | ||
1316 | .pte_val = xen_pte_val, | 1309 | .pte_val = xen_pte_val, |
1317 | .pte_flags = native_pte_flags, | ||
1318 | .pgd_val = xen_pgd_val, | 1310 | .pgd_val = xen_pgd_val, |
1319 | 1311 | ||
1320 | .make_pte = xen_make_pte, | 1312 | .make_pte = xen_make_pte, |
@@ -1652,7 +1644,6 @@ asmlinkage void __init xen_start_kernel(void) | |||
1652 | #ifdef CONFIG_X86_64 | 1644 | #ifdef CONFIG_X86_64 |
1653 | /* Disable until direct per-cpu data access. */ | 1645 | /* Disable until direct per-cpu data access. */ |
1654 | have_vcpu_info_placement = 0; | 1646 | have_vcpu_info_placement = 0; |
1655 | x86_64_init_pda(); | ||
1656 | #endif | 1647 | #endif |
1657 | 1648 | ||
1658 | xen_smp_init(); | 1649 | xen_smp_init(); |
diff --git a/arch/x86/xen/irq.c b/arch/x86/xen/irq.c index bb042608c602..2e8271431e1a 100644 --- a/arch/x86/xen/irq.c +++ b/arch/x86/xen/irq.c | |||
@@ -39,7 +39,7 @@ static unsigned long xen_save_fl(void) | |||
39 | struct vcpu_info *vcpu; | 39 | struct vcpu_info *vcpu; |
40 | unsigned long flags; | 40 | unsigned long flags; |
41 | 41 | ||
42 | vcpu = x86_read_percpu(xen_vcpu); | 42 | vcpu = percpu_read(xen_vcpu); |
43 | 43 | ||
44 | /* flag has opposite sense of mask */ | 44 | /* flag has opposite sense of mask */ |
45 | flags = !vcpu->evtchn_upcall_mask; | 45 | flags = !vcpu->evtchn_upcall_mask; |
@@ -62,7 +62,7 @@ static void xen_restore_fl(unsigned long flags) | |||
62 | make sure we're don't switch CPUs between getting the vcpu | 62 | make sure we're don't switch CPUs between getting the vcpu |
63 | pointer and updating the mask. */ | 63 | pointer and updating the mask. */ |
64 | preempt_disable(); | 64 | preempt_disable(); |
65 | vcpu = x86_read_percpu(xen_vcpu); | 65 | vcpu = percpu_read(xen_vcpu); |
66 | vcpu->evtchn_upcall_mask = flags; | 66 | vcpu->evtchn_upcall_mask = flags; |
67 | preempt_enable_no_resched(); | 67 | preempt_enable_no_resched(); |
68 | 68 | ||
@@ -83,7 +83,7 @@ static void xen_irq_disable(void) | |||
83 | make sure we're don't switch CPUs between getting the vcpu | 83 | make sure we're don't switch CPUs between getting the vcpu |
84 | pointer and updating the mask. */ | 84 | pointer and updating the mask. */ |
85 | preempt_disable(); | 85 | preempt_disable(); |
86 | x86_read_percpu(xen_vcpu)->evtchn_upcall_mask = 1; | 86 | percpu_read(xen_vcpu)->evtchn_upcall_mask = 1; |
87 | preempt_enable_no_resched(); | 87 | preempt_enable_no_resched(); |
88 | } | 88 | } |
89 | 89 | ||
@@ -96,7 +96,7 @@ static void xen_irq_enable(void) | |||
96 | the caller is confused and is trying to re-enable interrupts | 96 | the caller is confused and is trying to re-enable interrupts |
97 | on an indeterminate processor. */ | 97 | on an indeterminate processor. */ |
98 | 98 | ||
99 | vcpu = x86_read_percpu(xen_vcpu); | 99 | vcpu = percpu_read(xen_vcpu); |
100 | vcpu->evtchn_upcall_mask = 0; | 100 | vcpu->evtchn_upcall_mask = 0; |
101 | 101 | ||
102 | /* Doesn't matter if we get preempted here, because any | 102 | /* Doesn't matter if we get preempted here, because any |
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 503c240e26c7..98cb9869eb24 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -1063,18 +1063,14 @@ static void drop_other_mm_ref(void *info) | |||
1063 | struct mm_struct *mm = info; | 1063 | struct mm_struct *mm = info; |
1064 | struct mm_struct *active_mm; | 1064 | struct mm_struct *active_mm; |
1065 | 1065 | ||
1066 | #ifdef CONFIG_X86_64 | 1066 | active_mm = percpu_read(cpu_tlbstate.active_mm); |
1067 | active_mm = read_pda(active_mm); | ||
1068 | #else | ||
1069 | active_mm = __get_cpu_var(cpu_tlbstate).active_mm; | ||
1070 | #endif | ||
1071 | 1067 | ||
1072 | if (active_mm == mm) | 1068 | if (active_mm == mm) |
1073 | leave_mm(smp_processor_id()); | 1069 | leave_mm(smp_processor_id()); |
1074 | 1070 | ||
1075 | /* If this cpu still has a stale cr3 reference, then make sure | 1071 | /* If this cpu still has a stale cr3 reference, then make sure |
1076 | it has been flushed. */ | 1072 | it has been flushed. */ |
1077 | if (x86_read_percpu(xen_current_cr3) == __pa(mm->pgd)) { | 1073 | if (percpu_read(xen_current_cr3) == __pa(mm->pgd)) { |
1078 | load_cr3(swapper_pg_dir); | 1074 | load_cr3(swapper_pg_dir); |
1079 | arch_flush_lazy_cpu_mode(); | 1075 | arch_flush_lazy_cpu_mode(); |
1080 | } | 1076 | } |
diff --git a/arch/x86/xen/multicalls.h b/arch/x86/xen/multicalls.h index 858938241616..e786fa7f2615 100644 --- a/arch/x86/xen/multicalls.h +++ b/arch/x86/xen/multicalls.h | |||
@@ -39,7 +39,7 @@ static inline void xen_mc_issue(unsigned mode) | |||
39 | xen_mc_flush(); | 39 | xen_mc_flush(); |
40 | 40 | ||
41 | /* restore flags saved in xen_mc_batch */ | 41 | /* restore flags saved in xen_mc_batch */ |
42 | local_irq_restore(x86_read_percpu(xen_mc_irq_flags)); | 42 | local_irq_restore(percpu_read(xen_mc_irq_flags)); |
43 | } | 43 | } |
44 | 44 | ||
45 | /* Set up a callback to be called when the current batch is flushed */ | 45 | /* Set up a callback to be called when the current batch is flushed */ |
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index c44e2069c7c7..7735e3dd359c 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c | |||
@@ -50,11 +50,7 @@ static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id); | |||
50 | */ | 50 | */ |
51 | static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id) | 51 | static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id) |
52 | { | 52 | { |
53 | #ifdef CONFIG_X86_32 | 53 | inc_irq_stat(irq_resched_count); |
54 | __get_cpu_var(irq_stat).irq_resched_count++; | ||
55 | #else | ||
56 | add_pda(irq_resched_count, 1); | ||
57 | #endif | ||
58 | 54 | ||
59 | return IRQ_HANDLED; | 55 | return IRQ_HANDLED; |
60 | } | 56 | } |
@@ -78,7 +74,7 @@ static __cpuinit void cpu_bringup(void) | |||
78 | xen_setup_cpu_clockevents(); | 74 | xen_setup_cpu_clockevents(); |
79 | 75 | ||
80 | cpu_set(cpu, cpu_online_map); | 76 | cpu_set(cpu, cpu_online_map); |
81 | x86_write_percpu(cpu_state, CPU_ONLINE); | 77 | percpu_write(cpu_state, CPU_ONLINE); |
82 | wmb(); | 78 | wmb(); |
83 | 79 | ||
84 | /* We can take interrupts now: we're officially "up". */ | 80 | /* We can take interrupts now: we're officially "up". */ |
@@ -283,22 +279,10 @@ static int __cpuinit xen_cpu_up(unsigned int cpu) | |||
283 | struct task_struct *idle = idle_task(cpu); | 279 | struct task_struct *idle = idle_task(cpu); |
284 | int rc; | 280 | int rc; |
285 | 281 | ||
286 | #ifdef CONFIG_X86_64 | ||
287 | /* Allocate node local memory for AP pdas */ | ||
288 | WARN_ON(cpu == 0); | ||
289 | if (cpu > 0) { | ||
290 | rc = get_local_pda(cpu); | ||
291 | if (rc) | ||
292 | return rc; | ||
293 | } | ||
294 | #endif | ||
295 | |||
296 | #ifdef CONFIG_X86_32 | ||
297 | init_gdt(cpu); | ||
298 | per_cpu(current_task, cpu) = idle; | 282 | per_cpu(current_task, cpu) = idle; |
283 | #ifdef CONFIG_X86_32 | ||
299 | irq_ctx_init(cpu); | 284 | irq_ctx_init(cpu); |
300 | #else | 285 | #else |
301 | cpu_pda(cpu)->pcurrent = idle; | ||
302 | clear_tsk_thread_flag(idle, TIF_FORK); | 286 | clear_tsk_thread_flag(idle, TIF_FORK); |
303 | #endif | 287 | #endif |
304 | xen_setup_timer(cpu); | 288 | xen_setup_timer(cpu); |
@@ -445,11 +429,7 @@ static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id) | |||
445 | { | 429 | { |
446 | irq_enter(); | 430 | irq_enter(); |
447 | generic_smp_call_function_interrupt(); | 431 | generic_smp_call_function_interrupt(); |
448 | #ifdef CONFIG_X86_32 | 432 | inc_irq_stat(irq_call_count); |
449 | __get_cpu_var(irq_stat).irq_call_count++; | ||
450 | #else | ||
451 | add_pda(irq_call_count, 1); | ||
452 | #endif | ||
453 | irq_exit(); | 433 | irq_exit(); |
454 | 434 | ||
455 | return IRQ_HANDLED; | 435 | return IRQ_HANDLED; |
@@ -459,11 +439,7 @@ static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id) | |||
459 | { | 439 | { |
460 | irq_enter(); | 440 | irq_enter(); |
461 | generic_smp_call_function_single_interrupt(); | 441 | generic_smp_call_function_single_interrupt(); |
462 | #ifdef CONFIG_X86_32 | 442 | inc_irq_stat(irq_call_count); |
463 | __get_cpu_var(irq_stat).irq_call_count++; | ||
464 | #else | ||
465 | add_pda(irq_call_count, 1); | ||
466 | #endif | ||
467 | irq_exit(); | 443 | irq_exit(); |
468 | 444 | ||
469 | return IRQ_HANDLED; | 445 | return IRQ_HANDLED; |
diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index 212ffe012b76..95be7b434724 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | #include <asm/xen/hypercall.h> | 7 | #include <asm/xen/hypercall.h> |
8 | #include <asm/xen/page.h> | 8 | #include <asm/xen/page.h> |
9 | #include <asm/fixmap.h> | ||
9 | 10 | ||
10 | #include "xen-ops.h" | 11 | #include "xen-ops.h" |
11 | #include "mmu.h" | 12 | #include "mmu.h" |
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S index 05794c566e87..d6fc51f4ce85 100644 --- a/arch/x86/xen/xen-asm_64.S +++ b/arch/x86/xen/xen-asm_64.S | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/processor-flags.h> | 17 | #include <asm/processor-flags.h> |
18 | #include <asm/errno.h> | 18 | #include <asm/errno.h> |
19 | #include <asm/segment.h> | 19 | #include <asm/segment.h> |
20 | #include <asm/percpu.h> | ||
20 | 21 | ||
21 | #include <xen/interface/xen.h> | 22 | #include <xen/interface/xen.h> |
22 | 23 | ||
@@ -28,12 +29,10 @@ | |||
28 | 29 | ||
29 | #if 1 | 30 | #if 1 |
30 | /* | 31 | /* |
31 | x86-64 does not yet support direct access to percpu variables | 32 | FIXME: x86_64 now can support direct access to percpu variables |
32 | via a segment override, so we just need to make sure this code | 33 | via a segment override. Update xen accordingly. |
33 | never gets used | ||
34 | */ | 34 | */ |
35 | #define BUG ud2a | 35 | #define BUG ud2a |
36 | #define PER_CPU_VAR(var, off) 0xdeadbeef | ||
37 | #endif | 36 | #endif |
38 | 37 | ||
39 | /* | 38 | /* |
@@ -45,14 +44,14 @@ ENTRY(xen_irq_enable_direct) | |||
45 | BUG | 44 | BUG |
46 | 45 | ||
47 | /* Unmask events */ | 46 | /* Unmask events */ |
48 | movb $0, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) | 47 | movb $0, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask |
49 | 48 | ||
50 | /* Preempt here doesn't matter because that will deal with | 49 | /* Preempt here doesn't matter because that will deal with |
51 | any pending interrupts. The pending check may end up being | 50 | any pending interrupts. The pending check may end up being |
52 | run on the wrong CPU, but that doesn't hurt. */ | 51 | run on the wrong CPU, but that doesn't hurt. */ |
53 | 52 | ||
54 | /* Test for pending */ | 53 | /* Test for pending */ |
55 | testb $0xff, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_pending) | 54 | testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending |
56 | jz 1f | 55 | jz 1f |
57 | 56 | ||
58 | 2: call check_events | 57 | 2: call check_events |
@@ -69,7 +68,7 @@ ENDPATCH(xen_irq_enable_direct) | |||
69 | ENTRY(xen_irq_disable_direct) | 68 | ENTRY(xen_irq_disable_direct) |
70 | BUG | 69 | BUG |
71 | 70 | ||
72 | movb $1, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) | 71 | movb $1, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask |
73 | ENDPATCH(xen_irq_disable_direct) | 72 | ENDPATCH(xen_irq_disable_direct) |
74 | ret | 73 | ret |
75 | ENDPROC(xen_irq_disable_direct) | 74 | ENDPROC(xen_irq_disable_direct) |
@@ -87,7 +86,7 @@ ENDPATCH(xen_irq_disable_direct) | |||
87 | ENTRY(xen_save_fl_direct) | 86 | ENTRY(xen_save_fl_direct) |
88 | BUG | 87 | BUG |
89 | 88 | ||
90 | testb $0xff, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) | 89 | testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask |
91 | setz %ah | 90 | setz %ah |
92 | addb %ah,%ah | 91 | addb %ah,%ah |
93 | ENDPATCH(xen_save_fl_direct) | 92 | ENDPATCH(xen_save_fl_direct) |
@@ -107,13 +106,13 @@ ENTRY(xen_restore_fl_direct) | |||
107 | BUG | 106 | BUG |
108 | 107 | ||
109 | testb $X86_EFLAGS_IF>>8, %ah | 108 | testb $X86_EFLAGS_IF>>8, %ah |
110 | setz PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) | 109 | setz PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask |
111 | /* Preempt here doesn't matter because that will deal with | 110 | /* Preempt here doesn't matter because that will deal with |
112 | any pending interrupts. The pending check may end up being | 111 | any pending interrupts. The pending check may end up being |
113 | run on the wrong CPU, but that doesn't hurt. */ | 112 | run on the wrong CPU, but that doesn't hurt. */ |
114 | 113 | ||
115 | /* check for unmasked and pending */ | 114 | /* check for unmasked and pending */ |
116 | cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_pending) | 115 | cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending |
117 | jz 1f | 116 | jz 1f |
118 | 2: call check_events | 117 | 2: call check_events |
119 | 1: | 118 | 1: |
@@ -195,11 +194,11 @@ RELOC(xen_sysexit, 1b+1) | |||
195 | ENTRY(xen_sysret64) | 194 | ENTRY(xen_sysret64) |
196 | /* We're already on the usermode stack at this point, but still | 195 | /* We're already on the usermode stack at this point, but still |
197 | with the kernel gs, so we can easily switch back */ | 196 | with the kernel gs, so we can easily switch back */ |
198 | movq %rsp, %gs:pda_oldrsp | 197 | movq %rsp, PER_CPU_VAR(old_rsp) |
199 | movq %gs:pda_kernelstack,%rsp | 198 | movq PER_CPU_VAR(kernel_stack),%rsp |
200 | 199 | ||
201 | pushq $__USER_DS | 200 | pushq $__USER_DS |
202 | pushq %gs:pda_oldrsp | 201 | pushq PER_CPU_VAR(old_rsp) |
203 | pushq %r11 | 202 | pushq %r11 |
204 | pushq $__USER_CS | 203 | pushq $__USER_CS |
205 | pushq %rcx | 204 | pushq %rcx |
@@ -212,11 +211,11 @@ RELOC(xen_sysret64, 1b+1) | |||
212 | ENTRY(xen_sysret32) | 211 | ENTRY(xen_sysret32) |
213 | /* We're already on the usermode stack at this point, but still | 212 | /* We're already on the usermode stack at this point, but still |
214 | with the kernel gs, so we can easily switch back */ | 213 | with the kernel gs, so we can easily switch back */ |
215 | movq %rsp, %gs:pda_oldrsp | 214 | movq %rsp, PER_CPU_VAR(old_rsp) |
216 | movq %gs:pda_kernelstack, %rsp | 215 | movq PER_CPU_VAR(kernel_stack), %rsp |
217 | 216 | ||
218 | pushq $__USER32_DS | 217 | pushq $__USER32_DS |
219 | pushq %gs:pda_oldrsp | 218 | pushq PER_CPU_VAR(old_rsp) |
220 | pushq %r11 | 219 | pushq %r11 |
221 | pushq $__USER32_CS | 220 | pushq $__USER32_CS |
222 | pushq %rcx | 221 | pushq %rcx |