2013-10-02 00:19:33 +08:00
|
|
|
/*
|
2017-02-28 21:32:17 +08:00
|
|
|
* writing ELF notes for ppc{64,} arch
|
2013-10-02 00:19:33 +08:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2013
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-27 02:16:58 +08:00
|
|
|
#include "qemu/osdep.h"
|
2013-10-02 00:19:33 +08:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "elf.h"
|
|
|
|
#include "sysemu/dump.h"
|
|
|
|
#include "sysemu/kvm.h"
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
#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;
|
2013-10-02 00:19:33 +08:00
|
|
|
} QEMU_PACKED;
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfPrstatus {
|
2013-10-02 00:19:33 +08:00
|
|
|
char pad1[112];
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCUserRegStruct pr_reg;
|
2017-04-11 14:04:56 +08:00
|
|
|
char pad2[40];
|
2013-10-02 00:19:33 +08:00
|
|
|
} QEMU_PACKED;
|
|
|
|
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfFpregset {
|
2013-10-02 00:19:33 +08:00
|
|
|
uint64_t fpr[32];
|
2017-02-28 21:32:17 +08:00
|
|
|
reg_t fpscr;
|
2013-10-02 00:19:33 +08:00
|
|
|
} QEMU_PACKED;
|
|
|
|
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfVmxregset {
|
2013-10-02 00:19:33 +08:00
|
|
|
ppc_avr_t avr[32];
|
|
|
|
ppc_avr_t vscr;
|
|
|
|
union {
|
|
|
|
ppc_avr_t unused;
|
|
|
|
uint32_t value;
|
|
|
|
} vrsave;
|
|
|
|
} QEMU_PACKED;
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfVsxregset {
|
2013-10-02 00:19:33 +08:00
|
|
|
uint64_t vsr[32];
|
|
|
|
} QEMU_PACKED;
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfSperegset {
|
2013-10-02 00:19:33 +08:00
|
|
|
uint32_t evr[32];
|
|
|
|
uint64_t spe_acc;
|
|
|
|
uint32_t spe_fscr;
|
|
|
|
} QEMU_PACKED;
|
|
|
|
|
|
|
|
typedef struct noteStruct {
|
2017-02-28 21:32:17 +08:00
|
|
|
Elf_Nhdr hdr;
|
2013-10-02 00:19:33 +08:00
|
|
|
char name[5];
|
|
|
|
char pad3[3];
|
|
|
|
union {
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfPrstatus prstatus;
|
|
|
|
struct PPCElfFpregset fpregset;
|
|
|
|
struct PPCElfVmxregset vmxregset;
|
|
|
|
struct PPCElfVsxregset vsxregset;
|
|
|
|
struct PPCElfSperegset speregset;
|
2013-10-02 00:19:33 +08:00
|
|
|
} contents;
|
|
|
|
} QEMU_PACKED Note;
|
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
typedef struct NoteFuncArg {
|
|
|
|
Note note;
|
|
|
|
DumpState *state;
|
|
|
|
} NoteFuncArg;
|
2013-10-02 00:19:33 +08:00
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
static void ppc_write_elf_prstatus(NoteFuncArg *arg, PowerPCCPU *cpu)
|
2013-10-02 00:19:33 +08:00
|
|
|
{
|
|
|
|
int i;
|
2017-02-28 21:32:17 +08:00
|
|
|
reg_t cr;
|
|
|
|
struct PPCElfPrstatus *prstatus;
|
|
|
|
struct PPCUserRegStruct *reg;
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
Note *note = &arg->note;
|
|
|
|
DumpState *s = arg->state;
|
2013-10-02 00:19:33 +08:00
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
note->hdr.n_type = cpu_to_dump32(s, NT_PRSTATUS);
|
2013-10-02 00:19:33 +08:00
|
|
|
|
|
|
|
prstatus = ¬e->contents.prstatus;
|
|
|
|
memset(prstatus, 0, sizeof(*prstatus));
|
|
|
|
reg = &prstatus->pr_reg;
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
2017-02-28 21:32:17 +08:00
|
|
|
reg->gpr[i] = cpu_to_dump_reg(s, cpu->env.gpr[i]);
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
2017-02-28 21:32:17 +08:00
|
|
|
reg->nip = cpu_to_dump_reg(s, cpu->env.nip);
|
|
|
|
reg->msr = cpu_to_dump_reg(s, cpu->env.msr);
|
|
|
|
reg->ctr = cpu_to_dump_reg(s, cpu->env.ctr);
|
|
|
|
reg->link = cpu_to_dump_reg(s, cpu->env.lr);
|
|
|
|
reg->xer = cpu_to_dump_reg(s, cpu_read_xer(&cpu->env));
|
2013-10-02 00:19:33 +08:00
|
|
|
|
|
|
|
cr = 0;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
cr |= (cpu->env.crf[i] & 15) << (4 * (7 - i));
|
|
|
|
}
|
2017-02-28 21:32:17 +08:00
|
|
|
reg->ccr = cpu_to_dump_reg(s, cr);
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
static void ppc_write_elf_fpregset(NoteFuncArg *arg, PowerPCCPU *cpu)
|
2013-10-02 00:19:33 +08:00
|
|
|
{
|
|
|
|
int i;
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfFpregset *fpregset;
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
Note *note = &arg->note;
|
|
|
|
DumpState *s = arg->state;
|
2013-10-02 00:19:33 +08:00
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
note->hdr.n_type = cpu_to_dump32(s, NT_PRFPREG);
|
2013-10-02 00:19:33 +08:00
|
|
|
|
|
|
|
fpregset = ¬e->contents.fpregset;
|
|
|
|
memset(fpregset, 0, sizeof(*fpregset));
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
2019-01-02 17:14:22 +08:00
|
|
|
uint64_t *fpr = cpu_fpr_ptr(&cpu->env, i);
|
|
|
|
fpregset->fpr[i] = cpu_to_dump64(s, *fpr);
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
2017-02-28 21:32:17 +08:00
|
|
|
fpregset->fpscr = cpu_to_dump_reg(s, cpu->env.fpscr);
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
static void ppc_write_elf_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu)
|
2013-10-02 00:19:33 +08:00
|
|
|
{
|
|
|
|
int i;
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfVmxregset *vmxregset;
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
Note *note = &arg->note;
|
|
|
|
DumpState *s = arg->state;
|
2013-10-02 00:19:33 +08:00
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
note->hdr.n_type = cpu_to_dump32(s, NT_PPC_VMX);
|
2013-10-02 00:19:33 +08:00
|
|
|
vmxregset = ¬e->contents.vmxregset;
|
|
|
|
memset(vmxregset, 0, sizeof(*vmxregset));
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
bool needs_byteswap;
|
2019-01-02 17:14:22 +08:00
|
|
|
ppc_avr_t *avr = cpu_avr_ptr(&cpu->env, i);
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
|
|
|
|
#ifdef HOST_WORDS_BIGENDIAN
|
|
|
|
needs_byteswap = s->dump_info.d_endian == ELFDATA2LSB;
|
|
|
|
#else
|
|
|
|
needs_byteswap = s->dump_info.d_endian == ELFDATA2MSB;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (needs_byteswap) {
|
2019-01-02 17:14:22 +08:00
|
|
|
vmxregset->avr[i].u64[0] = bswap64(avr->u64[1]);
|
|
|
|
vmxregset->avr[i].u64[1] = bswap64(avr->u64[0]);
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
} else {
|
2019-01-02 17:14:22 +08:00
|
|
|
vmxregset->avr[i].u64[0] = avr->u64[0];
|
|
|
|
vmxregset->avr[i].u64[1] = avr->u64[1];
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
}
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
2021-05-12 22:08:03 +08:00
|
|
|
vmxregset->vscr.u32[3] = cpu_to_dump32(s, ppc_get_vscr(&cpu->env));
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
2017-02-28 21:32:17 +08:00
|
|
|
|
|
|
|
static void ppc_write_elf_vsxregset(NoteFuncArg *arg, PowerPCCPU *cpu)
|
2013-10-02 00:19:33 +08:00
|
|
|
{
|
|
|
|
int i;
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfVsxregset *vsxregset;
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
Note *note = &arg->note;
|
|
|
|
DumpState *s = arg->state;
|
2013-10-02 00:19:33 +08:00
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
note->hdr.n_type = cpu_to_dump32(s, NT_PPC_VSX);
|
2013-10-02 00:19:33 +08:00
|
|
|
vsxregset = ¬e->contents.vsxregset;
|
|
|
|
memset(vsxregset, 0, sizeof(*vsxregset));
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
2019-01-02 17:14:22 +08:00
|
|
|
uint64_t *vsrl = cpu_vsrl_ptr(&cpu->env, i);
|
|
|
|
vsxregset->vsr[i] = cpu_to_dump64(s, *vsrl);
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
|
|
|
}
|
2017-02-28 21:32:17 +08:00
|
|
|
|
|
|
|
static void ppc_write_elf_speregset(NoteFuncArg *arg, PowerPCCPU *cpu)
|
2013-10-02 00:19:33 +08:00
|
|
|
{
|
2017-02-28 21:32:17 +08:00
|
|
|
struct PPCElfSperegset *speregset;
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
Note *note = &arg->note;
|
|
|
|
DumpState *s = arg->state;
|
|
|
|
|
|
|
|
note->hdr.n_type = cpu_to_dump32(s, NT_PPC_SPE);
|
2013-10-02 00:19:33 +08:00
|
|
|
speregset = ¬e->contents.speregset;
|
|
|
|
memset(speregset, 0, sizeof(*speregset));
|
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
speregset->spe_acc = cpu_to_dump64(s, cpu->env.spe_acc);
|
|
|
|
speregset->spe_fscr = cpu_to_dump32(s, cpu->env.spe_fscr);
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
|
|
|
|
2014-03-16 21:49:54 +08:00
|
|
|
static const struct NoteFuncDescStruct {
|
2013-10-02 00:19:33 +08:00
|
|
|
int contents_size;
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
void (*note_contents_func)(NoteFuncArg *arg, PowerPCCPU *cpu);
|
2013-10-02 00:19:33 +08:00
|
|
|
} note_func[] = {
|
2018-06-15 00:44:31 +08:00
|
|
|
{sizeof_field(Note, contents.prstatus), ppc_write_elf_prstatus},
|
|
|
|
{sizeof_field(Note, contents.fpregset), ppc_write_elf_fpregset},
|
|
|
|
{sizeof_field(Note, contents.vmxregset), ppc_write_elf_vmxregset},
|
|
|
|
{sizeof_field(Note, contents.vsxregset), ppc_write_elf_vsxregset},
|
|
|
|
{sizeof_field(Note, contents.speregset), ppc_write_elf_speregset},
|
2013-10-02 00:19:33 +08:00
|
|
|
{ 0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct NoteFuncDescStruct NoteFuncDesc;
|
|
|
|
|
|
|
|
int cpu_get_dump_info(ArchDumpInfo *info,
|
|
|
|
const struct GuestPhysBlockList *guest_phys_blocks)
|
|
|
|
{
|
2017-09-13 22:20:33 +08:00
|
|
|
PowerPCCPU *cpu;
|
|
|
|
PowerPCCPUClass *pcc;
|
|
|
|
|
|
|
|
if (first_cpu == NULL) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpu = POWERPC_CPU(first_cpu);
|
|
|
|
pcc = POWERPC_CPU_GET_CLASS(cpu);
|
2014-05-20 01:59:22 +08:00
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
info->d_machine = PPC_ELF_MACHINE;
|
|
|
|
info->d_class = ELFCLASS;
|
|
|
|
|
2014-05-20 01:59:22 +08:00
|
|
|
if ((*pcc->interrupts_big_endian)(cpu)) {
|
|
|
|
info->d_endian = ELFDATA2MSB;
|
|
|
|
} else {
|
|
|
|
info->d_endian = ELFDATA2LSB;
|
|
|
|
}
|
2016-08-08 21:08:53 +08:00
|
|
|
/* 64KB is the max page size for pseries kernel */
|
|
|
|
if (strncmp(object_get_typename(qdev_get_machine()),
|
|
|
|
"pseries-", 8) == 0) {
|
|
|
|
info->page_size = (1U << 16);
|
|
|
|
}
|
2013-10-02 00:19:33 +08:00
|
|
|
|
|
|
|
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;
|
2014-03-16 21:49:54 +08:00
|
|
|
const NoteFuncDesc *nf;
|
2013-10-02 00:19:33 +08:00
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
note_head_size = sizeof(Elf_Nhdr);
|
2013-10-02 00:19:33 +08:00
|
|
|
for (nf = note_func; nf->note_contents_func; nf++) {
|
|
|
|
elf_note_size = elf_note_size + note_head_size + name_size +
|
2017-02-28 21:32:17 +08:00
|
|
|
nf->contents_size;
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (elf_note_size) * nr_cpus;
|
|
|
|
}
|
|
|
|
|
2017-02-28 21:32:17 +08:00
|
|
|
static int ppc_write_all_elf_notes(const char *note_name,
|
|
|
|
WriteCoreDumpFunction f,
|
|
|
|
PowerPCCPU *cpu, int id,
|
|
|
|
void *opaque)
|
2013-10-02 00:19:33 +08:00
|
|
|
{
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
NoteFuncArg arg = { .state = opaque };
|
2013-10-02 00:19:33 +08:00
|
|
|
int ret = -1;
|
|
|
|
int note_size;
|
2014-03-16 21:49:54 +08:00
|
|
|
const NoteFuncDesc *nf;
|
2013-10-02 00:19:33 +08:00
|
|
|
|
|
|
|
for (nf = note_func; nf->note_contents_func; nf++) {
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
arg.note.hdr.n_namesz = cpu_to_dump32(opaque, sizeof(arg.note.name));
|
|
|
|
arg.note.hdr.n_descsz = cpu_to_dump32(opaque, nf->contents_size);
|
|
|
|
strncpy(arg.note.name, note_name, sizeof(arg.note.name));
|
2013-10-02 00:19:33 +08:00
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
(*nf->note_contents_func)(&arg, cpu);
|
2013-10-02 00:19:33 +08:00
|
|
|
|
target-ppc: Support dump for little endian ppc64
Fix ppc64 arch specific dump code to support all combinations of little/big
endian hosts/guests. FWIW the current code is broken for altivec registers
when guest and host have a different endianness: these 128-bit registers
are written to guest memory as a two 64-bit entities and we should also swap
them.
Unit testing was done with the following program provided by Tom Musta:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
__uint128_t v = ((__uint128_t)0x0001020304050607ull << 64) |
0x08090a0b0c0d0e0full;
register void * vptr asm ("r11");
vptr = &v;
for(;;)
asm volatile ("lvx 30,0,11" );
}
When sending SIGABRT to this program and examining the core file, we get:
- ppc64 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64le: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
We expect to find the very same layout in the QEMU dump since they are
real core files. This is what we get:
- ppc64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- ppc64 host, ppc64le guest : 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
- x86_64 host, ppc64 guest : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
- x86_64 host, ppc64le guest: 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
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,
fix altivec support,
Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-05-20 01:58:35 +08:00
|
|
|
note_size =
|
|
|
|
sizeof(arg.note) - sizeof(arg.note.contents) + nf->contents_size;
|
|
|
|
ret = f(&arg.note, note_size, opaque);
|
2013-10-02 00:19:33 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
|
|
|
|
int cpuid, void *opaque)
|
|
|
|
{
|
|
|
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
2017-02-28 21:32:17 +08:00
|
|
|
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 = POWERPC_CPU(cs);
|
|
|
|
return ppc_write_all_elf_notes("CORE", f, cpu, cpuid, opaque);
|
2013-10-02 00:19:33 +08:00
|
|
|
}
|