--- arch/x86/Makefile_64 | 1 + arch/x86/kernel/entry_64.S | 4 ++-- include/asm-x86/percpu_64.h | 32 +++++++++++++++++++------------- 3 files changed, 22 insertions(+), 15 deletions(-) Index: linux-2.6/arch/x86/Makefile_64 =================================================================== --- linux-2.6.orig/arch/x86/Makefile_64 2007-10-29 18:23:24.340823073 -0700 +++ linux-2.6/arch/x86/Makefile_64 2007-10-29 18:23:47.749072234 -0700 @@ -61,6 +61,7 @@ cflags-y += $(call cc-option,-mno-sse -m # this works around some issues with generating unwind tables in older gccs # newer gccs do it by default cflags-y += -maccumulate-outgoing-args +cflags-y += -mtls-direct-seg-other # do binutils support CFI? cflags-y += $(call as-instr,.cfi_startproc\n.cfi_rel_offset rsp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,) Index: linux-2.6/arch/x86/kernel/entry_64.S =================================================================== --- linux-2.6.orig/arch/x86/kernel/entry_64.S 2007-10-29 17:56:59.111573397 -0700 +++ linux-2.6/arch/x86/kernel/entry_64.S 2007-10-29 17:58:19.380322743 -0700 @@ -741,11 +741,11 @@ END(spurious_interrupt) movq ORIG_RAX(%rsp),%rsi movq $-1,ORIG_RAX(%rsp) .if \ist - subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) +// subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) .endif call \sym .if \ist - addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) +// addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) .endif cli .if \irqtrace Index: linux-2.6/include/asm-x86/percpu_64.h =================================================================== --- linux-2.6.orig/include/asm-x86/percpu_64.h 2007-10-29 17:44:24.635822796 -0700 +++ linux-2.6/include/asm-x86/percpu_64.h 2007-10-29 17:59:51.440722104 -0700 @@ -12,29 +12,24 @@ #include #define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset) -#define __my_cpu_offset() read_pda(data_offset) +#define __my_cpu_offset() 0 #define per_cpu_offset(x) (__per_cpu_offset(x)) /* Separate out the type, so (int[3], foo) works. */ #define DEFINE_PER_CPU(type, name) \ - __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name + __attribute__((__section__(".data.percpu"))) __typeof__(type) __thread per_cpu__##name #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ __attribute__((__section__(".data.percpu.shared_aligned"))) \ - __typeof__(type) per_cpu__##name \ - ____cacheline_internodealigned_in_smp + __typeof__(type) __thread per_cpu__##name /* var is in discarded region: offset to particular copy we want */ #define per_cpu(var, cpu) (*({ \ extern int simple_identifier_##var(void); \ RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)); })) -#define __get_cpu_var(var) (*({ \ - extern int simple_identifier_##var(void); \ - RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); })) -#define __raw_get_cpu_var(var) (*({ \ - extern int simple_identifier_##var(void); \ - RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); })) +#define __get_cpu_var(var) per_cpu__##var +#define __raw_get_cpu_var(var) per_cpu__##var /* A macro to avoid #include hell... */ #define percpu_modcopy(pcpudst, src, size) \ @@ -60,9 +55,20 @@ extern void setup_per_cpu_areas(void); #endif /* SMP */ -#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name +#define DECLARE_PER_CPU(type, name) extern __typeof__(type) __thread per_cpu__##name + +#define __EXPORT_PER_CPUSYMBOL(sym, sec) \ + extern typeof(sym) __thread sym; \ + __CRC_SYMBOL(sym, sec) \ + static const char __kstrtab_##sym[] \ + __attribute__((section("__ksymtab_strings"))) \ + = MODULE_SYMBOL_PREFIX #sym; \ + static const struct kernel_symbol __ksymtab_##sym \ + __attribute_used__ \ + __attribute__((section("__ksymtab" sec), unused)) \ + = { /* FIXME: addr not working */ 0, __kstrtab_##sym } -#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) -#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) +#define EXPORT_PER_CPU_SYMBOL(var) __EXPORT_PER_CPUSYMBOL(per_cpu__##var, "") +#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_PER_CPUSYMBOL_GPL(per_cpu__##var, "_gpl") #endif /* _ASM_X8664_PERCPU_H_ */