From: Andi Kleen <ak@muc.de>

x86-64 update for test4. Makes everything compile and boot again.

The earlier third party ioport.c changes unfortunately didn't even compile, 
fix that too.

Only changes x86-64 specific files. Some other related changes are comming
in separate mails.

- Update defconfig
- Some minor cleanup
- Introduce physid_t for APIC masks (fixes UP kernels) 
- Finish ioport.c merge and fix compilation
- Add bandaid for CardBus bridges and broken BIOS (Vojtech) 
- Add bandaid for unsynchronized TSCs  (Vojtech) 
- Fix ffs(0) return value (fixes XFS) 
- Fix compilation with software suspend




 arch/x86_64/defconfig          |   59 +++++------------------------------------
 arch/x86_64/ia32/sys_ia32.c    |    2 -
 arch/x86_64/kernel/apic.c      |    4 +-
 arch/x86_64/kernel/io_apic.c   |   20 ++++++-------
 arch/x86_64/kernel/ioport.c    |   12 ++------
 arch/x86_64/kernel/mpparse.c   |    4 +-
 arch/x86_64/kernel/setup.c     |   10 ++++++
 arch/x86_64/kernel/smpboot.c   |   16 +++++------
 arch/x86_64/kernel/time.c      |    1 
 arch/x86_64/kernel/vsyscall.c  |    1 
 include/asm-x86_64/bitops.h    |    2 -
 include/asm-x86_64/mpspec.h    |   45 ++++++++++++++++++++++++++++++-
 include/asm-x86_64/percpu.h    |    5 ++-
 include/asm-x86_64/processor.h |    1 
 include/asm-x86_64/smp.h       |    1 
 include/asm-x86_64/suspend.h   |    2 -
 include/asm-x86_64/topology.h  |   11 ++-----
 17 files changed, 97 insertions(+), 99 deletions(-)

diff -puN arch/x86_64/defconfig~x86_64-update-3 arch/x86_64/defconfig
--- 25/arch/x86_64/defconfig~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/defconfig	2003-08-23 13:41:37.000000000 -0700
@@ -14,6 +14,7 @@ CONFIG_GENERIC_ISA_DMA=y
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
+# CONFIG_BROKEN is not set
 
 #
 # General setup
@@ -23,10 +24,12 @@ CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 CONFIG_LOG_BUF_SHIFT=18
+# CONFIG_IKCONFIG is not set
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
 CONFIG_IOSCHED_AS=y
 CONFIG_IOSCHED_DEADLINE=y
 
@@ -72,10 +75,10 @@ CONFIG_PM=y
 CONFIG_SOFTWARE_SUSPEND=y
 
 #
-# ACPI Support
+# ACPI (Advanced Configuration and Power Interface) Support
 #
+# CONFIG_ACPI_HT is not set
 CONFIG_ACPI=y
-# CONFIG_ACPI_HT_ONLY is not set
 CONFIG_ACPI_BOOT=y
 CONFIG_ACPI_SLEEP=y
 CONFIG_ACPI_SLEEP_PROC_FS=y
@@ -117,7 +120,6 @@ CONFIG_UID16=y
 #
 # Generic Driver Options
 #
-# CONFIG_FW_LOADER is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -159,6 +161,7 @@ CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_IDEDISK_MULTI_MODE=y
 # CONFIG_IDEDISK_STROKE is not set
 CONFIG_BLK_DEV_IDECD=y
+# CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
 # CONFIG_IDE_TASK_IOCTL is not set
@@ -318,7 +321,6 @@ CONFIG_IP_MULTICAST=y
 # CONFIG_DECNET is not set
 # CONFIG_BRIDGE is not set
 # CONFIG_NETFILTER is not set
-# CONFIG_XFRM_USER is not set
 
 #
 # SCTP Configuration (EXPERIMENTAL)
@@ -405,6 +407,7 @@ CONFIG_E1000=m
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
 # CONFIG_SK98LIN is not set
 CONFIG_TIGON3=y
 
