cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From c4249cf0d89f6a5ba4448eb1ff22f496387d0e50 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Fri, 7 Nov 2014 17:18:11 +0100
Subject: [PATCH 24/41] dump: select header bitness based on ELF class, not ELF
 architecture

Message-id: <1415380693-16593-25-git-send-email-lersek@redhat.com>
Patchwork-id: 62212
O-Subject: [RHEL-7.1 qemu-kvm PATCH 24/26] dump: select header bitness based on ELF class, not ELF architecture
Bugzilla: 1157798
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
RH-Acked-by: dgibson <dgibson@redhat.com>

The specific ELF architecture (d_machine) carries Too Much Information
(TM) for deciding between create_header32() and create_header64(), use
"d_class" instead (ELFCLASS32 vs. ELFCLASS64).

This change adapts write_dump_header() to write_elf_loads(), dump_begin()
etc. that also rely on the ELF class of the target for bitness selection.

Considering the current targets that support dumping, cpu_get_dump_info()
works as follows:
- target-s390x/arch_dump.c: (EM_S390, ELFCLASS64) only
- target-ppc/arch_dump.c (EM_PPC64, ELFCLASS64) only
- target-i386/arch_dump.c: sets (EM_X86_64, ELFCLASS64) vs. (EM_386,
  ELFCLASS32) keying off the same Long Mode Active flag.

Hence no observable change.

Approximately-suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
(cherry picked from commit 24aeeace7a9f264688e9eda77b6c04db607cbdfd)
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dump.c b/dump.c
index f8e0fd7..450f658 100644
--- a/dump.c
+++ b/dump.c
@@ -1006,7 +1006,7 @@ out:
 
 static int write_dump_header(DumpState *s)
 {
-    if (s->dump_info.d_machine == EM_386) {
+    if (s->dump_info.d_class == ELFCLASS32) {
         return create_header32(s);
     } else {
         return create_header64(s);
-- 
1.8.3.1