aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/kexecboot/linux-kexecboot/use-noclone-attribute-for-naked.patch
blob: 72bf4a1e0a28d4741f56f2e69ab0f7f1183fd27e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
https://patchwork.kernel.org/patch/104260/

This patch add noinline and noclone attributes to naked functions. 
GCC 4.5 has new optimization -fipa-ira which is enabled at -Os and -O2
this option will clone the functions and that can change the standard
calling convention but the naked functions expect that and use
arguments as in standard calling convention. Therefore the naked
functions should not be marked non inline and noclone.

Signed-off-by: Khem Raj <raj.khem@gmail.com>

Index: linux-2.6.34/include/linux/compiler-gcc4.h
===================================================================
--- linux-2.6.34.orig/include/linux/compiler-gcc4.h	2010-05-29 17:18:55.338127623 -0700
+++ linux-2.6.34/include/linux/compiler-gcc4.h	2010-05-29 17:32:33.910657021 -0700
@@ -48,6 +48,10 @@
  * unreleased.  Really, we need to have autoconf for the kernel.
  */
 #define unreachable() __builtin_unreachable()
+
+/* Mark a function definition as prohibited from being cloned. */
+#define __noclone	__attribute__((__noclone__))
+
 #endif
 
 #endif
Index: linux-2.6.34/include/linux/compiler-gcc.h
===================================================================
--- linux-2.6.34.orig/include/linux/compiler-gcc.h	2010-05-29 17:28:28.238113095 -0700
+++ linux-2.6.34/include/linux/compiler-gcc.h	2010-05-29 17:31:58.938153321 -0700
@@ -58,8 +58,12 @@
  * naked functions because then mcount is called without stack and frame pointer
  * being set up and there is no chance to restore the lr register to the value
  * before mcount was called.
+ *
+ * The asm() bodies of naked functions often depend on standard calling conventions,
+ * therefore they must be noinline and noclone.  GCC 4.[56] currently fail to enforce
+ * this, so we must do so ourselves.  See GCC PR44290.
  */
-#define __naked				__attribute__((naked)) notrace
+#define __naked				__attribute__((naked)) noinline __noclone notrace
 
 #define __noreturn			__attribute__((noreturn))
 
@@ -85,3 +89,8 @@
 #define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
 #define gcc_header(x) _gcc_header(x)
 #include gcc_header(__GNUC__)
+
+#if !defined(__noclone)
+#define __noclone	/* not needed */
+#endif
+