@@ -595,10 +598,7 @@ CONFIG_FS_MBCACHE=y
 CONFIG_REISERFS_FS=y
 # CONFIG_REISERFS_CHECK is not set
 # CONFIG_REISERFS_PROC_INFO is not set
-CONFIG_JFS_FS=y
-CONFIG_JFS_POSIX_ACL=y
-# CONFIG_JFS_DEBUG is not set
-# CONFIG_JFS_STATISTICS is not set
+# CONFIG_JFS_FS is not set
 CONFIG_FS_POSIX_ACL=y
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
@@ -674,49 +674,6 @@ CONFIG_SUNRPC=y
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-CONFIG_NLS=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
 
 #
 # Graphics support
diff -puN arch/x86_64/ia32/sys_ia32.c~x86_64-update-3 arch/x86_64/ia32/sys_ia32.c
--- 25/arch/x86_64/ia32/sys_ia32.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/ia32/sys_ia32.c	2003-08-23 13:45:38.000000000 -0700
@@ -1170,8 +1170,6 @@ sys32_rt_sigqueueinfo(int pid, int sig, 
 	return ret;
 }
 
-extern void check_pending(int signum);
-
 asmlinkage long sys_utimes(char *, struct timeval *);
 
 asmlinkage long
diff -puN arch/x86_64/kernel/apic.c~x86_64-update-3 arch/x86_64/kernel/apic.c
--- 25/arch/x86_64/kernel/apic.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/apic.c	2003-08-23 13:41:42.000000000 -0700
@@ -299,7 +299,7 @@ void __init setup_local_APIC (void)
 	 * This is meaningless in clustered apic mode, so we skip it.
 	 */
 	if (!clustered_apic_mode &&
-		!cpu_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
+		!physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
 		BUG();
 
 	/*
@@ -993,7 +993,7 @@ int __init APIC_init_uniprocessor (void)
 
 	connect_bsp_APIC();
 
-	phys_cpu_present_map = cpumask_of_cpu(0);
+	phys_cpu_present_map = physid_mask_of_physid(0);
 	apic_write_around(APIC_ID, boot_cpu_id);
 
 	setup_local_APIC();
diff -puN arch/x86_64/kernel/io_apic.c~x86_64-update-3 arch/x86_64/kernel/io_apic.c
--- 25/arch/x86_64/kernel/io_apic.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/io_apic.c	2003-08-23 13:41:42.000000000 -0700
@@ -1014,7 +1014,7 @@ void disable_IO_APIC(void)
 static void __init setup_ioapic_ids_from_mpc (void)
 {
 	union IO_APIC_reg_00 reg_00;
-	cpumask_t phys_id_present_map = phys_cpu_present_map;
+	physid_mask_t phys_id_present_map = phys_cpu_present_map;
 	int apic;
 	int i;
 	unsigned char old_id;
@@ -1047,22 +1047,22 @@ static void __init setup_ioapic_ids_from
 		 * system must have a unique ID or we get lots of nice
 		 * 'stuck on smp_invalidate_needed IPI wait' messages.
 	 	 */
-		if (cpu_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
+		if (physid_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
 			printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
 				apic, mp_ioapics[apic].mpc_apicid);
 			for (i = 0; i < 0xf; i++)
-				if (!cpu_isset(i, phys_id_present_map))
+				if (!physid_isset(i, phys_id_present_map))
 					break;
 			if (i >= 0xf)
 				panic("Max APIC ID exceeded!\n");
 			printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
 				i);
-			cpu_set(i, phys_id_present_map);
+			physid_set(i, phys_id_present_map);
 			mp_ioapics[apic].mpc_apicid = i;
 		} else {
 			printk(KERN_INFO 
 			       "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
-			cpu_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
+			physid_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
 		}
 
 
@@ -1642,7 +1642,7 @@ void __init mp_config_ioapic_for_sci(int
 int __init io_apic_get_unique_id (int ioapic, int apic_id)
 {
 	union IO_APIC_reg_00 reg_00;
-	static cpumask_t apic_id_map;
+	static physid_mask_t apic_id_map;
 	unsigned long flags;
 	int i = 0;
 
@@ -1655,7 +1655,7 @@ int __init io_apic_get_unique_id (int io
 	 *      advantage of new APIC bus architecture.
 	 */
 
-	if (!cpus_empty(apic_id_map))
+	if (!physids_empty(apic_id_map))
 		apic_id_map = phys_cpu_present_map;
 
 	spin_lock_irqsave(&ioapic_lock, flags);
@@ -1672,10 +1672,10 @@ int __init io_apic_get_unique_id (int io
 	 * Every APIC in a system must have a unique ID or we get lots of nice 
 	 * 'stuck on smp_invalidate_needed IPI wait' messages.
 	 */
-	if (cpu_isset(apic_id, apic_id_map)) {
+	if (physid_isset(apic_id, apic_id_map)) {
 
 		for (i = 0; i < IO_APIC_MAX_ID; i++) {
-			if (!cpu_isset(i, apic_id_map))
+			if (!physid_isset(i, apic_id_map))
 				break;
 		}
 
@@ -1688,7 +1688,7 @@ int __init io_apic_get_unique_id (int io
 		apic_id = i;
 	} 
 
-	cpu_set(apic_id, apic_id_map);
+	physid_set(apic_id, apic_id_map);
 
 	if (reg_00.bits.ID != apic_id) {
 		reg_00.bits.ID = apic_id;
diff -puN arch/x86_64/kernel/ioport.c~x86_64-update-3 arch/x86_64/kernel/ioport.c
--- 25/arch/x86_64/kernel/ioport.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/ioport.c	2003-08-23 13:41:42.000000000 -0700
@@ -10,12 +10,11 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
-#include <linux/mm.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/stddef.h>
 #include <linux/slab.h>
-#include <asm/io.h>
+#include <linux/thread_info.h>
 
 /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
 static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
@@ -118,12 +117,7 @@ asmlinkage long sys_iopl(unsigned int le
 			return -EPERM;
 	}
 	regs.eflags = (regs.eflags &~ 0x3000UL) | (level << 12);
+	/* Make sure we return the long way (not sysenter) */
+	set_thread_flag(TIF_IRET);
 	return 0;
 }
-
-void eat_key(void)
-{
-	if (inb(0x60) & 1) 
-		inb(0x64);
-}
-
diff -puN arch/x86_64/kernel/mpparse.c~x86_64-update-3 arch/x86_64/kernel/mpparse.c
--- 25/arch/x86_64/kernel/mpparse.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/mpparse.c	2003-08-23 13:41:42.000000000 -0700
@@ -67,7 +67,7 @@ unsigned int boot_cpu_id = -1U;
 static unsigned int num_processors = 0;
 
 /* Bitmask of physically existing CPUs */
-cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
+physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
 
 /* ACPI MADT entry parsing functions */
 #ifdef CONFIG_ACPI_BOOT
@@ -126,7 +126,7 @@ static void __init MP_processor_info (st
 	}
 	ver = m->mpc_apicver;
 
-	cpu_set(m->mpc_apicid, phys_cpu_present_map);
+	physid_set(m->mpc_apicid, phys_cpu_present_map);
 	/*
 	 * Validate version
 	 */
diff -puN arch/x86_64/kernel/setup.c~x86_64-update-3 arch/x86_64/kernel/setup.c
--- 25/arch/x86_64/kernel/setup.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/setup.c	2003-08-23 13:41:42.000000000 -0700
@@ -243,6 +243,8 @@ static void __init contig_initmem_init(v
 
 void __init setup_arch(char **cmdline_p)
 {
+	unsigned long low_mem_size;
+
  	ROOT_DEV = ORIG_ROOT_DEV;
  	drive_info = DRIVE_INFO;
  	screen_info = SCREEN_INFO;
@@ -378,7 +380,13 @@ void __init setup_arch(char **cmdline_p)
 		request_resource(&ioport_resource, standard_io_resources+i);
 	}
 
-	pci_mem_start = IOMAP_START; 
+	/* Will likely break when you have unassigned resources with more
+	   than 4GB memory and bridges that don't support more than 4GB.
+	   Doing it properly would require to allocate GFP_DMA memory
+	   in this case. */
+	low_mem_size = ((end_pfn << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
+	if (low_mem_size > pci_mem_start)
+		pci_mem_start = low_mem_size;
 
 #ifdef CONFIG_GART_IOMMU
        iommu_hole_init();
diff -puN arch/x86_64/kernel/smpboot.c~x86_64-update-3 arch/x86_64/kernel/smpboot.c
--- 25/arch/x86_64/kernel/smpboot.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/smpboot.c	2003-08-23 13:41:42.000000000 -0700
@@ -734,10 +734,10 @@ static void __init smp_boot_cpus(unsigne
 	current_thread_info()->cpu = 0;
 	smp_tune_scheduling();
 
-	if (!cpu_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
+	if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
 		printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
 		       hard_smp_processor_id());
-		cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
+		physid_set(hard_smp_processor_id(), phys_cpu_present_map);
 	}
 
 	/*
@@ -748,7 +748,7 @@ static void __init smp_boot_cpus(unsigne
 		printk(KERN_NOTICE "SMP motherboard not detected.\n");
 		io_apic_irqs = 0;
 		cpu_online_map = cpumask_of_cpu(0);
-		phys_cpu_present_map = cpumask_of_cpu(0);
+		phys_cpu_present_map = physid_mask_of_physid(0);
 		if (APIC_init_uniprocessor())
 			printk(KERN_NOTICE "Local APIC not detected."
 					   " Using dummy APIC emulation.\n");
@@ -759,10 +759,10 @@ static void __init smp_boot_cpus(unsigne
 	 * Should not be necessary because the MP table should list the boot
 	 * CPU too, but we do it for the sake of robustness anyway.
 	 */
-	if (!cpu_isset(boot_cpu_id, phys_cpu_present_map)) {
+	if (!physid_isset(boot_cpu_id, phys_cpu_present_map)) {
 		printk(KERN_NOTICE "weird, boot CPU (#%d) not listed by the BIOS.\n",
 								 boot_cpu_id);
-		cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
+		physid_set(hard_smp_processor_id(), phys_cpu_present_map);
 	}
 
 	/*
@@ -774,7 +774,7 @@ static void __init smp_boot_cpus(unsigne
 		printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
 		io_apic_irqs = 0;
 		cpu_online_map = cpumask_of_cpu(0);
-		phys_cpu_present_map = cpumask_of_cpu(0);
+		phys_cpu_present_map = physid_mask_of_physid(0);
 		disable_apic = 1;
 		goto smp_done;
 	}
@@ -789,7 +789,7 @@ static void __init smp_boot_cpus(unsigne
 		printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
 		io_apic_irqs = 0;
 		cpu_online_map = cpumask_of_cpu(0);
-		phys_cpu_present_map = cpumask_of_cpu(0);
+		phys_cpu_present_map = physid_mask_of_physid(0);
 		disable_apic = 1;
 		goto smp_done;
 	}
@@ -803,7 +803,7 @@ static void __init smp_boot_cpus(unsigne
 	/*
 	 * Now scan the CPU present map and fire up the other CPUs.
 	 */
-	Dprintk("CPU present map: %lx\n", phys_cpu_present_map);
+	Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map));
 
 	for (apicid = 0; apicid < NR_CPUS; apicid++) {
 		/*
diff -puN arch/x86_64/kernel/time.c~x86_64-update-3 arch/x86_64/kernel/time.c
--- 25/arch/x86_64/kernel/time.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/time.c	2003-08-23 13:41:42.000000000 -0700
@@ -79,6 +79,7 @@ static inline unsigned int do_gettimeoff
 	unsigned long t;
 	unsigned long x;
 	rdtscll_sync(&t);
+	if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */
 	x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32;
 	return x;
 }
diff -puN arch/x86_64/kernel/vsyscall.c~x86_64-update-3 arch/x86_64/kernel/vsyscall.c
--- 25/arch/x86_64/kernel/vsyscall.c~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/arch/x86_64/kernel/vsyscall.c	2003-08-23 13:41:42.000000000 -0700
@@ -85,6 +85,7 @@ static force_inline void do_vgettimeofda
 		if (__vxtime.mode == VXTIME_TSC) {
 			sync_core();
 			rdtscll(t);
+			if (t < __vxtime.last_tsc) t = __vxtime.last_tsc;
 			usec += ((t - __vxtime.last_tsc) *
 				 __vxtime.tsc_quot) >> 32;
 		} else {
diff -puN include/asm-x86_64/bitops.h~x86_64-update-3 include/asm-x86_64/bitops.h
--- 25/include/asm-x86_64/bitops.h~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/include/asm-x86_64/bitops.h	2003-08-23 13:41:42.000000000 -0700
@@ -466,7 +466,7 @@ static __inline__ int ffs(int x)
 
 	__asm__("bsfl %1,%0\n\t"
 		"cmovzl %2,%0" 
-		: "=r" (r) : "g" (x), "r" (32));
+		: "=r" (r) : "g" (x), "r" (-1));
 	return r+1;
 }
 
diff -puN include/asm-x86_64/mpspec.h~x86_64-update-3 include/asm-x86_64/mpspec.h
--- 25/include/asm-x86_64/mpspec.h~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/include/asm-x86_64/mpspec.h	2003-08-23 13:41:42.000000000 -0700
@@ -169,7 +169,6 @@ extern int mp_bus_id_to_pci_bus [MAX_MP_
 extern cpumask_t mp_bus_to_cpumask [MAX_MP_BUSSES];
 
 extern unsigned int boot_cpu_physical_apicid;
-extern cpumask_t phys_cpu_present_map;
 extern int smp_found_config;
 extern void find_smp_config (void);
 extern void get_smp_config (void);
@@ -198,5 +197,49 @@ extern void mp_config_ioapic_for_sci(int
 
 extern int using_apic_timer;
 
+#define PHYSID_ARRAY_SIZE	BITS_TO_LONGS(MAX_APICS)
+
+struct physid_mask
+{
+	unsigned long mask[PHYSID_ARRAY_SIZE];
+};
+
+typedef struct physid_mask physid_mask_t;
+
+#define physid_set(physid, map)			set_bit(physid, (map).mask)
+#define physid_clear(physid, map)		clear_bit(physid, (map).mask)
+#define physid_isset(physid, map)		test_bit(physid, (map).mask)
+#define physid_test_and_set(physid, map)	test_and_set_bit(physid, (map).mask)
+
+#define physids_and(dst, src1, src2)		bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
+#define physids_or(dst, src1, src2)		bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
+#define physids_clear(map)			bitmap_clear((map).mask, MAX_APICS)
+#define physids_complement(map)			bitmap_complement((map).mask, MAX_APICS)
+#define physids_empty(map)			bitmap_empty((map).mask, MAX_APICS)
+#define physids_equal(map1, map2)		bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
+#define physids_weight(map)			bitmap_weight((map).mask, MAX_APICS)
+#define physids_shift_right(d, s, n)		bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
+#define physids_shift_left(d, s, n)		bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
+#define physids_coerce(map)			((map).mask[0])
+
+#define physids_promote(physids)						\
+	({									\
+		physid_mask_t __physid_mask = PHYSID_MASK_NONE;			\
+		__physid_mask.mask[0] = physids;				\
+		__physid_mask;							\
+	})
+
+#define physid_mask_of_physid(physid)						\
+	({									\
+		physid_mask_t __physid_mask = PHYSID_MASK_NONE;			\
+		physid_set(physid, __physid_mask);				\
+		__physid_mask;							\
+	})
+
+#define PHYSID_MASK_ALL		{ {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
+#define PHYSID_MASK_NONE	{ {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
+
+extern physid_mask_t phys_cpu_present_map;
+
 #endif
 
diff -puN include/asm-x86_64/percpu.h~x86_64-update-3 include/asm-x86_64/percpu.h
--- 25/include/asm-x86_64/percpu.h~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/include/asm-x86_64/percpu.h	2003-08-23 13:41:42.000000000 -0700
@@ -31,6 +31,9 @@ do {								\
 			memcpy((pcpudst)+__per_cpu_offset(__i),	\
 			       (src), (size));			\
 } while (0)
+
+extern void setup_per_cpu_areas(void);
+
 #else /* ! SMP */
 
 #define DEFINE_PER_CPU(type, name) \
@@ -46,6 +49,4 @@ do {								\
 #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
 #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
 
-extern void setup_per_cpu_areas(void);
-
 #endif /* _ASM_X8664_PERCPU_H_ */
diff -puN include/asm-x86_64/processor.h~x86_64-update-3 include/asm-x86_64/processor.h
--- 25/include/asm-x86_64/processor.h~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/include/asm-x86_64/processor.h	2003-08-23 13:41:42.000000000 -0700
@@ -225,7 +225,6 @@ struct tss_struct {
 	 * 8 bytes, for an extra "long" of ~0UL
 	 */
 	unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
-	u32 __cacheline_filler[4];      /* size is 0x100 */
 } __attribute__((packed)) ____cacheline_aligned;
 
 struct thread_struct {
diff -puN include/asm-x86_64/smp.h~x86_64-update-3 include/asm-x86_64/smp.h
--- 25/include/asm-x86_64/smp.h~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/include/asm-x86_64/smp.h	2003-08-23 13:41:42.000000000 -0700
@@ -36,7 +36,6 @@ struct pt_regs;
  */
  
 extern void smp_alloc_memory(void);
-extern cpumask_t phys_cpu_present_map;
 extern cpumask_t cpu_online_map;
 extern volatile unsigned long smp_invalidate_needed;
 extern int pic_mode;
diff -puN include/asm-x86_64/suspend.h~x86_64-update-3 include/asm-x86_64/suspend.h
--- 25/include/asm-x86_64/suspend.h~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/include/asm-x86_64/suspend.h	2003-08-23 13:41:42.000000000 -0700
@@ -44,7 +44,7 @@ extern unsigned long saved_context_eflag
                        :"r" ((thread)->debugreg##register))
 
 extern void fix_processor_context(void);
-extern void do_magic(int resume);
+extern int do_magic(int resume);
 
 #ifdef CONFIG_ACPI_SLEEP
 extern unsigned long saved_eip;
diff -puN include/asm-x86_64/topology.h~x86_64-update-3 include/asm-x86_64/topology.h
--- 25/include/asm-x86_64/topology.h~x86_64-update-3	2003-08-23 13:41:37.000000000 -0700
+++ 25-akpm/include/asm-x86_64/topology.h	2003-08-23 13:41:42.000000000 -0700
@@ -10,21 +10,18 @@
 /* Map the K8 CPU local memory controllers to a simple 1:1 CPU:NODE topology */
 
 extern int fake_node;
-extern cpumask_t cpu_online_map;
+extern unsigned long cpu_online_map;
 
 #define cpu_to_node(cpu)		(fake_node ? 0 : (cpu))
 #define memblk_to_node(memblk) 	(fake_node ? 0 : (memblk))
 #define parent_node(node)		(node)
 #define node_to_first_cpu(node) 	(fake_node ? 0 : (node))
-#define node_to_cpu_mask(node)	(fake_node ? cpu_online_map : cpumask_of_cpu(node))
+#define node_to_cpu_mask(node)	(fake_node ? cpu_online_map : (1UL << (node)))
 #define node_to_memblk(node)		(node)
 
-static inline cpumask_t pcibus_to_cpumask(int bus)
+static inline unsigned long pcibus_to_cpumask(int bus)
 {
-	cpumask_t ret;
-
-	cpus_and(ret, mp_bus_to_cpumask[bus], cpu_online_map);
-	return ret;
+	return mp_bus_to_cpumask[bus] & cpu_online_map;
 }
 
 #define NODE_BALANCE_RATE 30	/* CHECKME */ 

_