* [Qemu-devel] [PATCH v2] s390: support dump-guest-memory on s390 @ 2013-06-12 8:09 Jens Freimann 2013-06-12 8:09 ` [Qemu-devel] [PATCH v2] s390: Implement dump-guest-memory support for target s390x Jens Freimann 0 siblings, 1 reply; 6+ messages in thread From: Jens Freimann @ 2013-06-12 8:09 UTC (permalink / raw) To: Andreas Färber; +Cc: Christian Borntraeger, Jens Freimann, qemu-devel This patch is based on Andreas Färber's qom-cpu branch. Due to new cpu_paging_enabled and get_memory_mapping cpu hooks this patch is now smaller. v2->v3: - fix endian issues - tested on little-endian host Ekaterina Tumanova (1): s390: Implement dump-guest-memory support for target s390x include/elf.h | 6 ++ target-s390x/Makefile.objs | 2 +- target-s390x/arch_dump.c | 224 +++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-qom.h | 9 ++ target-s390x/cpu.c | 4 + 5 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 target-s390x/arch_dump.c -- 1.8.1.6 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v2] s390: Implement dump-guest-memory support for target s390x 2013-06-12 8:09 [Qemu-devel] [PATCH v2] s390: support dump-guest-memory on s390 Jens Freimann @ 2013-06-12 8:09 ` Jens Freimann 2013-06-20 12:21 ` Alexander Graf 0 siblings, 1 reply; 6+ messages in thread From: Jens Freimann @ 2013-06-12 8:09 UTC (permalink / raw) To: Andreas Färber Cc: Christian Borntraeger, Ekaterina Tumanova, qemu-devel, Jens Freimann From: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> With this patch dump-guest-memory on s390 produces an ELF formatted, crash-readable dump. In order to implement this, the arch-specific part of dump-guest-memory was added: target-s390x/arch_dump.c contains the whole set of function for writing Elf note sections of all types for s390x. Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> --- include/elf.h | 6 ++ target-s390x/Makefile.objs | 2 +- target-s390x/arch_dump.c | 224 +++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-qom.h | 9 ++ target-s390x/cpu.c | 4 + 5 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 target-s390x/arch_dump.c diff --git a/include/elf.h b/include/elf.h index a21ea53..ba4b3a7 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1219,11 +1219,17 @@ typedef struct elf64_shdr { /* Notes used in ET_CORE */ #define NT_PRSTATUS 1 +#define NT_FPREGSET 2 #define NT_PRFPREG 2 #define NT_PRPSINFO 3 #define NT_TASKSTRUCT 4 #define NT_AUXV 6 #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */ +#define NT_S390_PREFIX 0x305 /* s390 prefix register */ +#define NT_S390_CTRS 0x304 /* s390 control registers */ +#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ +#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ +#define NT_S390_TIMER 0x301 /* s390 timer register */ /* Note header in a PT_NOTE section */ diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs index 4e63417..c34f654 100644 --- a/target-s390x/Makefile.objs +++ b/target-s390x/Makefile.objs @@ -1,4 +1,4 @@ obj-y += translate.o helper.o cpu.o interrupt.o obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o -obj-$(CONFIG_SOFTMMU) += ioinst.o +obj-$(CONFIG_SOFTMMU) += ioinst.o arch_dump.o obj-$(CONFIG_KVM) += kvm.o diff --git a/target-s390x/arch_dump.c b/target-s390x/arch_dump.c new file mode 100644 index 0000000..06760a7 --- /dev/null +++ b/target-s390x/arch_dump.c @@ -0,0 +1,224 @@ +/* + * writing ELF notes for s390x arch + * + * + * Copyright IBM Corp. 2012, 2013 + * + * Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "cpu.h" +#include "elf.h" +#include "exec/cpu-all.h" +#include "sysemu/dump.h" +#include "sysemu/kvm.h" + + +struct s390x_user_regs_struct { + uint64_t psw[2]; + uint64_t gprs[16]; + uint32_t acrs[16]; +} QEMU_PACKED; + +typedef struct s390x_user_regs_struct s390x_user_regs; + +struct s390x_elf_prstatus_struct { + uint8_t pad1[32]; + uint32_t pid; + uint8_t pad2[76]; + s390x_user_regs regs; + uint8_t pad3[16]; +} QEMU_PACKED; + +typedef struct s390x_elf_prstatus_struct s390x_elf_prstatus; + +struct s390x_elf_fpregset_struct { + uint32_t fpc; + uint32_t pad; + uint64_t fprs[16]; +} QEMU_PACKED; + +typedef struct s390x_elf_fpregset_struct s390x_elf_fpregset; + + typedef struct note_struct { + Elf64_Nhdr hdr; + char name[5]; + char pad3[3]; + union { + s390x_elf_prstatus prstatus; + s390x_elf_fpregset fpregset; + uint32_t prefix; + uint64_t timer; + uint64_t todcmp; + uint32_t todpreg; + uint64_t ctrs[16]; + } contents; + } QEMU_PACKED note_t; + +static int s390x_write_elf64_prstatus(note_t *note, CPUArchState *env) +{ + int i; + s390x_user_regs *regs; + + note->hdr.n_type = cpu_to_be32(NT_PRSTATUS); + + regs = &(note->contents.prstatus.regs); + regs->psw[0] = cpu_to_be64(env->psw.mask); + regs->psw[1] = cpu_to_be64(env->psw.addr); + for (i = 0; i <= 15; i++) { + regs->acrs[i] = cpu_to_be32(env->aregs[i]); + regs->gprs[i] = cpu_to_be64(env->regs[i]); + } + + return 0; +} + +static int s390x_write_elf64_fpregset(note_t *note, CPUArchState *env) +{ + int i; + + note->hdr.n_type = cpu_to_be32(NT_FPREGSET); + + note->contents.fpregset.fpc = cpu_to_be32(env->fpc); + for (i = 0; i <= 15; i++) { + note->contents.fpregset.fprs[i] = cpu_to_be64(env->fregs[i].ll); + } + + return 0; +} + + +static int s390x_write_elf64_timer(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TIMER); + + note->contents.timer = cpu_to_be64((uint64_t)(env->cputm)); + + return 0; +} + +static int s390x_write_elf64_todcmp(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TODCMP); + + note->contents.todcmp = cpu_to_be64((uint64_t)(env->ckc)); + + return 0; +} + +static int s390x_write_elf64_todpreg(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TODPREG); + + note->contents.todpreg = cpu_to_be32((uint32_t)(env->todpr)); + + return 0; +} + +static int s390x_write_elf64_ctrs(note_t *note, CPUArchState *env) +{ + int i; + + note->hdr.n_type = cpu_to_be32(NT_S390_CTRS); + + for (i = 0; i <= 15; i++) { + note->contents.ctrs[i] = cpu_to_be64(env->cregs[i]); + } + + return 0; +} + +static int s390x_write_elf64_prefix(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_PREFIX); + + note->contents.prefix = cpu_to_be32((uint32_t)(env->psa)); + + return 0; +} + + +struct note_func_desc_struct { + int contents_size; + int (*note_contents_func)(note_t *note, CPUArchState *env); +} note_func[] = { + {sizeof(((note_t *)0)->contents.prstatus), s390x_write_elf64_prstatus}, + {sizeof(((note_t *)0)->contents.prefix), s390x_write_elf64_prefix}, + {sizeof(((note_t *)0)->contents.fpregset), s390x_write_elf64_fpregset}, + {sizeof(((note_t *)0)->contents.ctrs), s390x_write_elf64_ctrs}, + {sizeof(((note_t *)0)->contents.timer), s390x_write_elf64_timer}, + {sizeof(((note_t *)0)->contents.todcmp), s390x_write_elf64_todcmp}, + {sizeof(((note_t *)0)->contents.todpreg), s390x_write_elf64_todpreg}, + { 0, NULL} +}; + + +static int s390x_write_all_elf64_notes(const char *note_name, + WriteCoreDumpFunction f, + CPUArchState *env, int id, + void *opaque) +{ + note_t note; + struct note_func_desc_struct *nf; + int note_size; + int ret = -1; + + for (nf = note_func; nf->note_contents_func; nf++) { + note.hdr.n_namesz = cpu_to_be32(sizeof(note.name)); + note.hdr.n_descsz = cpu_to_be32(nf->contents_size); + strncpy(note.name, note_name, sizeof(note.name)); + ret = (*nf->note_contents_func)(¬e, env); + + note_size = sizeof(note) - sizeof(note.contents) + nf->contents_size; + ret = f(¬e, note_size, opaque); + + if (ret < 0) { + return -1; + } + + } + + return 0; +} + + +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->env, cpuid, opaque); +} + +int cpu_get_dump_info(ArchDumpInfo *info) +{ + info->d_machine = EM_S390; + info->d_endian = ELFDATA2MSB; + info->d_class = ELFCLASS64; + + return 0; +} + +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) +{ + int name_size = 8; /* "CORE" or "QEMU" rounded */ + size_t elf_note_size = 0; + int note_head_size; + struct note_func_desc_struct *nf; + + assert(class == ELFCLASS64); + assert(machine == EM_S390); + + note_head_size = sizeof(Elf64_Nhdr); + + for (nf = note_func; nf->note_contents_func; nf++) { + elf_note_size = elf_note_size + note_head_size + name_size + + nf->contents_size; + } + + return (elf_note_size) * nr_cpus; +} + diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h index 34d45c2..4dfc8f1 100644 --- a/target-s390x/cpu-qom.h +++ b/target-s390x/cpu-qom.h @@ -72,5 +72,14 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env) #define ENV_OFFSET offsetof(S390CPU, env) void s390_cpu_do_interrupt(CPUState *cpu); +int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, + int cpuid, void *opaque); + +static inline int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, + CPUState *env, void *opaque) +{ + return 0; +} + #endif diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 23fe51f..9376a6c 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -171,6 +171,10 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = s390_cpu_do_interrupt; dc->vmsd = &vmstate_s390_cpu; +#ifndef CONFIG_USER_ONLY + cc->write_elf64_note = s390_cpu_write_elf64_note; + cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote; +#endif } static const TypeInfo s390_cpu_type_info = { -- 1.8.1.6 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] s390: Implement dump-guest-memory support for target s390x 2013-06-12 8:09 ` [Qemu-devel] [PATCH v2] s390: Implement dump-guest-memory support for target s390x Jens Freimann @ 2013-06-20 12:21 ` Alexander Graf 2013-06-25 10:17 ` [Qemu-devel] [PATCH v3] " Jens Freimann 0 siblings, 1 reply; 6+ messages in thread From: Alexander Graf @ 2013-06-20 12:21 UTC (permalink / raw) To: Jens Freimann Cc: Christian Borntraeger, Ekaterina Tumanova, Andreas Färber, qemu-devel On 12.06.2013, at 10:09, Jens Freimann wrote: > From: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> > > With this patch dump-guest-memory on s390 produces an ELF formatted, > crash-readable dump. > In order to implement this, the arch-specific part of dump-guest-memory > was added: > target-s390x/arch_dump.c contains the whole set of function for writing > Elf note sections of all types for s390x. > > Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> > Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> > > [...] > diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h > index 34d45c2..4dfc8f1 100644 > --- a/target-s390x/cpu-qom.h > +++ b/target-s390x/cpu-qom.h > @@ -72,5 +72,14 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env) > #define ENV_OFFSET offsetof(S390CPU, env) > > void s390_cpu_do_interrupt(CPUState *cpu); > +int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, > + int cpuid, void *opaque); > + > +static inline int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, > + CPUState *env, void *opaque) > +{ > + return 0; > +} This one looks odd to me. cpu-qom.h shouldn't really have a static inline to not write notes :). Either put the function into arch_dump.c as well and only export the header here or drop the whole thing and make sure that write_elf64_qemunote == NULL still works. The rest looks good, without any guarantees that the format is actually correctly implemented. Alex > + > > #endif > diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c > index 23fe51f..9376a6c 100644 > --- a/target-s390x/cpu.c > +++ b/target-s390x/cpu.c > @@ -171,6 +171,10 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) > > cc->do_interrupt = s390_cpu_do_interrupt; > dc->vmsd = &vmstate_s390_cpu; > +#ifndef CONFIG_USER_ONLY > + cc->write_elf64_note = s390_cpu_write_elf64_note; > + cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote; > +#endif > } > > static const TypeInfo s390_cpu_type_info = { > -- > 1.8.1.6 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3] s390: Implement dump-guest-memory support for target s390x 2013-06-20 12:21 ` Alexander Graf @ 2013-06-25 10:17 ` Jens Freimann 2013-06-25 15:39 ` Andreas Färber 0 siblings, 1 reply; 6+ messages in thread From: Jens Freimann @ 2013-06-25 10:17 UTC (permalink / raw) To: Alexander Graf Cc: Christian Borntraeger, Ekaterina Tumanova, Andreas Färber, Jens Freimann, qemu-devel With this patch dump-guest-memory on s390 produces an ELF formatted, crash-readable dump. In order to implement this, the arch-specific part of dump-guest-memory was added: target-s390x/arch_dump.c contains the whole set of function for writing Elf note sections of all types for s390x. Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> --- include/elf.h | 6 ++ target-s390x/Makefile.objs | 2 +- target-s390x/arch_dump.c | 229 +++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-qom.h | 5 + target-s390x/cpu.c | 4 + 5 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 target-s390x/arch_dump.c diff --git a/include/elf.h b/include/elf.h index cf0d3e2..58bfbf8 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1348,11 +1348,17 @@ typedef struct elf64_shdr { /* Notes used in ET_CORE */ #define NT_PRSTATUS 1 +#define NT_FPREGSET 2 #define NT_PRFPREG 2 #define NT_PRPSINFO 3 #define NT_TASKSTRUCT 4 #define NT_AUXV 6 #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */ +#define NT_S390_PREFIX 0x305 /* s390 prefix register */ +#define NT_S390_CTRS 0x304 /* s390 control registers */ +#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ +#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ +#define NT_S390_TIMER 0x301 /* s390 timer register */ /* Note header in a PT_NOTE section */ diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs index 4e63417..c34f654 100644 --- a/target-s390x/Makefile.objs +++ b/target-s390x/Makefile.objs @@ -1,4 +1,4 @@ obj-y += translate.o helper.o cpu.o interrupt.o obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o -obj-$(CONFIG_SOFTMMU) += ioinst.o +obj-$(CONFIG_SOFTMMU) += ioinst.o arch_dump.o obj-$(CONFIG_KVM) += kvm.o diff --git a/target-s390x/arch_dump.c b/target-s390x/arch_dump.c new file mode 100644 index 0000000..df95e46 --- /dev/null +++ b/target-s390x/arch_dump.c @@ -0,0 +1,229 @@ +/* + * writing ELF notes for s390x arch + * + * + * Copyright IBM Corp. 2012, 2013 + * + * Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "cpu.h" +#include "elf.h" +#include "exec/cpu-all.h" +#include "sysemu/dump.h" +#include "sysemu/kvm.h" + + +struct s390x_user_regs_struct { + uint64_t psw[2]; + uint64_t gprs[16]; + uint32_t acrs[16]; +} QEMU_PACKED; + +typedef struct s390x_user_regs_struct s390x_user_regs; + +struct s390x_elf_prstatus_struct { + uint8_t pad1[32]; + uint32_t pid; + uint8_t pad2[76]; + s390x_user_regs regs; + uint8_t pad3[16]; +} QEMU_PACKED; + +typedef struct s390x_elf_prstatus_struct s390x_elf_prstatus; + +struct s390x_elf_fpregset_struct { + uint32_t fpc; + uint32_t pad; + uint64_t fprs[16]; +} QEMU_PACKED; + +typedef struct s390x_elf_fpregset_struct s390x_elf_fpregset; + + typedef struct note_struct { + Elf64_Nhdr hdr; + char name[5]; + char pad3[3]; + union { + s390x_elf_prstatus prstatus; + s390x_elf_fpregset fpregset; + uint32_t prefix; + uint64_t timer; + uint64_t todcmp; + uint32_t todpreg; + uint64_t ctrs[16]; + } contents; + } QEMU_PACKED note_t; + +static int s390x_write_elf64_prstatus(note_t *note, CPUArchState *env) +{ + int i; + s390x_user_regs *regs; + + note->hdr.n_type = cpu_to_be32(NT_PRSTATUS); + + regs = &(note->contents.prstatus.regs); + regs->psw[0] = cpu_to_be64(env->psw.mask); + regs->psw[1] = cpu_to_be64(env->psw.addr); + for (i = 0; i <= 15; i++) { + regs->acrs[i] = cpu_to_be32(env->aregs[i]); + regs->gprs[i] = cpu_to_be64(env->regs[i]); + } + + return 0; +} + +static int s390x_write_elf64_fpregset(note_t *note, CPUArchState *env) +{ + int i; + + note->hdr.n_type = cpu_to_be32(NT_FPREGSET); + + note->contents.fpregset.fpc = cpu_to_be32(env->fpc); + for (i = 0; i <= 15; i++) { + note->contents.fpregset.fprs[i] = cpu_to_be64(env->fregs[i].ll); + } + + return 0; +} + + +static int s390x_write_elf64_timer(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TIMER); + + note->contents.timer = cpu_to_be64((uint64_t)(env->cputm)); + + return 0; +} + +static int s390x_write_elf64_todcmp(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TODCMP); + + note->contents.todcmp = cpu_to_be64((uint64_t)(env->ckc)); + + return 0; +} + +static int s390x_write_elf64_todpreg(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TODPREG); + + note->contents.todpreg = cpu_to_be32((uint32_t)(env->todpr)); + + return 0; +} + +static int s390x_write_elf64_ctrs(note_t *note, CPUArchState *env) +{ + int i; + + note->hdr.n_type = cpu_to_be32(NT_S390_CTRS); + + for (i = 0; i <= 15; i++) { + note->contents.ctrs[i] = cpu_to_be64(env->cregs[i]); + } + + return 0; +} + +static int s390x_write_elf64_prefix(note_t *note, CPUArchState *env) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_PREFIX); + + note->contents.prefix = cpu_to_be32((uint32_t)(env->psa)); + + return 0; +} + + +struct note_func_desc_struct { + int contents_size; + int (*note_contents_func)(note_t *note, CPUArchState *env); +} note_func[] = { + {sizeof(((note_t *)0)->contents.prstatus), s390x_write_elf64_prstatus}, + {sizeof(((note_t *)0)->contents.prefix), s390x_write_elf64_prefix}, + {sizeof(((note_t *)0)->contents.fpregset), s390x_write_elf64_fpregset}, + {sizeof(((note_t *)0)->contents.ctrs), s390x_write_elf64_ctrs}, + {sizeof(((note_t *)0)->contents.timer), s390x_write_elf64_timer}, + {sizeof(((note_t *)0)->contents.todcmp), s390x_write_elf64_todcmp}, + {sizeof(((note_t *)0)->contents.todpreg), s390x_write_elf64_todpreg}, + { 0, NULL} +}; + + +static int s390x_write_all_elf64_notes(const char *note_name, + WriteCoreDumpFunction f, + CPUArchState *env, int id, + void *opaque) +{ + note_t note; + struct note_func_desc_struct *nf; + int note_size; + int ret = -1; + + for (nf = note_func; nf->note_contents_func; nf++) { + note.hdr.n_namesz = cpu_to_be32(sizeof(note.name)); + note.hdr.n_descsz = cpu_to_be32(nf->contents_size); + strncpy(note.name, note_name, sizeof(note.name)); + ret = (*nf->note_contents_func)(¬e, env); + + note_size = sizeof(note) - sizeof(note.contents) + nf->contents_size; + ret = f(¬e, note_size, opaque); + + if (ret < 0) { + return -1; + } + + } + + return 0; +} + + +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->env, cpuid, opaque); +} + +int cpu_get_dump_info(ArchDumpInfo *info) +{ + info->d_machine = EM_S390; + info->d_endian = ELFDATA2MSB; + info->d_class = ELFCLASS64; + + return 0; +} + +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) +{ + int name_size = 8; /* "CORE" or "QEMU" rounded */ + size_t elf_note_size = 0; + int note_head_size; + struct note_func_desc_struct *nf; + + assert(class == ELFCLASS64); + assert(machine == EM_S390); + + note_head_size = sizeof(Elf64_Nhdr); + + for (nf = note_func; nf->note_contents_func; nf++) { + elf_note_size = elf_note_size + note_head_size + name_size + + nf->contents_size; + } + + return (elf_note_size) * nr_cpus; +} + +int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, + CPUState *env, void *opaque) +{ + return 0; +} diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h index 34d45c2..6327802 100644 --- a/target-s390x/cpu-qom.h +++ b/target-s390x/cpu-qom.h @@ -72,5 +72,10 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env) #define ENV_OFFSET offsetof(S390CPU, env) void s390_cpu_do_interrupt(CPUState *cpu); +int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, + int cpuid, void *opaque); + +int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, + CPUState *env, void *opaque); #endif diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 23fe51f..9376a6c 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -171,6 +171,10 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = s390_cpu_do_interrupt; dc->vmsd = &vmstate_s390_cpu; +#ifndef CONFIG_USER_ONLY + cc->write_elf64_note = s390_cpu_write_elf64_note; + cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote; +#endif } static const TypeInfo s390_cpu_type_info = { -- 1.8.2.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3] s390: Implement dump-guest-memory support for target s390x 2013-06-25 10:17 ` [Qemu-devel] [PATCH v3] " Jens Freimann @ 2013-06-25 15:39 ` Andreas Färber 2013-06-26 14:46 ` [Qemu-devel] [PATCH v4] " Jens Freimann 0 siblings, 1 reply; 6+ messages in thread From: Andreas Färber @ 2013-06-25 15:39 UTC (permalink / raw) To: Jens Freimann Cc: Christian Borntraeger, Ekaterina Tumanova, Alexander Graf, qemu-devel Hi Jens, Am 25.06.2013 12:17, schrieb Jens Freimann: > With this patch dump-guest-memory on s390 produces an ELF formatted, > crash-readable dump. > In order to implement this, the arch-specific part of dump-guest-memory > was added: > target-s390x/arch_dump.c contains the whole set of function for writing > Elf note sections of all types for s390x. > > Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> > Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Just some more nitpicks... > --- > include/elf.h | 6 ++ > target-s390x/Makefile.objs | 2 +- > target-s390x/arch_dump.c | 229 +++++++++++++++++++++++++++++++++++++++++++++ > target-s390x/cpu-qom.h | 5 + > target-s390x/cpu.c | 4 + > 5 files changed, 245 insertions(+), 1 deletion(-) > create mode 100644 target-s390x/arch_dump.c > > diff --git a/include/elf.h b/include/elf.h > index cf0d3e2..58bfbf8 100644 > --- a/include/elf.h > +++ b/include/elf.h > @@ -1348,11 +1348,17 @@ typedef struct elf64_shdr { > > /* Notes used in ET_CORE */ > #define NT_PRSTATUS 1 > +#define NT_FPREGSET 2 > #define NT_PRFPREG 2 > #define NT_PRPSINFO 3 > #define NT_TASKSTRUCT 4 > #define NT_AUXV 6 > #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */ > +#define NT_S390_PREFIX 0x305 /* s390 prefix register */ > +#define NT_S390_CTRS 0x304 /* s390 control registers */ > +#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ > +#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ > +#define NT_S390_TIMER 0x301 /* s390 timer register */ > > > /* Note header in a PT_NOTE section */ > diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs > index 4e63417..c34f654 100644 > --- a/target-s390x/Makefile.objs > +++ b/target-s390x/Makefile.objs > @@ -1,4 +1,4 @@ > obj-y += translate.o helper.o cpu.o interrupt.o > obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o > -obj-$(CONFIG_SOFTMMU) += ioinst.o > +obj-$(CONFIG_SOFTMMU) += ioinst.o arch_dump.o > obj-$(CONFIG_KVM) += kvm.o > diff --git a/target-s390x/arch_dump.c b/target-s390x/arch_dump.c > new file mode 100644 > index 0000000..df95e46 > --- /dev/null > +++ b/target-s390x/arch_dump.c > @@ -0,0 +1,229 @@ > +/* > + * writing ELF notes for s390x arch > + * > + * > + * Copyright IBM Corp. 2012, 2013 > + * > + * Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + * > + */ > + > +#include "cpu.h" > +#include "elf.h" > +#include "exec/cpu-all.h" > +#include "sysemu/dump.h" > +#include "sysemu/kvm.h" > + > + > +struct s390x_user_regs_struct { > + uint64_t psw[2]; > + uint64_t gprs[16]; > + uint32_t acrs[16]; > +} QEMU_PACKED; > + > +typedef struct s390x_user_regs_struct s390x_user_regs; Are these copied from the kernel or somewhere? QEMU expects CamelCase for both struct and typedef. > + > +struct s390x_elf_prstatus_struct { > + uint8_t pad1[32]; > + uint32_t pid; > + uint8_t pad2[76]; > + s390x_user_regs regs; > + uint8_t pad3[16]; > +} QEMU_PACKED; > + > +typedef struct s390x_elf_prstatus_struct s390x_elf_prstatus; > + > +struct s390x_elf_fpregset_struct { > + uint32_t fpc; > + uint32_t pad; > + uint64_t fprs[16]; Indentation? > +} QEMU_PACKED; > + > +typedef struct s390x_elf_fpregset_struct s390x_elf_fpregset; > + > + typedef struct note_struct { > + Elf64_Nhdr hdr; > + char name[5]; > + char pad3[3]; > + union { > + s390x_elf_prstatus prstatus; > + s390x_elf_fpregset fpregset; > + uint32_t prefix; > + uint64_t timer; > + uint64_t todcmp; > + uint32_t todpreg; > + uint64_t ctrs[16]; > + } contents; > + } QEMU_PACKED note_t; Why indented? *_t has been criticized as being reserved for POSIX. > + > +static int s390x_write_elf64_prstatus(note_t *note, CPUArchState *env) Please don't use CPUArchState in s390x-only code, use CPUS390XState where needed; for static helpers please prefer S390CPU. `git grep CPUArchState` flags to me where I still need to touch things, same for ENV_GET_CPU() (which Jason recently introduced, fix upcoming). > +{ > + int i; > + s390x_user_regs *regs; > + > + note->hdr.n_type = cpu_to_be32(NT_PRSTATUS); > + > + regs = &(note->contents.prstatus.regs); > + regs->psw[0] = cpu_to_be64(env->psw.mask); > + regs->psw[1] = cpu_to_be64(env->psw.addr); Two spaces accidental? > + for (i = 0; i <= 15; i++) { > + regs->acrs[i] = cpu_to_be32(env->aregs[i]); > + regs->gprs[i] = cpu_to_be64(env->regs[i]); > + } > + > + return 0; > +} Already returns 0, make it void? Same for all callbacks below. > + > +static int s390x_write_elf64_fpregset(note_t *note, CPUArchState *env) > +{ > + int i; > + > + note->hdr.n_type = cpu_to_be32(NT_FPREGSET); > + > + note->contents.fpregset.fpc = cpu_to_be32(env->fpc); > + for (i = 0; i <= 15; i++) { > + note->contents.fpregset.fprs[i] = cpu_to_be64(env->fregs[i].ll); > + } > + > + return 0; > +} > + > + > +static int s390x_write_elf64_timer(note_t *note, CPUArchState *env) > +{ > + note->hdr.n_type = cpu_to_be32(NT_S390_TIMER); > + > + note->contents.timer = cpu_to_be64((uint64_t)(env->cputm)); > + > + return 0; > +} > + > +static int s390x_write_elf64_todcmp(note_t *note, CPUArchState *env) > +{ > + note->hdr.n_type = cpu_to_be32(NT_S390_TODCMP); > + > + note->contents.todcmp = cpu_to_be64((uint64_t)(env->ckc)); > + > + return 0; > +} > + > +static int s390x_write_elf64_todpreg(note_t *note, CPUArchState *env) > +{ > + note->hdr.n_type = cpu_to_be32(NT_S390_TODPREG); > + > + note->contents.todpreg = cpu_to_be32((uint32_t)(env->todpr)); > + > + return 0; > +} > + > +static int s390x_write_elf64_ctrs(note_t *note, CPUArchState *env) > +{ > + int i; > + > + note->hdr.n_type = cpu_to_be32(NT_S390_CTRS); > + > + for (i = 0; i <= 15; i++) { > + note->contents.ctrs[i] = cpu_to_be64(env->cregs[i]); > + } > + > + return 0; > +} > + > +static int s390x_write_elf64_prefix(note_t *note, CPUArchState *env) > +{ > + note->hdr.n_type = cpu_to_be32(NT_S390_PREFIX); > + > + note->contents.prefix = cpu_to_be32((uint32_t)(env->psa)); > + > + return 0; > +} > + > + > +struct note_func_desc_struct { > + int contents_size; > + int (*note_contents_func)(note_t *note, CPUArchState *env); > +} note_func[] = { > + {sizeof(((note_t *)0)->contents.prstatus), s390x_write_elf64_prstatus}, > + {sizeof(((note_t *)0)->contents.prefix), s390x_write_elf64_prefix}, > + {sizeof(((note_t *)0)->contents.fpregset), s390x_write_elf64_fpregset}, > + {sizeof(((note_t *)0)->contents.ctrs), s390x_write_elf64_ctrs}, > + {sizeof(((note_t *)0)->contents.timer), s390x_write_elf64_timer}, > + {sizeof(((note_t *)0)->contents.todcmp), s390x_write_elf64_todcmp}, > + {sizeof(((note_t *)0)->contents.todpreg), s390x_write_elf64_todpreg}, > + { 0, NULL} > +}; > + > + > +static int s390x_write_all_elf64_notes(const char *note_name, > + WriteCoreDumpFunction f, > + CPUArchState *env, int id, > + void *opaque) Odd indentation? > +{ > + note_t note; > + struct note_func_desc_struct *nf; typedef and CamelCase > + int note_size; > + int ret = -1; > + > + for (nf = note_func; nf->note_contents_func; nf++) { > + note.hdr.n_namesz = cpu_to_be32(sizeof(note.name)); > + note.hdr.n_descsz = cpu_to_be32(nf->contents_size); > + strncpy(note.name, note_name, sizeof(note.name)); > + ret = (*nf->note_contents_func)(¬e, env); > + > + note_size = sizeof(note) - sizeof(note.contents) + nf->contents_size; > + ret = f(¬e, note_size, opaque); > + > + if (ret < 0) { > + return -1; > + } > + > + } > + > + return 0; > +} > + > + > +int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, > + int cpuid, void *opaque) > +{ > + S390CPU *cpu = S390_CPU(cs); Here you have the S390CPU that you could just pass on. > + return s390x_write_all_elf64_notes("CORE", f, &cpu->env, cpuid, opaque); > +} > + > +int cpu_get_dump_info(ArchDumpInfo *info) > +{ > + info->d_machine = EM_S390; > + info->d_endian = ELFDATA2MSB; > + info->d_class = ELFCLASS64; > + > + return 0; > +} > + > +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) > +{ > + int name_size = 8; /* "CORE" or "QEMU" rounded */ > + size_t elf_note_size = 0; > + int note_head_size; > + struct note_func_desc_struct *nf; > + > + assert(class == ELFCLASS64); > + assert(machine == EM_S390); > + > + note_head_size = sizeof(Elf64_Nhdr); > + > + for (nf = note_func; nf->note_contents_func; nf++) { > + elf_note_size = elf_note_size + note_head_size + name_size + > + nf->contents_size; > + } > + > + return (elf_note_size) * nr_cpus; > +} > + > +int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, > + CPUState *env, void *opaque) Please don't mix env with CPUState. Indentation? > +{ > + return 0; > +} > diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h > index 34d45c2..6327802 100644 > --- a/target-s390x/cpu-qom.h > +++ b/target-s390x/cpu-qom.h > @@ -72,5 +72,10 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env) > #define ENV_OFFSET offsetof(S390CPU, env) > > void s390_cpu_do_interrupt(CPUState *cpu); > +int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, > + int cpuid, void *opaque); > + > +int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, > + CPUState *env, void *opaque); Consistent indentation? > > #endif > diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c > index 23fe51f..9376a6c 100644 > --- a/target-s390x/cpu.c > +++ b/target-s390x/cpu.c > @@ -171,6 +171,10 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) > > cc->do_interrupt = s390_cpu_do_interrupt; > dc->vmsd = &vmstate_s390_cpu; > +#ifndef CONFIG_USER_ONLY > + cc->write_elf64_note = s390_cpu_write_elf64_note; > + cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote; > +#endif > } > > static const TypeInfo s390_cpu_type_info = { Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v4] s390: Implement dump-guest-memory support for target s390x 2013-06-25 15:39 ` Andreas Färber @ 2013-06-26 14:46 ` Jens Freimann 0 siblings, 0 replies; 6+ messages in thread From: Jens Freimann @ 2013-06-26 14:46 UTC (permalink / raw) To: Alexander Graf Cc: Christian Borntraeger, Ekaterina Tumanova, Andreas Färber, Jens Freimann, qemu-devel With this patch dump-guest-memory on s390 produces an ELF formatted, crash-readable dump. In order to implement this, the arch-specific part of dump-guest-memory was added: target-s390x/arch_dump.c contains the whole set of function for writing Elf note sections of all types for s390x. Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> [fixed indentation, use CamelCase, rename note_t to Note, use S390CPU] --- include/elf.h | 6 ++ target-s390x/Makefile.objs | 2 +- target-s390x/arch_dump.c | 213 +++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-qom.h | 5 ++ target-s390x/cpu.c | 4 + 5 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 target-s390x/arch_dump.c diff --git a/include/elf.h b/include/elf.h index cf0d3e2..58bfbf8 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1348,11 +1348,17 @@ typedef struct elf64_shdr { /* Notes used in ET_CORE */ #define NT_PRSTATUS 1 +#define NT_FPREGSET 2 #define NT_PRFPREG 2 #define NT_PRPSINFO 3 #define NT_TASKSTRUCT 4 #define NT_AUXV 6 #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */ +#define NT_S390_PREFIX 0x305 /* s390 prefix register */ +#define NT_S390_CTRS 0x304 /* s390 control registers */ +#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ +#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ +#define NT_S390_TIMER 0x301 /* s390 timer register */ /* Note header in a PT_NOTE section */ diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs index 4e63417..c34f654 100644 --- a/target-s390x/Makefile.objs +++ b/target-s390x/Makefile.objs @@ -1,4 +1,4 @@ obj-y += translate.o helper.o cpu.o interrupt.o obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o -obj-$(CONFIG_SOFTMMU) += ioinst.o +obj-$(CONFIG_SOFTMMU) += ioinst.o arch_dump.o obj-$(CONFIG_KVM) += kvm.o diff --git a/target-s390x/arch_dump.c b/target-s390x/arch_dump.c new file mode 100644 index 0000000..bc8db62 --- /dev/null +++ b/target-s390x/arch_dump.c @@ -0,0 +1,213 @@ +/* + * writing ELF notes for s390x arch + * + * + * Copyright IBM Corp. 2012, 2013 + * + * Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "cpu.h" +#include "cpu-qom.h" +#include "elf.h" +#include "exec/cpu-all.h" +#include "sysemu/dump.h" +#include "sysemu/kvm.h" + + +struct S390xUserRegsStruct { + uint64_t psw[2]; + uint64_t gprs[16]; + uint32_t acrs[16]; +} QEMU_PACKED; + +typedef struct S390xUserRegsStruct S390xUserRegs; + +struct S390xElfPrstatusStruct { + uint8_t pad1[32]; + uint32_t pid; + uint8_t pad2[76]; + S390xUserRegs regs; + uint8_t pad3[16]; +} QEMU_PACKED; + +typedef struct S390xElfPrstatusStruct S390xElfPrstatus; + +struct S390xElfFpregsetStruct { + uint32_t fpc; + uint32_t pad; + uint64_t fprs[16]; +} QEMU_PACKED; + +typedef struct S390xElfFpregsetStruct S390xElfFpregset; + +typedef struct noteStruct { + Elf64_Nhdr hdr; + char name[5]; + char pad3[3]; + union { + S390xElfPrstatus prstatus; + S390xElfFpregset fpregset; + uint32_t prefix; + uint64_t timer; + uint64_t todcmp; + uint32_t todpreg; + uint64_t ctrs[16]; + } contents; +} QEMU_PACKED Note; + +static void s390x_write_elf64_prstatus(Note *note, S390CPU *cpu) +{ + int i; + S390xUserRegs *regs; + + note->hdr.n_type = cpu_to_be32(NT_PRSTATUS); + + regs = &(note->contents.prstatus.regs); + regs->psw[0] = cpu_to_be64(cpu->env.psw.mask); + regs->psw[1] = cpu_to_be64(cpu->env.psw.addr); + for (i = 0; i <= 15; i++) { + regs->acrs[i] = cpu_to_be32(cpu->env.aregs[i]); + regs->gprs[i] = cpu_to_be64(cpu->env.regs[i]); + } +} + +static void s390x_write_elf64_fpregset(Note *note, S390CPU *cpu) +{ + int i; + + note->hdr.n_type = cpu_to_be32(NT_FPREGSET); + note->contents.fpregset.fpc = cpu_to_be32(cpu->env.fpc); + for (i = 0; i <= 15; i++) { + note->contents.fpregset.fprs[i] = cpu_to_be64(cpu->env.fregs[i].ll); + } +} + + +static void s390x_write_elf64_timer(Note *note, S390CPU *cpu) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TIMER); + note->contents.timer = cpu_to_be64((uint64_t)(cpu->env.cputm)); +} + +static void s390x_write_elf64_todcmp(Note *note, S390CPU *cpu) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TODCMP); + note->contents.todcmp = cpu_to_be64((uint64_t)(cpu->env.ckc)); +} + +static void s390x_write_elf64_todpreg(Note *note, S390CPU *cpu) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_TODPREG); + note->contents.todpreg = cpu_to_be32((uint32_t)(cpu->env.todpr)); +} + +static void s390x_write_elf64_ctrs(Note *note, S390CPU *cpu) +{ + int i; + + note->hdr.n_type = cpu_to_be32(NT_S390_CTRS); + + for (i = 0; i <= 15; i++) { + note->contents.ctrs[i] = cpu_to_be64(cpu->env.cregs[i]); + } +} + +static void s390x_write_elf64_prefix(Note *note, S390CPU *cpu) +{ + note->hdr.n_type = cpu_to_be32(NT_S390_PREFIX); + note->contents.prefix = cpu_to_be32((uint32_t)(cpu->env.psa)); +} + + +struct NoteFuncDescStruct { + int contents_size; + void (*note_contents_func)(Note *note, S390CPU *cpu); +} note_func[] = { + {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}, + {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}, + {sizeof(((Note *)0)->contents.todpreg), s390x_write_elf64_todpreg}, + { 0, NULL} +}; + +typedef struct NoteFuncDescStruct NoteFuncDesc; + + +static int s390x_write_all_elf64_notes(const char *note_name, + WriteCoreDumpFunction f, + S390CPU *cpu, int id, + void *opaque) +{ + Note note; + NoteFuncDesc *nf; + int note_size; + int ret = -1; + + for (nf = note_func; nf->note_contents_func; nf++) { + note.hdr.n_namesz = cpu_to_be32(sizeof(note.name)); + note.hdr.n_descsz = cpu_to_be32(nf->contents_size); + strncpy(note.name, note_name, sizeof(note.name)); + (*nf->note_contents_func)(¬e, cpu); + + note_size = sizeof(note) - sizeof(note.contents) + nf->contents_size; + ret = f(¬e, note_size, opaque); + + if (ret < 0) { + return -1; + } + + } + + return 0; +} + + +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 cpu_get_dump_info(ArchDumpInfo *info) +{ + info->d_machine = EM_S390; + info->d_endian = ELFDATA2MSB; + info->d_class = ELFCLASS64; + + return 0; +} + +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) +{ + int name_size = 8; /* "CORE" or "QEMU" rounded */ + size_t elf_note_size = 0; + int note_head_size; + NoteFuncDesc *nf; + + assert(class == ELFCLASS64); + assert(machine == EM_S390); + + note_head_size = sizeof(Elf64_Nhdr); + + for (nf = note_func; nf->note_contents_func; nf++) { + elf_note_size = elf_note_size + note_head_size + name_size + + nf->contents_size; + } + + return (elf_note_size) * nr_cpus; +} + +int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, + CPUState *cpu, void *opaque) +{ + return 0; +} diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h index 34d45c2..1b52abb 100644 --- a/target-s390x/cpu-qom.h +++ b/target-s390x/cpu-qom.h @@ -72,5 +72,10 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env) #define ENV_OFFSET offsetof(S390CPU, env) void s390_cpu_do_interrupt(CPUState *cpu); +int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, + int cpuid, void *opaque); + +int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, + CPUState *cpu, void *opaque); #endif diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 23fe51f..9376a6c 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -171,6 +171,10 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = s390_cpu_do_interrupt; dc->vmsd = &vmstate_s390_cpu; +#ifndef CONFIG_USER_ONLY + cc->write_elf64_note = s390_cpu_write_elf64_note; + cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote; +#endif } static const TypeInfo s390_cpu_type_info = { -- 1.8.2.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-06-26 14:46 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-06-12 8:09 [Qemu-devel] [PATCH v2] s390: support dump-guest-memory on s390 Jens Freimann 2013-06-12 8:09 ` [Qemu-devel] [PATCH v2] s390: Implement dump-guest-memory support for target s390x Jens Freimann 2013-06-20 12:21 ` Alexander Graf 2013-06-25 10:17 ` [Qemu-devel] [PATCH v3] " Jens Freimann 2013-06-25 15:39 ` Andreas Färber 2013-06-26 14:46 ` [Qemu-devel] [PATCH v4] " Jens Freimann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).