PPC64 Improvements
v3 cover PPC64 Improvements
v3:
- sent v2 in March and applied the review but, for some reason, this patchset has never been sent.
- dropped ARCH parameter from makefile
- renamed *ppc64le.* to *ppc64.*
v2:
- applied code review
This patchset include initial support to PPC64 (Big-Endian), that is pretty much the same: only some fixes in configure and risugen.
Also, it adds a better random initialization of VSX registers.
Jose Ricardo Ziviani (4):
risugen_ppc64: Load random 128-bit data to vector registers
configure: Add initial support to PPC64 (big endian) risugen,risugen_ppc64.pm: Add support ppc64 (big-endian)
build: Add support to PowerPC BE and remove ARCH
build-all-archs | 2 +- configure | 14 +--- risu_ppc64.c | 40 ++++++++++ risu_ppc64le.c | 40 ---------- risu_reginfo_ppc64.c | 193 +++++++++++++++++++++++++++++++++++++++++++++++++ risu_reginfo_ppc64.h | 28 +++++++ risu_reginfo_ppc64le.c | 193 ------------------------------------------------- risu_reginfo_ppc64le.h | 28 ------- risugen | 6 +- risugen_ppc64.pm | 46 +++++++++--- test_ppc64.s | 49 +++++++++++++ test_ppc64le.s | 49 ------------- 12 files changed, 353 insertions(+), 335 deletions(-) create mode 100644 risu_ppc64.c delete mode 100644 risu_ppc64le.c create mode 100644 risu_reginfo_ppc64.c create mode 100644 risu_reginfo_ppc64.h delete mode 100644 risu_reginfo_ppc64le.c delete mode 100644 risu_reginfo_ppc64le.h create mode 100644 test_ppc64.s delete mode 100644 test_ppc64le.s
Signature · 1 line
2.7.4
PATCH v3 1/4 risugen_ppc64: Load random 128-bit data to vector registers
--- risugen_ppc64.pm | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-)
risugen_ppc64.pm +31 -11
@@ -99,6 +99,29 @@ sub write_mov_ri64($$) insn32((0x3e << 26) | (20 << 21) | (1 << 16) | 0x10); } +sub write_mov_ri128($$$$) +{ + my ($imhh, $imh, $iml, $imll) = @_; + + # store the lowest 32 bits + write_mov_ri32(20, $imll); + # stw r20, 16(r1) + insn32((0x24 << 26) | (20 << 21) | (1 << 16) | 0x10); + # store the lower 32 bits + write_mov_ri32(20, $iml); + # stw r20, 20(r1) + insn32((0x24 << 26) | (20 << 21) | (1 << 16) | 0x14); + # store the higher 32 bits + write_mov_ri32(20, $imh); + # stw r20, 24(r1) + insn32((0x24 << 26) | (20 << 21) | (1 << 16) | 0x18); + # store the highest 32 bits + write_mov_ri32(20, $imhh); + # stw r20, 28(r1) + insn32((0x24 << 26) | (20 << 21) | (1 << 16) | 0x1c); + +} + sub write_random_ppc64_fpdata() { for (my $i = 0; $i < 32; $i++) {
@@ -106,22 +129,18 @@ sub write_random_ppc64_fpdata() write_mov_ri64(rand(0xfffff), rand(0xfffff)); # since the EA is r1+16, load such value in FP reg insn32((0x32 << 26) | ($i << 21) | (0x1 << 16) | 0x10); - insn32((0x39 << 26) | ($i << 21) | (0x1 << 16) | 0x12); - } } -sub write_random_ppc64_fpdata_i() +sub write_random_ppc64_vrdata() { - # get an space from the stack - insn32(0x3ac10020); # addi r22, r1, 32 - insn32(0x3ee03ff0); # lis r23, 0x3ff0 - insn32(0x3af70000); # addi r23, r23, 0 - insn32(0xfaf60000); # std r23, 0(r22) - for (my $i = 0; $i < 32; $i++) { - # lfd f$i, 0(r22) - insn32((0x32 << 26 | $i << 21 | 0x16 << 16)); + # load a random doubleword value at r0 + write_mov_ri128(rand(0xffff), rand(0xffff), rand(0xfffff), rand(0xfffff)); + # li r0, 16 + write_mov_ri16(0, 0x10); + # lvx vr$i, r1, r0 + insn32((0x1f << 26) | ($i << 21) | (0x1 << 16) | 0x2ce); } }
@@ -172,6 +191,7 @@ sub write_random_register_data($) clear_vr_registers(); + write_random_ppc64_vrdata(); if ($fp_enabled) { # load floating point / SIMD registers write_random_ppc64_fpdata();
Signature · 1 line
2.7.4
PATCH v3 2/4 configure: Add initial support to PPC64 (big endian)
In reply to Jose Ricardo ZivianiUses the same ppc64 source file for both BE/LE archs since they are essentially the same thing.
--- configure | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
configure +4 -5
@@ -51,11 +51,7 @@ guess_arch() { elif check_define __aarch64__ ; then ARCH="aarch64" elif check_define __powerpc64__ ; then - if check_define __BIG_ENDIAN__; then - ARCH="ppc64" - else - ARCH="ppc64le" - fi + ARCH="ppc64le" else echo "This cpu is not supported by risu. Try -h. " >&2 exit 1
@@ -127,6 +123,9 @@ OBJDUMP="${OBJDUMP-${CROSS_PREFIX}objdump}" if test "x${ARCH}" = "x"; then guess_arch +elif test "x${ARCH}" = "xppc64"; then + # ppc64 and ppc64le uses the same C source code + ARCH="ppc64le" fi generate_makefilein
Signature · 1 line
2.7.4
PATCH v3 3/4 risugen, risugen_ppc64.pm: Add support ppc64 (big-endian)
In reply to Jose Ricardo ZivianiThis commit adds an option to risugen in order to give the opportunity to generated big-endian instructions. By passing --be, users force risugen to generated big-endian instructions for ppc64.
./risugen --be --numinsns 1000 --pattern "ADD" ppc64.risu test.bin ./risugen --numinsns 1000 --pattern "ADD" ppc64.risu test.bin
--- risugen | 6 +++++- risugen_ppc64.pm | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-)
risugen +5 -1
@@ -264,6 +264,7 @@ Valid options: a general set you have excluded. --no-fp : disable floating point: no fp init, randomization etc. Useful to test before support for FP is available. + --be : generate instructions in Big-Endian byte order (ppc64 only). --help : print this message EOT }
@@ -274,6 +275,7 @@ sub main() my $condprob = 0; my $fpscr = 0; my $fp_enabled = 1; + my $big_endian = 0; my ($infile, $outfile); GetOptions( "help" => sub { usage(); exit(0); },
@@ -287,6 +289,7 @@ sub main() die "Value \"$condprob\" invalid for option condprob (must be between 0 and 1)\n"; } }, + "be" => sub { $big_endian = 1; }, "no-fp" => sub { $fp_enabled = 0; }, ) or return 1; # allow "--pattern re,re" and "--pattern re --pattern re"
@@ -317,7 +320,8 @@ sub main() 'not_pattern_re' => \@not_pattern_re, 'details' => \%insn_details, 'arch' => $full_arch[0], - 'subarch' => $full_arch[1] || '' + 'subarch' => $full_arch[1] || '', + 'bigendian' => $big_endian ); write_test_code(\%params);
risugen_ppc64.pm +4 -0
@@ -375,6 +375,10 @@ sub write_test_code($) my @not_pattern_re = @{ $params->{ 'not_pattern_re' } }; my %insn_details = %{ $params->{ 'details' } }; + if ($params->{ 'bigendian' } eq 1) { + set_endian(1); + } + open_bin($outfile); # convert from probability that insn will be conditional to
Signature · 1 line
2.7.4
PATCH v3 4/4 build: Add support to PowerPC BE and remove ARCH
In reply to Jose Ricardo ZivianiEssentialy the code for PowerPC BE and LE are the same, so this patch renames all *ppc64le.* files to *ppc64.* and reflects such in the Makefile.
Due to the fact that all supported archs are covered by guess_arch function, this also drops the ARCH parameter from the Makefile.
--- build-all-archs | 2 +- configure | 13 +--- risu_ppc64.c | 40 ++++++++++ risu_ppc64le.c | 40 ---------- risu_reginfo_ppc64.c | 193 +++++++++++++++++++++++++++++++++++++++++++++++++ risu_reginfo_ppc64.h | 28 +++++++ risu_reginfo_ppc64le.c | 193 ------------------------------------------------- risu_reginfo_ppc64le.h | 28 ------- test_ppc64.s | 49 +++++++++++++ test_ppc64le.s | 49 ------------- 10 files changed, 313 insertions(+), 322 deletions(-) create mode 100644 risu_ppc64.c delete mode 100644 risu_ppc64le.c create mode 100644 risu_reginfo_ppc64.c create mode 100644 risu_reginfo_ppc64.h delete mode 100644 risu_reginfo_ppc64le.c delete mode 100644 risu_reginfo_ppc64le.h create mode 100644 test_ppc64.s delete mode 100644 test_ppc64le.s
build-all-archs +1 -1
@@ -25,7 +25,7 @@ program_exists() { # powerpc64-linux-gnu doesn't work at the moment, so not yet listed. for triplet in aarch64-linux-gnu arm-linux-gnueabihf m68k-linux-gnu \ - powerpc64le-linux-gnu ; do + powerpc64le-linux-gnu powerpc64-linux-gnu ; do if ! program_exists "${triplet}-gcc"; then echo "Skipping ${triplet}: no compiler found"
configure +2 -11
@@ -51,7 +51,7 @@ guess_arch() { elif check_define __aarch64__ ; then ARCH="aarch64" elif check_define __powerpc64__ ; then - ARCH="ppc64le" + ARCH="ppc64" else echo "This cpu is not supported by risu. Try -h. " >&2 exit 1
@@ -87,9 +87,6 @@ Some influential environment variables: CROSS_PREFIX cross-compiler prefix, defaults to gcc and other tools prefixed with the given string. - ARCH force target architecture instead of trying to detect it. - Valid values=[arm|aarch64|ppc64|ppc64le|m68k] - CC C compiler command CFLAGS C compiler flags CPPFLAGS C preprocessor flags, e.g. -I<include dir>
@@ -121,13 +118,7 @@ AS="${AS-${CROSS_PREFIX}as}" OBJCOPY="${OBJCOPY-${CROSS_PREFIX}objcopy}" OBJDUMP="${OBJDUMP-${CROSS_PREFIX}objdump}" -if test "x${ARCH}" = "x"; then - guess_arch -elif test "x${ARCH}" = "xppc64"; then - # ppc64 and ppc64le uses the same C source code - ARCH="ppc64le" -fi - +guess_arch generate_makefilein # Are we in a separate build tree? If so, link the Makefile
risu_ppc64.c new file +40 -0
@@ -0,0 +1,40 @@ +/****************************************************************************** +* Copyright (c) IBM Corp, 2016 +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Jose Ricardo Ziviani - initial implementation +* based on Claudio Fontana's risu_aarch64.c +* based on Peter Maydell's risu_arm.c +*****************************************************************************/ + +#include "risu.h" + +void advance_pc (void *vuc) +{ +ucontext_t *uc = (ucontext_t *)vuc; + uc->uc_mcontext.regs->nip +=4 ; +} + +void set_ucontext_paramreg (void *vuc,uint64_t value) +{ +ucontext_t *uc = vuc; + uc->uc_mcontext.gp_regs[0 ] = value; +} + +uint64_t get_reginfo_paramreg (struct reginfo *ri) +{ +return ri->gregs[0 ]; +} + +int get_risuop (struct reginfo *ri) +{ +uint32_t insn = ri->faulting_insn; +uint32_t op = insn &0xf ; +uint32_t key = insn & ~0xf ; +uint32_t risukey =0x00005af0 ; +return (key != risukey) ?-1 : op; +}
risu_ppc64le.c deleted +0 -40
@@ -1,40 +0,0 @@ -/****************************************************************************** -* Copyright (c) IBM Corp, 2016 -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Eclipse Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/epl-v10.html -* -* Contributors: -* Jose Ricardo Ziviani - initial implementation -* based on Claudio Fontana's risu_aarch64.c -* based on Peter Maydell's risu_arm.c -*****************************************************************************/ - -#include "risu.h" - -void advance_pc (void *vuc) -{ -ucontext_t *uc = (ucontext_t *)vuc; - uc->uc_mcontext.regs->nip +=4 ; -} - -void set_ucontext_paramreg (void *vuc,uint64_t value) -{ -ucontext_t *uc = vuc; - uc->uc_mcontext.gp_regs[0 ] = value; -} - -uint64_t get_reginfo_paramreg (struct reginfo *ri) -{ -return ri->gregs[0 ]; -} - -int get_risuop (struct reginfo *ri) -{ -uint32_t insn = ri->faulting_insn; -uint32_t op = insn &0xf ; -uint32_t key = insn & ~0xf ; -uint32_t risukey =0x00005af0 ; -return (key != risukey) ?-1 : op; -}
risu_reginfo_ppc64.c new file +193 -0
193 lines not on this page · raw message
risu_reginfo_ppc64.h new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) IBM Corp, 2016 +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Jose Ricardo Ziviani - initial implementation +* based on Claudio Fontana's risu_reginfo_aarch64 +* based on Peter Maydell's risu_arm.c +*****************************************************************************/ + +#ifndef RISU_REGINFO_PPC64LE_H +#define RISU_REGINFO_PPC64LE_H + +struct reginfo +{ +uint32_t faulting_insn; +uint32_t prev_insn; +uint64_t nip; +uint64_t prev_addr; +gregset_t gregs; +fpregset_t fpregs; +vrregset_t vrregs; +}; + +#endif /* RISU_REGINFO_PPC64LE_H */
risu_reginfo_ppc64le.c deleted +0 -193
193 lines not on this page · raw message
risu_reginfo_ppc64le.h deleted +0 -28
@@ -1,28 +0,0 @@ -/****************************************************************************** -* Copyright (c) IBM Corp, 2016 -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Eclipse Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/epl-v10.html -* -* Contributors: -* Jose Ricardo Ziviani - initial implementation -* based on Claudio Fontana's risu_reginfo_aarch64 -* based on Peter Maydell's risu_arm.c -*****************************************************************************/ - -#ifndef RISU_REGINFO_PPC64LE_H -#define RISU_REGINFO_PPC64LE_H - -struct reginfo -{ -uint32_t faulting_insn; -uint32_t prev_insn; -uint64_t nip; -uint64_t prev_addr; -gregset_t gregs; -fpregset_t fpregs; -vrregset_t vrregs; -}; - -#endif /* RISU_REGINFO_PPC64LE_H */
test_ppc64.s new file +49 -0
49 lines not on this page · raw message
test_ppc64le.s deleted +0 -49
49 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH Risu v3 4/4] build: Add support to PowerPC BE and remove ARCH
Quoted 6 lines · Jose Ricardo Ziviani
Essentialy the code for PowerPC BE and LE are the same, so this patch renames all *ppc64le.* files to *ppc64.* and reflects such in the
Makefile.Due to the fact that all supported archs are covered by
guess_archfunction, this also drops the ARCH parameter from theMakefile.
This change isn't right -- the point is that guess_arch might (in theory) guess wrong, so the user can override it.
You forgot to delete the comment about "powerpc64-linux-gnu doesn't work" from the build-all-archs script.
The rest is fine though, so I've made those minor tweaks and applied the series to risu master.
PS: for patches like this there is a neat git option --find-renames which you can use when you're generating the patch email to create smaller and easier to read patches.
thanks
-- PMM
Re: [Qemu-devel] [PATCH Risu v3 4/4] build: Add support to PowerPC BE and remove ARCH
Quoted 17 lines · Peter Maydell
Quoted 6 lines · Jose Ricardo Ziviani
Essentialy the code for PowerPC BE and LE are the same, so this patch renames all *ppc64le.* files to *ppc64.* and reflects such in the
Makefile.Due to the fact that all supported archs are covered by
guess_archfunction, this also drops the ARCH parameter from theMakefile.This change isn't right -- the point is that
guess_archmight (in theory) guess wrong, so the user can override it.You forgot to delete the comment about "powerpc64-linux-gnu doesn't work" from the build-all-archs script.
The rest is fine though, so I've made those minor tweaks and applied the series to risu master.
Quoted 7 lines
PS: for patches like this there is a neat git option --find-renames which you can use when you're generating the patch email to create smaller and easier to read patches.
thanks
-- PMM
Peter, thanks for your review, I always learn from it. Just added the "git config diff.renames true; git config diff.algorithm patience" config here. Next time it'll be better indeed! :)
Thanks