Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 1 | From fd40eee42273220fb0050fe10744b10067adc0a7 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= <anibal.limon@linux.intel.com> |
| 3 | Date: Fri, 31 Aug 2018 17:31:50 +0200 |
| 4 | Subject: [PATCH] x86_64: Add support to build kexec-tools with x32 ABI |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 8 | |
| 9 | Summary of changes, |
| 10 | |
| 11 | configure.ac: Add test for detect x32 ABI. |
| 12 | purgatory/arch/x86_64/Makefile: Not use mcmodel large when |
| 13 | x32 ABI is set. |
| 14 | kexec/arch/x86_64/kexec-elf-rel-x86_64.c: When x32 ABI is set |
| 15 | use ELFCLASS32 instead of ELFCLASS64. |
| 16 | kexec/kexec-syscall.h: Add correct syscall number for x32 ABI. |
| 17 | |
| 18 | Upstream-Status: Submitted |
| 19 | |
| 20 | Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> |
| 21 | Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> |
| 22 | |
| 23 | --- |
| 24 | configure.ac | 9 +++++++++ |
| 25 | kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 4 ++++ |
| 26 | kexec/kexec-syscall.h | 4 ++++ |
| 27 | purgatory/arch/x86_64/Makefile | 4 +++- |
| 28 | 4 files changed, 20 insertions(+), 1 deletion(-) |
| 29 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 30 | diff --git a/configure.ac b/configure.ac |
| 31 | index e05d601..c428146 100644 |
| 32 | --- a/configure.ac |
| 33 | +++ b/configure.ac |
| 34 | @@ -54,6 +54,15 @@ case $target_cpu in |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | ;; |
| 36 | ia64|x86_64|alpha|m68k ) |
| 37 | ARCH="$target_cpu" |
| 38 | + |
| 39 | + dnl ---Test for x32 ABI in x86_64 |
| 40 | + if test "x$ARCH" = "xx86_64" ; then |
| 41 | + AC_EGREP_CPP(x32_test, |
| 42 | + [#if defined(__x86_64__) && defined (__ILP32__) |
| 43 | + x32_test |
| 44 | + #endif |
| 45 | + ], SUBARCH='x32', SUBARCH='64') |
| 46 | + fi |
| 47 | ;; |
| 48 | * ) |
| 49 | AC_MSG_ERROR([unsupported architecture $target_cpu]) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 50 | diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c |
| 51 | index 761a4ed..1c0e3f8 100644 |
| 52 | --- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c |
| 53 | +++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c |
| 54 | @@ -8,7 +8,11 @@ int machine_verify_elf_rel(struct mem_ehdr *ehdr) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 55 | if (ehdr->ei_data != ELFDATA2LSB) { |
| 56 | return 0; |
| 57 | } |
| 58 | +#ifdef __ILP32__ |
| 59 | + if (ehdr->ei_class != ELFCLASS32) { |
| 60 | +#else |
| 61 | if (ehdr->ei_class != ELFCLASS64) { |
| 62 | +#endif |
| 63 | return 0; |
| 64 | } |
| 65 | if (ehdr->e_machine != EM_X86_64) { |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 66 | diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h |
| 67 | index 2a3794d..3e67078 100644 |
| 68 | --- a/kexec/kexec-syscall.h |
| 69 | +++ b/kexec/kexec-syscall.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 70 | @@ -31,8 +31,12 @@ |
| 71 | #define __NR_kexec_load 268 |
| 72 | #endif |
| 73 | #ifdef __x86_64__ |
| 74 | +#ifdef __ILP32__ |
| 75 | +#define __NR_kexec_load 528 |
| 76 | +#else |
| 77 | #define __NR_kexec_load 246 |
| 78 | #endif |
| 79 | +#endif |
| 80 | #ifdef __s390x__ |
| 81 | #define __NR_kexec_load 277 |
| 82 | #endif |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 83 | diff --git a/purgatory/arch/x86_64/Makefile b/purgatory/arch/x86_64/Makefile |
| 84 | index 7300937..4af11e4 100644 |
| 85 | --- a/purgatory/arch/x86_64/Makefile |
| 86 | +++ b/purgatory/arch/x86_64/Makefile |
| 87 | @@ -23,4 +23,6 @@ x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 88 | x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c |
| 89 | x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c |
| 90 | |
| 91 | -x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large |
| 92 | +ifeq ($(SUBARCH),64) |
| 93 | + x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large |
| 94 | +endif |