From nobody Mon Apr 29 23:09:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488289854946971.1469585936691; Tue, 28 Feb 2017 05:50:54 -0800 (PST) Received: from localhost ([::1]:32927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciiB2-0004p9-EI for importer@patchew.org; Tue, 28 Feb 2017 08:50:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cihtU-0004oa-7s for qemu-devel@nongnu.org; Tue, 28 Feb 2017 08:32:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cihtR-0008F9-1O for qemu-devel@nongnu.org; Tue, 28 Feb 2017 08:32:44 -0500 Received: from relay2.gtri.gatech.edu ([130.207.199.168]:38285) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cihtQ-0008EL-S1 for qemu-devel@nongnu.org; Tue, 28 Feb 2017 08:32:40 -0500 Received: from apatlisdmail07.core.gtri.org (apatlisdmail07.core.gtri.org [10.41.47.117]) by relay2.gtri.gatech.edu with ESMTP id vLgD3lZrqTQUNOdw (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Tue, 28 Feb 2017 08:32:38 -0500 (EST) Received: from apatlisdmail06.core.gtri.org (10.41.47.116) by apatlisdmail07.core.gtri.org (10.41.47.117) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 28 Feb 2017 08:32:38 -0500 Received: from etcm-MPN-d02.ctisl.gtri.org (130.207.205.130) by apatlisdmail06.core.gtri.org (10.41.47.116) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 28 Feb 2017 08:32:38 -0500 X-ASG-Debug-ID: 1488288758-0768e4117d1181250001-jgbH7p X-Barracuda-Envelope-From: Michael.Nawrocki@gtri.gatech.edu From: Mike Nawrocki To: Date: Tue, 28 Feb 2017 08:32:17 -0500 X-ASG-Orig-Subj: [PATCH] Add PowerPC 32-bit guest memory dump support Message-ID: <20170228133217.20039-1-michael.nawrocki@gtri.gatech.edu> X-Mailer: git-send-email 2.11.0 In-Reply-To: <148825736854.186.587070083826625623@0e2666bad730> References: <148825736854.186.587070083826625623@0e2666bad730> MIME-Version: 1.0 X-Originating-IP: [130.207.205.130] X-ClientProxiedBy: apatlisdmfe4.core.gtri.org (10.41.47.104) To apatlisdmail06.core.gtri.org (10.41.47.116) X-Barracuda-Connect: apatlisdmail07.core.gtri.org[10.41.47.117] X-Barracuda-Start-Time: 1488288758 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA384 X-Barracuda-URL: https://130.207.199.168:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at gtri.gatech.edu X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.36859 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 130.207.199.168 Subject: [Qemu-devel] [PATCH] Add PowerPC 32-bit guest memory dump support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Nawrocki , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Mike Nawrocki Sorry, I was only testing against the ppc-softmmu and ppc64-softmmu targets= . I've now validated that this compiles against the following targets: ppc-softmmu,ppc64-softmmu,ppcemb-softmmu,s390x-softmmu,sh4-softmmu,ppc-linu= x-user,ppc64-linux-user,ppc64abi32-linux-user,ppc64le-linux-user,s390x-linu= x-user Thanks! --- target/ppc/Makefile.objs | 4 +- target/ppc/arch_dump.c | 154 ++++++++++++++++++++++++----------------= ---- target/ppc/cpu.h | 2 + target/ppc/translate_init.c | 7 +- 4 files changed, 93 insertions(+), 74 deletions(-) diff --git a/target/ppc/Makefile.objs b/target/ppc/Makefile.objs index a8c7a30cde..f50ffacfa1 100644 --- a/target/ppc/Makefile.objs +++ b/target/ppc/Makefile.objs @@ -1,8 +1,8 @@ obj-y +=3D cpu-models.o obj-y +=3D translate.o ifeq ($(CONFIG_SOFTMMU),y) -obj-y +=3D machine.o mmu_helper.o mmu-hash32.o monitor.o -obj-$(TARGET_PPC64) +=3D mmu-hash64.o arch_dump.o compat.o +obj-y +=3D machine.o mmu_helper.o mmu-hash32.o monitor.o arch_dump.o +obj-$(TARGET_PPC64) +=3D mmu-hash64.o compat.o endif obj-$(CONFIG_KVM) +=3D kvm.o obj-$(call lnot,$(CONFIG_KVM)) +=3D kvm-stub.o diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c index 40282a1f50..28d9cc7d79 100644 --- a/target/ppc/arch_dump.c +++ b/target/ppc/arch_dump.c @@ -1,5 +1,5 @@ /* - * writing ELF notes for ppc64 arch + * writing ELF notes for ppc{64,} arch * * * Copyright IBM, Corp. 2013 @@ -19,36 +19,48 @@ #include "sysemu/dump.h" #include "sysemu/kvm.h" =20 -struct PPC64UserRegStruct { - uint64_t gpr[32]; - uint64_t nip; - uint64_t msr; - uint64_t orig_gpr3; - uint64_t ctr; - uint64_t link; - uint64_t xer; - uint64_t ccr; - uint64_t softe; - uint64_t trap; - uint64_t dar; - uint64_t dsisr; - uint64_t result; +#ifdef TARGET_PPC64 +#define ELFCLASS ELFCLASS64 +#define cpu_to_dump_reg cpu_to_dump64 +typedef uint64_t reg_t; +typedef Elf64_Nhdr Elf_Nhdr; +#else +#define ELFCLASS ELFCLASS32 +#define cpu_to_dump_reg cpu_to_dump32 +typedef uint32_t reg_t; +typedef Elf32_Nhdr Elf_Nhdr; +#endif /* TARGET_PPC64 */ + +struct PPCUserRegStruct { + reg_t gpr[32]; + reg_t nip; + reg_t msr; + reg_t orig_gpr3; + reg_t ctr; + reg_t link; + reg_t xer; + reg_t ccr; + reg_t softe; + reg_t trap; + reg_t dar; + reg_t dsisr; + reg_t result; } QEMU_PACKED; =20 -struct PPC64ElfPrstatus { +struct PPCElfPrstatus { char pad1[112]; - struct PPC64UserRegStruct pr_reg; - uint64_t pad2[4]; + struct PPCUserRegStruct pr_reg; + reg_t pad2[4]; } QEMU_PACKED; =20 =20 -struct PPC64ElfFpregset { +struct PPCElfFpregset { uint64_t fpr[32]; - uint64_t fpscr; + reg_t fpscr; } QEMU_PACKED; =20 =20 -struct PPC64ElfVmxregset { +struct PPCElfVmxregset { ppc_avr_t avr[32]; ppc_avr_t vscr; union { @@ -57,26 +69,26 @@ struct PPC64ElfVmxregset { } vrsave; } QEMU_PACKED; =20 -struct PPC64ElfVsxregset { +struct PPCElfVsxregset { uint64_t vsr[32]; } QEMU_PACKED; =20 -struct PPC64ElfSperegset { +struct PPCElfSperegset { uint32_t evr[32]; uint64_t spe_acc; uint32_t spe_fscr; } QEMU_PACKED; =20 typedef struct noteStruct { - Elf64_Nhdr hdr; + Elf_Nhdr hdr; char name[5]; char pad3[3]; union { - struct PPC64ElfPrstatus prstatus; - struct PPC64ElfFpregset fpregset; - struct PPC64ElfVmxregset vmxregset; - struct PPC64ElfVsxregset vsxregset; - struct PPC64ElfSperegset speregset; + struct PPCElfPrstatus prstatus; + struct PPCElfFpregset fpregset; + struct PPCElfVmxregset vmxregset; + struct PPCElfVsxregset vsxregset; + struct PPCElfSperegset speregset; } contents; } QEMU_PACKED Note; =20 @@ -85,12 +97,12 @@ typedef struct NoteFuncArg { DumpState *state; } NoteFuncArg; =20 -static void ppc64_write_elf64_prstatus(NoteFuncArg *arg, PowerPCCPU *cpu) +static void ppc_write_elf_prstatus(NoteFuncArg *arg, PowerPCCPU *cpu) { int i; - uint64_t cr; - struct PPC64ElfPrstatus *prstatus; - struct PPC64UserRegStruct *reg; + reg_t cr; + struct PPCElfPrstatus *prstatus; + struct PPCUserRegStruct *reg; Note *note =3D &arg->note; DumpState *s =3D arg->state; =20 @@ -101,25 +113,25 @@ static void ppc64_write_elf64_prstatus(NoteFuncArg *a= rg, PowerPCCPU *cpu) reg =3D &prstatus->pr_reg; =20 for (i =3D 0; i < 32; i++) { - reg->gpr[i] =3D cpu_to_dump64(s, cpu->env.gpr[i]); + reg->gpr[i] =3D cpu_to_dump_reg(s, cpu->env.gpr[i]); } - reg->nip =3D cpu_to_dump64(s, cpu->env.nip); - reg->msr =3D cpu_to_dump64(s, cpu->env.msr); - reg->ctr =3D cpu_to_dump64(s, cpu->env.ctr); - reg->link =3D cpu_to_dump64(s, cpu->env.lr); - reg->xer =3D cpu_to_dump64(s, cpu_read_xer(&cpu->env)); + reg->nip =3D cpu_to_dump_reg(s, cpu->env.nip); + reg->msr =3D cpu_to_dump_reg(s, cpu->env.msr); + reg->ctr =3D cpu_to_dump_reg(s, cpu->env.ctr); + reg->link =3D cpu_to_dump_reg(s, cpu->env.lr); + reg->xer =3D cpu_to_dump_reg(s, cpu_read_xer(&cpu->env)); =20 cr =3D 0; for (i =3D 0; i < 8; i++) { cr |=3D (cpu->env.crf[i] & 15) << (4 * (7 - i)); } - reg->ccr =3D cpu_to_dump64(s, cr); + reg->ccr =3D cpu_to_dump_reg(s, cr); } =20 -static void ppc64_write_elf64_fpregset(NoteFuncArg *arg, PowerPCCPU *cpu) +static void ppc_write_elf_fpregset(NoteFuncArg *arg, PowerPCCPU *cpu) { int i; - struct PPC64ElfFpregset *fpregset; + struct PPCElfFpregset *fpregset; Note *note =3D &arg->note; DumpState *s =3D arg->state; =20 @@ -131,13 +143,13 @@ static void ppc64_write_elf64_fpregset(NoteFuncArg *a= rg, PowerPCCPU *cpu) for (i =3D 0; i < 32; i++) { fpregset->fpr[i] =3D cpu_to_dump64(s, cpu->env.fpr[i]); } - fpregset->fpscr =3D cpu_to_dump64(s, cpu->env.fpscr); + fpregset->fpscr =3D cpu_to_dump_reg(s, cpu->env.fpscr); } =20 -static void ppc64_write_elf64_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu) +static void ppc_write_elf_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu) { int i; - struct PPC64ElfVmxregset *vmxregset; + struct PPCElfVmxregset *vmxregset; Note *note =3D &arg->note; DumpState *s =3D arg->state; =20 @@ -164,10 +176,11 @@ static void ppc64_write_elf64_vmxregset(NoteFuncArg *= arg, PowerPCCPU *cpu) } vmxregset->vscr.u32[3] =3D cpu_to_dump32(s, cpu->env.vscr); } -static void ppc64_write_elf64_vsxregset(NoteFuncArg *arg, PowerPCCPU *cpu) + +static void ppc_write_elf_vsxregset(NoteFuncArg *arg, PowerPCCPU *cpu) { int i; - struct PPC64ElfVsxregset *vsxregset; + struct PPCElfVsxregset *vsxregset; Note *note =3D &arg->note; DumpState *s =3D arg->state; =20 @@ -179,9 +192,10 @@ static void ppc64_write_elf64_vsxregset(NoteFuncArg *a= rg, PowerPCCPU *cpu) vsxregset->vsr[i] =3D cpu_to_dump64(s, cpu->env.vsr[i]); } } -static void ppc64_write_elf64_speregset(NoteFuncArg *arg, PowerPCCPU *cpu) + +static void ppc_write_elf_speregset(NoteFuncArg *arg, PowerPCCPU *cpu) { - struct PPC64ElfSperegset *speregset; + struct PPCElfSperegset *speregset; Note *note =3D &arg->note; DumpState *s =3D arg->state; =20 @@ -197,11 +211,11 @@ static const struct NoteFuncDescStruct { int contents_size; void (*note_contents_func)(NoteFuncArg *arg, PowerPCCPU *cpu); } note_func[] =3D { - {sizeof(((Note *)0)->contents.prstatus), ppc64_write_elf64_prstatus}, - {sizeof(((Note *)0)->contents.fpregset), ppc64_write_elf64_fpregset}, - {sizeof(((Note *)0)->contents.vmxregset), ppc64_write_elf64_vmxregset}, - {sizeof(((Note *)0)->contents.vsxregset), ppc64_write_elf64_vsxregset}, - {sizeof(((Note *)0)->contents.speregset), ppc64_write_elf64_speregset}, + {sizeof(((Note *)0)->contents.prstatus), ppc_write_elf_prstatus}, + {sizeof(((Note *)0)->contents.fpregset), ppc_write_elf_fpregset}, + {sizeof(((Note *)0)->contents.vmxregset), ppc_write_elf_vmxregset}, + {sizeof(((Note *)0)->contents.vsxregset), ppc_write_elf_vsxregset}, + {sizeof(((Note *)0)->contents.speregset), ppc_write_elf_speregset}, { 0, NULL} }; =20 @@ -213,8 +227,9 @@ int cpu_get_dump_info(ArchDumpInfo *info, PowerPCCPU *cpu =3D POWERPC_CPU(first_cpu); PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 - info->d_machine =3D EM_PPC64; - info->d_class =3D ELFCLASS64; + info->d_machine =3D PPC_ELF_MACHINE; + info->d_class =3D ELFCLASS; + if ((*pcc->interrupts_big_endian)(cpu)) { info->d_endian =3D ELFDATA2MSB; } else { @@ -236,25 +251,19 @@ ssize_t cpu_get_note_size(int class, int machine, int= nr_cpus) int note_head_size; const NoteFuncDesc *nf; =20 - if (class !=3D ELFCLASS64) { - return -1; - } - assert(machine =3D=3D EM_PPC64); - - note_head_size =3D sizeof(Elf64_Nhdr); - + note_head_size =3D sizeof(Elf_Nhdr); for (nf =3D note_func; nf->note_contents_func; nf++) { elf_note_size =3D elf_note_size + note_head_size + name_size + - nf->contents_size; + nf->contents_size; } =20 return (elf_note_size) * nr_cpus; } =20 -static int ppc64_write_all_elf64_notes(const char *note_name, - WriteCoreDumpFunction f, - PowerPCCPU *cpu, int id, - void *opaque) +static int ppc_write_all_elf_notes(const char *note_name, + WriteCoreDumpFunction f, + PowerPCCPU *cpu, int id, + void *opaque) { NoteFuncArg arg =3D { .state =3D opaque }; int ret =3D -1; @@ -282,5 +291,12 @@ int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f= , CPUState *cs, int cpuid, void *opaque) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); - return ppc64_write_all_elf64_notes("CORE", f, cpu, cpuid, opaque); + return ppc_write_all_elf_notes("CORE", f, cpu, cpuid, opaque); +} + +int ppc32_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, + int cpuid, void *opaque) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + return ppc_write_all_elf_notes("CORE", f, cpu, cpuid, opaque); } diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 425e79d52d..d8a91dfd98 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1243,6 +1243,8 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t= *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque); +int ppc32_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, + int cpuid, void *opaque); #ifndef CONFIG_USER_ONLY void ppc_cpu_do_system_reset(CPUState *cs); extern const struct VMStateDescription vmstate_ppc_cpu; diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index be35cbd3a2..4cceab09bd 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10489,11 +10489,12 @@ static void ppc_cpu_class_init(ObjectClass *oc, v= oid *data) #else cc->get_phys_page_debug =3D ppc_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_ppc_cpu; -#if defined(TARGET_PPC64) - cc->write_elf64_note =3D ppc64_cpu_write_elf64_note; -#endif #endif cc->cpu_exec_enter =3D ppc_cpu_exec_enter; +#if defined(CONFIG_SOFTMMU) + cc->write_elf64_note =3D ppc64_cpu_write_elf64_note; + cc->write_elf32_note =3D ppc32_cpu_write_elf32_note; +#endif =20 cc->gdb_num_core_regs =3D 71; =20 --=20 2.11.0