aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/kernel/entry-armv.S7
-rw-r--r--arch/arm/lib/bitops.h4
-rw-r--r--arch/arm/mach-s3c2410/usb-simtec.c18
-rw-r--r--arch/arm/mm/mm-armv.c17
-rw-r--r--arch/arm/mm/proc-v6.S22
-rw-r--r--arch/ia64/kernel/domain.c2
-rw-r--r--arch/ia64/kernel/process.c2
-rw-r--r--arch/ppc64/kernel/LparData.c79
-rw-r--r--arch/ppc64/kernel/Makefile5
-rw-r--r--arch/ppc64/kernel/head.S6
-rw-r--r--arch/ppc64/kernel/lparmap.c31
-rw-r--r--arch/ppc64/kernel/prom_init.c2
-rw-r--r--arch/sparc64/solaris/socket.c193
-rw-r--r--arch/x86_64/kernel/smpboot.c2
14 files changed, 211 insertions, 179 deletions
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 39a6c1b0b9a3..7152bfbee581 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -533,6 +533,13 @@ ENTRY(__switch_to)
533 ldr r3, [r2, #TI_TP_VALUE] 533 ldr r3, [r2, #TI_TP_VALUE]
534 stmia ip!, {r4 - sl, fp, sp, lr} @ Store most regs on stack 534 stmia ip!, {r4 - sl, fp, sp, lr} @ Store most regs on stack
535 ldr r6, [r2, #TI_CPU_DOMAIN]! 535 ldr r6, [r2, #TI_CPU_DOMAIN]!
536#if __LINUX_ARM_ARCH__ >= 6
537#ifdef CONFIG_CPU_MPCORE
538 clrex
539#else
540 strex r3, r4, [ip] @ Clear exclusive monitor
541#endif
542#endif
536#if defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_IWMMXT) 543#if defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_IWMMXT)
537 mra r4, r5, acc0 544 mra r4, r5, acc0
538 stmia ip, {r4, r5} 545 stmia ip, {r4, r5}
diff --git a/arch/arm/lib/bitops.h b/arch/arm/lib/bitops.h
index 2036ff15bda9..64a988c1ad44 100644
--- a/arch/arm/lib/bitops.h
+++ b/arch/arm/lib/bitops.h
@@ -1,4 +1,6 @@
1#if __LINUX_ARM_ARCH__ >= 6 1#include <linux/config.h>
2
3#if __LINUX_ARM_ARCH__ >= 6 && defined(CONFIG_CPU_MPCORE)
2 .macro bitop, instr 4 .macro bitop, instr
3 mov r2, #1 5 mov r2, #1
4 and r3, r0, #7 @ Get bit offset 6 and r3, r0, #7 @ Get bit offset
diff --git a/arch/arm/mach-s3c2410/usb-simtec.c b/arch/arm/mach-s3c2410/usb-simtec.c
index 7f2b61362976..f021fd82be52 100644
--- a/arch/arm/mach-s3c2410/usb-simtec.c
+++ b/arch/arm/mach-s3c2410/usb-simtec.c
@@ -1,6 +1,6 @@
1/* linux/arch/arm/mach-s3c2410/usb-simtec.c 1/* linux/arch/arm/mach-s3c2410/usb-simtec.c
2 * 2 *
3 * Copyright (c) 2004 Simtec Electronics 3 * Copyright (c) 2004,2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 4 * Ben Dooks <ben@simtec.co.uk>
5 * 5 *
6 * http://www.simtec.co.uk/products/EB2410ITX/ 6 * http://www.simtec.co.uk/products/EB2410ITX/
@@ -14,6 +14,8 @@
14 * Modifications: 14 * Modifications:
15 * 14-Sep-2004 BJD Created 15 * 14-Sep-2004 BJD Created
16 * 18-Oct-2004 BJD Cleanups, and added code to report OC cleared 16 * 18-Oct-2004 BJD Cleanups, and added code to report OC cleared
17 * 09-Aug-2005 BJD Renamed s3c2410_report_oc to s3c2410_usb_report_oc
18 * 09-Aug-2005 BJD Ports powered only if both are enabled
17*/ 19*/
18 20
19#define DEBUG 21#define DEBUG
@@ -47,13 +49,19 @@
47 * designed boards. 49 * designed boards.
48*/ 50*/
49 51
52static unsigned int power_state[2];
53
50static void 54static void
51usb_simtec_powercontrol(int port, int to) 55usb_simtec_powercontrol(int port, int to)
52{ 56{
53 pr_debug("usb_simtec_powercontrol(%d,%d)\n", port, to); 57 pr_debug("usb_simtec_powercontrol(%d,%d)\n", port, to);
54 58
55 if (port == 1) 59 power_state[port] = to;
56 s3c2410_gpio_setpin(S3C2410_GPB4, to ? 0:1); 60
61 if (power_state[0] && power_state[1])
62 s3c2410_gpio_setpin(S3C2410_GPB4, 0);
63 else
64 s3c2410_gpio_setpin(S3C2410_GPB4, 1);
57} 65}
58 66
59static irqreturn_t 67static irqreturn_t
@@ -63,10 +71,10 @@ usb_simtec_ocirq(int irq, void *pw, struct pt_regs *regs)
63 71
64 if (s3c2410_gpio_getpin(S3C2410_GPG10) == 0) { 72 if (s3c2410_gpio_getpin(S3C2410_GPG10) == 0) {
65 pr_debug("usb_simtec: over-current irq (oc detected)\n"); 73 pr_debug("usb_simtec: over-current irq (oc detected)\n");
66 s3c2410_report_oc(info, 3); 74 s3c2410_usb_report_oc(info, 3);
67 } else { 75 } else {
68 pr_debug("usb_simtec: over-current irq (oc cleared)\n"); 76 pr_debug("usb_simtec: over-current irq (oc cleared)\n");
69 s3c2410_report_oc(info, 0); 77 s3c2410_usb_report_oc(info, 0);
70 } 78 }
71 79
72 return IRQ_HANDLED; 80 return IRQ_HANDLED;
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index e33fe4229d05..3c655c54e231 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -383,6 +383,7 @@ static void __init build_mem_type_table(void)
383{ 383{
384 struct cachepolicy *cp; 384 struct cachepolicy *cp;
385 unsigned int cr = get_cr(); 385 unsigned int cr = get_cr();
386 unsigned int user_pgprot;
386 int cpu_arch = cpu_architecture(); 387 int cpu_arch = cpu_architecture();
387 int i; 388 int i;
388 389
@@ -408,6 +409,9 @@ static void __init build_mem_type_table(void)
408 } 409 }
409 } 410 }
410 411
412 cp = &cache_policies[cachepolicy];
413 user_pgprot = cp->pte;
414
411 /* 415 /*
412 * ARMv6 and above have extended page tables. 416 * ARMv6 and above have extended page tables.
413 */ 417 */
@@ -426,11 +430,18 @@ static void __init build_mem_type_table(void)
426 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE; 430 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
427 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE; 431 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
428 432
433 /*
434 * Mark the device area as "shared device"
435 */
429 mem_types[MT_DEVICE].prot_pte |= L_PTE_BUFFERABLE; 436 mem_types[MT_DEVICE].prot_pte |= L_PTE_BUFFERABLE;
430 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_BUFFERED; 437 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_BUFFERED;
431 }
432 438
433 cp = &cache_policies[cachepolicy]; 439 /*
440 * User pages need to be mapped with the ASID
441 * (iow, non-global)
442 */
443 user_pgprot |= L_PTE_ASID;
444 }
434 445
435 if (cpu_arch >= CPU_ARCH_ARMv5) { 446 if (cpu_arch >= CPU_ARCH_ARMv5) {
436 mem_types[MT_LOW_VECTORS].prot_pte |= cp->pte & PTE_CACHEABLE; 447 mem_types[MT_LOW_VECTORS].prot_pte |= cp->pte & PTE_CACHEABLE;
@@ -448,7 +459,7 @@ static void __init build_mem_type_table(void)
448 459
449 for (i = 0; i < 16; i++) { 460 for (i = 0; i < 16; i++) {
450 unsigned long v = pgprot_val(protection_map[i]); 461 unsigned long v = pgprot_val(protection_map[i]);
451 v &= (~(PTE_BUFFERABLE|PTE_CACHEABLE)) | cp->pte; 462 v &= (~(PTE_BUFFERABLE|PTE_CACHEABLE)) | user_pgprot;
452 protection_map[i] = __pgprot(v); 463 protection_map[i] = __pgprot(v);
453 } 464 }
454 465
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 352db98ee269..3429ddcf65d1 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -111,12 +111,6 @@ ENTRY(cpu_v6_switch_mm)
111 mcr p15, 0, r1, c13, c0, 1 @ set context ID 111 mcr p15, 0, r1, c13, c0, 1 @ set context ID
112 mov pc, lr 112 mov pc, lr
113 113
114#define nG (1 << 11)
115#define APX (1 << 9)
116#define AP1 (1 << 5)
117#define AP0 (1 << 4)
118#define XN (1 << 0)
119
120/* 114/*
121 * cpu_v6_set_pte(ptep, pte) 115 * cpu_v6_set_pte(ptep, pte)
122 * 116 *
@@ -139,24 +133,24 @@ ENTRY(cpu_v6_switch_mm)
139ENTRY(cpu_v6_set_pte) 133ENTRY(cpu_v6_set_pte)
140 str r1, [r0], #-2048 @ linux version 134 str r1, [r0], #-2048 @ linux version
141 135
142 bic r2, r1, #0x00000ff0 136 bic r2, r1, #0x000007f0
143 bic r2, r2, #0x00000003 137 bic r2, r2, #0x00000003
144 orr r2, r2, #AP0 | 2 138 orr r2, r2, #PTE_EXT_AP0 | 2
145 139
146 tst r1, #L_PTE_WRITE 140 tst r1, #L_PTE_WRITE
147 tstne r1, #L_PTE_DIRTY 141 tstne r1, #L_PTE_DIRTY
148 orreq r2, r2, #APX 142 orreq r2, r2, #PTE_EXT_APX
149 143
150 tst r1, #L_PTE_USER 144 tst r1, #L_PTE_USER
151 orrne r2, r2, #AP1 | nG 145 orrne r2, r2, #PTE_EXT_AP1
152 tstne r2, #APX 146 tstne r2, #PTE_EXT_APX
153 bicne r2, r2, #APX | AP0 147 bicne r2, r2, #PTE_EXT_APX | PTE_EXT_AP0
154 148
155 tst r1, #L_PTE_YOUNG 149 tst r1, #L_PTE_YOUNG
156 biceq r2, r2, #APX | AP1 | AP0 150 biceq r2, r2, #PTE_EXT_APX | PTE_EXT_AP_MASK
157 151
158@ tst r1, #L_PTE_EXEC 152@ tst r1, #L_PTE_EXEC
159@ orreq r2, r2, #XN 153@ orreq r2, r2, #PTE_EXT_XN
160 154
161 tst r1, #L_PTE_PRESENT 155 tst r1, #L_PTE_PRESENT
162 moveq r2, #0 156 moveq r2, #0
diff --git a/arch/ia64/kernel/domain.c b/arch/ia64/kernel/domain.c
index d65e87b6394f..bbb8efe126b7 100644
--- a/arch/ia64/kernel/domain.c
+++ b/arch/ia64/kernel/domain.c
@@ -341,7 +341,7 @@ next_sg:
341#endif 341#endif
342 342
343 /* Attach the domains */ 343 /* Attach the domains */
344 for_each_online_cpu(i) { 344 for_each_cpu_mask(i, *cpu_map) {
345 struct sched_domain *sd; 345 struct sched_domain *sd;
346#ifdef CONFIG_SCHED_SMT 346#ifdef CONFIG_SCHED_SMT
347 sd = &per_cpu(cpu_domains, i); 347 sd = &per_cpu(cpu_domains, i);
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 66e840609808..051e050359e4 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -179,7 +179,7 @@ static int can_do_pal_halt = 1;
179 179
180static int __init nohalt_setup(char * str) 180static int __init nohalt_setup(char * str)
181{ 181{
182 pal_halt = 0; 182 pal_halt = can_do_pal_halt = 0;
183 return 1; 183 return 1;
184} 184}
185__setup("nohalt", nohalt_setup); 185__setup("nohalt", nohalt_setup);
diff --git a/arch/ppc64/kernel/LparData.c b/arch/ppc64/kernel/LparData.c
index 76cfd1449d52..1c11031c838e 100644
--- a/arch/ppc64/kernel/LparData.c
+++ b/arch/ppc64/kernel/LparData.c
@@ -32,32 +32,12 @@
32/* The HvReleaseData is the root of the information shared between 32/* The HvReleaseData is the root of the information shared between
33 * the hypervisor and Linux. 33 * the hypervisor and Linux.
34 */ 34 */
35
36/*
37 * WARNING - magic here
38 *
39 * Ok, this is a horrid hack below, but marginally better than the
40 * alternatives. What we really want is just to initialize
41 * hvReleaseData in C as in the #if 0 section here. However, gcc
42 * refuses to believe that (u32)&x is a constant expression, so will
43 * not allow the xMsNucDataOffset field to be properly initialized.
44 * So, we declare hvReleaseData in inline asm instead. We use inline
45 * asm, rather than a .S file, because the assembler won't generate
46 * the necessary relocation for the LparMap either, unless that symbol
47 * is declared in the same source file. Finally, we put the asm in a
48 * dummy, attribute-used function, instead of at file scope, because
49 * file scope asms don't allow contraints. We want to use the "i"
50 * constraints to put sizeof() and offsetof() expressions in there,
51 * because including asm/offsets.h in C code then stringifying causes
52 * all manner of warnings.
53 */
54#if 0
55struct HvReleaseData hvReleaseData = { 35struct HvReleaseData hvReleaseData = {
56 .xDesc = 0xc8a5d9c4, /* "HvRD" ebcdic */ 36 .xDesc = 0xc8a5d9c4, /* "HvRD" ebcdic */
57 .xSize = sizeof(struct HvReleaseData), 37 .xSize = sizeof(struct HvReleaseData),
58 .xVpdAreasPtrOffset = offsetof(struct naca_struct, xItVpdAreas), 38 .xVpdAreasPtrOffset = offsetof(struct naca_struct, xItVpdAreas),
59 .xSlicNacaAddr = &naca, /* 64-bit Naca address */ 39 .xSlicNacaAddr = &naca, /* 64-bit Naca address */
60 .xMsNucDataOffset = (u32)((unsigned long)&xLparMap - KERNELBASE), 40 .xMsNucDataOffset = LPARMAP_PHYS,
61 .xFlags = HVREL_TAGSINACTIVE /* tags inactive */ 41 .xFlags = HVREL_TAGSINACTIVE /* tags inactive */
62 /* 64 bit */ 42 /* 64 bit */
63 /* shared processors */ 43 /* shared processors */
@@ -70,63 +50,6 @@ struct HvReleaseData hvReleaseData = {
70 0xa7, 0x40, 0xf2, 0x4b, 50 0xa7, 0x40, 0xf2, 0x4b,
71 0xf4, 0x4b, 0xf6, 0xf4 }, 51 0xf4, 0x4b, 0xf6, 0xf4 },
72}; 52};
73#endif
74
75
76extern struct HvReleaseData hvReleaseData;
77
78static void __attribute_used__ hvReleaseData_wrapper(void)
79{
80 /* This doesn't appear to need any alignment (even 4 byte) */
81 asm volatile (
82 " lparMapPhys = xLparMap - %3\n"
83 " .data\n"
84 " .globl hvReleaseData\n"
85 "hvReleaseData:\n"
86 " .long 0xc8a5d9c4\n" /* xDesc */
87 /* "HvRD" in ebcdic */
88 " .short %0\n" /* xSize */
89 " .short %1\n" /* xVpdAreasPtrOffset */
90 " .llong naca\n" /* xSlicNacaAddr */
91 " .long lparMapPhys\n" /* xMsNucDataOffset */
92 " .long 0\n" /* xRsvd1 */
93 " .short %2\n" /* xFlags */
94 " .short 4\n" /* xVrmIndex - v5r2m0 */
95 " .short 3\n" /* xMinSupportedPlicVrmIndex - v5r1m0 */
96 " .short 3\n" /* xMinCompatablePlicVrmIndex - v5r1m0 */
97 " .long 0xd38995a4\n" /* xVrmName */
98 " .long 0xa740f24b\n" /* "Linux 2.4.64" ebcdic */
99 " .long 0xf44bf6f4\n"
100 " . = hvReleaseData + %0\n"
101 " .previous\n"
102 : : "i"(sizeof(hvReleaseData)),
103 "i"(offsetof(struct naca_struct, xItVpdAreas)),
104 "i"(HVREL_TAGSINACTIVE /* tags inactive, 64 bit, */
105 /* shared processors, HMT allowed */
106 | 6), /* TEMP: This allows non-GA drivers */
107 "i"(KERNELBASE)
108 );
109}
110
111struct LparMap __attribute__((aligned (16))) xLparMap = {
112 .xNumberEsids = HvEsidsToMap,
113 .xNumberRanges = HvRangesToMap,
114 .xSegmentTableOffs = STAB0_PAGE,
115
116 .xEsids = {
117 { .xKernelEsid = GET_ESID(KERNELBASE),
118 .xKernelVsid = KERNEL_VSID(KERNELBASE), },
119 { .xKernelEsid = GET_ESID(VMALLOCBASE),
120 .xKernelVsid = KERNEL_VSID(VMALLOCBASE), },
121 },
122
123 .xRanges = {
124 { .xPages = HvPagesToMap,
125 .xOffset = 0,
126 .xVPN = KERNEL_VSID(KERNELBASE) << (SID_SHIFT - PAGE_SHIFT),
127 },
128 },
129};
130 53
131extern void system_reset_iSeries(void); 54extern void system_reset_iSeries(void);
132extern void machine_check_iSeries(void); 55extern void machine_check_iSeries(void);
diff --git a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile
index d9b2660ef221..2ecccb6b4f8c 100644
--- a/arch/ppc64/kernel/Makefile
+++ b/arch/ppc64/kernel/Makefile
@@ -73,3 +73,8 @@ obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o
73obj-$(CONFIG_KPROBES) += kprobes.o 73obj-$(CONFIG_KPROBES) += kprobes.o
74 74
75CFLAGS_ioctl32.o += -Ifs/ 75CFLAGS_ioctl32.o += -Ifs/
76
77ifeq ($(CONFIG_PPC_ISERIES),y)
78arch/ppc64/kernel/head.o: arch/ppc64/kernel/lparmap.s
79AFLAGS_head.o += -Iarch/ppc64/kernel
80endif
diff --git a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S
index 784f56d4684c..accaa052d31f 100644
--- a/arch/ppc64/kernel/head.S
+++ b/arch/ppc64/kernel/head.S
@@ -38,6 +38,7 @@
38#include <asm/cputable.h> 38#include <asm/cputable.h>
39#include <asm/setup.h> 39#include <asm/setup.h>
40#include <asm/hvcall.h> 40#include <asm/hvcall.h>
41#include <asm/iSeries/LparMap.h>
41 42
42#ifdef CONFIG_PPC_ISERIES 43#ifdef CONFIG_PPC_ISERIES
43#define DO_SOFT_DISABLE 44#define DO_SOFT_DISABLE
@@ -679,6 +680,11 @@ hardware_interrupt_iSeries_masked:
679 .globl fwnmi_data_area 680 .globl fwnmi_data_area
680fwnmi_data_area: 681fwnmi_data_area:
681 682
683#ifdef CONFIG_PPC_ISERIES
684 . = LPARMAP_PHYS
685#include "lparmap.s"
686#endif /* CONFIG_PPC_ISERIES */
687
682/* 688/*
683 * Vectors for the FWNMI option. Share common code. 689 * Vectors for the FWNMI option. Share common code.
684 */ 690 */
diff --git a/arch/ppc64/kernel/lparmap.c b/arch/ppc64/kernel/lparmap.c
new file mode 100644
index 000000000000..b81de286df5e
--- /dev/null
+++ b/arch/ppc64/kernel/lparmap.c
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2005 Stephen Rothwell IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#include <asm/mmu.h>
10#include <asm/page.h>
11#include <asm/iSeries/LparMap.h>
12
13const struct LparMap __attribute__((__section__(".text"))) xLparMap = {
14 .xNumberEsids = HvEsidsToMap,
15 .xNumberRanges = HvRangesToMap,
16 .xSegmentTableOffs = STAB0_PAGE,
17
18 .xEsids = {
19 { .xKernelEsid = GET_ESID(KERNELBASE),
20 .xKernelVsid = KERNEL_VSID(KERNELBASE), },
21 { .xKernelEsid = GET_ESID(VMALLOCBASE),
22 .xKernelVsid = KERNEL_VSID(VMALLOCBASE), },
23 },
24
25 .xRanges = {
26 { .xPages = HvPagesToMap,
27 .xOffset = 0,
28 .xVPN = KERNEL_VSID(KERNELBASE) << (SID_SHIFT - PAGE_SHIFT),
29 },
30 },
31};
diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c
index e248a7950aeb..dbbe6c79d8da 100644
--- a/arch/ppc64/kernel/prom_init.c
+++ b/arch/ppc64/kernel/prom_init.c
@@ -1803,7 +1803,7 @@ static void __init fixup_device_tree(void)
1803 if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev)) 1803 if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev))
1804 == PROM_ERROR) 1804 == PROM_ERROR)
1805 return; 1805 return;
1806 if (u3_rev != 0x35) 1806 if (u3_rev != 0x35 && u3_rev != 0x37)
1807 return; 1807 return;
1808 /* does it need fixup ? */ 1808 /* does it need fixup ? */
1809 if (prom_getproplen(i2c, "interrupts") > 0) 1809 if (prom_getproplen(i2c, "interrupts") > 0)
diff --git a/arch/sparc64/solaris/socket.c b/arch/sparc64/solaris/socket.c
index 06740582717e..d3a66ea74a7f 100644
--- a/arch/sparc64/solaris/socket.c
+++ b/arch/sparc64/solaris/socket.c
@@ -16,6 +16,7 @@
16#include <linux/net.h> 16#include <linux/net.h>
17#include <linux/compat.h> 17#include <linux/compat.h>
18#include <net/compat.h> 18#include <net/compat.h>
19#include <net/sock.h>
19 20
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21#include <asm/string.h> 22#include <asm/string.h>
@@ -297,121 +298,165 @@ asmlinkage int solaris_sendmsg(int fd, struct sol_nmsghdr __user *user_msg, unsi
297{ 298{
298 struct socket *sock; 299 struct socket *sock;
299 char address[MAX_SOCK_ADDR]; 300 char address[MAX_SOCK_ADDR];
300 struct iovec iov[UIO_FASTIOV]; 301 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
301 unsigned char ctl[sizeof(struct cmsghdr) + 20]; 302 unsigned char ctl[sizeof(struct cmsghdr) + 20];
302 unsigned char *ctl_buf = ctl; 303 unsigned char *ctl_buf = ctl;
303 struct msghdr kern_msg; 304 struct msghdr msg_sys;
304 int err, total_len; 305 int err, ctl_len, iov_size, total_len;
305 306
306 if(msghdr_from_user32_to_kern(&kern_msg, user_msg)) 307 err = -EFAULT;
307 return -EFAULT; 308 if (msghdr_from_user32_to_kern(&msg_sys, user_msg))
308 if(kern_msg.msg_iovlen > UIO_MAXIOV) 309 goto out;
309 return -EINVAL; 310
310 err = verify_compat_iovec(&kern_msg, iov, address, VERIFY_READ); 311 sock = sockfd_lookup(fd, &err);
311 if (err < 0) 312 if (!sock)
312 goto out; 313 goto out;
314
315 /* do not move before msg_sys is valid */
316 err = -EMSGSIZE;
317 if (msg_sys.msg_iovlen > UIO_MAXIOV)
318 goto out_put;
319
320 /* Check whether to allocate the iovec area*/
321 err = -ENOMEM;
322 iov_size = msg_sys.msg_iovlen * sizeof(struct iovec);
323 if (msg_sys.msg_iovlen > UIO_FASTIOV) {
324 iov = sock_kmalloc(sock->sk, iov_size, GFP_KERNEL);
325 if (!iov)
326 goto out_put;
327 }
328
329 err = verify_compat_iovec(&msg_sys, iov, address, VERIFY_READ);
330 if (err < 0)
331 goto out_freeiov;
313 total_len = err; 332 total_len = err;
314 333
315 if(kern_msg.msg_controllen) { 334 err = -ENOBUFS;
316 struct sol_cmsghdr __user *ucmsg = kern_msg.msg_control; 335 if (msg_sys.msg_controllen > INT_MAX)
336 goto out_freeiov;
337
338 ctl_len = msg_sys.msg_controllen;
339 if (ctl_len) {
340 struct sol_cmsghdr __user *ucmsg = msg_sys.msg_control;
317 unsigned long *kcmsg; 341 unsigned long *kcmsg;
318 compat_size_t cmlen; 342 compat_size_t cmlen;
319 343
320 if (kern_msg.msg_controllen <= sizeof(compat_size_t)) 344 err = -EINVAL;
321 return -EINVAL; 345 if (ctl_len <= sizeof(compat_size_t))
346 goto out_freeiov;
322 347
323 if(kern_msg.msg_controllen > sizeof(ctl)) { 348 if (ctl_len > sizeof(ctl)) {
324 err = -ENOBUFS; 349 err = -ENOBUFS;
325 ctl_buf = kmalloc(kern_msg.msg_controllen, GFP_KERNEL); 350 ctl_buf = kmalloc(ctl_len, GFP_KERNEL);
326 if(!ctl_buf) 351 if (!ctl_buf)
327 goto out_freeiov; 352 goto out_freeiov;
328 } 353 }
329 __get_user(cmlen, &ucmsg->cmsg_len); 354 __get_user(cmlen, &ucmsg->cmsg_len);
330 kcmsg = (unsigned long *) ctl_buf; 355 kcmsg = (unsigned long *) ctl_buf;
331 *kcmsg++ = (unsigned long)cmlen; 356 *kcmsg++ = (unsigned long)cmlen;
332 err = -EFAULT; 357 err = -EFAULT;
333 if(copy_from_user(kcmsg, &ucmsg->cmsg_level, 358 if (copy_from_user(kcmsg, &ucmsg->cmsg_level,
334 kern_msg.msg_controllen - sizeof(compat_size_t))) 359 ctl_len - sizeof(compat_size_t)))
335 goto out_freectl; 360 goto out_freectl;
336 kern_msg.msg_control = ctl_buf; 361 msg_sys.msg_control = ctl_buf;
337 } 362 }
338 kern_msg.msg_flags = solaris_to_linux_msgflags(user_flags); 363 msg_sys.msg_flags = solaris_to_linux_msgflags(user_flags);
339 364
340 lock_kernel(); 365 if (sock->file->f_flags & O_NONBLOCK)
341 sock = sockfd_lookup(fd, &err); 366 msg_sys.msg_flags |= MSG_DONTWAIT;
342 if (sock != NULL) { 367 err = sock_sendmsg(sock, &msg_sys, total_len);
343 if (sock->file->f_flags & O_NONBLOCK)
344 kern_msg.msg_flags |= MSG_DONTWAIT;
345 err = sock_sendmsg(sock, &kern_msg, total_len);
346 sockfd_put(sock);
347 }
348 unlock_kernel();
349 368
350out_freectl: 369out_freectl:
351 /* N.B. Use kfree here, as kern_msg.msg_controllen might change? */ 370 if (ctl_buf != ctl)
352 if(ctl_buf != ctl) 371 sock_kfree_s(sock->sk, ctl_buf, ctl_len);
353 kfree(ctl_buf);
354out_freeiov: 372out_freeiov:
355 if(kern_msg.msg_iov != iov) 373 if (iov != iovstack)
356 kfree(kern_msg.msg_iov); 374 sock_kfree_s(sock->sk, iov, iov_size);
357out: 375out_put:
376 sockfd_put(sock);
377out:
358 return err; 378 return err;
359} 379}
360 380
361asmlinkage int solaris_recvmsg(int fd, struct sol_nmsghdr __user *user_msg, unsigned int user_flags) 381asmlinkage int solaris_recvmsg(int fd, struct sol_nmsghdr __user *user_msg, unsigned int user_flags)
362{ 382{
363 struct iovec iovstack[UIO_FASTIOV];
364 struct msghdr kern_msg;
365 char addr[MAX_SOCK_ADDR];
366 struct socket *sock; 383 struct socket *sock;
384 struct iovec iovstack[UIO_FASTIOV];
367 struct iovec *iov = iovstack; 385 struct iovec *iov = iovstack;
386 struct msghdr msg_sys;
387 unsigned long cmsg_ptr;
388 int err, iov_size, total_len, len;
389
390 /* kernel mode address */
391 char addr[MAX_SOCK_ADDR];
392
393 /* user mode address pointers */
368 struct sockaddr __user *uaddr; 394 struct sockaddr __user *uaddr;
369 int __user *uaddr_len; 395 int __user *uaddr_len;
370 unsigned long cmsg_ptr;
371 int err, total_len, len = 0;
372 396
373 if(msghdr_from_user32_to_kern(&kern_msg, user_msg)) 397 if (msghdr_from_user32_to_kern(&msg_sys, user_msg))
374 return -EFAULT; 398 return -EFAULT;
375 if(kern_msg.msg_iovlen > UIO_MAXIOV)
376 return -EINVAL;
377 399
378 uaddr = kern_msg.msg_name; 400 sock = sockfd_lookup(fd, &err);
401 if (!sock)
402 goto out;
403
404 err = -EMSGSIZE;
405 if (msg_sys.msg_iovlen > UIO_MAXIOV)
406 goto out_put;
407
408 /* Check whether to allocate the iovec area*/
409 err = -ENOMEM;
410 iov_size = msg_sys.msg_iovlen * sizeof(struct iovec);
411 if (msg_sys.msg_iovlen > UIO_FASTIOV) {
412 iov = sock_kmalloc(sock->sk, iov_size, GFP_KERNEL);
413 if (!iov)
414 goto out_put;
415 }
416
417 /*
418 * Save the user-mode address (verify_iovec will change the
419 * kernel msghdr to use the kernel address space)
420 */
421
422 uaddr = (void __user *) msg_sys.msg_name;
379 uaddr_len = &user_msg->msg_namelen; 423 uaddr_len = &user_msg->msg_namelen;
380 err = verify_compat_iovec(&kern_msg, iov, addr, VERIFY_WRITE); 424 err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE);
381 if (err < 0) 425 if (err < 0)
382 goto out; 426 goto out_freeiov;
383 total_len = err; 427 total_len = err;
384 428
385 cmsg_ptr = (unsigned long) kern_msg.msg_control; 429 cmsg_ptr = (unsigned long) msg_sys.msg_control;
386 kern_msg.msg_flags = 0; 430 msg_sys.msg_flags = MSG_CMSG_COMPAT;
387 431
388 lock_kernel(); 432 if (sock->file->f_flags & O_NONBLOCK)
389 sock = sockfd_lookup(fd, &err); 433 user_flags |= MSG_DONTWAIT;
390 if (sock != NULL) { 434
391 if (sock->file->f_flags & O_NONBLOCK) 435 err = sock_recvmsg(sock, &msg_sys, total_len, user_flags);
392 user_flags |= MSG_DONTWAIT; 436 if(err < 0)
393 err = sock_recvmsg(sock, &kern_msg, total_len, user_flags); 437 goto out_freeiov;
394 if(err >= 0) 438
395 len = err; 439 len = err;
396 sockfd_put(sock); 440
397 } 441 if (uaddr != NULL) {
398 unlock_kernel(); 442 err = move_addr_to_user(addr, msg_sys.msg_namelen, uaddr, uaddr_len);
399 443 if (err < 0)
400 if(uaddr != NULL && err >= 0) 444 goto out_freeiov;
401 err = move_addr_to_user(addr, kern_msg.msg_namelen, uaddr, uaddr_len);
402 if(err >= 0) {
403 err = __put_user(linux_to_solaris_msgflags(kern_msg.msg_flags), &user_msg->msg_flags);
404 if(!err) {
405 /* XXX Convert cmsg back into userspace 32-bit format... */
406 err = __put_user((unsigned long)kern_msg.msg_control - cmsg_ptr,
407 &user_msg->msg_controllen);
408 }
409 } 445 }
446 err = __put_user(linux_to_solaris_msgflags(msg_sys.msg_flags), &user_msg->msg_flags);
447 if (err)
448 goto out_freeiov;
449 err = __put_user((unsigned long)msg_sys.msg_control - cmsg_ptr,
450 &user_msg->msg_controllen);
451 if (err)
452 goto out_freeiov;
453 err = len;
410 454
411 if(kern_msg.msg_iov != iov) 455out_freeiov:
412 kfree(kern_msg.msg_iov); 456 if (iov != iovstack)
457 sock_kfree_s(sock->sk, iov, iov_size);
458out_put:
459 sockfd_put(sock);
413out: 460out:
414 if(err < 0) 461 return err;
415 return err;
416 return len;
417} 462}
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 6e4807d64d46..b15761ff4101 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -334,7 +334,7 @@ static void __cpuinit tsc_sync_wait(void)
334{ 334{
335 if (notscsync || !cpu_has_tsc) 335 if (notscsync || !cpu_has_tsc)
336 return; 336 return;
337 sync_tsc(boot_cpu_id); 337 sync_tsc(0);
338} 338}
339 339
340static __init int notscsync_setup(char *s) 340static __init int notscsync_setup(char *s)