[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/12] s390x/arch_dump: use proper note name and not
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PATCH 11/12] s390x/arch_dump: use proper note name and note size |
Date: |
Mon, 20 Feb 2017 10:57:33 +0100 |
From: Christian Borntraeger <address@hidden>
In binutils/libbfd (bfd/elf.c) it is enforced that all s390
specific ELF notes like e.g. NT_S390_PREFIX or NT_S390_CTRS
have "LINUX" specified as note name and that the namesz is
6. Otherwise the notes are ignored.
QEMU currently uses "CORE" for these notes. Up to now this has
not been a real problem because the dump analysis tool "crash"
does handle that. But it will break all programs that use libbfd
for processing ELF notes.
So fix this and use "LINUX" for all s390 specific notes to comply
with libbfd. Also set the correct namesz.
Reported-by: Philipp Rudo <address@hidden>
Signed-off-by: Christian Borntraeger <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
target/s390x/arch_dump.c | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c
index 4731869f6b..887cae947e 100644
--- a/target/s390x/arch_dump.c
+++ b/target/s390x/arch_dump.c
@@ -59,8 +59,7 @@ typedef struct S390xElfVregsHiStruct S390xElfVregsHi;
typedef struct noteStruct {
Elf64_Nhdr hdr;
- char name[5];
- char pad3[3];
+ char name[8];
union {
S390xElfPrstatus prstatus;
S390xElfFpregset fpregset;
@@ -162,13 +161,19 @@ static void s390x_write_elf64_prefix(Note *note, S390CPU
*cpu)
}
-static const struct NoteFuncDescStruct {
+typedef struct NoteFuncDescStruct {
int contents_size;
void (*note_contents_func)(Note *note, S390CPU *cpu);
-} note_func[] = {
+} NoteFuncDesc;
+
+static const NoteFuncDesc note_core[] = {
{sizeof(((Note *)0)->contents.prstatus), s390x_write_elf64_prstatus},
- {sizeof(((Note *)0)->contents.prefix), s390x_write_elf64_prefix},
{sizeof(((Note *)0)->contents.fpregset), s390x_write_elf64_fpregset},
+ { 0, NULL}
+};
+
+static const NoteFuncDesc note_linux[] = {
+ {sizeof(((Note *)0)->contents.prefix), s390x_write_elf64_prefix},
{sizeof(((Note *)0)->contents.ctrs), s390x_write_elf64_ctrs},
{sizeof(((Note *)0)->contents.timer), s390x_write_elf64_timer},
{sizeof(((Note *)0)->contents.todcmp), s390x_write_elf64_todcmp},
@@ -178,22 +183,20 @@ static const struct NoteFuncDescStruct {
{ 0, NULL}
};
-typedef struct NoteFuncDescStruct NoteFuncDesc;
-
-
-static int s390x_write_all_elf64_notes(const char *note_name,
+static int s390x_write_elf64_notes(const char *note_name,
WriteCoreDumpFunction f,
S390CPU *cpu, int id,
- void *opaque)
+ void *opaque,
+ const NoteFuncDesc *funcs)
{
Note note;
const NoteFuncDesc *nf;
int note_size;
int ret = -1;
- for (nf = note_func; nf->note_contents_func; nf++) {
+ for (nf = funcs; nf->note_contents_func; nf++) {
memset(¬e, 0, sizeof(note));
- note.hdr.n_namesz = cpu_to_be32(sizeof(note.name));
+ note.hdr.n_namesz = cpu_to_be32(strlen(note_name) + 1);
note.hdr.n_descsz = cpu_to_be32(nf->contents_size);
strncpy(note.name, note_name, sizeof(note.name));
(*nf->note_contents_func)(¬e, cpu);
@@ -215,7 +218,13 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f,
CPUState *cs,
int cpuid, void *opaque)
{
S390CPU *cpu = S390_CPU(cs);
- return s390x_write_all_elf64_notes("CORE", f, cpu, cpuid, opaque);
+ int r;
+
+ r = s390x_write_elf64_notes("CORE", f, cpu, cpuid, opaque, note_core);
+ if (r) {
+ return r;
+ }
+ return s390x_write_elf64_notes("LINUX", f, cpu, cpuid, opaque, note_linux);
}
int cpu_get_dump_info(ArchDumpInfo *info,
@@ -230,7 +239,7 @@ int cpu_get_dump_info(ArchDumpInfo *info,
ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)
{
- int name_size = 8; /* "CORE" or "QEMU" rounded */
+ int name_size = 8; /* "LINUX" or "CORE" + pad */
size_t elf_note_size = 0;
int note_head_size;
const NoteFuncDesc *nf;
@@ -240,7 +249,11 @@ ssize_t cpu_get_note_size(int class, int machine, int
nr_cpus)
note_head_size = sizeof(Elf64_Nhdr);
- for (nf = note_func; nf->note_contents_func; nf++) {
+ for (nf = note_core; nf->note_contents_func; nf++) {
+ elf_note_size = elf_note_size + note_head_size + name_size +
+ nf->contents_size;
+ }
+ for (nf = note_linux; nf->note_contents_func; nf++) {
elf_note_size = elf_note_size + note_head_size + name_size +
nf->contents_size;
}
--
2.11.0
- [Qemu-devel] [PATCH 00/12] more s390x patches for 2.9, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 02/12] s390x/kvm: detect some program check loops, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 01/12] s390x/s390-virtio: get rid of DPRINTF, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 05/12] virtio-ccw: add virtio-crypto-ccw device, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 03/12] s390x/flic: fail migration on source already, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 08/12] virtio-ccw: check flic->adapter_routes_max_batch, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 07/12] s390x: add property adapter_routes_max_batch, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 06/12] virtio-ccw: Check the number of vqs in CCW_CMD_SET_IND, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 04/12] virtio-ccw: handle virtio 1 only devices, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 09/12] s390x: bump ADAPTER_ROUTES_MAX_GSI, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 11/12] s390x/arch_dump: use proper note name and note size,
Cornelia Huck <=
- [Qemu-devel] [PATCH 12/12] s390x/arch_dump: pass cpuid into notes sections, Cornelia Huck, 2017/02/20
- [Qemu-devel] [PATCH 10/12] virtio-ccw: support VIRTIO_QUEUE_MAX virtqueues, Cornelia Huck, 2017/02/20