From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whx5y-0002pW-52 for qemu-devel@nongnu.org; Wed, 07 May 2014 04:21:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Whx5p-0000eN-8F for qemu-devel@nongnu.org; Wed, 07 May 2014 04:20:54 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:46694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whx5o-0000di-W1 for qemu-devel@nongnu.org; Wed, 07 May 2014 04:20:45 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 May 2014 09:20:44 +0100 Date: Wed, 7 May 2014 10:20:37 +0200 From: Greg Kurz Message-ID: <20140507102037.72d76d56@bahia.local> In-Reply-To: <53677043.5000606@suse.de> References: <20140505074816.25523.71374.stgit@bahia.local> <20140505080438.25523.94922.stgit@bahia.local> <53677043.5000606@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 2/4] ppc64-dump: Support dump for little endian ppc64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Tom Musta , peter.maydell@linaro.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, afaerber@suse.de On Mon, 05 May 2014 13:04:35 +0200 Alexander Graf wrote: > On 05/05/2014 10:05 AM, Greg Kurz wrote: > > From: Bharata B Rao > > > > Fix ppc64 arch specific dump code to work correctly for little endian > > guests. > > > > We introduce a NoteFuncArg type to avoid adding extra arguments to all note > > functions. > > > > Signed-off-by: Bharata B Rao > > [ rebased on top of current master branch, > > introduced NoteFuncArg, > > use new cpu_to_dump{16,32,64} endian helpers, > > Greg Kurz ] > > Reviewed-by: Alexander Graf > > Signed-off-by: Greg Kurz > > --- > > > > Changes in v3: > > - better taste with the endian helpers naming > > > > target-ppc/arch_dump.c | 82 +++++++++++++++++++++++++++++------------------- > > 1 file changed, 49 insertions(+), 33 deletions(-) > > > > diff --git a/target-ppc/arch_dump.c b/target-ppc/arch_dump.c > > index 9dccf1a..5487b61 100644 > > --- a/target-ppc/arch_dump.c > > +++ b/target-ppc/arch_dump.c > > @@ -79,94 +79,109 @@ typedef struct noteStruct { > > } contents; > > } QEMU_PACKED Note; > > > > +typedef struct NoteFuncArg { > > + Note note; > > + DumpState *state; > > +} NoteFuncArg; > > > > -static void ppc64_write_elf64_prstatus(Note *note, PowerPCCPU *cpu) > > +static void ppc64_write_elf64_prstatus(NoteFuncArg *arg, PowerPCCPU *cpu) > > { > > int i; > > uint64_t cr; > > struct PPC64ElfPrstatus *prstatus; > > struct PPC64UserRegStruct *reg; > > + Note *note = &arg->note; > > + DumpState *s = arg->state; > > > > - note->hdr.n_type = cpu_to_be32(NT_PRSTATUS); > > + note->hdr.n_type = cpu_to_dump32(s, NT_PRSTATUS); > > > > prstatus = ¬e->contents.prstatus; > > memset(prstatus, 0, sizeof(*prstatus)); > > reg = &prstatus->pr_reg; > > > > for (i = 0; i < 32; i++) { > > - reg->gpr[i] = cpu_to_be64(cpu->env.gpr[i]); > > + reg->gpr[i] = cpu_to_dump64(s, cpu->env.gpr[i]); > > } > > - reg->nip = cpu_to_be64(cpu->env.nip); > > - reg->msr = cpu_to_be64(cpu->env.msr); > > - reg->ctr = cpu_to_be64(cpu->env.ctr); > > - reg->link = cpu_to_be64(cpu->env.lr); > > - reg->xer = cpu_to_be64(cpu_read_xer(&cpu->env)); > > + reg->nip = cpu_to_dump64(s, cpu->env.nip); > > + reg->msr = cpu_to_dump64(s, cpu->env.msr); > > + reg->ctr = cpu_to_dump64(s, cpu->env.ctr); > > + reg->link = cpu_to_dump64(s, cpu->env.lr); > > + reg->xer = cpu_to_dump64(s, cpu_read_xer(&cpu->env)); > > > > cr = 0; > > for (i = 0; i < 8; i++) { > > cr |= (cpu->env.crf[i] & 15) << (4 * (7 - i)); > > } > > - reg->ccr = cpu_to_be64(cr); > > + reg->ccr = cpu_to_dump64(s, cr); > > } > > > > -static void ppc64_write_elf64_fpregset(Note *note, PowerPCCPU *cpu) > > +static void ppc64_write_elf64_fpregset(NoteFuncArg *arg, PowerPCCPU *cpu) > > { > > int i; > > struct PPC64ElfFpregset *fpregset; > > + Note *note = &arg->note; > > + DumpState *s = arg->state; > > > > - note->hdr.n_type = cpu_to_be32(NT_PRFPREG); > > + note->hdr.n_type = cpu_to_dump32(s, NT_PRFPREG); > > > > fpregset = ¬e->contents.fpregset; > > memset(fpregset, 0, sizeof(*fpregset)); > > > > for (i = 0; i < 32; i++) { > > - fpregset->fpr[i] = cpu_to_be64(cpu->env.fpr[i]); > > + fpregset->fpr[i] = cpu_to_dump64(s, cpu->env.fpr[i]); > > } > > - fpregset->fpscr = cpu_to_be64(cpu->env.fpscr); > > + fpregset->fpscr = cpu_to_dump64(s, cpu->env.fpscr); > > } > > > > -static void ppc64_write_elf64_vmxregset(Note *note, PowerPCCPU *cpu) > > +static void ppc64_write_elf64_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu) > > { > > int i; > > struct PPC64ElfVmxregset *vmxregset; > > + Note *note = &arg->note; > > + DumpState *s = arg->state; > > > > - note->hdr.n_type = cpu_to_be32(NT_PPC_VMX); > > + note->hdr.n_type = cpu_to_dump32(s, NT_PPC_VMX); > > vmxregset = ¬e->contents.vmxregset; > > memset(vmxregset, 0, sizeof(*vmxregset)); > > > > for (i = 0; i < 32; i++) { > > - vmxregset->avr[i].u64[0] = cpu_to_be64(cpu->env.avr[i].u64[0]); > > - vmxregset->avr[i].u64[1] = cpu_to_be64(cpu->env.avr[i].u64[1]); > > + vmxregset->avr[i].u64[0] = cpu_to_dump64(s, cpu->env.avr[i].u64[0]); > > + vmxregset->avr[i].u64[1] = cpu_to_dump64(s, cpu->env.avr[i].u64[1]); > > Is this correct? Tom, could you please ack if it is? > > > Alex > > Tom, Can you comment plz ? Thanks. -- Gregory Kurz kurzgreg@fr.ibm.com gkurz@linux.vnet.ibm.com Software Engineer @ IBM/Meiosys http://www.ibm.com Tel +33 (0)562 165 496 "Anarchy is about taking complete responsibility for yourself." Alan Moore.