Skip to contentSkip to conversation

x86_64: Add support to build kexec-tools with x32 ABI

PATCH In review Aníbal Limón 2 participants 7 messages Mar 26, 2015 – Apr 9, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 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(-)
configure.ac +9 -0
index c410e90..1ecadd5 100644
@@ -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])
kexec/arch/x86_64/kexec-elf-rel-x86_64.c +4 -0
index c795037..06db7f0 100644
@@ -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) {
kexec/kexec-syscall.h +4 -0
index ce2e20b..cab5535 100644
@@ -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
purgatory/arch/x86_64/Makefile +3 -1
index 7300937..4af11e4 100644
@@ -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
Signature · 7 lines
1.8.4.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

Any comment or feedback?

alimon

Quoted 76 lines · Aníbal Limón

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.

---
  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(-)
configure.ac +9 -0
index c410e90..1ecadd5 100644
@@ -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])
kexec/arch/x86_64/kexec-elf-rel-x86_64.c +4 -0
index c795037..06db7f0 100644
@@ -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) {
kexec/kexec-syscall.h +4 -0
index ce2e20b..cab5535 100644
@@ -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
purgatory/arch/x86_64/Makefile +0 -0
index 7300937..4af11e4 100644

purgatory/arch/x86_64/Makefile x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c · line 28

Quoted 7 lines
purgatory/arch/x86_64/Makefile +3 -1
@@ -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

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw
Quoted 1 line · Aníbal Limón

Any comment or feedback?

I feel like I am missing something obvious, but could you explain the use case a little more clearly?

Quoted 84 lines

alimon

Quoted 80 lines · Aníbal Limón

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.

---
 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(-)
configure.ac +9 -0
index c410e90..1ecadd5 100644
@@ -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])
kexec/arch/x86_64/kexec-elf-rel-x86_64.c +4 -0
index c795037..06db7f0 100644
@@ -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) {
kexec/kexec-syscall.h +4 -0
index ce2e20b..cab5535 100644
@@ -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
purgatory/arch/x86_64/Makefile +1 -1
index 7300937..4af11e4 100644
@@ -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)
Quoted 8 lines

purgatory/arch/x86_64/Makefile x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c · line 28

Quoted 2 lines
purgatory/arch/x86_64/Makefile +2 -0
+        x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
+endif

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
Quoted 4 lines · Simon Horman
Quoted 1 line · Aníbal Limón

Any comment or feedback?

I feel like I am missing something obvious, but could you explain the use case a little more clearly?

I'm working in the Yocto Project enabling x32 ABI support, the x32 ABI enables programs to work with 32-bit address space and support of benefits of 64-bit mode like register calling convention, this improves performance in some applications, details [1][2].

I don't know if this answer your question?

Cheers,
alimon

[1] https://sites.google.com/site/x32abi/
[2] http://en.wikipedia.org/wiki/X32_ABI

Quoted 83 lines
Quoted 83 lines

alimon

Quoted 79 lines · Aníbal Limón

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.

---
  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(-)
configure.ac +9 -0
index c410e90..1ecadd5 100644
@@ -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])
kexec/arch/x86_64/kexec-elf-rel-x86_64.c +4 -0
index c795037..06db7f0 100644
@@ -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) {
kexec/kexec-syscall.h +4 -0
index ce2e20b..cab5535 100644
@@ -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
purgatory/arch/x86_64/Makefile +0 -1
index 7300937..4af11e4 100644
@@ -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
Quoted 8 lines
Quoted 8 lines

purgatory/arch/x86_64/Makefile x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c · line 28

Quoted 3 lines
purgatory/arch/x86_64/Makefile +3 -0
+ifeq ($(SUBARCH),64)
+        x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
+endif

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
Quoted 15 lines · Aníbal Limón
Quoted 4 lines · Simon Horman
Quoted 1 line · Aníbal Limón

Any comment or feedback?

I feel like I am missing something obvious, but could you explain the use case a little more clearly?

I'm working in the Yocto Project enabling x32 ABI support, the x32 ABI enables
programs to work with 32-bit address space and support of benefits of 64-bit mode
like register calling convention, this improves performance in some applications,
details [1][2].

Quoted 1 line

I don't know if this answer your question?

Thanks, that answers my question very well.
I have applied your patch.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw

Hi Simon,

I did more testing and found that the patch causes a fail when try to compile with zlib and other arch not x86_64, it's related to AC_EGREP_CPP needs previous AC_PROG_CC.

I sent a patch for that,

http://lists.infradead.org/pipermail/kexec/2015-April/013554.html

Sorry for the problems that i may have caused.

Kind regards,
alimon

Quoted 14 lines · Simon Horman
Quoted 13 lines · Aníbal Limón
Quoted 4 lines · Simon Horman
Quoted 1 line · Aníbal Limón

Any comment or feedback?

I feel like I am missing something obvious, but could you explain the use case a little more clearly?

I'm working in the Yocto Project enabling x32 ABI support, the x32 ABI enables
programs to work with 32-bit address space and support of benefits of 64-bit mode
like register calling convention, this improves performance in some applications,
details [1][2].

Quoted 3 lines
Quoted 1 line

I don't know if this answer your question?

Thanks, that answers my question very well.
I have applied your patch.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw
Quoted 11 lines · Aníbal Limón

Hi Simon,

I did more testing and found that the patch causes a fail when try to compile with zlib and other arch not
x86_64, it's related to AC_EGREP_CPP needs previous AC_PROG_CC.

I sent a patch for that,

http://lists.infradead.org/pipermail/kexec/2015-April/013554.html

Sorry for the problems that i may have caused.

Thanks, got it.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec