ia64/xen-unstable

changeset 8757:7cd3d2e41559

Update patches for Linux 2.6.16-rc2.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Feb 03 18:24:28 2006 +0000 (2006-02-03)
parents ce9170da40ae
children 57e6d7218427
files patches/linux-2.6.16-rc1-git4/i386-mach-io-check-nmi.patch patches/linux-2.6.16-rc1-git4/net-csum.patch patches/linux-2.6.16-rc1-git4/pmd-shared.patch patches/linux-2.6.16-rc1-git4/smp-alts.patch patches/linux-2.6.16-rc2/i386-mach-io-check-nmi.patch patches/linux-2.6.16-rc2/net-csum.patch patches/linux-2.6.16-rc2/pmd-shared.patch patches/linux-2.6.16-rc2/smp-alts.patch
line diff
     1.1 --- a/patches/linux-2.6.16-rc1-git4/i386-mach-io-check-nmi.patch	Fri Feb 03 18:10:40 2006 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,45 +0,0 @@
     1.4 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
     1.5 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/traps.c	2006-02-02 17:39:29.000000000 +0000
     1.6 -+++ ./arch/i386/kernel/traps.c	2006-02-02 17:43:01.000000000 +0000
     1.7 -@@ -564,18 +564,11 @@ static void mem_parity_error(unsigned ch
     1.8 - 
     1.9 - static void io_check_error(unsigned char reason, struct pt_regs * regs)
    1.10 - {
    1.11 --	unsigned long i;
    1.12 --
    1.13 - 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
    1.14 - 	show_registers(regs);
    1.15 - 
    1.16 - 	/* Re-enable the IOCK line, wait for a few seconds */
    1.17 --	reason = (reason & 0xf) | 8;
    1.18 --	outb(reason, 0x61);
    1.19 --	i = 2000;
    1.20 --	while (--i) udelay(1000);
    1.21 --	reason &= ~8;
    1.22 --	outb(reason, 0x61);
    1.23 -+	clear_io_check_error(reason);
    1.24 - }
    1.25 - 
    1.26 - static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
    1.27 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
    1.28 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/mach-default/mach_traps.h	2006-01-03 03:21:10.000000000 +0000
    1.29 -+++ ./include/asm-i386/mach-default/mach_traps.h	2006-02-02 17:41:55.000000000 +0000
    1.30 -@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
    1.31 - 	outb(reason, 0x61);
    1.32 - }
    1.33 - 
    1.34 -+static inline void clear_io_check_error(unsigned char reason)
    1.35 -+{
    1.36 -+	unsigned long i;
    1.37 -+
    1.38 -+	reason = (reason & 0xf) | 8;
    1.39 -+	outb(reason, 0x61);
    1.40 -+	i = 2000;
    1.41 -+	while (--i) udelay(1000);
    1.42 -+	reason &= ~8;
    1.43 -+	outb(reason, 0x61);
    1.44 -+}
    1.45 -+
    1.46 - static inline unsigned char get_nmi_reason(void)
    1.47 - {
    1.48 - 	return inb(0x61);
     2.1 --- a/patches/linux-2.6.16-rc1-git4/net-csum.patch	Fri Feb 03 18:10:40 2006 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,46 +0,0 @@
     2.4 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
     2.5 ---- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:39:51.000000000 +0000
     2.6 -+++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:44:18.000000000 +0000
     2.7 -@@ -129,10 +129,16 @@ tcp_manip_pkt(struct sk_buff **pskb,
     2.8 - 	if (hdrsize < sizeof(*hdr))
     2.9 - 		return 1;
    2.10 - 
    2.11 --	hdr->check = ip_nat_cheat_check(~oldip, newip,
    2.12 -+	if ((*pskb)->proto_csum_blank) {
    2.13 -+		hdr->check = ip_nat_cheat_check(oldip, ~newip,
    2.14 -+				ip_nat_cheat_check(oldport ^ 0xFFFF,
    2.15 -+					newport, hdr->check));
    2.16 -+	} else { 
    2.17 -+		hdr->check = ip_nat_cheat_check(~oldip, newip,
    2.18 - 					ip_nat_cheat_check(oldport ^ 0xFFFF,
    2.19 - 							   newport,
    2.20 - 							   hdr->check));
    2.21 -+	}
    2.22 - 	return 1;
    2.23 - }
    2.24 - 
    2.25 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
    2.26 ---- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:39:51.000000000 +0000
    2.27 -+++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:44:18.000000000 +0000
    2.28 -@@ -113,11 +113,19 @@ udp_manip_pkt(struct sk_buff **pskb,
    2.29 - 		newport = tuple->dst.u.udp.port;
    2.30 - 		portptr = &hdr->dest;
    2.31 - 	}
    2.32 --	if (hdr->check) /* 0 is a special case meaning no checksum */
    2.33 --		hdr->check = ip_nat_cheat_check(~oldip, newip,
    2.34 -+	
    2.35 -+	if (hdr->check) { /* 0 is a special case meaning no checksum */
    2.36 -+		if ((*pskb)->proto_csum_blank) {
    2.37 -+			hdr->check = ip_nat_cheat_check(oldip, ~newip, 
    2.38 -+					ip_nat_cheat_check(*portptr ^ 0xFFFF, 
    2.39 -+						newport, hdr->check));
    2.40 -+		} else {
    2.41 -+			hdr->check = ip_nat_cheat_check(~oldip, newip,
    2.42 - 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
    2.43 - 							   newport,
    2.44 - 							   hdr->check));
    2.45 -+		}
    2.46 -+	}
    2.47 - 	*portptr = newport;
    2.48 - 	return 1;
    2.49 - }
     3.1 --- a/patches/linux-2.6.16-rc1-git4/pmd-shared.patch	Fri Feb 03 18:10:40 2006 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,111 +0,0 @@
     3.4 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
     3.5 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c	2006-02-02 17:39:29.000000000 +0000
     3.6 -+++ ./arch/i386/mm/pageattr.c	2006-02-02 17:45:14.000000000 +0000
     3.7 -@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
     3.8 - 	unsigned long flags;
     3.9 - 
    3.10 - 	set_pte_atomic(kpte, pte); 	/* change init_mm */
    3.11 --	if (PTRS_PER_PMD > 1)
    3.12 -+	if (HAVE_SHARED_KERNEL_PMD)
    3.13 - 		return;
    3.14 - 
    3.15 - 	spin_lock_irqsave(&pgd_lock, flags);
    3.16 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
    3.17 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c	2006-01-03 03:21:10.000000000 +0000
    3.18 -+++ ./arch/i386/mm/pgtable.c	2006-02-02 17:45:14.000000000 +0000
    3.19 -@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
    3.20 - 		spin_lock_irqsave(&pgd_lock, flags);
    3.21 - 	}
    3.22 - 
    3.23 --	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
    3.24 --			swapper_pg_dir + USER_PTRS_PER_PGD,
    3.25 --			KERNEL_PGD_PTRS);
    3.26 -+	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
    3.27 -+		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
    3.28 -+				swapper_pg_dir + USER_PTRS_PER_PGD,
    3.29 -+				KERNEL_PGD_PTRS);
    3.30 - 	if (PTRS_PER_PMD > 1)
    3.31 - 		return;
    3.32 - 
    3.33 -@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
    3.34 - 			goto out_oom;
    3.35 - 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
    3.36 - 	}
    3.37 -+
    3.38 -+	if (!HAVE_SHARED_KERNEL_PMD) {
    3.39 -+		unsigned long flags;
    3.40 -+
    3.41 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
    3.42 -+			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
    3.43 -+			if (!pmd)
    3.44 -+				goto out_oom;
    3.45 -+			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
    3.46 -+		}
    3.47 -+
    3.48 -+		spin_lock_irqsave(&pgd_lock, flags);
    3.49 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
    3.50 -+			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
    3.51 -+			pgd_t *kpgd = pgd_offset_k(v);
    3.52 -+			pud_t *kpud = pud_offset(kpgd, v);
    3.53 -+			pmd_t *kpmd = pmd_offset(kpud, v);
    3.54 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    3.55 -+			memcpy(pmd, kpmd, PAGE_SIZE);
    3.56 -+		}
    3.57 -+		pgd_list_add(pgd);
    3.58 -+		spin_unlock_irqrestore(&pgd_lock, flags);
    3.59 -+	}
    3.60 -+
    3.61 - 	return pgd;
    3.62 - 
    3.63 - out_oom:
    3.64 -@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
    3.65 - 	int i;
    3.66 - 
    3.67 - 	/* in the PAE case user pgd entries are overwritten before usage */
    3.68 --	if (PTRS_PER_PMD > 1)
    3.69 --		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
    3.70 --			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
    3.71 -+	if (PTRS_PER_PMD > 1) {
    3.72 -+		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
    3.73 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    3.74 -+			kmem_cache_free(pmd_cache, pmd);
    3.75 -+		}
    3.76 -+		if (!HAVE_SHARED_KERNEL_PMD) {
    3.77 -+			unsigned long flags;
    3.78 -+			spin_lock_irqsave(&pgd_lock, flags);
    3.79 -+			pgd_list_del(pgd);
    3.80 -+			spin_unlock_irqrestore(&pgd_lock, flags);
    3.81 -+			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
    3.82 -+				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    3.83 -+				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
    3.84 -+				kmem_cache_free(pmd_cache, pmd);
    3.85 -+			}
    3.86 -+		}
    3.87 -+	}
    3.88 - 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
    3.89 - 	kmem_cache_free(pgd_cache, pgd);
    3.90 - }
    3.91 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
    3.92 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h	2006-01-03 03:21:10.000000000 +0000
    3.93 -+++ ./include/asm-i386/pgtable-2level-defs.h	2006-02-02 17:45:14.000000000 +0000
    3.94 -@@ -1,6 +1,8 @@
    3.95 - #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
    3.96 - #define _I386_PGTABLE_2LEVEL_DEFS_H
    3.97 - 
    3.98 -+#define HAVE_SHARED_KERNEL_PMD 0
    3.99 -+
   3.100 - /*
   3.101 -  * traditional i386 two-level paging structure:
   3.102 -  */
   3.103 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
   3.104 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h	2006-01-03 03:21:10.000000000 +0000
   3.105 -+++ ./include/asm-i386/pgtable-3level-defs.h	2006-02-02 17:45:14.000000000 +0000
   3.106 -@@ -1,6 +1,8 @@
   3.107 - #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
   3.108 - #define _I386_PGTABLE_3LEVEL_DEFS_H
   3.109 - 
   3.110 -+#define HAVE_SHARED_KERNEL_PMD 1
   3.111 -+
   3.112 - /*
   3.113 -  * PGDIR_SHIFT determines what a top-level page table entry can map
   3.114 -  */
     4.1 --- a/patches/linux-2.6.16-rc1-git4/smp-alts.patch	Fri Feb 03 18:10:40 2006 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,593 +0,0 @@
     4.4 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/Kconfig ./arch/i386/Kconfig
     4.5 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/Kconfig	2006-02-02 17:39:28.000000000 +0000
     4.6 -+++ ./arch/i386/Kconfig	2006-02-02 17:45:59.000000000 +0000
     4.7 -@@ -211,6 +211,19 @@ config SMP
     4.8 - 
     4.9 - 	  If you don't know what to do here, say N.
    4.10 - 
    4.11 -+config SMP_ALTERNATIVES
    4.12 -+	bool "SMP alternatives support (EXPERIMENTAL)"
    4.13 -+	depends on SMP && EXPERIMENTAL
    4.14 -+	help
    4.15 -+	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
    4.16 -+	  host slightly by replacing certain key instruction sequences
    4.17 -+	  according to whether we currently have more than one CPU available.
    4.18 -+	  This should provide a noticeable boost to performance when
    4.19 -+	  running SMP kernels on UP machines, and have negligible impact
    4.20 -+	  when running on an true SMP host.
    4.21 -+
    4.22 -+          If unsure, say N.
    4.23 -+	  
    4.24 - config NR_CPUS
    4.25 - 	int "Maximum number of CPUs (2-255)"
    4.26 - 	range 2 255
    4.27 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
    4.28 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/Makefile	2006-02-02 17:39:28.000000000 +0000
    4.29 -+++ ./arch/i386/kernel/Makefile	2006-02-02 17:45:59.000000000 +0000
    4.30 -@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
    4.31 - obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
    4.32 - obj-$(CONFIG_VM86)		+= vm86.o
    4.33 - obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
    4.34 -+obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
    4.35 - 
    4.36 - EXTRA_AFLAGS   := -traditional
    4.37 - 
    4.38 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
    4.39 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
    4.40 -+++ ./arch/i386/kernel/smpalts.c	2006-02-02 17:45:59.000000000 +0000
    4.41 -@@ -0,0 +1,85 @@
    4.42 -+#include <linux/kernel.h>
    4.43 -+#include <asm/system.h>
    4.44 -+#include <asm/smp_alt.h>
    4.45 -+#include <asm/processor.h>
    4.46 -+#include <asm/string.h>
    4.47 -+
    4.48 -+struct smp_replacement_record {
    4.49 -+	unsigned char targ_size;
    4.50 -+	unsigned char smp1_size;
    4.51 -+	unsigned char smp2_size;
    4.52 -+	unsigned char up_size;
    4.53 -+	unsigned char feature;
    4.54 -+	unsigned char data[0];
    4.55 -+};
    4.56 -+
    4.57 -+struct smp_alternative_record {
    4.58 -+	void *targ_start;
    4.59 -+	struct smp_replacement_record *repl;
    4.60 -+};
    4.61 -+
    4.62 -+extern struct smp_alternative_record __start_smp_alternatives_table,
    4.63 -+  __stop_smp_alternatives_table;
    4.64 -+extern unsigned long __init_begin, __init_end;
    4.65 -+
    4.66 -+void prepare_for_smp(void)
    4.67 -+{
    4.68 -+	struct smp_alternative_record *r;
    4.69 -+	printk(KERN_INFO "Enabling SMP...\n");
    4.70 -+	for (r = &__start_smp_alternatives_table;
    4.71 -+	     r != &__stop_smp_alternatives_table;
    4.72 -+	     r++) {
    4.73 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
    4.74 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
    4.75 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
    4.76 -+               if (system_state == SYSTEM_RUNNING &&
    4.77 -+                   r->targ_start >= (void *)&__init_begin &&
    4.78 -+                   r->targ_start < (void *)&__init_end)
    4.79 -+                       continue;
    4.80 -+		if (r->repl->feature != (unsigned char)-1 &&
    4.81 -+		    boot_cpu_has(r->repl->feature)) {
    4.82 -+			memcpy(r->targ_start,
    4.83 -+			       r->repl->data + r->repl->smp1_size,
    4.84 -+			       r->repl->smp2_size);
    4.85 -+			memset(r->targ_start + r->repl->smp2_size,
    4.86 -+			       0x90,
    4.87 -+			       r->repl->targ_size - r->repl->smp2_size);
    4.88 -+		} else {
    4.89 -+			memcpy(r->targ_start,
    4.90 -+			       r->repl->data,
    4.91 -+			       r->repl->smp1_size);
    4.92 -+			memset(r->targ_start + r->repl->smp1_size,
    4.93 -+			       0x90,
    4.94 -+			       r->repl->targ_size - r->repl->smp1_size);
    4.95 -+		}
    4.96 -+	}
    4.97 -+	/* Paranoia */
    4.98 -+	asm volatile ("jmp 1f\n1:");
    4.99 -+	mb();
   4.100 -+}
   4.101 -+
   4.102 -+void unprepare_for_smp(void)
   4.103 -+{
   4.104 -+	struct smp_alternative_record *r;
   4.105 -+	printk(KERN_INFO "Disabling SMP...\n");
   4.106 -+	for (r = &__start_smp_alternatives_table;
   4.107 -+	     r != &__stop_smp_alternatives_table;
   4.108 -+	     r++) {
   4.109 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   4.110 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   4.111 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
   4.112 -+               if (system_state == SYSTEM_RUNNING &&
   4.113 -+                   r->targ_start >= (void *)&__init_begin &&
   4.114 -+                   r->targ_start < (void *)&__init_end)
   4.115 -+                       continue;
   4.116 -+		memcpy(r->targ_start,
   4.117 -+		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
   4.118 -+		       r->repl->up_size);
   4.119 -+		memset(r->targ_start + r->repl->up_size,
   4.120 -+		       0x90,
   4.121 -+		       r->repl->targ_size - r->repl->up_size);
   4.122 -+	}
   4.123 -+	/* Paranoia */
   4.124 -+	asm volatile ("jmp 1f\n1:");
   4.125 -+	mb();
   4.126 -+}
   4.127 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
   4.128 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/smpboot.c	2006-02-02 17:39:29.000000000 +0000
   4.129 -+++ ./arch/i386/kernel/smpboot.c	2006-02-02 17:45:59.000000000 +0000
   4.130 -@@ -1218,6 +1218,11 @@ static void __init smp_boot_cpus(unsigne
   4.131 - 		if (max_cpus <= cpucount+1)
   4.132 - 			continue;
   4.133 - 
   4.134 -+#ifdef CONFIG_SMP_ALTERNATIVES
   4.135 -+		if (kicked == 1)
   4.136 -+			prepare_for_smp();
   4.137 -+#endif
   4.138 -+
   4.139 - 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
   4.140 - 			printk("CPU #%d not responding - cannot use it.\n",
   4.141 - 								apicid);
   4.142 -@@ -1396,6 +1401,11 @@ int __devinit __cpu_up(unsigned int cpu)
   4.143 - 		return -EIO;
   4.144 - 	}
   4.145 - 
   4.146 -+#ifdef CONFIG_SMP_ALTERNATIVES
   4.147 -+	if (num_online_cpus() == 1)
   4.148 -+		prepare_for_smp();
   4.149 -+#endif
   4.150 -+
   4.151 - 	local_irq_enable();
   4.152 - 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
   4.153 - 	/* Unleash the CPU! */
   4.154 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
   4.155 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/vmlinux.lds.S	2006-01-03 03:21:10.000000000 +0000
   4.156 -+++ ./arch/i386/kernel/vmlinux.lds.S	2006-02-02 17:45:59.000000000 +0000
   4.157 -@@ -34,6 +34,13 @@ SECTIONS
   4.158 -   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
   4.159 -   __stop___ex_table = .;
   4.160 - 
   4.161 -+  . = ALIGN(16);
   4.162 -+  __start_smp_alternatives_table = .;
   4.163 -+  __smp_alternatives : { *(__smp_alternatives) }
   4.164 -+  __stop_smp_alternatives_table = .;
   4.165 -+
   4.166 -+  __smp_replacements : { *(__smp_replacements) }
   4.167 -+
   4.168 -   RODATA
   4.169 - 
   4.170 -   /* writeable */
   4.171 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
   4.172 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/atomic.h	2006-02-02 17:39:31.000000000 +0000
   4.173 -+++ ./include/asm-i386/atomic.h	2006-02-02 17:45:59.000000000 +0000
   4.174 -@@ -4,18 +4,13 @@
   4.175 - #include <linux/config.h>
   4.176 - #include <linux/compiler.h>
   4.177 - #include <asm/processor.h>
   4.178 -+#include <asm/smp_alt.h>
   4.179 - 
   4.180 - /*
   4.181 -  * Atomic operations that C can't guarantee us.  Useful for
   4.182 -  * resource counting etc..
   4.183 -  */
   4.184 - 
   4.185 --#ifdef CONFIG_SMP
   4.186 --#define LOCK "lock ; "
   4.187 --#else
   4.188 --#define LOCK ""
   4.189 --#endif
   4.190 --
   4.191 - /*
   4.192 -  * Make sure gcc doesn't try to be clever and move things around
   4.193 -  * on us. We need to use _exactly_ the address the user gave us,
   4.194 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
   4.195 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/bitops.h	2006-02-02 17:39:31.000000000 +0000
   4.196 -+++ ./include/asm-i386/bitops.h	2006-02-02 17:45:59.000000000 +0000
   4.197 -@@ -7,6 +7,7 @@
   4.198 - 
   4.199 - #include <linux/config.h>
   4.200 - #include <linux/compiler.h>
   4.201 -+#include <asm/smp_alt.h>
   4.202 - 
   4.203 - /*
   4.204 -  * These have to be done with inline assembly: that way the bit-setting
   4.205 -@@ -16,12 +17,6 @@
   4.206 -  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
   4.207 -  */
   4.208 - 
   4.209 --#ifdef CONFIG_SMP
   4.210 --#define LOCK_PREFIX "lock ; "
   4.211 --#else
   4.212 --#define LOCK_PREFIX ""
   4.213 --#endif
   4.214 --
   4.215 - #define ADDR (*(volatile long *) addr)
   4.216 - 
   4.217 - /**
   4.218 -@@ -41,7 +36,7 @@
   4.219 -  */
   4.220 - static inline void set_bit(int nr, volatile unsigned long * addr)
   4.221 - {
   4.222 --	__asm__ __volatile__( LOCK_PREFIX
   4.223 -+	__asm__ __volatile__( LOCK
   4.224 - 		"btsl %1,%0"
   4.225 - 		:"+m" (ADDR)
   4.226 - 		:"Ir" (nr));
   4.227 -@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
   4.228 -  */
   4.229 - static inline void clear_bit(int nr, volatile unsigned long * addr)
   4.230 - {
   4.231 --	__asm__ __volatile__( LOCK_PREFIX
   4.232 -+	__asm__ __volatile__( LOCK
   4.233 - 		"btrl %1,%0"
   4.234 - 		:"+m" (ADDR)
   4.235 - 		:"Ir" (nr));
   4.236 -@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
   4.237 -  */
   4.238 - static inline void change_bit(int nr, volatile unsigned long * addr)
   4.239 - {
   4.240 --	__asm__ __volatile__( LOCK_PREFIX
   4.241 -+	__asm__ __volatile__( LOCK
   4.242 - 		"btcl %1,%0"
   4.243 - 		:"+m" (ADDR)
   4.244 - 		:"Ir" (nr));
   4.245 -@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
   4.246 - {
   4.247 - 	int oldbit;
   4.248 - 
   4.249 --	__asm__ __volatile__( LOCK_PREFIX
   4.250 -+	__asm__ __volatile__( LOCK
   4.251 - 		"btsl %2,%1\n\tsbbl %0,%0"
   4.252 - 		:"=r" (oldbit),"+m" (ADDR)
   4.253 - 		:"Ir" (nr) : "memory");
   4.254 -@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
   4.255 - {
   4.256 - 	int oldbit;
   4.257 - 
   4.258 --	__asm__ __volatile__( LOCK_PREFIX
   4.259 -+	__asm__ __volatile__( LOCK
   4.260 - 		"btrl %2,%1\n\tsbbl %0,%0"
   4.261 - 		:"=r" (oldbit),"+m" (ADDR)
   4.262 - 		:"Ir" (nr) : "memory");
   4.263 -@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
   4.264 - {
   4.265 - 	int oldbit;
   4.266 - 
   4.267 --	__asm__ __volatile__( LOCK_PREFIX
   4.268 -+	__asm__ __volatile__( LOCK
   4.269 - 		"btcl %2,%1\n\tsbbl %0,%0"
   4.270 - 		:"=r" (oldbit),"+m" (ADDR)
   4.271 - 		:"Ir" (nr) : "memory");
   4.272 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/futex.h ./include/asm-i386/futex.h
   4.273 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/futex.h	2006-02-02 17:40:00.000000000 +0000
   4.274 -+++ ./include/asm-i386/futex.h	2006-02-02 17:45:59.000000000 +0000
   4.275 -@@ -28,7 +28,7 @@
   4.276 - "1:	movl	%2, %0\n\
   4.277 - 	movl	%0, %3\n"					\
   4.278 - 	insn "\n"						\
   4.279 --"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
   4.280 -+"2:	" LOCK "cmpxchgl %3, %2\n\
   4.281 - 	jnz	1b\n\
   4.282 - 3:	.section .fixup,\"ax\"\n\
   4.283 - 4:	mov	%5, %1\n\
   4.284 -@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
   4.285 - #endif
   4.286 - 		switch (op) {
   4.287 - 		case FUTEX_OP_ADD:
   4.288 --			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
   4.289 -+			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
   4.290 - 					   oldval, uaddr, oparg);
   4.291 - 			break;
   4.292 - 		case FUTEX_OP_OR:
   4.293 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
   4.294 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/rwsem.h	2006-01-03 03:21:10.000000000 +0000
   4.295 -+++ ./include/asm-i386/rwsem.h	2006-02-02 17:45:59.000000000 +0000
   4.296 -@@ -40,6 +40,7 @@
   4.297 - 
   4.298 - #include <linux/list.h>
   4.299 - #include <linux/spinlock.h>
   4.300 -+#include <asm/smp_alt.h>
   4.301 - 
   4.302 - struct rwsem_waiter;
   4.303 - 
   4.304 -@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
   4.305 - {
   4.306 - 	__asm__ __volatile__(
   4.307 - 		"# beginning down_read\n\t"
   4.308 --LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
   4.309 -+LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
   4.310 - 		"  js        2f\n\t" /* jump if we weren't granted the lock */
   4.311 - 		"1:\n\t"
   4.312 - 		LOCK_SECTION_START("")
   4.313 -@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
   4.314 - 		"  movl	     %1,%2\n\t"
   4.315 - 		"  addl      %3,%2\n\t"
   4.316 - 		"  jle	     2f\n\t"
   4.317 --LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
   4.318 -+LOCK	        "  cmpxchgl  %2,%0\n\t"
   4.319 - 		"  jnz	     1b\n\t"
   4.320 - 		"2:\n\t"
   4.321 - 		"# ending __down_read_trylock\n\t"
   4.322 -@@ -150,7 +151,7 @@ static inline void __down_write(struct r
   4.323 - 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
   4.324 - 	__asm__ __volatile__(
   4.325 - 		"# beginning down_write\n\t"
   4.326 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
   4.327 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
   4.328 - 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
   4.329 - 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
   4.330 - 		"1:\n\t"
   4.331 -@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
   4.332 - 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
   4.333 - 	__asm__ __volatile__(
   4.334 - 		"# beginning __up_read\n\t"
   4.335 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
   4.336 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
   4.337 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
   4.338 - 		"1:\n\t"
   4.339 - 		LOCK_SECTION_START("")
   4.340 -@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
   4.341 - 	__asm__ __volatile__(
   4.342 - 		"# beginning __up_write\n\t"
   4.343 - 		"  movl      %2,%%edx\n\t"
   4.344 --LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
   4.345 -+LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
   4.346 - 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
   4.347 - 		"1:\n\t"
   4.348 - 		LOCK_SECTION_START("")
   4.349 -@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
   4.350 - {
   4.351 - 	__asm__ __volatile__(
   4.352 - 		"# beginning __downgrade_write\n\t"
   4.353 --LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
   4.354 -+LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
   4.355 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
   4.356 - 		"1:\n\t"
   4.357 - 		LOCK_SECTION_START("")
   4.358 -@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
   4.359 - static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
   4.360 - {
   4.361 - 	__asm__ __volatile__(
   4.362 --LOCK_PREFIX	"addl %1,%0"
   4.363 -+LOCK	          "addl %1,%0"
   4.364 - 		: "=m"(sem->count)
   4.365 - 		: "ir"(delta), "m"(sem->count));
   4.366 - }
   4.367 -@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
   4.368 - 	int tmp = delta;
   4.369 - 
   4.370 - 	__asm__ __volatile__(
   4.371 --LOCK_PREFIX	"xadd %0,(%2)"
   4.372 -+LOCK  	          "xadd %0,(%2)"
   4.373 - 		: "+r"(tmp), "=m"(sem->count)
   4.374 - 		: "r"(sem), "m"(sem->count)
   4.375 - 		: "memory");
   4.376 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
   4.377 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
   4.378 -+++ ./include/asm-i386/smp_alt.h	2006-02-02 17:45:59.000000000 +0000
   4.379 -@@ -0,0 +1,32 @@
   4.380 -+#ifndef __ASM_SMP_ALT_H__
   4.381 -+#define __ASM_SMP_ALT_H__
   4.382 -+
   4.383 -+#include <linux/config.h>
   4.384 -+
   4.385 -+#ifdef CONFIG_SMP
   4.386 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
   4.387 -+#define LOCK \
   4.388 -+        "6677: nop\n" \
   4.389 -+	".section __smp_alternatives,\"a\"\n" \
   4.390 -+	".long 6677b\n" \
   4.391 -+	".long 6678f\n" \
   4.392 -+	".previous\n" \
   4.393 -+	".section __smp_replacements,\"a\"\n" \
   4.394 -+	"6678: .byte 1\n" \
   4.395 -+	".byte 1\n" \
   4.396 -+	".byte 0\n" \
   4.397 -+        ".byte 1\n" \
   4.398 -+	".byte -1\n" \
   4.399 -+	"lock\n" \
   4.400 -+	"nop\n" \
   4.401 -+	".previous\n"
   4.402 -+void prepare_for_smp(void);
   4.403 -+void unprepare_for_smp(void);
   4.404 -+#else
   4.405 -+#define LOCK "lock ; "
   4.406 -+#endif
   4.407 -+#else
   4.408 -+#define LOCK ""
   4.409 -+#endif
   4.410 -+
   4.411 -+#endif /* __ASM_SMP_ALT_H__ */
   4.412 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
   4.413 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/spinlock.h	2006-01-03 03:21:10.000000000 +0000
   4.414 -+++ ./include/asm-i386/spinlock.h	2006-02-02 17:45:59.000000000 +0000
   4.415 -@@ -6,6 +6,7 @@
   4.416 - #include <asm/page.h>
   4.417 - #include <linux/config.h>
   4.418 - #include <linux/compiler.h>
   4.419 -+#include <asm/smp_alt.h>
   4.420 - 
   4.421 - /*
   4.422 -  * Your basic SMP spinlocks, allowing only a single CPU anywhere
   4.423 -@@ -23,7 +24,8 @@
   4.424 - 
   4.425 - #define __raw_spin_lock_string \
   4.426 - 	"\n1:\t" \
   4.427 --	"lock ; decb %0\n\t" \
   4.428 -+	LOCK \
   4.429 -+	"decb %0\n\t" \
   4.430 - 	"jns 3f\n" \
   4.431 - 	"2:\t" \
   4.432 - 	"rep;nop\n\t" \
   4.433 -@@ -34,7 +36,8 @@
   4.434 - 
   4.435 - #define __raw_spin_lock_string_flags \
   4.436 - 	"\n1:\t" \
   4.437 --	"lock ; decb %0\n\t" \
   4.438 -+	LOCK \
   4.439 -+	"decb %0\n\t" \
   4.440 - 	"jns 4f\n\t" \
   4.441 - 	"2:\t" \
   4.442 - 	"testl $0x200, %1\n\t" \
   4.443 -@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
   4.444 - static inline int __raw_spin_trylock(raw_spinlock_t *lock)
   4.445 - {
   4.446 - 	char oldval;
   4.447 -+#ifdef CONFIG_SMP_ALTERNATIVES
   4.448 - 	__asm__ __volatile__(
   4.449 --		"xchgb %b0,%1"
   4.450 -+		"1:movb %1,%b0\n"
   4.451 -+		"movb $0,%1\n"
   4.452 -+		"2:"
   4.453 -+		".section __smp_alternatives,\"a\"\n"
   4.454 -+		".long 1b\n"
   4.455 -+		".long 3f\n"
   4.456 -+		".previous\n"
   4.457 -+		".section __smp_replacements,\"a\"\n"
   4.458 -+		"3: .byte 2b - 1b\n"
   4.459 -+		".byte 5f-4f\n"
   4.460 -+		".byte 0\n"
   4.461 -+		".byte 6f-5f\n"
   4.462 -+		".byte -1\n"
   4.463 -+		"4: xchgb %b0,%1\n"
   4.464 -+		"5: movb %1,%b0\n"
   4.465 -+		"movb $0,%1\n"
   4.466 -+		"6:\n"
   4.467 -+		".previous\n"
   4.468 - 		:"=q" (oldval), "=m" (lock->slock)
   4.469 - 		:"0" (0) : "memory");
   4.470 -+#else
   4.471 -+	__asm__ __volatile__(
   4.472 -+		"xchgb %b0,%1\n"
   4.473 -+		:"=q" (oldval), "=m" (lock->slock)
   4.474 -+		:"0" (0) : "memory");
   4.475 -+#endif
   4.476 - 	return oldval > 0;
   4.477 - }
   4.478 - 
   4.479 -@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
   4.480 - 
   4.481 - static inline void __raw_read_unlock(raw_rwlock_t *rw)
   4.482 - {
   4.483 --	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
   4.484 -+	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
   4.485 - }
   4.486 - 
   4.487 - static inline void __raw_write_unlock(raw_rwlock_t *rw)
   4.488 - {
   4.489 --	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
   4.490 -+	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
   4.491 - 				 : "=m" (rw->lock) : : "memory");
   4.492 - }
   4.493 - 
   4.494 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/system.h ./include/asm-i386/system.h
   4.495 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/system.h	2006-02-02 17:39:31.000000000 +0000
   4.496 -+++ ./include/asm-i386/system.h	2006-02-02 17:45:59.000000000 +0000
   4.497 -@@ -5,7 +5,7 @@
   4.498 - #include <linux/kernel.h>
   4.499 - #include <asm/segment.h>
   4.500 - #include <asm/cpufeature.h>
   4.501 --#include <linux/bitops.h> /* for LOCK_PREFIX */
   4.502 -+#include <asm/smp_alt.h>
   4.503 - 
   4.504 - #ifdef __KERNEL__
   4.505 - 
   4.506 -@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
   4.507 - 	unsigned long prev;
   4.508 - 	switch (size) {
   4.509 - 	case 1:
   4.510 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
   4.511 -+		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
   4.512 - 				     : "=a"(prev)
   4.513 - 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
   4.514 - 				     : "memory");
   4.515 - 		return prev;
   4.516 - 	case 2:
   4.517 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
   4.518 -+		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
   4.519 - 				     : "=a"(prev)
   4.520 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
   4.521 - 				     : "memory");
   4.522 - 		return prev;
   4.523 - 	case 4:
   4.524 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
   4.525 -+		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
   4.526 - 				     : "=a"(prev)
   4.527 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
   4.528 - 				     : "memory");
   4.529 -@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
   4.530 - 				      unsigned long long new)
   4.531 - {
   4.532 - 	unsigned long long prev;
   4.533 --	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
   4.534 -+	__asm__ __volatile__(LOCK "cmpxchg8b %3"
   4.535 - 			     : "=A"(prev)
   4.536 - 			     : "b"((unsigned long)new),
   4.537 - 			       "c"((unsigned long)(new >> 32)),
   4.538 -@@ -503,11 +503,55 @@ struct alt_instr { 
   4.539 - #endif
   4.540 - 
   4.541 - #ifdef CONFIG_SMP
   4.542 --#define smp_mb()	mb()
   4.543 --#define smp_rmb()	rmb()
   4.544 - #define smp_wmb()	wmb()
   4.545 --#define smp_read_barrier_depends()	read_barrier_depends()
   4.546 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
   4.547 -+#define smp_alt_mb(instr)                                           \
   4.548 -+__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
   4.549 -+		     ".section __smp_alternatives,\"a\"\n"          \
   4.550 -+		     ".long 6667b\n"                                \
   4.551 -+                     ".long 6673f\n"                                \
   4.552 -+		     ".previous\n"                                  \
   4.553 -+		     ".section __smp_replacements,\"a\"\n"          \
   4.554 -+		     "6673:.byte 6668b-6667b\n"                     \
   4.555 -+		     ".byte 6670f-6669f\n"                          \
   4.556 -+		     ".byte 6671f-6670f\n"                          \
   4.557 -+                     ".byte 0\n"                                    \
   4.558 -+		     ".byte %c0\n"                                  \
   4.559 -+		     "6669:lock;addl $0,0(%%esp)\n"                 \
   4.560 -+		     "6670:" instr "\n"                             \
   4.561 -+		     "6671:\n"                                      \
   4.562 -+		     ".previous\n"                                  \
   4.563 -+		     :                                              \
   4.564 -+		     : "i" (X86_FEATURE_XMM2)                       \
   4.565 -+		     : "memory")
   4.566 -+#define smp_rmb() smp_alt_mb("lfence")
   4.567 -+#define smp_mb()  smp_alt_mb("mfence")
   4.568 -+#define set_mb(var, value) do {                                     \
   4.569 -+unsigned long __set_mb_temp;                                        \
   4.570 -+__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
   4.571 -+		     ".section __smp_alternatives,\"a\"\n"          \
   4.572 -+		     ".long 6667b\n"                                \
   4.573 -+		     ".long 6673f\n"                                \
   4.574 -+		     ".previous\n"                                  \
   4.575 -+		     ".section __smp_replacements,\"a\"\n"          \
   4.576 -+		     "6673: .byte 6668b-6667b\n"                    \
   4.577 -+		     ".byte 6670f-6669f\n"                          \
   4.578 -+		     ".byte 0\n"                                    \
   4.579 -+		     ".byte 6671f-6670f\n"                          \
   4.580 -+		     ".byte -1\n"                                   \
   4.581 -+		     "6669: xchg %1, %0\n"                          \
   4.582 -+		     "6670:movl %1, %0\n"                           \
   4.583 -+		     "6671:\n"                                      \
   4.584 -+		     ".previous\n"                                  \
   4.585 -+		     : "=m" (var), "=r" (__set_mb_temp)             \
   4.586 -+		     : "1" (value)                                  \
   4.587 -+		     : "memory"); } while (0)
   4.588 -+#else
   4.589 -+#define smp_rmb()	rmb()
   4.590 -+#define smp_mb()	mb()
   4.591 - #define set_mb(var, value) do { xchg(&var, value); } while (0)
   4.592 -+#endif
   4.593 -+#define smp_read_barrier_depends()	read_barrier_depends()
   4.594 - #else
   4.595 - #define smp_mb()	barrier()
   4.596 - #define smp_rmb()	barrier()
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/patches/linux-2.6.16-rc2/i386-mach-io-check-nmi.patch	Fri Feb 03 18:24:28 2006 +0000
     5.3 @@ -0,0 +1,45 @@
     5.4 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
     5.5 +--- ../pristine-linux-2.6.16-rc1-git4/arch/i386/kernel/traps.c	2006-02-02 17:39:29.000000000 +0000
     5.6 ++++ ./arch/i386/kernel/traps.c	2006-02-02 17:43:01.000000000 +0000
     5.7 +@@ -564,18 +564,11 @@ static void mem_parity_error(unsigned ch
     5.8 + 
     5.9 + static void io_check_error(unsigned char reason, struct pt_regs * regs)
    5.10 + {
    5.11 +-	unsigned long i;
    5.12 +-
    5.13 + 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
    5.14 + 	show_registers(regs);
    5.15 + 
    5.16 + 	/* Re-enable the IOCK line, wait for a few seconds */
    5.17 +-	reason = (reason & 0xf) | 8;
    5.18 +-	outb(reason, 0x61);
    5.19 +-	i = 2000;
    5.20 +-	while (--i) udelay(1000);
    5.21 +-	reason &= ~8;
    5.22 +-	outb(reason, 0x61);
    5.23 ++	clear_io_check_error(reason);
    5.24 + }
    5.25 + 
    5.26 + static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
    5.27 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
    5.28 +--- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/mach-default/mach_traps.h	2006-01-03 03:21:10.000000000 +0000
    5.29 ++++ ./include/asm-i386/mach-default/mach_traps.h	2006-02-02 17:41:55.000000000 +0000
    5.30 +@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
    5.31 + 	outb(reason, 0x61);
    5.32 + }
    5.33 + 
    5.34 ++static inline void clear_io_check_error(unsigned char reason)
    5.35 ++{
    5.36 ++	unsigned long i;
    5.37 ++
    5.38 ++	reason = (reason & 0xf) | 8;
    5.39 ++	outb(reason, 0x61);
    5.40 ++	i = 2000;
    5.41 ++	while (--i) udelay(1000);
    5.42 ++	reason &= ~8;
    5.43 ++	outb(reason, 0x61);
    5.44 ++}
    5.45 ++
    5.46 + static inline unsigned char get_nmi_reason(void)
    5.47 + {
    5.48 + 	return inb(0x61);
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/patches/linux-2.6.16-rc2/net-csum.patch	Fri Feb 03 18:24:28 2006 +0000
     6.3 @@ -0,0 +1,46 @@
     6.4 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
     6.5 +--- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:39:51.000000000 +0000
     6.6 ++++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:44:18.000000000 +0000
     6.7 +@@ -129,10 +129,16 @@ tcp_manip_pkt(struct sk_buff **pskb,
     6.8 + 	if (hdrsize < sizeof(*hdr))
     6.9 + 		return 1;
    6.10 + 
    6.11 +-	hdr->check = ip_nat_cheat_check(~oldip, newip,
    6.12 ++	if ((*pskb)->proto_csum_blank) {
    6.13 ++		hdr->check = ip_nat_cheat_check(oldip, ~newip,
    6.14 ++				ip_nat_cheat_check(oldport ^ 0xFFFF,
    6.15 ++					newport, hdr->check));
    6.16 ++	} else { 
    6.17 ++		hdr->check = ip_nat_cheat_check(~oldip, newip,
    6.18 + 					ip_nat_cheat_check(oldport ^ 0xFFFF,
    6.19 + 							   newport,
    6.20 + 							   hdr->check));
    6.21 ++	}
    6.22 + 	return 1;
    6.23 + }
    6.24 + 
    6.25 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
    6.26 +--- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:39:51.000000000 +0000
    6.27 ++++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:44:18.000000000 +0000
    6.28 +@@ -113,11 +113,19 @@ udp_manip_pkt(struct sk_buff **pskb,
    6.29 + 		newport = tuple->dst.u.udp.port;
    6.30 + 		portptr = &hdr->dest;
    6.31 + 	}
    6.32 +-	if (hdr->check) /* 0 is a special case meaning no checksum */
    6.33 +-		hdr->check = ip_nat_cheat_check(~oldip, newip,
    6.34 ++	
    6.35 ++	if (hdr->check) { /* 0 is a special case meaning no checksum */
    6.36 ++		if ((*pskb)->proto_csum_blank) {
    6.37 ++			hdr->check = ip_nat_cheat_check(oldip, ~newip, 
    6.38 ++					ip_nat_cheat_check(*portptr ^ 0xFFFF, 
    6.39 ++						newport, hdr->check));
    6.40 ++		} else {
    6.41 ++			hdr->check = ip_nat_cheat_check(~oldip, newip,
    6.42 + 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
    6.43 + 							   newport,
    6.44 + 							   hdr->check));
    6.45 ++		}
    6.46 ++	}
    6.47 + 	*portptr = newport;
    6.48 + 	return 1;
    6.49 + }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/patches/linux-2.6.16-rc2/pmd-shared.patch	Fri Feb 03 18:24:28 2006 +0000
     7.3 @@ -0,0 +1,111 @@
     7.4 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
     7.5 +--- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c	2006-02-02 17:39:29.000000000 +0000
     7.6 ++++ ./arch/i386/mm/pageattr.c	2006-02-02 17:45:14.000000000 +0000
     7.7 +@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
     7.8 + 	unsigned long flags;
     7.9 + 
    7.10 + 	set_pte_atomic(kpte, pte); 	/* change init_mm */
    7.11 +-	if (PTRS_PER_PMD > 1)
    7.12 ++	if (HAVE_SHARED_KERNEL_PMD)
    7.13 + 		return;
    7.14 + 
    7.15 + 	spin_lock_irqsave(&pgd_lock, flags);
    7.16 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
    7.17 +--- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c	2006-01-03 03:21:10.000000000 +0000
    7.18 ++++ ./arch/i386/mm/pgtable.c	2006-02-02 17:45:14.000000000 +0000
    7.19 +@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
    7.20 + 		spin_lock_irqsave(&pgd_lock, flags);
    7.21 + 	}
    7.22 + 
    7.23 +-	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
    7.24 +-			swapper_pg_dir + USER_PTRS_PER_PGD,
    7.25 +-			KERNEL_PGD_PTRS);
    7.26 ++	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
    7.27 ++		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
    7.28 ++				swapper_pg_dir + USER_PTRS_PER_PGD,
    7.29 ++				KERNEL_PGD_PTRS);
    7.30 + 	if (PTRS_PER_PMD > 1)
    7.31 + 		return;
    7.32 + 
    7.33 +@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
    7.34 + 			goto out_oom;
    7.35 + 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
    7.36 + 	}
    7.37 ++
    7.38 ++	if (!HAVE_SHARED_KERNEL_PMD) {
    7.39 ++		unsigned long flags;
    7.40 ++
    7.41 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
    7.42 ++			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
    7.43 ++			if (!pmd)
    7.44 ++				goto out_oom;
    7.45 ++			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
    7.46 ++		}
    7.47 ++
    7.48 ++		spin_lock_irqsave(&pgd_lock, flags);
    7.49 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
    7.50 ++			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
    7.51 ++			pgd_t *kpgd = pgd_offset_k(v);
    7.52 ++			pud_t *kpud = pud_offset(kpgd, v);
    7.53 ++			pmd_t *kpmd = pmd_offset(kpud, v);
    7.54 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    7.55 ++			memcpy(pmd, kpmd, PAGE_SIZE);
    7.56 ++		}
    7.57 ++		pgd_list_add(pgd);
    7.58 ++		spin_unlock_irqrestore(&pgd_lock, flags);
    7.59 ++	}
    7.60 ++
    7.61 + 	return pgd;
    7.62 + 
    7.63 + out_oom:
    7.64 +@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
    7.65 + 	int i;
    7.66 + 
    7.67 + 	/* in the PAE case user pgd entries are overwritten before usage */
    7.68 +-	if (PTRS_PER_PMD > 1)
    7.69 +-		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
    7.70 +-			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
    7.71 ++	if (PTRS_PER_PMD > 1) {
    7.72 ++		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
    7.73 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    7.74 ++			kmem_cache_free(pmd_cache, pmd);
    7.75 ++		}
    7.76 ++		if (!HAVE_SHARED_KERNEL_PMD) {
    7.77 ++			unsigned long flags;
    7.78 ++			spin_lock_irqsave(&pgd_lock, flags);
    7.79 ++			pgd_list_del(pgd);
    7.80 ++			spin_unlock_irqrestore(&pgd_lock, flags);
    7.81 ++			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
    7.82 ++				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    7.83 ++				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
    7.84 ++				kmem_cache_free(pmd_cache, pmd);
    7.85 ++			}
    7.86 ++		}
    7.87 ++	}
    7.88 + 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
    7.89 + 	kmem_cache_free(pgd_cache, pgd);
    7.90 + }
    7.91 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
    7.92 +--- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h	2006-01-03 03:21:10.000000000 +0000
    7.93 ++++ ./include/asm-i386/pgtable-2level-defs.h	2006-02-02 17:45:14.000000000 +0000
    7.94 +@@ -1,6 +1,8 @@
    7.95 + #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
    7.96 + #define _I386_PGTABLE_2LEVEL_DEFS_H
    7.97 + 
    7.98 ++#define HAVE_SHARED_KERNEL_PMD 0
    7.99 ++
   7.100 + /*
   7.101 +  * traditional i386 two-level paging structure:
   7.102 +  */
   7.103 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
   7.104 +--- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h	2006-01-03 03:21:10.000000000 +0000
   7.105 ++++ ./include/asm-i386/pgtable-3level-defs.h	2006-02-02 17:45:14.000000000 +0000
   7.106 +@@ -1,6 +1,8 @@
   7.107 + #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
   7.108 + #define _I386_PGTABLE_3LEVEL_DEFS_H
   7.109 + 
   7.110 ++#define HAVE_SHARED_KERNEL_PMD 1
   7.111 ++
   7.112 + /*
   7.113 +  * PGDIR_SHIFT determines what a top-level page table entry can map
   7.114 +  */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/patches/linux-2.6.16-rc2/smp-alts.patch	Fri Feb 03 18:24:28 2006 +0000
     8.3 @@ -0,0 +1,593 @@
     8.4 +diff -pruN ../pristine-linux-2.6.16-rc2/arch/i386/Kconfig ./arch/i386/Kconfig
     8.5 +--- ../pristine-linux-2.6.16-rc2/arch/i386/Kconfig	2006-02-03 16:11:47.000000000 +0000
     8.6 ++++ ./arch/i386/Kconfig	2006-02-03 18:20:37.000000000 +0000
     8.7 +@@ -202,6 +202,19 @@ config SMP
     8.8 + 
     8.9 + 	  If you don't know what to do here, say N.
    8.10 + 
    8.11 ++config SMP_ALTERNATIVES
    8.12 ++	bool "SMP alternatives support (EXPERIMENTAL)"
    8.13 ++	depends on SMP && EXPERIMENTAL
    8.14 ++	help
    8.15 ++	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
    8.16 ++	  host slightly by replacing certain key instruction sequences
    8.17 ++	  according to whether we currently have more than one CPU available.
    8.18 ++	  This should provide a noticeable boost to performance when
    8.19 ++	  running SMP kernels on UP machines, and have negligible impact
    8.20 ++	  when running on an true SMP host.
    8.21 ++
    8.22 ++          If unsure, say N.
    8.23 ++	  
    8.24 + config NR_CPUS
    8.25 + 	int "Maximum number of CPUs (2-255)"
    8.26 + 	range 2 255
    8.27 +diff -pruN ../pristine-linux-2.6.16-rc2/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
    8.28 +--- ../pristine-linux-2.6.16-rc2/arch/i386/kernel/Makefile	2006-02-03 16:11:47.000000000 +0000
    8.29 ++++ ./arch/i386/kernel/Makefile	2006-02-03 18:20:37.000000000 +0000
    8.30 +@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
    8.31 + obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
    8.32 + obj-$(CONFIG_VM86)		+= vm86.o
    8.33 + obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
    8.34 ++obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
    8.35 + 
    8.36 + EXTRA_AFLAGS   := -traditional
    8.37 + 
    8.38 +diff -pruN ../pristine-linux-2.6.16-rc2/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
    8.39 +--- ../pristine-linux-2.6.16-rc2/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
    8.40 ++++ ./arch/i386/kernel/smpalts.c	2006-02-03 18:20:37.000000000 +0000
    8.41 +@@ -0,0 +1,85 @@
    8.42 ++#include <linux/kernel.h>
    8.43 ++#include <asm/system.h>
    8.44 ++#include <asm/smp_alt.h>
    8.45 ++#include <asm/processor.h>
    8.46 ++#include <asm/string.h>
    8.47 ++
    8.48 ++struct smp_replacement_record {
    8.49 ++	unsigned char targ_size;
    8.50 ++	unsigned char smp1_size;
    8.51 ++	unsigned char smp2_size;
    8.52 ++	unsigned char up_size;
    8.53 ++	unsigned char feature;
    8.54 ++	unsigned char data[0];
    8.55 ++};
    8.56 ++
    8.57 ++struct smp_alternative_record {
    8.58 ++	void *targ_start;
    8.59 ++	struct smp_replacement_record *repl;
    8.60 ++};
    8.61 ++
    8.62 ++extern struct smp_alternative_record __start_smp_alternatives_table,
    8.63 ++  __stop_smp_alternatives_table;
    8.64 ++extern unsigned long __init_begin, __init_end;
    8.65 ++
    8.66 ++void prepare_for_smp(void)
    8.67 ++{
    8.68 ++	struct smp_alternative_record *r;
    8.69 ++	printk(KERN_INFO "Enabling SMP...\n");
    8.70 ++	for (r = &__start_smp_alternatives_table;
    8.71 ++	     r != &__stop_smp_alternatives_table;
    8.72 ++	     r++) {
    8.73 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
    8.74 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
    8.75 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
    8.76 ++               if (system_state == SYSTEM_RUNNING &&
    8.77 ++                   r->targ_start >= (void *)&__init_begin &&
    8.78 ++                   r->targ_start < (void *)&__init_end)
    8.79 ++                       continue;
    8.80 ++		if (r->repl->feature != (unsigned char)-1 &&
    8.81 ++		    boot_cpu_has(r->repl->feature)) {
    8.82 ++			memcpy(r->targ_start,
    8.83 ++			       r->repl->data + r->repl->smp1_size,
    8.84 ++			       r->repl->smp2_size);
    8.85 ++			memset(r->targ_start + r->repl->smp2_size,
    8.86 ++			       0x90,
    8.87 ++			       r->repl->targ_size - r->repl->smp2_size);
    8.88 ++		} else {
    8.89 ++			memcpy(r->targ_start,
    8.90 ++			       r->repl->data,
    8.91 ++			       r->repl->smp1_size);
    8.92 ++			memset(r->targ_start + r->repl->smp1_size,
    8.93 ++			       0x90,
    8.94 ++			       r->repl->targ_size - r->repl->smp1_size);
    8.95 ++		}
    8.96 ++	}
    8.97 ++	/* Paranoia */
    8.98 ++	asm volatile ("jmp 1f\n1:");
    8.99 ++	mb();
   8.100 ++}
   8.101 ++
   8.102 ++void unprepare_for_smp(void)
   8.103 ++{
   8.104 ++	struct smp_alternative_record *r;
   8.105 ++	printk(KERN_INFO "Disabling SMP...\n");
   8.106 ++	for (r = &__start_smp_alternatives_table;
   8.107 ++	     r != &__stop_smp_alternatives_table;
   8.108 ++	     r++) {
   8.109 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   8.110 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   8.111 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
   8.112 ++               if (system_state == SYSTEM_RUNNING &&
   8.113 ++                   r->targ_start >= (void *)&__init_begin &&
   8.114 ++                   r->targ_start < (void *)&__init_end)
   8.115 ++                       continue;
   8.116 ++		memcpy(r->targ_start,
   8.117 ++		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
   8.118 ++		       r->repl->up_size);
   8.119 ++		memset(r->targ_start + r->repl->up_size,
   8.120 ++		       0x90,
   8.121 ++		       r->repl->targ_size - r->repl->up_size);
   8.122 ++	}
   8.123 ++	/* Paranoia */
   8.124 ++	asm volatile ("jmp 1f\n1:");
   8.125 ++	mb();
   8.126 ++}
   8.127 +diff -pruN ../pristine-linux-2.6.16-rc2/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
   8.128 +--- ../pristine-linux-2.6.16-rc2/arch/i386/kernel/smpboot.c	2006-02-03 16:11:47.000000000 +0000
   8.129 ++++ ./arch/i386/kernel/smpboot.c	2006-02-03 18:20:37.000000000 +0000
   8.130 +@@ -1218,6 +1218,11 @@ static void __init smp_boot_cpus(unsigne
   8.131 + 		if (max_cpus <= cpucount+1)
   8.132 + 			continue;
   8.133 + 
   8.134 ++#ifdef CONFIG_SMP_ALTERNATIVES
   8.135 ++		if (kicked == 1)
   8.136 ++			prepare_for_smp();
   8.137 ++#endif
   8.138 ++
   8.139 + 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
   8.140 + 			printk("CPU #%d not responding - cannot use it.\n",
   8.141 + 								apicid);
   8.142 +@@ -1396,6 +1401,11 @@ int __devinit __cpu_up(unsigned int cpu)
   8.143 + 		return -EIO;
   8.144 + 	}
   8.145 + 
   8.146 ++#ifdef CONFIG_SMP_ALTERNATIVES
   8.147 ++	if (num_online_cpus() == 1)
   8.148 ++		prepare_for_smp();
   8.149 ++#endif
   8.150 ++
   8.151 + 	local_irq_enable();
   8.152 + 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
   8.153 + 	/* Unleash the CPU! */
   8.154 +diff -pruN ../pristine-linux-2.6.16-rc2/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
   8.155 +--- ../pristine-linux-2.6.16-rc2/arch/i386/kernel/vmlinux.lds.S	2006-01-03 03:21:10.000000000 +0000
   8.156 ++++ ./arch/i386/kernel/vmlinux.lds.S	2006-02-03 18:20:37.000000000 +0000
   8.157 +@@ -34,6 +34,13 @@ SECTIONS
   8.158 +   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
   8.159 +   __stop___ex_table = .;
   8.160 + 
   8.161 ++  . = ALIGN(16);
   8.162 ++  __start_smp_alternatives_table = .;
   8.163 ++  __smp_alternatives : { *(__smp_alternatives) }
   8.164 ++  __stop_smp_alternatives_table = .;
   8.165 ++
   8.166 ++  __smp_replacements : { *(__smp_replacements) }
   8.167 ++
   8.168 +   RODATA
   8.169 + 
   8.170 +   /* writeable */
   8.171 +diff -pruN ../pristine-linux-2.6.16-rc2/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
   8.172 +--- ../pristine-linux-2.6.16-rc2/include/asm-i386/atomic.h	2006-02-03 16:11:50.000000000 +0000
   8.173 ++++ ./include/asm-i386/atomic.h	2006-02-03 18:20:37.000000000 +0000
   8.174 +@@ -4,18 +4,13 @@
   8.175 + #include <linux/config.h>
   8.176 + #include <linux/compiler.h>
   8.177 + #include <asm/processor.h>
   8.178 ++#include <asm/smp_alt.h>
   8.179 + 
   8.180 + /*
   8.181 +  * Atomic operations that C can't guarantee us.  Useful for
   8.182 +  * resource counting etc..
   8.183 +  */
   8.184 + 
   8.185 +-#ifdef CONFIG_SMP
   8.186 +-#define LOCK "lock ; "
   8.187 +-#else
   8.188 +-#define LOCK ""
   8.189 +-#endif
   8.190 +-
   8.191 + /*
   8.192 +  * Make sure gcc doesn't try to be clever and move things around
   8.193 +  * on us. We need to use _exactly_ the address the user gave us,
   8.194 +diff -pruN ../pristine-linux-2.6.16-rc2/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
   8.195 +--- ../pristine-linux-2.6.16-rc2/include/asm-i386/bitops.h	2006-02-03 16:11:50.000000000 +0000
   8.196 ++++ ./include/asm-i386/bitops.h	2006-02-03 18:20:37.000000000 +0000
   8.197 +@@ -7,6 +7,7 @@
   8.198 + 
   8.199 + #include <linux/config.h>
   8.200 + #include <linux/compiler.h>
   8.201 ++#include <asm/smp_alt.h>
   8.202 + 
   8.203 + /*
   8.204 +  * These have to be done with inline assembly: that way the bit-setting
   8.205 +@@ -16,12 +17,6 @@
   8.206 +  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
   8.207 +  */
   8.208 + 
   8.209 +-#ifdef CONFIG_SMP
   8.210 +-#define LOCK_PREFIX "lock ; "
   8.211 +-#else
   8.212 +-#define LOCK_PREFIX ""
   8.213 +-#endif
   8.214 +-
   8.215 + #define ADDR (*(volatile long *) addr)
   8.216 + 
   8.217 + /**
   8.218 +@@ -41,7 +36,7 @@
   8.219 +  */
   8.220 + static inline void set_bit(int nr, volatile unsigned long * addr)
   8.221 + {
   8.222 +-	__asm__ __volatile__( LOCK_PREFIX
   8.223 ++	__asm__ __volatile__( LOCK
   8.224 + 		"btsl %1,%0"
   8.225 + 		:"+m" (ADDR)
   8.226 + 		:"Ir" (nr));
   8.227 +@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
   8.228 +  */
   8.229 + static inline void clear_bit(int nr, volatile unsigned long * addr)
   8.230 + {
   8.231 +-	__asm__ __volatile__( LOCK_PREFIX
   8.232 ++	__asm__ __volatile__( LOCK
   8.233 + 		"btrl %1,%0"
   8.234 + 		:"+m" (ADDR)
   8.235 + 		:"Ir" (nr));
   8.236 +@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
   8.237 +  */
   8.238 + static inline void change_bit(int nr, volatile unsigned long * addr)
   8.239 + {
   8.240 +-	__asm__ __volatile__( LOCK_PREFIX
   8.241 ++	__asm__ __volatile__( LOCK
   8.242 + 		"btcl %1,%0"
   8.243 + 		:"+m" (ADDR)
   8.244 + 		:"Ir" (nr));
   8.245 +@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
   8.246 + {
   8.247 + 	int oldbit;
   8.248 + 
   8.249 +-	__asm__ __volatile__( LOCK_PREFIX
   8.250 ++	__asm__ __volatile__( LOCK
   8.251 + 		"btsl %2,%1\n\tsbbl %0,%0"
   8.252 + 		:"=r" (oldbit),"+m" (ADDR)
   8.253 + 		:"Ir" (nr) : "memory");
   8.254 +@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
   8.255 + {
   8.256 + 	int oldbit;
   8.257 + 
   8.258 +-	__asm__ __volatile__( LOCK_PREFIX
   8.259 ++	__asm__ __volatile__( LOCK
   8.260 + 		"btrl %2,%1\n\tsbbl %0,%0"
   8.261 + 		:"=r" (oldbit),"+m" (ADDR)
   8.262 + 		:"Ir" (nr) : "memory");
   8.263 +@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
   8.264 + {
   8.265 + 	int oldbit;
   8.266 + 
   8.267 +-	__asm__ __volatile__( LOCK_PREFIX
   8.268 ++	__asm__ __volatile__( LOCK
   8.269 + 		"btcl %2,%1\n\tsbbl %0,%0"
   8.270 + 		:"=r" (oldbit),"+m" (ADDR)
   8.271 + 		:"Ir" (nr) : "memory");
   8.272 +diff -pruN ../pristine-linux-2.6.16-rc2/include/asm-i386/futex.h ./include/asm-i386/futex.h
   8.273 +--- ../pristine-linux-2.6.16-rc2/include/asm-i386/futex.h	2006-02-03 16:11:50.000000000 +0000
   8.274 ++++ ./include/asm-i386/futex.h	2006-02-03 18:20:37.000000000 +0000
   8.275 +@@ -28,7 +28,7 @@
   8.276 + "1:	movl	%2, %0\n\
   8.277 + 	movl	%0, %3\n"					\
   8.278 + 	insn "\n"						\
   8.279 +-"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
   8.280 ++"2:	" LOCK "cmpxchgl %3, %2\n\
   8.281 + 	jnz	1b\n\
   8.282 + 3:	.section .fixup,\"ax\"\n\
   8.283 + 4:	mov	%5, %1\n\
   8.284 +@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
   8.285 + #endif
   8.286 + 		switch (op) {
   8.287 + 		case FUTEX_OP_ADD:
   8.288 +-			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
   8.289 ++			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
   8.290 + 					   oldval, uaddr, oparg);
   8.291 + 			break;
   8.292 + 		case FUTEX_OP_OR:
   8.293 +diff -pruN ../pristine-linux-2.6.16-rc2/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
   8.294 +--- ../pristine-linux-2.6.16-rc2/include/asm-i386/rwsem.h	2006-01-03 03:21:10.000000000 +0000
   8.295 ++++ ./include/asm-i386/rwsem.h	2006-02-03 18:20:37.000000000 +0000
   8.296 +@@ -40,6 +40,7 @@
   8.297 + 
   8.298 + #include <linux/list.h>
   8.299 + #include <linux/spinlock.h>
   8.300 ++#include <asm/smp_alt.h>
   8.301 + 
   8.302 + struct rwsem_waiter;
   8.303 + 
   8.304 +@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
   8.305 + {
   8.306 + 	__asm__ __volatile__(
   8.307 + 		"# beginning down_read\n\t"
   8.308 +-LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
   8.309 ++LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
   8.310 + 		"  js        2f\n\t" /* jump if we weren't granted the lock */
   8.311 + 		"1:\n\t"
   8.312 + 		LOCK_SECTION_START("")
   8.313 +@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
   8.314 + 		"  movl	     %1,%2\n\t"
   8.315 + 		"  addl      %3,%2\n\t"
   8.316 + 		"  jle	     2f\n\t"
   8.317 +-LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
   8.318 ++LOCK	        "  cmpxchgl  %2,%0\n\t"
   8.319 + 		"  jnz	     1b\n\t"
   8.320 + 		"2:\n\t"
   8.321 + 		"# ending __down_read_trylock\n\t"
   8.322 +@@ -150,7 +151,7 @@ static inline void __down_write(struct r
   8.323 + 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
   8.324 + 	__asm__ __volatile__(
   8.325 + 		"# beginning down_write\n\t"
   8.326 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
   8.327 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
   8.328 + 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
   8.329 + 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
   8.330 + 		"1:\n\t"
   8.331 +@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
   8.332 + 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
   8.333 + 	__asm__ __volatile__(
   8.334 + 		"# beginning __up_read\n\t"
   8.335 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
   8.336 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
   8.337 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
   8.338 + 		"1:\n\t"
   8.339 + 		LOCK_SECTION_START("")
   8.340 +@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
   8.341 + 	__asm__ __volatile__(
   8.342 + 		"# beginning __up_write\n\t"
   8.343 + 		"  movl      %2,%%edx\n\t"
   8.344 +-LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
   8.345 ++LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
   8.346 + 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
   8.347 + 		"1:\n\t"
   8.348 + 		LOCK_SECTION_START("")
   8.349 +@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
   8.350 + {
   8.351 + 	__asm__ __volatile__(
   8.352 + 		"# beginning __downgrade_write\n\t"
   8.353 +-LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
   8.354 ++LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
   8.355 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
   8.356 + 		"1:\n\t"
   8.357 + 		LOCK_SECTION_START("")
   8.358 +@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
   8.359 + static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
   8.360 + {
   8.361 + 	__asm__ __volatile__(
   8.362 +-LOCK_PREFIX	"addl %1,%0"
   8.363 ++LOCK	          "addl %1,%0"
   8.364 + 		: "=m"(sem->count)
   8.365 + 		: "ir"(delta), "m"(sem->count));
   8.366 + }
   8.367 +@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
   8.368 + 	int tmp = delta;
   8.369 + 
   8.370 + 	__asm__ __volatile__(
   8.371 +-LOCK_PREFIX	"xadd %0,(%2)"
   8.372 ++LOCK  	          "xadd %0,(%2)"
   8.373 + 		: "+r"(tmp), "=m"(sem->count)
   8.374 + 		: "r"(sem), "m"(sem->count)
   8.375 + 		: "memory");
   8.376 +diff -pruN ../pristine-linux-2.6.16-rc2/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
   8.377 +--- ../pristine-linux-2.6.16-rc2/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
   8.378 ++++ ./include/asm-i386/smp_alt.h	2006-02-03 18:20:37.000000000 +0000
   8.379 +@@ -0,0 +1,32 @@
   8.380 ++#ifndef __ASM_SMP_ALT_H__
   8.381 ++#define __ASM_SMP_ALT_H__
   8.382 ++
   8.383 ++#include <linux/config.h>
   8.384 ++
   8.385 ++#ifdef CONFIG_SMP
   8.386 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
   8.387 ++#define LOCK \
   8.388 ++        "6677: nop\n" \
   8.389 ++	".section __smp_alternatives,\"a\"\n" \
   8.390 ++	".long 6677b\n" \
   8.391 ++	".long 6678f\n" \
   8.392 ++	".previous\n" \
   8.393 ++	".section __smp_replacements,\"a\"\n" \
   8.394 ++	"6678: .byte 1\n" \
   8.395 ++	".byte 1\n" \
   8.396 ++	".byte 0\n" \
   8.397 ++        ".byte 1\n" \
   8.398 ++	".byte -1\n" \
   8.399 ++	"lock\n" \
   8.400 ++	"nop\n" \
   8.401 ++	".previous\n"
   8.402 ++void prepare_for_smp(void);
   8.403 ++void unprepare_for_smp(void);
   8.404 ++#else
   8.405 ++#define LOCK "lock ; "
   8.406 ++#endif
   8.407 ++#else
   8.408 ++#define LOCK ""
   8.409 ++#endif
   8.410 ++
   8.411 ++#endif /* __ASM_SMP_ALT_H__ */
   8.412 +diff -pruN ../pristine-linux-2.6.16-rc2/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
   8.413 +--- ../pristine-linux-2.6.16-rc2/include/asm-i386/spinlock.h	2006-01-03 03:21:10.000000000 +0000
   8.414 ++++ ./include/asm-i386/spinlock.h	2006-02-03 18:20:37.000000000 +0000
   8.415 +@@ -6,6 +6,7 @@
   8.416 + #include <asm/page.h>
   8.417 + #include <linux/config.h>
   8.418 + #include <linux/compiler.h>
   8.419 ++#include <asm/smp_alt.h>
   8.420 + 
   8.421 + /*
   8.422 +  * Your basic SMP spinlocks, allowing only a single CPU anywhere
   8.423 +@@ -23,7 +24,8 @@
   8.424 + 
   8.425 + #define __raw_spin_lock_string \
   8.426 + 	"\n1:\t" \
   8.427 +-	"lock ; decb %0\n\t" \
   8.428 ++	LOCK \
   8.429 ++	"decb %0\n\t" \
   8.430 + 	"jns 3f\n" \
   8.431 + 	"2:\t" \
   8.432 + 	"rep;nop\n\t" \
   8.433 +@@ -34,7 +36,8 @@
   8.434 + 
   8.435 + #define __raw_spin_lock_string_flags \
   8.436 + 	"\n1:\t" \
   8.437 +-	"lock ; decb %0\n\t" \
   8.438 ++	LOCK \
   8.439 ++	"decb %0\n\t" \
   8.440 + 	"jns 4f\n\t" \
   8.441 + 	"2:\t" \
   8.442 + 	"testl $0x200, %1\n\t" \
   8.443 +@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
   8.444 + static inline int __raw_spin_trylock(raw_spinlock_t *lock)
   8.445 + {
   8.446 + 	char oldval;
   8.447 ++#ifdef CONFIG_SMP_ALTERNATIVES
   8.448 + 	__asm__ __volatile__(
   8.449 +-		"xchgb %b0,%1"
   8.450 ++		"1:movb %1,%b0\n"
   8.451 ++		"movb $0,%1\n"
   8.452 ++		"2:"
   8.453 ++		".section __smp_alternatives,\"a\"\n"
   8.454 ++		".long 1b\n"
   8.455 ++		".long 3f\n"
   8.456 ++		".previous\n"
   8.457 ++		".section __smp_replacements,\"a\"\n"
   8.458 ++		"3: .byte 2b - 1b\n"
   8.459 ++		".byte 5f-4f\n"
   8.460 ++		".byte 0\n"
   8.461 ++		".byte 6f-5f\n"
   8.462 ++		".byte -1\n"
   8.463 ++		"4: xchgb %b0,%1\n"
   8.464 ++		"5: movb %1,%b0\n"
   8.465 ++		"movb $0,%1\n"
   8.466 ++		"6:\n"
   8.467 ++		".previous\n"
   8.468 + 		:"=q" (oldval), "=m" (lock->slock)
   8.469 + 		:"0" (0) : "memory");
   8.470 ++#else
   8.471 ++	__asm__ __volatile__(
   8.472 ++		"xchgb %b0,%1\n"
   8.473 ++		:"=q" (oldval), "=m" (lock->slock)
   8.474 ++		:"0" (0) : "memory");
   8.475 ++#endif
   8.476 + 	return oldval > 0;
   8.477 + }
   8.478 + 
   8.479 +@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
   8.480 + 
   8.481 + static inline void __raw_read_unlock(raw_rwlock_t *rw)
   8.482 + {
   8.483 +-	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
   8.484 ++	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
   8.485 + }
   8.486 + 
   8.487 + static inline void __raw_write_unlock(raw_rwlock_t *rw)
   8.488 + {
   8.489 +-	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
   8.490 ++	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
   8.491 + 				 : "=m" (rw->lock) : : "memory");
   8.492 + }
   8.493 + 
   8.494 +diff -pruN ../pristine-linux-2.6.16-rc2/include/asm-i386/system.h ./include/asm-i386/system.h
   8.495 +--- ../pristine-linux-2.6.16-rc2/include/asm-i386/system.h	2006-02-03 16:11:50.000000000 +0000
   8.496 ++++ ./include/asm-i386/system.h	2006-02-03 18:20:37.000000000 +0000
   8.497 +@@ -5,7 +5,7 @@
   8.498 + #include <linux/kernel.h>
   8.499 + #include <asm/segment.h>
   8.500 + #include <asm/cpufeature.h>
   8.501 +-#include <linux/bitops.h> /* for LOCK_PREFIX */
   8.502 ++#include <asm/smp_alt.h>
   8.503 + 
   8.504 + #ifdef __KERNEL__
   8.505 + 
   8.506 +@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
   8.507 + 	unsigned long prev;
   8.508 + 	switch (size) {
   8.509 + 	case 1:
   8.510 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
   8.511 ++		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
   8.512 + 				     : "=a"(prev)
   8.513 + 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
   8.514 + 				     : "memory");
   8.515 + 		return prev;
   8.516 + 	case 2:
   8.517 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
   8.518 ++		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
   8.519 + 				     : "=a"(prev)
   8.520 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
   8.521 + 				     : "memory");
   8.522 + 		return prev;
   8.523 + 	case 4:
   8.524 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
   8.525 ++		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
   8.526 + 				     : "=a"(prev)
   8.527 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
   8.528 + 				     : "memory");
   8.529 +@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
   8.530 + 				      unsigned long long new)
   8.531 + {
   8.532 + 	unsigned long long prev;
   8.533 +-	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
   8.534 ++	__asm__ __volatile__(LOCK "cmpxchg8b %3"
   8.535 + 			     : "=A"(prev)
   8.536 + 			     : "b"((unsigned long)new),
   8.537 + 			       "c"((unsigned long)(new >> 32)),
   8.538 +@@ -503,11 +503,55 @@ struct alt_instr { 
   8.539 + #endif
   8.540 + 
   8.541 + #ifdef CONFIG_SMP
   8.542 +-#define smp_mb()	mb()
   8.543 +-#define smp_rmb()	rmb()
   8.544 + #define smp_wmb()	wmb()
   8.545 +-#define smp_read_barrier_depends()	read_barrier_depends()
   8.546 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
   8.547 ++#define smp_alt_mb(instr)                                           \
   8.548 ++__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
   8.549 ++		     ".section __smp_alternatives,\"a\"\n"          \
   8.550 ++		     ".long 6667b\n"                                \
   8.551 ++                     ".long 6673f\n"                                \
   8.552 ++		     ".previous\n"                                  \
   8.553 ++		     ".section __smp_replacements,\"a\"\n"          \
   8.554 ++		     "6673:.byte 6668b-6667b\n"                     \
   8.555 ++		     ".byte 6670f-6669f\n"                          \
   8.556 ++		     ".byte 6671f-6670f\n"                          \
   8.557 ++                     ".byte 0\n"                                    \
   8.558 ++		     ".byte %c0\n"                                  \
   8.559 ++		     "6669:lock;addl $0,0(%%esp)\n"                 \
   8.560 ++		     "6670:" instr "\n"                             \
   8.561 ++		     "6671:\n"                                      \
   8.562 ++		     ".previous\n"                                  \
   8.563 ++		     :                                              \
   8.564 ++		     : "i" (X86_FEATURE_XMM2)                       \
   8.565 ++		     : "memory")
   8.566 ++#define smp_rmb() smp_alt_mb("lfence")
   8.567 ++#define smp_mb()  smp_alt_mb("mfence")
   8.568 ++#define set_mb(var, value) do {                                     \
   8.569 ++unsigned long __set_mb_temp;                                        \
   8.570 ++__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
   8.571 ++		     ".section __smp_alternatives,\"a\"\n"          \
   8.572 ++		     ".long 6667b\n"                                \
   8.573 ++		     ".long 6673f\n"                                \
   8.574 ++		     ".previous\n"                                  \
   8.575 ++		     ".section __smp_replacements,\"a\"\n"          \
   8.576 ++		     "6673: .byte 6668b-6667b\n"                    \
   8.577 ++		     ".byte 6670f-6669f\n"                          \
   8.578 ++		     ".byte 0\n"                                    \
   8.579 ++		     ".byte 6671f-6670f\n"                          \
   8.580 ++		     ".byte -1\n"                                   \
   8.581 ++		     "6669: xchg %1, %0\n"                          \
   8.582 ++		     "6670:movl %1, %0\n"                           \
   8.583 ++		     "6671:\n"                                      \
   8.584 ++		     ".previous\n"                                  \
   8.585 ++		     : "=m" (var), "=r" (__set_mb_temp)             \
   8.586 ++		     : "1" (value)                                  \
   8.587 ++		     : "memory"); } while (0)
   8.588 ++#else
   8.589 ++#define smp_rmb()	rmb()
   8.590 ++#define smp_mb()	mb()
   8.591 + #define set_mb(var, value) do { xchg(&var, value); } while (0)
   8.592 ++#endif
   8.593 ++#define smp_read_barrier_depends()	read_barrier_depends()
   8.594 + #else
   8.595 + #define smp_mb()	barrier()
   8.596 + #define smp_rmb()	barrier()