Skip to contentSkip to conversation

Fix x86_64 builds with CC_STACKPROTECTOR enabled

PATCH In review Wolfgang Mauerer 2 participants 3 messages May 6, 2010 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix x86_64 builds with CC_STACKPROTECTOR enabled

From: Wolfgang Mauerer (none) <[email protected]>

The per_cpu__ prefix for per-cpu-variables in the Linux kernel is gone since dd17c8f72993f. This patch adapts the x86_64 task switching code to cope with kernels before and after this commit.

---
 include/asm-x86/switch_64.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/asm-x86/switch_64.h +4 -0
index a716ad6..c2df7d8 100644
@@ -37,6 +37,10 @@ struct xnarch_x8664_initstack {
 };
 
 #ifdef CONFIG_CC_STACKPROTECTOR
+#include <asm/percpu.h>
+#ifndef per_cpu_var
+#define per_cpu_var(x)	x
+#endif
 /*
  * We have an added complexity with -fstack-protector, due to the
  * hybrid scheduling between user- and kernel-based Xenomai threads,
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 18 lines · Wolfgang Mauerer

From: Wolfgang Mauerer (none) <[email protected]>

The per_cpu__ prefix for per-cpu-variables in the Linux kernel is gone since dd17c8f72993f. This patch adapts the x86_64 task switching code to cope with kernels before and after this commit.

---
 include/asm-x86/switch_64.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/asm-x86/switch_64.h +0 -0
index a716ad6..c2df7d8 100644

include/asm-x86/switch_64.h struct xnarch_x8664_initstack { · line 43

Quoted 7 lines
include/asm-x86/switch_64.h +4 -0
@@ -37,6 +37,10 @@ struct xnarch_x8664_initstack {
 };
 
 #ifdef CONFIG_CC_STACKPROTECTOR
+#include <asm/percpu.h>
+#ifndef per_cpu_var
+#define per_cpu_var(x)	x
+#endif

Please move those soon-to-be-generic bits to asm-generic/wrappers.h, into a section that would be unconditionally parsed with 2.6.34 or later.

TIA,

Quoted 3 lines
include/asm-x86/switch_64.h +0 -0
 /*
  * We have an added complexity with -fstack-protector, due to the
  * hybrid scheduling between user- and kernel-based Xenomai threads,
Signature · 1 line
Philippe.
#2 lore raw

PATCH 1/1 Fix x86_64 builds with CC_STACKPROTECTOR enabled

The per_cpu__ prefix for per-cpu-variables in the Linux kernel is gone since dd17c8f72993f. This patch adds a corresponding wrapper.

---
 include/asm-generic/wrappers.h |    4 ++++
 include/asm-x86/switch_64.h    |    3 +++
 2 files changed, 7 insertions(+), 0 deletions(-)
include/asm-generic/wrappers.h +4 -0
index ecc1867..3827492 100644
@@ -598,4 +598,8 @@ static inline void wrap_proc_dir_entry_owner(struct proc_dir_entry *entry)
 	raw_spin_unlock_irqrestore(&rthal_irq_descp(irq)->lock, flags)
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) */
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
+#define per_cpu_var(x)	x
+#endif
+
 #endif /* _XENO_ASM_GENERIC_WRAPPERS_H */
include/asm-x86/switch_64.h +3 -0
index a716ad6..a436917 100644
@@ -25,6 +25,9 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <asm/percpu.h>
+#include <asm/xenomai/wrappers.h>
+
 struct xnarch_x8664_initstack {
 
 #ifdef CONFIG_CC_STACKPROTECTOR
Signature · 1 line
1.7.0.4