summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/kexec/kexec-tools/kexec-x32.patch
blob: 0bd3264af75684f7c43bde03f1f2d4b45b66a0a1 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
x86_64: Add support to build kexec-tools with x32 ABI

Summary of changes,

configure.ac: Add test for detect x32 ABI.
purgatory/arch/x86_64/Makefile: Not use mcmodel large when
	x32 ABI is set.
kexec/arch/x86_64/kexec-elf-rel-x86_64.c: When x32 ABI is set
	use ELFCLASS32 instead of ELFCLASS64.
kexec/kexec-syscall.h: Add correct syscall number for x32 ABI.

Upstream-Status: Submitted

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>

---
 configure.ac                             | 9 +++++++++
 kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 4 ++++
 kexec/kexec-syscall.h                    | 4 ++++
 purgatory/arch/x86_64/Makefile           | 4 +++-
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index c410e90..1ecadd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,15 @@ case $target_cpu in
 		;;
 	ia64|x86_64|alpha|m68k )
 		ARCH="$target_cpu"
+
+		dnl ---Test for x32 ABI in x86_64
+		if test "x$ARCH" = "xx86_64" ; then
+			AC_EGREP_CPP(x32_test,
+			[#if defined(__x86_64__) && defined (__ILP32__)
+				x32_test
+			#endif
+			], SUBARCH='x32', SUBARCH='64')
+		fi
 		;;
 	* )
 		AC_MSG_ERROR([unsupported architecture $target_cpu])
diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
index c795037..06db7f0 100644
--- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
@@ -8,7 +8,11 @@ int machine_verify_elf_rel(struct mem_ehdr *ehdr)
 	if (ehdr->ei_data != ELFDATA2LSB) {
 		return 0;
 	}
+#ifdef __ILP32__
+	if (ehdr->ei_class != ELFCLASS32) {
+#else
 	if (ehdr->ei_class != ELFCLASS64) {
+#endif
 		return 0;
 	}
 	if (ehdr->e_machine != EM_X86_64) {
diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h
index ce2e20b..cab5535 100644
--- a/kexec/kexec-syscall.h
+++ b/kexec/kexec-syscall.h
@@ -31,8 +31,12 @@
 #define __NR_kexec_load		268
 #endif
 #ifdef __x86_64__
+#ifdef __ILP32__
+#define __NR_kexec_load		528
+#else
 #define __NR_kexec_load		246
 #endif
+#endif
 #ifdef __s390x__
 #define __NR_kexec_load		277
 #endif
diff --git a/purgatory/arch/x86_64/Makefile b/purgatory/arch/x86_64/Makefile
index 7300937..4af11e4 100644
--- a/purgatory/arch/x86_64/Makefile
+++ b/purgatory/arch/x86_64/Makefile
@@ -23,4 +23,6 @@ x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c
 x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c
 x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c
 
-x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
+ifeq ($(SUBARCH),64)
+        x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
+endif
-- 
1.8.4.5

diff --git a/configure.ac b/configure.ac
index 1ecadd5..e0b5f78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,6 +8,7 @@ AC_INIT(kexec-tools, 2.0.10.git)
 AC_CONFIG_AUX_DIR(./config)
 AC_CONFIG_HEADERS([include/config.h])
 AC_LANG(C)
+AC_PROG_CC
 
 AC_DEFINE_UNQUOTED(PACKAGE_DATE, "`date '+%d %B %Y'`",
 		[Define to the release date of this package])
@@ -106,9 +107,6 @@ AC_ARG_WITH([booke],
 
 dnl ---Programs
 dnl To specify a different compiler, just 'export CC=/path/to/compiler'
-
-AC_PROG_CC
-
 if test "${build}" != "${host}" ; then
 	AC_CHECK_PROGS(BUILD_CC, [${build_alias}-gcc ${build}-gcc gcc])
 else