aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/Kconfig8
-rw-r--r--arch/alpha/kernel/osf_sys.c1
-rw-r--r--arch/alpha/kernel/setup.c14
-rw-r--r--arch/alpha/kernel/time.c3
-rw-r--r--arch/alpha/lib/ev6-memchr.S2
-rw-r--r--arch/alpha/lib/fpreg.c8
-rw-r--r--arch/alpha/mm/numa.c4
-rw-r--r--arch/arm/Kconfig7
-rw-r--r--arch/arm/common/rtctime.c108
-rw-r--r--arch/arm/lib/copy_template.S2
-rw-r--r--arch/arm/mach-ep93xx/core.c68
-rw-r--r--arch/arm/mach-footbridge/time.c17
-rw-r--r--arch/arm/mach-integrator/core.c46
-rw-r--r--arch/arm/mach-integrator/time.c16
-rw-r--r--arch/arm/mach-omap1/board-netstar.c2
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c2
-rw-r--r--arch/arm/mach-pxa/generic.c6
-rw-r--r--arch/arm/mach-sa1100/generic.c6
-rw-r--r--arch/arm26/Kconfig4
-rw-r--r--arch/arm26/kernel/traps.c12
-rw-r--r--arch/arm26/mm/init.c7
-rw-r--r--arch/cris/Kconfig8
-rw-r--r--arch/cris/kernel/setup.c5
-rw-r--r--arch/frv/Kconfig4
-rw-r--r--arch/frv/mm/mmu-context.c6
-rw-r--r--arch/h8300/Kconfig8
-rw-r--r--arch/i386/Kconfig13
-rw-r--r--arch/i386/Makefile9
-rw-r--r--arch/i386/boot/Makefile36
-rw-r--r--arch/i386/boot/video.S2
-rw-r--r--arch/i386/kernel/acpi/boot.c8
-rw-r--r--arch/i386/kernel/cpu/common.c10
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c16
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.h4
-rw-r--r--arch/i386/kernel/cpu/intel_cacheinfo.c77
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c13
-rw-r--r--arch/i386/kernel/dmi_scan.c90
-rw-r--r--arch/i386/kernel/efi.c23
-rw-r--r--arch/i386/kernel/io_apic.c4
-rw-r--r--arch/i386/kernel/kprobes.c253
-rw-r--r--arch/i386/kernel/microcode.c24
-rw-r--r--arch/i386/kernel/nmi.c9
-rw-r--r--arch/i386/kernel/process.c8
-rw-r--r--arch/i386/kernel/setup.c9
-rw-r--r--arch/i386/kernel/smpboot.c24
-rw-r--r--arch/i386/kernel/syscall_table.S2
-rw-r--r--arch/i386/kernel/timers/timer_pm.c104
-rw-r--r--arch/i386/kernel/traps.c34
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c2
-rw-r--r--arch/i386/mm/discontig.c12
-rw-r--r--arch/i386/mm/pgtable.c2
-rw-r--r--arch/i386/oprofile/nmi_int.c2
-rw-r--r--arch/ia64/Kconfig8
-rw-r--r--arch/ia64/ia32/ia32priv.h4
-rw-r--r--arch/ia64/ia32/sys_ia32.c75
-rw-r--r--arch/ia64/kernel/Makefile3
-rw-r--r--arch/ia64/kernel/acpi.c6
-rw-r--r--arch/ia64/kernel/efi.c62
-rw-r--r--arch/ia64/kernel/kprobes.c51
-rw-r--r--arch/ia64/kernel/mca.c3
-rw-r--r--arch/ia64/kernel/process.c8
-rw-r--r--arch/ia64/kernel/setup.c10
-rw-r--r--arch/ia64/kernel/traps.c6
-rw-r--r--arch/ia64/lib/Makefile2
-rw-r--r--arch/ia64/lib/bitop.c88
-rw-r--r--arch/ia64/mm/Makefile2
-rw-r--r--arch/ia64/mm/discontig.c33
-rw-r--r--arch/ia64/mm/init.c2
-rw-r--r--arch/ia64/mm/ioremap.c43
-rw-r--r--arch/ia64/sn/kernel/setup.c5
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_proc_fs.c39
-rw-r--r--arch/m32r/Kconfig8
-rw-r--r--arch/m32r/kernel/setup.c1
-rw-r--r--arch/m32r/mm/discontig.c7
-rw-r--r--arch/m32r/mm/init.c3
-rw-r--r--arch/m68k/Kconfig4
-rw-r--r--arch/m68k/bvme6000/config.c2
-rw-r--r--arch/m68k/mvme16x/rtc.c4
-rw-r--r--arch/m68knommu/Kconfig8
-rw-r--r--arch/mips/Kconfig8
-rw-r--r--arch/mips/au1000/common/setup.c2
-rw-r--r--arch/mips/ddb5xxx/common/rtc_ds1386.c4
-rw-r--r--arch/mips/dec/time.c51
-rw-r--r--arch/mips/ite-boards/generic/time.c4
-rw-r--r--arch/mips/ite-boards/ivr/init.c3
-rw-r--r--arch/mips/ite-boards/qed-4n-s01b/init.c3
-rw-r--r--arch/mips/jmr3927/common/rtc_ds1742.c4
-rw-r--r--arch/mips/kernel/linux32.c74
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/setup.c9
-rw-r--r--arch/mips/kernel/time.c22
-rw-r--r--arch/mips/lasat/setup.c7
-rw-r--r--arch/mips/lasat/sysctl.c63
-rw-r--r--arch/mips/mips-boards/atlas/atlas_setup.c2
-rw-r--r--arch/mips/mips-boards/generic/memory.c7
-rw-r--r--arch/mips/mips-boards/malta/malta_setup.c2
-rw-r--r--arch/mips/mips-boards/sim/sim_mem.c7
-rw-r--r--arch/mips/mm/init.c4
-rw-r--r--arch/mips/momentum/jaguar_atx/setup.c4
-rw-r--r--arch/mips/momentum/ocelot_3/setup.c38
-rw-r--r--arch/mips/momentum/ocelot_c/setup.c4
-rw-r--r--arch/mips/pmc-sierra/yosemite/setup.c4
-rw-r--r--arch/mips/sgi-ip22/ip22-reset.c2
-rw-r--r--arch/mips/sgi-ip22/ip22-time.c4
-rw-r--r--arch/mips/sgi-ip27/ip27-memory.c3
-rw-r--r--arch/mips/sgi-ip32/ip32-reset.c2
-rw-r--r--arch/mips/sgi-ip32/ip32-setup.c4
-rw-r--r--arch/mips/sibyte/swarm/setup.c8
-rw-r--r--arch/mips/sni/setup.c4
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c4
-rw-r--r--arch/mips/tx4938/common/rtc_rx5c348.c16
-rw-r--r--arch/parisc/Kconfig8
-rw-r--r--arch/parisc/kernel/pdc_chassis.c3
-rw-r--r--arch/parisc/kernel/sys_parisc32.c58
-rw-r--r--arch/parisc/kernel/syscall_table.S2
-rw-r--r--arch/powerpc/Kconfig4
-rw-r--r--arch/powerpc/kernel/kprobes.c66
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--arch/powerpc/kernel/setup_64.c3
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c73
-rw-r--r--arch/powerpc/kernel/traps.c16
-rw-r--r--arch/powerpc/mm/imalloc.c18
-rw-r--r--arch/powerpc/mm/mem.c4
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c22
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c2
-rw-r--r--arch/powerpc/platforms/chrp/time.c22
-rw-r--r--arch/powerpc/platforms/maple/time.c24
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_64.c7
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c10
-rw-r--r--arch/ppc/Kconfig4
-rw-r--r--arch/ppc/kernel/ppc_htab.c2
-rw-r--r--arch/ppc/platforms/chrp_time.c42
-rw-r--r--arch/ppc/platforms/prep_setup.c2
-rw-r--r--arch/s390/Kconfig4
-rw-r--r--arch/s390/crypto/crypt_s390_query.c2
-rw-r--r--arch/s390/kernel/compat_linux.c74
-rw-r--r--arch/s390/kernel/compat_wrapper.S8
-rw-r--r--arch/s390/kernel/process.c11
-rw-r--r--arch/s390/kernel/syscalls.S2
-rw-r--r--arch/sh/Kconfig8
-rw-r--r--arch/sh/boards/mpc1211/rtc.c50
-rw-r--r--arch/sh/boards/sh03/rtc.c13
-rw-r--r--arch/sh/kernel/cpu/rtc.c10
-rw-r--r--arch/sh/kernel/setup.c5
-rw-r--r--arch/sh64/Kconfig8
-rw-r--r--arch/sh64/kernel/setup.c1
-rw-r--r--arch/sh64/kernel/time.c9
-rw-r--r--arch/sparc/Kconfig8
-rw-r--r--arch/sparc64/Kconfig8
-rw-r--r--arch/sparc64/defconfig39
-rw-r--r--arch/sparc64/kernel/kprobes.c69
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c15
-rw-r--r--arch/sparc64/kernel/sys_sparc32.c74
-rw-r--r--arch/sparc64/kernel/systbls.S2
-rw-r--r--arch/sparc64/kernel/time.c16
-rw-r--r--arch/sparc64/kernel/traps.c17
-rw-r--r--arch/sparc64/lib/Makefile2
-rw-r--r--arch/sparc64/lib/find_bit.c127
-rw-r--r--arch/sparc64/mm/fault.c4
-rw-r--r--arch/um/Kconfig.i3865
-rw-r--r--arch/um/Kconfig.x86_645
-rw-r--r--arch/um/drivers/mconsole_kern.c3
-rw-r--r--arch/um/drivers/ubd_kern.c76
-rw-r--r--arch/um/include/irq_user.h15
-rw-r--r--arch/um/include/kern.h2
-rw-r--r--arch/um/include/misc_constants.h6
-rw-r--r--arch/um/include/os.h36
-rw-r--r--arch/um/include/sigio.h3
-rw-r--r--arch/um/include/skas/mode-skas.h1
-rw-r--r--arch/um/include/skas/skas.h1
-rw-r--r--arch/um/include/user_util.h1
-rw-r--r--arch/um/kernel/Makefile9
-rw-r--r--arch/um/kernel/exec_kern.c2
-rw-r--r--arch/um/kernel/irq.c294
-rw-r--r--arch/um/kernel/irq_user.c412
-rw-r--r--arch/um/kernel/physmem.c3
-rw-r--r--arch/um/kernel/sigio_kern.c10
-rw-r--r--arch/um/kernel/smp.c14
-rw-r--r--arch/um/kernel/um_arch.c12
-rw-r--r--arch/um/os-Linux/Makefile13
-rw-r--r--arch/um/os-Linux/irq.c162
-rw-r--r--arch/um/os-Linux/sigio.c (renamed from arch/um/kernel/sigio_user.c)233
-rw-r--r--arch/um/os-Linux/start_up.c128
-rw-r--r--arch/um/os-Linux/tt.c10
-rw-r--r--arch/um/os-Linux/tty_log.c (renamed from arch/um/kernel/tty_log.c)18
-rw-r--r--arch/um/os-Linux/umid.c33
-rw-r--r--arch/um/sys-i386/ptrace.c15
-rw-r--r--arch/um/sys-i386/signal.c59
-rw-r--r--arch/um/sys-i386/user-offsets.c10
-rw-r--r--arch/um/sys-x86_64/ptrace.c22
-rw-r--r--arch/um/sys-x86_64/signal.c56
-rw-r--r--arch/um/sys-x86_64/user-offsets.c6
-rw-r--r--arch/v850/Kconfig6
-rw-r--r--arch/x86_64/Kconfig17
-rw-r--r--arch/x86_64/Makefile17
-rw-r--r--arch/x86_64/boot/Makefile36
-rw-r--r--arch/x86_64/ia32/ia32entry.S4
-rw-r--r--arch/x86_64/ia32/sys_ia32.c77
-rw-r--r--arch/x86_64/kernel/kprobes.c65
-rw-r--r--arch/x86_64/kernel/process.c26
-rw-r--r--arch/x86_64/kernel/setup.c3
-rw-r--r--arch/x86_64/kernel/smpboot.c24
-rw-r--r--arch/x86_64/kernel/time.c41
-rw-r--r--arch/x86_64/kernel/traps.c18
-rw-r--r--arch/x86_64/mm/init.c2
-rw-r--r--arch/x86_64/mm/numa.c15
-rw-r--r--arch/xtensa/Kconfig8
-rw-r--r--arch/xtensa/platform-iss/setup.c2
209 files changed, 2533 insertions, 2511 deletions
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index eedf41bf7057..9bef61b30367 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -25,6 +25,10 @@ config RWSEM_XCHGADD_ALGORITHM
25 bool 25 bool
26 default y 26 default y
27 27
28config GENERIC_FIND_NEXT_BIT
29 bool
30 default y
31
28config GENERIC_CALIBRATE_DELAY 32config GENERIC_CALIBRATE_DELAY
29 bool 33 bool
30 default y 34 default y
@@ -447,6 +451,10 @@ config ALPHA_IRONGATE
447 depends on ALPHA_NAUTILUS 451 depends on ALPHA_NAUTILUS
448 default y 452 default y
449 453
454config GENERIC_HWEIGHT
455 bool
456 default y if !ALPHA_EV6 && !ALPHA_EV67
457
450config ALPHA_AVANTI 458config ALPHA_AVANTI
451 bool 459 bool
452 depends on ALPHA_XL || ALPHA_AVANTI_CH 460 depends on ALPHA_XL || ALPHA_AVANTI_CH
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 7fb14f42a125..31afe3d91ac6 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -821,7 +821,6 @@ osf_setsysinfo(unsigned long op, void __user *buffer, unsigned long nbytes,
821 affects all sorts of things, like timeval and itimerval. */ 821 affects all sorts of things, like timeval and itimerval. */
822 822
823extern struct timezone sys_tz; 823extern struct timezone sys_tz;
824extern int do_adjtimex(struct timex *);
825 824
826struct timeval32 825struct timeval32
827{ 826{
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index b4e5f8ff2b25..dd8769670596 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -34,6 +34,7 @@
34#include <linux/root_dev.h> 34#include <linux/root_dev.h>
35#include <linux/initrd.h> 35#include <linux/initrd.h>
36#include <linux/eisa.h> 36#include <linux/eisa.h>
37#include <linux/pfn.h>
37#ifdef CONFIG_MAGIC_SYSRQ 38#ifdef CONFIG_MAGIC_SYSRQ
38#include <linux/sysrq.h> 39#include <linux/sysrq.h>
39#include <linux/reboot.h> 40#include <linux/reboot.h>
@@ -42,7 +43,7 @@
42#include <asm/setup.h> 43#include <asm/setup.h>
43#include <asm/io.h> 44#include <asm/io.h>
44 45
45extern struct notifier_block *panic_notifier_list; 46extern struct atomic_notifier_head panic_notifier_list;
46static int alpha_panic_event(struct notifier_block *, unsigned long, void *); 47static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
47static struct notifier_block alpha_panic_block = { 48static struct notifier_block alpha_panic_block = {
48 alpha_panic_event, 49 alpha_panic_event,
@@ -241,9 +242,6 @@ reserve_std_resources(void)
241 request_resource(io, standard_io_resources+i); 242 request_resource(io, standard_io_resources+i);
242} 243}
243 244
244#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
245#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
246#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
247#define PFN_MAX PFN_DOWN(0x80000000) 245#define PFN_MAX PFN_DOWN(0x80000000)
248#define for_each_mem_cluster(memdesc, cluster, i) \ 246#define for_each_mem_cluster(memdesc, cluster, i) \
249 for ((cluster) = (memdesc)->cluster, (i) = 0; \ 247 for ((cluster) = (memdesc)->cluster, (i) = 0; \
@@ -472,11 +470,6 @@ page_is_ram(unsigned long pfn)
472 return 0; 470 return 0;
473} 471}
474 472
475#undef PFN_UP
476#undef PFN_DOWN
477#undef PFN_PHYS
478#undef PFN_MAX
479
480void __init 473void __init
481setup_arch(char **cmdline_p) 474setup_arch(char **cmdline_p)
482{ 475{
@@ -507,7 +500,8 @@ setup_arch(char **cmdline_p)
507 } 500 }
508 501
509 /* Register a call for panic conditions. */ 502 /* Register a call for panic conditions. */
510 notifier_chain_register(&panic_notifier_list, &alpha_panic_block); 503 atomic_notifier_chain_register(&panic_notifier_list,
504 &alpha_panic_block);
511 505
512#ifdef CONFIG_ALPHA_GENERIC 506#ifdef CONFIG_ALPHA_GENERIC
513 /* Assume that we've booted from SRM if we haven't booted from MILO. 507 /* Assume that we've booted from SRM if we haven't booted from MILO.
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
index 6b2921be1909..3859749810b4 100644
--- a/arch/alpha/kernel/time.c
+++ b/arch/alpha/kernel/time.c
@@ -314,10 +314,11 @@ time_init(void)
314 if (!est_cycle_freq) 314 if (!est_cycle_freq)
315 est_cycle_freq = validate_cc_value(calibrate_cc_with_pit()); 315 est_cycle_freq = validate_cc_value(calibrate_cc_with_pit());
316 316
317 cc1 = rpcc_after_update_in_progress(); 317 cc1 = rpcc();
318 318
319 /* Calibrate CPU clock -- attempt #2. */ 319 /* Calibrate CPU clock -- attempt #2. */
320 if (!est_cycle_freq) { 320 if (!est_cycle_freq) {
321 cc1 = rpcc_after_update_in_progress();
321 cc2 = rpcc_after_update_in_progress(); 322 cc2 = rpcc_after_update_in_progress();
322 est_cycle_freq = validate_cc_value(cc2 - cc1); 323 est_cycle_freq = validate_cc_value(cc2 - cc1);
323 cc1 = cc2; 324 cc1 = cc2;
diff --git a/arch/alpha/lib/ev6-memchr.S b/arch/alpha/lib/ev6-memchr.S
index a8e843dbcc23..1a5f71b9d8b1 100644
--- a/arch/alpha/lib/ev6-memchr.S
+++ b/arch/alpha/lib/ev6-memchr.S
@@ -84,7 +84,7 @@ $last_quad:
84 beq $2, $not_found # U : U L U L 84 beq $2, $not_found # U : U L U L
85 85
86$found_it: 86$found_it:
87#if defined(__alpha_fix__) && defined(__alpha_cix__) 87#ifdef CONFIG_ALPHA_EV67
88 /* 88 /*
89 * Since we are guaranteed to have set one of the bits, we don't 89 * Since we are guaranteed to have set one of the bits, we don't
90 * have to worry about coming back with a 0x40 out of cttz... 90 * have to worry about coming back with a 0x40 out of cttz...
diff --git a/arch/alpha/lib/fpreg.c b/arch/alpha/lib/fpreg.c
index 97c4d9d7a4d5..05017ba34c3c 100644
--- a/arch/alpha/lib/fpreg.c
+++ b/arch/alpha/lib/fpreg.c
@@ -4,7 +4,7 @@
4 * (C) Copyright 1998 Linus Torvalds 4 * (C) Copyright 1998 Linus Torvalds
5 */ 5 */
6 6
7#if defined(__alpha_cix__) || defined(__alpha_fix__) 7#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
8#define STT(reg,val) asm volatile ("ftoit $f"#reg",%0" : "=r"(val)); 8#define STT(reg,val) asm volatile ("ftoit $f"#reg",%0" : "=r"(val));
9#else 9#else
10#define STT(reg,val) asm volatile ("stt $f"#reg",%0" : "=m"(val)); 10#define STT(reg,val) asm volatile ("stt $f"#reg",%0" : "=m"(val));
@@ -53,7 +53,7 @@ alpha_read_fp_reg (unsigned long reg)
53 return val; 53 return val;
54} 54}
55 55
56#if defined(__alpha_cix__) || defined(__alpha_fix__) 56#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
57#define LDT(reg,val) asm volatile ("itoft %0,$f"#reg : : "r"(val)); 57#define LDT(reg,val) asm volatile ("itoft %0,$f"#reg : : "r"(val));
58#else 58#else
59#define LDT(reg,val) asm volatile ("ldt $f"#reg",%0" : : "m"(val)); 59#define LDT(reg,val) asm volatile ("ldt $f"#reg",%0" : : "m"(val));
@@ -98,7 +98,7 @@ alpha_write_fp_reg (unsigned long reg, unsigned long val)
98 } 98 }
99} 99}
100 100
101#if defined(__alpha_cix__) || defined(__alpha_fix__) 101#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
102#define STS(reg,val) asm volatile ("ftois $f"#reg",%0" : "=r"(val)); 102#define STS(reg,val) asm volatile ("ftois $f"#reg",%0" : "=r"(val));
103#else 103#else
104#define STS(reg,val) asm volatile ("sts $f"#reg",%0" : "=m"(val)); 104#define STS(reg,val) asm volatile ("sts $f"#reg",%0" : "=m"(val));
@@ -147,7 +147,7 @@ alpha_read_fp_reg_s (unsigned long reg)
147 return val; 147 return val;
148} 148}
149 149
150#if defined(__alpha_cix__) || defined(__alpha_fix__) 150#if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
151#define LDS(reg,val) asm volatile ("itofs %0,$f"#reg : : "r"(val)); 151#define LDS(reg,val) asm volatile ("itofs %0,$f"#reg : : "r"(val));
152#else 152#else
153#define LDS(reg,val) asm volatile ("lds $f"#reg",%0" : : "m"(val)); 153#define LDS(reg,val) asm volatile ("lds $f"#reg",%0" : : "m"(val));
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index 6d5251254f68..bf6b65c81bef 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -13,6 +13,7 @@
13#include <linux/bootmem.h> 13#include <linux/bootmem.h>
14#include <linux/swap.h> 14#include <linux/swap.h>
15#include <linux/initrd.h> 15#include <linux/initrd.h>
16#include <linux/pfn.h>
16 17
17#include <asm/hwrpb.h> 18#include <asm/hwrpb.h>
18#include <asm/pgalloc.h> 19#include <asm/pgalloc.h>
@@ -27,9 +28,6 @@ bootmem_data_t node_bdata[MAX_NUMNODES];
27#define DBGDCONT(args...) 28#define DBGDCONT(args...)
28#endif 29#endif
29 30
30#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
31#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
32#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
33#define for_each_mem_cluster(memdesc, cluster, i) \ 31#define for_each_mem_cluster(memdesc, cluster, i) \
34 for ((cluster) = (memdesc)->cluster, (i) = 0; \ 32 for ((cluster) = (memdesc)->cluster, (i) = 0; \
35 (i) < (memdesc)->numclusters; (i)++, (cluster)++) 33 (i) < (memdesc)->numclusters; (i)++, (cluster)++)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 427c72140110..ba46d779ede7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -8,6 +8,7 @@ mainmenu "Linux Kernel Configuration"
8config ARM 8config ARM
9 bool 9 bool
10 default y 10 default y
11 select RTC_LIB
11 help 12 help
12 The ARM series is a line of low-power-consumption RISC chip designs 13 The ARM series is a line of low-power-consumption RISC chip designs
13 licensed by ARM Ltd and targeted at embedded applications and 14 licensed by ARM Ltd and targeted at embedded applications and
@@ -53,6 +54,10 @@ config RWSEM_GENERIC_SPINLOCK
53config RWSEM_XCHGADD_ALGORITHM 54config RWSEM_XCHGADD_ALGORITHM
54 bool 55 bool
55 56
57config GENERIC_HWEIGHT
58 bool
59 default y
60
56config GENERIC_CALIBRATE_DELAY 61config GENERIC_CALIBRATE_DELAY
57 bool 62 bool
58 default y 63 default y
@@ -844,6 +849,8 @@ source "drivers/usb/Kconfig"
844 849
845source "drivers/mmc/Kconfig" 850source "drivers/mmc/Kconfig"
846 851
852source "drivers/rtc/Kconfig"
853
847endmenu 854endmenu
848 855
849source "fs/Kconfig" 856source "fs/Kconfig"
diff --git a/arch/arm/common/rtctime.c b/arch/arm/common/rtctime.c
index e851d86c212c..35c9a64ac14c 100644
--- a/arch/arm/common/rtctime.c
+++ b/arch/arm/common/rtctime.c
@@ -20,6 +20,7 @@
20#include <linux/capability.h> 20#include <linux/capability.h>
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/rtc.h>
23 24
24#include <asm/rtc.h> 25#include <asm/rtc.h>
25#include <asm/semaphore.h> 26#include <asm/semaphore.h>
@@ -42,89 +43,6 @@ static struct rtc_ops *rtc_ops;
42 43
43#define rtc_epoch 1900UL 44#define rtc_epoch 1900UL
44 45
45static const unsigned char days_in_month[] = {
46 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
47};
48
49#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
50#define LEAP_YEAR(year) ((!(year % 4) && (year % 100)) || !(year % 400))
51
52static int month_days(unsigned int month, unsigned int year)
53{
54 return days_in_month[month] + (LEAP_YEAR(year) && month == 1);
55}
56
57/*
58 * Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
59 */
60void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
61{
62 int days, month, year;
63
64 days = time / 86400;
65 time -= days * 86400;
66
67 tm->tm_wday = (days + 4) % 7;
68
69 year = 1970 + days / 365;
70 days -= (year - 1970) * 365
71 + LEAPS_THRU_END_OF(year - 1)
72 - LEAPS_THRU_END_OF(1970 - 1);
73 if (days < 0) {
74 year -= 1;
75 days += 365 + LEAP_YEAR(year);
76 }
77 tm->tm_year = year - 1900;
78 tm->tm_yday = days + 1;
79
80 for (month = 0; month < 11; month++) {
81 int newdays;
82
83 newdays = days - month_days(month, year);
84 if (newdays < 0)
85 break;
86 days = newdays;
87 }
88 tm->tm_mon = month;
89 tm->tm_mday = days + 1;
90
91 tm->tm_hour = time / 3600;
92 time -= tm->tm_hour * 3600;
93 tm->tm_min = time / 60;
94 tm->tm_sec = time - tm->tm_min * 60;
95}
96EXPORT_SYMBOL(rtc_time_to_tm);
97
98/*
99 * Does the rtc_time represent a valid date/time?
100 */
101int rtc_valid_tm(struct rtc_time *tm)
102{
103 if (tm->tm_year < 70 ||
104 tm->tm_mon >= 12 ||
105 tm->tm_mday < 1 ||
106 tm->tm_mday > month_days(tm->tm_mon, tm->tm_year + 1900) ||
107 tm->tm_hour >= 24 ||
108 tm->tm_min >= 60 ||
109 tm->tm_sec >= 60)
110 return -EINVAL;
111
112 return 0;
113}
114EXPORT_SYMBOL(rtc_valid_tm);
115
116/*
117 * Convert Gregorian date to seconds since 01-01-1970 00:00:00.
118 */
119int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time)
120{
121 *time = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
122 tm->tm_hour, tm->tm_min, tm->tm_sec);
123
124 return 0;
125}
126EXPORT_SYMBOL(rtc_tm_to_time);
127
128/* 46/*
129 * Calculate the next alarm time given the requested alarm time mask 47 * Calculate the next alarm time given the requested alarm time mask
130 * and the current time. 48 * and the current time.
@@ -151,13 +69,13 @@ void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc
151 } 69 }
152} 70}
153 71
154static inline int rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm) 72static inline int rtc_arm_read_time(struct rtc_ops *ops, struct rtc_time *tm)
155{ 73{
156 memset(tm, 0, sizeof(struct rtc_time)); 74 memset(tm, 0, sizeof(struct rtc_time));
157 return ops->read_time(tm); 75 return ops->read_time(tm);
158} 76}
159 77
160static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm) 78static inline int rtc_arm_set_time(struct rtc_ops *ops, struct rtc_time *tm)
161{ 79{
162 int ret; 80 int ret;
163 81
@@ -168,7 +86,7 @@ static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm)
168 return ret; 86 return ret;
169} 87}
170 88
171static inline int rtc_read_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm) 89static inline int rtc_arm_read_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm)
172{ 90{
173 int ret = -EINVAL; 91 int ret = -EINVAL;
174 if (ops->read_alarm) { 92 if (ops->read_alarm) {
@@ -178,7 +96,7 @@ static inline int rtc_read_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm)
178 return ret; 96 return ret;
179} 97}
180 98
181static inline int rtc_set_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm) 99static inline int rtc_arm_set_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm)
182{ 100{
183 int ret = -EINVAL; 101 int ret = -EINVAL;
184 if (ops->set_alarm) 102 if (ops->set_alarm)
@@ -266,7 +184,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
266 184
267 switch (cmd) { 185 switch (cmd) {
268 case RTC_ALM_READ: 186 case RTC_ALM_READ:
269 ret = rtc_read_alarm(ops, &alrm); 187 ret = rtc_arm_read_alarm(ops, &alrm);
270 if (ret) 188 if (ret)
271 break; 189 break;
272 ret = copy_to_user(uarg, &alrm.time, sizeof(tm)); 190 ret = copy_to_user(uarg, &alrm.time, sizeof(tm));
@@ -288,11 +206,11 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
288 alrm.time.tm_wday = -1; 206 alrm.time.tm_wday = -1;
289 alrm.time.tm_yday = -1; 207 alrm.time.tm_yday = -1;
290 alrm.time.tm_isdst = -1; 208 alrm.time.tm_isdst = -1;
291 ret = rtc_set_alarm(ops, &alrm); 209 ret = rtc_arm_set_alarm(ops, &alrm);
292 break; 210 break;
293 211
294 case RTC_RD_TIME: 212 case RTC_RD_TIME:
295 ret = rtc_read_time(ops, &tm); 213 ret = rtc_arm_read_time(ops, &tm);
296 if (ret) 214 if (ret)
297 break; 215 break;
298 ret = copy_to_user(uarg, &tm, sizeof(tm)); 216 ret = copy_to_user(uarg, &tm, sizeof(tm));
@@ -310,7 +228,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
310 ret = -EFAULT; 228 ret = -EFAULT;
311 break; 229 break;
312 } 230 }
313 ret = rtc_set_time(ops, &tm); 231 ret = rtc_arm_set_time(ops, &tm);
314 break; 232 break;
315 233
316 case RTC_EPOCH_SET: 234 case RTC_EPOCH_SET:
@@ -341,11 +259,11 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
341 ret = -EFAULT; 259 ret = -EFAULT;
342 break; 260 break;
343 } 261 }
344 ret = rtc_set_alarm(ops, &alrm); 262 ret = rtc_arm_set_alarm(ops, &alrm);
345 break; 263 break;
346 264
347 case RTC_WKALM_RD: 265 case RTC_WKALM_RD:
348 ret = rtc_read_alarm(ops, &alrm); 266 ret = rtc_arm_read_alarm(ops, &alrm);
349 if (ret) 267 if (ret)
350 break; 268 break;
351 ret = copy_to_user(uarg, &alrm, sizeof(alrm)); 269 ret = copy_to_user(uarg, &alrm, sizeof(alrm));
@@ -435,7 +353,7 @@ static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eo
435 struct rtc_time tm; 353 struct rtc_time tm;
436 char *p = page; 354 char *p = page;
437 355
438 if (rtc_read_time(ops, &tm) == 0) { 356 if (rtc_arm_read_time(ops, &tm) == 0) {
439 p += sprintf(p, 357 p += sprintf(p,
440 "rtc_time\t: %02d:%02d:%02d\n" 358 "rtc_time\t: %02d:%02d:%02d\n"
441 "rtc_date\t: %04d-%02d-%02d\n" 359 "rtc_date\t: %04d-%02d-%02d\n"
@@ -445,7 +363,7 @@ static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eo
445 rtc_epoch); 363 rtc_epoch);
446 } 364 }
447 365
448 if (rtc_read_alarm(ops, &alrm) == 0) { 366 if (rtc_arm_read_alarm(ops, &alrm) == 0) {
449 p += sprintf(p, "alrm_time\t: "); 367 p += sprintf(p, "alrm_time\t: ");
450 if ((unsigned int)alrm.time.tm_hour <= 24) 368 if ((unsigned int)alrm.time.tm_hour <= 24)
451 p += sprintf(p, "%02d:", alrm.time.tm_hour); 369 p += sprintf(p, "%02d:", alrm.time.tm_hour);
diff --git a/arch/arm/lib/copy_template.S b/arch/arm/lib/copy_template.S
index 838e435e4922..cab355c0c1f7 100644
--- a/arch/arm/lib/copy_template.S
+++ b/arch/arm/lib/copy_template.S
@@ -236,7 +236,7 @@
236 236
237 237
238/* 238/*
239 * Abort preanble and completion macros. 239 * Abort preamble and completion macros.
240 * If a fixup handler is required then those macros must surround it. 240 * If a fixup handler is required then those macros must surround it.
241 * It is assumed that the fixup code will handle the private part of 241 * It is assumed that the fixup code will handle the private part of
242 * the exit macro. 242 * the exit macro.
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 865427bfad7e..2d892e4daa07 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -30,7 +30,9 @@
30#include <linux/time.h> 30#include <linux/time.h>
31#include <linux/timex.h> 31#include <linux/timex.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/termios.h>
33#include <linux/amba/bus.h> 34#include <linux/amba/bus.h>
35#include <linux/amba/serial.h>
34 36
35#include <asm/types.h> 37#include <asm/types.h>
36#include <asm/setup.h> 38#include <asm/setup.h>
@@ -360,6 +362,68 @@ void __init ep93xx_init_irq(void)
360/************************************************************************* 362/*************************************************************************
361 * EP93xx peripheral handling 363 * EP93xx peripheral handling
362 *************************************************************************/ 364 *************************************************************************/
365#define EP93XX_UART_MCR_OFFSET (0x0100)
366
367static void ep93xx_uart_set_mctrl(struct amba_device *dev,
368 void __iomem *base, unsigned int mctrl)
369{
370 unsigned int mcr;
371
372 mcr = 0;
373 if (!(mctrl & TIOCM_RTS))
374 mcr |= 2;
375 if (!(mctrl & TIOCM_DTR))
376 mcr |= 1;
377
378 __raw_writel(mcr, base + EP93XX_UART_MCR_OFFSET);
379}
380
381static struct amba_pl010_data ep93xx_uart_data = {
382 .set_mctrl = ep93xx_uart_set_mctrl,
383};
384
385static struct amba_device uart1_device = {
386 .dev = {
387 .bus_id = "apb:uart1",
388 .platform_data = &ep93xx_uart_data,
389 },
390 .res = {
391 .start = EP93XX_UART1_PHYS_BASE,
392 .end = EP93XX_UART1_PHYS_BASE + 0x0fff,
393 .flags = IORESOURCE_MEM,
394 },
395 .irq = { IRQ_EP93XX_UART1, NO_IRQ },
396 .periphid = 0x00041010,
397};
398
399static struct amba_device uart2_device = {
400 .dev = {
401 .bus_id = "apb:uart2",
402 .platform_data = &ep93xx_uart_data,
403 },
404 .res = {
405 .start = EP93XX_UART2_PHYS_BASE,
406 .end = EP93XX_UART2_PHYS_BASE + 0x0fff,
407 .flags = IORESOURCE_MEM,
408 },
409 .irq = { IRQ_EP93XX_UART2, NO_IRQ },
410 .periphid = 0x00041010,
411};
412
413static struct amba_device uart3_device = {
414 .dev = {
415 .bus_id = "apb:uart3",
416 .platform_data = &ep93xx_uart_data,
417 },
418 .res = {
419 .start = EP93XX_UART3_PHYS_BASE,
420 .end = EP93XX_UART3_PHYS_BASE + 0x0fff,
421 .flags = IORESOURCE_MEM,
422 },
423 .irq = { IRQ_EP93XX_UART3, NO_IRQ },
424 .periphid = 0x00041010,
425};
426
363void __init ep93xx_init_devices(void) 427void __init ep93xx_init_devices(void)
364{ 428{
365 unsigned int v; 429 unsigned int v;
@@ -371,4 +435,8 @@ void __init ep93xx_init_devices(void)
371 v &= ~EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE; 435 v &= ~EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE;
372 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK); 436 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
373 __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG); 437 __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG);
438
439 amba_device_register(&uart1_device, &iomem_resource);
440 amba_device_register(&uart2_device, &iomem_resource);
441 amba_device_register(&uart3_device, &iomem_resource);
374} 442}
diff --git a/arch/arm/mach-footbridge/time.c b/arch/arm/mach-footbridge/time.c
index 2c64a0b0502e..5d02e95dede3 100644
--- a/arch/arm/mach-footbridge/time.c
+++ b/arch/arm/mach-footbridge/time.c
@@ -34,27 +34,12 @@ static int rtc_base;
34static unsigned long __init get_isa_cmos_time(void) 34static unsigned long __init get_isa_cmos_time(void)
35{ 35{
36 unsigned int year, mon, day, hour, min, sec; 36 unsigned int year, mon, day, hour, min, sec;
37 int i;
38 37
39 // check to see if the RTC makes sense..... 38 // check to see if the RTC makes sense.....
40 if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0) 39 if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0)
41 return mktime(1970, 1, 1, 0, 0, 0); 40 return mktime(1970, 1, 1, 0, 0, 0);
42 41
43 /* The Linux interpretation of the CMOS clock register contents: 42 do {
44 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
45 * RTC registers show the second which has precisely just started.
46 * Let's hope other operating systems interpret the RTC the same way.
47 */
48 /* read RTC exactly on falling edge of update flag */
49 for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
50 if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
51 break;
52
53 for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */
54 if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
55 break;
56
57 do { /* Isn't this overkill ? UIP above should guarantee consistency */
58 sec = CMOS_READ(RTC_SECONDS); 43 sec = CMOS_READ(RTC_SECONDS);
59 min = CMOS_READ(RTC_MINUTES); 44 min = CMOS_READ(RTC_MINUTES);
60 hour = CMOS_READ(RTC_HOURS); 45 hour = CMOS_READ(RTC_HOURS);
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 20071a2767cc..576a5e979c00 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -15,7 +15,9 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/termios.h>
18#include <linux/amba/bus.h> 19#include <linux/amba/bus.h>
20#include <linux/amba/serial.h>
19 21
20#include <asm/hardware.h> 22#include <asm/hardware.h>
21#include <asm/irq.h> 23#include <asm/irq.h>
@@ -28,6 +30,8 @@
28 30
29#include "common.h" 31#include "common.h"
30 32
33static struct amba_pl010_data integrator_uart_data;
34
31static struct amba_device rtc_device = { 35static struct amba_device rtc_device = {
32 .dev = { 36 .dev = {
33 .bus_id = "mb:15", 37 .bus_id = "mb:15",
@@ -44,6 +48,7 @@ static struct amba_device rtc_device = {
44static struct amba_device uart0_device = { 48static struct amba_device uart0_device = {
45 .dev = { 49 .dev = {
46 .bus_id = "mb:16", 50 .bus_id = "mb:16",
51 .platform_data = &integrator_uart_data,
47 }, 52 },
48 .res = { 53 .res = {
49 .start = INTEGRATOR_UART0_BASE, 54 .start = INTEGRATOR_UART0_BASE,
@@ -57,6 +62,7 @@ static struct amba_device uart0_device = {
57static struct amba_device uart1_device = { 62static struct amba_device uart1_device = {
58 .dev = { 63 .dev = {
59 .bus_id = "mb:17", 64 .bus_id = "mb:17",
65 .platform_data = &integrator_uart_data,
60 }, 66 },
61 .res = { 67 .res = {
62 .start = INTEGRATOR_UART1_BASE, 68 .start = INTEGRATOR_UART1_BASE,
@@ -115,6 +121,46 @@ static int __init integrator_init(void)
115 121
116arch_initcall(integrator_init); 122arch_initcall(integrator_init);
117 123
124/*
125 * On the Integrator platform, the port RTS and DTR are provided by
126 * bits in the following SC_CTRLS register bits:
127 * RTS DTR
128 * UART0 7 6
129 * UART1 5 4
130 */
131#define SC_CTRLC (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLC_OFFSET)
132#define SC_CTRLS (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLS_OFFSET)
133
134static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *base, unsigned int mctrl)
135{
136 unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
137
138 if (dev == &uart0_device) {
139 rts_mask = 1 << 4;
140 dtr_mask = 1 << 5;
141 } else {
142 rts_mask = 1 << 6;
143 dtr_mask = 1 << 7;
144 }
145
146 if (mctrl & TIOCM_RTS)
147 ctrlc |= rts_mask;
148 else
149 ctrls |= rts_mask;
150
151 if (mctrl & TIOCM_DTR)
152 ctrlc |= dtr_mask;
153 else
154 ctrls |= dtr_mask;
155
156 __raw_writel(ctrls, SC_CTRLS);
157 __raw_writel(ctrlc, SC_CTRLC);
158}
159
160static struct amba_pl010_data integrator_uart_data = {
161 .set_mctrl = integrator_uart_set_mctrl,
162};
163
118#define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_BASE) + INTEGRATOR_HDR_CTRL_OFFSET 164#define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_BASE) + INTEGRATOR_HDR_CTRL_OFFSET
119 165
120static DEFINE_SPINLOCK(cm_lock); 166static DEFINE_SPINLOCK(cm_lock);
diff --git a/arch/arm/mach-integrator/time.c b/arch/arm/mach-integrator/time.c
index 3c22c16b38bf..bc07f52a6fd7 100644
--- a/arch/arm/mach-integrator/time.c
+++ b/arch/arm/mach-integrator/time.c
@@ -40,13 +40,13 @@ static int integrator_set_rtc(void)
40 return 1; 40 return 1;
41} 41}
42 42
43static int rtc_read_alarm(struct rtc_wkalrm *alrm) 43static int integrator_rtc_read_alarm(struct rtc_wkalrm *alrm)
44{ 44{
45 rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time); 45 rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time);
46 return 0; 46 return 0;
47} 47}
48 48
49static inline int rtc_set_alarm(struct rtc_wkalrm *alrm) 49static inline int integrator_rtc_set_alarm(struct rtc_wkalrm *alrm)
50{ 50{
51 unsigned long time; 51 unsigned long time;
52 int ret; 52 int ret;
@@ -62,7 +62,7 @@ static inline int rtc_set_alarm(struct rtc_wkalrm *alrm)
62 return ret; 62 return ret;
63} 63}
64 64
65static int rtc_read_time(struct rtc_time *tm) 65static int integrator_rtc_read_time(struct rtc_time *tm)
66{ 66{
67 rtc_time_to_tm(readl(rtc_base + RTC_DR), tm); 67 rtc_time_to_tm(readl(rtc_base + RTC_DR), tm);
68 return 0; 68 return 0;
@@ -76,7 +76,7 @@ static int rtc_read_time(struct rtc_time *tm)
76 * edge of the 1Hz clock, we must write the time one second 76 * edge of the 1Hz clock, we must write the time one second
77 * in advance. 77 * in advance.
78 */ 78 */
79static inline int rtc_set_time(struct rtc_time *tm) 79static inline int integrator_rtc_set_time(struct rtc_time *tm)
80{ 80{
81 unsigned long time; 81 unsigned long time;
82 int ret; 82 int ret;
@@ -90,10 +90,10 @@ static inline int rtc_set_time(struct rtc_time *tm)
90 90
91static struct rtc_ops rtc_ops = { 91static struct rtc_ops rtc_ops = {
92 .owner = THIS_MODULE, 92 .owner = THIS_MODULE,
93 .read_time = rtc_read_time, 93 .read_time = integrator_rtc_read_time,
94 .set_time = rtc_set_time, 94 .set_time = integrator_rtc_set_time,
95 .read_alarm = rtc_read_alarm, 95 .read_alarm = integrator_rtc_read_alarm,
96 .set_alarm = rtc_set_alarm, 96 .set_alarm = integrator_rtc_set_alarm,
97}; 97};
98 98
99static irqreturn_t arm_rtc_interrupt(int irq, void *dev_id, 99static irqreturn_t arm_rtc_interrupt(int irq, void *dev_id,
diff --git a/arch/arm/mach-omap1/board-netstar.c b/arch/arm/mach-omap1/board-netstar.c
index 60d5f8a3339c..7520e602d7a2 100644
--- a/arch/arm/mach-omap1/board-netstar.c
+++ b/arch/arm/mach-omap1/board-netstar.c
@@ -141,7 +141,7 @@ static int __init netstar_late_init(void)
141 /* TODO: Setup front panel switch here */ 141 /* TODO: Setup front panel switch here */
142 142
143 /* Setup panic notifier */ 143 /* Setup panic notifier */
144 notifier_chain_register(&panic_notifier_list, &panic_block); 144 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
145 145
146 return 0; 146 return 0;
147} 147}
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index bfd5fdd1a875..52e4a9d69642 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -235,7 +235,7 @@ static struct notifier_block panic_block = {
235static int __init voiceblue_setup(void) 235static int __init voiceblue_setup(void)
236{ 236{
237 /* Setup panic notifier */ 237 /* Setup panic notifier */
238 notifier_chain_register(&panic_notifier_list, &panic_block); 238 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
239 239
240 return 0; 240 return 0;
241} 241}
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 9b48a90aefce..5efa84749f37 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -319,6 +319,11 @@ void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
319 pxaficp_device.dev.platform_data = info; 319 pxaficp_device.dev.platform_data = info;
320} 320}
321 321
322static struct platform_device pxartc_device = {
323 .name = "sa1100-rtc",
324 .id = -1,
325};
326
322static struct platform_device *devices[] __initdata = { 327static struct platform_device *devices[] __initdata = {
323 &pxamci_device, 328 &pxamci_device,
324 &udc_device, 329 &udc_device,
@@ -329,6 +334,7 @@ static struct platform_device *devices[] __initdata = {
329 &pxaficp_device, 334 &pxaficp_device,
330 &i2c_device, 335 &i2c_device,
331 &i2s_device, 336 &i2s_device,
337 &pxartc_device,
332}; 338};
333 339
334static int __init pxa_init(void) 340static int __init pxa_init(void)
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 2abdc419e984..9ea71551fc04 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -324,6 +324,11 @@ void sa11x0_set_irda_data(struct irda_platform_data *irda)
324 sa11x0ir_device.dev.platform_data = irda; 324 sa11x0ir_device.dev.platform_data = irda;
325} 325}
326 326
327static struct platform_device sa11x0rtc_device = {
328 .name = "sa1100-rtc",
329 .id = -1,
330};
331
327static struct platform_device *sa11x0_devices[] __initdata = { 332static struct platform_device *sa11x0_devices[] __initdata = {
328 &sa11x0udc_device, 333 &sa11x0udc_device,
329 &sa11x0uart1_device, 334 &sa11x0uart1_device,
@@ -333,6 +338,7 @@ static struct platform_device *sa11x0_devices[] __initdata = {
333 &sa11x0pcmcia_device, 338 &sa11x0pcmcia_device,
334 &sa11x0fb_device, 339 &sa11x0fb_device,
335 &sa11x0mtd_device, 340 &sa11x0mtd_device,
341 &sa11x0rtc_device,
336}; 342};
337 343
338static int __init sa1100_init(void) 344static int __init sa1100_init(void)
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
index dee23d87fc5a..cf4ebf4c274d 100644
--- a/arch/arm26/Kconfig
+++ b/arch/arm26/Kconfig
@@ -41,6 +41,10 @@ config RWSEM_GENERIC_SPINLOCK
41config RWSEM_XCHGADD_ALGORITHM 41config RWSEM_XCHGADD_ALGORITHM
42 bool 42 bool
43 43
44config GENERIC_HWEIGHT
45 bool
46 default y
47
44config GENERIC_CALIBRATE_DELAY 48config GENERIC_CALIBRATE_DELAY
45 bool 49 bool
46 default y 50 default y
diff --git a/arch/arm26/kernel/traps.c b/arch/arm26/kernel/traps.c
index 5847ea5d7747..a79de041b50e 100644
--- a/arch/arm26/kernel/traps.c
+++ b/arch/arm26/kernel/traps.c
@@ -34,7 +34,7 @@
34#include <asm/system.h> 34#include <asm/system.h>
35#include <asm/uaccess.h> 35#include <asm/uaccess.h>
36#include <asm/unistd.h> 36#include <asm/unistd.h>
37#include <asm/semaphore.h> 37#include <linux/mutex.h>
38 38
39#include "ptrace.h" 39#include "ptrace.h"
40 40
@@ -207,19 +207,19 @@ void die_if_kernel(const char *str, struct pt_regs *regs, int err)
207 die(str, regs, err); 207 die(str, regs, err);
208} 208}
209 209
210static DECLARE_MUTEX(undef_sem); 210static DEFINE_MUTEX(undef_mutex);
211static int (*undef_hook)(struct pt_regs *); 211static int (*undef_hook)(struct pt_regs *);
212 212
213int request_undef_hook(int (*fn)(struct pt_regs *)) 213int request_undef_hook(int (*fn)(struct pt_regs *))
214{ 214{
215 int ret = -EBUSY; 215 int ret = -EBUSY;
216 216
217 down(&undef_sem); 217 mutex_lock(&undef_mutex);
218 if (undef_hook == NULL) { 218 if (undef_hook == NULL) {
219 undef_hook = fn; 219 undef_hook = fn;
220 ret = 0; 220 ret = 0;
221 } 221 }
222 up(&undef_sem); 222 mutex_unlock(&undef_mutex);
223 223
224 return ret; 224 return ret;
225} 225}
@@ -228,12 +228,12 @@ int release_undef_hook(int (*fn)(struct pt_regs *))
228{ 228{
229 int ret = -EINVAL; 229 int ret = -EINVAL;
230 230
231 down(&undef_sem); 231 mutex_lock(&undef_mutex);
232 if (undef_hook == fn) { 232 if (undef_hook == fn) {
233 undef_hook = NULL; 233 undef_hook = NULL;
234 ret = 0; 234 ret = 0;
235 } 235 }
236 up(&undef_sem); 236 mutex_unlock(&undef_mutex);
237 237
238 return ret; 238 return ret;
239} 239}
diff --git a/arch/arm26/mm/init.c b/arch/arm26/mm/init.c
index e3ecaa453747..7da8a5205678 100644
--- a/arch/arm26/mm/init.c
+++ b/arch/arm26/mm/init.c
@@ -23,6 +23,7 @@
23#include <linux/initrd.h> 23#include <linux/initrd.h>
24#include <linux/bootmem.h> 24#include <linux/bootmem.h>
25#include <linux/blkdev.h> 25#include <linux/blkdev.h>
26#include <linux/pfn.h>
26 27
27#include <asm/segment.h> 28#include <asm/segment.h>
28#include <asm/mach-types.h> 29#include <asm/mach-types.h>
@@ -101,12 +102,6 @@ struct node_info {
101 int bootmap_pages; 102 int bootmap_pages;
102}; 103};
103 104
104#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
105#define PFN_UP(x) (PAGE_ALIGN(x) >> PAGE_SHIFT)
106#define PFN_SIZE(x) ((x) >> PAGE_SHIFT)
107#define PFN_RANGE(s,e) PFN_SIZE(PAGE_ALIGN((unsigned long)(e)) - \
108 (((unsigned long)(s)) & PAGE_MASK))
109
110/* 105/*
111 * FIXME: We really want to avoid allocating the bootmap bitmap 106 * FIXME: We really want to avoid allocating the bootmap bitmap
112 * over the top of the initrd. Hopefully, this is located towards 107 * over the top of the initrd. Hopefully, this is located towards
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index b83261949737..856b665020e7 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -16,6 +16,14 @@ config RWSEM_GENERIC_SPINLOCK
16config RWSEM_XCHGADD_ALGORITHM 16config RWSEM_XCHGADD_ALGORITHM
17 bool 17 bool
18 18
19config GENERIC_FIND_NEXT_BIT
20 bool
21 default y
22
23config GENERIC_HWEIGHT
24 bool
25 default y
26
19config GENERIC_CALIBRATE_DELAY 27config GENERIC_CALIBRATE_DELAY
20 bool 28 bool
21 default y 29 default y
diff --git a/arch/cris/kernel/setup.c b/arch/cris/kernel/setup.c
index 1ba57efff60d..619a6eefd893 100644
--- a/arch/cris/kernel/setup.c
+++ b/arch/cris/kernel/setup.c
@@ -18,6 +18,7 @@
18#include <linux/seq_file.h> 18#include <linux/seq_file.h>
19#include <linux/tty.h> 19#include <linux/tty.h>
20#include <linux/utsname.h> 20#include <linux/utsname.h>
21#include <linux/pfn.h>
21 22
22#include <asm/setup.h> 23#include <asm/setup.h>
23 24
@@ -88,10 +89,6 @@ setup_arch(char **cmdline_p)
88 init_mm.end_data = (unsigned long) &_edata; 89 init_mm.end_data = (unsigned long) &_edata;
89 init_mm.brk = (unsigned long) &_end; 90 init_mm.brk = (unsigned long) &_end;
90 91
91#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
92#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
93#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
94
95 /* min_low_pfn points to the start of DRAM, start_pfn points 92 /* min_low_pfn points to the start of DRAM, start_pfn points
96 * to the first DRAM pages after the kernel, and max_low_pfn 93 * to the first DRAM pages after the kernel, and max_low_pfn
97 * to the end of DRAM. 94 * to the end of DRAM.
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index e08383712370..95a3892b8d1b 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -17,6 +17,10 @@ config GENERIC_FIND_NEXT_BIT
17 bool 17 bool
18 default y 18 default y
19 19
20config GENERIC_HWEIGHT
21 bool
22 default y
23
20config GENERIC_CALIBRATE_DELAY 24config GENERIC_CALIBRATE_DELAY
21 bool 25 bool
22 default n 26 default n
diff --git a/arch/frv/mm/mmu-context.c b/arch/frv/mm/mmu-context.c
index f2c6866fc88b..1530a4111e6d 100644
--- a/arch/frv/mm/mmu-context.c
+++ b/arch/frv/mm/mmu-context.c
@@ -54,9 +54,9 @@ static unsigned get_cxn(mm_context_t *ctx)
54 /* find the first unallocated context number 54 /* find the first unallocated context number
55 * - 0 is reserved for the kernel 55 * - 0 is reserved for the kernel
56 */ 56 */
57 cxn = find_next_zero_bit(&cxn_bitmap, NR_CXN, 1); 57 cxn = find_next_zero_bit(cxn_bitmap, NR_CXN, 1);
58 if (cxn < NR_CXN) { 58 if (cxn < NR_CXN) {
59 set_bit(cxn, &cxn_bitmap); 59 set_bit(cxn, cxn_bitmap);
60 } 60 }
61 else { 61 else {
62 /* none remaining - need to steal someone else's cxn */ 62 /* none remaining - need to steal someone else's cxn */
@@ -138,7 +138,7 @@ void destroy_context(struct mm_struct *mm)
138 cxn_pinned = -1; 138 cxn_pinned = -1;
139 139
140 list_del_init(&ctx->id_link); 140 list_del_init(&ctx->id_link);
141 clear_bit(ctx->id, &cxn_bitmap); 141 clear_bit(ctx->id, cxn_bitmap);
142 __flush_tlb_mm(ctx->id); 142 __flush_tlb_mm(ctx->id);
143 ctx->id = 0; 143 ctx->id = 0;
144 } 144 }
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 98308b018a35..cabf0bfffc53 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -29,6 +29,14 @@ config RWSEM_XCHGADD_ALGORITHM
29 bool 29 bool
30 default n 30 default n
31 31
32config GENERIC_FIND_NEXT_BIT
33 bool
34 default y
35
36config GENERIC_HWEIGHT
37 bool
38 default y
39
32config GENERIC_CALIBRATE_DELAY 40config GENERIC_CALIBRATE_DELAY
33 bool 41 bool
34 default y 42 default y
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index b008fb0cd7b7..f17bd1d2707e 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -37,6 +37,10 @@ config GENERIC_IOMAP
37 bool 37 bool
38 default y 38 default y
39 39
40config GENERIC_HWEIGHT
41 bool
42 default y
43
40config ARCH_MAY_HAVE_PC_FDC 44config ARCH_MAY_HAVE_PC_FDC
41 bool 45 bool
42 default y 46 default y
@@ -227,6 +231,15 @@ config SCHED_SMT
227 cost of slightly increased overhead in some places. If unsure say 231 cost of slightly increased overhead in some places. If unsure say
228 N here. 232 N here.
229 233
234config SCHED_MC
235 bool "Multi-core scheduler support"
236 depends on SMP
237 default y
238 help
239 Multi-core scheduler support improves the CPU scheduler's decision
240 making when dealing with multi-core CPU chips at a cost of slightly
241 increased overhead in some places. If unsure say N here.
242
230source "kernel/Kconfig.preempt" 243source "kernel/Kconfig.preempt"
231 244
232config X86_UP_APIC 245config X86_UP_APIC
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index c848a5b30391..3e4adb1e2244 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -103,7 +103,7 @@ AFLAGS += $(mflags-y)
103boot := arch/i386/boot 103boot := arch/i386/boot
104 104
105PHONY += zImage bzImage compressed zlilo bzlilo \ 105PHONY += zImage bzImage compressed zlilo bzlilo \
106 zdisk bzdisk fdimage fdimage144 fdimage288 install 106 zdisk bzdisk fdimage fdimage144 fdimage288 isoimage install
107 107
108all: bzImage 108all: bzImage
109 109
@@ -122,7 +122,7 @@ zlilo bzlilo: vmlinux
122zdisk bzdisk: vmlinux 122zdisk bzdisk: vmlinux
123 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) zdisk 123 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) zdisk
124 124
125fdimage fdimage144 fdimage288: vmlinux 125fdimage fdimage144 fdimage288 isoimage: vmlinux
126 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@ 126 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@
127 127
128install: 128install:
@@ -139,6 +139,9 @@ define archhelp
139 echo ' install to $$(INSTALL_PATH) and run lilo' 139 echo ' install to $$(INSTALL_PATH) and run lilo'
140 echo ' bzdisk - Create a boot floppy in /dev/fd0' 140 echo ' bzdisk - Create a boot floppy in /dev/fd0'
141 echo ' fdimage - Create a boot floppy image' 141 echo ' fdimage - Create a boot floppy image'
142 echo ' isoimage - Create a boot CD-ROM image'
142endef 143endef
143 144
144CLEAN_FILES += arch/$(ARCH)/boot/fdimage arch/$(ARCH)/boot/mtools.conf 145CLEAN_FILES += arch/$(ARCH)/boot/fdimage \
146 arch/$(ARCH)/boot/image.iso \
147 arch/$(ARCH)/boot/mtools.conf
diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
index f136752563b1..33e55476381b 100644
--- a/arch/i386/boot/Makefile
+++ b/arch/i386/boot/Makefile
@@ -62,8 +62,12 @@ $(obj)/setup $(obj)/bootsect: %: %.o FORCE
62$(obj)/compressed/vmlinux: FORCE 62$(obj)/compressed/vmlinux: FORCE
63 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@ 63 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
64 64
65# Set this if you want to pass append arguments to the zdisk/fdimage kernel 65# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
66FDARGS = 66FDARGS =
67# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
68FDINITRD =
69
70image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
67 71
68$(obj)/mtools.conf: $(src)/mtools.conf.in 72$(obj)/mtools.conf: $(src)/mtools.conf.in
69 sed -e 's|@OBJ@|$(obj)|g' < $< > $@ 73 sed -e 's|@OBJ@|$(obj)|g' < $< > $@
@@ -72,8 +76,11 @@ $(obj)/mtools.conf: $(src)/mtools.conf.in
72zdisk: $(BOOTIMAGE) $(obj)/mtools.conf 76zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
73 MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync 77 MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
74 syslinux /dev/fd0 ; sync 78 syslinux /dev/fd0 ; sync
75 echo 'default linux $(FDARGS)' | \ 79 echo '$(image_cmdline)' | \
76 MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg 80 MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
81 if [ -f '$(FDINITRD)' ] ; then \
82 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
83 fi
77 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync 84 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
78 85
79# These require being root or having syslinux 2.02 or higher installed 86# These require being root or having syslinux 2.02 or higher installed
@@ -81,18 +88,39 @@ fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
81 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440 88 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
82 MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync 89 MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
83 syslinux $(obj)/fdimage ; sync 90 syslinux $(obj)/fdimage ; sync
84 echo 'default linux $(FDARGS)' | \ 91 echo '$(image_cmdline)' | \
85 MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg 92 MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
93 if [ -f '$(FDINITRD)' ] ; then \
94 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
95 fi
86 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync 96 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
87 97
88fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf 98fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
89 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880 99 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
90 MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync 100 MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
91 syslinux $(obj)/fdimage ; sync 101 syslinux $(obj)/fdimage ; sync
92 echo 'default linux $(FDARGS)' | \ 102 echo '$(image_cmdline)' | \
93 MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg 103 MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
104 if [ -f '$(FDINITRD)' ] ; then \
105 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
106 fi
94 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync 107 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
95 108
109isoimage: $(BOOTIMAGE)
110 -rm -rf $(obj)/isoimage
111 mkdir $(obj)/isoimage
112 cp `echo /usr/lib*/syslinux/isolinux.bin | awk '{ print $1; }'` \
113 $(obj)/isoimage
114 cp $(BOOTIMAGE) $(obj)/isoimage/linux
115 echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
116 if [ -f '$(FDINITRD)' ] ; then \
117 cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
118 fi
119 mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
120 -no-emul-boot -boot-load-size 4 -boot-info-table \
121 $(obj)/isoimage
122 rm -rf $(obj)/isoimage
123
96zlilo: $(BOOTIMAGE) 124zlilo: $(BOOTIMAGE)
97 if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi 125 if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
98 if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi 126 if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S
index 2ac40c8244c4..0000a2674537 100644
--- a/arch/i386/boot/video.S
+++ b/arch/i386/boot/video.S
@@ -1924,6 +1924,7 @@ skip10: movb %ah, %al
1924 ret 1924 ret
1925 1925
1926store_edid: 1926store_edid:
1927#ifdef CONFIG_FB_FIRMWARE_EDID
1927 pushw %es # just save all registers 1928 pushw %es # just save all registers
1928 pushw %ax 1929 pushw %ax
1929 pushw %bx 1930 pushw %bx
@@ -1954,6 +1955,7 @@ store_edid:
1954 popw %bx 1955 popw %bx
1955 popw %ax 1956 popw %ax
1956 popw %es 1957 popw %es
1958#endif
1957 ret 1959 ret
1958 1960
1959# VIDEO_SELECT-only variables 1961# VIDEO_SELECT-only variables
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index f1a21945963d..033066176b3e 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -668,10 +668,10 @@ unsigned long __init acpi_find_rsdp(void)
668 unsigned long rsdp_phys = 0; 668 unsigned long rsdp_phys = 0;
669 669
670 if (efi_enabled) { 670 if (efi_enabled) {
671 if (efi.acpi20) 671 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
672 return __pa(efi.acpi20); 672 return efi.acpi20;
673 else if (efi.acpi) 673 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
674 return __pa(efi.acpi); 674 return efi.acpi;
675 } 675 }
676 /* 676 /*
677 * Scan memory looking for the RSDP signature. First search EBDA (low 677 * Scan memory looking for the RSDP signature. First search EBDA (low
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 7e3d6b6a4e96..a06a49075f10 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -266,7 +266,7 @@ static void __init early_cpu_detect(void)
266void __cpuinit generic_identify(struct cpuinfo_x86 * c) 266void __cpuinit generic_identify(struct cpuinfo_x86 * c)
267{ 267{
268 u32 tfms, xlvl; 268 u32 tfms, xlvl;
269 int junk; 269 int ebx;
270 270
271 if (have_cpuid_p()) { 271 if (have_cpuid_p()) {
272 /* Get vendor name */ 272 /* Get vendor name */
@@ -282,7 +282,7 @@ void __cpuinit generic_identify(struct cpuinfo_x86 * c)
282 /* Intel-defined flags: level 0x00000001 */ 282 /* Intel-defined flags: level 0x00000001 */
283 if ( c->cpuid_level >= 0x00000001 ) { 283 if ( c->cpuid_level >= 0x00000001 ) {
284 u32 capability, excap; 284 u32 capability, excap;
285 cpuid(0x00000001, &tfms, &junk, &excap, &capability); 285 cpuid(0x00000001, &tfms, &ebx, &excap, &capability);
286 c->x86_capability[0] = capability; 286 c->x86_capability[0] = capability;
287 c->x86_capability[4] = excap; 287 c->x86_capability[4] = excap;
288 c->x86 = (tfms >> 8) & 15; 288 c->x86 = (tfms >> 8) & 15;
@@ -292,6 +292,11 @@ void __cpuinit generic_identify(struct cpuinfo_x86 * c)
292 if (c->x86 >= 0x6) 292 if (c->x86 >= 0x6)
293 c->x86_model += ((tfms >> 16) & 0xF) << 4; 293 c->x86_model += ((tfms >> 16) & 0xF) << 4;
294 c->x86_mask = tfms & 15; 294 c->x86_mask = tfms & 15;
295#ifdef CONFIG_SMP
296 c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0);
297#else
298 c->apicid = (ebx >> 24) & 0xFF;
299#endif
295 } else { 300 } else {
296 /* Have CPUID level 0 only - unheard of */ 301 /* Have CPUID level 0 only - unheard of */
297 c->x86 = 4; 302 c->x86 = 4;
@@ -474,7 +479,6 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
474 479
475 cpuid(1, &eax, &ebx, &ecx, &edx); 480 cpuid(1, &eax, &ebx, &ecx, &edx);
476 481
477 c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0);
478 482
479 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)) 483 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
480 return; 484 return;
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index e5bc06480ff9..712a26bd4457 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -40,6 +40,7 @@
40 40
41#ifdef CONFIG_X86_POWERNOW_K8_ACPI 41#ifdef CONFIG_X86_POWERNOW_K8_ACPI
42#include <linux/acpi.h> 42#include <linux/acpi.h>
43#include <linux/mutex.h>
43#include <acpi/processor.h> 44#include <acpi/processor.h>
44#endif 45#endif
45 46
@@ -49,7 +50,7 @@
49#include "powernow-k8.h" 50#include "powernow-k8.h"
50 51
51/* serialize freq changes */ 52/* serialize freq changes */
52static DECLARE_MUTEX(fidvid_sem); 53static DEFINE_MUTEX(fidvid_mutex);
53 54
54static struct powernow_k8_data *powernow_data[NR_CPUS]; 55static struct powernow_k8_data *powernow_data[NR_CPUS];
55 56
@@ -943,17 +944,17 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
943 if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate)) 944 if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate))
944 goto err_out; 945 goto err_out;
945 946
946 down(&fidvid_sem); 947 mutex_lock(&fidvid_mutex);
947 948
948 powernow_k8_acpi_pst_values(data, newstate); 949 powernow_k8_acpi_pst_values(data, newstate);
949 950
950 if (transition_frequency(data, newstate)) { 951 if (transition_frequency(data, newstate)) {
951 printk(KERN_ERR PFX "transition frequency failed\n"); 952 printk(KERN_ERR PFX "transition frequency failed\n");
952 ret = 1; 953 ret = 1;
953 up(&fidvid_sem); 954 mutex_unlock(&fidvid_mutex);
954 goto err_out; 955 goto err_out;
955 } 956 }
956 up(&fidvid_sem); 957 mutex_unlock(&fidvid_mutex);
957 958
958 pol->cur = find_khz_freq_from_fid(data->currfid); 959 pol->cur = find_khz_freq_from_fid(data->currfid);
959 ret = 0; 960 ret = 0;
@@ -1094,10 +1095,15 @@ static int __devexit powernowk8_cpu_exit (struct cpufreq_policy *pol)
1094 1095
1095static unsigned int powernowk8_get (unsigned int cpu) 1096static unsigned int powernowk8_get (unsigned int cpu)
1096{ 1097{
1097 struct powernow_k8_data *data = powernow_data[cpu]; 1098 struct powernow_k8_data *data;
1098 cpumask_t oldmask = current->cpus_allowed; 1099 cpumask_t oldmask = current->cpus_allowed;
1099 unsigned int khz = 0; 1100 unsigned int khz = 0;
1100 1101
1102 data = powernow_data[first_cpu(cpu_core_map[cpu])];
1103
1104 if (!data)
1105 return -EINVAL;
1106
1101 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 1107 set_cpus_allowed(current, cpumask_of_cpu(cpu));
1102 if (smp_processor_id() != cpu) { 1108 if (smp_processor_id() != cpu) {
1103 printk(KERN_ERR PFX "limiting to CPU %d failed in powernowk8_get\n", cpu); 1109 printk(KERN_ERR PFX "limiting to CPU %d failed in powernowk8_get\n", cpu);
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
index 00ea899c17e1..79a7c5c87edc 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
@@ -182,10 +182,6 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);
182 182
183static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index); 183static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index);
184 184
185#ifndef for_each_cpu_mask
186#define for_each_cpu_mask(i,mask) for (i=0;i<1;i++)
187#endif
188
189#ifdef CONFIG_SMP 185#ifdef CONFIG_SMP
190static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[]) 186static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[])
191{ 187{
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
index ce61921369e5..9df87b03612c 100644
--- a/arch/i386/kernel/cpu/intel_cacheinfo.c
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c
@@ -173,6 +173,10 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
173 unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */ 173 unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
174 unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */ 174 unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
175 unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */ 175 unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
176 unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb;
177#ifdef CONFIG_SMP
178 unsigned int cpu = (c == &boot_cpu_data) ? 0 : (c - cpu_data);
179#endif
176 180
177 if (c->cpuid_level > 3) { 181 if (c->cpuid_level > 3) {
178 static int is_initialized; 182 static int is_initialized;
@@ -205,9 +209,15 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
205 break; 209 break;
206 case 2: 210 case 2:
207 new_l2 = this_leaf.size/1024; 211 new_l2 = this_leaf.size/1024;
212 num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;
213 index_msb = get_count_order(num_threads_sharing);
214 l2_id = c->apicid >> index_msb;
208 break; 215 break;
209 case 3: 216 case 3:
210 new_l3 = this_leaf.size/1024; 217 new_l3 = this_leaf.size/1024;
218 num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;
219 index_msb = get_count_order(num_threads_sharing);
220 l3_id = c->apicid >> index_msb;
211 break; 221 break;
212 default: 222 default:
213 break; 223 break;
@@ -215,11 +225,19 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
215 } 225 }
216 } 226 }
217 } 227 }
218 if (c->cpuid_level > 1) { 228 /*
229 * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for
230 * trace cache
231 */
232 if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) {
219 /* supports eax=2 call */ 233 /* supports eax=2 call */
220 int i, j, n; 234 int i, j, n;
221 int regs[4]; 235 int regs[4];
222 unsigned char *dp = (unsigned char *)regs; 236 unsigned char *dp = (unsigned char *)regs;
237 int only_trace = 0;
238
239 if (num_cache_leaves != 0 && c->x86 == 15)
240 only_trace = 1;
223 241
224 /* Number of times to iterate */ 242 /* Number of times to iterate */
225 n = cpuid_eax(2) & 0xFF; 243 n = cpuid_eax(2) & 0xFF;
@@ -241,6 +259,8 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
241 while (cache_table[k].descriptor != 0) 259 while (cache_table[k].descriptor != 0)
242 { 260 {
243 if (cache_table[k].descriptor == des) { 261 if (cache_table[k].descriptor == des) {
262 if (only_trace && cache_table[k].cache_type != LVL_TRACE)
263 break;
244 switch (cache_table[k].cache_type) { 264 switch (cache_table[k].cache_type) {
245 case LVL_1_INST: 265 case LVL_1_INST:
246 l1i += cache_table[k].size; 266 l1i += cache_table[k].size;
@@ -266,34 +286,45 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
266 } 286 }
267 } 287 }
268 } 288 }
289 }
269 290
270 if (new_l1d) 291 if (new_l1d)
271 l1d = new_l1d; 292 l1d = new_l1d;
272 293
273 if (new_l1i) 294 if (new_l1i)
274 l1i = new_l1i; 295 l1i = new_l1i;
275 296
276 if (new_l2) 297 if (new_l2) {
277 l2 = new_l2; 298 l2 = new_l2;
299#ifdef CONFIG_SMP
300 cpu_llc_id[cpu] = l2_id;
301#endif
302 }
278 303
279 if (new_l3) 304 if (new_l3) {
280 l3 = new_l3; 305 l3 = new_l3;
306#ifdef CONFIG_SMP
307 cpu_llc_id[cpu] = l3_id;
308#endif
309 }
281 310
282 if ( trace ) 311 if (trace)
283 printk (KERN_INFO "CPU: Trace cache: %dK uops", trace); 312 printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
284 else if ( l1i ) 313 else if ( l1i )
285 printk (KERN_INFO "CPU: L1 I cache: %dK", l1i); 314 printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
286 if ( l1d )
287 printk(", L1 D cache: %dK\n", l1d);
288 else
289 printk("\n");
290 if ( l2 )
291 printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
292 if ( l3 )
293 printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
294 315
295 c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d)); 316 if (l1d)
296 } 317 printk(", L1 D cache: %dK\n", l1d);
318 else
319 printk("\n");
320
321 if (l2)
322 printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
323
324 if (l3)
325 printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
326
327 c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d));
297 328
298 return l2; 329 return l2;
299} 330}
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index 3b4618bed70d..fff90bda4733 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -36,6 +36,7 @@
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/smp.h> 37#include <linux/smp.h>
38#include <linux/cpu.h> 38#include <linux/cpu.h>
39#include <linux/mutex.h>
39 40
40#include <asm/mtrr.h> 41#include <asm/mtrr.h>
41 42
@@ -47,7 +48,7 @@
47u32 num_var_ranges = 0; 48u32 num_var_ranges = 0;
48 49
49unsigned int *usage_table; 50unsigned int *usage_table;
50static DECLARE_MUTEX(mtrr_sem); 51static DEFINE_MUTEX(mtrr_mutex);
51 52
52u32 size_or_mask, size_and_mask; 53u32 size_or_mask, size_and_mask;
53 54
@@ -333,7 +334,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
333 /* No CPU hotplug when we change MTRR entries */ 334 /* No CPU hotplug when we change MTRR entries */
334 lock_cpu_hotplug(); 335 lock_cpu_hotplug();
335 /* Search for existing MTRR */ 336 /* Search for existing MTRR */
336 down(&mtrr_sem); 337 mutex_lock(&mtrr_mutex);
337 for (i = 0; i < num_var_ranges; ++i) { 338 for (i = 0; i < num_var_ranges; ++i) {
338 mtrr_if->get(i, &lbase, &lsize, &ltype); 339 mtrr_if->get(i, &lbase, &lsize, &ltype);
339 if (base >= lbase + lsize) 340 if (base >= lbase + lsize)
@@ -371,7 +372,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
371 printk(KERN_INFO "mtrr: no more MTRRs available\n"); 372 printk(KERN_INFO "mtrr: no more MTRRs available\n");
372 error = i; 373 error = i;
373 out: 374 out:
374 up(&mtrr_sem); 375 mutex_unlock(&mtrr_mutex);
375 unlock_cpu_hotplug(); 376 unlock_cpu_hotplug();
376 return error; 377 return error;
377} 378}
@@ -464,7 +465,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
464 max = num_var_ranges; 465 max = num_var_ranges;
465 /* No CPU hotplug when we change MTRR entries */ 466 /* No CPU hotplug when we change MTRR entries */
466 lock_cpu_hotplug(); 467 lock_cpu_hotplug();
467 down(&mtrr_sem); 468 mutex_lock(&mtrr_mutex);
468 if (reg < 0) { 469 if (reg < 0) {
469 /* Search for existing MTRR */ 470 /* Search for existing MTRR */
470 for (i = 0; i < max; ++i) { 471 for (i = 0; i < max; ++i) {
@@ -503,7 +504,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
503 set_mtrr(reg, 0, 0, 0); 504 set_mtrr(reg, 0, 0, 0);
504 error = reg; 505 error = reg;
505 out: 506 out:
506 up(&mtrr_sem); 507 mutex_unlock(&mtrr_mutex);
507 unlock_cpu_hotplug(); 508 unlock_cpu_hotplug();
508 return error; 509 return error;
509} 510}
@@ -685,7 +686,7 @@ void mtrr_ap_init(void)
685 if (!mtrr_if || !use_intel()) 686 if (!mtrr_if || !use_intel())
686 return; 687 return;
687 /* 688 /*
688 * Ideally we should hold mtrr_sem here to avoid mtrr entries changed, 689 * Ideally we should hold mtrr_mutex here to avoid mtrr entries changed,
689 * but this routine will be called in cpu boot time, holding the lock 690 * but this routine will be called in cpu boot time, holding the lock
690 * breaks it. This routine is called in two cases: 1.very earily time 691 * breaks it. This routine is called in two cases: 1.very earily time
691 * of software resume, when there absolutely isn't mtrr entry changes; 692 * of software resume, when there absolutely isn't mtrr entry changes;
diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
index ebc8dc116c43..5efceebc48dc 100644
--- a/arch/i386/kernel/dmi_scan.c
+++ b/arch/i386/kernel/dmi_scan.c
@@ -3,6 +3,7 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/dmi.h> 5#include <linux/dmi.h>
6#include <linux/efi.h>
6#include <linux/bootmem.h> 7#include <linux/bootmem.h>
7#include <linux/slab.h> 8#include <linux/slab.h>
8#include <asm/dmi.h> 9#include <asm/dmi.h>
@@ -185,47 +186,72 @@ static void __init dmi_decode(struct dmi_header *dm)
185 } 186 }
186} 187}
187 188
188void __init dmi_scan_machine(void) 189static int __init dmi_present(char __iomem *p)
189{ 190{
190 u8 buf[15]; 191 u8 buf[15];
191 char __iomem *p, *q; 192 memcpy_fromio(buf, p, 15);
193 if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) {
194 u16 num = (buf[13] << 8) | buf[12];
195 u16 len = (buf[7] << 8) | buf[6];
196 u32 base = (buf[11] << 24) | (buf[10] << 16) |
197 (buf[9] << 8) | buf[8];
192 198
193 /* 199 /*
194 * no iounmap() for that ioremap(); it would be a no-op, but it's 200 * DMI version 0.0 means that the real version is taken from
195 * so early in setup that sucker gets confused into doing what 201 * the SMBIOS version, which we don't know at this point.
196 * it shouldn't if we actually call it. 202 */
197 */ 203 if (buf[14] != 0)
198 p = ioremap(0xF0000, 0x10000); 204 printk(KERN_INFO "DMI %d.%d present.\n",
199 if (p == NULL) 205 buf[14] >> 4, buf[14] & 0xF);
200 goto out; 206 else
201 207 printk(KERN_INFO "DMI present.\n");
202 for (q = p; q < p + 0x10000; q += 16) { 208 if (dmi_table(base,len, num, dmi_decode) == 0)
203 memcpy_fromio(buf, q, 15); 209 return 0;
204 if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) { 210 }
205 u16 num = (buf[13] << 8) | buf[12]; 211 return 1;
206 u16 len = (buf[7] << 8) | buf[6]; 212}
207 u32 base = (buf[11] << 24) | (buf[10] << 16) |
208 (buf[9] << 8) | buf[8];
209
210 /*
211 * DMI version 0.0 means that the real version is taken from
212 * the SMBIOS version, which we don't know at this point.
213 */
214 if (buf[14] != 0)
215 printk(KERN_INFO "DMI %d.%d present.\n",
216 buf[14] >> 4, buf[14] & 0xF);
217 else
218 printk(KERN_INFO "DMI present.\n");
219 213
220 if (dmi_table(base,len, num, dmi_decode) == 0) 214void __init dmi_scan_machine(void)
215{
216 char __iomem *p, *q;
217 int rc;
218
219 if (efi_enabled) {
220 if (efi.smbios == EFI_INVALID_TABLE_ADDR)
221 goto out;
222
223 /* This is called as a core_initcall() because it isn't
224 * needed during early boot. This also means we can
225 * iounmap the space when we're done with it.
226 */
227 p = dmi_ioremap(efi.smbios, 32);
228 if (p == NULL)
229 goto out;
230
231 rc = dmi_present(p + 0x10); /* offset of _DMI_ string */
232 dmi_iounmap(p, 32);
233 if (!rc)
234 return;
235 }
236 else {
237 /*
238 * no iounmap() for that ioremap(); it would be a no-op, but
239 * it's so early in setup that sucker gets confused into doing
240 * what it shouldn't if we actually call it.
241 */
242 p = dmi_ioremap(0xF0000, 0x10000);
243 if (p == NULL)
244 goto out;
245
246 for (q = p; q < p + 0x10000; q += 16) {
247 rc = dmi_present(q);
248 if (!rc)
221 return; 249 return;
222 } 250 }
223 } 251 }
224 252 out: printk(KERN_INFO "DMI not present or invalid.\n");
225out: printk(KERN_INFO "DMI not present or invalid.\n");
226} 253}
227 254
228
229/** 255/**
230 * dmi_check_system - check system DMI data 256 * dmi_check_system - check system DMI data
231 * @list: array of dmi_system_id structures to match against 257 * @list: array of dmi_system_id structures to match against
diff --git a/arch/i386/kernel/efi.c b/arch/i386/kernel/efi.c
index 7ec6cfa01fb3..9202b67c4b2e 100644
--- a/arch/i386/kernel/efi.c
+++ b/arch/i386/kernel/efi.c
@@ -361,7 +361,7 @@ void __init efi_init(void)
361 */ 361 */
362 c16 = (efi_char16_t *) boot_ioremap(efi.systab->fw_vendor, 2); 362 c16 = (efi_char16_t *) boot_ioremap(efi.systab->fw_vendor, 2);
363 if (c16) { 363 if (c16) {
364 for (i = 0; i < sizeof(vendor) && *c16; ++i) 364 for (i = 0; i < (sizeof(vendor) - 1) && *c16; ++i)
365 vendor[i] = *c16++; 365 vendor[i] = *c16++;
366 vendor[i] = '\0'; 366 vendor[i] = '\0';
367 } else 367 } else
@@ -381,29 +381,38 @@ void __init efi_init(void)
381 if (config_tables == NULL) 381 if (config_tables == NULL)
382 printk(KERN_ERR PFX "Could not map EFI Configuration Table!\n"); 382 printk(KERN_ERR PFX "Could not map EFI Configuration Table!\n");
383 383
384 efi.mps = EFI_INVALID_TABLE_ADDR;
385 efi.acpi = EFI_INVALID_TABLE_ADDR;
386 efi.acpi20 = EFI_INVALID_TABLE_ADDR;
387 efi.smbios = EFI_INVALID_TABLE_ADDR;
388 efi.sal_systab = EFI_INVALID_TABLE_ADDR;
389 efi.boot_info = EFI_INVALID_TABLE_ADDR;
390 efi.hcdp = EFI_INVALID_TABLE_ADDR;
391 efi.uga = EFI_INVALID_TABLE_ADDR;
392
384 for (i = 0; i < num_config_tables; i++) { 393 for (i = 0; i < num_config_tables; i++) {
385 if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) { 394 if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
386 efi.mps = (void *)config_tables[i].table; 395 efi.mps = config_tables[i].table;
387 printk(KERN_INFO " MPS=0x%lx ", config_tables[i].table); 396 printk(KERN_INFO " MPS=0x%lx ", config_tables[i].table);
388 } else 397 } else
389 if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) { 398 if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
390 efi.acpi20 = __va(config_tables[i].table); 399 efi.acpi20 = config_tables[i].table;
391 printk(KERN_INFO " ACPI 2.0=0x%lx ", config_tables[i].table); 400 printk(KERN_INFO " ACPI 2.0=0x%lx ", config_tables[i].table);
392 } else 401 } else
393 if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) { 402 if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
394 efi.acpi = __va(config_tables[i].table); 403 efi.acpi = config_tables[i].table;
395 printk(KERN_INFO " ACPI=0x%lx ", config_tables[i].table); 404 printk(KERN_INFO " ACPI=0x%lx ", config_tables[i].table);
396 } else 405 } else
397 if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) { 406 if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
398 efi.smbios = (void *) config_tables[i].table; 407 efi.smbios = config_tables[i].table;
399 printk(KERN_INFO " SMBIOS=0x%lx ", config_tables[i].table); 408 printk(KERN_INFO " SMBIOS=0x%lx ", config_tables[i].table);
400 } else 409 } else
401 if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) { 410 if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
402 efi.hcdp = (void *)config_tables[i].table; 411 efi.hcdp = config_tables[i].table;
403 printk(KERN_INFO " HCDP=0x%lx ", config_tables[i].table); 412 printk(KERN_INFO " HCDP=0x%lx ", config_tables[i].table);
404 } else 413 } else
405 if (efi_guidcmp(config_tables[i].guid, UGA_IO_PROTOCOL_GUID) == 0) { 414 if (efi_guidcmp(config_tables[i].guid, UGA_IO_PROTOCOL_GUID) == 0) {
406 efi.uga = (void *)config_tables[i].table; 415 efi.uga = config_tables[i].table;
407 printk(KERN_INFO " UGA=0x%lx ", config_tables[i].table); 416 printk(KERN_INFO " UGA=0x%lx ", config_tables[i].table);
408 } 417 }
409 } 418 }
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 311b4e7266f1..3b329af4afc5 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -381,7 +381,7 @@ static void do_irq_balance(void)
381 unsigned long imbalance = 0; 381 unsigned long imbalance = 0;
382 cpumask_t allowed_mask, target_cpu_mask, tmp; 382 cpumask_t allowed_mask, target_cpu_mask, tmp;
383 383
384 for_each_cpu(i) { 384 for_each_possible_cpu(i) {
385 int package_index; 385 int package_index;
386 CPU_IRQ(i) = 0; 386 CPU_IRQ(i) = 0;
387 if (!cpu_online(i)) 387 if (!cpu_online(i))
@@ -632,7 +632,7 @@ static int __init balanced_irq_init(void)
632 else 632 else
633 printk(KERN_ERR "balanced_irq_init: failed to spawn balanced_irq"); 633 printk(KERN_ERR "balanced_irq_init: failed to spawn balanced_irq");
634failed: 634failed:
635 for_each_cpu(i) { 635 for_each_possible_cpu(i) {
636 kfree(irq_cpu_data[i].irq_delta); 636 kfree(irq_cpu_data[i].irq_delta);
637 irq_cpu_data[i].irq_delta = NULL; 637 irq_cpu_data[i].irq_delta = NULL;
638 kfree(irq_cpu_data[i].last_irq); 638 kfree(irq_cpu_data[i].last_irq);
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 7a59050242a7..f19768789e8a 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -35,12 +35,56 @@
35#include <asm/cacheflush.h> 35#include <asm/cacheflush.h>
36#include <asm/kdebug.h> 36#include <asm/kdebug.h>
37#include <asm/desc.h> 37#include <asm/desc.h>
38#include <asm/uaccess.h>
38 39
39void jprobe_return_end(void); 40void jprobe_return_end(void);
40 41
41DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 42DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
42DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 43DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
43 44
45/* insert a jmp code */
46static inline void set_jmp_op(void *from, void *to)
47{
48 struct __arch_jmp_op {
49 char op;
50 long raddr;
51 } __attribute__((packed)) *jop;
52 jop = (struct __arch_jmp_op *)from;
53 jop->raddr = (long)(to) - ((long)(from) + 5);
54 jop->op = RELATIVEJUMP_INSTRUCTION;
55}
56
57/*
58 * returns non-zero if opcodes can be boosted.
59 */
60static inline int can_boost(kprobe_opcode_t opcode)
61{
62 switch (opcode & 0xf0 ) {
63 case 0x70:
64 return 0; /* can't boost conditional jump */
65 case 0x90:
66 /* can't boost call and pushf */
67 return opcode != 0x9a && opcode != 0x9c;
68 case 0xc0:
69 /* can't boost undefined opcodes and soft-interruptions */
70 return (0xc1 < opcode && opcode < 0xc6) ||
71 (0xc7 < opcode && opcode < 0xcc) || opcode == 0xcf;
72 case 0xd0:
73 /* can boost AA* and XLAT */
74 return (opcode == 0xd4 || opcode == 0xd5 || opcode == 0xd7);
75 case 0xe0:
76 /* can boost in/out and (may be) jmps */
77 return (0xe3 < opcode && opcode != 0xe8);
78 case 0xf0:
79 /* clear and set flags can be boost */
80 return (opcode == 0xf5 || (0xf7 < opcode && opcode < 0xfe));
81 default:
82 /* currently, can't boost 2 bytes opcodes */
83 return opcode != 0x0f;
84 }
85}
86
87
44/* 88/*
45 * returns non-zero if opcode modifies the interrupt flag. 89 * returns non-zero if opcode modifies the interrupt flag.
46 */ 90 */
@@ -65,6 +109,11 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
65 109
66 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 110 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
67 p->opcode = *p->addr; 111 p->opcode = *p->addr;
112 if (can_boost(p->opcode)) {
113 p->ainsn.boostable = 0;
114 } else {
115 p->ainsn.boostable = -1;
116 }
68 return 0; 117 return 0;
69} 118}
70 119
@@ -155,9 +204,13 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
155{ 204{
156 struct kprobe *p; 205 struct kprobe *p;
157 int ret = 0; 206 int ret = 0;
158 kprobe_opcode_t *addr = NULL; 207 kprobe_opcode_t *addr;
159 unsigned long *lp;
160 struct kprobe_ctlblk *kcb; 208 struct kprobe_ctlblk *kcb;
209#ifdef CONFIG_PREEMPT
210 unsigned pre_preempt_count = preempt_count();
211#endif /* CONFIG_PREEMPT */
212
213 addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t));
161 214
162 /* 215 /*
163 * We don't want to be preempted for the entire 216 * We don't want to be preempted for the entire
@@ -166,17 +219,6 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
166 preempt_disable(); 219 preempt_disable();
167 kcb = get_kprobe_ctlblk(); 220 kcb = get_kprobe_ctlblk();
168 221
169 /* Check if the application is using LDT entry for its code segment and
170 * calculate the address by reading the base address from the LDT entry.
171 */
172 if ((regs->xcs & 4) && (current->mm)) {
173 lp = (unsigned long *) ((unsigned long)((regs->xcs >> 3) * 8)
174 + (char *) current->mm->context.ldt);
175 addr = (kprobe_opcode_t *) (get_desc_base(lp) + regs->eip -
176 sizeof(kprobe_opcode_t));
177 } else {
178 addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t));
179 }
180 /* Check we're not actually recursing */ 222 /* Check we're not actually recursing */
181 if (kprobe_running()) { 223 if (kprobe_running()) {
182 p = get_kprobe(addr); 224 p = get_kprobe(addr);
@@ -252,6 +294,21 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
252 /* handler has already set things up, so skip ss setup */ 294 /* handler has already set things up, so skip ss setup */
253 return 1; 295 return 1;
254 296
297 if (p->ainsn.boostable == 1 &&
298#ifdef CONFIG_PREEMPT
299 !(pre_preempt_count) && /*
300 * This enables booster when the direct
301 * execution path aren't preempted.
302 */
303#endif /* CONFIG_PREEMPT */
304 !p->post_handler && !p->break_handler ) {
305 /* Boost up -- we can execute copied instructions directly */
306 reset_current_kprobe();
307 regs->eip = (unsigned long)p->ainsn.insn;
308 preempt_enable_no_resched();
309 return 1;
310 }
311
255ss_probe: 312ss_probe:
256 prepare_singlestep(p, regs); 313 prepare_singlestep(p, regs);
257 kcb->kprobe_status = KPROBE_HIT_SS; 314 kcb->kprobe_status = KPROBE_HIT_SS;
@@ -267,17 +324,44 @@ no_kprobe:
267 * here. When a retprobed function returns, this probe is hit and 324 * here. When a retprobed function returns, this probe is hit and
268 * trampoline_probe_handler() runs, calling the kretprobe's handler. 325 * trampoline_probe_handler() runs, calling the kretprobe's handler.
269 */ 326 */
270 void kretprobe_trampoline_holder(void) 327 void __kprobes kretprobe_trampoline_holder(void)
271 { 328 {
272 asm volatile ( ".global kretprobe_trampoline\n" 329 asm volatile ( ".global kretprobe_trampoline\n"
273 "kretprobe_trampoline: \n" 330 "kretprobe_trampoline: \n"
274 "nop\n"); 331 " pushf\n"
275 } 332 /* skip cs, eip, orig_eax, es, ds */
333 " subl $20, %esp\n"
334 " pushl %eax\n"
335 " pushl %ebp\n"
336 " pushl %edi\n"
337 " pushl %esi\n"
338 " pushl %edx\n"
339 " pushl %ecx\n"
340 " pushl %ebx\n"
341 " movl %esp, %eax\n"
342 " call trampoline_handler\n"
343 /* move eflags to cs */
344 " movl 48(%esp), %edx\n"
345 " movl %edx, 44(%esp)\n"
346 /* save true return address on eflags */
347 " movl %eax, 48(%esp)\n"
348 " popl %ebx\n"
349 " popl %ecx\n"
350 " popl %edx\n"
351 " popl %esi\n"
352 " popl %edi\n"
353 " popl %ebp\n"
354 " popl %eax\n"
355 /* skip eip, orig_eax, es, ds */
356 " addl $16, %esp\n"
357 " popf\n"
358 " ret\n");
359}
276 360
277/* 361/*
278 * Called when we hit the probe point at kretprobe_trampoline 362 * Called from kretprobe_trampoline
279 */ 363 */
280int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) 364fastcall void *__kprobes trampoline_handler(struct pt_regs *regs)
281{ 365{
282 struct kretprobe_instance *ri = NULL; 366 struct kretprobe_instance *ri = NULL;
283 struct hlist_head *head; 367 struct hlist_head *head;
@@ -306,8 +390,11 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
306 /* another task is sharing our hash bucket */ 390 /* another task is sharing our hash bucket */
307 continue; 391 continue;
308 392
309 if (ri->rp && ri->rp->handler) 393 if (ri->rp && ri->rp->handler){
394 __get_cpu_var(current_kprobe) = &ri->rp->kp;
310 ri->rp->handler(ri, regs); 395 ri->rp->handler(ri, regs);
396 __get_cpu_var(current_kprobe) = NULL;
397 }
311 398
312 orig_ret_address = (unsigned long)ri->ret_addr; 399 orig_ret_address = (unsigned long)ri->ret_addr;
313 recycle_rp_inst(ri); 400 recycle_rp_inst(ri);
@@ -322,18 +409,10 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
322 } 409 }
323 410
324 BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address)); 411 BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
325 regs->eip = orig_ret_address;
326 412
327 reset_current_kprobe();
328 spin_unlock_irqrestore(&kretprobe_lock, flags); 413 spin_unlock_irqrestore(&kretprobe_lock, flags);
329 preempt_enable_no_resched();
330 414
331 /* 415 return (void*)orig_ret_address;
332 * By returning a non-zero value, we are telling
333 * kprobe_handler() that we don't want the post_handler
334 * to run (and have re-enabled preemption)
335 */
336 return 1;
337} 416}
338 417
339/* 418/*
@@ -357,15 +436,17 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
357 * 2) If the single-stepped instruction was a call, the return address 436 * 2) If the single-stepped instruction was a call, the return address
358 * that is atop the stack is the address following the copied instruction. 437 * that is atop the stack is the address following the copied instruction.
359 * We need to make it the address following the original instruction. 438 * We need to make it the address following the original instruction.
439 *
440 * This function also checks instruction size for preparing direct execution.
360 */ 441 */
361static void __kprobes resume_execution(struct kprobe *p, 442static void __kprobes resume_execution(struct kprobe *p,
362 struct pt_regs *regs, struct kprobe_ctlblk *kcb) 443 struct pt_regs *regs, struct kprobe_ctlblk *kcb)
363{ 444{
364 unsigned long *tos = (unsigned long *)&regs->esp; 445 unsigned long *tos = (unsigned long *)&regs->esp;
365 unsigned long next_eip = 0;
366 unsigned long copy_eip = (unsigned long)p->ainsn.insn; 446 unsigned long copy_eip = (unsigned long)p->ainsn.insn;
367 unsigned long orig_eip = (unsigned long)p->addr; 447 unsigned long orig_eip = (unsigned long)p->addr;
368 448
449 regs->eflags &= ~TF_MASK;
369 switch (p->ainsn.insn[0]) { 450 switch (p->ainsn.insn[0]) {
370 case 0x9c: /* pushfl */ 451 case 0x9c: /* pushfl */
371 *tos &= ~(TF_MASK | IF_MASK); 452 *tos &= ~(TF_MASK | IF_MASK);
@@ -375,37 +456,51 @@ static void __kprobes resume_execution(struct kprobe *p,
375 case 0xcb: 456 case 0xcb:
376 case 0xc2: 457 case 0xc2:
377 case 0xca: 458 case 0xca:
378 regs->eflags &= ~TF_MASK; 459 case 0xea: /* jmp absolute -- eip is correct */
379 /* eip is already adjusted, no more changes required*/ 460 /* eip is already adjusted, no more changes required */
380 return; 461 p->ainsn.boostable = 1;
462 goto no_change;
381 case 0xe8: /* call relative - Fix return addr */ 463 case 0xe8: /* call relative - Fix return addr */
382 *tos = orig_eip + (*tos - copy_eip); 464 *tos = orig_eip + (*tos - copy_eip);
383 break; 465 break;
384 case 0xff: 466 case 0xff:
385 if ((p->ainsn.insn[1] & 0x30) == 0x10) { 467 if ((p->ainsn.insn[1] & 0x30) == 0x10) {
386 /* call absolute, indirect */ 468 /* call absolute, indirect */
387 /* Fix return addr; eip is correct. */ 469 /*
388 next_eip = regs->eip; 470 * Fix return addr; eip is correct.
471 * But this is not boostable
472 */
389 *tos = orig_eip + (*tos - copy_eip); 473 *tos = orig_eip + (*tos - copy_eip);
474 goto no_change;
390 } else if (((p->ainsn.insn[1] & 0x31) == 0x20) || /* jmp near, absolute indirect */ 475 } else if (((p->ainsn.insn[1] & 0x31) == 0x20) || /* jmp near, absolute indirect */
391 ((p->ainsn.insn[1] & 0x31) == 0x21)) { /* jmp far, absolute indirect */ 476 ((p->ainsn.insn[1] & 0x31) == 0x21)) { /* jmp far, absolute indirect */
392 /* eip is correct. */ 477 /* eip is correct. And this is boostable */
393 next_eip = regs->eip; 478 p->ainsn.boostable = 1;
479 goto no_change;
394 } 480 }
395 break;
396 case 0xea: /* jmp absolute -- eip is correct */
397 next_eip = regs->eip;
398 break;
399 default: 481 default:
400 break; 482 break;
401 } 483 }
402 484
403 regs->eflags &= ~TF_MASK; 485 if (p->ainsn.boostable == 0) {
404 if (next_eip) { 486 if ((regs->eip > copy_eip) &&
405 regs->eip = next_eip; 487 (regs->eip - copy_eip) + 5 < MAX_INSN_SIZE) {
406 } else { 488 /*
407 regs->eip = orig_eip + (regs->eip - copy_eip); 489 * These instructions can be executed directly if it
490 * jumps back to correct address.
491 */
492 set_jmp_op((void *)regs->eip,
493 (void *)orig_eip + (regs->eip - copy_eip));
494 p->ainsn.boostable = 1;
495 } else {
496 p->ainsn.boostable = -1;
497 }
408 } 498 }
499
500 regs->eip = orig_eip + (regs->eip - copy_eip);
501
502no_change:
503 return;
409} 504}
410 505
411/* 506/*
@@ -453,15 +548,57 @@ static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
453 struct kprobe *cur = kprobe_running(); 548 struct kprobe *cur = kprobe_running();
454 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 549 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
455 550
456 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr)) 551 switch(kcb->kprobe_status) {
457 return 1; 552 case KPROBE_HIT_SS:
458 553 case KPROBE_REENTER:
459 if (kcb->kprobe_status & KPROBE_HIT_SS) { 554 /*
460 resume_execution(cur, regs, kcb); 555 * We are here because the instruction being single
556 * stepped caused a page fault. We reset the current
557 * kprobe and the eip points back to the probe address
558 * and allow the page fault handler to continue as a
559 * normal page fault.
560 */
561 regs->eip = (unsigned long)cur->addr;
461 regs->eflags |= kcb->kprobe_old_eflags; 562 regs->eflags |= kcb->kprobe_old_eflags;
462 563 if (kcb->kprobe_status == KPROBE_REENTER)
463 reset_current_kprobe(); 564 restore_previous_kprobe(kcb);
565 else
566 reset_current_kprobe();
464 preempt_enable_no_resched(); 567 preempt_enable_no_resched();
568 break;
569 case KPROBE_HIT_ACTIVE:
570 case KPROBE_HIT_SSDONE:
571 /*
572 * We increment the nmissed count for accounting,
573 * we can also use npre/npostfault count for accouting
574 * these specific fault cases.
575 */
576 kprobes_inc_nmissed_count(cur);
577
578 /*
579 * We come here because instructions in the pre/post
580 * handler caused the page_fault, this could happen
581 * if handler tries to access user space by
582 * copy_from_user(), get_user() etc. Let the
583 * user-specified handler try to fix it first.
584 */
585 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
586 return 1;
587
588 /*
589 * In case the user-specified fault handler returned
590 * zero, try to fix up.
591 */
592 if (fixup_exception(regs))
593 return 1;
594
595 /*
596 * fixup_exception() could not handle it,
597 * Let do_page_fault() fix it.
598 */
599 break;
600 default:
601 break;
465 } 602 }
466 return 0; 603 return 0;
467} 604}
@@ -475,6 +612,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
475 struct die_args *args = (struct die_args *)data; 612 struct die_args *args = (struct die_args *)data;
476 int ret = NOTIFY_DONE; 613 int ret = NOTIFY_DONE;
477 614
615 if (args->regs && user_mode(args->regs))
616 return ret;
617
478 switch (val) { 618 switch (val) {
479 case DIE_INT3: 619 case DIE_INT3:
480 if (kprobe_handler(args->regs)) 620 if (kprobe_handler(args->regs))
@@ -564,12 +704,7 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
564 return 0; 704 return 0;
565} 705}
566 706
567static struct kprobe trampoline_p = {
568 .addr = (kprobe_opcode_t *) &kretprobe_trampoline,
569 .pre_handler = trampoline_probe_handler
570};
571
572int __init arch_init_kprobes(void) 707int __init arch_init_kprobes(void)
573{ 708{
574 return register_kprobe(&trampoline_p); 709 return 0;
575} 710}
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 55bc365b8753..e7c138f66c5a 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -81,6 +81,7 @@
81#include <linux/miscdevice.h> 81#include <linux/miscdevice.h>
82#include <linux/spinlock.h> 82#include <linux/spinlock.h>
83#include <linux/mm.h> 83#include <linux/mm.h>
84#include <linux/mutex.h>
84 85
85#include <asm/msr.h> 86#include <asm/msr.h>
86#include <asm/uaccess.h> 87#include <asm/uaccess.h>
@@ -114,7 +115,7 @@ MODULE_LICENSE("GPL");
114static DEFINE_SPINLOCK(microcode_update_lock); 115static DEFINE_SPINLOCK(microcode_update_lock);
115 116
116/* no concurrent ->write()s are allowed on /dev/cpu/microcode */ 117/* no concurrent ->write()s are allowed on /dev/cpu/microcode */
117static DECLARE_MUTEX(microcode_sem); 118static DEFINE_MUTEX(microcode_mutex);
118 119
119static void __user *user_buffer; /* user area microcode data buffer */ 120static void __user *user_buffer; /* user area microcode data buffer */
120static unsigned int user_buffer_size; /* it's size */ 121static unsigned int user_buffer_size; /* it's size */
@@ -444,7 +445,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
444 return -EINVAL; 445 return -EINVAL;
445 } 446 }
446 447
447 down(&microcode_sem); 448 mutex_lock(&microcode_mutex);
448 449
449 user_buffer = (void __user *) buf; 450 user_buffer = (void __user *) buf;
450 user_buffer_size = (int) len; 451 user_buffer_size = (int) len;
@@ -453,31 +454,14 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
453 if (!ret) 454 if (!ret)
454 ret = (ssize_t)len; 455 ret = (ssize_t)len;
455 456
456 up(&microcode_sem); 457 mutex_unlock(&microcode_mutex);
457 458
458 return ret; 459 return ret;
459} 460}
460 461
461static int microcode_ioctl (struct inode *inode, struct file *file,
462 unsigned int cmd, unsigned long arg)
463{
464 switch (cmd) {
465 /*
466 * XXX: will be removed after microcode_ctl
467 * is updated to ignore failure of this ioctl()
468 */
469 case MICROCODE_IOCFREE:
470 return 0;
471 default:
472 return -EINVAL;
473 }
474 return -EINVAL;
475}
476
477static struct file_operations microcode_fops = { 462static struct file_operations microcode_fops = {
478 .owner = THIS_MODULE, 463 .owner = THIS_MODULE,
479 .write = microcode_write, 464 .write = microcode_write,
480 .ioctl = microcode_ioctl,
481 .open = microcode_open, 465 .open = microcode_open,
482}; 466};
483 467
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index 9074818b9473..d43b498ec745 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -138,12 +138,12 @@ static int __init check_nmi_watchdog(void)
138 if (nmi_watchdog == NMI_LOCAL_APIC) 138 if (nmi_watchdog == NMI_LOCAL_APIC)
139 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0); 139 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
140 140
141 for_each_cpu(cpu) 141 for_each_possible_cpu(cpu)
142 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count; 142 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count;
143 local_irq_enable(); 143 local_irq_enable();
144 mdelay((10*1000)/nmi_hz); // wait 10 ticks 144 mdelay((10*1000)/nmi_hz); // wait 10 ticks
145 145
146 for_each_cpu(cpu) { 146 for_each_possible_cpu(cpu) {
147#ifdef CONFIG_SMP 147#ifdef CONFIG_SMP
148 /* Check cpu_callin_map here because that is set 148 /* Check cpu_callin_map here because that is set
149 after the timer is started. */ 149 after the timer is started. */
@@ -510,7 +510,7 @@ void touch_nmi_watchdog (void)
510 * Just reset the alert counters, (other CPUs might be 510 * Just reset the alert counters, (other CPUs might be
511 * spinning on locks we hold): 511 * spinning on locks we hold):
512 */ 512 */
513 for_each_cpu(i) 513 for_each_possible_cpu(i)
514 alert_counter[i] = 0; 514 alert_counter[i] = 0;
515 515
516 /* 516 /*
@@ -529,7 +529,8 @@ void nmi_watchdog_tick (struct pt_regs * regs)
529 * always switch the stack NMI-atomically, it's safe to use 529 * always switch the stack NMI-atomically, it's safe to use
530 * smp_processor_id(). 530 * smp_processor_id().
531 */ 531 */
532 int sum, cpu = smp_processor_id(); 532 unsigned int sum;
533 int cpu = smp_processor_id();
533 534
534 sum = per_cpu(irq_stat, cpu).apic_timer_irqs; 535 sum = per_cpu(irq_stat, cpu).apic_timer_irqs;
535 536
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 299e61674084..24b3e745478b 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -38,7 +38,6 @@
38#include <linux/kallsyms.h> 38#include <linux/kallsyms.h>
39#include <linux/ptrace.h> 39#include <linux/ptrace.h>
40#include <linux/random.h> 40#include <linux/random.h>
41#include <linux/kprobes.h>
42 41
43#include <asm/uaccess.h> 42#include <asm/uaccess.h>
44#include <asm/pgtable.h> 43#include <asm/pgtable.h>
@@ -364,13 +363,6 @@ void exit_thread(void)
364 struct task_struct *tsk = current; 363 struct task_struct *tsk = current;
365 struct thread_struct *t = &tsk->thread; 364 struct thread_struct *t = &tsk->thread;
366 365
367 /*
368 * Remove function-return probe instances associated with this task
369 * and put them back on the free list. Do not insert an exit probe for
370 * this function, it will be disabled by kprobe_flush_task if you do.
371 */
372 kprobe_flush_task(tsk);
373
374 /* The process may have allocated an io port bitmap... nuke it. */ 366 /* The process may have allocated an io port bitmap... nuke it. */
375 if (unlikely(NULL != t->io_bitmap_ptr)) { 367 if (unlikely(NULL != t->io_bitmap_ptr)) {
376 int cpu = get_cpu(); 368 int cpu = get_cpu();
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index d313a11acafa..8c08660b4e5d 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -46,6 +46,7 @@
46#include <linux/kexec.h> 46#include <linux/kexec.h>
47#include <linux/crash_dump.h> 47#include <linux/crash_dump.h>
48#include <linux/dmi.h> 48#include <linux/dmi.h>
49#include <linux/pfn.h>
49 50
50#include <video/edid.h> 51#include <video/edid.h>
51 52
@@ -1058,10 +1059,10 @@ static int __init
1058free_available_memory(unsigned long start, unsigned long end, void *arg) 1059free_available_memory(unsigned long start, unsigned long end, void *arg)
1059{ 1060{
1060 /* check max_low_pfn */ 1061 /* check max_low_pfn */
1061 if (start >= ((max_low_pfn + 1) << PAGE_SHIFT)) 1062 if (start >= (max_low_pfn << PAGE_SHIFT))
1062 return 0; 1063 return 0;
1063 if (end >= ((max_low_pfn + 1) << PAGE_SHIFT)) 1064 if (end >= (max_low_pfn << PAGE_SHIFT))
1064 end = (max_low_pfn + 1) << PAGE_SHIFT; 1065 end = max_low_pfn << PAGE_SHIFT;
1065 if (start < end) 1066 if (start < end)
1066 free_bootmem(start, end - start); 1067 free_bootmem(start, end - start);
1067 1068
@@ -1286,8 +1287,6 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
1286 probe_roms(); 1287 probe_roms();
1287 for (i = 0; i < e820.nr_map; i++) { 1288 for (i = 0; i < e820.nr_map; i++) {
1288 struct resource *res; 1289 struct resource *res;
1289 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
1290 continue;
1291 res = kzalloc(sizeof(struct resource), GFP_ATOMIC); 1290 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
1292 switch (e820.map[i].type) { 1291 switch (e820.map[i].type) {
1293 case E820_RAM: res->name = "System RAM"; break; 1292 case E820_RAM: res->name = "System RAM"; break;
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 82371d83bfa9..a6969903f2d6 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -72,6 +72,9 @@ int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
72/* Core ID of each logical CPU */ 72/* Core ID of each logical CPU */
73int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; 73int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
74 74
75/* Last level cache ID of each logical CPU */
76int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID};
77
75/* representing HT siblings of each logical CPU */ 78/* representing HT siblings of each logical CPU */
76cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly; 79cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
77EXPORT_SYMBOL(cpu_sibling_map); 80EXPORT_SYMBOL(cpu_sibling_map);
@@ -440,6 +443,18 @@ static void __devinit smp_callin(void)
440 443
441static int cpucount; 444static int cpucount;
442 445
446/* maps the cpu to the sched domain representing multi-core */
447cpumask_t cpu_coregroup_map(int cpu)
448{
449 struct cpuinfo_x86 *c = cpu_data + cpu;
450 /*
451 * For perf, we return last level cache shared map.
452 * TBD: when power saving sched policy is added, we will return
453 * cpu_core_map when power saving policy is enabled
454 */
455 return c->llc_shared_map;
456}
457
443/* representing cpus for which sibling maps can be computed */ 458/* representing cpus for which sibling maps can be computed */
444static cpumask_t cpu_sibling_setup_map; 459static cpumask_t cpu_sibling_setup_map;
445 460
@@ -459,12 +474,16 @@ set_cpu_sibling_map(int cpu)
459 cpu_set(cpu, cpu_sibling_map[i]); 474 cpu_set(cpu, cpu_sibling_map[i]);
460 cpu_set(i, cpu_core_map[cpu]); 475 cpu_set(i, cpu_core_map[cpu]);
461 cpu_set(cpu, cpu_core_map[i]); 476 cpu_set(cpu, cpu_core_map[i]);
477 cpu_set(i, c[cpu].llc_shared_map);
478 cpu_set(cpu, c[i].llc_shared_map);
462 } 479 }
463 } 480 }
464 } else { 481 } else {
465 cpu_set(cpu, cpu_sibling_map[cpu]); 482 cpu_set(cpu, cpu_sibling_map[cpu]);
466 } 483 }
467 484
485 cpu_set(cpu, c[cpu].llc_shared_map);
486
468 if (current_cpu_data.x86_max_cores == 1) { 487 if (current_cpu_data.x86_max_cores == 1) {
469 cpu_core_map[cpu] = cpu_sibling_map[cpu]; 488 cpu_core_map[cpu] = cpu_sibling_map[cpu];
470 c[cpu].booted_cores = 1; 489 c[cpu].booted_cores = 1;
@@ -472,6 +491,11 @@ set_cpu_sibling_map(int cpu)
472 } 491 }
473 492
474 for_each_cpu_mask(i, cpu_sibling_setup_map) { 493 for_each_cpu_mask(i, cpu_sibling_setup_map) {
494 if (cpu_llc_id[cpu] != BAD_APICID &&
495 cpu_llc_id[cpu] == cpu_llc_id[i]) {
496 cpu_set(i, c[cpu].llc_shared_map);
497 cpu_set(cpu, c[i].llc_shared_map);
498 }
475 if (phys_proc_id[cpu] == phys_proc_id[i]) { 499 if (phys_proc_id[cpu] == phys_proc_id[i]) {
476 cpu_set(i, cpu_core_map[cpu]); 500 cpu_set(i, cpu_core_map[cpu]);
477 cpu_set(cpu, cpu_core_map[i]); 501 cpu_set(cpu, cpu_core_map[i]);
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index ac687d00a1ce..326595f3fa4d 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -310,3 +310,5 @@ ENTRY(sys_call_table)
310 .long sys_pselect6 310 .long sys_pselect6
311 .long sys_ppoll 311 .long sys_ppoll
312 .long sys_unshare /* 310 */ 312 .long sys_unshare /* 310 */
313 .long sys_set_robust_list
314 .long sys_get_robust_list
diff --git a/arch/i386/kernel/timers/timer_pm.c b/arch/i386/kernel/timers/timer_pm.c
index 264edaaac315..144e94a04933 100644
--- a/arch/i386/kernel/timers/timer_pm.c
+++ b/arch/i386/kernel/timers/timer_pm.c
@@ -15,6 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/pci.h>
18#include <asm/types.h> 19#include <asm/types.h>
19#include <asm/timer.h> 20#include <asm/timer.h>
20#include <asm/smp.h> 21#include <asm/smp.h>
@@ -45,24 +46,31 @@ static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED;
45 46
46#define ACPI_PM_MASK 0xFFFFFF /* limit it to 24 bits */ 47#define ACPI_PM_MASK 0xFFFFFF /* limit it to 24 bits */
47 48
49static int pmtmr_need_workaround __read_mostly = 1;
50
48/*helper function to safely read acpi pm timesource*/ 51/*helper function to safely read acpi pm timesource*/
49static inline u32 read_pmtmr(void) 52static inline u32 read_pmtmr(void)
50{ 53{
51 u32 v1=0,v2=0,v3=0; 54 if (pmtmr_need_workaround) {
52 /* It has been reported that because of various broken 55 u32 v1, v2, v3;
53 * chipsets (ICH4, PIIX4 and PIIX4E) where the ACPI PM time 56
54 * source is not latched, so you must read it multiple 57 /* It has been reported that because of various broken
55 * times to insure a safe value is read. 58 * chipsets (ICH4, PIIX4 and PIIX4E) where the ACPI PM time
56 */ 59 * source is not latched, so you must read it multiple
57 do { 60 * times to insure a safe value is read.
58 v1 = inl(pmtmr_ioport); 61 */
59 v2 = inl(pmtmr_ioport); 62 do {
60 v3 = inl(pmtmr_ioport); 63 v1 = inl(pmtmr_ioport);
61 } while ((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) 64 v2 = inl(pmtmr_ioport);
62 || (v3 > v1 && v3 < v2)); 65 v3 = inl(pmtmr_ioport);
63 66 } while ((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
64 /* mask the output to 24 bits */ 67 || (v3 > v1 && v3 < v2));
65 return v2 & ACPI_PM_MASK; 68
69 /* mask the output to 24 bits */
70 return v2 & ACPI_PM_MASK;
71 }
72
73 return inl(pmtmr_ioport) & ACPI_PM_MASK;
66} 74}
67 75
68 76
@@ -263,6 +271,72 @@ struct init_timer_opts __initdata timer_pmtmr_init = {
263 .opts = &timer_pmtmr, 271 .opts = &timer_pmtmr,
264}; 272};
265 273
274#ifdef CONFIG_PCI
275/*
276 * PIIX4 Errata:
277 *
278 * The power management timer may return improper results when read.
279 * Although the timer value settles properly after incrementing,
280 * while incrementing there is a 3 ns window every 69.8 ns where the
281 * timer value is indeterminate (a 4.2% chance that the data will be
282 * incorrect when read). As a result, the ACPI free running count up
283 * timer specification is violated due to erroneous reads.
284 */
285static int __init pmtmr_bug_check(void)
286{
287 static struct pci_device_id gray_list[] __initdata = {
288 /* these chipsets may have bug. */
289 { PCI_DEVICE(PCI_VENDOR_ID_INTEL,
290 PCI_DEVICE_ID_INTEL_82801DB_0) },
291 { },
292 };
293 struct pci_dev *dev;
294 int pmtmr_has_bug = 0;
295 u8 rev;
296
297 if (cur_timer != &timer_pmtmr || !pmtmr_need_workaround)
298 return 0;
299
300 dev = pci_get_device(PCI_VENDOR_ID_INTEL,
301 PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
302 if (dev) {
303 pci_read_config_byte(dev, PCI_REVISION_ID, &rev);
304 /* the bug has been fixed in PIIX4M */
305 if (rev < 3) {
306 printk(KERN_WARNING "* Found PM-Timer Bug on this "
307 "chipset. Due to workarounds for a bug,\n"
308 "* this time source is slow. Consider trying "
309 "other time sources (clock=)\n");
310 pmtmr_has_bug = 1;
311 }
312 pci_dev_put(dev);
313 }
314
315 if (pci_dev_present(gray_list)) {
316 printk(KERN_WARNING "* This chipset may have PM-Timer Bug. Due"
317 " to workarounds for a bug,\n"
318 "* this time source is slow. If you are sure your timer"
319 " does not have\n"
320 "* this bug, please use \"pmtmr_good\" to disable the "
321 "workaround\n");
322 pmtmr_has_bug = 1;
323 }
324
325 if (!pmtmr_has_bug)
326 pmtmr_need_workaround = 0;
327
328 return 0;
329}
330device_initcall(pmtmr_bug_check);
331#endif
332
333static int __init pmtr_good_setup(char *__str)
334{
335 pmtmr_need_workaround = 0;
336 return 1;
337}
338__setup("pmtmr_good", pmtr_good_setup);
339
266MODULE_LICENSE("GPL"); 340MODULE_LICENSE("GPL");
267MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); 341MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
268MODULE_DESCRIPTION("Power Management Timer (PMTMR) as primary timing source for x86"); 342MODULE_DESCRIPTION("Power Management Timer (PMTMR) as primary timing source for x86");
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index de5386b01d38..6b63a5aa1e46 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -92,22 +92,21 @@ asmlinkage void spurious_interrupt_bug(void);
92asmlinkage void machine_check(void); 92asmlinkage void machine_check(void);
93 93
94static int kstack_depth_to_print = 24; 94static int kstack_depth_to_print = 24;
95struct notifier_block *i386die_chain; 95ATOMIC_NOTIFIER_HEAD(i386die_chain);
96static DEFINE_SPINLOCK(die_notifier_lock);
97 96
98int register_die_notifier(struct notifier_block *nb) 97int register_die_notifier(struct notifier_block *nb)
99{ 98{
100 int err = 0;
101 unsigned long flags;
102
103 vmalloc_sync_all(); 99 vmalloc_sync_all();
104 spin_lock_irqsave(&die_notifier_lock, flags); 100 return atomic_notifier_chain_register(&i386die_chain, nb);
105 err = notifier_chain_register(&i386die_chain, nb);
106 spin_unlock_irqrestore(&die_notifier_lock, flags);
107 return err;
108} 101}
109EXPORT_SYMBOL(register_die_notifier); 102EXPORT_SYMBOL(register_die_notifier);
110 103
104int unregister_die_notifier(struct notifier_block *nb)
105{
106 return atomic_notifier_chain_unregister(&i386die_chain, nb);
107}
108EXPORT_SYMBOL(unregister_die_notifier);
109
111static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) 110static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
112{ 111{
113 return p > (void *)tinfo && 112 return p > (void *)tinfo &&
@@ -386,8 +385,12 @@ void die(const char * str, struct pt_regs * regs, long err)
386#endif 385#endif
387 if (nl) 386 if (nl)
388 printk("\n"); 387 printk("\n");
389 notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV); 388 if (notify_die(DIE_OOPS, str, regs, err,
390 show_registers(regs); 389 current->thread.trap_no, SIGSEGV) !=
390 NOTIFY_STOP)
391 show_registers(regs);
392 else
393 regs = NULL;
391 } else 394 } else
392 printk(KERN_EMERG "Recursive die() failure, output suppressed\n"); 395 printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
393 396
@@ -395,6 +398,9 @@ void die(const char * str, struct pt_regs * regs, long err)
395 die.lock_owner = -1; 398 die.lock_owner = -1;
396 spin_unlock_irqrestore(&die.lock, flags); 399 spin_unlock_irqrestore(&die.lock, flags);
397 400
401 if (!regs)
402 return;
403
398 if (kexec_should_crash(current)) 404 if (kexec_should_crash(current))
399 crash_kexec(regs); 405 crash_kexec(regs);
400 406
@@ -623,7 +629,7 @@ static DEFINE_SPINLOCK(nmi_print_lock);
623 629
624void die_nmi (struct pt_regs *regs, const char *msg) 630void die_nmi (struct pt_regs *regs, const char *msg)
625{ 631{
626 if (notify_die(DIE_NMIWATCHDOG, msg, regs, 0, 0, SIGINT) == 632 if (notify_die(DIE_NMIWATCHDOG, msg, regs, 0, 2, SIGINT) ==
627 NOTIFY_STOP) 633 NOTIFY_STOP)
628 return; 634 return;
629 635
@@ -662,7 +668,7 @@ static void default_do_nmi(struct pt_regs * regs)
662 reason = get_nmi_reason(); 668 reason = get_nmi_reason();
663 669
664 if (!(reason & 0xc0)) { 670 if (!(reason & 0xc0)) {
665 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 0, SIGINT) 671 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
666 == NOTIFY_STOP) 672 == NOTIFY_STOP)
667 return; 673 return;
668#ifdef CONFIG_X86_LOCAL_APIC 674#ifdef CONFIG_X86_LOCAL_APIC
@@ -678,7 +684,7 @@ static void default_do_nmi(struct pt_regs * regs)
678 unknown_nmi_error(reason, regs); 684 unknown_nmi_error(reason, regs);
679 return; 685 return;
680 } 686 }
681 if (notify_die(DIE_NMI, "nmi", regs, reason, 0, SIGINT) == NOTIFY_STOP) 687 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
682 return; 688 return;
683 if (reason & 0x80) 689 if (reason & 0x80)
684 mem_parity_error(reason, regs); 690 mem_parity_error(reason, regs);
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index 8165626a5c30..70e560a1b79a 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -1700,7 +1700,7 @@ after_handle_vic_irq(unsigned int irq)
1700 1700
1701 printk("VOYAGER SMP: CPU%d lost interrupt %d\n", 1701 printk("VOYAGER SMP: CPU%d lost interrupt %d\n",
1702 cpu, irq); 1702 cpu, irq);
1703 for_each_cpu(real_cpu, mask) { 1703 for_each_possible_cpu(real_cpu, mask) {
1704 1704
1705 outb(VIC_CPU_MASQUERADE_ENABLE | real_cpu, 1705 outb(VIC_CPU_MASQUERADE_ENABLE | real_cpu,
1706 VIC_PROCESSOR_ID); 1706 VIC_PROCESSOR_ID);
diff --git a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
index c4af9638dbfa..fe6eb901326e 100644
--- a/arch/i386/mm/discontig.c
+++ b/arch/i386/mm/discontig.c
@@ -31,6 +31,7 @@
31#include <linux/nodemask.h> 31#include <linux/nodemask.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/kexec.h> 33#include <linux/kexec.h>
34#include <linux/pfn.h>
34 35
35#include <asm/e820.h> 36#include <asm/e820.h>
36#include <asm/setup.h> 37#include <asm/setup.h>
@@ -352,17 +353,6 @@ void __init zone_sizes_init(void)
352{ 353{
353 int nid; 354 int nid;
354 355
355 /*
356 * Insert nodes into pgdat_list backward so they appear in order.
357 * Clobber node 0's links and NULL out pgdat_list before starting.
358 */
359 pgdat_list = NULL;
360 for (nid = MAX_NUMNODES - 1; nid >= 0; nid--) {
361 if (!node_online(nid))
362 continue;
363 NODE_DATA(nid)->pgdat_next = pgdat_list;
364 pgdat_list = NODE_DATA(nid);
365 }
366 356
367 for_each_online_node(nid) { 357 for_each_online_node(nid) {
368 unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0}; 358 unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
index 9db3242103be..2889567e21a1 100644
--- a/arch/i386/mm/pgtable.c
+++ b/arch/i386/mm/pgtable.c
@@ -36,7 +36,7 @@ void show_mem(void)
36 printk(KERN_INFO "Mem-info:\n"); 36 printk(KERN_INFO "Mem-info:\n");
37 show_free_areas(); 37 show_free_areas();
38 printk(KERN_INFO "Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 38 printk(KERN_INFO "Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
39 for_each_pgdat(pgdat) { 39 for_each_online_pgdat(pgdat) {
40 pgdat_resize_lock(pgdat, &flags); 40 pgdat_resize_lock(pgdat, &flags);
41 for (i = 0; i < pgdat->node_spanned_pages; ++i) { 41 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
42 page = pgdat_page_nr(pgdat, i); 42 page = pgdat_page_nr(pgdat, i);
diff --git a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
index 1accce50c2c7..1a2076ce6f6a 100644
--- a/arch/i386/oprofile/nmi_int.c
+++ b/arch/i386/oprofile/nmi_int.c
@@ -122,7 +122,7 @@ static void nmi_save_registers(void * dummy)
122static void free_msrs(void) 122static void free_msrs(void)
123{ 123{
124 int i; 124 int i;
125 for_each_cpu(i) { 125 for_each_possible_cpu(i) {
126 kfree(cpu_msrs[i].counters); 126 kfree(cpu_msrs[i].counters);
127 cpu_msrs[i].counters = NULL; 127 cpu_msrs[i].counters = NULL;
128 kfree(cpu_msrs[i].controls); 128 kfree(cpu_msrs[i].controls);
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 10b6b9e7716b..edffe25a477a 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -34,6 +34,10 @@ config RWSEM_XCHGADD_ALGORITHM
34 bool 34 bool
35 default y 35 default y
36 36
37config GENERIC_FIND_NEXT_BIT
38 bool
39 default y
40
37config GENERIC_CALIBRATE_DELAY 41config GENERIC_CALIBRATE_DELAY
38 bool 42 bool
39 default y 43 default y
@@ -42,6 +46,10 @@ config TIME_INTERPOLATION
42 bool 46 bool
43 default y 47 default y
44 48
49config DMI
50 bool
51 default y
52
45config EFI 53config EFI
46 bool 54 bool
47 default y 55 default y
diff --git a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
index 68ceb4e690c7..ccb98ed48e58 100644
--- a/arch/ia64/ia32/ia32priv.h
+++ b/arch/ia64/ia32/ia32priv.h
@@ -29,9 +29,9 @@
29struct partial_page { 29struct partial_page {
30 struct partial_page *next; /* linked list, sorted by address */ 30 struct partial_page *next; /* linked list, sorted by address */
31 struct rb_node pp_rb; 31 struct rb_node pp_rb;
32 /* 64K is the largest "normal" page supported by ia64 ABI. So 4K*32 32 /* 64K is the largest "normal" page supported by ia64 ABI. So 4K*64
33 * should suffice.*/ 33 * should suffice.*/
34 unsigned int bitmap; 34 unsigned long bitmap;
35 unsigned int base; 35 unsigned int base;
36}; 36};
37 37
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 13e739e4c84d..5366b3b23d09 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -25,7 +25,6 @@
25#include <linux/resource.h> 25#include <linux/resource.h>
26#include <linux/times.h> 26#include <linux/times.h>
27#include <linux/utsname.h> 27#include <linux/utsname.h>
28#include <linux/timex.h>
29#include <linux/smp.h> 28#include <linux/smp.h>
30#include <linux/smp_lock.h> 29#include <linux/smp_lock.h>
31#include <linux/sem.h> 30#include <linux/sem.h>
@@ -2591,78 +2590,4 @@ sys32_setresgid(compat_gid_t rgid, compat_gid_t egid,
2591 ssgid = (sgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)sgid); 2590 ssgid = (sgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)sgid);
2592 return sys_setresgid(srgid, segid, ssgid); 2591 return sys_setresgid(srgid, segid, ssgid);
2593} 2592}
2594
2595/* Handle adjtimex compatibility. */
2596
2597struct timex32 {
2598 u32 modes;
2599 s32 offset, freq, maxerror, esterror;
2600 s32 status, constant, precision, tolerance;
2601 struct compat_timeval time;
2602 s32 tick;
2603 s32 ppsfreq, jitter, shift, stabil;
2604 s32 jitcnt, calcnt, errcnt, stbcnt;
2605 s32 :32; s32 :32; s32 :32; s32 :32;
2606 s32 :32; s32 :32; s32 :32; s32 :32;
2607 s32 :32; s32 :32; s32 :32; s32 :32;
2608};
2609
2610extern int do_adjtimex(struct timex *);
2611
2612asmlinkage long
2613sys32_adjtimex(struct timex32 *utp)
2614{
2615 struct timex txc;
2616 int ret;
2617
2618 memset(&txc, 0, sizeof(struct timex));
2619
2620 if(get_user(txc.modes, &utp->modes) ||
2621 __get_user(txc.offset, &utp->offset) ||
2622 __get_user(txc.freq, &utp->freq) ||
2623 __get_user(txc.maxerror, &utp->maxerror) ||
2624 __get_user(txc.esterror, &utp->esterror) ||
2625 __get_user(txc.status, &utp->status) ||
2626 __get_user(txc.constant, &utp->constant) ||
2627 __get_user(txc.precision, &utp->precision) ||
2628 __get_user(txc.tolerance, &utp->tolerance) ||
2629 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
2630 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
2631 __get_user(txc.tick, &utp->tick) ||
2632 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
2633 __get_user(txc.jitter, &utp->jitter) ||
2634 __get_user(txc.shift, &utp->shift) ||
2635 __get_user(txc.stabil, &utp->stabil) ||
2636 __get_user(txc.jitcnt, &utp->jitcnt) ||
2637 __get_user(txc.calcnt, &utp->calcnt) ||
2638 __get_user(txc.errcnt, &utp->errcnt) ||
2639 __get_user(txc.stbcnt, &utp->stbcnt))
2640 return -EFAULT;
2641
2642 ret = do_adjtimex(&txc);
2643
2644 if(put_user(txc.modes, &utp->modes) ||
2645 __put_user(txc.offset, &utp->offset) ||
2646 __put_user(txc.freq, &utp->freq) ||
2647 __put_user(txc.maxerror, &utp->maxerror) ||
2648 __put_user(txc.esterror, &utp->esterror) ||
2649 __put_user(txc.status, &utp->status) ||
2650 __put_user(txc.constant, &utp->constant) ||
2651 __put_user(txc.precision, &utp->precision) ||
2652 __put_user(txc.tolerance, &utp->tolerance) ||
2653 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
2654 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
2655 __put_user(txc.tick, &utp->tick) ||
2656 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
2657 __put_user(txc.jitter, &utp->jitter) ||
2658 __put_user(txc.shift, &utp->shift) ||
2659 __put_user(txc.stabil, &utp->stabil) ||
2660 __put_user(txc.jitcnt, &utp->jitcnt) ||
2661 __put_user(txc.calcnt, &utp->calcnt) ||
2662 __put_user(txc.errcnt, &utp->errcnt) ||
2663 __put_user(txc.stbcnt, &utp->stbcnt))
2664 ret = -EFAULT;
2665
2666 return ret;
2667}
2668#endif /* NOTYET */ 2593#endif /* NOTYET */
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index 09a0dbc17fb6..59e871dae742 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.lds
7obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ 7obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \
8 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \ 8 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \
9 salinfo.o semaphore.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ 9 salinfo.o semaphore.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \
10 unwind.o mca.o mca_asm.o topology.o 10 unwind.o mca.o mca_asm.o topology.o dmi_scan.o
11 11
12obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o 12obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o
13obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o 13obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o
@@ -30,6 +30,7 @@ obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o
30obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o 30obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o
31obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o 31obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o
32mca_recovery-y += mca_drv.o mca_drv_asm.o 32mca_recovery-y += mca_drv.o mca_drv_asm.o
33dmi_scan-y += ../../i386/kernel/dmi_scan.o
33 34
34# The gate DSO image is built using a special linker script. 35# The gate DSO image is built using a special linker script.
35targets += gate.so gate-syms.o 36targets += gate.so gate-syms.o
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index a4e218ce2edb..58c93a30348c 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -651,9 +651,9 @@ unsigned long __init acpi_find_rsdp(void)
651{ 651{
652 unsigned long rsdp_phys = 0; 652 unsigned long rsdp_phys = 0;
653 653
654 if (efi.acpi20) 654 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
655 rsdp_phys = __pa(efi.acpi20); 655 rsdp_phys = efi.acpi20;
656 else if (efi.acpi) 656 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
657 printk(KERN_WARNING PREFIX 657 printk(KERN_WARNING PREFIX
658 "v1.0/r0.71 tables no longer supported\n"); 658 "v1.0/r0.71 tables no longer supported\n");
659 return rsdp_phys; 659 return rsdp_phys;
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c
index 9990320b6f9a..12cfedce73b1 100644
--- a/arch/ia64/kernel/efi.c
+++ b/arch/ia64/kernel/efi.c
@@ -458,24 +458,33 @@ efi_init (void)
458 printk(KERN_INFO "EFI v%u.%.02u by %s:", 458 printk(KERN_INFO "EFI v%u.%.02u by %s:",
459 efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 0xffff, vendor); 459 efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 0xffff, vendor);
460 460
461 efi.mps = EFI_INVALID_TABLE_ADDR;
462 efi.acpi = EFI_INVALID_TABLE_ADDR;
463 efi.acpi20 = EFI_INVALID_TABLE_ADDR;
464 efi.smbios = EFI_INVALID_TABLE_ADDR;
465 efi.sal_systab = EFI_INVALID_TABLE_ADDR;
466 efi.boot_info = EFI_INVALID_TABLE_ADDR;
467 efi.hcdp = EFI_INVALID_TABLE_ADDR;
468 efi.uga = EFI_INVALID_TABLE_ADDR;
469
461 for (i = 0; i < (int) efi.systab->nr_tables; i++) { 470 for (i = 0; i < (int) efi.systab->nr_tables; i++) {
462 if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) { 471 if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
463 efi.mps = __va(config_tables[i].table); 472 efi.mps = config_tables[i].table;
464 printk(" MPS=0x%lx", config_tables[i].table); 473 printk(" MPS=0x%lx", config_tables[i].table);
465 } else if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) { 474 } else if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
466 efi.acpi20 = __va(config_tables[i].table); 475 efi.acpi20 = config_tables[i].table;
467 printk(" ACPI 2.0=0x%lx", config_tables[i].table); 476 printk(" ACPI 2.0=0x%lx", config_tables[i].table);
468 } else if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) { 477 } else if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
469 efi.acpi = __va(config_tables[i].table); 478 efi.acpi = config_tables[i].table;
470 printk(" ACPI=0x%lx", config_tables[i].table); 479 printk(" ACPI=0x%lx", config_tables[i].table);
471 } else if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) { 480 } else if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
472 efi.smbios = __va(config_tables[i].table); 481 efi.smbios = config_tables[i].table;
473 printk(" SMBIOS=0x%lx", config_tables[i].table); 482 printk(" SMBIOS=0x%lx", config_tables[i].table);
474 } else if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) { 483 } else if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) {
475 efi.sal_systab = __va(config_tables[i].table); 484 efi.sal_systab = config_tables[i].table;
476 printk(" SALsystab=0x%lx", config_tables[i].table); 485 printk(" SALsystab=0x%lx", config_tables[i].table);
477 } else if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) { 486 } else if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
478 efi.hcdp = __va(config_tables[i].table); 487 efi.hcdp = config_tables[i].table;
479 printk(" HCDP=0x%lx", config_tables[i].table); 488 printk(" HCDP=0x%lx", config_tables[i].table);
480 } 489 }
481 } 490 }
@@ -677,27 +686,34 @@ EXPORT_SYMBOL(efi_mem_attributes);
677/* 686/*
678 * Determines whether the memory at phys_addr supports the desired 687 * Determines whether the memory at phys_addr supports the desired
679 * attribute (WB, UC, etc). If this returns 1, the caller can safely 688 * attribute (WB, UC, etc). If this returns 1, the caller can safely
680 * access *size bytes at phys_addr with the specified attribute. 689 * access size bytes at phys_addr with the specified attribute.
681 */ 690 */
682static int 691int
683efi_mem_attribute_range (unsigned long phys_addr, unsigned long *size, u64 attr) 692efi_mem_attribute_range (unsigned long phys_addr, unsigned long size, u64 attr)
684{ 693{
694 unsigned long end = phys_addr + size;
685 efi_memory_desc_t *md = efi_memory_descriptor(phys_addr); 695 efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
686 unsigned long md_end;
687 696
688 if (!md || (md->attribute & attr) != attr) 697 /*
698 * Some firmware doesn't report MMIO regions in the EFI memory
699 * map. The Intel BigSur (a.k.a. HP i2000) has this problem.
700 * On those platforms, we have to assume UC is valid everywhere.
701 */
702 if (!md || (md->attribute & attr) != attr) {
703 if (attr == EFI_MEMORY_UC && !efi_memmap_has_mmio())
704 return 1;
689 return 0; 705 return 0;
706 }
690 707
691 do { 708 do {
692 md_end = efi_md_end(md); 709 unsigned long md_end = efi_md_end(md);
693 if (phys_addr + *size <= md_end) 710
711 if (end <= md_end)
694 return 1; 712 return 1;
695 713
696 md = efi_memory_descriptor(md_end); 714 md = efi_memory_descriptor(md_end);
697 if (!md || (md->attribute & attr) != attr) { 715 if (!md || (md->attribute & attr) != attr)
698 *size = md_end - phys_addr; 716 return 0;
699 return 1;
700 }
701 } while (md); 717 } while (md);
702 return 0; 718 return 0;
703} 719}
@@ -708,7 +724,7 @@ efi_mem_attribute_range (unsigned long phys_addr, unsigned long *size, u64 attr)
708 * control access size. 724 * control access size.
709 */ 725 */
710int 726int
711valid_phys_addr_range (unsigned long phys_addr, unsigned long *size) 727valid_phys_addr_range (unsigned long phys_addr, unsigned long size)
712{ 728{
713 return efi_mem_attribute_range(phys_addr, size, EFI_MEMORY_WB); 729 return efi_mem_attribute_range(phys_addr, size, EFI_MEMORY_WB);
714} 730}
@@ -723,7 +739,7 @@ valid_phys_addr_range (unsigned long phys_addr, unsigned long *size)
723 * because that doesn't appear in the boot-time EFI memory map. 739 * because that doesn't appear in the boot-time EFI memory map.
724 */ 740 */
725int 741int
726valid_mmap_phys_addr_range (unsigned long phys_addr, unsigned long *size) 742valid_mmap_phys_addr_range (unsigned long phys_addr, unsigned long size)
727{ 743{
728 if (efi_mem_attribute_range(phys_addr, size, EFI_MEMORY_WB)) 744 if (efi_mem_attribute_range(phys_addr, size, EFI_MEMORY_WB))
729 return 1; 745 return 1;
@@ -731,14 +747,6 @@ valid_mmap_phys_addr_range (unsigned long phys_addr, unsigned long *size)
731 if (efi_mem_attribute_range(phys_addr, size, EFI_MEMORY_UC)) 747 if (efi_mem_attribute_range(phys_addr, size, EFI_MEMORY_UC))
732 return 1; 748 return 1;
733 749
734 /*
735 * Some firmware doesn't report MMIO regions in the EFI memory map.
736 * The Intel BigSur (a.k.a. HP i2000) has this problem. In this
737 * case, we can't use the EFI memory map to validate mmap requests.
738 */
739 if (!efi_memmap_has_mmio())
740 return 1;
741
742 return 0; 750 return 0;
743} 751}
744 752
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 50ae8c7d453d..789881ca83d4 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -34,6 +34,7 @@
34#include <asm/pgtable.h> 34#include <asm/pgtable.h>
35#include <asm/kdebug.h> 35#include <asm/kdebug.h>
36#include <asm/sections.h> 36#include <asm/sections.h>
37#include <asm/uaccess.h>
37 38
38extern void jprobe_inst_return(void); 39extern void jprobe_inst_return(void);
39 40
@@ -722,13 +723,50 @@ static int __kprobes kprobes_fault_handler(struct pt_regs *regs, int trapnr)
722 struct kprobe *cur = kprobe_running(); 723 struct kprobe *cur = kprobe_running();
723 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 724 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
724 725
725 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
726 return 1;
727 726
728 if (kcb->kprobe_status & KPROBE_HIT_SS) { 727 switch(kcb->kprobe_status) {
729 resume_execution(cur, regs); 728 case KPROBE_HIT_SS:
730 reset_current_kprobe(); 729 case KPROBE_REENTER:
730 /*
731 * We are here because the instruction being single
732 * stepped caused a page fault. We reset the current
733 * kprobe and the instruction pointer points back to
734 * the probe address and allow the page fault handler
735 * to continue as a normal page fault.
736 */
737 regs->cr_iip = ((unsigned long)cur->addr) & ~0xFULL;
738 ia64_psr(regs)->ri = ((unsigned long)cur->addr) & 0xf;
739 if (kcb->kprobe_status == KPROBE_REENTER)
740 restore_previous_kprobe(kcb);
741 else
742 reset_current_kprobe();
731 preempt_enable_no_resched(); 743 preempt_enable_no_resched();
744 break;
745 case KPROBE_HIT_ACTIVE:
746 case KPROBE_HIT_SSDONE:
747 /*
748 * We increment the nmissed count for accounting,
749 * we can also use npre/npostfault count for accouting
750 * these specific fault cases.
751 */
752 kprobes_inc_nmissed_count(cur);
753
754 /*
755 * We come here because instructions in the pre/post
756 * handler caused the page_fault, this could happen
757 * if handler tries to access user space by
758 * copy_from_user(), get_user() etc. Let the
759 * user-specified handler try to fix it first.
760 */
761 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
762 return 1;
763
764 /*
765 * Let ia64_do_page_fault() fix it.
766 */
767 break;
768 default:
769 break;
732 } 770 }
733 771
734 return 0; 772 return 0;
@@ -740,6 +778,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
740 struct die_args *args = (struct die_args *)data; 778 struct die_args *args = (struct die_args *)data;
741 int ret = NOTIFY_DONE; 779 int ret = NOTIFY_DONE;
742 780
781 if (args->regs && user_mode(args->regs))
782 return ret;
783
743 switch(val) { 784 switch(val) {
744 case DIE_BREAK: 785 case DIE_BREAK:
745 /* err is break number from ia64_bad_break() */ 786 /* err is break number from ia64_bad_break() */
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 87ff7fe33cfb..8963171788d5 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -69,6 +69,7 @@
69#include <linux/kernel.h> 69#include <linux/kernel.h>
70#include <linux/smp.h> 70#include <linux/smp.h>
71#include <linux/workqueue.h> 71#include <linux/workqueue.h>
72#include <linux/cpumask.h>
72 73
73#include <asm/delay.h> 74#include <asm/delay.h>
74#include <asm/kdebug.h> 75#include <asm/kdebug.h>
@@ -1505,7 +1506,7 @@ format_mca_init_stack(void *mca_data, unsigned long offset,
1505 ti->cpu = cpu; 1506 ti->cpu = cpu;
1506 p->thread_info = ti; 1507 p->thread_info = ti;
1507 p->state = TASK_UNINTERRUPTIBLE; 1508 p->state = TASK_UNINTERRUPTIBLE;
1508 __set_bit(cpu, &p->cpus_allowed); 1509 cpu_set(cpu, p->cpus_allowed);
1509 INIT_LIST_HEAD(&p->tasks); 1510 INIT_LIST_HEAD(&p->tasks);
1510 p->parent = p->real_parent = p->group_leader = p; 1511 p->parent = p->real_parent = p->group_leader = p;
1511 INIT_LIST_HEAD(&p->children); 1512 INIT_LIST_HEAD(&p->children);
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 309d59658e5f..355d57970ba3 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -30,7 +30,6 @@
30#include <linux/efi.h> 30#include <linux/efi.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/kprobes.h>
34 33
35#include <asm/cpu.h> 34#include <asm/cpu.h>
36#include <asm/delay.h> 35#include <asm/delay.h>
@@ -738,13 +737,6 @@ void
738exit_thread (void) 737exit_thread (void)
739{ 738{
740 739
741 /*
742 * Remove function-return probe instances associated with this task
743 * and put them back on the free list. Do not insert an exit probe for
744 * this function, it will be disabled by kprobe_flush_task if you do.
745 */
746 kprobe_flush_task(current);
747
748 ia64_drop_fpu(current); 740 ia64_drop_fpu(current);
749#ifdef CONFIG_PERFMON 741#ifdef CONFIG_PERFMON
750 /* if needed, stop monitoring and flush state to perfmon context */ 742 /* if needed, stop monitoring and flush state to perfmon context */
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index eb388e271b2b..e4dfda1eb7dd 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -37,6 +37,7 @@
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/threads.h> 38#include <linux/threads.h>
39#include <linux/tty.h> 39#include <linux/tty.h>
40#include <linux/dmi.h>
40#include <linux/serial.h> 41#include <linux/serial.h>
41#include <linux/serial_core.h> 42#include <linux/serial_core.h>
42#include <linux/efi.h> 43#include <linux/efi.h>
@@ -433,7 +434,7 @@ setup_arch (char **cmdline_p)
433 find_memory(); 434 find_memory();
434 435
435 /* process SAL system table: */ 436 /* process SAL system table: */
436 ia64_sal_init(efi.sal_systab); 437 ia64_sal_init(__va(efi.sal_systab));
437 438
438 ia64_setup_printk_clock(); 439 ia64_setup_printk_clock();
439 440
@@ -887,3 +888,10 @@ check_bugs (void)
887 ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles, 888 ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
888 (unsigned long) __end___mckinley_e9_bundles); 889 (unsigned long) __end___mckinley_e9_bundles);
889} 890}
891
892static int __init run_dmi_scan(void)
893{
894 dmi_scan_machine();
895 return 0;
896}
897core_initcall(run_dmi_scan);
diff --git a/arch/ia64/kernel/traps.c b/arch/ia64/kernel/traps.c
index dabd6c32641e..7c1ddc8ac443 100644
--- a/arch/ia64/kernel/traps.c
+++ b/arch/ia64/kernel/traps.c
@@ -30,19 +30,19 @@ extern spinlock_t timerlist_lock;
30fpswa_interface_t *fpswa_interface; 30fpswa_interface_t *fpswa_interface;
31EXPORT_SYMBOL(fpswa_interface); 31EXPORT_SYMBOL(fpswa_interface);
32 32
33struct notifier_block *ia64die_chain; 33ATOMIC_NOTIFIER_HEAD(ia64die_chain);
34 34
35int 35int
36register_die_notifier(struct notifier_block *nb) 36register_die_notifier(struct notifier_block *nb)
37{ 37{
38 return notifier_chain_register(&ia64die_chain, nb); 38 return atomic_notifier_chain_register(&ia64die_chain, nb);
39} 39}
40EXPORT_SYMBOL_GPL(register_die_notifier); 40EXPORT_SYMBOL_GPL(register_die_notifier);
41 41
42int 42int
43unregister_die_notifier(struct notifier_block *nb) 43unregister_die_notifier(struct notifier_block *nb)
44{ 44{
45 return notifier_chain_unregister(&ia64die_chain, nb); 45 return atomic_notifier_chain_unregister(&ia64die_chain, nb);
46} 46}
47EXPORT_SYMBOL_GPL(unregister_die_notifier); 47EXPORT_SYMBOL_GPL(unregister_die_notifier);
48 48
diff --git a/arch/ia64/lib/Makefile b/arch/ia64/lib/Makefile
index ac64664a1807..d8536a2c22a9 100644
--- a/arch/ia64/lib/Makefile
+++ b/arch/ia64/lib/Makefile
@@ -6,7 +6,7 @@ obj-y := io.o
6 6
7lib-y := __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \ 7lib-y := __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \
8 __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o \ 8 __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o \
9 bitop.o checksum.o clear_page.o csum_partial_copy.o \ 9 checksum.o clear_page.o csum_partial_copy.o \
10 clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o \ 10 clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o \
11 flush.o ip_fast_csum.o do_csum.o \ 11 flush.o ip_fast_csum.o do_csum.o \
12 memset.o strlen.o 12 memset.o strlen.o
diff --git a/arch/ia64/lib/bitop.c b/arch/ia64/lib/bitop.c
deleted file mode 100644
index 82e299c8464e..000000000000
--- a/arch/ia64/lib/bitop.c
+++ /dev/null
@@ -1,88 +0,0 @@
1#include <linux/compiler.h>
2#include <linux/types.h>
3#include <asm/intrinsics.h>
4#include <linux/module.h>
5#include <linux/bitops.h>
6
7/*
8 * Find next zero bit in a bitmap reasonably efficiently..
9 */
10
11int __find_next_zero_bit (const void *addr, unsigned long size, unsigned long offset)
12{
13 unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
14 unsigned long result = offset & ~63UL;
15 unsigned long tmp;
16
17 if (offset >= size)
18 return size;
19 size -= result;
20 offset &= 63UL;
21 if (offset) {
22 tmp = *(p++);
23 tmp |= ~0UL >> (64-offset);
24 if (size < 64)
25 goto found_first;
26 if (~tmp)
27 goto found_middle;
28 size -= 64;
29 result += 64;
30 }
31 while (size & ~63UL) {
32 if (~(tmp = *(p++)))
33 goto found_middle;
34 result += 64;
35 size -= 64;
36 }
37 if (!size)
38 return result;
39 tmp = *p;
40found_first:
41 tmp |= ~0UL << size;
42 if (tmp == ~0UL) /* any bits zero? */
43 return result + size; /* nope */
44found_middle:
45 return result + ffz(tmp);
46}
47EXPORT_SYMBOL(__find_next_zero_bit);
48
49/*
50 * Find next bit in a bitmap reasonably efficiently..
51 */
52int __find_next_bit(const void *addr, unsigned long size, unsigned long offset)
53{
54 unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
55 unsigned long result = offset & ~63UL;
56 unsigned long tmp;
57
58 if (offset >= size)
59 return size;
60 size -= result;
61 offset &= 63UL;
62 if (offset) {
63 tmp = *(p++);
64 tmp &= ~0UL << offset;
65 if (size < 64)
66 goto found_first;
67 if (tmp)
68 goto found_middle;
69 size -= 64;
70 result += 64;
71 }
72 while (size & ~63UL) {
73 if ((tmp = *(p++)))
74 goto found_middle;
75 result += 64;
76 size -= 64;
77 }
78 if (!size)
79 return result;
80 tmp = *p;
81 found_first:
82 tmp &= ~0UL >> (64-size);
83 if (tmp == 0UL) /* Are any bits set? */
84 return result + size; /* Nope. */
85 found_middle:
86 return result + __ffs(tmp);
87}
88EXPORT_SYMBOL(__find_next_bit);
diff --git a/arch/ia64/mm/Makefile b/arch/ia64/mm/Makefile
index d78d20f0a0f0..bb0a01a81878 100644
--- a/arch/ia64/mm/Makefile
+++ b/arch/ia64/mm/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the ia64-specific parts of the memory manager. 2# Makefile for the ia64-specific parts of the memory manager.
3# 3#
4 4
5obj-y := init.o fault.o tlb.o extable.o 5obj-y := init.o fault.o tlb.o extable.o ioremap.o
6 6
7obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 7obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
8obj-$(CONFIG_NUMA) += numa.o 8obj-$(CONFIG_NUMA) += numa.o
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 2f5e44862e91..ec9eeb89975d 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -379,31 +379,6 @@ static void __init *memory_less_node_alloc(int nid, unsigned long pernodesize)
379} 379}
380 380
381/** 381/**
382 * pgdat_insert - insert the pgdat into global pgdat_list
383 * @pgdat: the pgdat for a node.
384 */
385static void __init pgdat_insert(pg_data_t *pgdat)
386{
387 pg_data_t *prev = NULL, *next;
388
389 for_each_pgdat(next)
390 if (pgdat->node_id < next->node_id)
391 break;
392 else
393 prev = next;
394
395 if (prev) {
396 prev->pgdat_next = pgdat;
397 pgdat->pgdat_next = next;
398 } else {
399 pgdat->pgdat_next = pgdat_list;
400 pgdat_list = pgdat;
401 }
402
403 return;
404}
405
406/**
407 * memory_less_nodes - allocate and initialize CPU only nodes pernode 382 * memory_less_nodes - allocate and initialize CPU only nodes pernode
408 * information. 383 * information.
409 */ 384 */
@@ -560,7 +535,7 @@ void show_mem(void)
560 printk("Mem-info:\n"); 535 printk("Mem-info:\n");
561 show_free_areas(); 536 show_free_areas();
562 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 537 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
563 for_each_pgdat(pgdat) { 538 for_each_online_pgdat(pgdat) {
564 unsigned long present; 539 unsigned long present;
565 unsigned long flags; 540 unsigned long flags;
566 int shared = 0, cached = 0, reserved = 0; 541 int shared = 0, cached = 0, reserved = 0;
@@ -745,11 +720,5 @@ void __init paging_init(void)
745 pfn_offset, zholes_size); 720 pfn_offset, zholes_size);
746 } 721 }
747 722
748 /*
749 * Make memory less nodes become a member of the known nodes.
750 */
751 for_each_node_mask(node, memory_less_mask)
752 pgdat_insert(mem_data[node].pgdat);
753
754 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page)); 723 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
755} 724}
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index ff4f31fcd330..2ef1151cde90 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -600,7 +600,7 @@ mem_init (void)
600 kclist_add(&kcore_vmem, (void *)VMALLOC_START, VMALLOC_END-VMALLOC_START); 600 kclist_add(&kcore_vmem, (void *)VMALLOC_START, VMALLOC_END-VMALLOC_START);
601 kclist_add(&kcore_kernel, _stext, _end - _stext); 601 kclist_add(&kcore_kernel, _stext, _end - _stext);
602 602
603 for_each_pgdat(pgdat) 603 for_each_online_pgdat(pgdat)
604 if (pgdat->bdata->node_bootmem_map) 604 if (pgdat->bdata->node_bootmem_map)
605 totalram_pages += free_all_bootmem_node(pgdat); 605 totalram_pages += free_all_bootmem_node(pgdat);
606 606
diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c
new file mode 100644
index 000000000000..62328621f99c
--- /dev/null
+++ b/arch/ia64/mm/ioremap.c
@@ -0,0 +1,43 @@
1/*
2 * (c) Copyright 2006 Hewlett-Packard Development Company, L.P.
3 * Bjorn Helgaas <bjorn.helgaas@hp.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/compiler.h>
11#include <linux/module.h>
12#include <linux/efi.h>
13#include <asm/io.h>
14
15static inline void __iomem *
16__ioremap (unsigned long offset, unsigned long size)
17{
18 return (void __iomem *) (__IA64_UNCACHED_OFFSET | offset);
19}
20
21void __iomem *
22ioremap (unsigned long offset, unsigned long size)
23{
24 if (efi_mem_attribute_range(offset, size, EFI_MEMORY_UC))
25 return __ioremap(offset, size);
26
27 if (efi_mem_attribute_range(offset, size, EFI_MEMORY_WB))
28 return phys_to_virt(offset);
29
30 /*
31 * Someday this should check ACPI resources so we
32 * can do the right thing for hot-plugged regions.
33 */
34 return __ioremap(offset, size);
35}
36EXPORT_SYMBOL(ioremap);
37
38void __iomem *
39ioremap_nocache (unsigned long offset, unsigned long size)
40{
41 return __ioremap(offset, size);
42}
43EXPORT_SYMBOL(ioremap_nocache);
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index 8b6d5c844708..30988dfbddff 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -327,10 +327,11 @@ sn_scan_pcdp(void)
327 struct pcdp_interface_pci if_pci; 327 struct pcdp_interface_pci if_pci;
328 extern struct efi efi; 328 extern struct efi efi;
329 329
330 pcdp = efi.hcdp; 330 if (efi.hcdp == EFI_INVALID_TABLE_ADDR)
331 if (! pcdp)
332 return; /* no hcdp/pcdp table */ 331 return; /* no hcdp/pcdp table */
333 332
333 pcdp = __va(efi.hcdp);
334
334 if (pcdp->rev < 3) 335 if (pcdp->rev < 3)
335 return; /* only support PCDP (rev >= 3) */ 336 return; /* only support PCDP (rev >= 3) */
336 337
diff --git a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
index c686d9c12f7b..5100261310f7 100644
--- a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
+++ b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
@@ -93,19 +93,22 @@ static int coherence_id_open(struct inode *inode, struct file *file)
93static struct proc_dir_entry 93static struct proc_dir_entry
94*sn_procfs_create_entry(const char *name, struct proc_dir_entry *parent, 94*sn_procfs_create_entry(const char *name, struct proc_dir_entry *parent,
95 int (*openfunc)(struct inode *, struct file *), 95 int (*openfunc)(struct inode *, struct file *),
96 int (*releasefunc)(struct inode *, struct file *)) 96 int (*releasefunc)(struct inode *, struct file *),
97 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *))
97{ 98{
98 struct proc_dir_entry *e = create_proc_entry(name, 0444, parent); 99 struct proc_dir_entry *e = create_proc_entry(name, 0444, parent);
99 100
100 if (e) { 101 if (e) {
101 e->proc_fops = (struct file_operations *)kmalloc( 102 struct file_operations *f;
102 sizeof(struct file_operations), GFP_KERNEL); 103
103 if (e->proc_fops) { 104 f = kzalloc(sizeof(*f), GFP_KERNEL);
104 memset(e->proc_fops, 0, sizeof(struct file_operations)); 105 if (f) {
105 e->proc_fops->open = openfunc; 106 f->open = openfunc;
106 e->proc_fops->read = seq_read; 107 f->read = seq_read;
107 e->proc_fops->llseek = seq_lseek; 108 f->llseek = seq_lseek;
108 e->proc_fops->release = releasefunc; 109 f->release = releasefunc;
110 f->write = write;
111 e->proc_fops = f;
109 } 112 }
110 } 113 }
111 114
@@ -119,31 +122,29 @@ extern int sn_topology_release(struct inode *, struct file *);
119void register_sn_procfs(void) 122void register_sn_procfs(void)
120{ 123{
121 static struct proc_dir_entry *sgi_proc_dir = NULL; 124 static struct proc_dir_entry *sgi_proc_dir = NULL;
122 struct proc_dir_entry *e;
123 125
124 BUG_ON(sgi_proc_dir != NULL); 126 BUG_ON(sgi_proc_dir != NULL);
125 if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL))) 127 if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
126 return; 128 return;
127 129
128 sn_procfs_create_entry("partition_id", sgi_proc_dir, 130 sn_procfs_create_entry("partition_id", sgi_proc_dir,
129 partition_id_open, single_release); 131 partition_id_open, single_release, NULL);
130 132
131 sn_procfs_create_entry("system_serial_number", sgi_proc_dir, 133 sn_procfs_create_entry("system_serial_number", sgi_proc_dir,
132 system_serial_number_open, single_release); 134 system_serial_number_open, single_release, NULL);
133 135
134 sn_procfs_create_entry("licenseID", sgi_proc_dir, 136 sn_procfs_create_entry("licenseID", sgi_proc_dir,
135 licenseID_open, single_release); 137 licenseID_open, single_release, NULL);
136 138
137 e = sn_procfs_create_entry("sn_force_interrupt", sgi_proc_dir, 139 sn_procfs_create_entry("sn_force_interrupt", sgi_proc_dir,
138 sn_force_interrupt_open, single_release); 140 sn_force_interrupt_open, single_release,
139 if (e) 141 sn_force_interrupt_write_proc);
140 e->proc_fops->write = sn_force_interrupt_write_proc;
141 142
142 sn_procfs_create_entry("coherence_id", sgi_proc_dir, 143 sn_procfs_create_entry("coherence_id", sgi_proc_dir,
143 coherence_id_open, single_release); 144 coherence_id_open, single_release, NULL);
144 145
145 sn_procfs_create_entry("sn_topology", sgi_proc_dir, 146 sn_procfs_create_entry("sn_topology", sgi_proc_dir,
146 sn_topology_open, sn_topology_release); 147 sn_topology_open, sn_topology_release, NULL);
147} 148}
148 149
149#endif /* CONFIG_PROC_FS */ 150#endif /* CONFIG_PROC_FS */
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index a3dcc3fab4b7..05c864c6c2d9 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -214,6 +214,14 @@ config RWSEM_XCHGADD_ALGORITHM
214 bool 214 bool
215 default n 215 default n
216 216
217config GENERIC_FIND_NEXT_BIT
218 bool
219 default y
220
221config GENERIC_HWEIGHT
222 bool
223 default y
224
217config GENERIC_CALIBRATE_DELAY 225config GENERIC_CALIBRATE_DELAY
218 bool 226 bool
219 default y 227 default y
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index d742037a7ccb..0d78942b4c76 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -24,6 +24,7 @@
24#include <linux/tty.h> 24#include <linux/tty.h>
25#include <linux/cpu.h> 25#include <linux/cpu.h>
26#include <linux/nodemask.h> 26#include <linux/nodemask.h>
27#include <linux/pfn.h>
27 28
28#include <asm/processor.h> 29#include <asm/processor.h>
29#include <asm/pgtable.h> 30#include <asm/pgtable.h>
diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index 08e727955555..cf610a7c5ff0 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -13,6 +13,7 @@
13#include <linux/initrd.h> 13#include <linux/initrd.h>
14#include <linux/nodemask.h> 14#include <linux/nodemask.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/pfn.h>
16 17
17#include <asm/setup.h> 18#include <asm/setup.h>
18 19
@@ -137,12 +138,6 @@ unsigned long __init zone_sizes_init(void)
137 int nid, i; 138 int nid, i;
138 mem_prof_t *mp; 139 mem_prof_t *mp;
139 140
140 pgdat_list = NULL;
141 for (nid = num_online_nodes() - 1 ; nid >= 0 ; nid--) {
142 NODE_DATA(nid)->pgdat_next = pgdat_list;
143 pgdat_list = NODE_DATA(nid);
144 }
145
146 for_each_online_node(nid) { 141 for_each_online_node(nid) {
147 mp = &mem_prof[nid]; 142 mp = &mem_prof[nid];
148 for (i = 0 ; i < MAX_NR_ZONES ; i++) { 143 for (i = 0 ; i < MAX_NR_ZONES ; i++) {
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index c9e7dad860b7..b71348fec1f4 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -18,6 +18,7 @@
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19#include <linux/bitops.h> 19#include <linux/bitops.h>
20#include <linux/nodemask.h> 20#include <linux/nodemask.h>
21#include <linux/pfn.h>
21#include <asm/types.h> 22#include <asm/types.h>
22#include <asm/processor.h> 23#include <asm/processor.h>
23#include <asm/page.h> 24#include <asm/page.h>
@@ -47,7 +48,7 @@ void show_mem(void)
47 printk("Mem-info:\n"); 48 printk("Mem-info:\n");
48 show_free_areas(); 49 show_free_areas();
49 printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); 50 printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
50 for_each_pgdat(pgdat) { 51 for_each_online_pgdat(pgdat) {
51 unsigned long flags; 52 unsigned long flags;
52 pgdat_resize_lock(pgdat, &flags); 53 pgdat_resize_lock(pgdat, &flags);
53 for (i = 0; i < pgdat->node_spanned_pages; ++i) { 54 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 8849439e88dd..805b81fedf80 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -17,6 +17,10 @@ config RWSEM_GENERIC_SPINLOCK
17config RWSEM_XCHGADD_ALGORITHM 17config RWSEM_XCHGADD_ALGORITHM
18 bool 18 bool
19 19
20config GENERIC_HWEIGHT
21 bool
22 default y
23
20config GENERIC_CALIBRATE_DELAY 24config GENERIC_CALIBRATE_DELAY
21 bool 25 bool
22 default y 26 default y
diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c
index 3ffc84f9c291..c90cb5fcc8ef 100644
--- a/arch/m68k/bvme6000/config.c
+++ b/arch/m68k/bvme6000/config.c
@@ -142,7 +142,7 @@ void __init config_bvme6000(void)
142 /* Now do the PIT configuration */ 142 /* Now do the PIT configuration */
143 143
144 pit->pgcr = 0x00; /* Unidirectional 8 bit, no handshake for now */ 144 pit->pgcr = 0x00; /* Unidirectional 8 bit, no handshake for now */
145 pit->psrr = 0x18; /* PIACK and PIRQ fucntions enabled */ 145 pit->psrr = 0x18; /* PIACK and PIRQ functions enabled */
146 pit->pacr = 0x00; /* Sub Mode 00, H2 i/p, no DMA */ 146 pit->pacr = 0x00; /* Sub Mode 00, H2 i/p, no DMA */
147 pit->padr = 0x00; /* Just to be tidy! */ 147 pit->padr = 0x00; /* Just to be tidy! */
148 pit->paddr = 0x00; /* All inputs for now (safest) */ 148 pit->paddr = 0x00; /* All inputs for now (safest) */
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index a69fe3048edc..b0e4c084df8a 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -17,6 +17,7 @@
17#include <linux/poll.h> 17#include <linux/poll.h>
18#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ 18#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
19#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
20#include <linux/bcd.h>
20#include <asm/mvme16xhw.h> 21#include <asm/mvme16xhw.h>
21 22
22#include <asm/io.h> 23#include <asm/io.h>
@@ -31,9 +32,6 @@
31 * ioctls. 32 * ioctls.
32 */ 33 */
33 34
34#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
35#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
36
37static const unsigned char days_in_mo[] = 35static const unsigned char days_in_mo[] =
38{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 36{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
39 37
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index e50858dbc237..3cde6822ead1 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -25,6 +25,14 @@ config RWSEM_XCHGADD_ALGORITHM
25 bool 25 bool
26 default n 26 default n
27 27
28config GENERIC_FIND_NEXT_BIT
29 bool
30 default y
31
32config GENERIC_HWEIGHT
33 bool
34 default y
35
28config GENERIC_CALIBRATE_DELAY 36config GENERIC_CALIBRATE_DELAY
29 bool 37 bool
30 default y 38 default y
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ac2012f033d6..5080ea1799a4 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -801,6 +801,14 @@ config RWSEM_GENERIC_SPINLOCK
801config RWSEM_XCHGADD_ALGORITHM 801config RWSEM_XCHGADD_ALGORITHM
802 bool 802 bool
803 803
804config GENERIC_FIND_NEXT_BIT
805 bool
806 default y
807
808config GENERIC_HWEIGHT
809 bool
810 default y
811
804config GENERIC_CALIBRATE_DELAY 812config GENERIC_CALIBRATE_DELAY
805 bool 813 bool
806 default y 814 default y
diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c
index 1080558c8100..307e98c29ddc 100644
--- a/arch/mips/au1000/common/setup.c
+++ b/arch/mips/au1000/common/setup.c
@@ -94,7 +94,7 @@ void __init plat_setup(void)
94 94
95 argptr = prom_getcmdline(); 95 argptr = prom_getcmdline();
96 96
97#if defined(CONFIG_SERIAL_AU1X00_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) 97#ifdef CONFIG_SERIAL_8250_CONSOLE
98 if ((argptr = strstr(argptr, "console=")) == NULL) { 98 if ((argptr = strstr(argptr, "console=")) == NULL) {
99 argptr = prom_getcmdline(); 99 argptr = prom_getcmdline();
100 strcat(argptr, " console=ttyS0,115200"); 100 strcat(argptr, " console=ttyS0,115200");
diff --git a/arch/mips/ddb5xxx/common/rtc_ds1386.c b/arch/mips/ddb5xxx/common/rtc_ds1386.c
index 995896ac0e39..5dc34daa7150 100644
--- a/arch/mips/ddb5xxx/common/rtc_ds1386.c
+++ b/arch/mips/ddb5xxx/common/rtc_ds1386.c
@@ -165,6 +165,6 @@ rtc_ds1386_init(unsigned long base)
165 WRITE_RTC(0xB, byte); 165 WRITE_RTC(0xB, byte);
166 166
167 /* set the function pointers */ 167 /* set the function pointers */
168 rtc_get_time = rtc_ds1386_get_time; 168 rtc_mips_get_time = rtc_ds1386_get_time;
169 rtc_set_time = rtc_ds1386_set_time; 169 rtc_mips_set_time = rtc_ds1386_set_time;
170} 170}
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c
index 174822344131..74cb055d4bf6 100644
--- a/arch/mips/dec/time.c
+++ b/arch/mips/dec/time.c
@@ -36,41 +36,13 @@
36#include <asm/dec/ioasic_addrs.h> 36#include <asm/dec/ioasic_addrs.h>
37#include <asm/dec/machtype.h> 37#include <asm/dec/machtype.h>
38 38
39
40/*
41 * Returns true if a clock update is in progress
42 */
43static inline unsigned char dec_rtc_is_updating(void)
44{
45 unsigned char uip;
46 unsigned long flags;
47
48 spin_lock_irqsave(&rtc_lock, flags);
49 uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
50 spin_unlock_irqrestore(&rtc_lock, flags);
51 return uip;
52}
53
54static unsigned long dec_rtc_get_time(void) 39static unsigned long dec_rtc_get_time(void)
55{ 40{
56 unsigned int year, mon, day, hour, min, sec, real_year; 41 unsigned int year, mon, day, hour, min, sec, real_year;
57 int i;
58 unsigned long flags; 42 unsigned long flags;
59 43
60 /* The Linux interpretation of the DS1287 clock register contents:
61 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
62 * RTC registers show the second which has precisely just started.
63 * Let's hope other operating systems interpret the RTC the same way.
64 */
65 /* read RTC exactly on falling edge of update flag */
66 for (i = 0; i < 1000000; i++) /* may take up to 1 second... */
67 if (dec_rtc_is_updating())
68 break;
69 for (i = 0; i < 1000000; i++) /* must try at least 2.228 ms */
70 if (!dec_rtc_is_updating())
71 break;
72 spin_lock_irqsave(&rtc_lock, flags); 44 spin_lock_irqsave(&rtc_lock, flags);
73 /* Isn't this overkill? UIP above should guarantee consistency */ 45
74 do { 46 do {
75 sec = CMOS_READ(RTC_SECONDS); 47 sec = CMOS_READ(RTC_SECONDS);
76 min = CMOS_READ(RTC_MINUTES); 48 min = CMOS_READ(RTC_MINUTES);
@@ -78,7 +50,16 @@ static unsigned long dec_rtc_get_time(void)
78 day = CMOS_READ(RTC_DAY_OF_MONTH); 50 day = CMOS_READ(RTC_DAY_OF_MONTH);
79 mon = CMOS_READ(RTC_MONTH); 51 mon = CMOS_READ(RTC_MONTH);
80 year = CMOS_READ(RTC_YEAR); 52 year = CMOS_READ(RTC_YEAR);
53 /*
54 * The PROM will reset the year to either '72 or '73.
55 * Therefore we store the real year separately, in one
56 * of unused BBU RAM locations.
57 */
58 real_year = CMOS_READ(RTC_DEC_YEAR);
81 } while (sec != CMOS_READ(RTC_SECONDS)); 59 } while (sec != CMOS_READ(RTC_SECONDS));
60
61 spin_unlock_irqrestore(&rtc_lock, flags);
62
82 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { 63 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
83 sec = BCD2BIN(sec); 64 sec = BCD2BIN(sec);
84 min = BCD2BIN(min); 65 min = BCD2BIN(min);
@@ -87,13 +68,7 @@ static unsigned long dec_rtc_get_time(void)
87 mon = BCD2BIN(mon); 68 mon = BCD2BIN(mon);
88 year = BCD2BIN(year); 69 year = BCD2BIN(year);
89 } 70 }
90 /* 71
91 * The PROM will reset the year to either '72 or '73.
92 * Therefore we store the real year separately, in one
93 * of unused BBU RAM locations.
94 */
95 real_year = CMOS_READ(RTC_DEC_YEAR);
96 spin_unlock_irqrestore(&rtc_lock, flags);
97 year += real_year - 72 + 2000; 72 year += real_year - 72 + 2000;
98 73
99 return mktime(year, mon, day, hour, min, sec); 74 return mktime(year, mon, day, hour, min, sec);
@@ -193,8 +168,8 @@ static void dec_ioasic_hpt_init(unsigned int count)
193 168
194void __init dec_time_init(void) 169void __init dec_time_init(void)
195{ 170{
196 rtc_get_time = dec_rtc_get_time; 171 rtc_mips_get_time = dec_rtc_get_time;
197 rtc_set_mmss = dec_rtc_set_mmss; 172 rtc_mips_set_mmss = dec_rtc_set_mmss;
198 173
199 mips_timer_state = dec_timer_state; 174 mips_timer_state = dec_timer_state;
200 mips_timer_ack = dec_timer_ack; 175 mips_timer_ack = dec_timer_ack;
diff --git a/arch/mips/ite-boards/generic/time.c b/arch/mips/ite-boards/generic/time.c
index f5d67ee21ac6..b79817bb6cce 100644
--- a/arch/mips/ite-boards/generic/time.c
+++ b/arch/mips/ite-boards/generic/time.c
@@ -227,8 +227,8 @@ void __init it8172_time_init(void)
227 227
228 local_irq_restore(flags); 228 local_irq_restore(flags);
229 229
230 rtc_get_time = it8172_rtc_get_time; 230 rtc_mips_get_time = it8172_rtc_get_time;
231 rtc_set_time = it8172_rtc_set_time; 231 rtc_mips_set_time = it8172_rtc_set_time;
232} 232}
233 233
234#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) 234#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
diff --git a/arch/mips/ite-boards/ivr/init.c b/arch/mips/ite-boards/ivr/init.c
index ea4e1935fec5..b774db035b31 100644
--- a/arch/mips/ite-boards/ivr/init.c
+++ b/arch/mips/ite-boards/ivr/init.c
@@ -45,9 +45,6 @@ extern void __init prom_init_cmdline(void);
45extern unsigned long __init prom_get_memsize(void); 45extern unsigned long __init prom_get_memsize(void);
46extern void __init it8172_init_ram_resource(unsigned long memsize); 46extern void __init it8172_init_ram_resource(unsigned long memsize);
47 47
48#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
49#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
50
51const char *get_system_type(void) 48const char *get_system_type(void)
52{ 49{
53 return "Globespan IVR"; 50 return "Globespan IVR";
diff --git a/arch/mips/ite-boards/qed-4n-s01b/init.c b/arch/mips/ite-boards/qed-4n-s01b/init.c
index 56dca7e0c21d..e8ec8be66a80 100644
--- a/arch/mips/ite-boards/qed-4n-s01b/init.c
+++ b/arch/mips/ite-boards/qed-4n-s01b/init.c
@@ -45,9 +45,6 @@ extern void __init prom_init_cmdline(void);
45extern unsigned long __init prom_get_memsize(void); 45extern unsigned long __init prom_get_memsize(void);
46extern void __init it8172_init_ram_resource(unsigned long memsize); 46extern void __init it8172_init_ram_resource(unsigned long memsize);
47 47
48#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
49#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
50
51const char *get_system_type(void) 48const char *get_system_type(void)
52{ 49{
53 return "ITE QED-4N-S01B"; 50 return "ITE QED-4N-S01B";
diff --git a/arch/mips/jmr3927/common/rtc_ds1742.c b/arch/mips/jmr3927/common/rtc_ds1742.c
index 9a8bff153d80..a6bd3f4d3049 100644
--- a/arch/mips/jmr3927/common/rtc_ds1742.c
+++ b/arch/mips/jmr3927/common/rtc_ds1742.c
@@ -159,8 +159,8 @@ rtc_ds1742_init(unsigned long base)
159 db_assert((rtc_base & 0xe0000000) == KSEG1); 159 db_assert((rtc_base & 0xe0000000) == KSEG1);
160 160
161 /* set the function pointers */ 161 /* set the function pointers */
162 rtc_get_time = rtc_ds1742_get_time; 162 rtc_mips_get_time = rtc_ds1742_get_time;
163 rtc_set_time = rtc_ds1742_set_time; 163 rtc_mips_set_time = rtc_ds1742_set_time;
164 164
165 /* clear oscillator stop bit */ 165 /* clear oscillator stop bit */
166 CMOS_WRITE(RTC_READ, RTC_CONTROL); 166 CMOS_WRITE(RTC_READ, RTC_CONTROL);
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 013bc93688e8..3f40c37a9ee6 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -30,7 +30,6 @@
30#include <linux/utime.h> 30#include <linux/utime.h>
31#include <linux/utsname.h> 31#include <linux/utsname.h>
32#include <linux/personality.h> 32#include <linux/personality.h>
33#include <linux/timex.h>
34#include <linux/dnotify.h> 33#include <linux/dnotify.h>
35#include <linux/module.h> 34#include <linux/module.h>
36#include <linux/binfmts.h> 35#include <linux/binfmts.h>
@@ -1157,79 +1156,6 @@ out:
1157 return err; 1156 return err;
1158} 1157}
1159 1158
1160/* Handle adjtimex compatibility. */
1161
1162struct timex32 {
1163 u32 modes;
1164 s32 offset, freq, maxerror, esterror;
1165 s32 status, constant, precision, tolerance;
1166 struct compat_timeval time;
1167 s32 tick;
1168 s32 ppsfreq, jitter, shift, stabil;
1169 s32 jitcnt, calcnt, errcnt, stbcnt;
1170 s32 :32; s32 :32; s32 :32; s32 :32;
1171 s32 :32; s32 :32; s32 :32; s32 :32;
1172 s32 :32; s32 :32; s32 :32; s32 :32;
1173};
1174
1175extern int do_adjtimex(struct timex *);
1176
1177asmlinkage int sys32_adjtimex(struct timex32 __user *utp)
1178{
1179 struct timex txc;
1180 int ret;
1181
1182 memset(&txc, 0, sizeof(struct timex));
1183
1184 if (get_user(txc.modes, &utp->modes) ||
1185 __get_user(txc.offset, &utp->offset) ||
1186 __get_user(txc.freq, &utp->freq) ||
1187 __get_user(txc.maxerror, &utp->maxerror) ||
1188 __get_user(txc.esterror, &utp->esterror) ||
1189 __get_user(txc.status, &utp->status) ||
1190 __get_user(txc.constant, &utp->constant) ||
1191 __get_user(txc.precision, &utp->precision) ||
1192 __get_user(txc.tolerance, &utp->tolerance) ||
1193 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
1194 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
1195 __get_user(txc.tick, &utp->tick) ||
1196 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
1197 __get_user(txc.jitter, &utp->jitter) ||
1198 __get_user(txc.shift, &utp->shift) ||
1199 __get_user(txc.stabil, &utp->stabil) ||
1200 __get_user(txc.jitcnt, &utp->jitcnt) ||
1201 __get_user(txc.calcnt, &utp->calcnt) ||
1202 __get_user(txc.errcnt, &utp->errcnt) ||
1203 __get_user(txc.stbcnt, &utp->stbcnt))
1204 return -EFAULT;
1205
1206 ret = do_adjtimex(&txc);
1207
1208 if (put_user(txc.modes, &utp->modes) ||
1209 __put_user(txc.offset, &utp->offset) ||
1210 __put_user(txc.freq, &utp->freq) ||
1211 __put_user(txc.maxerror, &utp->maxerror) ||
1212 __put_user(txc.esterror, &utp->esterror) ||
1213 __put_user(txc.status, &utp->status) ||
1214 __put_user(txc.constant, &utp->constant) ||
1215 __put_user(txc.precision, &utp->precision) ||
1216 __put_user(txc.tolerance, &utp->tolerance) ||
1217 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
1218 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
1219 __put_user(txc.tick, &utp->tick) ||
1220 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
1221 __put_user(txc.jitter, &utp->jitter) ||
1222 __put_user(txc.shift, &utp->shift) ||
1223 __put_user(txc.stabil, &utp->stabil) ||
1224 __put_user(txc.jitcnt, &utp->jitcnt) ||
1225 __put_user(txc.calcnt, &utp->calcnt) ||
1226 __put_user(txc.errcnt, &utp->errcnt) ||
1227 __put_user(txc.stbcnt, &utp->stbcnt))
1228 ret = -EFAULT;
1229
1230 return ret;
1231}
1232
1233asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, 1159asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset,
1234 s32 count) 1160 s32 count)
1235{ 1161{
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 02c8267e45e7..05a2c0567dae 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -273,7 +273,7 @@ EXPORT(sysn32_call_table)
273 PTR sys_pivot_root 273 PTR sys_pivot_root
274 PTR sys32_sysctl 274 PTR sys32_sysctl
275 PTR sys_prctl 275 PTR sys_prctl
276 PTR sys32_adjtimex 276 PTR compat_sys_adjtimex
277 PTR compat_sys_setrlimit /* 6155 */ 277 PTR compat_sys_setrlimit /* 6155 */
278 PTR sys_chroot 278 PTR sys_chroot
279 PTR sys_sync 279 PTR sys_sync
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 797e0d874889..19c4ca481b02 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -328,7 +328,7 @@ sys_call_table:
328 PTR sys_setdomainname 328 PTR sys_setdomainname
329 PTR sys32_newuname 329 PTR sys32_newuname
330 PTR sys_ni_syscall /* sys_modify_ldt */ 330 PTR sys_ni_syscall /* sys_modify_ldt */
331 PTR sys32_adjtimex 331 PTR compat_sys_adjtimex
332 PTR sys_mprotect /* 4125 */ 332 PTR sys_mprotect /* 4125 */
333 PTR compat_sys_sigprocmask 333 PTR compat_sys_sigprocmask
334 PTR sys_ni_syscall /* was creat_module */ 334 PTR sys_ni_syscall /* was creat_module */
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 0cb3b6097e0e..dcbfd27071f0 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -34,6 +34,7 @@
34#include <linux/highmem.h> 34#include <linux/highmem.h>
35#include <linux/console.h> 35#include <linux/console.h>
36#include <linux/mmzone.h> 36#include <linux/mmzone.h>
37#include <linux/pfn.h>
37 38
38#include <asm/addrspace.h> 39#include <asm/addrspace.h>
39#include <asm/bootinfo.h> 40#include <asm/bootinfo.h>
@@ -257,10 +258,6 @@ static inline int parse_rd_cmdline(unsigned long* rd_start, unsigned long* rd_en
257 return 0; 258 return 0;
258} 259}
259 260
260#define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
261#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
262#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
263
264#define MAXMEM HIGHMEM_START 261#define MAXMEM HIGHMEM_START
265#define MAXMEM_PFN PFN_DOWN(MAXMEM) 262#define MAXMEM_PFN PFN_DOWN(MAXMEM)
266 263
@@ -493,10 +490,6 @@ static inline void resource_init(void)
493 } 490 }
494} 491}
495 492
496#undef PFN_UP
497#undef PFN_DOWN
498#undef PFN_PHYS
499
500#undef MAXMEM 493#undef MAXMEM
501#undef MAXMEM_PFN 494#undef MAXMEM_PFN
502 495
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 51273b7297a7..5e51a2d8f3f0 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -65,9 +65,9 @@ static int null_rtc_set_time(unsigned long sec)
65 return 0; 65 return 0;
66} 66}
67 67
68unsigned long (*rtc_get_time)(void) = null_rtc_get_time; 68unsigned long (*rtc_mips_get_time)(void) = null_rtc_get_time;
69int (*rtc_set_time)(unsigned long) = null_rtc_set_time; 69int (*rtc_mips_set_time)(unsigned long) = null_rtc_set_time;
70int (*rtc_set_mmss)(unsigned long); 70int (*rtc_mips_set_mmss)(unsigned long);
71 71
72 72
73/* usecs per counter cycle, shifted to left by 32 bits */ 73/* usecs per counter cycle, shifted to left by 32 bits */
@@ -440,14 +440,14 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
440 440
441 /* 441 /*
442 * If we have an externally synchronized Linux clock, then update 442 * If we have an externally synchronized Linux clock, then update
443 * CMOS clock accordingly every ~11 minutes. rtc_set_time() has to be 443 * CMOS clock accordingly every ~11 minutes. rtc_mips_set_time() has to be
444 * called as close as possible to 500 ms before the new second starts. 444 * called as close as possible to 500 ms before the new second starts.
445 */ 445 */
446 if (ntp_synced() && 446 if (ntp_synced() &&
447 xtime.tv_sec > last_rtc_update + 660 && 447 xtime.tv_sec > last_rtc_update + 660 &&
448 (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 && 448 (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
449 (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) { 449 (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
450 if (rtc_set_mmss(xtime.tv_sec) == 0) { 450 if (rtc_mips_set_mmss(xtime.tv_sec) == 0) {
451 last_rtc_update = xtime.tv_sec; 451 last_rtc_update = xtime.tv_sec;
452 } else { 452 } else {
453 /* do it again in 60 s */ 453 /* do it again in 60 s */
@@ -565,7 +565,7 @@ asmlinkage void ll_local_timer_interrupt(int irq, struct pt_regs *regs)
565 * b) (optional) calibrate and set the mips_hpt_frequency 565 * b) (optional) calibrate and set the mips_hpt_frequency
566 * (only needed if you intended to use fixed_rate_gettimeoffset 566 * (only needed if you intended to use fixed_rate_gettimeoffset
567 * or use cpu counter as timer interrupt source) 567 * or use cpu counter as timer interrupt source)
568 * 2) setup xtime based on rtc_get_time(). 568 * 2) setup xtime based on rtc_mips_get_time().
569 * 3) choose a appropriate gettimeoffset routine. 569 * 3) choose a appropriate gettimeoffset routine.
570 * 4) calculate a couple of cached variables for later usage 570 * 4) calculate a couple of cached variables for later usage
571 * 5) board_timer_setup() - 571 * 5) board_timer_setup() -
@@ -633,10 +633,10 @@ void __init time_init(void)
633 if (board_time_init) 633 if (board_time_init)
634 board_time_init(); 634 board_time_init();
635 635
636 if (!rtc_set_mmss) 636 if (!rtc_mips_set_mmss)
637 rtc_set_mmss = rtc_set_time; 637 rtc_mips_set_mmss = rtc_mips_set_time;
638 638
639 xtime.tv_sec = rtc_get_time(); 639 xtime.tv_sec = rtc_mips_get_time();
640 xtime.tv_nsec = 0; 640 xtime.tv_nsec = 0;
641 641
642 set_normalized_timespec(&wall_to_monotonic, 642 set_normalized_timespec(&wall_to_monotonic,
@@ -772,8 +772,8 @@ void to_tm(unsigned long tim, struct rtc_time *tm)
772 772
773EXPORT_SYMBOL(rtc_lock); 773EXPORT_SYMBOL(rtc_lock);
774EXPORT_SYMBOL(to_tm); 774EXPORT_SYMBOL(to_tm);
775EXPORT_SYMBOL(rtc_set_time); 775EXPORT_SYMBOL(rtc_mips_set_time);
776EXPORT_SYMBOL(rtc_get_time); 776EXPORT_SYMBOL(rtc_mips_get_time);
777 777
778unsigned long long sched_clock(void) 778unsigned long long sched_clock(void)
779{ 779{
diff --git a/arch/mips/lasat/setup.c b/arch/mips/lasat/setup.c
index 83eb08b7a072..bb70a8240e61 100644
--- a/arch/mips/lasat/setup.c
+++ b/arch/mips/lasat/setup.c
@@ -165,7 +165,8 @@ void __init plat_setup(void)
165 165
166 /* Set up panic notifier */ 166 /* Set up panic notifier */
167 for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++) 167 for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++)
168 notifier_chain_register(&panic_notifier_list, &lasat_panic_block[i]); 168 atomic_notifier_chain_register(&panic_notifier_list,
169 &lasat_panic_block[i]);
169 170
170 lasat_reboot_setup(); 171 lasat_reboot_setup();
171 172
@@ -174,8 +175,8 @@ void __init plat_setup(void)
174 175
175#ifdef CONFIG_DS1603 176#ifdef CONFIG_DS1603
176 ds1603 = &ds_defs[mips_machtype]; 177 ds1603 = &ds_defs[mips_machtype];
177 rtc_get_time = ds1603_read; 178 rtc_mips_get_time = ds1603_read;
178 rtc_set_time = ds1603_set; 179 rtc_mips_set_time = ds1603_set;
179#endif 180#endif
180 181
181#ifdef DYNAMIC_SERIAL_INIT 182#ifdef DYNAMIC_SERIAL_INIT
diff --git a/arch/mips/lasat/sysctl.c b/arch/mips/lasat/sysctl.c
index 8ff43a1c1e99..e3d5aaa90f0d 100644
--- a/arch/mips/lasat/sysctl.c
+++ b/arch/mips/lasat/sysctl.c
@@ -30,12 +30,13 @@
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/net.h> 31#include <linux/net.h>
32#include <linux/inet.h> 32#include <linux/inet.h>
33#include <linux/mutex.h>
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
34 35
35#include "sysctl.h" 36#include "sysctl.h"
36#include "ds1603.h" 37#include "ds1603.h"
37 38
38static DECLARE_MUTEX(lasat_info_sem); 39static DEFINE_MUTEX(lasat_info_mutex);
39 40
40/* Strategy function to write EEPROM after changing string entry */ 41/* Strategy function to write EEPROM after changing string entry */
41int sysctl_lasatstring(ctl_table *table, int *name, int nlen, 42int sysctl_lasatstring(ctl_table *table, int *name, int nlen,
@@ -43,17 +44,17 @@ int sysctl_lasatstring(ctl_table *table, int *name, int nlen,
43 void *newval, size_t newlen, void **context) 44 void *newval, size_t newlen, void **context)
44{ 45{
45 int r; 46 int r;
46 down(&lasat_info_sem); 47 mutex_lock(&lasat_info_mutex);
47 r = sysctl_string(table, name, 48 r = sysctl_string(table, name,
48 nlen, oldval, oldlenp, newval, newlen, context); 49 nlen, oldval, oldlenp, newval, newlen, context);
49 if (r < 0) { 50 if (r < 0) {
50 up(&lasat_info_sem); 51 mutex_unlock(&lasat_info_mutex);
51 return r; 52 return r;
52 } 53 }
53 if (newval && newlen) { 54 if (newval && newlen) {
54 lasat_write_eeprom_info(); 55 lasat_write_eeprom_info();
55 } 56 }
56 up(&lasat_info_sem); 57 mutex_unlock(&lasat_info_mutex);
57 return 1; 58 return 1;
58} 59}
59 60
@@ -63,14 +64,14 @@ int proc_dolasatstring(ctl_table *table, int write, struct file *filp,
63 void *buffer, size_t *lenp, loff_t *ppos) 64 void *buffer, size_t *lenp, loff_t *ppos)
64{ 65{
65 int r; 66 int r;
66 down(&lasat_info_sem); 67 mutex_lock(&lasat_info_mutex);
67 r = proc_dostring(table, write, filp, buffer, lenp, ppos); 68 r = proc_dostring(table, write, filp, buffer, lenp, ppos);
68 if ( (!write) || r) { 69 if ( (!write) || r) {
69 up(&lasat_info_sem); 70 mutex_unlock(&lasat_info_mutex);
70 return r; 71 return r;
71 } 72 }
72 lasat_write_eeprom_info(); 73 lasat_write_eeprom_info();
73 up(&lasat_info_sem); 74 mutex_unlock(&lasat_info_mutex);
74 return 0; 75 return 0;
75} 76}
76 77
@@ -79,14 +80,14 @@ int proc_dolasatint(ctl_table *table, int write, struct file *filp,
79 void *buffer, size_t *lenp, loff_t *ppos) 80 void *buffer, size_t *lenp, loff_t *ppos)
80{ 81{
81 int r; 82 int r;
82 down(&lasat_info_sem); 83 mutex_lock(&lasat_info_mutex);
83 r = proc_dointvec(table, write, filp, buffer, lenp, ppos); 84 r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
84 if ( (!write) || r) { 85 if ( (!write) || r) {
85 up(&lasat_info_sem); 86 mutex_unlock(&lasat_info_mutex);
86 return r; 87 return r;
87 } 88 }
88 lasat_write_eeprom_info(); 89 lasat_write_eeprom_info();
89 up(&lasat_info_sem); 90 mutex_unlock(&lasat_info_mutex);
90 return 0; 91 return 0;
91} 92}
92 93
@@ -98,7 +99,7 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
98 void *buffer, size_t *lenp, loff_t *ppos) 99 void *buffer, size_t *lenp, loff_t *ppos)
99{ 100{
100 int r; 101 int r;
101 down(&lasat_info_sem); 102 mutex_lock(&lasat_info_mutex);
102 if (!write) { 103 if (!write) {
103 rtctmp = ds1603_read(); 104 rtctmp = ds1603_read();
104 /* check for time < 0 and set to 0 */ 105 /* check for time < 0 and set to 0 */
@@ -107,11 +108,11 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
107 } 108 }
108 r = proc_dointvec(table, write, filp, buffer, lenp, ppos); 109 r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
109 if ( (!write) || r) { 110 if ( (!write) || r) {
110 up(&lasat_info_sem); 111 mutex_unlock(&lasat_info_mutex);
111 return r; 112 return r;
112 } 113 }
113 ds1603_set(rtctmp); 114 ds1603_set(rtctmp);
114 up(&lasat_info_sem); 115 mutex_unlock(&lasat_info_mutex);
115 return 0; 116 return 0;
116} 117}
117#endif 118#endif
@@ -122,16 +123,16 @@ int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen,
122 void *newval, size_t newlen, void **context) 123 void *newval, size_t newlen, void **context)
123{ 124{
124 int r; 125 int r;
125 down(&lasat_info_sem); 126 mutex_lock(&lasat_info_mutex);
126 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context); 127 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
127 if (r < 0) { 128 if (r < 0) {
128 up(&lasat_info_sem); 129 mutex_unlock(&lasat_info_mutex);
129 return r; 130 return r;
130 } 131 }
131 if (newval && newlen) { 132 if (newval && newlen) {
132 lasat_write_eeprom_info(); 133 lasat_write_eeprom_info();
133 } 134 }
134 up(&lasat_info_sem); 135 mutex_unlock(&lasat_info_mutex);
135 return 1; 136 return 1;
136} 137}
137 138
@@ -142,19 +143,19 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
142 void *newval, size_t newlen, void **context) 143 void *newval, size_t newlen, void **context)
143{ 144{
144 int r; 145 int r;
145 down(&lasat_info_sem); 146 mutex_lock(&lasat_info_mutex);
146 rtctmp = ds1603_read(); 147 rtctmp = ds1603_read();
147 if (rtctmp < 0) 148 if (rtctmp < 0)
148 rtctmp = 0; 149 rtctmp = 0;
149 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context); 150 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
150 if (r < 0) { 151 if (r < 0) {
151 up(&lasat_info_sem); 152 mutex_unlock(&lasat_info_mutex);
152 return r; 153 return r;
153 } 154 }
154 if (newval && newlen) { 155 if (newval && newlen) {
155 ds1603_set(rtctmp); 156 ds1603_set(rtctmp);
156 } 157 }
157 up(&lasat_info_sem); 158 mutex_unlock(&lasat_info_mutex);
158 return 1; 159 return 1;
159} 160}
160#endif 161#endif
@@ -192,13 +193,13 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
192 return 0; 193 return 0;
193 } 194 }
194 195
195 down(&lasat_info_sem); 196 mutex_lock(&lasat_info_mutex);
196 if (write) { 197 if (write) {
197 len = 0; 198 len = 0;
198 p = buffer; 199 p = buffer;
199 while (len < *lenp) { 200 while (len < *lenp) {
200 if(get_user(c, p++)) { 201 if(get_user(c, p++)) {
201 up(&lasat_info_sem); 202 mutex_unlock(&lasat_info_mutex);
202 return -EFAULT; 203 return -EFAULT;
203 } 204 }
204 if (c == 0 || c == '\n') 205 if (c == 0 || c == '\n')
@@ -209,7 +210,7 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
209 len = sizeof(proc_lasat_ipbuf) - 1; 210 len = sizeof(proc_lasat_ipbuf) - 1;
210 if (copy_from_user(proc_lasat_ipbuf, buffer, len)) 211 if (copy_from_user(proc_lasat_ipbuf, buffer, len))
211 { 212 {
212 up(&lasat_info_sem); 213 mutex_unlock(&lasat_info_mutex);
213 return -EFAULT; 214 return -EFAULT;
214 } 215 }
215 proc_lasat_ipbuf[len] = 0; 216 proc_lasat_ipbuf[len] = 0;
@@ -230,12 +231,12 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
230 len = *lenp; 231 len = *lenp;
231 if (len) 232 if (len)
232 if(copy_to_user(buffer, proc_lasat_ipbuf, len)) { 233 if(copy_to_user(buffer, proc_lasat_ipbuf, len)) {
233 up(&lasat_info_sem); 234 mutex_unlock(&lasat_info_mutex);
234 return -EFAULT; 235 return -EFAULT;
235 } 236 }
236 if (len < *lenp) { 237 if (len < *lenp) {
237 if(put_user('\n', ((char *) buffer) + len)) { 238 if(put_user('\n', ((char *) buffer) + len)) {
238 up(&lasat_info_sem); 239 mutex_unlock(&lasat_info_mutex);
239 return -EFAULT; 240 return -EFAULT;
240 } 241 }
241 len++; 242 len++;
@@ -244,7 +245,7 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
244 *ppos += len; 245 *ppos += len;
245 } 246 }
246 update_bcastaddr(); 247 update_bcastaddr();
247 up(&lasat_info_sem); 248 mutex_unlock(&lasat_info_mutex);
248 return 0; 249 return 0;
249} 250}
250#endif /* defined(CONFIG_INET) */ 251#endif /* defined(CONFIG_INET) */
@@ -256,10 +257,10 @@ static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen,
256{ 257{
257 int r; 258 int r;
258 259
259 down(&lasat_info_sem); 260 mutex_lock(&lasat_info_mutex);
260 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context); 261 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
261 if (r < 0) { 262 if (r < 0) {
262 up(&lasat_info_sem); 263 mutex_unlock(&lasat_info_mutex);
263 return r; 264 return r;
264 } 265 }
265 266
@@ -271,7 +272,7 @@ static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen,
271 lasat_write_eeprom_info(); 272 lasat_write_eeprom_info();
272 lasat_init_board_info(); 273 lasat_init_board_info();
273 } 274 }
274 up(&lasat_info_sem); 275 mutex_unlock(&lasat_info_mutex);
275 276
276 return 0; 277 return 0;
277} 278}
@@ -280,10 +281,10 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp,
280 void *buffer, size_t *lenp, loff_t *ppos) 281 void *buffer, size_t *lenp, loff_t *ppos)
281{ 282{
282 int r; 283 int r;
283 down(&lasat_info_sem); 284 mutex_lock(&lasat_info_mutex);
284 r = proc_dointvec(table, write, filp, buffer, lenp, ppos); 285 r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
285 if ( (!write) || r) { 286 if ( (!write) || r) {
286 up(&lasat_info_sem); 287 mutex_unlock(&lasat_info_mutex);
287 return r; 288 return r;
288 } 289 }
289 if (filp && filp->f_dentry) 290 if (filp && filp->f_dentry)
@@ -294,7 +295,7 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp,
294 lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess; 295 lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess;
295 } 296 }
296 lasat_write_eeprom_info(); 297 lasat_write_eeprom_info();
297 up(&lasat_info_sem); 298 mutex_unlock(&lasat_info_mutex);
298 return 0; 299 return 0;
299} 300}
300 301
diff --git a/arch/mips/mips-boards/atlas/atlas_setup.c b/arch/mips/mips-boards/atlas/atlas_setup.c
index 873cf3141a31..c20d401ecf80 100644
--- a/arch/mips/mips-boards/atlas/atlas_setup.c
+++ b/arch/mips/mips-boards/atlas/atlas_setup.c
@@ -65,7 +65,7 @@ void __init plat_setup(void)
65 65
66 board_time_init = mips_time_init; 66 board_time_init = mips_time_init;
67 board_timer_setup = mips_timer_setup; 67 board_timer_setup = mips_timer_setup;
68 rtc_get_time = mips_rtc_get_time; 68 rtc_mips_get_time = mips_rtc_get_time;
69} 69}
70 70
71static void __init serial_init(void) 71static void __init serial_init(void)
diff --git a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mips-boards/generic/memory.c
index ee5e70c95cf3..32c9210373ac 100644
--- a/arch/mips/mips-boards/generic/memory.c
+++ b/arch/mips/mips-boards/generic/memory.c
@@ -49,9 +49,6 @@ static char *mtypes[3] = {
49/* References to section boundaries */ 49/* References to section boundaries */
50extern char _end; 50extern char _end;
51 51
52#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
53
54
55struct prom_pmemblock * __init prom_getmdesc(void) 52struct prom_pmemblock * __init prom_getmdesc(void)
56{ 53{
57 char *memsize_str; 54 char *memsize_str;
@@ -109,10 +106,10 @@ struct prom_pmemblock * __init prom_getmdesc(void)
109 106
110 mdesc[3].type = yamon_dontuse; 107 mdesc[3].type = yamon_dontuse;
111 mdesc[3].base = 0x00100000; 108 mdesc[3].base = 0x00100000;
112 mdesc[3].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base; 109 mdesc[3].size = CPHYSADDR(PAGE_ALIGN(&_end)) - mdesc[3].base;
113 110
114 mdesc[4].type = yamon_free; 111 mdesc[4].type = yamon_free;
115 mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end)); 112 mdesc[4].base = CPHYSADDR(PAGE_ALIGN(&_end));
116 mdesc[4].size = memsize - mdesc[4].base; 113 mdesc[4].size = memsize - mdesc[4].base;
117 114
118 return &mdesc[0]; 115 return &mdesc[0];
diff --git a/arch/mips/mips-boards/malta/malta_setup.c b/arch/mips/mips-boards/malta/malta_setup.c
index 2209e8a9de34..b8488aab6df1 100644
--- a/arch/mips/mips-boards/malta/malta_setup.c
+++ b/arch/mips/mips-boards/malta/malta_setup.c
@@ -225,5 +225,5 @@ void __init plat_setup(void)
225 225
226 board_time_init = mips_time_init; 226 board_time_init = mips_time_init;
227 board_timer_setup = mips_timer_setup; 227 board_timer_setup = mips_timer_setup;
228 rtc_get_time = mips_rtc_get_time; 228 rtc_mips_get_time = mips_rtc_get_time;
229} 229}
diff --git a/arch/mips/mips-boards/sim/sim_mem.c b/arch/mips/mips-boards/sim/sim_mem.c
index 1ec4e75656bd..e57f737bab10 100644
--- a/arch/mips/mips-boards/sim/sim_mem.c
+++ b/arch/mips/mips-boards/sim/sim_mem.c
@@ -42,9 +42,6 @@ static char *mtypes[3] = {
42/* References to section boundaries */ 42/* References to section boundaries */
43extern char _end; 43extern char _end;
44 44
45#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
46
47
48struct prom_pmemblock * __init prom_getmdesc(void) 45struct prom_pmemblock * __init prom_getmdesc(void)
49{ 46{
50 unsigned int memsize; 47 unsigned int memsize;
@@ -64,10 +61,10 @@ struct prom_pmemblock * __init prom_getmdesc(void)
64 61
65 mdesc[2].type = simmem_reserved; 62 mdesc[2].type = simmem_reserved;
66 mdesc[2].base = 0x00100000; 63 mdesc[2].base = 0x00100000;
67 mdesc[2].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[2].base; 64 mdesc[2].size = CPHYSADDR(PAGE_ALIGN(&_end)) - mdesc[2].base;
68 65
69 mdesc[3].type = simmem_free; 66 mdesc[3].type = simmem_free;
70 mdesc[3].base = CPHYSADDR(PFN_ALIGN(&_end)); 67 mdesc[3].base = CPHYSADDR(PAGE_ALIGN(&_end));
71 mdesc[3].size = memsize - mdesc[3].base; 68 mdesc[3].size = memsize - mdesc[3].base;
72 69
73 return &mdesc[0]; 70 return &mdesc[0];
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 52f7d59fe612..ad89c442f299 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -25,6 +25,7 @@
25#include <linux/highmem.h> 25#include <linux/highmem.h>
26#include <linux/swap.h> 26#include <linux/swap.h>
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/pfn.h>
28 29
29#include <asm/bootinfo.h> 30#include <asm/bootinfo.h>
30#include <asm/cachectl.h> 31#include <asm/cachectl.h>
@@ -177,9 +178,6 @@ void __init paging_init(void)
177 free_area_init(zones_size); 178 free_area_init(zones_size);
178} 179}
179 180
180#define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
181#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
182
183static inline int page_is_ram(unsigned long pagenr) 181static inline int page_is_ram(unsigned long pagenr)
184{ 182{
185 int i; 183 int i;
diff --git a/arch/mips/momentum/jaguar_atx/setup.c b/arch/mips/momentum/jaguar_atx/setup.c
index 3784c898db1a..91d9637143d7 100644
--- a/arch/mips/momentum/jaguar_atx/setup.c
+++ b/arch/mips/momentum/jaguar_atx/setup.c
@@ -229,8 +229,8 @@ void momenco_time_init(void)
229 mips_hpt_frequency = cpu_clock / 2; 229 mips_hpt_frequency = cpu_clock / 2;
230 board_timer_setup = momenco_timer_setup; 230 board_timer_setup = momenco_timer_setup;
231 231
232 rtc_get_time = m48t37y_get_time; 232 rtc_mips_get_time = m48t37y_get_time;
233 rtc_set_time = m48t37y_set_time; 233 rtc_mips_set_time = m48t37y_set_time;
234} 234}
235 235
236static struct resource mv_pci_io_mem0_resource = { 236static struct resource mv_pci_io_mem0_resource = {
diff --git a/arch/mips/momentum/ocelot_3/setup.c b/arch/mips/momentum/ocelot_3/setup.c
index f95677f4f06f..370e75d0e75c 100644
--- a/arch/mips/momentum/ocelot_3/setup.c
+++ b/arch/mips/momentum/ocelot_3/setup.c
@@ -58,6 +58,7 @@
58#include <linux/bootmem.h> 58#include <linux/bootmem.h>
59#include <linux/mv643xx.h> 59#include <linux/mv643xx.h>
60#include <linux/pm.h> 60#include <linux/pm.h>
61#include <linux/bcd.h>
61 62
62#include <asm/time.h> 63#include <asm/time.h>
63#include <asm/page.h> 64#include <asm/page.h>
@@ -131,9 +132,6 @@ void setup_wired_tlb_entries(void)
131 add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M); 132 add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M);
132} 133}
133 134
134#define CONV_BCD_TO_BIN(val) (((val) & 0xf) + (((val) >> 4) * 10))
135#define CONV_BIN_TO_BCD(val) (((val) % 10) + (((val) / 10) << 4))
136
137unsigned long m48t37y_get_time(void) 135unsigned long m48t37y_get_time(void)
138{ 136{
139 unsigned int year, month, day, hour, min, sec; 137 unsigned int year, month, day, hour, min, sec;
@@ -143,16 +141,16 @@ unsigned long m48t37y_get_time(void)
143 /* stop the update */ 141 /* stop the update */
144 rtc_base[0x7ff8] = 0x40; 142 rtc_base[0x7ff8] = 0x40;
145 143
146 year = CONV_BCD_TO_BIN(rtc_base[0x7fff]); 144 year = BCD2BIN(rtc_base[0x7fff]);
147 year += CONV_BCD_TO_BIN(rtc_base[0x7ff1]) * 100; 145 year += BCD2BIN(rtc_base[0x7ff1]) * 100;
148 146
149 month = CONV_BCD_TO_BIN(rtc_base[0x7ffe]); 147 month = BCD2BIN(rtc_base[0x7ffe]);
150 148
151 day = CONV_BCD_TO_BIN(rtc_base[0x7ffd]); 149 day = BCD2BIN(rtc_base[0x7ffd]);
152 150
153 hour = CONV_BCD_TO_BIN(rtc_base[0x7ffb]); 151 hour = BCD2BIN(rtc_base[0x7ffb]);
154 min = CONV_BCD_TO_BIN(rtc_base[0x7ffa]); 152 min = BCD2BIN(rtc_base[0x7ffa]);
155 sec = CONV_BCD_TO_BIN(rtc_base[0x7ff9]); 153 sec = BCD2BIN(rtc_base[0x7ff9]);
156 154
157 /* start the update */ 155 /* start the update */
158 rtc_base[0x7ff8] = 0x00; 156 rtc_base[0x7ff8] = 0x00;
@@ -175,22 +173,22 @@ int m48t37y_set_time(unsigned long sec)
175 rtc_base[0x7ff8] = 0x80; 173 rtc_base[0x7ff8] = 0x80;
176 174
177 /* year */ 175 /* year */
178 rtc_base[0x7fff] = CONV_BIN_TO_BCD(tm.tm_year % 100); 176 rtc_base[0x7fff] = BIN2BCD(tm.tm_year % 100);
179 rtc_base[0x7ff1] = CONV_BIN_TO_BCD(tm.tm_year / 100); 177 rtc_base[0x7ff1] = BIN2BCD(tm.tm_year / 100);
180 178
181 /* month */ 179 /* month */
182 rtc_base[0x7ffe] = CONV_BIN_TO_BCD(tm.tm_mon); 180 rtc_base[0x7ffe] = BIN2BCD(tm.tm_mon);
183 181
184 /* day */ 182 /* day */
185 rtc_base[0x7ffd] = CONV_BIN_TO_BCD(tm.tm_mday); 183 rtc_base[0x7ffd] = BIN2BCD(tm.tm_mday);
186 184
187 /* hour/min/sec */ 185 /* hour/min/sec */
188 rtc_base[0x7ffb] = CONV_BIN_TO_BCD(tm.tm_hour); 186 rtc_base[0x7ffb] = BIN2BCD(tm.tm_hour);
189 rtc_base[0x7ffa] = CONV_BIN_TO_BCD(tm.tm_min); 187 rtc_base[0x7ffa] = BIN2BCD(tm.tm_min);
190 rtc_base[0x7ff9] = CONV_BIN_TO_BCD(tm.tm_sec); 188 rtc_base[0x7ff9] = BIN2BCD(tm.tm_sec);
191 189
192 /* day of week -- not really used, but let's keep it up-to-date */ 190 /* day of week -- not really used, but let's keep it up-to-date */
193 rtc_base[0x7ffc] = CONV_BIN_TO_BCD(tm.tm_wday + 1); 191 rtc_base[0x7ffc] = BIN2BCD(tm.tm_wday + 1);
194 192
195 /* disable writing */ 193 /* disable writing */
196 rtc_base[0x7ff8] = 0x00; 194 rtc_base[0x7ff8] = 0x00;
@@ -215,8 +213,8 @@ void momenco_time_init(void)
215 mips_hpt_frequency = cpu_clock / 2; 213 mips_hpt_frequency = cpu_clock / 2;
216 board_timer_setup = momenco_timer_setup; 214 board_timer_setup = momenco_timer_setup;
217 215
218 rtc_get_time = m48t37y_get_time; 216 rtc_mips_get_time = m48t37y_get_time;
219 rtc_set_time = m48t37y_set_time; 217 rtc_mips_set_time = m48t37y_set_time;
220} 218}
221 219
222/* 220/*
diff --git a/arch/mips/momentum/ocelot_c/setup.c b/arch/mips/momentum/ocelot_c/setup.c
index bd02e60d037a..a3e6f5575592 100644
--- a/arch/mips/momentum/ocelot_c/setup.c
+++ b/arch/mips/momentum/ocelot_c/setup.c
@@ -227,8 +227,8 @@ void momenco_time_init(void)
227 printk("momenco_time_init cpu_clock=%d\n", cpu_clock); 227 printk("momenco_time_init cpu_clock=%d\n", cpu_clock);
228 board_timer_setup = momenco_timer_setup; 228 board_timer_setup = momenco_timer_setup;
229 229
230 rtc_get_time = m48t37y_get_time; 230 rtc_mips_get_time = m48t37y_get_time;
231 rtc_set_time = m48t37y_set_time; 231 rtc_mips_set_time = m48t37y_set_time;
232} 232}
233 233
234void __init plat_setup(void) 234void __init plat_setup(void)
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c b/arch/mips/pmc-sierra/yosemite/setup.c
index 8bce711575de..3f724d661bdb 100644
--- a/arch/mips/pmc-sierra/yosemite/setup.c
+++ b/arch/mips/pmc-sierra/yosemite/setup.c
@@ -198,8 +198,8 @@ static void __init py_rtc_setup(void)
198 if (!m48t37_base) 198 if (!m48t37_base)
199 printk(KERN_ERR "Mapping the RTC failed\n"); 199 printk(KERN_ERR "Mapping the RTC failed\n");
200 200
201 rtc_get_time = m48t37y_get_time; 201 rtc_mips_get_time = m48t37y_get_time;
202 rtc_set_time = m48t37y_set_time; 202 rtc_mips_set_time = m48t37y_set_time;
203 203
204 write_seqlock(&xtime_lock); 204 write_seqlock(&xtime_lock);
205 xtime.tv_sec = m48t37y_get_time(); 205 xtime.tv_sec = m48t37y_get_time();
diff --git a/arch/mips/sgi-ip22/ip22-reset.c b/arch/mips/sgi-ip22/ip22-reset.c
index 92a3b3c15ed3..a9c58e067b53 100644
--- a/arch/mips/sgi-ip22/ip22-reset.c
+++ b/arch/mips/sgi-ip22/ip22-reset.c
@@ -238,7 +238,7 @@ static int __init reboot_setup(void)
238 request_irq(SGI_PANEL_IRQ, panel_int, 0, "Front Panel", NULL); 238 request_irq(SGI_PANEL_IRQ, panel_int, 0, "Front Panel", NULL);
239 init_timer(&blink_timer); 239 init_timer(&blink_timer);
240 blink_timer.function = blink_timeout; 240 blink_timer.function = blink_timeout;
241 notifier_chain_register(&panic_notifier_list, &panic_block); 241 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
242 242
243 return 0; 243 return 0;
244} 244}
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c
index b7300cc5c5ad..cca688ad64ad 100644
--- a/arch/mips/sgi-ip22/ip22-time.c
+++ b/arch/mips/sgi-ip22/ip22-time.c
@@ -212,8 +212,8 @@ static void indy_timer_setup(struct irqaction *irq)
212void __init ip22_time_init(void) 212void __init ip22_time_init(void)
213{ 213{
214 /* setup hookup functions */ 214 /* setup hookup functions */
215 rtc_get_time = indy_rtc_get_time; 215 rtc_mips_get_time = indy_rtc_get_time;
216 rtc_set_time = indy_rtc_set_time; 216 rtc_mips_set_time = indy_rtc_set_time;
217 217
218 board_time_init = indy_time_init; 218 board_time_init = indy_time_init;
219 board_timer_setup = indy_timer_setup; 219 board_timer_setup = indy_timer_setup;
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index e0d095daa5ed..6c00dce9f73f 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -19,6 +19,7 @@
19#include <linux/nodemask.h> 19#include <linux/nodemask.h>
20#include <linux/swap.h> 20#include <linux/swap.h>
21#include <linux/bootmem.h> 21#include <linux/bootmem.h>
22#include <linux/pfn.h>
22#include <asm/page.h> 23#include <asm/page.h>
23#include <asm/sections.h> 24#include <asm/sections.h>
24 25
@@ -28,8 +29,6 @@
28#include <asm/sn/sn_private.h> 29#include <asm/sn/sn_private.h>
29 30
30 31
31#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
32
33#define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) 32#define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT)
34#define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) 33#define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT)
35 34
diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c
index 0c948008b023..ab9d9cef089e 100644
--- a/arch/mips/sgi-ip32/ip32-reset.c
+++ b/arch/mips/sgi-ip32/ip32-reset.c
@@ -193,7 +193,7 @@ static __init int ip32_reboot_setup(void)
193 193
194 init_timer(&blink_timer); 194 init_timer(&blink_timer);
195 blink_timer.function = blink_timeout; 195 blink_timer.function = blink_timeout;
196 notifier_chain_register(&panic_notifier_list, &panic_block); 196 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
197 197
198 request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL); 198 request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL);
199 199
diff --git a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
index 2f50c79b7887..a2dd8ae1ea8f 100644
--- a/arch/mips/sgi-ip32/ip32-setup.c
+++ b/arch/mips/sgi-ip32/ip32-setup.c
@@ -91,8 +91,8 @@ void __init plat_setup(void)
91{ 91{
92 board_be_init = ip32_be_init; 92 board_be_init = ip32_be_init;
93 93
94 rtc_get_time = mc146818_get_cmos_time; 94 rtc_mips_get_time = mc146818_get_cmos_time;
95 rtc_set_mmss = mc146818_set_rtc_mmss; 95 rtc_mips_set_mmss = mc146818_set_rtc_mmss;
96 96
97 board_time_init = ip32_time_init; 97 board_time_init = ip32_time_init;
98 board_timer_setup = ip32_timer_setup; 98 board_timer_setup = ip32_timer_setup;
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
index b661d2425a36..4b5f74ff3edd 100644
--- a/arch/mips/sibyte/swarm/setup.c
+++ b/arch/mips/sibyte/swarm/setup.c
@@ -121,14 +121,14 @@ void __init plat_setup(void)
121 121
122 if (xicor_probe()) { 122 if (xicor_probe()) {
123 printk("swarm setup: Xicor 1241 RTC detected.\n"); 123 printk("swarm setup: Xicor 1241 RTC detected.\n");
124 rtc_get_time = xicor_get_time; 124 rtc_mips_get_time = xicor_get_time;
125 rtc_set_time = xicor_set_time; 125 rtc_mips_set_time = xicor_set_time;
126 } 126 }
127 127
128 if (m41t81_probe()) { 128 if (m41t81_probe()) {
129 printk("swarm setup: M41T81 RTC detected.\n"); 129 printk("swarm setup: M41T81 RTC detected.\n");
130 rtc_get_time = m41t81_get_time; 130 rtc_mips_get_time = m41t81_get_time;
131 rtc_set_time = m41t81_set_time; 131 rtc_mips_set_time = m41t81_set_time;
132 } 132 }
133 133
134 printk("This kernel optimized for " 134 printk("This kernel optimized for "
diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
index 1141fcd13a59..01ba6c581e3d 100644
--- a/arch/mips/sni/setup.c
+++ b/arch/mips/sni/setup.c
@@ -164,8 +164,8 @@ static struct pci_controller sni_controller = {
164 164
165static inline void sni_pcimt_time_init(void) 165static inline void sni_pcimt_time_init(void)
166{ 166{
167 rtc_get_time = mc146818_get_cmos_time; 167 rtc_mips_get_time = mc146818_get_cmos_time;
168 rtc_set_time = mc146818_set_rtc_mmss; 168 rtc_mips_set_time = mc146818_set_rtc_mmss;
169} 169}
170 170
171void __init plat_setup(void) 171void __init plat_setup(void)
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
index 2ad6401d2af4..6dcf077f61a0 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
@@ -1036,8 +1036,8 @@ toshiba_rbtx4927_time_init(void)
1036 1036
1037#ifdef CONFIG_RTC_DS1742 1037#ifdef CONFIG_RTC_DS1742
1038 1038
1039 rtc_get_time = rtc_ds1742_get_time; 1039 rtc_mips_get_time = rtc_ds1742_get_time;
1040 rtc_set_time = rtc_ds1742_set_time; 1040 rtc_mips_set_time = rtc_ds1742_set_time;
1041 1041
1042 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, 1042 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
1043 ":rtc_ds1742_init()-\n"); 1043 ":rtc_ds1742_init()-\n");
diff --git a/arch/mips/tx4938/common/rtc_rx5c348.c b/arch/mips/tx4938/common/rtc_rx5c348.c
index d249edbb6af4..07f782fc0725 100644
--- a/arch/mips/tx4938/common/rtc_rx5c348.c
+++ b/arch/mips/tx4938/common/rtc_rx5c348.c
@@ -14,6 +14,7 @@
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/rtc.h> 15#include <linux/rtc.h>
16#include <linux/time.h> 16#include <linux/time.h>
17#include <linux/bcd.h>
17#include <asm/time.h> 18#include <asm/time.h>
18#include <asm/tx4938/spi.h> 19#include <asm/tx4938/spi.h>
19 20
@@ -77,17 +78,6 @@ spi_rtc_io(unsigned char *inbuf, unsigned char *outbuf, unsigned int count)
77 inbufs, incounts, outbufs, outcounts, 0); 78 inbufs, incounts, outbufs, outcounts, 0);
78} 79}
79 80
80/*
81 * Conversion between binary and BCD.
82 */
83#ifndef BCD_TO_BIN
84#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
85#endif
86
87#ifndef BIN_TO_BCD
88#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
89#endif
90
91/* RTC-dependent code for time.c */ 81/* RTC-dependent code for time.c */
92 82
93static int 83static int
@@ -197,6 +187,6 @@ rtc_rx5c348_init(int chipid)
197 srtc_24h = 1; 187 srtc_24h = 1;
198 188
199 /* set the function pointers */ 189 /* set the function pointers */
200 rtc_get_time = rtc_rx5c348_get_time; 190 rtc_mips_get_time = rtc_rx5c348_get_time;
201 rtc_set_time = rtc_rx5c348_set_time; 191 rtc_mips_set_time = rtc_rx5c348_set_time;
202} 192}
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index eca33cfa8a4c..6b3c50964ca9 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -25,6 +25,14 @@ config RWSEM_GENERIC_SPINLOCK
25config RWSEM_XCHGADD_ALGORITHM 25config RWSEM_XCHGADD_ALGORITHM
26 bool 26 bool
27 27
28config GENERIC_FIND_NEXT_BIT
29 bool
30 default y
31
32config GENERIC_HWEIGHT
33 bool
34 default y
35
28config GENERIC_CALIBRATE_DELAY 36config GENERIC_CALIBRATE_DELAY
29 bool 37 bool
30 default y 38 default y
diff --git a/arch/parisc/kernel/pdc_chassis.c b/arch/parisc/kernel/pdc_chassis.c
index 2a01fe1bdc98..0cea6958f427 100644
--- a/arch/parisc/kernel/pdc_chassis.c
+++ b/arch/parisc/kernel/pdc_chassis.c
@@ -150,7 +150,8 @@ void __init parisc_pdc_chassis_init(void)
150 150
151 if (handle) { 151 if (handle) {
152 /* initialize panic notifier chain */ 152 /* initialize panic notifier chain */
153 notifier_chain_register(&panic_notifier_list, &pdc_chassis_panic_block); 153 atomic_notifier_chain_register(&panic_notifier_list,
154 &pdc_chassis_panic_block);
154 155
155 /* initialize reboot notifier chain */ 156 /* initialize reboot notifier chain */
156 register_reboot_notifier(&pdc_chassis_reboot_block); 157 register_reboot_notifier(&pdc_chassis_reboot_block);
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index 613569018410..d286f68a3d3a 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -21,7 +21,6 @@
21#include <linux/times.h> 21#include <linux/times.h>
22#include <linux/utsname.h> 22#include <linux/utsname.h>
23#include <linux/time.h> 23#include <linux/time.h>
24#include <linux/timex.h>
25#include <linux/smp.h> 24#include <linux/smp.h>
26#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
27#include <linux/sem.h> 26#include <linux/sem.h>
@@ -567,63 +566,6 @@ asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *off
567} 566}
568 567
569 568
570struct timex32 {
571 unsigned int modes; /* mode selector */
572 int offset; /* time offset (usec) */
573 int freq; /* frequency offset (scaled ppm) */
574 int maxerror; /* maximum error (usec) */
575 int esterror; /* estimated error (usec) */
576 int status; /* clock command/status */
577 int constant; /* pll time constant */
578 int precision; /* clock precision (usec) (read only) */
579 int tolerance; /* clock frequency tolerance (ppm)
580 * (read only)
581 */
582 struct compat_timeval time; /* (read only) */
583 int tick; /* (modified) usecs between clock ticks */
584
585 int ppsfreq; /* pps frequency (scaled ppm) (ro) */
586 int jitter; /* pps jitter (us) (ro) */
587 int shift; /* interval duration (s) (shift) (ro) */
588 int stabil; /* pps stability (scaled ppm) (ro) */
589 int jitcnt; /* jitter limit exceeded (ro) */
590 int calcnt; /* calibration intervals (ro) */
591 int errcnt; /* calibration errors (ro) */
592 int stbcnt; /* stability limit exceeded (ro) */
593
594 int :32; int :32; int :32; int :32;
595 int :32; int :32; int :32; int :32;
596 int :32; int :32; int :32; int :32;
597};
598
599asmlinkage long sys32_adjtimex(struct timex32 __user *txc_p32)
600{
601 struct timex txc;
602 struct timex32 t32;
603 int ret;
604 extern int do_adjtimex(struct timex *txc);
605
606 if(copy_from_user(&t32, txc_p32, sizeof(struct timex32)))
607 return -EFAULT;
608#undef CP
609#define CP(x) txc.x = t32.x
610 CP(modes); CP(offset); CP(freq); CP(maxerror); CP(esterror);
611 CP(status); CP(constant); CP(precision); CP(tolerance);
612 CP(time.tv_sec); CP(time.tv_usec); CP(tick); CP(ppsfreq); CP(jitter);
613 CP(shift); CP(stabil); CP(jitcnt); CP(calcnt); CP(errcnt);
614 CP(stbcnt);
615 ret = do_adjtimex(&txc);
616#undef CP
617#define CP(x) t32.x = txc.x
618 CP(modes); CP(offset); CP(freq); CP(maxerror); CP(esterror);
619 CP(status); CP(constant); CP(precision); CP(tolerance);
620 CP(time.tv_sec); CP(time.tv_usec); CP(tick); CP(ppsfreq); CP(jitter);
621 CP(shift); CP(stabil); CP(jitcnt); CP(calcnt); CP(errcnt);
622 CP(stbcnt);
623 return copy_to_user(txc_p32, &t32, sizeof(struct timex32)) ? -EFAULT : ret;
624}
625
626
627struct sysinfo32 { 569struct sysinfo32 {
628 s32 uptime; 570 s32 uptime;
629 u32 loads[3]; 571 u32 loads[3];
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 71011eadb872..89b6c56ea0a8 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -207,7 +207,7 @@
207 /* struct sockaddr... */ 207 /* struct sockaddr... */
208 ENTRY_SAME(recvfrom) 208 ENTRY_SAME(recvfrom)
209 /* struct timex contains longs */ 209 /* struct timex contains longs */
210 ENTRY_DIFF(adjtimex) 210 ENTRY_COMP(adjtimex)
211 ENTRY_SAME(mprotect) /* 125 */ 211 ENTRY_SAME(mprotect) /* 125 */
212 /* old_sigset_t forced to 32 bits. Beware glibc sigset_t */ 212 /* old_sigset_t forced to 32 bits. Beware glibc sigset_t */
213 ENTRY_COMP(sigprocmask) 213 ENTRY_COMP(sigprocmask)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index fae42da7468d..a433b7126d33 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -37,6 +37,10 @@ config RWSEM_XCHGADD_ALGORITHM
37 bool 37 bool
38 default y 38 default y
39 39
40config GENERIC_HWEIGHT
41 bool
42 default y
43
40config GENERIC_CALIBRATE_DELAY 44config GENERIC_CALIBRATE_DELAY
41 bool 45 bool
42 default y 46 default y
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index cb1fe5878e8b..ad7a90212204 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -30,9 +30,11 @@
30#include <linux/kprobes.h> 30#include <linux/kprobes.h>
31#include <linux/ptrace.h> 31#include <linux/ptrace.h>
32#include <linux/preempt.h> 32#include <linux/preempt.h>
33#include <linux/module.h>
33#include <asm/cacheflush.h> 34#include <asm/cacheflush.h>
34#include <asm/kdebug.h> 35#include <asm/kdebug.h>
35#include <asm/sstep.h> 36#include <asm/sstep.h>
37#include <asm/uaccess.h>
36 38
37DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 39DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
38DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 40DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
@@ -372,17 +374,62 @@ static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
372{ 374{
373 struct kprobe *cur = kprobe_running(); 375 struct kprobe *cur = kprobe_running();
374 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 376 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
375 377 const struct exception_table_entry *entry;
376 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr)) 378
377 return 1; 379 switch(kcb->kprobe_status) {
378 380 case KPROBE_HIT_SS:
379 if (kcb->kprobe_status & KPROBE_HIT_SS) { 381 case KPROBE_REENTER:
380 resume_execution(cur, regs); 382 /*
383 * We are here because the instruction being single
384 * stepped caused a page fault. We reset the current
385 * kprobe and the nip points back to the probe address
386 * and allow the page fault handler to continue as a
387 * normal page fault.
388 */
389 regs->nip = (unsigned long)cur->addr;
381 regs->msr &= ~MSR_SE; 390 regs->msr &= ~MSR_SE;
382 regs->msr |= kcb->kprobe_saved_msr; 391 regs->msr |= kcb->kprobe_saved_msr;
383 392 if (kcb->kprobe_status == KPROBE_REENTER)
384 reset_current_kprobe(); 393 restore_previous_kprobe(kcb);
394 else
395 reset_current_kprobe();
385 preempt_enable_no_resched(); 396 preempt_enable_no_resched();
397 break;
398 case KPROBE_HIT_ACTIVE:
399 case KPROBE_HIT_SSDONE:
400 /*
401 * We increment the nmissed count for accounting,
402 * we can also use npre/npostfault count for accouting
403 * these specific fault cases.
404 */
405 kprobes_inc_nmissed_count(cur);
406
407 /*
408 * We come here because instructions in the pre/post
409 * handler caused the page_fault, this could happen
410 * if handler tries to access user space by
411 * copy_from_user(), get_user() etc. Let the
412 * user-specified handler try to fix it first.
413 */
414 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
415 return 1;
416
417 /*
418 * In case the user-specified fault handler returned
419 * zero, try to fix up.
420 */
421 if ((entry = search_exception_tables(regs->nip)) != NULL) {
422 regs->nip = entry->fixup;
423 return 1;
424 }
425
426 /*
427 * fixup_exception() could not handle it,
428 * Let do_page_fault() fix it.
429 */
430 break;
431 default:
432 break;
386 } 433 }
387 return 0; 434 return 0;
388} 435}
@@ -396,6 +443,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
396 struct die_args *args = (struct die_args *)data; 443 struct die_args *args = (struct die_args *)data;
397 int ret = NOTIFY_DONE; 444 int ret = NOTIFY_DONE;
398 445
446 if (args->regs && user_mode(args->regs))
447 return ret;
448
399 switch (val) { 449 switch (val) {
400 case DIE_BPT: 450 case DIE_BPT:
401 if (kprobe_handler(args->regs)) 451 if (kprobe_handler(args->regs))
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 1770a066c217..f698aa77127e 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -35,7 +35,6 @@
35#include <linux/mqueue.h> 35#include <linux/mqueue.h>
36#include <linux/hardirq.h> 36#include <linux/hardirq.h>
37#include <linux/utsname.h> 37#include <linux/utsname.h>
38#include <linux/kprobes.h>
39 38
40#include <asm/pgtable.h> 39#include <asm/pgtable.h>
41#include <asm/uaccess.h> 40#include <asm/uaccess.h>
@@ -460,7 +459,6 @@ void show_regs(struct pt_regs * regs)
460 459
461void exit_thread(void) 460void exit_thread(void)
462{ 461{
463 kprobe_flush_task(current);
464 discard_lazy_cpu_state(); 462 discard_lazy_cpu_state();
465} 463}
466 464
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 2f3fdad35594..e20c1fae3423 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -579,7 +579,8 @@ void __init setup_arch(char **cmdline_p)
579 panic_timeout = 180; 579 panic_timeout = 180;
580 580
581 if (ppc_md.panic) 581 if (ppc_md.panic)
582 notifier_chain_register(&panic_notifier_list, &ppc64_panic_block); 582 atomic_notifier_chain_register(&panic_notifier_list,
583 &ppc64_panic_block);
583 584
584 init_mm.start_code = PAGE_OFFSET; 585 init_mm.start_code = PAGE_OFFSET;
585 init_mm.end_code = (unsigned long) _etext; 586 init_mm.end_code = (unsigned long) _etext;
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index cd75ab2908fa..ec274e688816 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -24,7 +24,6 @@
24#include <linux/resource.h> 24#include <linux/resource.h>
25#include <linux/times.h> 25#include <linux/times.h>
26#include <linux/utsname.h> 26#include <linux/utsname.h>
27#include <linux/timex.h>
28#include <linux/smp.h> 27#include <linux/smp.h>
29#include <linux/smp_lock.h> 28#include <linux/smp_lock.h>
30#include <linux/sem.h> 29#include <linux/sem.h>
@@ -161,78 +160,6 @@ asmlinkage long compat_sys_sysfs(u32 option, u32 arg1, u32 arg2)
161 return sys_sysfs((int)option, arg1, arg2); 160 return sys_sysfs((int)option, arg1, arg2);
162} 161}
163 162
164/* Handle adjtimex compatibility. */
165struct timex32 {
166 u32 modes;
167 s32 offset, freq, maxerror, esterror;
168 s32 status, constant, precision, tolerance;
169 struct compat_timeval time;
170 s32 tick;
171 s32 ppsfreq, jitter, shift, stabil;
172 s32 jitcnt, calcnt, errcnt, stbcnt;
173 s32 :32; s32 :32; s32 :32; s32 :32;
174 s32 :32; s32 :32; s32 :32; s32 :32;
175 s32 :32; s32 :32; s32 :32; s32 :32;
176};
177
178extern int do_adjtimex(struct timex *);
179
180asmlinkage long compat_sys_adjtimex(struct timex32 __user *utp)
181{
182 struct timex txc;
183 int ret;
184
185 memset(&txc, 0, sizeof(struct timex));
186
187 if(get_user(txc.modes, &utp->modes) ||
188 __get_user(txc.offset, &utp->offset) ||
189 __get_user(txc.freq, &utp->freq) ||
190 __get_user(txc.maxerror, &utp->maxerror) ||
191 __get_user(txc.esterror, &utp->esterror) ||
192 __get_user(txc.status, &utp->status) ||
193 __get_user(txc.constant, &utp->constant) ||
194 __get_user(txc.precision, &utp->precision) ||
195 __get_user(txc.tolerance, &utp->tolerance) ||
196 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
197 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
198 __get_user(txc.tick, &utp->tick) ||
199 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
200 __get_user(txc.jitter, &utp->jitter) ||
201 __get_user(txc.shift, &utp->shift) ||
202 __get_user(txc.stabil, &utp->stabil) ||
203 __get_user(txc.jitcnt, &utp->jitcnt) ||
204 __get_user(txc.calcnt, &utp->calcnt) ||
205 __get_user(txc.errcnt, &utp->errcnt) ||
206 __get_user(txc.stbcnt, &utp->stbcnt))
207 return -EFAULT;
208
209 ret = do_adjtimex(&txc);
210
211 if(put_user(txc.modes, &utp->modes) ||
212 __put_user(txc.offset, &utp->offset) ||
213 __put_user(txc.freq, &utp->freq) ||
214 __put_user(txc.maxerror, &utp->maxerror) ||
215 __put_user(txc.esterror, &utp->esterror) ||
216 __put_user(txc.status, &utp->status) ||
217 __put_user(txc.constant, &utp->constant) ||
218 __put_user(txc.precision, &utp->precision) ||
219 __put_user(txc.tolerance, &utp->tolerance) ||
220 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
221 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
222 __put_user(txc.tick, &utp->tick) ||
223 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
224 __put_user(txc.jitter, &utp->jitter) ||
225 __put_user(txc.shift, &utp->shift) ||
226 __put_user(txc.stabil, &utp->stabil) ||
227 __put_user(txc.jitcnt, &utp->jitcnt) ||
228 __put_user(txc.calcnt, &utp->calcnt) ||
229 __put_user(txc.errcnt, &utp->errcnt) ||
230 __put_user(txc.stbcnt, &utp->stbcnt))
231 ret = -EFAULT;
232
233 return ret;
234}
235
236asmlinkage long compat_sys_pause(void) 163asmlinkage long compat_sys_pause(void)
237{ 164{
238 current->state = TASK_INTERRUPTIBLE; 165 current->state = TASK_INTERRUPTIBLE;
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 98660aedeeb7..9763faab6739 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -74,19 +74,19 @@ EXPORT_SYMBOL(__debugger_dabr_match);
74EXPORT_SYMBOL(__debugger_fault_handler); 74EXPORT_SYMBOL(__debugger_fault_handler);
75#endif 75#endif
76 76
77struct notifier_block *powerpc_die_chain; 77ATOMIC_NOTIFIER_HEAD(powerpc_die_chain);
78static DEFINE_SPINLOCK(die_notifier_lock);
79 78
80int register_die_notifier(struct notifier_block *nb) 79int register_die_notifier(struct notifier_block *nb)
81{ 80{
82 int err = 0; 81 return atomic_notifier_chain_register(&powerpc_die_chain, nb);
83 unsigned long flags; 82}
83EXPORT_SYMBOL(register_die_notifier);
84 84
85 spin_lock_irqsave(&die_notifier_lock, flags); 85int unregister_die_notifier(struct notifier_block *nb)
86 err = notifier_chain_register(&powerpc_die_chain, nb); 86{
87 spin_unlock_irqrestore(&die_notifier_lock, flags); 87 return atomic_notifier_chain_unregister(&powerpc_die_chain, nb);
88 return err;
89} 88}
89EXPORT_SYMBOL(unregister_die_notifier);
90 90
91/* 91/*
92 * Trap & Exception support 92 * Trap & Exception support
diff --git a/arch/powerpc/mm/imalloc.c b/arch/powerpc/mm/imalloc.c
index 8b0c132bc163..add8c1a9af68 100644
--- a/arch/powerpc/mm/imalloc.c
+++ b/arch/powerpc/mm/imalloc.c
@@ -13,12 +13,12 @@
13#include <asm/uaccess.h> 13#include <asm/uaccess.h>
14#include <asm/pgalloc.h> 14#include <asm/pgalloc.h>
15#include <asm/pgtable.h> 15#include <asm/pgtable.h>
16#include <asm/semaphore.h> 16#include <linux/mutex.h>
17#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
18 18
19#include "mmu_decl.h" 19#include "mmu_decl.h"
20 20
21static DECLARE_MUTEX(imlist_sem); 21static DEFINE_MUTEX(imlist_mutex);
22struct vm_struct * imlist = NULL; 22struct vm_struct * imlist = NULL;
23 23
24static int get_free_im_addr(unsigned long size, unsigned long *im_addr) 24static int get_free_im_addr(unsigned long size, unsigned long *im_addr)
@@ -257,7 +257,7 @@ struct vm_struct * im_get_free_area(unsigned long size)
257 struct vm_struct *area; 257 struct vm_struct *area;
258 unsigned long addr; 258 unsigned long addr;
259 259
260 down(&imlist_sem); 260 mutex_lock(&imlist_mutex);
261 if (get_free_im_addr(size, &addr)) { 261 if (get_free_im_addr(size, &addr)) {
262 printk(KERN_ERR "%s() cannot obtain addr for size 0x%lx\n", 262 printk(KERN_ERR "%s() cannot obtain addr for size 0x%lx\n",
263 __FUNCTION__, size); 263 __FUNCTION__, size);
@@ -272,7 +272,7 @@ struct vm_struct * im_get_free_area(unsigned long size)
272 __FUNCTION__, addr, size); 272 __FUNCTION__, addr, size);
273 } 273 }
274next_im_done: 274next_im_done:
275 up(&imlist_sem); 275 mutex_unlock(&imlist_mutex);
276 return area; 276 return area;
277} 277}
278 278
@@ -281,9 +281,9 @@ struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
281{ 281{
282 struct vm_struct *area; 282 struct vm_struct *area;
283 283
284 down(&imlist_sem); 284 mutex_lock(&imlist_mutex);
285 area = __im_get_area(v_addr, size, criteria); 285 area = __im_get_area(v_addr, size, criteria);
286 up(&imlist_sem); 286 mutex_unlock(&imlist_mutex);
287 return area; 287 return area;
288} 288}
289 289
@@ -297,17 +297,17 @@ void im_free(void * addr)
297 printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__, addr); 297 printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__, addr);
298 return; 298 return;
299 } 299 }
300 down(&imlist_sem); 300 mutex_lock(&imlist_mutex);
301 for (p = &imlist ; (tmp = *p) ; p = &tmp->next) { 301 for (p = &imlist ; (tmp = *p) ; p = &tmp->next) {
302 if (tmp->addr == addr) { 302 if (tmp->addr == addr) {
303 *p = tmp->next; 303 *p = tmp->next;
304 unmap_vm_area(tmp); 304 unmap_vm_area(tmp);
305 kfree(tmp); 305 kfree(tmp);
306 up(&imlist_sem); 306 mutex_unlock(&imlist_mutex);
307 return; 307 return;
308 } 308 }
309 } 309 }
310 up(&imlist_sem); 310 mutex_unlock(&imlist_mutex);
311 printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__, 311 printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__,
312 addr); 312 addr);
313} 313}
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index badac10d700c..5e435a9c3431 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -195,7 +195,7 @@ void show_mem(void)
195 printk("Mem-info:\n"); 195 printk("Mem-info:\n");
196 show_free_areas(); 196 show_free_areas();
197 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 197 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
198 for_each_pgdat(pgdat) { 198 for_each_online_pgdat(pgdat) {
199 unsigned long flags; 199 unsigned long flags;
200 pgdat_resize_lock(pgdat, &flags); 200 pgdat_resize_lock(pgdat, &flags);
201 for (i = 0; i < pgdat->node_spanned_pages; i++) { 201 for (i = 0; i < pgdat->node_spanned_pages; i++) {
@@ -351,7 +351,7 @@ void __init mem_init(void)
351 max_mapnr = max_pfn; 351 max_mapnr = max_pfn;
352 totalram_pages += free_all_bootmem(); 352 totalram_pages += free_all_bootmem();
353#endif 353#endif
354 for_each_pgdat(pgdat) { 354 for_each_online_pgdat(pgdat) {
355 for (i = 0; i < pgdat->node_spanned_pages; i++) { 355 for (i = 0; i < pgdat->node_spanned_pages; i++) {
356 if (!pfn_valid(pgdat->node_start_pfn + i)) 356 if (!pfn_valid(pgdat->node_start_pfn + i))
357 continue; 357 continue;
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index d75ae03df686..a8fa1eeeb174 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -32,7 +32,7 @@
32 32
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/prom.h> 34#include <asm/prom.h>
35#include <asm/semaphore.h> 35#include <linux/mutex.h>
36#include <asm/spu.h> 36#include <asm/spu.h>
37#include <asm/mmu_context.h> 37#include <asm/mmu_context.h>
38 38
@@ -342,7 +342,7 @@ spu_free_irqs(struct spu *spu)
342} 342}
343 343
344static LIST_HEAD(spu_list); 344static LIST_HEAD(spu_list);
345static DECLARE_MUTEX(spu_mutex); 345static DEFINE_MUTEX(spu_mutex);
346 346
347static void spu_init_channels(struct spu *spu) 347static void spu_init_channels(struct spu *spu)
348{ 348{
@@ -382,7 +382,7 @@ struct spu *spu_alloc(void)
382{ 382{
383 struct spu *spu; 383 struct spu *spu;
384 384
385 down(&spu_mutex); 385 mutex_lock(&spu_mutex);
386 if (!list_empty(&spu_list)) { 386 if (!list_empty(&spu_list)) {
387 spu = list_entry(spu_list.next, struct spu, list); 387 spu = list_entry(spu_list.next, struct spu, list);
388 list_del_init(&spu->list); 388 list_del_init(&spu->list);
@@ -391,7 +391,7 @@ struct spu *spu_alloc(void)
391 pr_debug("No SPU left\n"); 391 pr_debug("No SPU left\n");
392 spu = NULL; 392 spu = NULL;
393 } 393 }
394 up(&spu_mutex); 394 mutex_unlock(&spu_mutex);
395 395
396 if (spu) 396 if (spu)
397 spu_init_channels(spu); 397 spu_init_channels(spu);
@@ -402,9 +402,9 @@ EXPORT_SYMBOL_GPL(spu_alloc);
402 402
403void spu_free(struct spu *spu) 403void spu_free(struct spu *spu)
404{ 404{
405 down(&spu_mutex); 405 mutex_lock(&spu_mutex);
406 list_add_tail(&spu->list, &spu_list); 406 list_add_tail(&spu->list, &spu_list);
407 up(&spu_mutex); 407 mutex_unlock(&spu_mutex);
408} 408}
409EXPORT_SYMBOL_GPL(spu_free); 409EXPORT_SYMBOL_GPL(spu_free);
410 410
@@ -633,14 +633,14 @@ static int __init create_spu(struct device_node *spe)
633 spu->wbox_callback = NULL; 633 spu->wbox_callback = NULL;
634 spu->stop_callback = NULL; 634 spu->stop_callback = NULL;
635 635
636 down(&spu_mutex); 636 mutex_lock(&spu_mutex);
637 spu->number = number++; 637 spu->number = number++;
638 ret = spu_request_irqs(spu); 638 ret = spu_request_irqs(spu);
639 if (ret) 639 if (ret)
640 goto out_unmap; 640 goto out_unmap;
641 641
642 list_add(&spu->list, &spu_list); 642 list_add(&spu->list, &spu_list);
643 up(&spu_mutex); 643 mutex_unlock(&spu_mutex);
644 644
645 pr_debug(KERN_DEBUG "Using SPE %s %02x %p %p %p %p %d\n", 645 pr_debug(KERN_DEBUG "Using SPE %s %02x %p %p %p %p %d\n",
646 spu->name, spu->isrc, spu->local_store, 646 spu->name, spu->isrc, spu->local_store,
@@ -648,7 +648,7 @@ static int __init create_spu(struct device_node *spe)
648 goto out; 648 goto out;
649 649
650out_unmap: 650out_unmap:
651 up(&spu_mutex); 651 mutex_unlock(&spu_mutex);
652 spu_unmap(spu); 652 spu_unmap(spu);
653out_free: 653out_free:
654 kfree(spu); 654 kfree(spu);
@@ -668,10 +668,10 @@ static void destroy_spu(struct spu *spu)
668static void cleanup_spu_base(void) 668static void cleanup_spu_base(void)
669{ 669{
670 struct spu *spu, *tmp; 670 struct spu *spu, *tmp;
671 down(&spu_mutex); 671 mutex_lock(&spu_mutex);
672 list_for_each_entry_safe(spu, tmp, &spu_list, list) 672 list_for_each_entry_safe(spu, tmp, &spu_list, list)
673 destroy_spu(spu); 673 destroy_spu(spu);
674 up(&spu_mutex); 674 mutex_unlock(&spu_mutex);
675} 675}
676module_exit(cleanup_spu_base); 676module_exit(cleanup_spu_base);
677 677
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index b3962c3a0348..5be40aa483fd 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -103,7 +103,7 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr)
103 103
104static int 104static int
105spufs_new_file(struct super_block *sb, struct dentry *dentry, 105spufs_new_file(struct super_block *sb, struct dentry *dentry,
106 struct file_operations *fops, int mode, 106 const struct file_operations *fops, int mode,
107 struct spu_context *ctx) 107 struct spu_context *ctx)
108{ 108{
109 static struct inode_operations spufs_file_iops = { 109 static struct inode_operations spufs_file_iops = {
diff --git a/arch/powerpc/platforms/chrp/time.c b/arch/powerpc/platforms/chrp/time.c
index 12c6f689b1aa..7d7889026936 100644
--- a/arch/powerpc/platforms/chrp/time.c
+++ b/arch/powerpc/platforms/chrp/time.c
@@ -120,33 +120,15 @@ int chrp_set_rtc_time(struct rtc_time *tmarg)
120void chrp_get_rtc_time(struct rtc_time *tm) 120void chrp_get_rtc_time(struct rtc_time *tm)
121{ 121{
122 unsigned int year, mon, day, hour, min, sec; 122 unsigned int year, mon, day, hour, min, sec;
123 int uip, i;
124 123
125 /* The Linux interpretation of the CMOS clock register contents: 124 do {
126 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
127 * RTC registers show the second which has precisely just started.
128 * Let's hope other operating systems interpret the RTC the same way.
129 */
130
131 /* Since the UIP flag is set for about 2.2 ms and the clock
132 * is typically written with a precision of 1 jiffy, trying
133 * to obtain a precision better than a few milliseconds is
134 * an illusion. Only consistency is interesting, this also
135 * allows to use the routine for /dev/rtc without a potential
136 * 1 second kernel busy loop triggered by any reader of /dev/rtc.
137 */
138
139 for ( i = 0; i<1000000; i++) {
140 uip = chrp_cmos_clock_read(RTC_FREQ_SELECT);
141 sec = chrp_cmos_clock_read(RTC_SECONDS); 125 sec = chrp_cmos_clock_read(RTC_SECONDS);
142 min = chrp_cmos_clock_read(RTC_MINUTES); 126 min = chrp_cmos_clock_read(RTC_MINUTES);
143 hour = chrp_cmos_clock_read(RTC_HOURS); 127 hour = chrp_cmos_clock_read(RTC_HOURS);
144 day = chrp_cmos_clock_read(RTC_DAY_OF_MONTH); 128 day = chrp_cmos_clock_read(RTC_DAY_OF_MONTH);
145 mon = chrp_cmos_clock_read(RTC_MONTH); 129 mon = chrp_cmos_clock_read(RTC_MONTH);
146 year = chrp_cmos_clock_read(RTC_YEAR); 130 year = chrp_cmos_clock_read(RTC_YEAR);
147 uip |= chrp_cmos_clock_read(RTC_FREQ_SELECT); 131 } while (sec != chrp_cmos_clock_read(RTC_SECONDS));
148 if ((uip & RTC_UIP)==0) break;
149 }
150 132
151 if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { 133 if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
152 BCD_TO_BIN(sec); 134 BCD_TO_BIN(sec);
diff --git a/arch/powerpc/platforms/maple/time.c b/arch/powerpc/platforms/maple/time.c
index 5e6981d17379..b9a2b3d4bf33 100644
--- a/arch/powerpc/platforms/maple/time.c
+++ b/arch/powerpc/platforms/maple/time.c
@@ -60,34 +60,14 @@ static void maple_clock_write(unsigned long val, int addr)
60 60
61void maple_get_rtc_time(struct rtc_time *tm) 61void maple_get_rtc_time(struct rtc_time *tm)
62{ 62{
63 int uip, i; 63 do {
64
65 /* The Linux interpretation of the CMOS clock register contents:
66 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
67 * RTC registers show the second which has precisely just started.
68 * Let's hope other operating systems interpret the RTC the same way.
69 */
70
71 /* Since the UIP flag is set for about 2.2 ms and the clock
72 * is typically written with a precision of 1 jiffy, trying
73 * to obtain a precision better than a few milliseconds is
74 * an illusion. Only consistency is interesting, this also
75 * allows to use the routine for /dev/rtc without a potential
76 * 1 second kernel busy loop triggered by any reader of /dev/rtc.
77 */
78
79 for (i = 0; i<1000000; i++) {
80 uip = maple_clock_read(RTC_FREQ_SELECT);
81 tm->tm_sec = maple_clock_read(RTC_SECONDS); 64 tm->tm_sec = maple_clock_read(RTC_SECONDS);
82 tm->tm_min = maple_clock_read(RTC_MINUTES); 65 tm->tm_min = maple_clock_read(RTC_MINUTES);
83 tm->tm_hour = maple_clock_read(RTC_HOURS); 66 tm->tm_hour = maple_clock_read(RTC_HOURS);
84 tm->tm_mday = maple_clock_read(RTC_DAY_OF_MONTH); 67 tm->tm_mday = maple_clock_read(RTC_DAY_OF_MONTH);
85 tm->tm_mon = maple_clock_read(RTC_MONTH); 68 tm->tm_mon = maple_clock_read(RTC_MONTH);
86 tm->tm_year = maple_clock_read(RTC_YEAR); 69 tm->tm_year = maple_clock_read(RTC_YEAR);
87 uip |= maple_clock_read(RTC_FREQ_SELECT); 70 } while (tm->tm_sec != maple_clock_read(RTC_SECONDS));
88 if ((uip & RTC_UIP)==0)
89 break;
90 }
91 71
92 if (!(maple_clock_read(RTC_CONTROL) & RTC_DM_BINARY) 72 if (!(maple_clock_read(RTC_CONTROL) & RTC_DM_BINARY)
93 || RTC_ALWAYS_BCD) { 73 || RTC_ALWAYS_BCD) {
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c
index a415e8d2f7af..b57e465a1b71 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_64.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -21,6 +21,7 @@
21#include <linux/cpufreq.h> 21#include <linux/cpufreq.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/completion.h> 23#include <linux/completion.h>
24#include <linux/mutex.h>
24#include <asm/prom.h> 25#include <asm/prom.h>
25#include <asm/machdep.h> 26#include <asm/machdep.h>
26#include <asm/irq.h> 27#include <asm/irq.h>
@@ -90,7 +91,7 @@ static void (*g5_switch_volt)(int speed_mode);
90static int (*g5_switch_freq)(int speed_mode); 91static int (*g5_switch_freq)(int speed_mode);
91static int (*g5_query_freq)(void); 92static int (*g5_query_freq)(void);
92 93
93static DECLARE_MUTEX(g5_switch_mutex); 94static DEFINE_MUTEX(g5_switch_mutex);
94 95
95 96
96static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */ 97static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */
@@ -327,7 +328,7 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy,
327 if (g5_pmode_cur == newstate) 328 if (g5_pmode_cur == newstate)
328 return 0; 329 return 0;
329 330
330 down(&g5_switch_mutex); 331 mutex_lock(&g5_switch_mutex);
331 332
332 freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency; 333 freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency;
333 freqs.new = g5_cpu_freqs[newstate].frequency; 334 freqs.new = g5_cpu_freqs[newstate].frequency;
@@ -337,7 +338,7 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy,
337 rc = g5_switch_freq(newstate); 338 rc = g5_switch_freq(newstate);
338 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 339 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
339 340
340 up(&g5_switch_mutex); 341 mutex_unlock(&g5_switch_mutex);
341 342
342 return rc; 343 return rc;
343} 344}
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 86cfa6ecdcf3..5ad90676567a 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -94,16 +94,16 @@ static struct device_node *derive_parent(const char *path)
94 return parent; 94 return parent;
95} 95}
96 96
97static struct notifier_block *pSeries_reconfig_chain; 97static BLOCKING_NOTIFIER_HEAD(pSeries_reconfig_chain);
98 98
99int pSeries_reconfig_notifier_register(struct notifier_block *nb) 99int pSeries_reconfig_notifier_register(struct notifier_block *nb)
100{ 100{
101 return notifier_chain_register(&pSeries_reconfig_chain, nb); 101 return blocking_notifier_chain_register(&pSeries_reconfig_chain, nb);
102} 102}
103 103
104void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) 104void pSeries_reconfig_notifier_unregister(struct notifier_block *nb)
105{ 105{
106 notifier_chain_unregister(&pSeries_reconfig_chain, nb); 106 blocking_notifier_chain_unregister(&pSeries_reconfig_chain, nb);
107} 107}
108 108
109static int pSeries_reconfig_add_node(const char *path, struct property *proplist) 109static int pSeries_reconfig_add_node(const char *path, struct property *proplist)
@@ -131,7 +131,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist
131 goto out_err; 131 goto out_err;
132 } 132 }
133 133
134 err = notifier_call_chain(&pSeries_reconfig_chain, 134 err = blocking_notifier_call_chain(&pSeries_reconfig_chain,
135 PSERIES_RECONFIG_ADD, np); 135 PSERIES_RECONFIG_ADD, np);
136 if (err == NOTIFY_BAD) { 136 if (err == NOTIFY_BAD) {
137 printk(KERN_ERR "Failed to add device node %s\n", path); 137 printk(KERN_ERR "Failed to add device node %s\n", path);
@@ -171,7 +171,7 @@ static int pSeries_reconfig_remove_node(struct device_node *np)
171 171
172 remove_node_proc_entries(np); 172 remove_node_proc_entries(np);
173 173
174 notifier_call_chain(&pSeries_reconfig_chain, 174 blocking_notifier_call_chain(&pSeries_reconfig_chain,
175 PSERIES_RECONFIG_REMOVE, np); 175 PSERIES_RECONFIG_REMOVE, np);
176 of_detach_node(np); 176 of_detach_node(np);
177 177
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 54a0a9bb12dd..3a3e302b4ea2 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -19,6 +19,10 @@ config RWSEM_XCHGADD_ALGORITHM
19 bool 19 bool
20 default y 20 default y
21 21
22config GENERIC_HWEIGHT
23 bool
24 default y
25
22config GENERIC_CALIBRATE_DELAY 26config GENERIC_CALIBRATE_DELAY
23 bool 27 bool
24 default y 28 default y
diff --git a/arch/ppc/kernel/ppc_htab.c b/arch/ppc/kernel/ppc_htab.c
index 2f5c7650274f..9b84bffdefce 100644
--- a/arch/ppc/kernel/ppc_htab.c
+++ b/arch/ppc/kernel/ppc_htab.c
@@ -52,7 +52,7 @@ static int ppc_htab_open(struct inode *inode, struct file *file)
52 return single_open(file, ppc_htab_show, NULL); 52 return single_open(file, ppc_htab_show, NULL);
53} 53}
54 54
55struct file_operations ppc_htab_operations = { 55const struct file_operations ppc_htab_operations = {
56 .open = ppc_htab_open, 56 .open = ppc_htab_open,
57 .read = seq_read, 57 .read = seq_read,
58 .llseek = seq_lseek, 58 .llseek = seq_lseek,
diff --git a/arch/ppc/platforms/chrp_time.c b/arch/ppc/platforms/chrp_time.c
index c8627770af13..51e06ad66168 100644
--- a/arch/ppc/platforms/chrp_time.c
+++ b/arch/ppc/platforms/chrp_time.c
@@ -119,44 +119,28 @@ int chrp_set_rtc_time(unsigned long nowtime)
119unsigned long chrp_get_rtc_time(void) 119unsigned long chrp_get_rtc_time(void)
120{ 120{
121 unsigned int year, mon, day, hour, min, sec; 121 unsigned int year, mon, day, hour, min, sec;
122 int uip, i;
123 122
124 /* The Linux interpretation of the CMOS clock register contents: 123 do {
125 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
126 * RTC registers show the second which has precisely just started.
127 * Let's hope other operating systems interpret the RTC the same way.
128 */
129
130 /* Since the UIP flag is set for about 2.2 ms and the clock
131 * is typically written with a precision of 1 jiffy, trying
132 * to obtain a precision better than a few milliseconds is
133 * an illusion. Only consistency is interesting, this also
134 * allows to use the routine for /dev/rtc without a potential
135 * 1 second kernel busy loop triggered by any reader of /dev/rtc.
136 */
137
138 for ( i = 0; i<1000000; i++) {
139 uip = chrp_cmos_clock_read(RTC_FREQ_SELECT);
140 sec = chrp_cmos_clock_read(RTC_SECONDS); 124 sec = chrp_cmos_clock_read(RTC_SECONDS);
141 min = chrp_cmos_clock_read(RTC_MINUTES); 125 min = chrp_cmos_clock_read(RTC_MINUTES);
142 hour = chrp_cmos_clock_read(RTC_HOURS); 126 hour = chrp_cmos_clock_read(RTC_HOURS);
143 day = chrp_cmos_clock_read(RTC_DAY_OF_MONTH); 127 day = chrp_cmos_clock_read(RTC_DAY_OF_MONTH);
144 mon = chrp_cmos_clock_read(RTC_MONTH); 128 mon = chrp_cmos_clock_read(RTC_MONTH);
145 year = chrp_cmos_clock_read(RTC_YEAR); 129 year = chrp_cmos_clock_read(RTC_YEAR);
146 uip |= chrp_cmos_clock_read(RTC_FREQ_SELECT); 130 } while (sec != chrp_cmos_clock_read(RTC_SECONDS));
147 if ((uip & RTC_UIP)==0) break; 131
132 if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY)
133 || RTC_ALWAYS_BCD) {
134 BCD_TO_BIN(sec);
135 BCD_TO_BIN(min);
136 BCD_TO_BIN(hour);
137 BCD_TO_BIN(day);
138 BCD_TO_BIN(mon);
139 BCD_TO_BIN(year);
148 } 140 }
149 141
150 if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) 142 year += 1900;
151 { 143 if (year < 1970)
152 BCD_TO_BIN(sec);
153 BCD_TO_BIN(min);
154 BCD_TO_BIN(hour);
155 BCD_TO_BIN(day);
156 BCD_TO_BIN(mon);
157 BCD_TO_BIN(year);
158 }
159 if ((year += 1900) < 1970)
160 year += 100; 144 year += 100;
161 return mktime(year, mon, day, hour, min, sec); 145 return mktime(year, mon, day, hour, min, sec);
162} 146}
diff --git a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c
index a0fc628ffb1e..d95c05d9824d 100644
--- a/arch/ppc/platforms/prep_setup.c
+++ b/arch/ppc/platforms/prep_setup.c
@@ -736,7 +736,7 @@ ibm_statusled_progress(char *s, unsigned short hex)
736 hex = 0xfff; 736 hex = 0xfff;
737 if (!notifier_installed) { 737 if (!notifier_installed) {
738 ++notifier_installed; 738 ++notifier_installed;
739 notifier_chain_register(&panic_notifier_list, 739 atomic_notifier_chain_register(&panic_notifier_list,
740 &ibm_statusled_block); 740 &ibm_statusled_block);
741 } 741 }
742 } 742 }
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 2b7364ed23bc..01c5c082f970 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -14,6 +14,10 @@ config RWSEM_XCHGADD_ALGORITHM
14 bool 14 bool
15 default y 15 default y
16 16
17config GENERIC_HWEIGHT
18 bool
19 default y
20
17config GENERIC_CALIBRATE_DELAY 21config GENERIC_CALIBRATE_DELAY
18 bool 22 bool
19 default y 23 default y
diff --git a/arch/s390/crypto/crypt_s390_query.c b/arch/s390/crypto/crypt_s390_query.c
index def02bdc44a4..54fb11d7fadd 100644
--- a/arch/s390/crypto/crypt_s390_query.c
+++ b/arch/s390/crypto/crypt_s390_query.c
@@ -55,7 +55,7 @@ static void query_available_functions(void)
55 printk(KERN_INFO "KMC_AES_256: %d\n", 55 printk(KERN_INFO "KMC_AES_256: %d\n",
56 crypt_s390_func_available(KMC_AES_256_ENCRYPT)); 56 crypt_s390_func_available(KMC_AES_256_ENCRYPT));
57 57
58 /* query available KIMD fucntions */ 58 /* query available KIMD functions */
59 printk(KERN_INFO "KIMD_QUERY: %d\n", 59 printk(KERN_INFO "KIMD_QUERY: %d\n",
60 crypt_s390_func_available(KIMD_QUERY)); 60 crypt_s390_func_available(KIMD_QUERY));
61 printk(KERN_INFO "KIMD_SHA_1: %d\n", 61 printk(KERN_INFO "KIMD_SHA_1: %d\n",
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index cc058dc3bc8b..5e14de37c17b 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -26,7 +26,6 @@
26#include <linux/resource.h> 26#include <linux/resource.h>
27#include <linux/times.h> 27#include <linux/times.h>
28#include <linux/utsname.h> 28#include <linux/utsname.h>
29#include <linux/timex.h>
30#include <linux/smp.h> 29#include <linux/smp.h>
31#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
32#include <linux/sem.h> 31#include <linux/sem.h>
@@ -705,79 +704,6 @@ asmlinkage long sys32_sendfile64(int out_fd, int in_fd,
705 return ret; 704 return ret;
706} 705}
707 706
708/* Handle adjtimex compatibility. */
709
710struct timex32 {
711 u32 modes;
712 s32 offset, freq, maxerror, esterror;
713 s32 status, constant, precision, tolerance;
714 struct compat_timeval time;
715 s32 tick;
716 s32 ppsfreq, jitter, shift, stabil;
717 s32 jitcnt, calcnt, errcnt, stbcnt;
718 s32 :32; s32 :32; s32 :32; s32 :32;
719 s32 :32; s32 :32; s32 :32; s32 :32;
720 s32 :32; s32 :32; s32 :32; s32 :32;
721};
722
723extern int do_adjtimex(struct timex *);
724
725asmlinkage long sys32_adjtimex(struct timex32 __user *utp)
726{
727 struct timex txc;
728 int ret;
729
730 memset(&txc, 0, sizeof(struct timex));
731
732 if(get_user(txc.modes, &utp->modes) ||
733 __get_user(txc.offset, &utp->offset) ||
734 __get_user(txc.freq, &utp->freq) ||
735 __get_user(txc.maxerror, &utp->maxerror) ||
736 __get_user(txc.esterror, &utp->esterror) ||
737 __get_user(txc.status, &utp->status) ||
738 __get_user(txc.constant, &utp->constant) ||
739 __get_user(txc.precision, &utp->precision) ||
740 __get_user(txc.tolerance, &utp->tolerance) ||
741 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
742 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
743 __get_user(txc.tick, &utp->tick) ||
744 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
745 __get_user(txc.jitter, &utp->jitter) ||
746 __get_user(txc.shift, &utp->shift) ||
747 __get_user(txc.stabil, &utp->stabil) ||
748 __get_user(txc.jitcnt, &utp->jitcnt) ||
749 __get_user(txc.calcnt, &utp->calcnt) ||
750 __get_user(txc.errcnt, &utp->errcnt) ||
751 __get_user(txc.stbcnt, &utp->stbcnt))
752 return -EFAULT;
753
754 ret = do_adjtimex(&txc);
755
756 if(put_user(txc.modes, &utp->modes) ||
757 __put_user(txc.offset, &utp->offset) ||
758 __put_user(txc.freq, &utp->freq) ||
759 __put_user(txc.maxerror, &utp->maxerror) ||
760 __put_user(txc.esterror, &utp->esterror) ||
761 __put_user(txc.status, &utp->status) ||
762 __put_user(txc.constant, &utp->constant) ||
763 __put_user(txc.precision, &utp->precision) ||
764 __put_user(txc.tolerance, &utp->tolerance) ||
765 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
766 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
767 __put_user(txc.tick, &utp->tick) ||
768 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
769 __put_user(txc.jitter, &utp->jitter) ||
770 __put_user(txc.shift, &utp->shift) ||
771 __put_user(txc.stabil, &utp->stabil) ||
772 __put_user(txc.jitcnt, &utp->jitcnt) ||
773 __put_user(txc.calcnt, &utp->calcnt) ||
774 __put_user(txc.errcnt, &utp->errcnt) ||
775 __put_user(txc.stbcnt, &utp->stbcnt))
776 ret = -EFAULT;
777
778 return ret;
779}
780
781#ifdef CONFIG_SYSCTL 707#ifdef CONFIG_SYSCTL
782struct __sysctl_args32 { 708struct __sysctl_args32 {
783 u32 name; 709 u32 name;
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 50e80138e7ad..199da68bd7be 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -551,10 +551,10 @@ sys32_newuname_wrapper:
551 llgtr %r2,%r2 # struct new_utsname * 551 llgtr %r2,%r2 # struct new_utsname *
552 jg s390x_newuname # branch to system call 552 jg s390x_newuname # branch to system call
553 553
554 .globl sys32_adjtimex_wrapper 554 .globl compat_sys_adjtimex_wrapper
555sys32_adjtimex_wrapper: 555compat_sys_adjtimex_wrapper:
556 llgtr %r2,%r2 # struct timex_emu31 * 556 llgtr %r2,%r2 # struct compat_timex *
557 jg sys32_adjtimex # branch to system call 557 jg compat_sys_adjtimex # branch to system call
558 558
559 .globl sys32_mprotect_wrapper 559 .globl sys32_mprotect_wrapper
560sys32_mprotect_wrapper: 560sys32_mprotect_wrapper:
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 99182a415fe7..4a0f5a1551ea 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -76,17 +76,17 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
76/* 76/*
77 * Need to know about CPUs going idle? 77 * Need to know about CPUs going idle?
78 */ 78 */
79static struct notifier_block *idle_chain; 79static ATOMIC_NOTIFIER_HEAD(idle_chain);
80 80
81int register_idle_notifier(struct notifier_block *nb) 81int register_idle_notifier(struct notifier_block *nb)
82{ 82{
83 return notifier_chain_register(&idle_chain, nb); 83 return atomic_notifier_chain_register(&idle_chain, nb);
84} 84}
85EXPORT_SYMBOL(register_idle_notifier); 85EXPORT_SYMBOL(register_idle_notifier);
86 86
87int unregister_idle_notifier(struct notifier_block *nb) 87int unregister_idle_notifier(struct notifier_block *nb)
88{ 88{
89 return notifier_chain_unregister(&idle_chain, nb); 89 return atomic_notifier_chain_unregister(&idle_chain, nb);
90} 90}
91EXPORT_SYMBOL(unregister_idle_notifier); 91EXPORT_SYMBOL(unregister_idle_notifier);
92 92
@@ -95,7 +95,7 @@ void do_monitor_call(struct pt_regs *regs, long interruption_code)
95 /* disable monitor call class 0 */ 95 /* disable monitor call class 0 */
96 __ctl_clear_bit(8, 15); 96 __ctl_clear_bit(8, 15);
97 97
98 notifier_call_chain(&idle_chain, CPU_NOT_IDLE, 98 atomic_notifier_call_chain(&idle_chain, CPU_NOT_IDLE,
99 (void *)(long) smp_processor_id()); 99 (void *)(long) smp_processor_id());
100} 100}
101 101
@@ -116,7 +116,8 @@ static void default_idle(void)
116 return; 116 return;
117 } 117 }
118 118
119 rc = notifier_call_chain(&idle_chain, CPU_IDLE, (void *)(long) cpu); 119 rc = atomic_notifier_call_chain(&idle_chain,
120 CPU_IDLE, (void *)(long) cpu);
120 if (rc != NOTIFY_OK && rc != NOTIFY_DONE) 121 if (rc != NOTIFY_OK && rc != NOTIFY_DONE)
121 BUG(); 122 BUG();
122 if (rc != NOTIFY_OK) { 123 if (rc != NOTIFY_OK) {
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index 7c88d85c3597..2f56654da821 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -132,7 +132,7 @@ SYSCALL(sys_clone_glue,sys_clone_glue,sys32_clone_glue) /* 120 */
132SYSCALL(sys_setdomainname,sys_setdomainname,sys32_setdomainname_wrapper) 132SYSCALL(sys_setdomainname,sys_setdomainname,sys32_setdomainname_wrapper)
133SYSCALL(sys_newuname,s390x_newuname,sys32_newuname_wrapper) 133SYSCALL(sys_newuname,s390x_newuname,sys32_newuname_wrapper)
134NI_SYSCALL /* modify_ldt for i386 */ 134NI_SYSCALL /* modify_ldt for i386 */
135SYSCALL(sys_adjtimex,sys_adjtimex,sys32_adjtimex_wrapper) 135SYSCALL(sys_adjtimex,sys_adjtimex,compat_sys_adjtimex_wrapper)
136SYSCALL(sys_mprotect,sys_mprotect,sys32_mprotect_wrapper) /* 125 */ 136SYSCALL(sys_mprotect,sys_mprotect,sys32_mprotect_wrapper) /* 125 */
137SYSCALL(sys_sigprocmask,sys_sigprocmask,compat_sys_sigprocmask_wrapper) 137SYSCALL(sys_sigprocmask,sys_sigprocmask,compat_sys_sigprocmask_wrapper)
138NI_SYSCALL /* old "create module" */ 138NI_SYSCALL /* old "create module" */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index e9b275d90737..58583f459471 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -21,6 +21,14 @@ config RWSEM_GENERIC_SPINLOCK
21config RWSEM_XCHGADD_ALGORITHM 21config RWSEM_XCHGADD_ALGORITHM
22 bool 22 bool
23 23
24config GENERIC_FIND_NEXT_BIT
25 bool
26 default y
27
28config GENERIC_HWEIGHT
29 bool
30 default y
31
24config GENERIC_HARDIRQS 32config GENERIC_HARDIRQS
25 bool 33 bool
26 default y 34 default y
diff --git a/arch/sh/boards/mpc1211/rtc.c b/arch/sh/boards/mpc1211/rtc.c
index 4d100f048072..a76c655dceee 100644
--- a/arch/sh/boards/mpc1211/rtc.c
+++ b/arch/sh/boards/mpc1211/rtc.c
@@ -9,36 +9,16 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/time.h> 11#include <linux/time.h>
12#include <linux/bcd.h>
12#include <linux/mc146818rtc.h> 13#include <linux/mc146818rtc.h>
13 14
14#ifndef BCD_TO_BIN
15#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
16#endif
17
18#ifndef BIN_TO_BCD
19#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
20#endif
21
22/* arc/i386/kernel/time.c */
23unsigned long get_cmos_time(void) 15unsigned long get_cmos_time(void)
24{ 16{
25 unsigned int year, mon, day, hour, min, sec; 17 unsigned int year, mon, day, hour, min, sec;
26 int i;
27 18
28 spin_lock(&rtc_lock); 19 spin_lock(&rtc_lock);
29 /* The Linux interpretation of the CMOS clock register contents: 20
30 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the 21 do {
31 * RTC registers show the second which has precisely just started.
32 * Let's hope other operating systems interpret the RTC the same way.
33 */
34 /* read RTC exactly on falling edge of update flag */
35 for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
36 if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
37 break;
38 for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */
39 if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
40 break;
41 do { /* Isn't this overkill ? UIP above should guarantee consistency */
42 sec = CMOS_READ(RTC_SECONDS); 22 sec = CMOS_READ(RTC_SECONDS);
43 min = CMOS_READ(RTC_MINUTES); 23 min = CMOS_READ(RTC_MINUTES);
44 hour = CMOS_READ(RTC_HOURS); 24 hour = CMOS_READ(RTC_HOURS);
@@ -46,18 +26,22 @@ unsigned long get_cmos_time(void)
46 mon = CMOS_READ(RTC_MONTH); 26 mon = CMOS_READ(RTC_MONTH);
47 year = CMOS_READ(RTC_YEAR); 27 year = CMOS_READ(RTC_YEAR);
48 } while (sec != CMOS_READ(RTC_SECONDS)); 28 } while (sec != CMOS_READ(RTC_SECONDS));
49 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) 29
50 { 30 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
51 BCD_TO_BIN(sec); 31 BCD_TO_BIN(sec);
52 BCD_TO_BIN(min); 32 BCD_TO_BIN(min);
53 BCD_TO_BIN(hour); 33 BCD_TO_BIN(hour);
54 BCD_TO_BIN(day); 34 BCD_TO_BIN(day);
55 BCD_TO_BIN(mon); 35 BCD_TO_BIN(mon);
56 BCD_TO_BIN(year); 36 BCD_TO_BIN(year);
57 } 37 }
38
58 spin_unlock(&rtc_lock); 39 spin_unlock(&rtc_lock);
59 if ((year += 1900) < 1970) 40
41 year += 1900;
42 if (year < 1970)
60 year += 100; 43 year += 100;
44
61 return mktime(year, mon, day, hour, min, sec); 45 return mktime(year, mon, day, hour, min, sec);
62} 46}
63 47
diff --git a/arch/sh/boards/sh03/rtc.c b/arch/sh/boards/sh03/rtc.c
index cbeca7037ba5..d609863cfe53 100644
--- a/arch/sh/boards/sh03/rtc.c
+++ b/arch/sh/boards/sh03/rtc.c
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/time.h> 11#include <linux/time.h>
12#include <linux/bcd.h>
12#include <asm/io.h> 13#include <asm/io.h>
13#include <linux/rtc.h> 14#include <linux/rtc.h>
14#include <linux/spinlock.h> 15#include <linux/spinlock.h>
@@ -33,14 +34,6 @@
33#define RTC_BUSY 1 34#define RTC_BUSY 1
34#define RTC_STOP 2 35#define RTC_STOP 2
35 36
36#ifndef BCD_TO_BIN
37#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
38#endif
39
40#ifndef BIN_TO_BCD
41#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
42#endif
43
44extern void (*rtc_get_time)(struct timespec *); 37extern void (*rtc_get_time)(struct timespec *);
45extern int (*rtc_set_time)(const time_t); 38extern int (*rtc_set_time)(const time_t);
46extern spinlock_t rtc_lock; 39extern spinlock_t rtc_lock;
@@ -48,13 +41,9 @@ extern spinlock_t rtc_lock;
48unsigned long get_cmos_time(void) 41unsigned long get_cmos_time(void)
49{ 42{
50 unsigned int year, mon, day, hour, min, sec; 43 unsigned int year, mon, day, hour, min, sec;
51 int i;
52 44
53 spin_lock(&rtc_lock); 45 spin_lock(&rtc_lock);
54 again: 46 again:
55 for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
56 if (!(ctrl_inb(RTC_CTL) & RTC_BUSY))
57 break;
58 do { 47 do {
59 sec = (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10; 48 sec = (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10;
60 min = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10; 49 min = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10;
diff --git a/arch/sh/kernel/cpu/rtc.c b/arch/sh/kernel/cpu/rtc.c
index f8361f5e788b..4304cf75cfa2 100644
--- a/arch/sh/kernel/cpu/rtc.c
+++ b/arch/sh/kernel/cpu/rtc.c
@@ -9,18 +9,10 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/time.h> 11#include <linux/time.h>
12 12#include <linux/bcd.h>
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/rtc.h> 14#include <asm/rtc.h>
15 15
16#ifndef BCD_TO_BIN
17#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
18#endif
19
20#ifndef BIN_TO_BCD
21#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
22#endif
23
24void sh_rtc_gettimeofday(struct timespec *ts) 16void sh_rtc_gettimeofday(struct timespec *ts)
25{ 17{
26 unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; 18 unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit;
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index c0e79843f580..7ee4ca203616 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -20,6 +20,7 @@
20#include <linux/root_dev.h> 20#include <linux/root_dev.h>
21#include <linux/utsname.h> 21#include <linux/utsname.h>
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <linux/pfn.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <asm/sections.h> 26#include <asm/sections.h>
@@ -275,10 +276,6 @@ void __init setup_arch(char **cmdline_p)
275 276
276 sh_mv_setup(cmdline_p); 277 sh_mv_setup(cmdline_p);
277 278
278#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
279#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
280#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
281
282 /* 279 /*
283 * Find the highest page frame number we have available 280 * Find the highest page frame number we have available
284 */ 281 */
diff --git a/arch/sh64/Kconfig b/arch/sh64/Kconfig
index 07b172deb872..58c678e06667 100644
--- a/arch/sh64/Kconfig
+++ b/arch/sh64/Kconfig
@@ -21,6 +21,14 @@ config RWSEM_GENERIC_SPINLOCK
21 bool 21 bool
22 default y 22 default y
23 23
24config GENERIC_FIND_NEXT_BIT
25 bool
26 default y
27
28config GENERIC_HWEIGHT
29 bool
30 default y
31
24config GENERIC_CALIBRATE_DELAY 32config GENERIC_CALIBRATE_DELAY
25 bool 33 bool
26 default y 34 default y
diff --git a/arch/sh64/kernel/setup.c b/arch/sh64/kernel/setup.c
index c7a7b816a30f..d2711c9c9d13 100644
--- a/arch/sh64/kernel/setup.c
+++ b/arch/sh64/kernel/setup.c
@@ -48,6 +48,7 @@
48#include <linux/root_dev.h> 48#include <linux/root_dev.h>
49#include <linux/cpu.h> 49#include <linux/cpu.h>
50#include <linux/initrd.h> 50#include <linux/initrd.h>
51#include <linux/pfn.h>
51#include <asm/processor.h> 52#include <asm/processor.h>
52#include <asm/page.h> 53#include <asm/page.h>
53#include <asm/pgtable.h> 54#include <asm/pgtable.h>
diff --git a/arch/sh64/kernel/time.c b/arch/sh64/kernel/time.c
index 0773c9f389f3..6b8f4d22abc6 100644
--- a/arch/sh64/kernel/time.c
+++ b/arch/sh64/kernel/time.c
@@ -30,6 +30,7 @@
30#include <linux/profile.h> 30#include <linux/profile.h>
31#include <linux/smp.h> 31#include <linux/smp.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/bcd.h>
33 34
34#include <asm/registers.h> /* required by inline __asm__ stmt. */ 35#include <asm/registers.h> /* required by inline __asm__ stmt. */
35 36
@@ -105,14 +106,6 @@
105#define RCR1 rtc_base+0x38 106#define RCR1 rtc_base+0x38
106#define RCR2 rtc_base+0x3c 107#define RCR2 rtc_base+0x3c
107 108
108#ifndef BCD_TO_BIN
109#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
110#endif
111
112#ifndef BIN_TO_BCD
113#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
114#endif
115
116#define TICK_SIZE (tick_nsec / 1000) 109#define TICK_SIZE (tick_nsec / 1000)
117 110
118extern unsigned long wall_jiffies; 111extern unsigned long wall_jiffies;
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 7c58fc1a39c4..9431e967aa45 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -150,6 +150,14 @@ config RWSEM_GENERIC_SPINLOCK
150config RWSEM_XCHGADD_ALGORITHM 150config RWSEM_XCHGADD_ALGORITHM
151 bool 151 bool
152 152
153config GENERIC_FIND_NEXT_BIT
154 bool
155 default y
156
157config GENERIC_HWEIGHT
158 bool
159 default y
160
153config GENERIC_CALIBRATE_DELAY 161config GENERIC_CALIBRATE_DELAY
154 bool 162 bool
155 default y 163 default y
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 267afddf63cf..d1e2fc566486 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -162,6 +162,14 @@ config RWSEM_XCHGADD_ALGORITHM
162 bool 162 bool
163 default y 163 default y
164 164
165config GENERIC_FIND_NEXT_BIT
166 bool
167 default y
168
169config GENERIC_HWEIGHT
170 bool
171 default y if !ULTRA_HAS_POPULATION_COUNT
172
165config GENERIC_CALIBRATE_DELAY 173config GENERIC_CALIBRATE_DELAY
166 bool 174 bool
167 default y 175 default y
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index f819a9663a8d..900fb0b940d8 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.16 3# Linux kernel version: 2.6.16
4# Mon Mar 20 01:23:21 2006 4# Sun Mar 26 14:58:11 2006
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
@@ -38,6 +38,7 @@ CONFIG_POSIX_MQUEUE=y
38CONFIG_SYSCTL=y 38CONFIG_SYSCTL=y
39# CONFIG_AUDIT is not set 39# CONFIG_AUDIT is not set
40# CONFIG_IKCONFIG is not set 40# CONFIG_IKCONFIG is not set
41CONFIG_RELAY=y
41CONFIG_INITRAMFS_SOURCE="" 42CONFIG_INITRAMFS_SOURCE=""
42CONFIG_UID16=y 43CONFIG_UID16=y
43CONFIG_CC_OPTIMIZE_FOR_SIZE=y 44CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -53,10 +54,6 @@ CONFIG_BASE_FULL=y
53CONFIG_FUTEX=y 54CONFIG_FUTEX=y
54CONFIG_EPOLL=y 55CONFIG_EPOLL=y
55CONFIG_SHMEM=y 56CONFIG_SHMEM=y
56CONFIG_CC_ALIGN_FUNCTIONS=0
57CONFIG_CC_ALIGN_LABELS=0
58CONFIG_CC_ALIGN_LOOPS=0
59CONFIG_CC_ALIGN_JUMPS=0
60CONFIG_SLAB=y 57CONFIG_SLAB=y
61# CONFIG_TINY_SHMEM is not set 58# CONFIG_TINY_SHMEM is not set
62CONFIG_BASE_SMALL=0 59CONFIG_BASE_SMALL=0
@@ -68,7 +65,6 @@ CONFIG_BASE_SMALL=0
68CONFIG_MODULES=y 65CONFIG_MODULES=y
69CONFIG_MODULE_UNLOAD=y 66CONFIG_MODULE_UNLOAD=y
70CONFIG_MODULE_FORCE_UNLOAD=y 67CONFIG_MODULE_FORCE_UNLOAD=y
71CONFIG_OBSOLETE_MODPARM=y
72CONFIG_MODVERSIONS=y 68CONFIG_MODVERSIONS=y
73CONFIG_MODULE_SRCVERSION_ALL=y 69CONFIG_MODULE_SRCVERSION_ALL=y
74CONFIG_KMOD=y 70CONFIG_KMOD=y
@@ -76,6 +72,7 @@ CONFIG_KMOD=y
76# 72#
77# Block layer 73# Block layer
78# 74#
75CONFIG_BLK_DEV_IO_TRACE=y
79 76
80# 77#
81# IO Schedulers 78# IO Schedulers
@@ -111,6 +108,8 @@ CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
111CONFIG_US3_FREQ=m 108CONFIG_US3_FREQ=m
112CONFIG_US2E_FREQ=m 109CONFIG_US2E_FREQ=m
113CONFIG_RWSEM_XCHGADD_ALGORITHM=y 110CONFIG_RWSEM_XCHGADD_ALGORITHM=y
111CONFIG_GENERIC_FIND_NEXT_BIT=y
112CONFIG_GENERIC_HWEIGHT=y
114CONFIG_GENERIC_CALIBRATE_DELAY=y 113CONFIG_GENERIC_CALIBRATE_DELAY=y
115CONFIG_HUGETLB_PAGE_SIZE_4MB=y 114CONFIG_HUGETLB_PAGE_SIZE_4MB=y
116# CONFIG_HUGETLB_PAGE_SIZE_512K is not set 115# CONFIG_HUGETLB_PAGE_SIZE_512K is not set
@@ -128,7 +127,6 @@ CONFIG_HAVE_MEMORY_PRESENT=y
128CONFIG_SPARSEMEM_EXTREME=y 127CONFIG_SPARSEMEM_EXTREME=y
129CONFIG_MEMORY_HOTPLUG=y 128CONFIG_MEMORY_HOTPLUG=y
130CONFIG_SPLIT_PTLOCK_CPUS=4 129CONFIG_SPLIT_PTLOCK_CPUS=4
131CONFIG_MIGRATION=y
132CONFIG_GENERIC_ISA_DMA=y 130CONFIG_GENERIC_ISA_DMA=y
133CONFIG_SBUS=y 131CONFIG_SBUS=y
134CONFIG_SBUSCHAR=y 132CONFIG_SBUSCHAR=y
@@ -136,7 +134,6 @@ CONFIG_SUN_AUXIO=y
136CONFIG_SUN_IO=y 134CONFIG_SUN_IO=y
137CONFIG_PCI=y 135CONFIG_PCI=y
138CONFIG_PCI_DOMAINS=y 136CONFIG_PCI_DOMAINS=y
139# CONFIG_PCI_LEGACY_PROC is not set
140# CONFIG_PCI_DEBUG is not set 137# CONFIG_PCI_DEBUG is not set
141CONFIG_SUN_OPENPROMFS=m 138CONFIG_SUN_OPENPROMFS=m
142CONFIG_SPARC32_COMPAT=y 139CONFIG_SPARC32_COMPAT=y
@@ -201,6 +198,8 @@ CONFIG_TCP_CONG_VEGAS=m
201CONFIG_TCP_CONG_SCALABLE=m 198CONFIG_TCP_CONG_SCALABLE=m
202CONFIG_IPV6=m 199CONFIG_IPV6=m
203CONFIG_IPV6_PRIVACY=y 200CONFIG_IPV6_PRIVACY=y
201CONFIG_IPV6_ROUTER_PREF=y
202CONFIG_IPV6_ROUTE_INFO=y
204CONFIG_INET6_AH=m 203CONFIG_INET6_AH=m
205CONFIG_INET6_ESP=m 204CONFIG_INET6_ESP=m
206CONFIG_INET6_IPCOMP=m 205CONFIG_INET6_IPCOMP=m
@@ -213,10 +212,12 @@ CONFIG_IPV6_TUNNEL=m
213# 212#
214CONFIG_IP_DCCP=m 213CONFIG_IP_DCCP=m
215CONFIG_INET_DCCP_DIAG=m 214CONFIG_INET_DCCP_DIAG=m
215CONFIG_IP_DCCP_ACKVEC=y
216 216
217# 217#
218# DCCP CCIDs Configuration (EXPERIMENTAL) 218# DCCP CCIDs Configuration (EXPERIMENTAL)
219# 219#
220CONFIG_IP_DCCP_CCID2=m
220CONFIG_IP_DCCP_CCID3=m 221CONFIG_IP_DCCP_CCID3=m
221CONFIG_IP_DCCP_TFRC_LIB=m 222CONFIG_IP_DCCP_TFRC_LIB=m
222 223
@@ -224,7 +225,6 @@ CONFIG_IP_DCCP_TFRC_LIB=m
224# DCCP Kernel Hacking 225# DCCP Kernel Hacking
225# 226#
226# CONFIG_IP_DCCP_DEBUG is not set 227# CONFIG_IP_DCCP_DEBUG is not set
227# CONFIG_IP_DCCP_UNLOAD_HACK is not set
228 228
229# 229#
230# SCTP Configuration (EXPERIMENTAL) 230# SCTP Configuration (EXPERIMENTAL)
@@ -309,6 +309,7 @@ CONFIG_BLK_DEV_NBD=m
309CONFIG_BLK_DEV_UB=m 309CONFIG_BLK_DEV_UB=m
310# CONFIG_BLK_DEV_RAM is not set 310# CONFIG_BLK_DEV_RAM is not set
311CONFIG_BLK_DEV_RAM_COUNT=16 311CONFIG_BLK_DEV_RAM_COUNT=16
312# CONFIG_BLK_DEV_INITRD is not set
312CONFIG_CDROM_PKTCDVD=m 313CONFIG_CDROM_PKTCDVD=m
313CONFIG_CDROM_PKTCDVD_BUFFERS=8 314CONFIG_CDROM_PKTCDVD_BUFFERS=8
314CONFIG_CDROM_PKTCDVD_WCACHE=y 315CONFIG_CDROM_PKTCDVD_WCACHE=y
@@ -722,7 +723,6 @@ CONFIG_I2C_ALGOBIT=y
722# CONFIG_I2C_PARPORT_LIGHT is not set 723# CONFIG_I2C_PARPORT_LIGHT is not set
723# CONFIG_I2C_PROSAVAGE is not set 724# CONFIG_I2C_PROSAVAGE is not set
724# CONFIG_I2C_SAVAGE4 is not set 725# CONFIG_I2C_SAVAGE4 is not set
725# CONFIG_SCx200_ACB is not set
726# CONFIG_I2C_SIS5595 is not set 726# CONFIG_I2C_SIS5595 is not set
727# CONFIG_I2C_SIS630 is not set 727# CONFIG_I2C_SIS630 is not set
728# CONFIG_I2C_SIS96X is not set 728# CONFIG_I2C_SIS96X is not set
@@ -808,10 +808,6 @@ CONFIG_HWMON=y
808# 808#
809 809
810# 810#
811# Multimedia Capabilities Port drivers
812#
813
814#
815# Multimedia devices 811# Multimedia devices
816# 812#
817# CONFIG_VIDEO_DEV is not set 813# CONFIG_VIDEO_DEV is not set
@@ -820,6 +816,7 @@ CONFIG_HWMON=y
820# Digital Video Broadcasting Devices 816# Digital Video Broadcasting Devices
821# 817#
822# CONFIG_DVB is not set 818# CONFIG_DVB is not set
819# CONFIG_USB_DABUSB is not set
823 820
824# 821#
825# Graphics support 822# Graphics support
@@ -901,10 +898,12 @@ CONFIG_SND_SEQ_DUMMY=m
901CONFIG_SND_OSSEMUL=y 898CONFIG_SND_OSSEMUL=y
902CONFIG_SND_MIXER_OSS=m 899CONFIG_SND_MIXER_OSS=m
903CONFIG_SND_PCM_OSS=m 900CONFIG_SND_PCM_OSS=m
901CONFIG_SND_PCM_OSS_PLUGINS=y
904CONFIG_SND_SEQUENCER_OSS=y 902CONFIG_SND_SEQUENCER_OSS=y
905# CONFIG_SND_RTCTIMER is not set 903# CONFIG_SND_RTCTIMER is not set
906# CONFIG_SND_DYNAMIC_MINORS is not set 904# CONFIG_SND_DYNAMIC_MINORS is not set
907CONFIG_SND_SUPPORT_OLD_API=y 905CONFIG_SND_SUPPORT_OLD_API=y
906CONFIG_SND_VERBOSE_PROCFS=y
908# CONFIG_SND_VERBOSE_PRINTK is not set 907# CONFIG_SND_VERBOSE_PRINTK is not set
909# CONFIG_SND_DEBUG is not set 908# CONFIG_SND_DEBUG is not set
910 909
@@ -987,6 +986,7 @@ CONFIG_SND_SUN_CS4231=m
987# 986#
988CONFIG_USB_ARCH_HAS_HCD=y 987CONFIG_USB_ARCH_HAS_HCD=y
989CONFIG_USB_ARCH_HAS_OHCI=y 988CONFIG_USB_ARCH_HAS_OHCI=y
989CONFIG_USB_ARCH_HAS_EHCI=y
990CONFIG_USB=y 990CONFIG_USB=y
991# CONFIG_USB_DEBUG is not set 991# CONFIG_USB_DEBUG is not set
992 992
@@ -1014,7 +1014,6 @@ CONFIG_USB_UHCI_HCD=m
1014# 1014#
1015# USB Device Class drivers 1015# USB Device Class drivers
1016# 1016#
1017# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
1018# CONFIG_USB_ACM is not set 1017# CONFIG_USB_ACM is not set
1019# CONFIG_USB_PRINTER is not set 1018# CONFIG_USB_PRINTER is not set
1020 1019
@@ -1058,15 +1057,6 @@ CONFIG_USB_HIDDEV=y
1058# CONFIG_USB_MICROTEK is not set 1057# CONFIG_USB_MICROTEK is not set
1059 1058
1060# 1059#
1061# USB Multimedia devices
1062#
1063# CONFIG_USB_DABUSB is not set
1064
1065#
1066# Video4Linux support is needed for USB Multimedia device support
1067#
1068
1069#
1070# USB Network Adapters 1060# USB Network Adapters
1071# 1061#
1072# CONFIG_USB_CATC is not set 1062# CONFIG_USB_CATC is not set
@@ -1194,7 +1184,6 @@ CONFIG_TMPFS=y
1194CONFIG_HUGETLBFS=y 1184CONFIG_HUGETLBFS=y
1195CONFIG_HUGETLB_PAGE=y 1185CONFIG_HUGETLB_PAGE=y
1196CONFIG_RAMFS=y 1186CONFIG_RAMFS=y
1197CONFIG_RELAYFS_FS=m
1198# CONFIG_CONFIGFS_FS is not set 1187# CONFIG_CONFIGFS_FS is not set
1199 1188
1200# 1189#
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
index b9a9ce70e55c..ffc7309e9f22 100644
--- a/arch/sparc64/kernel/kprobes.c
+++ b/arch/sparc64/kernel/kprobes.c
@@ -6,9 +6,11 @@
6#include <linux/config.h> 6#include <linux/config.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/kprobes.h> 8#include <linux/kprobes.h>
9#include <linux/module.h>
9#include <asm/kdebug.h> 10#include <asm/kdebug.h>
10#include <asm/signal.h> 11#include <asm/signal.h>
11#include <asm/cacheflush.h> 12#include <asm/cacheflush.h>
13#include <asm/uaccess.h>
12 14
13/* We do not have hardware single-stepping on sparc64. 15/* We do not have hardware single-stepping on sparc64.
14 * So we implement software single-stepping with breakpoint 16 * So we implement software single-stepping with breakpoint
@@ -302,16 +304,68 @@ static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
302{ 304{
303 struct kprobe *cur = kprobe_running(); 305 struct kprobe *cur = kprobe_running();
304 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 306 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
307 const struct exception_table_entry *entry;
308
309 switch(kcb->kprobe_status) {
310 case KPROBE_HIT_SS:
311 case KPROBE_REENTER:
312 /*
313 * We are here because the instruction being single
314 * stepped caused a page fault. We reset the current
315 * kprobe and the tpc points back to the probe address
316 * and allow the page fault handler to continue as a
317 * normal page fault.
318 */
319 regs->tpc = (unsigned long)cur->addr;
320 regs->tnpc = kcb->kprobe_orig_tnpc;
321 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
322 kcb->kprobe_orig_tstate_pil);
323 if (kcb->kprobe_status == KPROBE_REENTER)
324 restore_previous_kprobe(kcb);
325 else
326 reset_current_kprobe();
327 preempt_enable_no_resched();
328 break;
329 case KPROBE_HIT_ACTIVE:
330 case KPROBE_HIT_SSDONE:
331 /*
332 * We increment the nmissed count for accounting,
333 * we can also use npre/npostfault count for accouting
334 * these specific fault cases.
335 */
336 kprobes_inc_nmissed_count(cur);
337
338 /*
339 * We come here because instructions in the pre/post
340 * handler caused the page_fault, this could happen
341 * if handler tries to access user space by
342 * copy_from_user(), get_user() etc. Let the
343 * user-specified handler try to fix it first.
344 */
345 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
346 return 1;
305 347
306 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr)) 348 /*
307 return 1; 349 * In case the user-specified fault handler returned
350 * zero, try to fix up.
351 */
308 352
309 if (kcb->kprobe_status & KPROBE_HIT_SS) { 353 entry = search_exception_tables(regs->tpc);
310 resume_execution(cur, regs, kcb); 354 if (entry) {
355 regs->tpc = entry->fixup;
356 regs->tnpc = regs->tpc + 4;
357 return 1;
358 }
311 359
312 reset_current_kprobe(); 360 /*
313 preempt_enable_no_resched(); 361 * fixup_exception() could not handle it,
362 * Let do_page_fault() fix it.
363 */
364 break;
365 default:
366 break;
314 } 367 }
368
315 return 0; 369 return 0;
316} 370}
317 371
@@ -324,6 +378,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
324 struct die_args *args = (struct die_args *)data; 378 struct die_args *args = (struct die_args *)data;
325 int ret = NOTIFY_DONE; 379 int ret = NOTIFY_DONE;
326 380
381 if (args->regs && user_mode(args->regs))
382 return ret;
383
327 switch (val) { 384 switch (val) {
328 case DIE_DEBUG: 385 case DIE_DEBUG:
329 if (kprobe_handler(args->regs)) 386 if (kprobe_handler(args->regs))
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index 9914a17651b4..f5e8db1de76b 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -175,11 +175,6 @@ EXPORT_SYMBOL(set_bit);
175EXPORT_SYMBOL(clear_bit); 175EXPORT_SYMBOL(clear_bit);
176EXPORT_SYMBOL(change_bit); 176EXPORT_SYMBOL(change_bit);
177 177
178/* Bit searching */
179EXPORT_SYMBOL(find_next_bit);
180EXPORT_SYMBOL(find_next_zero_bit);
181EXPORT_SYMBOL(find_next_zero_le_bit);
182
183EXPORT_SYMBOL(ivector_table); 178EXPORT_SYMBOL(ivector_table);
184EXPORT_SYMBOL(enable_irq); 179EXPORT_SYMBOL(enable_irq);
185EXPORT_SYMBOL(disable_irq); 180EXPORT_SYMBOL(disable_irq);
@@ -279,18 +274,9 @@ EXPORT_SYMBOL(__prom_getsibling);
279 274
280/* sparc library symbols */ 275/* sparc library symbols */
281EXPORT_SYMBOL(strlen); 276EXPORT_SYMBOL(strlen);
282EXPORT_SYMBOL(strnlen);
283EXPORT_SYMBOL(__strlen_user); 277EXPORT_SYMBOL(__strlen_user);
284EXPORT_SYMBOL(__strnlen_user); 278EXPORT_SYMBOL(__strnlen_user);
285EXPORT_SYMBOL(strcpy);
286EXPORT_SYMBOL(strncpy);
287EXPORT_SYMBOL(strcat);
288EXPORT_SYMBOL(strncat);
289EXPORT_SYMBOL(strcmp);
290EXPORT_SYMBOL(strchr);
291EXPORT_SYMBOL(strrchr);
292EXPORT_SYMBOL(strpbrk); 279EXPORT_SYMBOL(strpbrk);
293EXPORT_SYMBOL(strstr);
294 280
295#ifdef CONFIG_SOLARIS_EMUL_MODULE 281#ifdef CONFIG_SOLARIS_EMUL_MODULE
296EXPORT_SYMBOL(linux_sparc_syscall); 282EXPORT_SYMBOL(linux_sparc_syscall);
@@ -324,7 +310,6 @@ EXPORT_SYMBOL(__memscan_zero);
324EXPORT_SYMBOL(__memscan_generic); 310EXPORT_SYMBOL(__memscan_generic);
325EXPORT_SYMBOL(__memcmp); 311EXPORT_SYMBOL(__memcmp);
326EXPORT_SYMBOL(__memset); 312EXPORT_SYMBOL(__memset);
327EXPORT_SYMBOL(memchr);
328 313
329EXPORT_SYMBOL(csum_partial); 314EXPORT_SYMBOL(csum_partial);
330EXPORT_SYMBOL(csum_partial_copy_nocheck); 315EXPORT_SYMBOL(csum_partial_copy_nocheck);
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index 0e41df024489..2e906bad56fa 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -19,7 +19,6 @@
19#include <linux/resource.h> 19#include <linux/resource.h>
20#include <linux/times.h> 20#include <linux/times.h>
21#include <linux/utsname.h> 21#include <linux/utsname.h>
22#include <linux/timex.h>
23#include <linux/smp.h> 22#include <linux/smp.h>
24#include <linux/smp_lock.h> 23#include <linux/smp_lock.h>
25#include <linux/sem.h> 24#include <linux/sem.h>
@@ -945,79 +944,6 @@ asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
945 return ret; 944 return ret;
946} 945}
947 946
948/* Handle adjtimex compatibility. */
949
950struct timex32 {
951 u32 modes;
952 s32 offset, freq, maxerror, esterror;
953 s32 status, constant, precision, tolerance;
954 struct compat_timeval time;
955 s32 tick;
956 s32 ppsfreq, jitter, shift, stabil;
957 s32 jitcnt, calcnt, errcnt, stbcnt;
958 s32 :32; s32 :32; s32 :32; s32 :32;
959 s32 :32; s32 :32; s32 :32; s32 :32;
960 s32 :32; s32 :32; s32 :32; s32 :32;
961};
962
963extern int do_adjtimex(struct timex *);
964
965asmlinkage long sys32_adjtimex(struct timex32 __user *utp)
966{
967 struct timex txc;
968 int ret;
969
970 memset(&txc, 0, sizeof(struct timex));
971
972 if (get_user(txc.modes, &utp->modes) ||
973 __get_user(txc.offset, &utp->offset) ||
974 __get_user(txc.freq, &utp->freq) ||
975 __get_user(txc.maxerror, &utp->maxerror) ||
976 __get_user(txc.esterror, &utp->esterror) ||
977 __get_user(txc.status, &utp->status) ||
978 __get_user(txc.constant, &utp->constant) ||
979 __get_user(txc.precision, &utp->precision) ||
980 __get_user(txc.tolerance, &utp->tolerance) ||
981 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
982 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
983 __get_user(txc.tick, &utp->tick) ||
984 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
985 __get_user(txc.jitter, &utp->jitter) ||
986 __get_user(txc.shift, &utp->shift) ||
987 __get_user(txc.stabil, &utp->stabil) ||
988 __get_user(txc.jitcnt, &utp->jitcnt) ||
989 __get_user(txc.calcnt, &utp->calcnt) ||
990 __get_user(txc.errcnt, &utp->errcnt) ||
991 __get_user(txc.stbcnt, &utp->stbcnt))
992 return -EFAULT;
993
994 ret = do_adjtimex(&txc);
995
996 if (put_user(txc.modes, &utp->modes) ||
997 __put_user(txc.offset, &utp->offset) ||
998 __put_user(txc.freq, &utp->freq) ||
999 __put_user(txc.maxerror, &utp->maxerror) ||
1000 __put_user(txc.esterror, &utp->esterror) ||
1001 __put_user(txc.status, &utp->status) ||
1002 __put_user(txc.constant, &utp->constant) ||
1003 __put_user(txc.precision, &utp->precision) ||
1004 __put_user(txc.tolerance, &utp->tolerance) ||
1005 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
1006 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
1007 __put_user(txc.tick, &utp->tick) ||
1008 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
1009 __put_user(txc.jitter, &utp->jitter) ||
1010 __put_user(txc.shift, &utp->shift) ||
1011 __put_user(txc.stabil, &utp->stabil) ||
1012 __put_user(txc.jitcnt, &utp->jitcnt) ||
1013 __put_user(txc.calcnt, &utp->calcnt) ||
1014 __put_user(txc.errcnt, &utp->errcnt) ||
1015 __put_user(txc.stbcnt, &utp->stbcnt))
1016 ret = -EFAULT;
1017
1018 return ret;
1019}
1020
1021/* This is just a version for 32-bit applications which does 947/* This is just a version for 32-bit applications which does
1022 * not force O_LARGEFILE on. 948 * not force O_LARGEFILE on.
1023 */ 949 */
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index c3adb7ac167d..3b250f2318fd 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -63,7 +63,7 @@ sys_call_table32:
63/*200*/ .word sys32_ssetmask, sys_sigsuspend, compat_sys_newlstat, sys_uselib, compat_sys_old_readdir 63/*200*/ .word sys32_ssetmask, sys_sigsuspend, compat_sys_newlstat, sys_uselib, compat_sys_old_readdir
64 .word sys32_readahead, sys32_socketcall, sys32_syslog, sys32_lookup_dcookie, sys32_fadvise64 64 .word sys32_readahead, sys32_socketcall, sys32_syslog, sys32_lookup_dcookie, sys32_fadvise64
65/*210*/ .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, sys32_sysinfo 65/*210*/ .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, sys32_sysinfo
66 .word sys32_ipc, sys32_sigreturn, sys_clone, sys32_ioprio_get, sys32_adjtimex 66 .word sys32_ipc, sys32_sigreturn, sys_clone, sys32_ioprio_get, compat_sys_adjtimex
67/*220*/ .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid 67/*220*/ .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid
68 .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16 68 .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16
69/*230*/ .word sys32_select, compat_sys_time, sys_nis_syscall, compat_sys_stime, compat_sys_statfs64 69/*230*/ .word sys32_select, compat_sys_time, sys_nis_syscall, compat_sys_stime, compat_sys_statfs64
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index 7d61f1bfd3d3..e55b5c6ece02 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -641,23 +641,8 @@ static void __init set_system_time(void)
641 mon = MSTK_REG_MONTH(mregs); 641 mon = MSTK_REG_MONTH(mregs);
642 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) ); 642 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
643 } else { 643 } else {
644 int i;
645
646 /* Dallas 12887 RTC chip. */ 644 /* Dallas 12887 RTC chip. */
647 645
648 /* Stolen from arch/i386/kernel/time.c, see there for
649 * credits and descriptive comments.
650 */
651 for (i = 0; i < 1000000; i++) {
652 if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
653 break;
654 udelay(10);
655 }
656 for (i = 0; i < 1000000; i++) {
657 if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
658 break;
659 udelay(10);
660 }
661 do { 646 do {
662 sec = CMOS_READ(RTC_SECONDS); 647 sec = CMOS_READ(RTC_SECONDS);
663 min = CMOS_READ(RTC_MINUTES); 648 min = CMOS_READ(RTC_MINUTES);
@@ -666,6 +651,7 @@ static void __init set_system_time(void)
666 mon = CMOS_READ(RTC_MONTH); 651 mon = CMOS_READ(RTC_MONTH);
667 year = CMOS_READ(RTC_YEAR); 652 year = CMOS_READ(RTC_YEAR);
668 } while (sec != CMOS_READ(RTC_SECONDS)); 653 } while (sec != CMOS_READ(RTC_SECONDS));
654
669 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { 655 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
670 BCD_TO_BIN(sec); 656 BCD_TO_BIN(sec);
671 BCD_TO_BIN(min); 657 BCD_TO_BIN(min);
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index df612e4f75f9..ff090bb9734b 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -43,18 +43,19 @@
43#include <linux/kmod.h> 43#include <linux/kmod.h>
44#endif 44#endif
45 45
46struct notifier_block *sparc64die_chain; 46ATOMIC_NOTIFIER_HEAD(sparc64die_chain);
47static DEFINE_SPINLOCK(die_notifier_lock);
48 47
49int register_die_notifier(struct notifier_block *nb) 48int register_die_notifier(struct notifier_block *nb)
50{ 49{
51 int err = 0; 50 return atomic_notifier_chain_register(&sparc64die_chain, nb);
52 unsigned long flags;
53 spin_lock_irqsave(&die_notifier_lock, flags);
54 err = notifier_chain_register(&sparc64die_chain, nb);
55 spin_unlock_irqrestore(&die_notifier_lock, flags);
56 return err;
57} 51}
52EXPORT_SYMBOL(register_die_notifier);
53
54int unregister_die_notifier(struct notifier_block *nb)
55{
56 return atomic_notifier_chain_unregister(&sparc64die_chain, nb);
57}
58EXPORT_SYMBOL(unregister_die_notifier);
58 59
59/* When an irrecoverable trap occurs at tl > 0, the trap entry 60/* When an irrecoverable trap occurs at tl > 0, the trap entry
60 * code logs the trap state registers at every level in the trap 61 * code logs the trap state registers at every level in the trap
diff --git a/arch/sparc64/lib/Makefile b/arch/sparc64/lib/Makefile
index 8812ded19f01..4a725d8985f1 100644
--- a/arch/sparc64/lib/Makefile
+++ b/arch/sparc64/lib/Makefile
@@ -14,6 +14,6 @@ lib-y := PeeCeeI.o copy_page.o clear_page.o strlen.o strncmp.o \
14 NGmemcpy.o NGcopy_from_user.o NGcopy_to_user.o NGpatch.o \ 14 NGmemcpy.o NGcopy_from_user.o NGcopy_to_user.o NGpatch.o \
15 NGpage.o NGbzero.o \ 15 NGpage.o NGbzero.o \
16 copy_in_user.o user_fixup.o memmove.o \ 16 copy_in_user.o user_fixup.o memmove.o \
17 mcount.o ipcsum.o rwsem.o xor.o find_bit.o delay.o 17 mcount.o ipcsum.o rwsem.o xor.o delay.o
18 18
19obj-y += iomap.o 19obj-y += iomap.o
diff --git a/arch/sparc64/lib/find_bit.c b/arch/sparc64/lib/find_bit.c
deleted file mode 100644
index 6059557067b4..000000000000
--- a/arch/sparc64/lib/find_bit.c
+++ /dev/null
@@ -1,127 +0,0 @@
1#include <linux/bitops.h>
2
3/**
4 * find_next_bit - find the next set bit in a memory region
5 * @addr: The address to base the search on
6 * @offset: The bitnumber to start searching at
7 * @size: The maximum size to search
8 */
9unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
10 unsigned long offset)
11{
12 const unsigned long *p = addr + (offset >> 6);
13 unsigned long result = offset & ~63UL;
14 unsigned long tmp;
15
16 if (offset >= size)
17 return size;
18 size -= result;
19 offset &= 63UL;
20 if (offset) {
21 tmp = *(p++);
22 tmp &= (~0UL << offset);
23 if (size < 64)
24 goto found_first;
25 if (tmp)
26 goto found_middle;
27 size -= 64;
28 result += 64;
29 }
30 while (size & ~63UL) {
31 if ((tmp = *(p++)))
32 goto found_middle;
33 result += 64;
34 size -= 64;
35 }
36 if (!size)
37 return result;
38 tmp = *p;
39
40found_first:
41 tmp &= (~0UL >> (64 - size));
42 if (tmp == 0UL) /* Are any bits set? */
43 return result + size; /* Nope. */
44found_middle:
45 return result + __ffs(tmp);
46}
47
48/* find_next_zero_bit() finds the first zero bit in a bit string of length
49 * 'size' bits, starting the search at bit 'offset'. This is largely based
50 * on Linus's ALPHA routines, which are pretty portable BTW.
51 */
52
53unsigned long find_next_zero_bit(const unsigned long *addr,
54 unsigned long size, unsigned long offset)
55{
56 const unsigned long *p = addr + (offset >> 6);
57 unsigned long result = offset & ~63UL;
58 unsigned long tmp;
59
60 if (offset >= size)
61 return size;
62 size -= result;
63 offset &= 63UL;
64 if (offset) {
65 tmp = *(p++);
66 tmp |= ~0UL >> (64-offset);
67 if (size < 64)
68 goto found_first;
69 if (~tmp)
70 goto found_middle;
71 size -= 64;
72 result += 64;
73 }
74 while (size & ~63UL) {
75 if (~(tmp = *(p++)))
76 goto found_middle;
77 result += 64;
78 size -= 64;
79 }
80 if (!size)
81 return result;
82 tmp = *p;
83
84found_first:
85 tmp |= ~0UL << size;
86 if (tmp == ~0UL) /* Are any bits zero? */
87 return result + size; /* Nope. */
88found_middle:
89 return result + ffz(tmp);
90}
91
92unsigned long find_next_zero_le_bit(unsigned long *addr, unsigned long size, unsigned long offset)
93{
94 unsigned long *p = addr + (offset >> 6);
95 unsigned long result = offset & ~63UL;
96 unsigned long tmp;
97
98 if (offset >= size)
99 return size;
100 size -= result;
101 offset &= 63UL;
102 if(offset) {
103 tmp = __swab64p(p++);
104 tmp |= (~0UL >> (64-offset));
105 if(size < 64)
106 goto found_first;
107 if(~tmp)
108 goto found_middle;
109 size -= 64;
110 result += 64;
111 }
112 while(size & ~63) {
113 if(~(tmp = __swab64p(p++)))
114 goto found_middle;
115 result += 64;
116 size -= 64;
117 }
118 if(!size)
119 return result;
120 tmp = __swab64p(p);
121found_first:
122 tmp |= (~0UL << size);
123 if (tmp == ~0UL) /* Are any bits zero? */
124 return result + size; /* Nope. */
125found_middle:
126 return result + ffz(tmp);
127}
diff --git a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c
index d21ff3230c02..0db2f7d9fab5 100644
--- a/arch/sparc64/mm/fault.c
+++ b/arch/sparc64/mm/fault.c
@@ -413,12 +413,12 @@ good_area:
413#ifdef CONFIG_HUGETLB_PAGE 413#ifdef CONFIG_HUGETLB_PAGE
414 mm_rss -= (mm->context.huge_pte_count * (HPAGE_SIZE / PAGE_SIZE)); 414 mm_rss -= (mm->context.huge_pte_count * (HPAGE_SIZE / PAGE_SIZE));
415#endif 415#endif
416 if (unlikely(mm_rss >= 416 if (unlikely(mm_rss >
417 mm->context.tsb_block[MM_TSB_BASE].tsb_rss_limit)) 417 mm->context.tsb_block[MM_TSB_BASE].tsb_rss_limit))
418 tsb_grow(mm, MM_TSB_BASE, mm_rss); 418 tsb_grow(mm, MM_TSB_BASE, mm_rss);
419#ifdef CONFIG_HUGETLB_PAGE 419#ifdef CONFIG_HUGETLB_PAGE
420 mm_rss = mm->context.huge_pte_count; 420 mm_rss = mm->context.huge_pte_count;
421 if (unlikely(mm_rss >= 421 if (unlikely(mm_rss >
422 mm->context.tsb_block[MM_TSB_HUGE].tsb_rss_limit)) 422 mm->context.tsb_block[MM_TSB_HUGE].tsb_rss_limit))
423 tsb_grow(mm, MM_TSB_HUGE, mm_rss); 423 tsb_grow(mm, MM_TSB_HUGE, mm_rss);
424#endif 424#endif
diff --git a/arch/um/Kconfig.i386 b/arch/um/Kconfig.i386
index ef79ed25aecd..85e6a55b3b59 100644
--- a/arch/um/Kconfig.i386
+++ b/arch/um/Kconfig.i386
@@ -52,3 +52,8 @@ config ARCH_HAS_SC_SIGNALS
52config ARCH_REUSE_HOST_VSYSCALL_AREA 52config ARCH_REUSE_HOST_VSYSCALL_AREA
53 bool 53 bool
54 default y 54 default y
55
56config GENERIC_HWEIGHT
57 bool
58 default y
59
diff --git a/arch/um/Kconfig.x86_64 b/arch/um/Kconfig.x86_64
index aae19bc4b06a..f60e9e506424 100644
--- a/arch/um/Kconfig.x86_64
+++ b/arch/um/Kconfig.x86_64
@@ -46,3 +46,8 @@ config ARCH_REUSE_HOST_VSYSCALL_AREA
46config SMP_BROKEN 46config SMP_BROKEN
47 bool 47 bool
48 default y 48 default y
49
50config GENERIC_HWEIGHT
51 bool
52 default y
53
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 54388d10bcf9..1488816588ea 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -762,7 +762,8 @@ static struct notifier_block panic_exit_notifier = {
762 762
763static int add_notifier(void) 763static int add_notifier(void)
764{ 764{
765 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); 765 atomic_notifier_chain_register(&panic_notifier_list,
766 &panic_exit_notifier);
766 return(0); 767 return(0);
767} 768}
768 769
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index fa617e0719ab..0336575d2448 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -71,7 +71,7 @@ struct io_thread_req {
71 int error; 71 int error;
72}; 72};
73 73
74extern int open_ubd_file(char *file, struct openflags *openflags, 74extern int open_ubd_file(char *file, struct openflags *openflags, int shared,
75 char **backing_file_out, int *bitmap_offset_out, 75 char **backing_file_out, int *bitmap_offset_out,
76 unsigned long *bitmap_len_out, int *data_offset_out, 76 unsigned long *bitmap_len_out, int *data_offset_out,
77 int *create_cow_out); 77 int *create_cow_out);
@@ -137,7 +137,7 @@ static int fake_major = MAJOR_NR;
137 137
138static struct gendisk *ubd_gendisk[MAX_DEV]; 138static struct gendisk *ubd_gendisk[MAX_DEV];
139static struct gendisk *fake_gendisk[MAX_DEV]; 139static struct gendisk *fake_gendisk[MAX_DEV];
140 140
141#ifdef CONFIG_BLK_DEV_UBD_SYNC 141#ifdef CONFIG_BLK_DEV_UBD_SYNC
142#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \ 142#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
143 .cl = 1 }) 143 .cl = 1 })
@@ -168,6 +168,7 @@ struct ubd {
168 __u64 size; 168 __u64 size;
169 struct openflags boot_openflags; 169 struct openflags boot_openflags;
170 struct openflags openflags; 170 struct openflags openflags;
171 int shared;
171 int no_cow; 172 int no_cow;
172 struct cow cow; 173 struct cow cow;
173 struct platform_device pdev; 174 struct platform_device pdev;
@@ -189,6 +190,7 @@ struct ubd {
189 .boot_openflags = OPEN_FLAGS, \ 190 .boot_openflags = OPEN_FLAGS, \
190 .openflags = OPEN_FLAGS, \ 191 .openflags = OPEN_FLAGS, \
191 .no_cow = 0, \ 192 .no_cow = 0, \
193 .shared = 0, \
192 .cow = DEFAULT_COW, \ 194 .cow = DEFAULT_COW, \
193} 195}
194 196
@@ -305,7 +307,7 @@ static int ubd_setup_common(char *str, int *index_out)
305 } 307 }
306 major = simple_strtoul(str, &end, 0); 308 major = simple_strtoul(str, &end, 0);
307 if((*end != '\0') || (end == str)){ 309 if((*end != '\0') || (end == str)){
308 printk(KERN_ERR 310 printk(KERN_ERR
309 "ubd_setup : didn't parse major number\n"); 311 "ubd_setup : didn't parse major number\n");
310 return(1); 312 return(1);
311 } 313 }
@@ -316,7 +318,7 @@ static int ubd_setup_common(char *str, int *index_out)
316 printk(KERN_ERR "Can't assign a fake major twice\n"); 318 printk(KERN_ERR "Can't assign a fake major twice\n");
317 goto out1; 319 goto out1;
318 } 320 }
319 321
320 fake_major = major; 322 fake_major = major;
321 323
322 printk(KERN_INFO "Setting extra ubd major number to %d\n", 324 printk(KERN_INFO "Setting extra ubd major number to %d\n",
@@ -351,7 +353,7 @@ static int ubd_setup_common(char *str, int *index_out)
351 if (index_out) 353 if (index_out)
352 *index_out = n; 354 *index_out = n;
353 355
354 for (i = 0; i < 4; i++) { 356 for (i = 0; i < sizeof("rscd="); i++) {
355 switch (*str) { 357 switch (*str) {
356 case 'r': 358 case 'r':
357 flags.w = 0; 359 flags.w = 0;
@@ -362,11 +364,14 @@ static int ubd_setup_common(char *str, int *index_out)
362 case 'd': 364 case 'd':
363 dev->no_cow = 1; 365 dev->no_cow = 1;
364 break; 366 break;
367 case 'c':
368 dev->shared = 1;
369 break;
365 case '=': 370 case '=':
366 str++; 371 str++;
367 goto break_loop; 372 goto break_loop;
368 default: 373 default:
369 printk(KERN_ERR "ubd_setup : Expected '=' or flag letter (r,s or d)\n"); 374 printk(KERN_ERR "ubd_setup : Expected '=' or flag letter (r, s, c, or d)\n");
370 goto out; 375 goto out;
371 } 376 }
372 str++; 377 str++;
@@ -515,7 +520,7 @@ static void ubd_handler(void)
515 spin_unlock(&ubd_io_lock); 520 spin_unlock(&ubd_io_lock);
516 return; 521 return;
517 } 522 }
518 523
519 ubd_finish(rq, req.error); 524 ubd_finish(rq, req.error);
520 reactivate_fd(thread_fd, UBD_IRQ); 525 reactivate_fd(thread_fd, UBD_IRQ);
521 do_ubd_request(ubd_queue); 526 do_ubd_request(ubd_queue);
@@ -532,7 +537,7 @@ static int io_pid = -1;
532 537
533void kill_io_thread(void) 538void kill_io_thread(void)
534{ 539{
535 if(io_pid != -1) 540 if(io_pid != -1)
536 os_kill_process(io_pid, 1); 541 os_kill_process(io_pid, 1);
537} 542}
538 543
@@ -567,14 +572,15 @@ static int ubd_open_dev(struct ubd *dev)
567 create_cow = 0; 572 create_cow = 0;
568 create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL; 573 create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL;
569 back_ptr = dev->no_cow ? NULL : &dev->cow.file; 574 back_ptr = dev->no_cow ? NULL : &dev->cow.file;
570 dev->fd = open_ubd_file(dev->file, &dev->openflags, back_ptr, 575 dev->fd = open_ubd_file(dev->file, &dev->openflags, dev->shared,
571 &dev->cow.bitmap_offset, &dev->cow.bitmap_len, 576 back_ptr, &dev->cow.bitmap_offset,
572 &dev->cow.data_offset, create_ptr); 577 &dev->cow.bitmap_len, &dev->cow.data_offset,
578 create_ptr);
573 579
574 if((dev->fd == -ENOENT) && create_cow){ 580 if((dev->fd == -ENOENT) && create_cow){
575 dev->fd = create_cow_file(dev->file, dev->cow.file, 581 dev->fd = create_cow_file(dev->file, dev->cow.file,
576 dev->openflags, 1 << 9, PAGE_SIZE, 582 dev->openflags, 1 << 9, PAGE_SIZE,
577 &dev->cow.bitmap_offset, 583 &dev->cow.bitmap_offset,
578 &dev->cow.bitmap_len, 584 &dev->cow.bitmap_len,
579 &dev->cow.data_offset); 585 &dev->cow.data_offset);
580 if(dev->fd >= 0){ 586 if(dev->fd >= 0){
@@ -598,16 +604,16 @@ static int ubd_open_dev(struct ubd *dev)
598 } 604 }
599 flush_tlb_kernel_vm(); 605 flush_tlb_kernel_vm();
600 606
601 err = read_cow_bitmap(dev->fd, dev->cow.bitmap, 607 err = read_cow_bitmap(dev->fd, dev->cow.bitmap,
602 dev->cow.bitmap_offset, 608 dev->cow.bitmap_offset,
603 dev->cow.bitmap_len); 609 dev->cow.bitmap_len);
604 if(err < 0) 610 if(err < 0)
605 goto error; 611 goto error;
606 612
607 flags = dev->openflags; 613 flags = dev->openflags;
608 flags.w = 0; 614 flags.w = 0;
609 err = open_ubd_file(dev->cow.file, &flags, NULL, NULL, NULL, 615 err = open_ubd_file(dev->cow.file, &flags, dev->shared, NULL,
610 NULL, NULL); 616 NULL, NULL, NULL, NULL);
611 if(err < 0) goto error; 617 if(err < 0) goto error;
612 dev->cow.fd = err; 618 dev->cow.fd = err;
613 } 619 }
@@ -685,11 +691,11 @@ static int ubd_add(int n)
685 dev->size = ROUND_BLOCK(dev->size); 691 dev->size = ROUND_BLOCK(dev->size);
686 692
687 err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]); 693 err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]);
688 if(err) 694 if(err)
689 goto out_close; 695 goto out_close;
690 696
691 if(fake_major != MAJOR_NR) 697 if(fake_major != MAJOR_NR)
692 ubd_new_disk(fake_major, dev->size, n, 698 ubd_new_disk(fake_major, dev->size, n,
693 &fake_gendisk[n]); 699 &fake_gendisk[n]);
694 700
695 /* perhaps this should also be under the "if (fake_major)" above */ 701 /* perhaps this should also be under the "if (fake_major)" above */
@@ -854,7 +860,7 @@ int ubd_init(void)
854 return -1; 860 return -1;
855 } 861 }
856 platform_driver_register(&ubd_driver); 862 platform_driver_register(&ubd_driver);
857 for (i = 0; i < MAX_DEV; i++) 863 for (i = 0; i < MAX_DEV; i++)
858 ubd_add(i); 864 ubd_add(i);
859 return 0; 865 return 0;
860} 866}
@@ -872,16 +878,16 @@ int ubd_driver_init(void){
872 * enough. So use anyway the io thread. */ 878 * enough. So use anyway the io thread. */
873 } 879 }
874 stack = alloc_stack(0, 0); 880 stack = alloc_stack(0, 0);
875 io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *), 881 io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *),
876 &thread_fd); 882 &thread_fd);
877 if(io_pid < 0){ 883 if(io_pid < 0){
878 printk(KERN_ERR 884 printk(KERN_ERR
879 "ubd : Failed to start I/O thread (errno = %d) - " 885 "ubd : Failed to start I/O thread (errno = %d) - "
880 "falling back to synchronous I/O\n", -io_pid); 886 "falling back to synchronous I/O\n", -io_pid);
881 io_pid = -1; 887 io_pid = -1;
882 return(0); 888 return(0);
883 } 889 }
884 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, 890 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr,
885 SA_INTERRUPT, "ubd", ubd_dev); 891 SA_INTERRUPT, "ubd", ubd_dev);
886 if(err != 0) 892 if(err != 0)
887 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err); 893 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
@@ -978,7 +984,7 @@ static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
978 if(req->op == UBD_READ) { 984 if(req->op == UBD_READ) {
979 for(i = 0; i < req->length >> 9; i++){ 985 for(i = 0; i < req->length >> 9; i++){
980 if(ubd_test_bit(sector + i, (unsigned char *) bitmap)) 986 if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
981 ubd_set_bit(i, (unsigned char *) 987 ubd_set_bit(i, (unsigned char *)
982 &req->sector_mask); 988 &req->sector_mask);
983 } 989 }
984 } 990 }
@@ -999,7 +1005,7 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
999 1005
1000 /* This should be impossible now */ 1006 /* This should be impossible now */
1001 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ 1007 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
1002 printk("Write attempted on readonly ubd device %s\n", 1008 printk("Write attempted on readonly ubd device %s\n",
1003 disk->disk_name); 1009 disk->disk_name);
1004 end_request(req, 0); 1010 end_request(req, 0);
1005 return(1); 1011 return(1);
@@ -1182,7 +1188,7 @@ int read_cow_bitmap(int fd, void *buf, int offset, int len)
1182 return(0); 1188 return(0);
1183} 1189}
1184 1190
1185int open_ubd_file(char *file, struct openflags *openflags, 1191int open_ubd_file(char *file, struct openflags *openflags, int shared,
1186 char **backing_file_out, int *bitmap_offset_out, 1192 char **backing_file_out, int *bitmap_offset_out,
1187 unsigned long *bitmap_len_out, int *data_offset_out, 1193 unsigned long *bitmap_len_out, int *data_offset_out,
1188 int *create_cow_out) 1194 int *create_cow_out)
@@ -1206,10 +1212,14 @@ int open_ubd_file(char *file, struct openflags *openflags,
1206 return fd; 1212 return fd;
1207 } 1213 }
1208 1214
1209 err = os_lock_file(fd, openflags->w); 1215 if(shared)
1210 if(err < 0){ 1216 printk("Not locking \"%s\" on the host\n", file);
1211 printk("Failed to lock '%s', err = %d\n", file, -err); 1217 else {
1212 goto out_close; 1218 err = os_lock_file(fd, openflags->w);
1219 if(err < 0){
1220 printk("Failed to lock '%s', err = %d\n", file, -err);
1221 goto out_close;
1222 }
1213 } 1223 }
1214 1224
1215 /* Succesful return case! */ 1225 /* Succesful return case! */
@@ -1260,7 +1270,7 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
1260 int err, fd; 1270 int err, fd;
1261 1271
1262 flags.c = 1; 1272 flags.c = 1;
1263 fd = open_ubd_file(cow_file, &flags, NULL, NULL, NULL, NULL, NULL); 1273 fd = open_ubd_file(cow_file, &flags, 0, NULL, NULL, NULL, NULL, NULL);
1264 if(fd < 0){ 1274 if(fd < 0){
1265 err = fd; 1275 err = fd;
1266 printk("Open of COW file '%s' failed, errno = %d\n", cow_file, 1276 printk("Open of COW file '%s' failed, errno = %d\n", cow_file,
diff --git a/arch/um/include/irq_user.h b/arch/um/include/irq_user.h
index b61deb8b362a..69a93c804f0e 100644
--- a/arch/um/include/irq_user.h
+++ b/arch/um/include/irq_user.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -6,6 +6,17 @@
6#ifndef __IRQ_USER_H__ 6#ifndef __IRQ_USER_H__
7#define __IRQ_USER_H__ 7#define __IRQ_USER_H__
8 8
9struct irq_fd {
10 struct irq_fd *next;
11 void *id;
12 int fd;
13 int type;
14 int irq;
15 int pid;
16 int events;
17 int current_events;
18};
19
9enum { IRQ_READ, IRQ_WRITE }; 20enum { IRQ_READ, IRQ_WRITE };
10 21
11extern void sigio_handler(int sig, union uml_pt_regs *regs); 22extern void sigio_handler(int sig, union uml_pt_regs *regs);
@@ -16,8 +27,6 @@ extern void reactivate_fd(int fd, int irqnum);
16extern void deactivate_fd(int fd, int irqnum); 27extern void deactivate_fd(int fd, int irqnum);
17extern int deactivate_all_fds(void); 28extern int deactivate_all_fds(void);
18extern void forward_interrupts(int pid); 29extern void forward_interrupts(int pid);
19extern void init_irq_signals(int on_sigstack);
20extern void forward_ipi(int fd, int pid);
21extern int activate_ipi(int fd, int pid); 30extern int activate_ipi(int fd, int pid);
22extern unsigned long irq_lock(void); 31extern unsigned long irq_lock(void);
23extern void irq_unlock(unsigned long flags); 32extern void irq_unlock(unsigned long flags);
diff --git a/arch/um/include/kern.h b/arch/um/include/kern.h
index 7d223beccbc0..4ce3fc650e57 100644
--- a/arch/um/include/kern.h
+++ b/arch/um/include/kern.h
@@ -29,7 +29,7 @@ extern int getuid(void);
29extern int getgid(void); 29extern int getgid(void);
30extern int pause(void); 30extern int pause(void);
31extern int write(int, const void *, int); 31extern int write(int, const void *, int);
32extern int exit(int); 32extern void exit(int);
33extern int close(int); 33extern int close(int);
34extern int read(unsigned int, char *, int); 34extern int read(unsigned int, char *, int);
35extern int pipe(int *); 35extern int pipe(int *);
diff --git a/arch/um/include/misc_constants.h b/arch/um/include/misc_constants.h
new file mode 100644
index 000000000000..989bc08de36e
--- /dev/null
+++ b/arch/um/include/misc_constants.h
@@ -0,0 +1,6 @@
1#ifndef __MISC_CONSTANT_H_
2#define __MISC_CONSTANT_H_
3
4#include <user_constants.h>
5
6#endif
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 2a1c64d8d0bf..d3d1bc6074ef 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -12,6 +12,7 @@
12#include "sysdep/ptrace.h" 12#include "sysdep/ptrace.h"
13#include "kern_util.h" 13#include "kern_util.h"
14#include "skas/mm_id.h" 14#include "skas/mm_id.h"
15#include "irq_user.h"
15 16
16#define OS_TYPE_FILE 1 17#define OS_TYPE_FILE 1
17#define OS_TYPE_DIR 2 18#define OS_TYPE_DIR 2
@@ -121,6 +122,7 @@ static inline struct openflags of_cloexec(struct openflags flags)
121 return(flags); 122 return(flags);
122} 123}
123 124
125/* file.c */
124extern int os_stat_file(const char *file_name, struct uml_stat *buf); 126extern int os_stat_file(const char *file_name, struct uml_stat *buf);
125extern int os_stat_fd(const int fd, struct uml_stat *buf); 127extern int os_stat_fd(const int fd, struct uml_stat *buf);
126extern int os_access(const char *file, int mode); 128extern int os_access(const char *file, int mode);
@@ -156,10 +158,20 @@ extern int os_connect_socket(char *name);
156extern int os_file_type(char *file); 158extern int os_file_type(char *file);
157extern int os_file_mode(char *file, struct openflags *mode_out); 159extern int os_file_mode(char *file, struct openflags *mode_out);
158extern int os_lock_file(int fd, int excl); 160extern int os_lock_file(int fd, int excl);
161extern void os_flush_stdout(void);
162extern int os_stat_filesystem(char *path, long *bsize_out,
163 long long *blocks_out, long long *bfree_out,
164 long long *bavail_out, long long *files_out,
165 long long *ffree_out, void *fsid_out,
166 int fsid_size, long *namelen_out,
167 long *spare_out);
168extern int os_change_dir(char *dir);
169extern int os_fchange_dir(int fd);
159 170
160/* start_up.c */ 171/* start_up.c */
161extern void os_early_checks(void); 172extern void os_early_checks(void);
162extern int can_do_skas(void); 173extern int can_do_skas(void);
174extern void os_check_bugs(void);
163 175
164/* Make sure they are clear when running in TT mode. Required by 176/* Make sure they are clear when running in TT mode. Required by
165 * SEGV_MAYBE_FIXABLE */ 177 * SEGV_MAYBE_FIXABLE */
@@ -198,6 +210,8 @@ extern void os_flush_stdout(void);
198/* tt.c 210/* tt.c
199 * for tt mode only (will be deleted in future...) 211 * for tt mode only (will be deleted in future...)
200 */ 212 */
213extern void forward_ipi(int fd, int pid);
214extern void kill_child_dead(int pid);
201extern void stop(void); 215extern void stop(void);
202extern int wait_for_stop(int pid, int sig, int cont_type, void *relay); 216extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
203extern int protect_memory(unsigned long addr, unsigned long len, 217extern int protect_memory(unsigned long addr, unsigned long len,
@@ -294,4 +308,26 @@ extern void initial_thread_cb_skas(void (*proc)(void *),
294extern void halt_skas(void); 308extern void halt_skas(void);
295extern void reboot_skas(void); 309extern void reboot_skas(void);
296 310
311/* irq.c */
312extern int os_waiting_for_events(struct irq_fd *active_fds);
313extern int os_isatty(int fd);
314extern int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds);
315extern void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
316 struct irq_fd *active_fds, struct irq_fd ***last_irq_ptr2);
317extern void os_free_irq_later(struct irq_fd *active_fds,
318 int irq, void *dev_id);
319extern int os_get_pollfd(int i);
320extern void os_set_pollfd(int i, int fd);
321extern void os_set_ioignore(void);
322extern void init_irq_signals(int on_sigstack);
323
324/* sigio.c */
325extern void write_sigio_workaround(void);
326extern int add_sigio_fd(int fd, int read);
327extern int ignore_sigio_fd(int fd);
328
329/* skas/trap */
330extern void sig_handler_common_skas(int sig, void *sc_ptr);
331extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
332
297#endif 333#endif
diff --git a/arch/um/include/sigio.h b/arch/um/include/sigio.h
index 37d76e29a147..fe99ea163c2e 100644
--- a/arch/um/include/sigio.h
+++ b/arch/um/include/sigio.h
@@ -8,9 +8,6 @@
8 8
9extern int write_sigio_irq(int fd); 9extern int write_sigio_irq(int fd);
10extern int register_sigio_fd(int fd); 10extern int register_sigio_fd(int fd);
11extern int read_sigio_fd(int fd);
12extern int add_sigio_fd(int fd, int read);
13extern int ignore_sigio_fd(int fd);
14extern void sigio_lock(void); 11extern void sigio_lock(void);
15extern void sigio_unlock(void); 12extern void sigio_unlock(void);
16 13
diff --git a/arch/um/include/skas/mode-skas.h b/arch/um/include/skas/mode-skas.h
index 260065cfeef1..8bc6916bbbb1 100644
--- a/arch/um/include/skas/mode-skas.h
+++ b/arch/um/include/skas/mode-skas.h
@@ -13,7 +13,6 @@ extern unsigned long exec_fp_regs[];
13extern unsigned long exec_fpx_regs[]; 13extern unsigned long exec_fpx_regs[];
14extern int have_fpx_regs; 14extern int have_fpx_regs;
15 15
16extern void sig_handler_common_skas(int sig, void *sc_ptr);
17extern void kill_off_processes_skas(void); 16extern void kill_off_processes_skas(void);
18 17
19#endif 18#endif
diff --git a/arch/um/include/skas/skas.h b/arch/um/include/skas/skas.h
index 86357282d681..853b26f148c5 100644
--- a/arch/um/include/skas/skas.h
+++ b/arch/um/include/skas/skas.h
@@ -17,7 +17,6 @@ extern int user_thread(unsigned long stack, int flags);
17extern void new_thread_proc(void *stack, void (*handler)(int sig)); 17extern void new_thread_proc(void *stack, void (*handler)(int sig));
18extern void new_thread_handler(int sig); 18extern void new_thread_handler(int sig);
19extern void handle_syscall(union uml_pt_regs *regs); 19extern void handle_syscall(union uml_pt_regs *regs);
20extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
21extern int new_mm(unsigned long stack); 20extern int new_mm(unsigned long stack);
22extern void get_skas_faultinfo(int pid, struct faultinfo * fi); 21extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
23extern long execute_syscall_skas(void *r); 22extern long execute_syscall_skas(void *r);
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h
index a6f1f176cf84..992a7e1e0fca 100644
--- a/arch/um/include/user_util.h
+++ b/arch/um/include/user_util.h
@@ -58,7 +58,6 @@ extern int attach(int pid);
58extern void kill_child_dead(int pid); 58extern void kill_child_dead(int pid);
59extern int cont(int pid); 59extern int cont(int pid);
60extern void check_sigio(void); 60extern void check_sigio(void);
61extern void write_sigio_workaround(void);
62extern void arch_check_bugs(void); 61extern void arch_check_bugs(void);
63extern int cpu_feature(char *what, char *buf, int len); 62extern int cpu_feature(char *what, char *buf, int len);
64extern int arch_handle_signal(int sig, union uml_pt_regs *regs); 63extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index 693018ba80f1..fe08971b64cf 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -7,23 +7,20 @@ extra-y := vmlinux.lds
7clean-files := 7clean-files :=
8 8
9obj-y = config.o exec_kern.o exitcode.o \ 9obj-y = config.o exec_kern.o exitcode.o \
10 init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ 10 init_task.o irq.o ksyms.o mem.o physmem.o \
11 process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ 11 process_kern.o ptrace.o reboot.o resource.o sigio_kern.o \
12 signal_kern.o smp.o syscall_kern.o sysrq.o \ 12 signal_kern.o smp.o syscall_kern.o sysrq.o \
13 time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o 13 time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o
14 14
15obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 15obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
16obj-$(CONFIG_GPROF) += gprof_syms.o 16obj-$(CONFIG_GPROF) += gprof_syms.o
17obj-$(CONFIG_GCOV) += gmon_syms.o 17obj-$(CONFIG_GCOV) += gmon_syms.o
18obj-$(CONFIG_TTY_LOG) += tty_log.o
19obj-$(CONFIG_SYSCALL_DEBUG) += syscall.o 18obj-$(CONFIG_SYSCALL_DEBUG) += syscall.o
20 19
21obj-$(CONFIG_MODE_TT) += tt/ 20obj-$(CONFIG_MODE_TT) += tt/
22obj-$(CONFIG_MODE_SKAS) += skas/ 21obj-$(CONFIG_MODE_SKAS) += skas/
23 22
24user-objs-$(CONFIG_TTY_LOG) += tty_log.o 23USER_OBJS := config.o
25
26USER_OBJS := $(user-objs-y) config.o tty_log.o
27 24
28include arch/um/scripts/Makefile.rules 25include arch/um/scripts/Makefile.rules
29 26
diff --git a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec_kern.c
index c264e1c05ab3..1ca84319317d 100644
--- a/arch/um/kernel/exec_kern.c
+++ b/arch/um/kernel/exec_kern.c
@@ -30,8 +30,6 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
30 CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp); 30 CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
31} 31}
32 32
33extern void log_exec(char **argv, void *tty);
34
35static long execve1(char *file, char __user * __user *argv, 33static long execve1(char *file, char __user * __user *argv,
36 char __user *__user *env) 34 char __user *__user *env)
37{ 35{
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index bbf94bf2921e..c39ea3abeda4 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -31,6 +31,8 @@
31#include "irq_user.h" 31#include "irq_user.h"
32#include "irq_kern.h" 32#include "irq_kern.h"
33#include "os.h" 33#include "os.h"
34#include "sigio.h"
35#include "misc_constants.h"
34 36
35/* 37/*
36 * Generic, controller-independent functions: 38 * Generic, controller-independent functions:
@@ -77,6 +79,298 @@ skip:
77 return 0; 79 return 0;
78} 80}
79 81
82struct irq_fd *active_fds = NULL;
83static struct irq_fd **last_irq_ptr = &active_fds;
84
85extern void free_irqs(void);
86
87void sigio_handler(int sig, union uml_pt_regs *regs)
88{
89 struct irq_fd *irq_fd;
90 int n;
91
92 if(smp_sigio_handler()) return;
93 while(1){
94 n = os_waiting_for_events(active_fds);
95 if (n <= 0) {
96 if(n == -EINTR) continue;
97 else break;
98 }
99
100 for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){
101 if(irq_fd->current_events != 0){
102 irq_fd->current_events = 0;
103 do_IRQ(irq_fd->irq, regs);
104 }
105 }
106 }
107
108 free_irqs();
109}
110
111static void maybe_sigio_broken(int fd, int type)
112{
113 if(os_isatty(fd)){
114 if((type == IRQ_WRITE) && !pty_output_sigio){
115 write_sigio_workaround();
116 add_sigio_fd(fd, 0);
117 }
118 else if((type == IRQ_READ) && !pty_close_sigio){
119 write_sigio_workaround();
120 add_sigio_fd(fd, 1);
121 }
122 }
123}
124
125
126int activate_fd(int irq, int fd, int type, void *dev_id)
127{
128 struct pollfd *tmp_pfd;
129 struct irq_fd *new_fd, *irq_fd;
130 unsigned long flags;
131 int pid, events, err, n;
132
133 pid = os_getpid();
134 err = os_set_fd_async(fd, pid);
135 if(err < 0)
136 goto out;
137
138 new_fd = um_kmalloc(sizeof(*new_fd));
139 err = -ENOMEM;
140 if(new_fd == NULL)
141 goto out;
142
143 if(type == IRQ_READ) events = UM_POLLIN | UM_POLLPRI;
144 else events = UM_POLLOUT;
145 *new_fd = ((struct irq_fd) { .next = NULL,
146 .id = dev_id,
147 .fd = fd,
148 .type = type,
149 .irq = irq,
150 .pid = pid,
151 .events = events,
152 .current_events = 0 } );
153
154 /* Critical section - locked by a spinlock because this stuff can
155 * be changed from interrupt handlers. The stuff above is done
156 * outside the lock because it allocates memory.
157 */
158
159 /* Actually, it only looks like it can be called from interrupt
160 * context. The culprit is reactivate_fd, which calls
161 * maybe_sigio_broken, which calls write_sigio_workaround,
162 * which calls activate_fd. However, write_sigio_workaround should
163 * only be called once, at boot time. That would make it clear that
164 * this is called only from process context, and can be locked with
165 * a semaphore.
166 */
167 flags = irq_lock();
168 for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){
169 if((irq_fd->fd == fd) && (irq_fd->type == type)){
170 printk("Registering fd %d twice\n", fd);
171 printk("Irqs : %d, %d\n", irq_fd->irq, irq);
172 printk("Ids : 0x%p, 0x%p\n", irq_fd->id, dev_id);
173 goto out_unlock;
174 }
175 }
176
177 /*-------------*/
178 if(type == IRQ_WRITE)
179 fd = -1;
180
181 tmp_pfd = NULL;
182 n = 0;
183
184 while(1){
185 n = os_create_pollfd(fd, events, tmp_pfd, n);
186 if (n == 0)
187 break;
188
189 /* n > 0
190 * It means we couldn't put new pollfd to current pollfds
191 * and tmp_fds is NULL or too small for new pollfds array.
192 * Needed size is equal to n as minimum.
193 *
194 * Here we have to drop the lock in order to call
195 * kmalloc, which might sleep.
196 * If something else came in and changed the pollfds array
197 * so we will not be able to put new pollfd struct to pollfds
198 * then we free the buffer tmp_fds and try again.
199 */
200 irq_unlock(flags);
201 if (tmp_pfd != NULL) {
202 kfree(tmp_pfd);
203 tmp_pfd = NULL;
204 }
205
206 tmp_pfd = um_kmalloc(n);
207 if (tmp_pfd == NULL)
208 goto out_kfree;
209
210 flags = irq_lock();
211 }
212 /*-------------*/
213
214 *last_irq_ptr = new_fd;
215 last_irq_ptr = &new_fd->next;
216
217 irq_unlock(flags);
218
219 /* This calls activate_fd, so it has to be outside the critical
220 * section.
221 */
222 maybe_sigio_broken(fd, type);
223
224 return(0);
225
226 out_unlock:
227 irq_unlock(flags);
228 out_kfree:
229 kfree(new_fd);
230 out:
231 return(err);
232}
233
234static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
235{
236 unsigned long flags;
237
238 flags = irq_lock();
239 os_free_irq_by_cb(test, arg, active_fds, &last_irq_ptr);
240 irq_unlock(flags);
241}
242
243struct irq_and_dev {
244 int irq;
245 void *dev;
246};
247
248static int same_irq_and_dev(struct irq_fd *irq, void *d)
249{
250 struct irq_and_dev *data = d;
251
252 return((irq->irq == data->irq) && (irq->id == data->dev));
253}
254
255void free_irq_by_irq_and_dev(unsigned int irq, void *dev)
256{
257 struct irq_and_dev data = ((struct irq_and_dev) { .irq = irq,
258 .dev = dev });
259
260 free_irq_by_cb(same_irq_and_dev, &data);
261}
262
263static int same_fd(struct irq_fd *irq, void *fd)
264{
265 return(irq->fd == *((int *) fd));
266}
267
268void free_irq_by_fd(int fd)
269{
270 free_irq_by_cb(same_fd, &fd);
271}
272
273static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
274{
275 struct irq_fd *irq;
276 int i = 0;
277 int fdi;
278
279 for(irq=active_fds; irq != NULL; irq = irq->next){
280 if((irq->fd == fd) && (irq->irq == irqnum)) break;
281 i++;
282 }
283 if(irq == NULL){
284 printk("find_irq_by_fd doesn't have descriptor %d\n", fd);
285 goto out;
286 }
287 fdi = os_get_pollfd(i);
288 if((fdi != -1) && (fdi != fd)){
289 printk("find_irq_by_fd - mismatch between active_fds and "
290 "pollfds, fd %d vs %d, need %d\n", irq->fd,
291 fdi, fd);
292 irq = NULL;
293 goto out;
294 }
295 *index_out = i;
296 out:
297 return(irq);
298}
299
300void reactivate_fd(int fd, int irqnum)
301{
302 struct irq_fd *irq;
303 unsigned long flags;
304 int i;
305
306 flags = irq_lock();
307 irq = find_irq_by_fd(fd, irqnum, &i);
308 if(irq == NULL){
309 irq_unlock(flags);
310 return;
311 }
312 os_set_pollfd(i, irq->fd);
313 irq_unlock(flags);
314
315 /* This calls activate_fd, so it has to be outside the critical
316 * section.
317 */
318 maybe_sigio_broken(fd, irq->type);
319}
320
321void deactivate_fd(int fd, int irqnum)
322{
323 struct irq_fd *irq;
324 unsigned long flags;
325 int i;
326
327 flags = irq_lock();
328 irq = find_irq_by_fd(fd, irqnum, &i);
329 if(irq == NULL)
330 goto out;
331 os_set_pollfd(i, -1);
332 out:
333 irq_unlock(flags);
334}
335
336int deactivate_all_fds(void)
337{
338 struct irq_fd *irq;
339 int err;
340
341 for(irq=active_fds;irq != NULL;irq = irq->next){
342 err = os_clear_fd_async(irq->fd);
343 if(err)
344 return(err);
345 }
346 /* If there is a signal already queued, after unblocking ignore it */
347 os_set_ioignore();
348
349 return(0);
350}
351
352void forward_interrupts(int pid)
353{
354 struct irq_fd *irq;
355 unsigned long flags;
356 int err;
357
358 flags = irq_lock();
359 for(irq=active_fds;irq != NULL;irq = irq->next){
360 err = os_set_owner(irq->fd, pid);
361 if(err < 0){
362 /* XXX Just remove the irq rather than
363 * print out an infinite stream of these
364 */
365 printk("Failed to forward %d to pid %d, err = %d\n",
366 irq->fd, pid, -err);
367 }
368
369 irq->pid = pid;
370 }
371 irq_unlock(flags);
372}
373
80/* 374/*
81 * do_IRQ handles all normal device IRQ's (the special 375 * do_IRQ handles all normal device IRQ's (the special
82 * SMP cross-CPU interrupts have their own specific 376 * SMP cross-CPU interrupts have their own specific
diff --git a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c
deleted file mode 100644
index 0e32f5f4a887..000000000000
--- a/arch/um/kernel/irq_user.c
+++ /dev/null
@@ -1,412 +0,0 @@
1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <stdlib.h>
7#include <unistd.h>
8#include <errno.h>
9#include <signal.h>
10#include <string.h>
11#include <sys/poll.h>
12#include <sys/types.h>
13#include <sys/time.h>
14#include "user_util.h"
15#include "kern_util.h"
16#include "user.h"
17#include "process.h"
18#include "sigio.h"
19#include "irq_user.h"
20#include "os.h"
21
22struct irq_fd {
23 struct irq_fd *next;
24 void *id;
25 int fd;
26 int type;
27 int irq;
28 int pid;
29 int events;
30 int current_events;
31};
32
33static struct irq_fd *active_fds = NULL;
34static struct irq_fd **last_irq_ptr = &active_fds;
35
36static struct pollfd *pollfds = NULL;
37static int pollfds_num = 0;
38static int pollfds_size = 0;
39
40extern int io_count, intr_count;
41
42extern void free_irqs(void);
43
44void sigio_handler(int sig, union uml_pt_regs *regs)
45{
46 struct irq_fd *irq_fd;
47 int i, n;
48
49 if(smp_sigio_handler()) return;
50 while(1){
51 n = poll(pollfds, pollfds_num, 0);
52 if(n < 0){
53 if(errno == EINTR) continue;
54 printk("sigio_handler : poll returned %d, "
55 "errno = %d\n", n, errno);
56 break;
57 }
58 if(n == 0) break;
59
60 irq_fd = active_fds;
61 for(i = 0; i < pollfds_num; i++){
62 if(pollfds[i].revents != 0){
63 irq_fd->current_events = pollfds[i].revents;
64 pollfds[i].fd = -1;
65 }
66 irq_fd = irq_fd->next;
67 }
68
69 for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){
70 if(irq_fd->current_events != 0){
71 irq_fd->current_events = 0;
72 do_IRQ(irq_fd->irq, regs);
73 }
74 }
75 }
76
77 free_irqs();
78}
79
80int activate_ipi(int fd, int pid)
81{
82 return(os_set_fd_async(fd, pid));
83}
84
85static void maybe_sigio_broken(int fd, int type)
86{
87 if(isatty(fd)){
88 if((type == IRQ_WRITE) && !pty_output_sigio){
89 write_sigio_workaround();
90 add_sigio_fd(fd, 0);
91 }
92 else if((type == IRQ_READ) && !pty_close_sigio){
93 write_sigio_workaround();
94 add_sigio_fd(fd, 1);
95 }
96 }
97}
98
99int activate_fd(int irq, int fd, int type, void *dev_id)
100{
101 struct pollfd *tmp_pfd;
102 struct irq_fd *new_fd, *irq_fd;
103 unsigned long flags;
104 int pid, events, err, n, size;
105
106 pid = os_getpid();
107 err = os_set_fd_async(fd, pid);
108 if(err < 0)
109 goto out;
110
111 new_fd = um_kmalloc(sizeof(*new_fd));
112 err = -ENOMEM;
113 if(new_fd == NULL)
114 goto out;
115
116 if(type == IRQ_READ) events = POLLIN | POLLPRI;
117 else events = POLLOUT;
118 *new_fd = ((struct irq_fd) { .next = NULL,
119 .id = dev_id,
120 .fd = fd,
121 .type = type,
122 .irq = irq,
123 .pid = pid,
124 .events = events,
125 .current_events = 0 } );
126
127 /* Critical section - locked by a spinlock because this stuff can
128 * be changed from interrupt handlers. The stuff above is done
129 * outside the lock because it allocates memory.
130 */
131
132 /* Actually, it only looks like it can be called from interrupt
133 * context. The culprit is reactivate_fd, which calls
134 * maybe_sigio_broken, which calls write_sigio_workaround,
135 * which calls activate_fd. However, write_sigio_workaround should
136 * only be called once, at boot time. That would make it clear that
137 * this is called only from process context, and can be locked with
138 * a semaphore.
139 */
140 flags = irq_lock();
141 for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){
142 if((irq_fd->fd == fd) && (irq_fd->type == type)){
143 printk("Registering fd %d twice\n", fd);
144 printk("Irqs : %d, %d\n", irq_fd->irq, irq);
145 printk("Ids : 0x%x, 0x%x\n", irq_fd->id, dev_id);
146 goto out_unlock;
147 }
148 }
149
150 n = pollfds_num;
151 if(n == pollfds_size){
152 while(1){
153 /* Here we have to drop the lock in order to call
154 * kmalloc, which might sleep. If something else
155 * came in and changed the pollfds array, we free
156 * the buffer and try again.
157 */
158 irq_unlock(flags);
159 size = (pollfds_num + 1) * sizeof(pollfds[0]);
160 tmp_pfd = um_kmalloc(size);
161 flags = irq_lock();
162 if(tmp_pfd == NULL)
163 goto out_unlock;
164 if(n == pollfds_size)
165 break;
166 kfree(tmp_pfd);
167 }
168 if(pollfds != NULL){
169 memcpy(tmp_pfd, pollfds,
170 sizeof(pollfds[0]) * pollfds_size);
171 kfree(pollfds);
172 }
173 pollfds = tmp_pfd;
174 pollfds_size++;
175 }
176
177 if(type == IRQ_WRITE)
178 fd = -1;
179
180 pollfds[pollfds_num] = ((struct pollfd) { .fd = fd,
181 .events = events,
182 .revents = 0 });
183 pollfds_num++;
184
185 *last_irq_ptr = new_fd;
186 last_irq_ptr = &new_fd->next;
187
188 irq_unlock(flags);
189
190 /* This calls activate_fd, so it has to be outside the critical
191 * section.
192 */
193 maybe_sigio_broken(fd, type);
194
195 return(0);
196
197 out_unlock:
198 irq_unlock(flags);
199 kfree(new_fd);
200 out:
201 return(err);
202}
203
204static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
205{
206 struct irq_fd **prev;
207 unsigned long flags;
208 int i = 0;
209
210 flags = irq_lock();
211 prev = &active_fds;
212 while(*prev != NULL){
213 if((*test)(*prev, arg)){
214 struct irq_fd *old_fd = *prev;
215 if((pollfds[i].fd != -1) &&
216 (pollfds[i].fd != (*prev)->fd)){
217 printk("free_irq_by_cb - mismatch between "
218 "active_fds and pollfds, fd %d vs %d\n",
219 (*prev)->fd, pollfds[i].fd);
220 goto out;
221 }
222
223 pollfds_num--;
224
225 /* This moves the *whole* array after pollfds[i] (though
226 * it doesn't spot as such)! */
227
228 memmove(&pollfds[i], &pollfds[i + 1],
229 (pollfds_num - i) * sizeof(pollfds[0]));
230
231 if(last_irq_ptr == &old_fd->next)
232 last_irq_ptr = prev;
233 *prev = (*prev)->next;
234 if(old_fd->type == IRQ_WRITE)
235 ignore_sigio_fd(old_fd->fd);
236 kfree(old_fd);
237 continue;
238 }
239 prev = &(*prev)->next;
240 i++;
241 }
242 out:
243 irq_unlock(flags);
244}
245
246struct irq_and_dev {
247 int irq;
248 void *dev;
249};
250
251static int same_irq_and_dev(struct irq_fd *irq, void *d)
252{
253 struct irq_and_dev *data = d;
254
255 return((irq->irq == data->irq) && (irq->id == data->dev));
256}
257
258void free_irq_by_irq_and_dev(unsigned int irq, void *dev)
259{
260 struct irq_and_dev data = ((struct irq_and_dev) { .irq = irq,
261 .dev = dev });
262
263 free_irq_by_cb(same_irq_and_dev, &data);
264}
265
266static int same_fd(struct irq_fd *irq, void *fd)
267{
268 return(irq->fd == *((int *) fd));
269}
270
271void free_irq_by_fd(int fd)
272{
273 free_irq_by_cb(same_fd, &fd);
274}
275
276static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
277{
278 struct irq_fd *irq;
279 int i = 0;
280
281 for(irq=active_fds; irq != NULL; irq = irq->next){
282 if((irq->fd == fd) && (irq->irq == irqnum)) break;
283 i++;
284 }
285 if(irq == NULL){
286 printk("find_irq_by_fd doesn't have descriptor %d\n", fd);
287 goto out;
288 }
289 if((pollfds[i].fd != -1) && (pollfds[i].fd != fd)){
290 printk("find_irq_by_fd - mismatch between active_fds and "
291 "pollfds, fd %d vs %d, need %d\n", irq->fd,
292 pollfds[i].fd, fd);
293 irq = NULL;
294 goto out;
295 }
296 *index_out = i;
297 out:
298 return(irq);
299}
300
301void reactivate_fd(int fd, int irqnum)
302{
303 struct irq_fd *irq;
304 unsigned long flags;
305 int i;
306
307 flags = irq_lock();
308 irq = find_irq_by_fd(fd, irqnum, &i);
309 if(irq == NULL){
310 irq_unlock(flags);
311 return;
312 }
313
314 pollfds[i].fd = irq->fd;
315
316 irq_unlock(flags);
317
318 /* This calls activate_fd, so it has to be outside the critical
319 * section.
320 */
321 maybe_sigio_broken(fd, irq->type);
322}
323
324void deactivate_fd(int fd, int irqnum)
325{
326 struct irq_fd *irq;
327 unsigned long flags;
328 int i;
329
330 flags = irq_lock();
331 irq = find_irq_by_fd(fd, irqnum, &i);
332 if(irq == NULL)
333 goto out;
334 pollfds[i].fd = -1;
335 out:
336 irq_unlock(flags);
337}
338
339int deactivate_all_fds(void)
340{
341 struct irq_fd *irq;
342 int err;
343
344 for(irq=active_fds;irq != NULL;irq = irq->next){
345 err = os_clear_fd_async(irq->fd);
346 if(err)
347 return(err);
348 }
349 /* If there is a signal already queued, after unblocking ignore it */
350 set_handler(SIGIO, SIG_IGN, 0, -1);
351
352 return(0);
353}
354
355void forward_ipi(int fd, int pid)
356{
357 int err;
358
359 err = os_set_owner(fd, pid);
360 if(err < 0)
361 printk("forward_ipi: set_owner failed, fd = %d, me = %d, "
362 "target = %d, err = %d\n", fd, os_getpid(), pid, -err);
363}
364
365void forward_interrupts(int pid)
366{
367 struct irq_fd *irq;
368 unsigned long flags;
369 int err;
370
371 flags = irq_lock();
372 for(irq=active_fds;irq != NULL;irq = irq->next){
373 err = os_set_owner(irq->fd, pid);
374 if(err < 0){
375 /* XXX Just remove the irq rather than
376 * print out an infinite stream of these
377 */
378 printk("Failed to forward %d to pid %d, err = %d\n",
379 irq->fd, pid, -err);
380 }
381
382 irq->pid = pid;
383 }
384 irq_unlock(flags);
385}
386
387void init_irq_signals(int on_sigstack)
388{
389 __sighandler_t h;
390 int flags;
391
392 flags = on_sigstack ? SA_ONSTACK : 0;
393 if(timer_irq_inited) h = (__sighandler_t) alarm_handler;
394 else h = boot_timer_handler;
395
396 set_handler(SIGVTALRM, h, flags | SA_RESTART,
397 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
398 set_handler(SIGIO, (__sighandler_t) sig_handler, flags | SA_RESTART,
399 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
400 signal(SIGWINCH, SIG_IGN);
401}
402
403/*
404 * Overrides for Emacs so that we follow Linus's tabbing style.
405 * Emacs will notice this stuff at the end of the file and automatically
406 * adjust the settings for this buffer only. This must remain at the end
407 * of the file.
408 * ---------------------------------------------------------------------------
409 * Local variables:
410 * c-file-style: "linux"
411 * End:
412 */
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index 0e65340eee33..0500800df1c1 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -9,6 +9,7 @@
9#include "linux/vmalloc.h" 9#include "linux/vmalloc.h"
10#include "linux/bootmem.h" 10#include "linux/bootmem.h"
11#include "linux/module.h" 11#include "linux/module.h"
12#include "linux/pfn.h"
12#include "asm/types.h" 13#include "asm/types.h"
13#include "asm/pgtable.h" 14#include "asm/pgtable.h"
14#include "kern_util.h" 15#include "kern_util.h"
@@ -316,8 +317,6 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
316 } 317 }
317} 318}
318 319
319#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
320
321extern int __syscall_stub_start, __binary_start; 320extern int __syscall_stub_start, __binary_start;
322 321
323void setup_physmem(unsigned long start, unsigned long reserve_end, 322void setup_physmem(unsigned long start, unsigned long reserve_end,
diff --git a/arch/um/kernel/sigio_kern.c b/arch/um/kernel/sigio_kern.c
index 229988463c4c..1c1300fb1e95 100644
--- a/arch/um/kernel/sigio_kern.c
+++ b/arch/um/kernel/sigio_kern.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -12,13 +12,16 @@
12#include "sigio.h" 12#include "sigio.h"
13#include "irq_user.h" 13#include "irq_user.h"
14#include "irq_kern.h" 14#include "irq_kern.h"
15#include "os.h"
15 16
16/* Protected by sigio_lock() called from write_sigio_workaround */ 17/* Protected by sigio_lock() called from write_sigio_workaround */
17static int sigio_irq_fd = -1; 18static int sigio_irq_fd = -1;
18 19
19static irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused) 20static irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
20{ 21{
21 read_sigio_fd(sigio_irq_fd); 22 char c;
23
24 os_read_file(sigio_irq_fd, &c, sizeof(c));
22 reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ); 25 reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
23 return(IRQ_HANDLED); 26 return(IRQ_HANDLED);
24} 27}
@@ -51,6 +54,9 @@ void sigio_unlock(void)
51 spin_unlock(&sigio_spinlock); 54 spin_unlock(&sigio_spinlock);
52} 55}
53 56
57extern void sigio_cleanup(void);
58__uml_exitcall(sigio_cleanup);
59
54/* 60/*
55 * Overrides for Emacs so that we follow Linus's tabbing style. 61 * Overrides for Emacs so that we follow Linus's tabbing style.
56 * Emacs will notice this stuff at the end of the file and automatically 62 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c
index 72113b0a96e7..c8d8d0ac1a7f 100644
--- a/arch/um/kernel/smp.c
+++ b/arch/um/kernel/smp.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -77,9 +77,9 @@ static int idle_proc(void *cpup)
77 if(err < 0) 77 if(err < 0)
78 panic("CPU#%d failed to create IPI pipe, err = %d", cpu, -err); 78 panic("CPU#%d failed to create IPI pipe, err = %d", cpu, -err);
79 79
80 activate_ipi(cpu_data[cpu].ipi_pipe[0], 80 os_set_fd_async(cpu_data[cpu].ipi_pipe[0],
81 current->thread.mode.tt.extern_pid); 81 current->thread.mode.tt.extern_pid);
82 82
83 wmb(); 83 wmb();
84 if (cpu_test_and_set(cpu, cpu_callin_map)) { 84 if (cpu_test_and_set(cpu, cpu_callin_map)) {
85 printk("huh, CPU#%d already present??\n", cpu); 85 printk("huh, CPU#%d already present??\n", cpu);
@@ -106,7 +106,7 @@ static struct task_struct *idle_thread(int cpu)
106 panic("copy_process failed in idle_thread, error = %ld", 106 panic("copy_process failed in idle_thread, error = %ld",
107 PTR_ERR(new_task)); 107 PTR_ERR(new_task));
108 108
109 cpu_tasks[cpu] = ((struct cpu_task) 109 cpu_tasks[cpu] = ((struct cpu_task)
110 { .pid = new_task->thread.mode.tt.extern_pid, 110 { .pid = new_task->thread.mode.tt.extern_pid,
111 .task = new_task } ); 111 .task = new_task } );
112 idle_threads[cpu] = new_task; 112 idle_threads[cpu] = new_task;
@@ -134,12 +134,12 @@ void smp_prepare_cpus(unsigned int maxcpus)
134 if(err < 0) 134 if(err < 0)
135 panic("CPU#0 failed to create IPI pipe, errno = %d", -err); 135 panic("CPU#0 failed to create IPI pipe, errno = %d", -err);
136 136
137 activate_ipi(cpu_data[me].ipi_pipe[0], 137 os_set_fd_async(cpu_data[me].ipi_pipe[0],
138 current->thread.mode.tt.extern_pid); 138 current->thread.mode.tt.extern_pid);
139 139
140 for(cpu = 1; cpu < ncpus; cpu++){ 140 for(cpu = 1; cpu < ncpus; cpu++){
141 printk("Booting processor %d...\n", cpu); 141 printk("Booting processor %d...\n", cpu);
142 142
143 idle = idle_thread(cpu); 143 idle = idle_thread(cpu);
144 144
145 init_idle(idle, cpu); 145 init_idle(idle, cpu);
@@ -223,7 +223,7 @@ void smp_call_function_slave(int cpu)
223 atomic_inc(&scf_finished); 223 atomic_inc(&scf_finished);
224} 224}
225 225
226int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic, 226int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic,
227 int wait) 227 int wait)
228{ 228{
229 int cpus = num_online_cpus() - 1; 229 int cpus = num_online_cpus() - 1;
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 80c9c18aae94..7d51dd7201c3 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -421,7 +421,7 @@ int linux_main(int argc, char **argv)
421#ifndef CONFIG_HIGHMEM 421#ifndef CONFIG_HIGHMEM
422 highmem = 0; 422 highmem = 0;
423 printf("CONFIG_HIGHMEM not enabled - physical memory shrunk " 423 printf("CONFIG_HIGHMEM not enabled - physical memory shrunk "
424 "to %lu bytes\n", physmem_size); 424 "to %Lu bytes\n", physmem_size);
425#endif 425#endif
426 } 426 }
427 427
@@ -433,8 +433,8 @@ int linux_main(int argc, char **argv)
433 433
434 setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem); 434 setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
435 if(init_maps(physmem_size, iomem_size, highmem)){ 435 if(init_maps(physmem_size, iomem_size, highmem)){
436 printf("Failed to allocate mem_map for %lu bytes of physical " 436 printf("Failed to allocate mem_map for %Lu bytes of physical "
437 "memory and %lu bytes of highmem\n", physmem_size, 437 "memory and %Lu bytes of highmem\n", physmem_size,
438 highmem); 438 highmem);
439 exit(1); 439 exit(1);
440 } 440 }
@@ -477,7 +477,8 @@ static struct notifier_block panic_exit_notifier = {
477 477
478void __init setup_arch(char **cmdline_p) 478void __init setup_arch(char **cmdline_p)
479{ 479{
480 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); 480 atomic_notifier_chain_register(&panic_notifier_list,
481 &panic_exit_notifier);
481 paging_init(); 482 paging_init();
482 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); 483 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
483 *cmdline_p = command_line; 484 *cmdline_p = command_line;
@@ -487,8 +488,7 @@ void __init setup_arch(char **cmdline_p)
487void __init check_bugs(void) 488void __init check_bugs(void)
488{ 489{
489 arch_check_bugs(); 490 arch_check_bugs();
490 check_sigio(); 491 os_check_bugs();
491 check_devanon();
492} 492}
493 493
494void apply_alternatives(struct alt_instr *start, struct alt_instr *end) 494void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index 08a4e628b24c..1659386b42bb 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -3,14 +3,17 @@
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6obj-y = aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ 6obj-y = aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o sigio.o \
7 start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o user_syms.o \ 7 signal.o start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o \
8 util.o drivers/ sys-$(SUBARCH)/ 8 user_syms.o util.o drivers/ sys-$(SUBARCH)/
9 9
10obj-$(CONFIG_MODE_SKAS) += skas/ 10obj-$(CONFIG_MODE_SKAS) += skas/
11obj-$(CONFIG_TTY_LOG) += tty_log.o
12user-objs-$(CONFIG_TTY_LOG) += tty_log.o
11 13
12USER_OBJS := aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ 14USER_OBJS := $(user-objs-y) aio.o elf_aux.o file.o helper.o irq.o main.o mem.o \
13 start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o util.o 15 process.o sigio.o signal.o start_up.o time.o trap.o tt.o tty.o \
16 uaccess.o umid.o util.o
14 17
15elf_aux.o: $(ARCH_DIR)/kernel-offsets.h 18elf_aux.o: $(ARCH_DIR)/kernel-offsets.h
16CFLAGS_elf_aux.o += -I$(objtree)/arch/um 19CFLAGS_elf_aux.o += -I$(objtree)/arch/um
diff --git a/arch/um/os-Linux/irq.c b/arch/um/os-Linux/irq.c
new file mode 100644
index 000000000000..e599be423da1
--- /dev/null
+++ b/arch/um/os-Linux/irq.c
@@ -0,0 +1,162 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <stdlib.h>
7#include <unistd.h>
8#include <errno.h>
9#include <signal.h>
10#include <string.h>
11#include <sys/poll.h>
12#include <sys/types.h>
13#include <sys/time.h>
14#include "user_util.h"
15#include "kern_util.h"
16#include "user.h"
17#include "process.h"
18#include "sigio.h"
19#include "irq_user.h"
20#include "os.h"
21
22static struct pollfd *pollfds = NULL;
23static int pollfds_num = 0;
24static int pollfds_size = 0;
25
26int os_waiting_for_events(struct irq_fd *active_fds)
27{
28 struct irq_fd *irq_fd;
29 int i, n, err;
30
31 n = poll(pollfds, pollfds_num, 0);
32 if(n < 0){
33 err = -errno;
34 if(errno != EINTR)
35 printk("sigio_handler: os_waiting_for_events:"
36 " poll returned %d, errno = %d\n", n, errno);
37 return err;
38 }
39
40 if(n == 0)
41 return 0;
42
43 irq_fd = active_fds;
44
45 for(i = 0; i < pollfds_num; i++){
46 if(pollfds[i].revents != 0){
47 irq_fd->current_events = pollfds[i].revents;
48 pollfds[i].fd = -1;
49 }
50 irq_fd = irq_fd->next;
51 }
52 return n;
53}
54
55int os_isatty(int fd)
56{
57 return(isatty(fd));
58}
59
60int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
61{
62 if (pollfds_num == pollfds_size) {
63 if (size_tmpfds <= pollfds_size * sizeof(pollfds[0])) {
64 /* return min size needed for new pollfds area */
65 return((pollfds_size + 1) * sizeof(pollfds[0]));
66 }
67
68 if(pollfds != NULL){
69 memcpy(tmp_pfd, pollfds,
70 sizeof(pollfds[0]) * pollfds_size);
71 /* remove old pollfds */
72 kfree(pollfds);
73 }
74 pollfds = tmp_pfd;
75 pollfds_size++;
76 } else {
77 /* remove not used tmp_pfd */
78 if (tmp_pfd != NULL)
79 kfree(tmp_pfd);
80 }
81
82 pollfds[pollfds_num] = ((struct pollfd) { .fd = fd,
83 .events = events,
84 .revents = 0 });
85 pollfds_num++;
86
87 return(0);
88}
89
90void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
91 struct irq_fd *active_fds, struct irq_fd ***last_irq_ptr2)
92{
93 struct irq_fd **prev;
94 int i = 0;
95
96 prev = &active_fds;
97 while(*prev != NULL){
98 if((*test)(*prev, arg)){
99 struct irq_fd *old_fd = *prev;
100 if((pollfds[i].fd != -1) &&
101 (pollfds[i].fd != (*prev)->fd)){
102 printk("os_free_irq_by_cb - mismatch between "
103 "active_fds and pollfds, fd %d vs %d\n",
104 (*prev)->fd, pollfds[i].fd);
105 goto out;
106 }
107
108 pollfds_num--;
109
110 /* This moves the *whole* array after pollfds[i]
111 * (though it doesn't spot as such)!
112 */
113
114 memmove(&pollfds[i], &pollfds[i + 1],
115 (pollfds_num - i) * sizeof(pollfds[0]));
116 if(*last_irq_ptr2 == &old_fd->next)
117 *last_irq_ptr2 = prev;
118
119 *prev = (*prev)->next;
120 if(old_fd->type == IRQ_WRITE)
121 ignore_sigio_fd(old_fd->fd);
122 kfree(old_fd);
123 continue;
124 }
125 prev = &(*prev)->next;
126 i++;
127 }
128 out:
129 return;
130}
131
132
133int os_get_pollfd(int i)
134{
135 return(pollfds[i].fd);
136}
137
138void os_set_pollfd(int i, int fd)
139{
140 pollfds[i].fd = fd;
141}
142
143void os_set_ioignore(void)
144{
145 set_handler(SIGIO, SIG_IGN, 0, -1);
146}
147
148void init_irq_signals(int on_sigstack)
149{
150 __sighandler_t h;
151 int flags;
152
153 flags = on_sigstack ? SA_ONSTACK : 0;
154 if(timer_irq_inited) h = (__sighandler_t) alarm_handler;
155 else h = boot_timer_handler;
156
157 set_handler(SIGVTALRM, h, flags | SA_RESTART,
158 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
159 set_handler(SIGIO, (__sighandler_t) sig_handler, flags | SA_RESTART,
160 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
161 signal(SIGWINCH, SIG_IGN);
162}
diff --git a/arch/um/kernel/sigio_user.c b/arch/um/os-Linux/sigio.c
index f7b18e157d35..9ba942947146 100644
--- a/arch/um/kernel/sigio_user.c
+++ b/arch/um/os-Linux/sigio.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -20,128 +20,7 @@
20#include "sigio.h" 20#include "sigio.h"
21#include "os.h" 21#include "os.h"
22 22
23/* Changed during early boot */ 23/* Protected by sigio_lock(), also used by sigio_cleanup, which is an
24int pty_output_sigio = 0;
25int pty_close_sigio = 0;
26
27/* Used as a flag during SIGIO testing early in boot */
28static volatile int got_sigio = 0;
29
30void __init handler(int sig)
31{
32 got_sigio = 1;
33}
34
35struct openpty_arg {
36 int master;
37 int slave;
38 int err;
39};
40
41static void openpty_cb(void *arg)
42{
43 struct openpty_arg *info = arg;
44
45 info->err = 0;
46 if(openpty(&info->master, &info->slave, NULL, NULL, NULL))
47 info->err = -errno;
48}
49
50void __init check_one_sigio(void (*proc)(int, int))
51{
52 struct sigaction old, new;
53 struct openpty_arg pty = { .master = -1, .slave = -1 };
54 int master, slave, err;
55
56 initial_thread_cb(openpty_cb, &pty);
57 if(pty.err){
58 printk("openpty failed, errno = %d\n", -pty.err);
59 return;
60 }
61
62 master = pty.master;
63 slave = pty.slave;
64
65 if((master == -1) || (slave == -1)){
66 printk("openpty failed to allocate a pty\n");
67 return;
68 }
69
70 /* Not now, but complain so we now where we failed. */
71 err = raw(master);
72 if (err < 0)
73 panic("check_sigio : __raw failed, errno = %d\n", -err);
74
75 err = os_sigio_async(master, slave);
76 if(err < 0)
77 panic("tty_fds : sigio_async failed, err = %d\n", -err);
78
79 if(sigaction(SIGIO, NULL, &old) < 0)
80 panic("check_sigio : sigaction 1 failed, errno = %d\n", errno);
81 new = old;
82 new.sa_handler = handler;
83 if(sigaction(SIGIO, &new, NULL) < 0)
84 panic("check_sigio : sigaction 2 failed, errno = %d\n", errno);
85
86 got_sigio = 0;
87 (*proc)(master, slave);
88
89 os_close_file(master);
90 os_close_file(slave);
91
92 if(sigaction(SIGIO, &old, NULL) < 0)
93 panic("check_sigio : sigaction 3 failed, errno = %d\n", errno);
94}
95
96static void tty_output(int master, int slave)
97{
98 int n;
99 char buf[512];
100
101 printk("Checking that host ptys support output SIGIO...");
102
103 memset(buf, 0, sizeof(buf));
104
105 while(os_write_file(master, buf, sizeof(buf)) > 0) ;
106 if(errno != EAGAIN)
107 panic("check_sigio : write failed, errno = %d\n", errno);
108 while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
109
110 if (got_sigio) {
111 printk("Yes\n");
112 pty_output_sigio = 1;
113 } else if (n == -EAGAIN) {
114 printk("No, enabling workaround\n");
115 } else {
116 panic("check_sigio : read failed, err = %d\n", n);
117 }
118}
119
120static void tty_close(int master, int slave)
121{
122 printk("Checking that host ptys support SIGIO on close...");
123
124 os_close_file(slave);
125 if(got_sigio){
126 printk("Yes\n");
127 pty_close_sigio = 1;
128 }
129 else printk("No, enabling workaround\n");
130}
131
132void __init check_sigio(void)
133{
134 if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) &&
135 (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){
136 printk("No pseudo-terminals available - skipping pty SIGIO "
137 "check\n");
138 return;
139 }
140 check_one_sigio(tty_output);
141 check_one_sigio(tty_close);
142}
143
144/* Protected by sigio_lock(), also used by sigio_cleanup, which is an
145 * exitcall. 24 * exitcall.
146 */ 25 */
147static int write_sigio_pid = -1; 26static int write_sigio_pid = -1;
@@ -150,8 +29,10 @@ static int write_sigio_pid = -1;
150 * the descriptors closed after it is killed. So, it can't see them change. 29 * the descriptors closed after it is killed. So, it can't see them change.
151 * On the UML side, they are changed under the sigio_lock. 30 * On the UML side, they are changed under the sigio_lock.
152 */ 31 */
153static int write_sigio_fds[2] = { -1, -1 }; 32#define SIGIO_FDS_INIT {-1, -1}
154static int sigio_private[2] = { -1, -1 }; 33
34static int write_sigio_fds[2] = SIGIO_FDS_INIT;
35static int sigio_private[2] = SIGIO_FDS_INIT;
155 36
156struct pollfds { 37struct pollfds {
157 struct pollfd *poll; 38 struct pollfd *poll;
@@ -264,13 +145,13 @@ static void update_thread(void)
264 return; 145 return;
265 fail: 146 fail:
266 /* Critical section start */ 147 /* Critical section start */
267 if(write_sigio_pid != -1) 148 if(write_sigio_pid != -1)
268 os_kill_process(write_sigio_pid, 1); 149 os_kill_process(write_sigio_pid, 1);
269 write_sigio_pid = -1; 150 write_sigio_pid = -1;
270 os_close_file(sigio_private[0]); 151 close(sigio_private[0]);
271 os_close_file(sigio_private[1]); 152 close(sigio_private[1]);
272 os_close_file(write_sigio_fds[0]); 153 close(write_sigio_fds[0]);
273 os_close_file(write_sigio_fds[1]); 154 close(write_sigio_fds[1]);
274 /* Critical section end */ 155 /* Critical section end */
275 set_signals(flags); 156 set_signals(flags);
276} 157}
@@ -281,13 +162,13 @@ int add_sigio_fd(int fd, int read)
281 162
282 sigio_lock(); 163 sigio_lock();
283 for(i = 0; i < current_poll.used; i++){ 164 for(i = 0; i < current_poll.used; i++){
284 if(current_poll.poll[i].fd == fd) 165 if(current_poll.poll[i].fd == fd)
285 goto out; 166 goto out;
286 } 167 }
287 168
288 n = current_poll.used + 1; 169 n = current_poll.used + 1;
289 err = need_poll(n); 170 err = need_poll(n);
290 if(err) 171 if(err)
291 goto out; 172 goto out;
292 173
293 for(i = 0; i < current_poll.used; i++) 174 for(i = 0; i < current_poll.used; i++)
@@ -316,7 +197,7 @@ int ignore_sigio_fd(int fd)
316 } 197 }
317 if(i == current_poll.used) 198 if(i == current_poll.used)
318 goto out; 199 goto out;
319 200
320 err = need_poll(current_poll.used - 1); 201 err = need_poll(current_poll.used - 1);
321 if(err) 202 if(err)
322 goto out; 203 goto out;
@@ -337,7 +218,7 @@ int ignore_sigio_fd(int fd)
337 return(err); 218 return(err);
338} 219}
339 220
340static struct pollfd* setup_initial_poll(int fd) 221static struct pollfd *setup_initial_poll(int fd)
341{ 222{
342 struct pollfd *p; 223 struct pollfd *p;
343 224
@@ -377,7 +258,7 @@ void write_sigio_workaround(void)
377 } 258 }
378 err = os_pipe(l_sigio_private, 1, 1); 259 err = os_pipe(l_sigio_private, 1, 1);
379 if(err < 0){ 260 if(err < 0){
380 printk("write_sigio_workaround - os_pipe 1 failed, " 261 printk("write_sigio_workaround - os_pipe 2 failed, "
381 "err = %d\n", -err); 262 "err = %d\n", -err);
382 goto out_close1; 263 goto out_close1;
383 } 264 }
@@ -391,76 +272,52 @@ void write_sigio_workaround(void)
391 /* Did we race? Don't try to optimize this, please, it's not so likely 272 /* Did we race? Don't try to optimize this, please, it's not so likely
392 * to happen, and no more than once at the boot. */ 273 * to happen, and no more than once at the boot. */
393 if(write_sigio_pid != -1) 274 if(write_sigio_pid != -1)
394 goto out_unlock; 275 goto out_free;
395 276
396 write_sigio_pid = run_helper_thread(write_sigio_thread, NULL, 277 current_poll = ((struct pollfds) { .poll = p,
397 CLONE_FILES | CLONE_VM, &stack, 0); 278 .used = 1,
398 279 .size = 1 });
399 if (write_sigio_pid < 0)
400 goto out_clear;
401 280
402 if (write_sigio_irq(l_write_sigio_fds[0])) 281 if (write_sigio_irq(l_write_sigio_fds[0]))
403 goto out_kill; 282 goto out_clear_poll;
404 283
405 /* Success, finally. */
406 memcpy(write_sigio_fds, l_write_sigio_fds, sizeof(l_write_sigio_fds)); 284 memcpy(write_sigio_fds, l_write_sigio_fds, sizeof(l_write_sigio_fds));
407 memcpy(sigio_private, l_sigio_private, sizeof(l_sigio_private)); 285 memcpy(sigio_private, l_sigio_private, sizeof(l_sigio_private));
408 286
409 current_poll = ((struct pollfds) { .poll = p, 287 write_sigio_pid = run_helper_thread(write_sigio_thread, NULL,
410 .used = 1, 288 CLONE_FILES | CLONE_VM, &stack, 0);
411 .size = 1 });
412 289
413 sigio_unlock(); 290 if (write_sigio_pid < 0)
414 return; 291 goto out_clear;
415 292
416 out_kill:
417 l_write_sigio_pid = write_sigio_pid;
418 write_sigio_pid = -1;
419 sigio_unlock(); 293 sigio_unlock();
420 /* Going to call waitpid, avoid holding the lock. */ 294 return;
421 os_kill_process(l_write_sigio_pid, 1);
422 goto out_free;
423 295
424 out_clear: 296out_clear:
425 write_sigio_pid = -1; 297 write_sigio_pid = -1;
426 out_unlock: 298 write_sigio_fds[0] = -1;
427 sigio_unlock(); 299 write_sigio_fds[1] = -1;
428 out_free: 300 sigio_private[0] = -1;
301 sigio_private[1] = -1;
302out_clear_poll:
303 current_poll = ((struct pollfds) { .poll = NULL,
304 .size = 0,
305 .used = 0 });
306out_free:
429 kfree(p); 307 kfree(p);
430 out_close2: 308 sigio_unlock();
431 os_close_file(l_sigio_private[0]); 309out_close2:
432 os_close_file(l_sigio_private[1]); 310 close(l_sigio_private[0]);
433 out_close1: 311 close(l_sigio_private[1]);
434 os_close_file(l_write_sigio_fds[0]); 312out_close1:
435 os_close_file(l_write_sigio_fds[1]); 313 close(l_write_sigio_fds[0]);
436 return; 314 close(l_write_sigio_fds[1]);
437}
438
439int read_sigio_fd(int fd)
440{
441 int n;
442 char c;
443
444 n = os_read_file(fd, &c, sizeof(c));
445 if(n != sizeof(c)){
446 if(n < 0) {
447 printk("read_sigio_fd - read failed, err = %d\n", -n);
448 return(n);
449 }
450 else {
451 printk("read_sigio_fd - short read, bytes = %d\n", n);
452 return(-EIO);
453 }
454 }
455 return(n);
456} 315}
457 316
458static void sigio_cleanup(void) 317void sigio_cleanup(void)
459{ 318{
460 if (write_sigio_pid != -1) { 319 if(write_sigio_pid != -1){
461 os_kill_process(write_sigio_pid, 1); 320 os_kill_process(write_sigio_pid, 1);
462 write_sigio_pid = -1; 321 write_sigio_pid = -1;
463 } 322 }
464} 323}
465
466__uml_exitcall(sigio_cleanup);
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 829d6b0d8b02..32753131f8d8 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -3,6 +3,7 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <pty.h>
6#include <stdio.h> 7#include <stdio.h>
7#include <stddef.h> 8#include <stddef.h>
8#include <stdarg.h> 9#include <stdarg.h>
@@ -539,3 +540,130 @@ int __init parse_iomem(char *str, int *add)
539 return(1); 540 return(1);
540} 541}
541 542
543
544/* Changed during early boot */
545int pty_output_sigio = 0;
546int pty_close_sigio = 0;
547
548/* Used as a flag during SIGIO testing early in boot */
549static volatile int got_sigio = 0;
550
551static void __init handler(int sig)
552{
553 got_sigio = 1;
554}
555
556struct openpty_arg {
557 int master;
558 int slave;
559 int err;
560};
561
562static void openpty_cb(void *arg)
563{
564 struct openpty_arg *info = arg;
565
566 info->err = 0;
567 if(openpty(&info->master, &info->slave, NULL, NULL, NULL))
568 info->err = -errno;
569}
570
571static void __init check_one_sigio(void (*proc)(int, int))
572{
573 struct sigaction old, new;
574 struct openpty_arg pty = { .master = -1, .slave = -1 };
575 int master, slave, err;
576
577 initial_thread_cb(openpty_cb, &pty);
578 if(pty.err){
579 printk("openpty failed, errno = %d\n", -pty.err);
580 return;
581 }
582
583 master = pty.master;
584 slave = pty.slave;
585
586 if((master == -1) || (slave == -1)){
587 printk("openpty failed to allocate a pty\n");
588 return;
589 }
590
591 /* Not now, but complain so we now where we failed. */
592 err = raw(master);
593 if (err < 0)
594 panic("check_sigio : __raw failed, errno = %d\n", -err);
595
596 err = os_sigio_async(master, slave);
597 if(err < 0)
598 panic("tty_fds : sigio_async failed, err = %d\n", -err);
599
600 if(sigaction(SIGIO, NULL, &old) < 0)
601 panic("check_sigio : sigaction 1 failed, errno = %d\n", errno);
602 new = old;
603 new.sa_handler = handler;
604 if(sigaction(SIGIO, &new, NULL) < 0)
605 panic("check_sigio : sigaction 2 failed, errno = %d\n", errno);
606
607 got_sigio = 0;
608 (*proc)(master, slave);
609
610 close(master);
611 close(slave);
612
613 if(sigaction(SIGIO, &old, NULL) < 0)
614 panic("check_sigio : sigaction 3 failed, errno = %d\n", errno);
615}
616
617static void tty_output(int master, int slave)
618{
619 int n;
620 char buf[512];
621
622 printk("Checking that host ptys support output SIGIO...");
623
624 memset(buf, 0, sizeof(buf));
625
626 while(os_write_file(master, buf, sizeof(buf)) > 0) ;
627 if(errno != EAGAIN)
628 panic("check_sigio : write failed, errno = %d\n", errno);
629 while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
630
631 if(got_sigio){
632 printk("Yes\n");
633 pty_output_sigio = 1;
634 }
635 else if(n == -EAGAIN) printk("No, enabling workaround\n");
636 else panic("check_sigio : read failed, err = %d\n", n);
637}
638
639static void tty_close(int master, int slave)
640{
641 printk("Checking that host ptys support SIGIO on close...");
642
643 close(slave);
644 if(got_sigio){
645 printk("Yes\n");
646 pty_close_sigio = 1;
647 }
648 else printk("No, enabling workaround\n");
649}
650
651void __init check_sigio(void)
652{
653 if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) &&
654 (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){
655 printk("No pseudo-terminals available - skipping pty SIGIO "
656 "check\n");
657 return;
658 }
659 check_one_sigio(tty_output);
660 check_one_sigio(tty_close);
661}
662
663void os_check_bugs(void)
664{
665 check_ptrace();
666 check_sigio();
667 check_devanon();
668}
669
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c
index 919d19f11537..5461a065bbb9 100644
--- a/arch/um/os-Linux/tt.c
+++ b/arch/um/os-Linux/tt.c
@@ -110,6 +110,16 @@ int wait_for_stop(int pid, int sig, int cont_type, void *relay)
110 } 110 }
111} 111}
112 112
113void forward_ipi(int fd, int pid)
114{
115 int err;
116
117 err = os_set_owner(fd, pid);
118 if(err < 0)
119 printk("forward_ipi: set_owner failed, fd = %d, me = %d, "
120 "target = %d, err = %d\n", fd, os_getpid(), pid, -err);
121}
122
113/* 123/*
114 *------------------------- 124 *-------------------------
115 * only for tt mode (will be deleted in future...) 125 * only for tt mode (will be deleted in future...)
diff --git a/arch/um/kernel/tty_log.c b/arch/um/os-Linux/tty_log.c
index 9ada656f68ce..c6ba56c1560f 100644
--- a/arch/um/kernel/tty_log.c
+++ b/arch/um/os-Linux/tty_log.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) and 2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) and
3 * geoffrey hing <ghing@net.ohio-state.edu> 3 * geoffrey hing <ghing@net.ohio-state.edu>
4 * Licensed under the GPL 4 * Licensed under the GPL
5 */ 5 */
@@ -58,7 +58,7 @@ int open_tty_log(void *tty, void *current_tty)
58 return(tty_log_fd); 58 return(tty_log_fd);
59 } 59 }
60 60
61 sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec, 61 sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec,
62 (unsigned int) tv.tv_usec); 62 (unsigned int) tv.tv_usec);
63 63
64 fd = os_open_file(buf, of_append(of_create(of_rdwr(OPENFLAGS()))), 64 fd = os_open_file(buf, of_append(of_create(of_rdwr(OPENFLAGS()))),
@@ -216,15 +216,3 @@ __uml_setup("tty_log_fd=", set_tty_log_fd,
216" tty data will be written. Preconfigure the descriptor with something\n" 216" tty data will be written. Preconfigure the descriptor with something\n"
217" like '10>tty_log tty_log_fd=10'.\n\n" 217" like '10>tty_log tty_log_fd=10'.\n\n"
218); 218);
219
220
221/*
222 * Overrides for Emacs so that we follow Linus's tabbing style.
223 * Emacs will notice this stuff at the end of the file and automatically
224 * adjust the settings for this buffer only. This must remain at the end
225 * of the file.
226 * ---------------------------------------------------------------------------
227 * Local variables:
228 * c-file-style: "linux"
229 * End:
230 */
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index ecf107ae5ac8..198e59163288 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -143,8 +143,10 @@ static int not_dead_yet(char *dir)
143 goto out_close; 143 goto out_close;
144 } 144 }
145 145
146 if((kill(p, 0) == 0) || (errno != ESRCH)) 146 if((kill(p, 0) == 0) || (errno != ESRCH)){
147 printk("umid \"%s\" is already in use by pid %d\n", umid, p);
147 return 1; 148 return 1;
149 }
148 150
149 err = actually_do_remove(dir); 151 err = actually_do_remove(dir);
150 if(err) 152 if(err)
@@ -234,33 +236,44 @@ int __init make_umid(void)
234 err = mkdir(tmp, 0777); 236 err = mkdir(tmp, 0777);
235 if(err < 0){ 237 if(err < 0){
236 err = -errno; 238 err = -errno;
237 if(errno != EEXIST) 239 if(err != -EEXIST)
238 goto err; 240 goto err;
239 241
240 if(not_dead_yet(tmp) < 0) 242 /* 1 -> this umid is already in use
243 * < 0 -> we couldn't remove the umid directory
244 * In either case, we can't use this umid, so return -EEXIST.
245 */
246 if(not_dead_yet(tmp) != 0)
241 goto err; 247 goto err;
242 248
243 err = mkdir(tmp, 0777); 249 err = mkdir(tmp, 0777);
244 } 250 }
245 if(err < 0){ 251 if(err){
246 printk("Failed to create '%s' - err = %d\n", umid, err); 252 err = -errno;
247 goto err_rmdir; 253 printk("Failed to create '%s' - err = %d\n", umid, -errno);
254 goto err;
248 } 255 }
249 256
250 umid_setup = 1; 257 umid_setup = 1;
251 258
252 create_pid_file(); 259 create_pid_file();
253 260
254 return 0; 261 err = 0;
255
256 err_rmdir:
257 rmdir(tmp);
258 err: 262 err:
259 return err; 263 return err;
260} 264}
261 265
262static int __init make_umid_init(void) 266static int __init make_umid_init(void)
263{ 267{
268 if(!make_umid())
269 return 0;
270
271 /* If initializing with the given umid failed, then try again with
272 * a random one.
273 */
274 printk("Failed to initialize umid \"%s\", trying with a random umid\n",
275 umid);
276 *umid = '\0';
264 make_umid(); 277 make_umid();
265 278
266 return 0; 279 return 0;
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
index e839ce65ad28..8032a105949a 100644
--- a/arch/um/sys-i386/ptrace.c
+++ b/arch/um/sys-i386/ptrace.c
@@ -6,6 +6,7 @@
6#include <linux/config.h> 6#include <linux/config.h>
7#include <linux/compiler.h> 7#include <linux/compiler.h>
8#include "linux/sched.h" 8#include "linux/sched.h"
9#include "linux/mm.h"
9#include "asm/elf.h" 10#include "asm/elf.h"
10#include "asm/ptrace.h" 11#include "asm/ptrace.h"
11#include "asm/uaccess.h" 12#include "asm/uaccess.h"
@@ -26,9 +27,17 @@ int is_syscall(unsigned long addr)
26 27
27 n = copy_from_user(&instr, (void __user *) addr, sizeof(instr)); 28 n = copy_from_user(&instr, (void __user *) addr, sizeof(instr));
28 if(n){ 29 if(n){
29 printk("is_syscall : failed to read instruction from 0x%lx\n", 30 /* access_process_vm() grants access to vsyscall and stub,
30 addr); 31 * while copy_from_user doesn't. Maybe access_process_vm is
31 return(0); 32 * slow, but that doesn't matter, since it will be called only
33 * in case of singlestepping, if copy_from_user failed.
34 */
35 n = access_process_vm(current, addr, &instr, sizeof(instr), 0);
36 if(n != sizeof(instr)) {
37 printk("is_syscall : failed to read instruction from "
38 "0x%lx\n", addr);
39 return(1);
40 }
32 } 41 }
33 /* int 0x80 or sysenter */ 42 /* int 0x80 or sysenter */
34 return((instr == 0x80cd) || (instr == 0x340f)); 43 return((instr == 0x80cd) || (instr == 0x340f));
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index 7cd1a82dc8c2..33a40f5ef0d2 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -58,7 +58,7 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
58} 58}
59 59
60int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, 60int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
61 struct pt_regs *regs) 61 struct pt_regs *regs, unsigned long sp)
62{ 62{
63 struct sigcontext sc; 63 struct sigcontext sc;
64 unsigned long fpregs[HOST_FP_SIZE]; 64 unsigned long fpregs[HOST_FP_SIZE];
@@ -72,7 +72,7 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
72 sc.edi = REGS_EDI(regs->regs.skas.regs); 72 sc.edi = REGS_EDI(regs->regs.skas.regs);
73 sc.esi = REGS_ESI(regs->regs.skas.regs); 73 sc.esi = REGS_ESI(regs->regs.skas.regs);
74 sc.ebp = REGS_EBP(regs->regs.skas.regs); 74 sc.ebp = REGS_EBP(regs->regs.skas.regs);
75 sc.esp = REGS_SP(regs->regs.skas.regs); 75 sc.esp = sp;
76 sc.ebx = REGS_EBX(regs->regs.skas.regs); 76 sc.ebx = REGS_EBX(regs->regs.skas.regs);
77 sc.edx = REGS_EDX(regs->regs.skas.regs); 77 sc.edx = REGS_EDX(regs->regs.skas.regs);
78 sc.ecx = REGS_ECX(regs->regs.skas.regs); 78 sc.ecx = REGS_ECX(regs->regs.skas.regs);
@@ -132,7 +132,7 @@ int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext *from,
132} 132}
133 133
134int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp, 134int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp,
135 struct sigcontext *from, int fpsize) 135 struct sigcontext *from, int fpsize, unsigned long sp)
136{ 136{
137 struct _fpstate *to_fp, *from_fp; 137 struct _fpstate *to_fp, *from_fp;
138 int err; 138 int err;
@@ -140,11 +140,18 @@ int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp,
140 to_fp = (fp ? fp : (struct _fpstate *) (to + 1)); 140 to_fp = (fp ? fp : (struct _fpstate *) (to + 1));
141 from_fp = from->fpstate; 141 from_fp = from->fpstate;
142 err = copy_to_user(to, from, sizeof(*to)); 142 err = copy_to_user(to, from, sizeof(*to));
143
144 /* The SP in the sigcontext is the updated one for the signal
145 * delivery. The sp passed in is the original, and this needs
146 * to be restored, so we stick it in separately.
147 */
148 err |= copy_to_user(&SC_SP(to), sp, sizeof(sp));
149
143 if(from_fp != NULL){ 150 if(from_fp != NULL){
144 err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate)); 151 err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
145 err |= copy_to_user(to_fp, from_fp, fpsize); 152 err |= copy_to_user(to_fp, from_fp, fpsize);
146 } 153 }
147 return(err); 154 return err;
148} 155}
149#endif 156#endif
150 157
@@ -159,11 +166,11 @@ static int copy_sc_from_user(struct pt_regs *to, void __user *from)
159} 166}
160 167
161static int copy_sc_to_user(struct sigcontext *to, struct _fpstate *fp, 168static int copy_sc_to_user(struct sigcontext *to, struct _fpstate *fp,
162 struct pt_regs *from) 169 struct pt_regs *from, unsigned long sp)
163{ 170{
164 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), 171 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
165 sizeof(*fp)), 172 sizeof(*fp), sp),
166 copy_sc_to_user_skas(to, fp, from))); 173 copy_sc_to_user_skas(to, fp, from, sp)));
167} 174}
168 175
169static int copy_ucontext_to_user(struct ucontext *uc, struct _fpstate *fp, 176static int copy_ucontext_to_user(struct ucontext *uc, struct _fpstate *fp,
@@ -174,7 +181,7 @@ static int copy_ucontext_to_user(struct ucontext *uc, struct _fpstate *fp,
174 err |= put_user(current->sas_ss_sp, &uc->uc_stack.ss_sp); 181 err |= put_user(current->sas_ss_sp, &uc->uc_stack.ss_sp);
175 err |= put_user(sas_ss_flags(sp), &uc->uc_stack.ss_flags); 182 err |= put_user(sas_ss_flags(sp), &uc->uc_stack.ss_flags);
176 err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size); 183 err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size);
177 err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs); 184 err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs, sp);
178 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set)); 185 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));
179 return(err); 186 return(err);
180} 187}
@@ -207,6 +214,7 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
207{ 214{
208 struct sigframe __user *frame; 215 struct sigframe __user *frame;
209 void *restorer; 216 void *restorer;
217 unsigned long save_sp = PT_REGS_SP(regs);
210 int err = 0; 218 int err = 0;
211 219
212 stack_top &= -8UL; 220 stack_top &= -8UL;
@@ -218,9 +226,19 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
218 if(ka->sa.sa_flags & SA_RESTORER) 226 if(ka->sa.sa_flags & SA_RESTORER)
219 restorer = ka->sa.sa_restorer; 227 restorer = ka->sa.sa_restorer;
220 228
229 /* Update SP now because the page fault handler refuses to extend
230 * the stack if the faulting address is too far below the current
231 * SP, which frame now certainly is. If there's an error, the original
232 * value is restored on the way out.
233 * When writing the sigcontext to the stack, we have to write the
234 * original value, so that's passed to copy_sc_to_user, which does
235 * the right thing with it.
236 */
237 PT_REGS_SP(regs) = (unsigned long) frame;
238
221 err |= __put_user(restorer, &frame->pretcode); 239 err |= __put_user(restorer, &frame->pretcode);
222 err |= __put_user(sig, &frame->sig); 240 err |= __put_user(sig, &frame->sig);
223 err |= copy_sc_to_user(&frame->sc, NULL, regs); 241 err |= copy_sc_to_user(&frame->sc, NULL, regs, save_sp);
224 err |= __put_user(mask->sig[0], &frame->sc.oldmask); 242 err |= __put_user(mask->sig[0], &frame->sc.oldmask);
225 if (_NSIG_WORDS > 1) 243 if (_NSIG_WORDS > 1)
226 err |= __copy_to_user(&frame->extramask, &mask->sig[1], 244 err |= __copy_to_user(&frame->extramask, &mask->sig[1],
@@ -238,7 +256,7 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
238 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6)); 256 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6));
239 257
240 if(err) 258 if(err)
241 return(err); 259 goto err;
242 260
243 PT_REGS_SP(regs) = (unsigned long) frame; 261 PT_REGS_SP(regs) = (unsigned long) frame;
244 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; 262 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
@@ -248,7 +266,11 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
248 266
249 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED)) 267 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
250 ptrace_notify(SIGTRAP); 268 ptrace_notify(SIGTRAP);
251 return(0); 269 return 0;
270
271err:
272 PT_REGS_SP(regs) = save_sp;
273 return err;
252} 274}
253 275
254int setup_signal_stack_si(unsigned long stack_top, int sig, 276int setup_signal_stack_si(unsigned long stack_top, int sig,
@@ -257,6 +279,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
257{ 279{
258 struct rt_sigframe __user *frame; 280 struct rt_sigframe __user *frame;
259 void *restorer; 281 void *restorer;
282 unsigned long save_sp = PT_REGS_SP(regs);
260 int err = 0; 283 int err = 0;
261 284
262 stack_top &= -8UL; 285 stack_top &= -8UL;
@@ -268,13 +291,16 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
268 if(ka->sa.sa_flags & SA_RESTORER) 291 if(ka->sa.sa_flags & SA_RESTORER)
269 restorer = ka->sa.sa_restorer; 292 restorer = ka->sa.sa_restorer;
270 293
294 /* See comment above about why this is here */
295 PT_REGS_SP(regs) = (unsigned long) frame;
296
271 err |= __put_user(restorer, &frame->pretcode); 297 err |= __put_user(restorer, &frame->pretcode);
272 err |= __put_user(sig, &frame->sig); 298 err |= __put_user(sig, &frame->sig);
273 err |= __put_user(&frame->info, &frame->pinfo); 299 err |= __put_user(&frame->info, &frame->pinfo);
274 err |= __put_user(&frame->uc, &frame->puc); 300 err |= __put_user(&frame->uc, &frame->puc);
275 err |= copy_siginfo_to_user(&frame->info, info); 301 err |= copy_siginfo_to_user(&frame->info, info);
276 err |= copy_ucontext_to_user(&frame->uc, &frame->fpstate, mask, 302 err |= copy_ucontext_to_user(&frame->uc, &frame->fpstate, mask,
277 PT_REGS_SP(regs)); 303 save_sp);
278 304
279 /* 305 /*
280 * This is movl $,%eax ; int $0x80 306 * This is movl $,%eax ; int $0x80
@@ -288,9 +314,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
288 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5)); 314 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));
289 315
290 if(err) 316 if(err)
291 return(err); 317 goto err;
292 318
293 PT_REGS_SP(regs) = (unsigned long) frame;
294 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; 319 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
295 PT_REGS_EAX(regs) = (unsigned long) sig; 320 PT_REGS_EAX(regs) = (unsigned long) sig;
296 PT_REGS_EDX(regs) = (unsigned long) &frame->info; 321 PT_REGS_EDX(regs) = (unsigned long) &frame->info;
@@ -298,7 +323,11 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
298 323
299 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED)) 324 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
300 ptrace_notify(SIGTRAP); 325 ptrace_notify(SIGTRAP);
301 return(0); 326 return 0;
327
328err:
329 PT_REGS_SP(regs) = save_sp;
330 return err;
302} 331}
303 332
304long sys_sigreturn(struct pt_regs regs) 333long sys_sigreturn(struct pt_regs regs)
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
index 26b68675053d..6f4ef2b7fa4a 100644
--- a/arch/um/sys-i386/user-offsets.c
+++ b/arch/um/sys-i386/user-offsets.c
@@ -3,12 +3,13 @@
3#include <asm/ptrace.h> 3#include <asm/ptrace.h>
4#include <asm/user.h> 4#include <asm/user.h>
5#include <linux/stddef.h> 5#include <linux/stddef.h>
6#include <sys/poll.h>
6 7
7#define DEFINE(sym, val) \ 8#define DEFINE(sym, val) \
8 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 9 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
9 10
10#define DEFINE_LONGS(sym, val) \ 11#define DEFINE_LONGS(sym, val) \
11 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) 12 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
12 13
13#define OFFSET(sym, str, mem) \ 14#define OFFSET(sym, str, mem) \
14 DEFINE(sym, offsetof(struct str, mem)); 15 DEFINE(sym, offsetof(struct str, mem));
@@ -67,4 +68,9 @@ void foo(void)
67 DEFINE(HOST_ES, ES); 68 DEFINE(HOST_ES, ES);
68 DEFINE(HOST_GS, GS); 69 DEFINE(HOST_GS, GS);
69 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); 70 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
71
72 /* XXX Duplicated between i386 and x86_64 */
73 DEFINE(UM_POLLIN, POLLIN);
74 DEFINE(UM_POLLPRI, POLLPRI);
75 DEFINE(UM_POLLOUT, POLLOUT);
70} 76}
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index 74eee5c7c6dd..147bbf05cbc2 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -8,6 +8,7 @@
8#include <asm/ptrace.h> 8#include <asm/ptrace.h>
9#include <linux/sched.h> 9#include <linux/sched.h>
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/mm.h>
11#include <asm/uaccess.h> 12#include <asm/uaccess.h>
12#include <asm/elf.h> 13#include <asm/elf.h>
13 14
@@ -136,9 +137,28 @@ void arch_switch(void)
136*/ 137*/
137} 138}
138 139
140/* XXX Mostly copied from sys-i386 */
139int is_syscall(unsigned long addr) 141int is_syscall(unsigned long addr)
140{ 142{
141 panic("is_syscall"); 143 unsigned short instr;
144 int n;
145
146 n = copy_from_user(&instr, (void __user *) addr, sizeof(instr));
147 if(n){
148 /* access_process_vm() grants access to vsyscall and stub,
149 * while copy_from_user doesn't. Maybe access_process_vm is
150 * slow, but that doesn't matter, since it will be called only
151 * in case of singlestepping, if copy_from_user failed.
152 */
153 n = access_process_vm(current, addr, &instr, sizeof(instr), 0);
154 if(n != sizeof(instr)) {
155 printk("is_syscall : failed to read instruction from "
156 "0x%lx\n", addr);
157 return(1);
158 }
159 }
160 /* sysenter */
161 return(instr == 0x050f);
142} 162}
143 163
144int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu ) 164int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
index fe1d065332b1..e75c4e1838b0 100644
--- a/arch/um/sys-x86_64/signal.c
+++ b/arch/um/sys-x86_64/signal.c
@@ -55,7 +55,8 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
55} 55}
56 56
57int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, 57int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
58 struct pt_regs *regs, unsigned long mask) 58 struct pt_regs *regs, unsigned long mask,
59 unsigned long sp)
59{ 60{
60 struct faultinfo * fi = &current->thread.arch.faultinfo; 61 struct faultinfo * fi = &current->thread.arch.faultinfo;
61 int err = 0; 62 int err = 0;
@@ -70,7 +71,11 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
70 err |= PUTREG(regs, RDI, to, rdi); 71 err |= PUTREG(regs, RDI, to, rdi);
71 err |= PUTREG(regs, RSI, to, rsi); 72 err |= PUTREG(regs, RSI, to, rsi);
72 err |= PUTREG(regs, RBP, to, rbp); 73 err |= PUTREG(regs, RBP, to, rbp);
73 err |= PUTREG(regs, RSP, to, rsp); 74 /* Must use orignal RSP, which is passed in, rather than what's in
75 * the pt_regs, because that's already been updated to point at the
76 * signal frame.
77 */
78 err |= __put_user(sp, &to->rsp);
74 err |= PUTREG(regs, RBX, to, rbx); 79 err |= PUTREG(regs, RBX, to, rbx);
75 err |= PUTREG(regs, RDX, to, rdx); 80 err |= PUTREG(regs, RDX, to, rdx);
76 err |= PUTREG(regs, RCX, to, rcx); 81 err |= PUTREG(regs, RCX, to, rcx);
@@ -102,7 +107,7 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
102 107
103#ifdef CONFIG_MODE_TT 108#ifdef CONFIG_MODE_TT
104int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext *from, 109int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext *from,
105 int fpsize) 110 int fpsize)
106{ 111{
107 struct _fpstate *to_fp, *from_fp; 112 struct _fpstate *to_fp, *from_fp;
108 unsigned long sigs; 113 unsigned long sigs;
@@ -120,7 +125,7 @@ int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext *from,
120} 125}
121 126
122int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp, 127int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp,
123 struct sigcontext *from, int fpsize) 128 struct sigcontext *from, int fpsize, unsigned long sp)
124{ 129{
125 struct _fpstate *to_fp, *from_fp; 130 struct _fpstate *to_fp, *from_fp;
126 int err; 131 int err;
@@ -128,11 +133,17 @@ int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp,
128 to_fp = (fp ? fp : (struct _fpstate *) (to + 1)); 133 to_fp = (fp ? fp : (struct _fpstate *) (to + 1));
129 from_fp = from->fpstate; 134 from_fp = from->fpstate;
130 err = copy_to_user(to, from, sizeof(*to)); 135 err = copy_to_user(to, from, sizeof(*to));
136 /* The SP in the sigcontext is the updated one for the signal
137 * delivery. The sp passed in is the original, and this needs
138 * to be restored, so we stick it in separately.
139 */
140 err |= copy_to_user(&SC_SP(to), sp, sizeof(sp));
141
131 if(from_fp != NULL){ 142 if(from_fp != NULL){
132 err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate)); 143 err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
133 err |= copy_to_user(to_fp, from_fp, fpsize); 144 err |= copy_to_user(to_fp, from_fp, fpsize);
134 } 145 }
135 return(err); 146 return err;
136} 147}
137 148
138#endif 149#endif
@@ -148,11 +159,12 @@ static int copy_sc_from_user(struct pt_regs *to, void __user *from)
148} 159}
149 160
150static int copy_sc_to_user(struct sigcontext *to, struct _fpstate *fp, 161static int copy_sc_to_user(struct sigcontext *to, struct _fpstate *fp,
151 struct pt_regs *from, unsigned long mask) 162 struct pt_regs *from, unsigned long mask,
163 unsigned long sp)
152{ 164{
153 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), 165 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
154 sizeof(*fp)), 166 sizeof(*fp), sp),
155 copy_sc_to_user_skas(to, fp, from, mask))); 167 copy_sc_to_user_skas(to, fp, from, mask, sp)));
156} 168}
157 169
158struct rt_sigframe 170struct rt_sigframe
@@ -170,6 +182,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
170{ 182{
171 struct rt_sigframe __user *frame; 183 struct rt_sigframe __user *frame;
172 struct _fpstate __user *fp = NULL; 184 struct _fpstate __user *fp = NULL;
185 unsigned long save_sp = PT_REGS_RSP(regs);
173 int err = 0; 186 int err = 0;
174 struct task_struct *me = current; 187 struct task_struct *me = current;
175 188
@@ -193,14 +206,25 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
193 goto out; 206 goto out;
194 } 207 }
195 208
209 /* Update SP now because the page fault handler refuses to extend
210 * the stack if the faulting address is too far below the current
211 * SP, which frame now certainly is. If there's an error, the original
212 * value is restored on the way out.
213 * When writing the sigcontext to the stack, we have to write the
214 * original value, so that's passed to copy_sc_to_user, which does
215 * the right thing with it.
216 */
217 PT_REGS_RSP(regs) = (unsigned long) frame;
218
196 /* Create the ucontext. */ 219 /* Create the ucontext. */
197 err |= __put_user(0, &frame->uc.uc_flags); 220 err |= __put_user(0, &frame->uc.uc_flags);
198 err |= __put_user(0, &frame->uc.uc_link); 221 err |= __put_user(0, &frame->uc.uc_link);
199 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 222 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
200 err |= __put_user(sas_ss_flags(PT_REGS_SP(regs)), 223 err |= __put_user(sas_ss_flags(save_sp),
201 &frame->uc.uc_stack.ss_flags); 224 &frame->uc.uc_stack.ss_flags);
202 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size); 225 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
203 err |= copy_sc_to_user(&frame->uc.uc_mcontext, fp, regs, set->sig[0]); 226 err |= copy_sc_to_user(&frame->uc.uc_mcontext, fp, regs, set->sig[0],
227 save_sp);
204 err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate); 228 err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate);
205 if (sizeof(*set) == 16) { 229 if (sizeof(*set) == 16) {
206 __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]); 230 __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);
@@ -217,10 +241,10 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
217 err |= __put_user(ka->sa.sa_restorer, &frame->pretcode); 241 err |= __put_user(ka->sa.sa_restorer, &frame->pretcode);
218 else 242 else
219 /* could use a vstub here */ 243 /* could use a vstub here */
220 goto out; 244 goto restore_sp;
221 245
222 if (err) 246 if (err)
223 goto out; 247 goto restore_sp;
224 248
225 /* Set up registers for signal handler */ 249 /* Set up registers for signal handler */
226 { 250 {
@@ -238,10 +262,12 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
238 PT_REGS_RSI(regs) = (unsigned long) &frame->info; 262 PT_REGS_RSI(regs) = (unsigned long) &frame->info;
239 PT_REGS_RDX(regs) = (unsigned long) &frame->uc; 263 PT_REGS_RDX(regs) = (unsigned long) &frame->uc;
240 PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler; 264 PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler;
241
242 PT_REGS_RSP(regs) = (unsigned long) frame;
243 out: 265 out:
244 return(err); 266 return err;
267
268restore_sp:
269 PT_REGS_RSP(regs) = save_sp;
270 return err;
245} 271}
246 272
247long sys_rt_sigreturn(struct pt_regs *regs) 273long sys_rt_sigreturn(struct pt_regs *regs)
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c
index 7bd54a921cf7..899cebb57c3f 100644
--- a/arch/um/sys-x86_64/user-offsets.c
+++ b/arch/um/sys-x86_64/user-offsets.c
@@ -1,6 +1,7 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stddef.h> 2#include <stddef.h>
3#include <signal.h> 3#include <signal.h>
4#include <sys/poll.h>
4#define __FRAME_OFFSETS 5#define __FRAME_OFFSETS
5#include <asm/ptrace.h> 6#include <asm/ptrace.h>
6#include <asm/types.h> 7#include <asm/types.h>
@@ -88,4 +89,9 @@ void foo(void)
88 DEFINE_LONGS(HOST_IP, RIP); 89 DEFINE_LONGS(HOST_IP, RIP);
89 DEFINE_LONGS(HOST_SP, RSP); 90 DEFINE_LONGS(HOST_SP, RSP);
90 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); 91 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
92
93 /* XXX Duplicated between i386 and x86_64 */
94 DEFINE(UM_POLLIN, POLLIN);
95 DEFINE(UM_POLLPRI, POLLPRI);
96 DEFINE(UM_POLLOUT, POLLOUT);
91} 97}
diff --git a/arch/v850/Kconfig b/arch/v850/Kconfig
index e7fc3e500342..37ec644603ab 100644
--- a/arch/v850/Kconfig
+++ b/arch/v850/Kconfig
@@ -16,6 +16,12 @@ config RWSEM_GENERIC_SPINLOCK
16config RWSEM_XCHGADD_ALGORITHM 16config RWSEM_XCHGADD_ALGORITHM
17 bool 17 bool
18 default n 18 default n
19config GENERIC_FIND_NEXT_BIT
20 bool
21 default y
22config GENERIC_HWEIGHT
23 bool
24 default y
19config GENERIC_CALIBRATE_DELAY 25config GENERIC_CALIBRATE_DELAY
20 bool 26 bool
21 default y 27 default y
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 6420baeb8c1f..4310b4a311a5 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -45,6 +45,10 @@ config RWSEM_GENERIC_SPINLOCK
45config RWSEM_XCHGADD_ALGORITHM 45config RWSEM_XCHGADD_ALGORITHM
46 bool 46 bool
47 47
48config GENERIC_HWEIGHT
49 bool
50 default y
51
48config GENERIC_CALIBRATE_DELAY 52config GENERIC_CALIBRATE_DELAY
49 bool 53 bool
50 default y 54 default y
@@ -246,6 +250,15 @@ config SCHED_SMT
246 cost of slightly increased overhead in some places. If unsure say 250 cost of slightly increased overhead in some places. If unsure say
247 N here. 251 N here.
248 252
253config SCHED_MC
254 bool "Multi-core scheduler support"
255 depends on SMP
256 default y
257 help
258 Multi-core scheduler support improves the CPU scheduler's decision
259 making when dealing with multi-core CPU chips at a cost of slightly
260 increased overhead in some places. If unsure say N here.
261
249source "kernel/Kconfig.preempt" 262source "kernel/Kconfig.preempt"
250 263
251config NUMA 264config NUMA
@@ -321,6 +334,10 @@ config HAVE_ARCH_EARLY_PFN_TO_NID
321 def_bool y 334 def_bool y
322 depends on NUMA 335 depends on NUMA
323 336
337config OUT_OF_LINE_PFN_TO_PAGE
338 def_bool y
339 depends on DISCONTIGMEM
340
324config NR_CPUS 341config NR_CPUS
325 int "Maximum number of CPUs (2-256)" 342 int "Maximum number of CPUs (2-256)"
326 range 2 255 343 range 2 255
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 0fbc0283609c..585fd4a559c8 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -70,7 +70,7 @@ drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/
70boot := arch/x86_64/boot 70boot := arch/x86_64/boot
71 71
72PHONY += bzImage bzlilo install archmrproper \ 72PHONY += bzImage bzlilo install archmrproper \
73 fdimage fdimage144 fdimage288 archclean 73 fdimage fdimage144 fdimage288 isoimage archclean
74 74
75#Default target when executing "make" 75#Default target when executing "make"
76all: bzImage 76all: bzImage
@@ -87,7 +87,7 @@ bzlilo: vmlinux
87bzdisk: vmlinux 87bzdisk: vmlinux
88 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zdisk 88 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zdisk
89 89
90fdimage fdimage144 fdimage288: vmlinux 90fdimage fdimage144 fdimage288 isoimage: vmlinux
91 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@ 91 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
92 92
93install: 93install:
@@ -99,11 +99,16 @@ archclean:
99define archhelp 99define archhelp
100 echo '* bzImage - Compressed kernel image (arch/$(ARCH)/boot/bzImage)' 100 echo '* bzImage - Compressed kernel image (arch/$(ARCH)/boot/bzImage)'
101 echo ' install - Install kernel using' 101 echo ' install - Install kernel using'
102 echo ' (your) ~/bin/installkernel or' 102 echo ' (your) ~/bin/installkernel or'
103 echo ' (distribution) /sbin/installkernel or' 103 echo ' (distribution) /sbin/installkernel or'
104 echo ' install to $$(INSTALL_PATH) and run lilo' 104 echo ' install to $$(INSTALL_PATH) and run lilo'
105 echo ' bzdisk - Create a boot floppy in /dev/fd0'
106 echo ' fdimage - Create a boot floppy image'
107 echo ' isoimage - Create a boot CD-ROM image'
105endef 108endef
106 109
107CLEAN_FILES += arch/$(ARCH)/boot/fdimage arch/$(ARCH)/boot/mtools.conf 110CLEAN_FILES += arch/$(ARCH)/boot/fdimage \
111 arch/$(ARCH)/boot/image.iso \
112 arch/$(ARCH)/boot/mtools.conf
108 113
109 114
diff --git a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile
index 29f8396ed151..43ee6c50c277 100644
--- a/arch/x86_64/boot/Makefile
+++ b/arch/x86_64/boot/Makefile
@@ -60,8 +60,12 @@ $(obj)/setup $(obj)/bootsect: %: %.o FORCE
60$(obj)/compressed/vmlinux: FORCE 60$(obj)/compressed/vmlinux: FORCE
61 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@ 61 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
62 62
63# Set this if you want to pass append arguments to the zdisk/fdimage kernel 63# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
64FDARGS = 64FDARGS =
65# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
66FDINITRD =
67
68image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
65 69
66$(obj)/mtools.conf: $(src)/mtools.conf.in 70$(obj)/mtools.conf: $(src)/mtools.conf.in
67 sed -e 's|@OBJ@|$(obj)|g' < $< > $@ 71 sed -e 's|@OBJ@|$(obj)|g' < $< > $@
@@ -70,8 +74,11 @@ $(obj)/mtools.conf: $(src)/mtools.conf.in
70zdisk: $(BOOTIMAGE) $(obj)/mtools.conf 74zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
71 MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync 75 MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
72 syslinux /dev/fd0 ; sync 76 syslinux /dev/fd0 ; sync
73 echo 'default linux $(FDARGS)' | \ 77 echo '$(image_cmdline)' | \
74 MTOOLSRC=$(obj)/mtools.conf mcopy - a:syslinux.cfg 78 MTOOLSRC=$(obj)/mtools.conf mcopy - a:syslinux.cfg
79 if [ -f '$(FDINITRD)' ] ; then \
80 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
81 fi
75 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync 82 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
76 83
77# These require being root or having syslinux 2.02 or higher installed 84# These require being root or having syslinux 2.02 or higher installed
@@ -79,18 +86,39 @@ fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
79 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440 86 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
80 MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync 87 MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
81 syslinux $(obj)/fdimage ; sync 88 syslinux $(obj)/fdimage ; sync
82 echo 'default linux $(FDARGS)' | \ 89 echo '$(image_cmdline)' | \
83 MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg 90 MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
91 if [ -f '$(FDINITRD)' ] ; then \
92 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
93 fi
84 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync 94 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
85 95
86fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf 96fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
87 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880 97 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
88 MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync 98 MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
89 syslinux $(obj)/fdimage ; sync 99 syslinux $(obj)/fdimage ; sync
90 echo 'default linux $(FDARGS)' | \ 100 echo '$(image_cmdline)' | \
91 MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg 101 MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
102 if [ -f '$(FDINITRD)' ] ; then \
103 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
104 fi
92 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync 105 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
93 106
107isoimage: $(BOOTIMAGE)
108 -rm -rf $(obj)/isoimage
109 mkdir $(obj)/isoimage
110 cp `echo /usr/lib*/syslinux/isolinux.bin | awk '{ print $1; }'` \
111 $(obj)/isoimage
112 cp $(BOOTIMAGE) $(obj)/isoimage/linux
113 echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
114 if [ -f '$(FDINITRD)' ] ; then \
115 cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
116 fi
117 mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
118 -no-emul-boot -boot-load-size 4 -boot-info-table \
119 $(obj)/isoimage
120 rm -rf $(obj)/isoimage
121
94zlilo: $(BOOTIMAGE) 122zlilo: $(BOOTIMAGE)
95 if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi 123 if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
96 if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi 124 if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 00dee176c08e..35b2faccdc6c 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -501,7 +501,7 @@ ia32_sys_call_table:
501 .quad sys_setdomainname 501 .quad sys_setdomainname
502 .quad sys_uname 502 .quad sys_uname
503 .quad sys_modify_ldt 503 .quad sys_modify_ldt
504 .quad sys32_adjtimex 504 .quad compat_sys_adjtimex
505 .quad sys32_mprotect /* 125 */ 505 .quad sys32_mprotect /* 125 */
506 .quad compat_sys_sigprocmask 506 .quad compat_sys_sigprocmask
507 .quad quiet_ni_syscall /* create_module */ 507 .quad quiet_ni_syscall /* create_module */
@@ -688,6 +688,8 @@ ia32_sys_call_table:
688 .quad sys_ni_syscall /* pselect6 for now */ 688 .quad sys_ni_syscall /* pselect6 for now */
689 .quad sys_ni_syscall /* ppoll for now */ 689 .quad sys_ni_syscall /* ppoll for now */
690 .quad sys_unshare /* 310 */ 690 .quad sys_unshare /* 310 */
691 .quad compat_sys_set_robust_list
692 .quad compat_sys_get_robust_list
691ia32_syscall_end: 693ia32_syscall_end:
692 .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8 694 .rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8
693 .quad ni_syscall 695 .quad ni_syscall
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index 2b2d029f477c..f182b20858e2 100644
--- a/arch/x86_64/ia32/sys_ia32.c
+++ b/arch/x86_64/ia32/sys_ia32.c
@@ -30,7 +30,6 @@
30#include <linux/resource.h> 30#include <linux/resource.h>
31#include <linux/times.h> 31#include <linux/times.h>
32#include <linux/utsname.h> 32#include <linux/utsname.h>
33#include <linux/timex.h>
34#include <linux/smp.h> 33#include <linux/smp.h>
35#include <linux/smp_lock.h> 34#include <linux/smp_lock.h>
36#include <linux/sem.h> 35#include <linux/sem.h>
@@ -767,82 +766,6 @@ sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
767 return ret; 766 return ret;
768} 767}
769 768
770/* Handle adjtimex compatibility. */
771
772struct timex32 {
773 u32 modes;
774 s32 offset, freq, maxerror, esterror;
775 s32 status, constant, precision, tolerance;
776 struct compat_timeval time;
777 s32 tick;
778 s32 ppsfreq, jitter, shift, stabil;
779 s32 jitcnt, calcnt, errcnt, stbcnt;
780 s32 :32; s32 :32; s32 :32; s32 :32;
781 s32 :32; s32 :32; s32 :32; s32 :32;
782 s32 :32; s32 :32; s32 :32; s32 :32;
783};
784
785extern int do_adjtimex(struct timex *);
786
787asmlinkage long
788sys32_adjtimex(struct timex32 __user *utp)
789{
790 struct timex txc;
791 int ret;
792
793 memset(&txc, 0, sizeof(struct timex));
794
795 if (!access_ok(VERIFY_READ, utp, sizeof(struct timex32)) ||
796 __get_user(txc.modes, &utp->modes) ||
797 __get_user(txc.offset, &utp->offset) ||
798 __get_user(txc.freq, &utp->freq) ||
799 __get_user(txc.maxerror, &utp->maxerror) ||
800 __get_user(txc.esterror, &utp->esterror) ||
801 __get_user(txc.status, &utp->status) ||
802 __get_user(txc.constant, &utp->constant) ||
803 __get_user(txc.precision, &utp->precision) ||
804 __get_user(txc.tolerance, &utp->tolerance) ||
805 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
806 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
807 __get_user(txc.tick, &utp->tick) ||
808 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
809 __get_user(txc.jitter, &utp->jitter) ||
810 __get_user(txc.shift, &utp->shift) ||
811 __get_user(txc.stabil, &utp->stabil) ||
812 __get_user(txc.jitcnt, &utp->jitcnt) ||
813 __get_user(txc.calcnt, &utp->calcnt) ||
814 __get_user(txc.errcnt, &utp->errcnt) ||
815 __get_user(txc.stbcnt, &utp->stbcnt))
816 return -EFAULT;
817
818 ret = do_adjtimex(&txc);
819
820 if (!access_ok(VERIFY_WRITE, utp, sizeof(struct timex32)) ||
821 __put_user(txc.modes, &utp->modes) ||
822 __put_user(txc.offset, &utp->offset) ||
823 __put_user(txc.freq, &utp->freq) ||
824 __put_user(txc.maxerror, &utp->maxerror) ||
825 __put_user(txc.esterror, &utp->esterror) ||
826 __put_user(txc.status, &utp->status) ||
827 __put_user(txc.constant, &utp->constant) ||
828 __put_user(txc.precision, &utp->precision) ||
829 __put_user(txc.tolerance, &utp->tolerance) ||
830 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
831 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
832 __put_user(txc.tick, &utp->tick) ||
833 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
834 __put_user(txc.jitter, &utp->jitter) ||
835 __put_user(txc.shift, &utp->shift) ||
836 __put_user(txc.stabil, &utp->stabil) ||
837 __put_user(txc.jitcnt, &utp->jitcnt) ||
838 __put_user(txc.calcnt, &utp->calcnt) ||
839 __put_user(txc.errcnt, &utp->errcnt) ||
840 __put_user(txc.stbcnt, &utp->stbcnt))
841 ret = -EFAULT;
842
843 return ret;
844}
845
846asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len, 769asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
847 unsigned long prot, unsigned long flags, 770 unsigned long prot, unsigned long flags,
848 unsigned long fd, unsigned long pgoff) 771 unsigned long fd, unsigned long pgoff)
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index 14f0ced613b6..accbff3fec49 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -37,10 +37,12 @@
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/preempt.h> 39#include <linux/preempt.h>
40#include <linux/module.h>
40 41
41#include <asm/cacheflush.h> 42#include <asm/cacheflush.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
43#include <asm/kdebug.h> 44#include <asm/kdebug.h>
45#include <asm/uaccess.h>
44 46
45void jprobe_return_end(void); 47void jprobe_return_end(void);
46static void __kprobes arch_copy_kprobe(struct kprobe *p); 48static void __kprobes arch_copy_kprobe(struct kprobe *p);
@@ -578,16 +580,62 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
578{ 580{
579 struct kprobe *cur = kprobe_running(); 581 struct kprobe *cur = kprobe_running();
580 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 582 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
583 const struct exception_table_entry *fixup;
581 584
582 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr)) 585 switch(kcb->kprobe_status) {
583 return 1; 586 case KPROBE_HIT_SS:
584 587 case KPROBE_REENTER:
585 if (kcb->kprobe_status & KPROBE_HIT_SS) { 588 /*
586 resume_execution(cur, regs, kcb); 589 * We are here because the instruction being single
590 * stepped caused a page fault. We reset the current
591 * kprobe and the rip points back to the probe address
592 * and allow the page fault handler to continue as a
593 * normal page fault.
594 */
595 regs->rip = (unsigned long)cur->addr;
587 regs->eflags |= kcb->kprobe_old_rflags; 596 regs->eflags |= kcb->kprobe_old_rflags;
588 597 if (kcb->kprobe_status == KPROBE_REENTER)
589 reset_current_kprobe(); 598 restore_previous_kprobe(kcb);
599 else
600 reset_current_kprobe();
590 preempt_enable_no_resched(); 601 preempt_enable_no_resched();
602 break;
603 case KPROBE_HIT_ACTIVE:
604 case KPROBE_HIT_SSDONE:
605 /*
606 * We increment the nmissed count for accounting,
607 * we can also use npre/npostfault count for accouting
608 * these specific fault cases.
609 */
610 kprobes_inc_nmissed_count(cur);
611
612 /*
613 * We come here because instructions in the pre/post
614 * handler caused the page_fault, this could happen
615 * if handler tries to access user space by
616 * copy_from_user(), get_user() etc. Let the
617 * user-specified handler try to fix it first.
618 */
619 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
620 return 1;
621
622 /*
623 * In case the user-specified fault handler returned
624 * zero, try to fix up.
625 */
626 fixup = search_exception_tables(regs->rip);
627 if (fixup) {
628 regs->rip = fixup->fixup;
629 return 1;
630 }
631
632 /*
633 * fixup() could not handle it,
634 * Let do_page_fault() fix it.
635 */
636 break;
637 default:
638 break;
591 } 639 }
592 return 0; 640 return 0;
593} 641}
@@ -601,6 +649,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
601 struct die_args *args = (struct die_args *)data; 649 struct die_args *args = (struct die_args *)data;
602 int ret = NOTIFY_DONE; 650 int ret = NOTIFY_DONE;
603 651
652 if (args->regs && user_mode(args->regs))
653 return ret;
654
604 switch (val) { 655 switch (val) {
605 case DIE_INT3: 656 case DIE_INT3:
606 if (kprobe_handler(args->regs)) 657 if (kprobe_handler(args->regs))
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 81111835722d..70dd8e5c6889 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -35,8 +35,8 @@
35#include <linux/ptrace.h> 35#include <linux/ptrace.h>
36#include <linux/utsname.h> 36#include <linux/utsname.h>
37#include <linux/random.h> 37#include <linux/random.h>
38#include <linux/kprobes.h>
39#include <linux/notifier.h> 38#include <linux/notifier.h>
39#include <linux/kprobes.h>
40 40
41#include <asm/uaccess.h> 41#include <asm/uaccess.h>
42#include <asm/pgtable.h> 42#include <asm/pgtable.h>
@@ -66,24 +66,17 @@ EXPORT_SYMBOL(boot_option_idle_override);
66void (*pm_idle)(void); 66void (*pm_idle)(void);
67static DEFINE_PER_CPU(unsigned int, cpu_idle_state); 67static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
68 68
69static struct notifier_block *idle_notifier; 69static ATOMIC_NOTIFIER_HEAD(idle_notifier);
70static DEFINE_SPINLOCK(idle_notifier_lock);
71 70
72void idle_notifier_register(struct notifier_block *n) 71void idle_notifier_register(struct notifier_block *n)
73{ 72{
74 unsigned long flags; 73 atomic_notifier_chain_register(&idle_notifier, n);
75 spin_lock_irqsave(&idle_notifier_lock, flags);
76 notifier_chain_register(&idle_notifier, n);
77 spin_unlock_irqrestore(&idle_notifier_lock, flags);
78} 74}
79EXPORT_SYMBOL_GPL(idle_notifier_register); 75EXPORT_SYMBOL_GPL(idle_notifier_register);
80 76
81void idle_notifier_unregister(struct notifier_block *n) 77void idle_notifier_unregister(struct notifier_block *n)
82{ 78{
83 unsigned long flags; 79 atomic_notifier_chain_unregister(&idle_notifier, n);
84 spin_lock_irqsave(&idle_notifier_lock, flags);
85 notifier_chain_unregister(&idle_notifier, n);
86 spin_unlock_irqrestore(&idle_notifier_lock, flags);
87} 80}
88EXPORT_SYMBOL(idle_notifier_unregister); 81EXPORT_SYMBOL(idle_notifier_unregister);
89 82
@@ -93,13 +86,13 @@ static DEFINE_PER_CPU(enum idle_state, idle_state) = CPU_NOT_IDLE;
93void enter_idle(void) 86void enter_idle(void)
94{ 87{
95 __get_cpu_var(idle_state) = CPU_IDLE; 88 __get_cpu_var(idle_state) = CPU_IDLE;
96 notifier_call_chain(&idle_notifier, IDLE_START, NULL); 89 atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL);
97} 90}
98 91
99static void __exit_idle(void) 92static void __exit_idle(void)
100{ 93{
101 __get_cpu_var(idle_state) = CPU_NOT_IDLE; 94 __get_cpu_var(idle_state) = CPU_NOT_IDLE;
102 notifier_call_chain(&idle_notifier, IDLE_END, NULL); 95 atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL);
103} 96}
104 97
105/* Called from interrupts to signify idle end */ 98/* Called from interrupts to signify idle end */
@@ -353,13 +346,6 @@ void exit_thread(void)
353 struct task_struct *me = current; 346 struct task_struct *me = current;
354 struct thread_struct *t = &me->thread; 347 struct thread_struct *t = &me->thread;
355 348
356 /*
357 * Remove function-return probe instances associated with this task
358 * and put them back on the free list. Do not insert an exit probe for
359 * this function, it will be disabled by kprobe_flush_task if you do.
360 */
361 kprobe_flush_task(me);
362
363 if (me->thread.io_bitmap_ptr) { 349 if (me->thread.io_bitmap_ptr) {
364 struct tss_struct *tss = &per_cpu(init_tss, get_cpu()); 350 struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
365 351
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index a57eec8311a7..d1f3e9272c05 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -962,7 +962,6 @@ static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
962 962
963 cpuid(1, &eax, &ebx, &ecx, &edx); 963 cpuid(1, &eax, &ebx, &ecx, &edx);
964 964
965 c->apicid = phys_pkg_id(0);
966 965
967 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)) 966 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
968 return; 967 return;
@@ -1171,6 +1170,8 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
1171 c->x86_capability[2] = cpuid_edx(0x80860001); 1170 c->x86_capability[2] = cpuid_edx(0x80860001);
1172 } 1171 }
1173 1172
1173 c->apicid = phys_pkg_id(0);
1174
1174 /* 1175 /*
1175 * Vendor-specific initialization. In this section we 1176 * Vendor-specific initialization. In this section we
1176 * canonicalize the feature flags, meaning if there are 1177 * canonicalize the feature flags, meaning if there are
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 66e98659d077..ea48fa638070 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -68,6 +68,9 @@ u8 phys_proc_id[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID };
68/* core ID of each logical CPU */ 68/* core ID of each logical CPU */
69u8 cpu_core_id[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID }; 69u8 cpu_core_id[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID };
70 70
71/* Last level cache ID of each logical CPU */
72u8 cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID};
73
71/* Bitmask of currently online CPUs */ 74/* Bitmask of currently online CPUs */
72cpumask_t cpu_online_map __read_mostly; 75cpumask_t cpu_online_map __read_mostly;
73 76
@@ -445,6 +448,18 @@ void __cpuinit smp_callin(void)
445 cpu_set(cpuid, cpu_callin_map); 448 cpu_set(cpuid, cpu_callin_map);
446} 449}
447 450
451/* maps the cpu to the sched domain representing multi-core */
452cpumask_t cpu_coregroup_map(int cpu)
453{
454 struct cpuinfo_x86 *c = cpu_data + cpu;
455 /*
456 * For perf, we return last level cache shared map.
457 * TBD: when power saving sched policy is added, we will return
458 * cpu_core_map when power saving policy is enabled
459 */
460 return c->llc_shared_map;
461}
462
448/* representing cpus for which sibling maps can be computed */ 463/* representing cpus for which sibling maps can be computed */
449static cpumask_t cpu_sibling_setup_map; 464static cpumask_t cpu_sibling_setup_map;
450 465
@@ -463,12 +478,16 @@ static inline void set_cpu_sibling_map(int cpu)
463 cpu_set(cpu, cpu_sibling_map[i]); 478 cpu_set(cpu, cpu_sibling_map[i]);
464 cpu_set(i, cpu_core_map[cpu]); 479 cpu_set(i, cpu_core_map[cpu]);
465 cpu_set(cpu, cpu_core_map[i]); 480 cpu_set(cpu, cpu_core_map[i]);
481 cpu_set(i, c[cpu].llc_shared_map);
482 cpu_set(cpu, c[i].llc_shared_map);
466 } 483 }
467 } 484 }
468 } else { 485 } else {
469 cpu_set(cpu, cpu_sibling_map[cpu]); 486 cpu_set(cpu, cpu_sibling_map[cpu]);
470 } 487 }
471 488
489 cpu_set(cpu, c[cpu].llc_shared_map);
490
472 if (current_cpu_data.x86_max_cores == 1) { 491 if (current_cpu_data.x86_max_cores == 1) {
473 cpu_core_map[cpu] = cpu_sibling_map[cpu]; 492 cpu_core_map[cpu] = cpu_sibling_map[cpu];
474 c[cpu].booted_cores = 1; 493 c[cpu].booted_cores = 1;
@@ -476,6 +495,11 @@ static inline void set_cpu_sibling_map(int cpu)
476 } 495 }
477 496
478 for_each_cpu_mask(i, cpu_sibling_setup_map) { 497 for_each_cpu_mask(i, cpu_sibling_setup_map) {
498 if (cpu_llc_id[cpu] != BAD_APICID &&
499 cpu_llc_id[cpu] == cpu_llc_id[i]) {
500 cpu_set(i, c[cpu].llc_shared_map);
501 cpu_set(cpu, c[i].llc_shared_map);
502 }
479 if (phys_proc_id[cpu] == phys_proc_id[i]) { 503 if (phys_proc_id[cpu] == phys_proc_id[i]) {
480 cpu_set(i, cpu_core_map[cpu]); 504 cpu_set(i, cpu_core_map[cpu]);
481 cpu_set(cpu, cpu_core_map[i]); 505 cpu_set(cpu, cpu_core_map[i]);
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 7f58fa682491..473b514b66e4 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -504,42 +504,25 @@ unsigned long long sched_clock(void)
504 504
505static unsigned long get_cmos_time(void) 505static unsigned long get_cmos_time(void)
506{ 506{
507 unsigned int timeout = 1000000, year, mon, day, hour, min, sec; 507 unsigned int year, mon, day, hour, min, sec;
508 unsigned char uip = 0, this = 0;
509 unsigned long flags; 508 unsigned long flags;
510 unsigned extyear = 0; 509 unsigned extyear = 0;
511 510
512/*
513 * The Linux interpretation of the CMOS clock register contents: When the
514 * Update-In-Progress (UIP) flag goes from 1 to 0, the RTC registers show the
515 * second which has precisely just started. Waiting for this can take up to 1
516 * second, we timeout approximately after 2.4 seconds on a machine with
517 * standard 8.3 MHz ISA bus.
518 */
519
520 spin_lock_irqsave(&rtc_lock, flags); 511 spin_lock_irqsave(&rtc_lock, flags);
521 512
522 while (timeout && (!uip || this)) { 513 do {
523 uip |= this; 514 sec = CMOS_READ(RTC_SECONDS);
524 this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP; 515 min = CMOS_READ(RTC_MINUTES);
525 timeout--; 516 hour = CMOS_READ(RTC_HOURS);
526 } 517 day = CMOS_READ(RTC_DAY_OF_MONTH);
527 518 mon = CMOS_READ(RTC_MONTH);
528 /* 519 year = CMOS_READ(RTC_YEAR);
529 * Here we are safe to assume the registers won't change for a whole
530 * second, so we just go ahead and read them.
531 */
532 sec = CMOS_READ(RTC_SECONDS);
533 min = CMOS_READ(RTC_MINUTES);
534 hour = CMOS_READ(RTC_HOURS);
535 day = CMOS_READ(RTC_DAY_OF_MONTH);
536 mon = CMOS_READ(RTC_MONTH);
537 year = CMOS_READ(RTC_YEAR);
538
539#ifdef CONFIG_ACPI 520#ifdef CONFIG_ACPI
540 if (acpi_fadt.revision >= FADT2_REVISION_ID && acpi_fadt.century) 521 if (acpi_fadt.revision >= FADT2_REVISION_ID &&
541 extyear = CMOS_READ(acpi_fadt.century); 522 acpi_fadt.century)
523 extyear = CMOS_READ(acpi_fadt.century);
542#endif 524#endif
525 } while (sec != CMOS_READ(RTC_SECONDS));
543 526
544 spin_unlock_irqrestore(&rtc_lock, flags); 527 spin_unlock_irqrestore(&rtc_lock, flags);
545 528
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 7b148309c529..edaa9fe654dc 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -69,20 +69,20 @@ asmlinkage void alignment_check(void);
69asmlinkage void machine_check(void); 69asmlinkage void machine_check(void);
70asmlinkage void spurious_interrupt_bug(void); 70asmlinkage void spurious_interrupt_bug(void);
71 71
72struct notifier_block *die_chain; 72ATOMIC_NOTIFIER_HEAD(die_chain);
73static DEFINE_SPINLOCK(die_notifier_lock);
74 73
75int register_die_notifier(struct notifier_block *nb) 74int register_die_notifier(struct notifier_block *nb)
76{ 75{
77 int err = 0;
78 unsigned long flags;
79
80 vmalloc_sync_all(); 76 vmalloc_sync_all();
81 spin_lock_irqsave(&die_notifier_lock, flags); 77 return atomic_notifier_chain_register(&die_chain, nb);
82 err = notifier_chain_register(&die_chain, nb); 78}
83 spin_unlock_irqrestore(&die_notifier_lock, flags); 79EXPORT_SYMBOL(register_die_notifier);
84 return err; 80
81int unregister_die_notifier(struct notifier_block *nb)
82{
83 return atomic_notifier_chain_unregister(&die_chain, nb);
85} 84}
85EXPORT_SYMBOL(unregister_die_notifier);
86 86
87static inline void conditional_sti(struct pt_regs *regs) 87static inline void conditional_sti(struct pt_regs *regs)
88{ 88{
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index b04415625442..e5f7f1c34462 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -72,7 +72,7 @@ void show_mem(void)
72 show_free_areas(); 72 show_free_areas();
73 printk(KERN_INFO "Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 73 printk(KERN_INFO "Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
74 74
75 for_each_pgdat(pgdat) { 75 for_each_online_pgdat(pgdat) {
76 for (i = 0; i < pgdat->node_spanned_pages; ++i) { 76 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
77 page = pfn_to_page(pgdat->node_start_pfn + i); 77 page = pfn_to_page(pgdat->node_start_pfn + i);
78 total++; 78 total++;
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 63c72641b737..4be82d6e2b48 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -377,21 +377,6 @@ EXPORT_SYMBOL(node_data);
377 * Should do that. 377 * Should do that.
378 */ 378 */
379 379
380/* Requires pfn_valid(pfn) to be true */
381struct page *pfn_to_page(unsigned long pfn)
382{
383 int nid = phys_to_nid(((unsigned long)(pfn)) << PAGE_SHIFT);
384 return (pfn - node_start_pfn(nid)) + NODE_DATA(nid)->node_mem_map;
385}
386EXPORT_SYMBOL(pfn_to_page);
387
388unsigned long page_to_pfn(struct page *page)
389{
390 return (long)(((page) - page_zone(page)->zone_mem_map) +
391 page_zone(page)->zone_start_pfn);
392}
393EXPORT_SYMBOL(page_to_pfn);
394
395int pfn_valid(unsigned long pfn) 380int pfn_valid(unsigned long pfn)
396{ 381{
397 unsigned nid; 382 unsigned nid;
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index e90ef5db8913..dbeb3504c3c8 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -22,6 +22,14 @@ config RWSEM_XCHGADD_ALGORITHM
22 bool 22 bool
23 default y 23 default y
24 24
25config GENERIC_FIND_NEXT_BIT
26 bool
27 default y
28
29config GENERIC_HWEIGHT
30 bool
31 default y
32
25config GENERIC_HARDIRQS 33config GENERIC_HARDIRQS
26 bool 34 bool
27 default y 35 default y
diff --git a/arch/xtensa/platform-iss/setup.c b/arch/xtensa/platform-iss/setup.c
index 2e6dcbf0cc04..23790a5610e2 100644
--- a/arch/xtensa/platform-iss/setup.c
+++ b/arch/xtensa/platform-iss/setup.c
@@ -108,5 +108,5 @@ static struct notifier_block iss_panic_block = {
108 108
109void __init platform_setup(char **p_cmdline) 109void __init platform_setup(char **p_cmdline)
110{ 110{
111 notifier_chain_register(&panic_notifier_list, &iss_panic_block); 111 atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
112} 112}