qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: Tom Musta <tommusta@gmail.com>,
	peter.maydell@linaro.org, qemu-devel@nongnu.org,
	qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com,
	afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v3 2/4] ppc64-dump: Support dump for little endian ppc64
Date: Mon, 05 May 2014 13:04:35 +0200	[thread overview]
Message-ID: <53677043.5000606@suse.de> (raw)
In-Reply-To: <20140505080438.25523.94922.stgit@bahia.local>

On 05/05/2014 10:05 AM, Greg Kurz wrote:
> From: Bharata B Rao <bharata@linux.vnet.ibm.com>
>
> 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 <bharata@linux.vnet.ibm.com>
> [ rebased on top of current master branch,
>    introduced NoteFuncArg,
>    use new cpu_to_dump{16,32,64} endian helpers,
>    Greg Kurz <gkurz@linux.vnet.ibm.com> ]
> Reviewed-by: Alexander Graf <agraf@suse.de>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
>
> 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 = &note->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 = &note->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 = &note->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

  reply	other threads:[~2014-05-05 11:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-05  8:02 [Qemu-devel] [PATCH v3 0/4] little-endian dump for ppc64 Greg Kurz
2014-05-05  8:04 ` [Qemu-devel] [PATCH v3 1/4] dump: Make DumpState and endian conversion routines available for arch-specific dump code Greg Kurz
2014-05-05  8:05 ` [Qemu-devel] [PATCH v3 2/4] ppc64-dump: Support dump for little endian ppc64 Greg Kurz
2014-05-05 11:04   ` Alexander Graf [this message]
2014-05-07  8:20     ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2014-05-07 19:02       ` Tom Musta
2014-05-07 20:54         ` Tom Musta
2014-05-07 20:59           ` Alexander Graf
2014-05-08  7:49           ` Greg Kurz
2014-05-05  8:07 ` [Qemu-devel] [PATCH v3 3/4] target-ppc: ppc can be either endian Greg Kurz
2014-05-06 18:37   ` Peter Maydell
2014-05-07  8:14     ` Greg Kurz
2014-05-07  9:06       ` Peter Maydell
2014-05-07  9:09       ` Alexander Graf
2014-05-07  9:26         ` Peter Maydell
2014-05-07  9:37           ` Alexander Graf
2014-05-07  9:40             ` Peter Maydell
2014-05-07  9:44               ` Alexander Graf
2014-05-07  9:41           ` Alexander Graf
2014-05-07 10:19             ` Greg Kurz
2014-05-07 11:54               ` Alexander Graf
2014-05-07 12:40                 ` Greg Kurz
2014-05-07 13:04                   ` Alexander Graf
2014-05-08  1:36                 ` Rusty Russell
2014-05-05  8:07 ` [Qemu-devel] [PATCH v2 4/4] ppc64 dump: Set the correct endianness in ELF dump header Greg Kurz
2014-05-05 11:08 ` [Qemu-devel] [PATCH v3 0/4] little-endian dump for ppc64 Alexander Graf
2014-05-07 21:14 ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53677043.5000606@suse.de \
    --to=agraf@suse.de \
    --cc=afaerber@suse.de \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=tommusta@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).