ia64/xen-unstable

view patches/linux-2.6.12/linux-2.6.12.3.patch @ 6128:57b3fdca5dae

Support VCPU migration for VMX guests.

Add a hook to support CPU migration for VMX domains

Reorganize the low level asm code to support relaunching a VMCS on a different
logical CPU.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Aug 11 21:38:58 2005 +0000 (2005-08-11)
parents f46bb706a38d
children
line source
1 diff --git a/Makefile b/Makefile
2 --- a/Makefile
3 +++ b/Makefile
4 @@ -1,7 +1,7 @@
5 VERSION = 2
6 PATCHLEVEL = 6
7 SUBLEVEL = 12
8 -EXTRAVERSION =
9 +EXTRAVERSION = .3
10 NAME=Woozy Numbat
12 # *DOCUMENTATION*
13 diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
14 --- a/arch/ia64/kernel/ptrace.c
15 +++ b/arch/ia64/kernel/ptrace.c
16 @@ -945,6 +945,13 @@ access_uarea (struct task_struct *child,
17 *data = (pt->cr_ipsr & IPSR_MASK);
18 return 0;
20 + case PT_AR_RSC:
21 + if (write_access)
22 + pt->ar_rsc = *data | (3 << 2); /* force PL3 */
23 + else
24 + *data = pt->ar_rsc;
25 + return 0;
26 +
27 case PT_AR_RNAT:
28 urbs_end = ia64_get_user_rbs_end(child, pt, NULL);
29 rnat_addr = (long) ia64_rse_rnat_addr((long *)
30 @@ -996,9 +1003,6 @@ access_uarea (struct task_struct *child,
31 case PT_AR_BSPSTORE:
32 ptr = pt_reg_addr(pt, ar_bspstore);
33 break;
34 - case PT_AR_RSC:
35 - ptr = pt_reg_addr(pt, ar_rsc);
36 - break;
37 case PT_AR_UNAT:
38 ptr = pt_reg_addr(pt, ar_unat);
39 break;
40 @@ -1234,7 +1238,7 @@ ptrace_getregs (struct task_struct *chil
41 static long
42 ptrace_setregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
43 {
44 - unsigned long psr, ec, lc, rnat, bsp, cfm, nat_bits, val = 0;
45 + unsigned long psr, rsc, ec, lc, rnat, bsp, cfm, nat_bits, val = 0;
46 struct unw_frame_info info;
47 struct switch_stack *sw;
48 struct ia64_fpreg fpval;
49 @@ -1267,7 +1271,7 @@ ptrace_setregs (struct task_struct *chil
50 /* app regs */
52 retval |= __get_user(pt->ar_pfs, &ppr->ar[PT_AUR_PFS]);
53 - retval |= __get_user(pt->ar_rsc, &ppr->ar[PT_AUR_RSC]);
54 + retval |= __get_user(rsc, &ppr->ar[PT_AUR_RSC]);
55 retval |= __get_user(pt->ar_bspstore, &ppr->ar[PT_AUR_BSPSTORE]);
56 retval |= __get_user(pt->ar_unat, &ppr->ar[PT_AUR_UNAT]);
57 retval |= __get_user(pt->ar_ccv, &ppr->ar[PT_AUR_CCV]);
58 @@ -1365,6 +1369,7 @@ ptrace_setregs (struct task_struct *chil
59 retval |= __get_user(nat_bits, &ppr->nat);
61 retval |= access_uarea(child, PT_CR_IPSR, &psr, 1);
62 + retval |= access_uarea(child, PT_AR_RSC, &rsc, 1);
63 retval |= access_uarea(child, PT_AR_EC, &ec, 1);
64 retval |= access_uarea(child, PT_AR_LC, &lc, 1);
65 retval |= access_uarea(child, PT_AR_RNAT, &rnat, 1);
66 diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
67 --- a/arch/ia64/kernel/signal.c
68 +++ b/arch/ia64/kernel/signal.c
69 @@ -94,7 +94,7 @@ sys_sigaltstack (const stack_t __user *u
70 static long
71 restore_sigcontext (struct sigcontext __user *sc, struct sigscratch *scr)
72 {
73 - unsigned long ip, flags, nat, um, cfm;
74 + unsigned long ip, flags, nat, um, cfm, rsc;
75 long err;
77 /* Always make any pending restarted system calls return -EINTR */
78 @@ -106,7 +106,7 @@ restore_sigcontext (struct sigcontext __
79 err |= __get_user(ip, &sc->sc_ip); /* instruction pointer */
80 err |= __get_user(cfm, &sc->sc_cfm);
81 err |= __get_user(um, &sc->sc_um); /* user mask */
82 - err |= __get_user(scr->pt.ar_rsc, &sc->sc_ar_rsc);
83 + err |= __get_user(rsc, &sc->sc_ar_rsc);
84 err |= __get_user(scr->pt.ar_unat, &sc->sc_ar_unat);
85 err |= __get_user(scr->pt.ar_fpsr, &sc->sc_ar_fpsr);
86 err |= __get_user(scr->pt.ar_pfs, &sc->sc_ar_pfs);
87 @@ -119,6 +119,7 @@ restore_sigcontext (struct sigcontext __
88 err |= __copy_from_user(&scr->pt.r15, &sc->sc_gr[15], 8); /* r15 */
90 scr->pt.cr_ifs = cfm | (1UL << 63);
91 + scr->pt.ar_rsc = rsc | (3 << 2); /* force PL3 */
93 /* establish new instruction pointer: */
94 scr->pt.cr_iip = ip & ~0x3UL;
95 diff --git a/arch/ppc/kernel/time.c b/arch/ppc/kernel/time.c
96 --- a/arch/ppc/kernel/time.c
97 +++ b/arch/ppc/kernel/time.c
98 @@ -89,6 +89,9 @@ unsigned long tb_to_ns_scale;
100 extern unsigned long wall_jiffies;
102 +/* used for timezone offset */
103 +static long timezone_offset;
104 +
105 DEFINE_SPINLOCK(rtc_lock);
107 EXPORT_SYMBOL(rtc_lock);
108 @@ -170,7 +173,7 @@ void timer_interrupt(struct pt_regs * re
109 xtime.tv_sec - last_rtc_update >= 659 &&
110 abs((xtime.tv_nsec / 1000) - (1000000-1000000/HZ)) < 500000/HZ &&
111 jiffies - wall_jiffies == 1) {
112 - if (ppc_md.set_rtc_time(xtime.tv_sec+1 + time_offset) == 0)
113 + if (ppc_md.set_rtc_time(xtime.tv_sec+1 + timezone_offset) == 0)
114 last_rtc_update = xtime.tv_sec+1;
115 else
116 /* Try again one minute later */
117 @@ -286,7 +289,7 @@ void __init time_init(void)
118 unsigned old_stamp, stamp, elapsed;
120 if (ppc_md.time_init != NULL)
121 - time_offset = ppc_md.time_init();
122 + timezone_offset = ppc_md.time_init();
124 if (__USE_RTC()) {
125 /* 601 processor: dec counts down by 128 every 128ns */
126 @@ -331,10 +334,10 @@ void __init time_init(void)
127 set_dec(tb_ticks_per_jiffy);
129 /* If platform provided a timezone (pmac), we correct the time */
130 - if (time_offset) {
131 - sys_tz.tz_minuteswest = -time_offset / 60;
132 + if (timezone_offset) {
133 + sys_tz.tz_minuteswest = -timezone_offset / 60;
134 sys_tz.tz_dsttime = 0;
135 - xtime.tv_sec -= time_offset;
136 + xtime.tv_sec -= timezone_offset;
137 }
138 set_normalized_timespec(&wall_to_monotonic,
139 -xtime.tv_sec, -xtime.tv_nsec);
140 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
141 --- a/arch/um/kernel/process.c
142 +++ b/arch/um/kernel/process.c
143 @@ -130,7 +130,7 @@ int start_fork_tramp(void *thread_arg, u
144 return(arg.pid);
145 }
147 -static int ptrace_child(void)
148 +static int ptrace_child(void *arg)
149 {
150 int ret;
151 int pid = os_getpid(), ppid = getppid();
152 @@ -159,16 +159,20 @@ static int ptrace_child(void)
153 _exit(ret);
154 }
156 -static int start_ptraced_child(void)
157 +static int start_ptraced_child(void **stack_out)
158 {
159 + void *stack;
160 + unsigned long sp;
161 int pid, n, status;
163 - pid = fork();
164 - if(pid == 0)
165 - ptrace_child();
166 -
167 + stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
168 + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
169 + if(stack == MAP_FAILED)
170 + panic("check_ptrace : mmap failed, errno = %d", errno);
171 + sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
172 + pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
173 if(pid < 0)
174 - panic("check_ptrace : fork failed, errno = %d", errno);
175 + panic("check_ptrace : clone failed, errno = %d", errno);
176 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
177 if(n < 0)
178 panic("check_ptrace : wait failed, errno = %d", errno);
179 @@ -176,6 +180,7 @@ static int start_ptraced_child(void)
180 panic("check_ptrace : expected SIGSTOP, got status = %d",
181 status);
183 + *stack_out = stack;
184 return(pid);
185 }
187 @@ -183,12 +188,12 @@ static int start_ptraced_child(void)
188 * just avoid using sysemu, not panic, but only if SYSEMU features are broken.
189 * So only for SYSEMU features we test mustpanic, while normal host features
190 * must work anyway!*/
191 -static int stop_ptraced_child(int pid, int exitcode, int mustexit)
192 +static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic)
193 {
194 int status, n, ret = 0;
196 if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
197 - panic("stop_ptraced_child : ptrace failed, errno = %d", errno);
198 + panic("check_ptrace : ptrace failed, errno = %d", errno);
199 CATCH_EINTR(n = waitpid(pid, &status, 0));
200 if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
201 int exit_with = WEXITSTATUS(status);
202 @@ -199,13 +204,15 @@ static int stop_ptraced_child(int pid, i
203 printk("check_ptrace : child exited with exitcode %d, while "
204 "expecting %d; status 0x%x", exit_with,
205 exitcode, status);
206 - if (mustexit)
207 + if (mustpanic)
208 panic("\n");
209 else
210 printk("\n");
211 ret = -1;
212 }
214 + if(munmap(stack, PAGE_SIZE) < 0)
215 + panic("check_ptrace : munmap failed, errno = %d", errno);
216 return ret;
217 }
219 @@ -227,11 +234,12 @@ __uml_setup("nosysemu", nosysemu_cmd_par
221 static void __init check_sysemu(void)
222 {
223 + void *stack;
224 int pid, syscall, n, status, count=0;
226 printk("Checking syscall emulation patch for ptrace...");
227 sysemu_supported = 0;
228 - pid = start_ptraced_child();
229 + pid = start_ptraced_child(&stack);
231 if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0)
232 goto fail;
233 @@ -249,7 +257,7 @@ static void __init check_sysemu(void)
234 panic("check_sysemu : failed to modify system "
235 "call return, errno = %d", errno);
237 - if (stop_ptraced_child(pid, 0, 0) < 0)
238 + if (stop_ptraced_child(pid, stack, 0, 0) < 0)
239 goto fail_stopped;
241 sysemu_supported = 1;
242 @@ -257,7 +265,7 @@ static void __init check_sysemu(void)
243 set_using_sysemu(!force_sysemu_disabled);
245 printk("Checking advanced syscall emulation patch for ptrace...");
246 - pid = start_ptraced_child();
247 + pid = start_ptraced_child(&stack);
248 while(1){
249 count++;
250 if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
251 @@ -282,7 +290,7 @@ static void __init check_sysemu(void)
252 break;
253 }
254 }
255 - if (stop_ptraced_child(pid, 0, 0) < 0)
256 + if (stop_ptraced_child(pid, stack, 0, 0) < 0)
257 goto fail_stopped;
259 sysemu_supported = 2;
260 @@ -293,17 +301,18 @@ static void __init check_sysemu(void)
261 return;
263 fail:
264 - stop_ptraced_child(pid, 1, 0);
265 + stop_ptraced_child(pid, stack, 1, 0);
266 fail_stopped:
267 printk("missing\n");
268 }
270 void __init check_ptrace(void)
271 {
272 + void *stack;
273 int pid, syscall, n, status;
275 printk("Checking that ptrace can change system call numbers...");
276 - pid = start_ptraced_child();
277 + pid = start_ptraced_child(&stack);
279 if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
280 panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno);
281 @@ -330,7 +339,7 @@ void __init check_ptrace(void)
282 break;
283 }
284 }
285 - stop_ptraced_child(pid, 0, 1);
286 + stop_ptraced_child(pid, stack, 0, 1);
287 printk("OK\n");
288 check_sysemu();
289 }
290 @@ -362,10 +371,11 @@ void forward_pending_sigio(int target)
291 static inline int check_skas3_ptrace_support(void)
292 {
293 struct ptrace_faultinfo fi;
294 + void *stack;
295 int pid, n, ret = 1;
297 printf("Checking for the skas3 patch in the host...");
298 - pid = start_ptraced_child();
299 + pid = start_ptraced_child(&stack);
301 n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
302 if (n < 0) {
303 @@ -380,7 +390,7 @@ static inline int check_skas3_ptrace_sup
304 }
306 init_registers(pid);
307 - stop_ptraced_child(pid, 1, 1);
308 + stop_ptraced_child(pid, stack, 1, 1);
310 return(ret);
311 }
312 diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
313 --- a/drivers/acpi/pci_irq.c
314 +++ b/drivers/acpi/pci_irq.c
315 @@ -433,8 +433,9 @@ acpi_pci_irq_enable (
316 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI",
317 pci_name(dev), ('A' + pin));
318 /* Interrupt Line values above 0xF are forbidden */
319 - if (dev->irq >= 0 && (dev->irq <= 0xF)) {
320 + if (dev->irq > 0 && (dev->irq <= 0xF)) {
321 printk(" - using IRQ %d\n", dev->irq);
322 + acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW);
323 return_VALUE(0);
324 }
325 else {
326 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
327 --- a/drivers/char/tpm/tpm.c
328 +++ b/drivers/char/tpm/tpm.c
329 @@ -32,12 +32,6 @@
331 #define TPM_BUFSIZE 2048
333 -/* PCI configuration addresses */
334 -#define PCI_GEN_PMCON_1 0xA0
335 -#define PCI_GEN1_DEC 0xE4
336 -#define PCI_LPC_EN 0xE6
337 -#define PCI_GEN2_DEC 0xEC
338 -
339 static LIST_HEAD(tpm_chip_list);
340 static DEFINE_SPINLOCK(driver_lock);
341 static int dev_mask[32];
342 @@ -61,72 +55,6 @@ void tpm_time_expired(unsigned long ptr)
343 EXPORT_SYMBOL_GPL(tpm_time_expired);
345 /*
346 - * Initialize the LPC bus and enable the TPM ports
347 - */
348 -int tpm_lpc_bus_init(struct pci_dev *pci_dev, u16 base)
349 -{
350 - u32 lpcenable, tmp;
351 - int is_lpcm = 0;
352 -
353 - switch (pci_dev->vendor) {
354 - case PCI_VENDOR_ID_INTEL:
355 - switch (pci_dev->device) {
356 - case PCI_DEVICE_ID_INTEL_82801CA_12:
357 - case PCI_DEVICE_ID_INTEL_82801DB_12:
358 - is_lpcm = 1;
359 - break;
360 - }
361 - /* init ICH (enable LPC) */
362 - pci_read_config_dword(pci_dev, PCI_GEN1_DEC, &lpcenable);
363 - lpcenable |= 0x20000000;
364 - pci_write_config_dword(pci_dev, PCI_GEN1_DEC, lpcenable);
365 -
366 - if (is_lpcm) {
367 - pci_read_config_dword(pci_dev, PCI_GEN1_DEC,
368 - &lpcenable);
369 - if ((lpcenable & 0x20000000) == 0) {
370 - dev_err(&pci_dev->dev,
371 - "cannot enable LPC\n");
372 - return -ENODEV;
373 - }
374 - }
375 -
376 - /* initialize TPM registers */
377 - pci_read_config_dword(pci_dev, PCI_GEN2_DEC, &tmp);
378 -
379 - if (!is_lpcm)
380 - tmp = (tmp & 0xFFFF0000) | (base & 0xFFF0);
381 - else
382 - tmp =
383 - (tmp & 0xFFFF0000) | (base & 0xFFF0) |
384 - 0x00000001;
385 -
386 - pci_write_config_dword(pci_dev, PCI_GEN2_DEC, tmp);
387 -
388 - if (is_lpcm) {
389 - pci_read_config_dword(pci_dev, PCI_GEN_PMCON_1,
390 - &tmp);
391 - tmp |= 0x00000004; /* enable CLKRUN */
392 - pci_write_config_dword(pci_dev, PCI_GEN_PMCON_1,
393 - tmp);
394 - }
395 - tpm_write_index(0x0D, 0x55); /* unlock 4F */
396 - tpm_write_index(0x0A, 0x00); /* int disable */
397 - tpm_write_index(0x08, base); /* base addr lo */
398 - tpm_write_index(0x09, (base & 0xFF00) >> 8); /* base addr hi */
399 - tpm_write_index(0x0D, 0xAA); /* lock 4F */
400 - break;
401 - case PCI_VENDOR_ID_AMD:
402 - /* nothing yet */
403 - break;
404 - }
405 -
406 - return 0;
407 -}
408 -
409 -EXPORT_SYMBOL_GPL(tpm_lpc_bus_init);
410 -
411 -/*
412 * Internal kernel interface to transmit TPM commands
413 */
414 static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
415 @@ -590,10 +518,6 @@ int tpm_pm_resume(struct pci_dev *pci_de
416 if (chip == NULL)
417 return -ENODEV;
419 - spin_lock(&driver_lock);
420 - tpm_lpc_bus_init(pci_dev, chip->vendor->base);
421 - spin_unlock(&driver_lock);
422 -
423 return 0;
424 }
426 diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
427 --- a/drivers/char/tpm/tpm.h
428 +++ b/drivers/char/tpm/tpm.h
429 @@ -79,8 +79,6 @@ static inline void tpm_write_index(int i
430 }
432 extern void tpm_time_expired(unsigned long);
433 -extern int tpm_lpc_bus_init(struct pci_dev *, u16);
434 -
435 extern int tpm_register_hardware(struct pci_dev *,
436 struct tpm_vendor_specific *);
437 extern int tpm_open(struct inode *, struct file *);
438 diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
439 --- a/drivers/char/tpm/tpm_atmel.c
440 +++ b/drivers/char/tpm/tpm_atmel.c
441 @@ -22,7 +22,10 @@
442 #include "tpm.h"
444 /* Atmel definitions */
445 -#define TPM_ATML_BASE 0x400
446 +enum tpm_atmel_addr {
447 + TPM_ATMEL_BASE_ADDR_LO = 0x08,
448 + TPM_ATMEL_BASE_ADDR_HI = 0x09
449 +};
451 /* write status bits */
452 #define ATML_STATUS_ABORT 0x01
453 @@ -127,7 +130,6 @@ static struct tpm_vendor_specific tpm_at
454 .cancel = tpm_atml_cancel,
455 .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
456 .req_complete_val = ATML_STATUS_DATA_AVAIL,
457 - .base = TPM_ATML_BASE,
458 .miscdev = { .fops = &atmel_ops, },
459 };
461 @@ -136,14 +138,16 @@ static int __devinit tpm_atml_init(struc
462 {
463 u8 version[4];
464 int rc = 0;
465 + int lo, hi;
467 if (pci_enable_device(pci_dev))
468 return -EIO;
470 - if (tpm_lpc_bus_init(pci_dev, TPM_ATML_BASE)) {
471 - rc = -ENODEV;
472 - goto out_err;
473 - }
474 + lo = tpm_read_index( TPM_ATMEL_BASE_ADDR_LO );
475 + hi = tpm_read_index( TPM_ATMEL_BASE_ADDR_HI );
476 +
477 + tpm_atmel.base = (hi<<8)|lo;
478 + dev_dbg( &pci_dev->dev, "Operating with base: 0x%x\n", tpm_atmel.base);
480 /* verify that it is an Atmel part */
481 if (tpm_read_index(4) != 'A' || tpm_read_index(5) != 'T'
482 diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
483 --- a/drivers/char/tpm/tpm_nsc.c
484 +++ b/drivers/char/tpm/tpm_nsc.c
485 @@ -24,6 +24,10 @@
486 /* National definitions */
487 #define TPM_NSC_BASE 0x360
488 #define TPM_NSC_IRQ 0x07
489 +#define TPM_NSC_BASE0_HI 0x60
490 +#define TPM_NSC_BASE0_LO 0x61
491 +#define TPM_NSC_BASE1_HI 0x62
492 +#define TPM_NSC_BASE1_LO 0x63
494 #define NSC_LDN_INDEX 0x07
495 #define NSC_SID_INDEX 0x20
496 @@ -234,7 +238,6 @@ static struct tpm_vendor_specific tpm_ns
497 .cancel = tpm_nsc_cancel,
498 .req_complete_mask = NSC_STATUS_OBF,
499 .req_complete_val = NSC_STATUS_OBF,
500 - .base = TPM_NSC_BASE,
501 .miscdev = { .fops = &nsc_ops, },
503 };
504 @@ -243,15 +246,16 @@ static int __devinit tpm_nsc_init(struct
505 const struct pci_device_id *pci_id)
506 {
507 int rc = 0;
508 + int lo, hi;
509 +
510 + hi = tpm_read_index(TPM_NSC_BASE0_HI);
511 + lo = tpm_read_index(TPM_NSC_BASE0_LO);
512 +
513 + tpm_nsc.base = (hi<<8) | lo;
515 if (pci_enable_device(pci_dev))
516 return -EIO;
518 - if (tpm_lpc_bus_init(pci_dev, TPM_NSC_BASE)) {
519 - rc = -ENODEV;
520 - goto out_err;
521 - }
522 -
523 /* verify that it is a National part (SID) */
524 if (tpm_read_index(NSC_SID_INDEX) != 0xEF) {
525 rc = -ENODEV;
526 diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
527 --- a/drivers/char/tty_ioctl.c
528 +++ b/drivers/char/tty_ioctl.c
529 @@ -476,11 +476,11 @@ int n_tty_ioctl(struct tty_struct * tty,
530 ld = tty_ldisc_ref(tty);
531 switch (arg) {
532 case TCIFLUSH:
533 - if (ld->flush_buffer)
534 + if (ld && ld->flush_buffer)
535 ld->flush_buffer(tty);
536 break;
537 case TCIOFLUSH:
538 - if (ld->flush_buffer)
539 + if (ld && ld->flush_buffer)
540 ld->flush_buffer(tty);
541 /* fall through */
542 case TCOFLUSH:
543 diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
544 --- a/drivers/media/video/cx88/cx88-video.c
545 +++ b/drivers/media/video/cx88/cx88-video.c
546 @@ -261,7 +261,7 @@ static struct cx88_ctrl cx8800_ctls[] =
547 .default_value = 0,
548 .type = V4L2_CTRL_TYPE_INTEGER,
549 },
550 - .off = 0,
551 + .off = 128,
552 .reg = MO_HUE,
553 .mask = 0x00ff,
554 .shift = 0,
555 diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
556 --- a/drivers/net/e1000/e1000_main.c
557 +++ b/drivers/net/e1000/e1000_main.c
558 @@ -2307,6 +2307,7 @@ e1000_xmit_frame(struct sk_buff *skb, st
559 tso = e1000_tso(adapter, skb);
560 if (tso < 0) {
561 dev_kfree_skb_any(skb);
562 + spin_unlock_irqrestore(&adapter->tx_lock, flags);
563 return NETDEV_TX_OK;
564 }
566 diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
567 --- a/drivers/net/hamradio/Kconfig
568 +++ b/drivers/net/hamradio/Kconfig
569 @@ -17,7 +17,7 @@ config MKISS
571 config 6PACK
572 tristate "Serial port 6PACK driver"
573 - depends on AX25 && BROKEN_ON_SMP
574 + depends on AX25
575 ---help---
576 6pack is a transmission protocol for the data exchange between your
577 PC and your TNC (the Terminal Node Controller acts as a kind of
578 diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c
579 --- a/drivers/net/shaper.c
580 +++ b/drivers/net/shaper.c
581 @@ -135,10 +135,8 @@ static int shaper_start_xmit(struct sk_b
582 {
583 struct shaper *shaper = dev->priv;
584 struct sk_buff *ptr;
585 -
586 - if (down_trylock(&shaper->sem))
587 - return -1;
589 + spin_lock(&shaper->lock);
590 ptr=shaper->sendq.prev;
592 /*
593 @@ -232,7 +230,7 @@ static int shaper_start_xmit(struct sk_b
594 shaper->stats.collisions++;
595 }
596 shaper_kick(shaper);
597 - up(&shaper->sem);
598 + spin_unlock(&shaper->lock);
599 return 0;
600 }
602 @@ -271,11 +269,9 @@ static void shaper_timer(unsigned long d
603 {
604 struct shaper *shaper = (struct shaper *)data;
606 - if (!down_trylock(&shaper->sem)) {
607 - shaper_kick(shaper);
608 - up(&shaper->sem);
609 - } else
610 - mod_timer(&shaper->timer, jiffies);
611 + spin_lock(&shaper->lock);
612 + shaper_kick(shaper);
613 + spin_unlock(&shaper->lock);
614 }
616 /*
617 @@ -332,21 +328,6 @@ static void shaper_kick(struct shaper *s
620 /*
621 - * Flush the shaper queues on a closedown
622 - */
623 -
624 -static void shaper_flush(struct shaper *shaper)
625 -{
626 - struct sk_buff *skb;
627 -
628 - down(&shaper->sem);
629 - while((skb=skb_dequeue(&shaper->sendq))!=NULL)
630 - dev_kfree_skb(skb);
631 - shaper_kick(shaper);
632 - up(&shaper->sem);
633 -}
634 -
635 -/*
636 * Bring the interface up. We just disallow this until a
637 * bind.
638 */
639 @@ -375,7 +356,15 @@ static int shaper_open(struct net_device
640 static int shaper_close(struct net_device *dev)
641 {
642 struct shaper *shaper=dev->priv;
643 - shaper_flush(shaper);
644 + struct sk_buff *skb;
645 +
646 + while ((skb = skb_dequeue(&shaper->sendq)) != NULL)
647 + dev_kfree_skb(skb);
648 +
649 + spin_lock_bh(&shaper->lock);
650 + shaper_kick(shaper);
651 + spin_unlock_bh(&shaper->lock);
652 +
653 del_timer_sync(&shaper->timer);
654 return 0;
655 }
656 @@ -576,6 +565,7 @@ static void shaper_init_priv(struct net_
657 init_timer(&sh->timer);
658 sh->timer.function=shaper_timer;
659 sh->timer.data=(unsigned long)sh;
660 + spin_lock_init(&sh->lock);
661 }
663 /*
664 diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
665 --- a/drivers/pci/pci-driver.c
666 +++ b/drivers/pci/pci-driver.c
667 @@ -396,7 +396,7 @@ int pci_register_driver(struct pci_drive
668 /* FIXME, once all of the existing PCI drivers have been fixed to set
669 * the pci shutdown function, this test can go away. */
670 if (!drv->driver.shutdown)
671 - drv->driver.shutdown = pci_device_shutdown,
672 + drv->driver.shutdown = pci_device_shutdown;
673 drv->driver.owner = drv->owner;
674 drv->driver.kobj.ktype = &pci_driver_kobj_type;
675 pci_init_dynids(&drv->dynids);
676 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
677 --- a/drivers/scsi/qla2xxx/qla_os.c
678 +++ b/drivers/scsi/qla2xxx/qla_os.c
679 @@ -1150,7 +1150,7 @@ iospace_error_exit:
680 */
681 int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
682 {
683 - int ret;
684 + int ret = -ENODEV;
685 device_reg_t __iomem *reg;
686 struct Scsi_Host *host;
687 scsi_qla_host_t *ha;
688 @@ -1161,7 +1161,7 @@ int qla2x00_probe_one(struct pci_dev *pd
689 fc_port_t *fcport;
691 if (pci_enable_device(pdev))
692 - return -1;
693 + goto probe_out;
695 host = scsi_host_alloc(&qla2x00_driver_template,
696 sizeof(scsi_qla_host_t));
697 @@ -1183,9 +1183,8 @@ int qla2x00_probe_one(struct pci_dev *pd
699 /* Configure PCI I/O space */
700 ret = qla2x00_iospace_config(ha);
701 - if (ret != 0) {
702 - goto probe_alloc_failed;
703 - }
704 + if (ret)
705 + goto probe_failed;
707 /* Sanitize the information from PCI BIOS. */
708 host->irq = pdev->irq;
709 @@ -1258,23 +1257,10 @@ int qla2x00_probe_one(struct pci_dev *pd
710 qla_printk(KERN_WARNING, ha,
711 "[ERROR] Failed to allocate memory for adapter\n");
713 - goto probe_alloc_failed;
714 + ret = -ENOMEM;
715 + goto probe_failed;
716 }
718 - pci_set_drvdata(pdev, ha);
719 - host->this_id = 255;
720 - host->cmd_per_lun = 3;
721 - host->unique_id = ha->instance;
722 - host->max_cmd_len = MAX_CMDSZ;
723 - host->max_channel = ha->ports - 1;
724 - host->max_id = ha->max_targets;
725 - host->max_lun = ha->max_luns;
726 - host->transportt = qla2xxx_transport_template;
727 - if (scsi_add_host(host, &pdev->dev))
728 - goto probe_alloc_failed;
729 -
730 - qla2x00_alloc_sysfs_attr(ha);
731 -
732 if (qla2x00_initialize_adapter(ha) &&
733 !(ha->device_flags & DFLG_NO_CABLE)) {
735 @@ -1285,11 +1271,10 @@ int qla2x00_probe_one(struct pci_dev *pd
736 "Adapter flags %x.\n",
737 ha->host_no, ha->device_flags));
739 + ret = -ENODEV;
740 goto probe_failed;
741 }
743 - qla2x00_init_host_attr(ha);
744 -
745 /*
746 * Startup the kernel thread for this host adapter
747 */
748 @@ -1299,17 +1284,26 @@ int qla2x00_probe_one(struct pci_dev *pd
749 qla_printk(KERN_WARNING, ha,
750 "Unable to start DPC thread!\n");
752 + ret = -ENODEV;
753 goto probe_failed;
754 }
755 wait_for_completion(&ha->dpc_inited);
757 + host->this_id = 255;
758 + host->cmd_per_lun = 3;
759 + host->unique_id = ha->instance;
760 + host->max_cmd_len = MAX_CMDSZ;
761 + host->max_channel = ha->ports - 1;
762 + host->max_lun = MAX_LUNS;
763 + host->transportt = qla2xxx_transport_template;
764 +
765 if (IS_QLA2100(ha) || IS_QLA2200(ha))
766 ret = request_irq(host->irq, qla2100_intr_handler,
767 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
768 else
769 ret = request_irq(host->irq, qla2300_intr_handler,
770 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
771 - if (ret != 0) {
772 + if (ret) {
773 qla_printk(KERN_WARNING, ha,
774 "Failed to reserve interrupt %d already in use.\n",
775 host->irq);
776 @@ -1363,9 +1357,18 @@ int qla2x00_probe_one(struct pci_dev *pd
777 msleep(10);
778 }
780 + pci_set_drvdata(pdev, ha);
781 ha->flags.init_done = 1;
782 num_hosts++;
784 + ret = scsi_add_host(host, &pdev->dev);
785 + if (ret)
786 + goto probe_failed;
787 +
788 + qla2x00_alloc_sysfs_attr(ha);
789 +
790 + qla2x00_init_host_attr(ha);
791 +
792 qla_printk(KERN_INFO, ha, "\n"
793 " QLogic Fibre Channel HBA Driver: %s\n"
794 " QLogic %s - %s\n"
795 @@ -1384,9 +1387,6 @@ int qla2x00_probe_one(struct pci_dev *pd
796 probe_failed:
797 fc_remove_host(ha->host);
799 - scsi_remove_host(host);
800 -
801 -probe_alloc_failed:
802 qla2x00_free_device(ha);
804 scsi_host_put(host);
805 @@ -1394,7 +1394,8 @@ probe_alloc_failed:
806 probe_disable_device:
807 pci_disable_device(pdev);
809 - return -1;
810 +probe_out:
811 + return ret;
812 }
813 EXPORT_SYMBOL_GPL(qla2x00_probe_one);
815 diff --git a/fs/char_dev.c b/fs/char_dev.c
816 --- a/fs/char_dev.c
817 +++ b/fs/char_dev.c
818 @@ -139,7 +139,7 @@ __unregister_chrdev_region(unsigned majo
819 struct char_device_struct *cd = NULL, **cp;
820 int i = major_to_index(major);
822 - up(&chrdevs_lock);
823 + down(&chrdevs_lock);
824 for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next)
825 if ((*cp)->major == major &&
826 (*cp)->baseminor == baseminor &&
827 diff --git a/fs/exec.c b/fs/exec.c
828 --- a/fs/exec.c
829 +++ b/fs/exec.c
830 @@ -649,6 +649,7 @@ static inline int de_thread(struct task_
831 }
832 sig->group_exit_task = NULL;
833 sig->notify_count = 0;
834 + sig->real_timer.data = (unsigned long)current;
835 spin_unlock_irq(lock);
837 /*
838 diff --git a/include/asm-i386/string.h b/include/asm-i386/string.h
839 --- a/include/asm-i386/string.h
840 +++ b/include/asm-i386/string.h
841 @@ -116,7 +116,8 @@ __asm__ __volatile__(
842 "orb $1,%%al\n"
843 "3:"
844 :"=a" (__res), "=&S" (d0), "=&D" (d1)
845 - :"1" (cs),"2" (ct));
846 + :"1" (cs),"2" (ct)
847 + :"memory");
848 return __res;
849 }
851 @@ -138,8 +139,9 @@ __asm__ __volatile__(
852 "3:\tsbbl %%eax,%%eax\n\t"
853 "orb $1,%%al\n"
854 "4:"
855 - :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
856 - :"1" (cs),"2" (ct),"3" (count));
857 + :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
858 + :"1" (cs),"2" (ct),"3" (count)
859 + :"memory");
860 return __res;
861 }
863 @@ -158,7 +160,9 @@ __asm__ __volatile__(
864 "movl $1,%1\n"
865 "2:\tmovl %1,%0\n\t"
866 "decl %0"
867 - :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c));
868 + :"=a" (__res), "=&S" (d0)
869 + :"1" (s),"0" (c)
870 + :"memory");
871 return __res;
872 }
874 @@ -175,7 +179,9 @@ __asm__ __volatile__(
875 "leal -1(%%esi),%0\n"
876 "2:\ttestb %%al,%%al\n\t"
877 "jne 1b"
878 - :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c));
879 + :"=g" (__res), "=&S" (d0), "=&a" (d1)
880 + :"0" (0),"1" (s),"2" (c)
881 + :"memory");
882 return __res;
883 }
885 @@ -189,7 +195,9 @@ __asm__ __volatile__(
886 "scasb\n\t"
887 "notl %0\n\t"
888 "decl %0"
889 - :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffffu));
890 + :"=c" (__res), "=&D" (d0)
891 + :"1" (s),"a" (0), "0" (0xffffffffu)
892 + :"memory");
893 return __res;
894 }
896 @@ -333,7 +341,9 @@ __asm__ __volatile__(
897 "je 1f\n\t"
898 "movl $1,%0\n"
899 "1:\tdecl %0"
900 - :"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count));
901 + :"=D" (__res), "=&c" (d0)
902 + :"a" (c),"0" (cs),"1" (count)
903 + :"memory");
904 return __res;
905 }
907 @@ -369,7 +379,7 @@ __asm__ __volatile__(
908 "je 2f\n\t"
909 "stosb\n"
910 "2:"
911 - : "=&c" (d0), "=&D" (d1)
912 + :"=&c" (d0), "=&D" (d1)
913 :"a" (c), "q" (count), "0" (count/4), "1" ((long) s)
914 :"memory");
915 return (s);
916 @@ -392,7 +402,8 @@ __asm__ __volatile__(
917 "jne 1b\n"
918 "3:\tsubl %2,%0"
919 :"=a" (__res), "=&d" (d0)
920 - :"c" (s),"1" (count));
921 + :"c" (s),"1" (count)
922 + :"memory");
923 return __res;
924 }
925 /* end of additional stuff */
926 @@ -473,7 +484,8 @@ static inline void * memscan(void * addr
927 "dec %%edi\n"
928 "1:"
929 : "=D" (addr), "=c" (size)
930 - : "0" (addr), "1" (size), "a" (c));
931 + : "0" (addr), "1" (size), "a" (c)
932 + : "memory");
933 return addr;
934 }
936 diff --git a/include/linux/if_shaper.h b/include/linux/if_shaper.h
937 --- a/include/linux/if_shaper.h
938 +++ b/include/linux/if_shaper.h
939 @@ -23,7 +23,7 @@ struct shaper
940 __u32 shapeclock;
941 unsigned long recovery; /* Time we can next clock a packet out on
942 an empty queue */
943 - struct semaphore sem;
944 + spinlock_t lock;
945 struct net_device_stats stats;
946 struct net_device *dev;
947 int (*hard_start_xmit) (struct sk_buff *skb,
948 diff --git a/mm/memory.c b/mm/memory.c
949 --- a/mm/memory.c
950 +++ b/mm/memory.c
951 @@ -1164,7 +1164,7 @@ int remap_pfn_range(struct vm_area_struc
952 {
953 pgd_t *pgd;
954 unsigned long next;
955 - unsigned long end = addr + size;
956 + unsigned long end = addr + PAGE_ALIGN(size);
957 struct mm_struct *mm = vma->vm_mm;
958 int err;
960 diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
961 --- a/net/ipv4/ip_output.c
962 +++ b/net/ipv4/ip_output.c
963 @@ -111,7 +111,6 @@ static int ip_dev_loopback_xmit(struct s
964 #ifdef CONFIG_NETFILTER_DEBUG
965 nf_debug_ip_loopback_xmit(newskb);
966 #endif
967 - nf_reset(newskb);
968 netif_rx(newskb);
969 return 0;
970 }
971 @@ -196,8 +195,6 @@ static inline int ip_finish_output2(stru
972 nf_debug_ip_finish_output2(skb);
973 #endif /*CONFIG_NETFILTER_DEBUG*/
975 - nf_reset(skb);
976 -
977 if (hh) {
978 int hh_alen;
980 diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
981 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c
982 +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
983 @@ -432,6 +432,13 @@ static unsigned int ip_conntrack_defrag(
984 const struct net_device *out,
985 int (*okfn)(struct sk_buff *))
986 {
987 +#if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
988 + /* Previously seen (loopback)? Ignore. Do this before
989 + fragment check. */
990 + if ((*pskb)->nfct)
991 + return NF_ACCEPT;
992 +#endif
993 +
994 /* Gather fragments. */
995 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
996 *pskb = ip_ct_gather_frags(*pskb,
997 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
998 --- a/net/netlink/af_netlink.c
999 +++ b/net/netlink/af_netlink.c
1000 @@ -315,8 +315,8 @@ err:
1001 static void netlink_remove(struct sock *sk)
1003 netlink_table_grab();
1004 - nl_table[sk->sk_protocol].hash.entries--;
1005 - sk_del_node_init(sk);
1006 + if (sk_del_node_init(sk))
1007 + nl_table[sk->sk_protocol].hash.entries--;
1008 if (nlk_sk(sk)->groups)
1009 __sk_del_bind_node(sk);
1010 netlink_table_ungrab();
1011 @@ -429,7 +429,12 @@ retry:
1012 err = netlink_insert(sk, pid);
1013 if (err == -EADDRINUSE)
1014 goto retry;
1015 - return 0;
1017 + /* If 2 threads race to autobind, that is fine. */
1018 + if (err == -EBUSY)
1019 + err = 0;
1021 + return err;
1024 static inline int netlink_capable(struct socket *sock, unsigned int flag)
1025 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
1026 --- a/net/packet/af_packet.c
1027 +++ b/net/packet/af_packet.c
1028 @@ -274,6 +274,9 @@ static int packet_rcv_spkt(struct sk_buf
1029 dst_release(skb->dst);
1030 skb->dst = NULL;
1032 + /* drop conntrack reference */
1033 + nf_reset(skb);
1035 spkt = (struct sockaddr_pkt*)skb->cb;
1037 skb_push(skb, skb->data-skb->mac.raw);
1038 @@ -517,6 +520,9 @@ static int packet_rcv(struct sk_buff *sk
1039 dst_release(skb->dst);
1040 skb->dst = NULL;
1042 + /* drop conntrack reference */
1043 + nf_reset(skb);
1045 spin_lock(&sk->sk_receive_queue.lock);
1046 po->stats.tp_packets++;
1047 __skb_queue_tail(&sk->sk_receive_queue, skb);