|
|
97168e |
From c851676d202b5b76962529f3b6d433936becbd8a Mon Sep 17 00:00:00 2001
|
|
|
97168e |
From: Janosch Frank <frankja@linux.ibm.com>
|
|
|
97168e |
Date: Wed, 30 Mar 2022 12:36:00 +0000
|
|
|
97168e |
Subject: [PATCH 18/42] dump: Introduce dump_is_64bit() helper function
|
|
|
97168e |
MIME-Version: 1.0
|
|
|
97168e |
Content-Type: text/plain; charset=UTF-8
|
|
|
97168e |
Content-Transfer-Encoding: 8bit
|
|
|
97168e |
|
|
|
97168e |
RH-Author: Cédric Le Goater <clg@redhat.com>
|
|
|
97168e |
RH-MergeRequest: 226: s390: Enhanced Interpretation for PCI Functions and Secure Execution guest dump
|
|
|
97168e |
RH-Bugzilla: 1664378 2043909
|
|
|
97168e |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
97168e |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
97168e |
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
97168e |
RH-Commit: [18/41] a0fd2d1985c61b8e50d4a7ca26bc0ee6fcaa6196
|
|
|
97168e |
|
|
|
97168e |
Checking d_class in dump_info leads to lengthy conditionals so let's
|
|
|
97168e |
shorten things a bit by introducing a helper function.
|
|
|
97168e |
|
|
|
97168e |
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
|
|
|
97168e |
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
|
|
97168e |
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
97168e |
Message-Id: <20220330123603.107120-7-frankja@linux.ibm.com>
|
|
|
97168e |
(cherry picked from commit 05bbaa5040ccb3419e8b93af8040485430e2db42)
|
|
|
97168e |
Signed-off-by: Cédric Le Goater <clg@redhat.com>
|
|
|
97168e |
---
|
|
|
97168e |
dump/dump.c | 25 +++++++++++++++----------
|
|
|
97168e |
1 file changed, 15 insertions(+), 10 deletions(-)
|
|
|
97168e |
|
|
|
97168e |
diff --git a/dump/dump.c b/dump/dump.c
|
|
|
97168e |
index 85a402b38c..6394e94023 100644
|
|
|
97168e |
--- a/dump/dump.c
|
|
|
97168e |
+++ b/dump/dump.c
|
|
|
97168e |
@@ -55,6 +55,11 @@ static Error *dump_migration_blocker;
|
|
|
97168e |
DIV_ROUND_UP((name_size), 4) + \
|
|
|
97168e |
DIV_ROUND_UP((desc_size), 4)) * 4)
|
|
|
97168e |
|
|
|
97168e |
+static inline bool dump_is_64bit(DumpState *s)
|
|
|
97168e |
+{
|
|
|
97168e |
+ return s->dump_info.d_class == ELFCLASS64;
|
|
|
97168e |
+}
|
|
|
97168e |
+
|
|
|
97168e |
uint16_t cpu_to_dump16(DumpState *s, uint16_t val)
|
|
|
97168e |
{
|
|
|
97168e |
if (s->dump_info.d_endian == ELFDATA2LSB) {
|
|
|
97168e |
@@ -489,7 +494,7 @@ static void write_elf_loads(DumpState *s, Error **errp)
|
|
|
97168e |
get_offset_range(memory_mapping->phys_addr,
|
|
|
97168e |
memory_mapping->length,
|
|
|
97168e |
s, &offset, &filesz);
|
|
|
97168e |
- if (s->dump_info.d_class == ELFCLASS64) {
|
|
|
97168e |
+ if (dump_is_64bit(s)) {
|
|
|
97168e |
write_elf64_load(s, memory_mapping, phdr_index++, offset,
|
|
|
97168e |
filesz, errp);
|
|
|
97168e |
} else {
|
|
|
97168e |
@@ -537,7 +542,7 @@ static void dump_begin(DumpState *s, Error **errp)
|
|
|
97168e |
*/
|
|
|
97168e |
|
|
|
97168e |
/* write elf header to vmcore */
|
|
|
97168e |
- if (s->dump_info.d_class == ELFCLASS64) {
|
|
|
97168e |
+ if (dump_is_64bit(s)) {
|
|
|
97168e |
write_elf64_header(s, errp);
|
|
|
97168e |
} else {
|
|
|
97168e |
write_elf32_header(s, errp);
|
|
|
97168e |
@@ -546,7 +551,7 @@ static void dump_begin(DumpState *s, Error **errp)
|
|
|
97168e |
return;
|
|
|
97168e |
}
|
|
|
97168e |
|
|
|
97168e |
- if (s->dump_info.d_class == ELFCLASS64) {
|
|
|
97168e |
+ if (dump_is_64bit(s)) {
|
|
|
97168e |
/* write PT_NOTE to vmcore */
|
|
|
97168e |
write_elf64_note(s, errp);
|
|
|
97168e |
if (*errp) {
|
|
|
97168e |
@@ -757,7 +762,7 @@ static void get_note_sizes(DumpState *s, const void *note,
|
|
|
97168e |
uint64_t name_sz;
|
|
|
97168e |
uint64_t desc_sz;
|
|
|
97168e |
|
|
|
97168e |
- if (s->dump_info.d_class == ELFCLASS64) {
|
|
|
97168e |
+ if (dump_is_64bit(s)) {
|
|
|
97168e |
const Elf64_Nhdr *hdr = note;
|
|
|
97168e |
note_head_sz = sizeof(Elf64_Nhdr);
|
|
|
97168e |
name_sz = tswap64(hdr->n_namesz);
|
|
|
97168e |
@@ -1017,10 +1022,10 @@ out:
|
|
|
97168e |
|
|
|
97168e |
static void write_dump_header(DumpState *s, Error **errp)
|
|
|
97168e |
{
|
|
|
97168e |
- if (s->dump_info.d_class == ELFCLASS32) {
|
|
|
97168e |
- create_header32(s, errp);
|
|
|
97168e |
- } else {
|
|
|
97168e |
+ if (dump_is_64bit(s)) {
|
|
|
97168e |
create_header64(s, errp);
|
|
|
97168e |
+ } else {
|
|
|
97168e |
+ create_header32(s, errp);
|
|
|
97168e |
}
|
|
|
97168e |
}
|
|
|
97168e |
|
|
|
97168e |
@@ -1715,8 +1720,8 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
97168e |
uint32_t size;
|
|
|
97168e |
uint16_t format;
|
|
|
97168e |
|
|
|
97168e |
- note_head_size = s->dump_info.d_class == ELFCLASS32 ?
|
|
|
97168e |
- sizeof(Elf32_Nhdr) : sizeof(Elf64_Nhdr);
|
|
|
97168e |
+ note_head_size = dump_is_64bit(s) ?
|
|
|
97168e |
+ sizeof(Elf64_Nhdr) : sizeof(Elf32_Nhdr);
|
|
|
97168e |
|
|
|
97168e |
format = le16_to_cpu(vmci->vmcoreinfo.guest_format);
|
|
|
97168e |
size = le32_to_cpu(vmci->vmcoreinfo.size);
|
|
|
97168e |
@@ -1819,7 +1824,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
97168e |
}
|
|
|
97168e |
}
|
|
|
97168e |
|
|
|
97168e |
- if (s->dump_info.d_class == ELFCLASS64) {
|
|
|
97168e |
+ if (dump_is_64bit(s)) {
|
|
|
97168e |
s->phdr_offset = sizeof(Elf64_Ehdr);
|
|
|
97168e |
s->shdr_offset = s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_num;
|
|
|
97168e |
s->note_offset = s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_num;
|
|
|
97168e |
--
|
|
|
97168e |
2.37.3
|
|
|
97168e |
|