Add support for s390x to RISU
PATCH v3 1/7 Pass siginfo_t->si_addr to the reginfo_init() function
In reply to Thomas HuthOn s390x, we need the si_addr from the siginfo_t to get to the address of the illegal instruction (the PSW address in the ucontext_t is already pointing to the next instruction there). So let's prepare for that situation and pass the si_addr to the reginfo_init() function everywhere.
--- risu.c | 12 ++++++------ risu.h | 2 +- risu_reginfo_aarch64.c | 2 +- risu_reginfo_arm.c | 2 +- risu_reginfo_i386.c | 2 +- risu_reginfo_loongarch64.c | 2 +- risu_reginfo_m68k.c | 2 +- risu_reginfo_ppc64.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-)
risu.c +6 -6
@@ -106,14 +106,14 @@ static void respond(RisuResult r) } } -static RisuResult send_register_info (void *uc) +static RisuResult send_register_info (void *uc,void *siaddr) {uint64_t paramreg;RisuResult res;RisuOp op;void *extra; -reginfo_init (&ri[MASTER ], uc); +reginfo_init (&ri[MASTER ], uc, siaddr); op =get_risuop (&ri[MASTER ]);/* Write a header with PC/op to keep in sync */
@@ -178,7 +178,7 @@ static void master_sigill(int sig, siginfo_t *si, void *uc)RisuResult r; signal_count++; - r =send_register_info (uc); + r =send_register_info (uc, si->si_addr);if (r ==RES_OK ) {advance_pc (uc); }else {
@@ -232,13 +232,13 @@ static RisuResult recv_register_info(struct reginfo *ri) } } -static RisuResult recv_and_compare_register_info (void *uc) +static RisuResult recv_and_compare_register_info (void *uc,void *siaddr) {uint64_t paramreg;RisuResult res;RisuOp op; -reginfo_init (&ri[APPRENTICE ], uc); +reginfo_init (&ri[APPRENTICE ], uc, siaddr); res =recv_register_info (&ri[MASTER ]);if (res !=RES_OK ) {
@@ -315,7 +315,7 @@ static void apprentice_sigill(int sig, siginfo_t *si, void *uc)RisuResult r; signal_count++; - r =recv_and_compare_register_info (uc); + r =recv_and_compare_register_info (uc, si->si_addr);if (r ==RES_OK ) {advance_pc (uc); }else {
risu.h +1 -1
@@ -115,7 +115,7 @@ RisuOp get_risuop(struct reginfo *ri);uintptr_t get_pc (struct reginfo *ri);/* initialize structure from a ucontext */ -void reginfo_init (struct reginfo *ri,ucontext_t *uc); +void reginfo_init (struct reginfo *ri,ucontext_t *uc,void *siaddr);/* return 1 if structs are equal, 0 otherwise. */ int reginfo_is_eq (struct reginfo *r1,struct reginfo *r2);
risu_reginfo_aarch64.c +1 -1
@@ -82,7 +82,7 @@ int reginfo_size(struct reginfo *ri) }/* reginfo_init: initialize with a ucontext */ -void reginfo_init (struct reginfo *ri,ucontext_t *uc) +void reginfo_init (struct reginfo *ri,ucontext_t *uc,void *siaddr) {int i;struct _aarch64_ctx *ctx, *extra =NULL ;
risu_reginfo_arm.c +1 -1
@@ -118,7 +118,7 @@ static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc) } } -void reginfo_init (struct reginfo *ri,ucontext_t *uc) +void reginfo_init (struct reginfo *ri,ucontext_t *uc,void *siaddr) {memset (ri,0 ,sizeof (*ri));/* necessary for memcmp later */
risu_reginfo_i386.c +1 -1
@@ -102,7 +102,7 @@ static void *xsave_feature_buf(struct _xstate *xs, int feature) }/* reginfo_init: initialize with a ucontext */ -void reginfo_init (struct reginfo *ri,ucontext_t *uc) +void reginfo_init (struct reginfo *ri,ucontext_t *uc,void *siaddr) {int i, nvecregs;struct _fpstate *fp;
risu_reginfo_loongarch64.c +1 -1
@@ -81,7 +81,7 @@ static int parse_extcontext(struct sigcontext *sc, struct extctx_layout *extctx) }/* reginfo_init: initialize with a ucontext */ -void reginfo_init (struct reginfo *ri,ucontext_t *context) +void reginfo_init (struct reginfo *ri,ucontext_t *context,void *siaddr) {int i;struct ucontext *uc = (struct ucontext *)context;
risu_reginfo_m68k.c +1 -1
@@ -33,7 +33,7 @@ int reginfo_size(struct reginfo *ri) }/* reginfo_init: initialize with a ucontext */ -void reginfo_init (struct reginfo *ri,ucontext_t *uc) +void reginfo_init (struct reginfo *ri,ucontext_t *uc,void *siaddr) {int i;memset (ri,0 ,sizeof (*ri));
risu_reginfo_ppc64.c +1 -1
@@ -42,7 +42,7 @@ int reginfo_size(struct reginfo *ri) }/* reginfo_init: initialize with a ucontext */ -void reginfo_init (struct reginfo *ri,ucontext_t *uc) +void reginfo_init (struct reginfo *ri,ucontext_t *uc,void *siaddr) {int i;
Signature · 1 line
2.41.0
PATCH v3 4/7 s390x: Add basic risugen perl module for s390x
In reply to Thomas HuthThis implements support for simple 16-bit and 32-bit instructions. Support for 48-bit instructions and support for load/store memory instructions is not implemented yet.
--- risugen_s390x.pm | 186 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 risugen_s390x.pm
risugen_s390x.pm new file +186 -0
@@ -0,0 +1,186 @@ +#!/usr/bin/perl -w +############################################################################### +# Copyright 2023 Red Hat Inc. +# 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: +# Thomas Huth - initial implementation (based on risugen_ppc64.pm etc.) +############################################################################### + +# risugen -- generate a test binary file for use with risu +# See 'risugen --help' for usage information. +package risugen_s390x; + +use strict; +use warnings; + +use risugen_common; + +require Exporter; + +our @ISA = qw(Exporter); +our @EXPORT = qw(write_test_code); + +my $periodic_reg_random = 1; + +# Maximum alignment restriction permitted for a memory op. +my $MAXALIGN = 64; + +sub write_mov_ri($$$) +{ + my ($r, $imm_h, $imm_l) = @_; + + # LGFI + insn16(0xc0 << 8 | $r << 4 | 0x1); + insn32($imm_l); + # IIHF r,imm_high + insn16(0xc0 << 8 | $r << 4 | 0x8); + insn32($imm_h); +} + +sub write_mov_fp($$) +{ + my ($r, $imm) = @_; + + write_mov_ri(0, ~$imm, $imm); + # LDGR + insn32(0xb3c1 << 16 | $r << 4); +} + +sub write_random_regdata() +{ + # Floating point registers + for (my $i = 0; $i < 16; $i++) { + write_mov_fp($i, rand(0xffffffff)); + } + + # Load FPC (via r0) + write_mov_ri(0, 0, (rand(0xffffffff) & 0x00fcff77)); + insn32(0xb3840000); + + # general purpose registers + for (my $i = 0; $i < 16; $i++) { + write_mov_ri($i, rand(0xffffffff), rand(0xffffffff)); + } +} + +my $OP_COMPARE = 0; # compare registers +my $OP_TESTEND = 1; # end of test, stop + +sub write_random_register_data() +{ + write_random_regdata(); + write_risuop($OP_COMPARE); +} + +sub gen_one_insn($$) +{ + # Given an instruction-details array, generate an instruction + my $constraintfailures = 0; + + INSN: while(1) { + my ($forcecond, $rec) = @_; + my $insn = int(rand(0xffffffff)); + my $insnname = $rec->{name}; + my $insnwidth = $rec->{width}; + my $fixedbits = $rec->{fixedbits}; + my $fixedbitmask = $rec->{fixedbitmask}; + my $constraint = $rec->{blocks}{"constraints"}; + my $memblock = $rec->{blocks}{"memory"}; + + $insn &= ~$fixedbitmask; + $insn |= $fixedbits; + + if (defined $constraint) { + # user-specified constraint: evaluate in an environment + # with variables set corresponding to the variable fields. + my $v = eval_with_fields($insnname, $insn, $rec, "constraints", $constraint); + if (!$v) { + $constraintfailures++; + if ($constraintfailures > 10000) { + print "10000 consecutive constraint failures for $insnname constraints string:\n$constraint\n"; + exit (1); + } + next INSN; + } + } + + # OK, we got a good one + $constraintfailures = 0; + + my $basereg; + + if (defined $memblock) { + die "memblock handling has not been implemented yet." + } + + if ($insnwidth == 16) { + insn16(($insn >> 16) & 0xffff); + } else { + insn32($insn); + } + + return; + } +} + +sub write_risuop($) +{ + my ($op) = @_; + insn32(0x835a0f00 | $op); +} + +sub write_test_code($) +{ + my ($params) = @_; + + my $condprob = $params->{ 'condprob' }; + my $numinsns = $params->{ 'numinsns' }; + my $outfile = $params->{ 'outfile' }; + + my %insn_details = %{ $params->{ 'details' } }; + my @keys = @{ $params->{ 'keys' } }; + + set_endian(1); + + open_bin($outfile); + + # convert from probability that insn will be conditional to + # probability of forcing insn to unconditional + $condprob = 1 - $condprob; + + # TODO better random number generator? + srand(0); + + print "Generating code using patterns: @keys...\n"; + progress_start(78, $numinsns); + + if (grep { defined($insn_details{$_}->{blocks}->{"memory"}) } @keys) { + write_memblock_setup(); + } + + # memblock setup doesn't clean its registers, so this must come afterwards. + write_random_register_data(); + + for my $i (1..$numinsns) { + my $insn_enc = $keys[int rand (@keys)]; + #dump_insn_details($insn_enc, $insn_details{$insn_enc}); + my $forcecond = (rand() < $condprob) ? 1 : 0; + gen_one_insn($forcecond, $insn_details{$insn_enc}); + write_risuop($OP_COMPARE); + # Rewrite the registers periodically. This avoids the tendency + # for the VFP registers to decay to NaNs and zeroes. + if ($periodic_reg_random && ($i % 100) == 0) { + write_random_register_data(); + } + progress_update($i); + } + write_risuop($OP_TESTEND); + progress_end(); + close_bin(); +} + +1;
Signature · 1 line
2.41.0
PATCH v3 3/7 s390x: Add simple s390x.risu file
In reply to Thomas HuthThis only adds a limited set of s390x instructions for initial testing. More instructions will be added later.
--- s390x.risu | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 s390x.risu
s390x.risu new file +81 -0
@@ -0,0 +1,81 @@ +############################################################################### +# Copyright 2023 Red Hat Inc. +# 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: +# Thomas Huth - initial implementation +############################################################################### + +.mode s390x + +# format:RR Add (register + register, 32 bit) +AR Z 00011010 r1:4 r2:4 + +# format:RRE Add (register + register, 64 bit) +AGR Z 10111001 00001000 00000000 r1:4 r2:4 + +# format:RRE Add (register + register, 32 bit to 64 bit) +AGFR Z 10111001 00011000 00000000 r1:4 r2:4 + +# format:RRF-a Add (three registers, 32 bit) +ARK STFLE45 10111001 11111000 r3:4 0000 r1:4 r2:4 + +# format:RRF-a Add (three registers, 64 bit) +AGRK STFLE45 10111001 11101000 r3:4 0000 r1:4 r2:4 + + +# format:RRE Add Halfword Immediate (32 bit) +AHI Z 10100111 r1:4 1010 i2:16 + +# format:RI Add Halfword Immediate (64 bit) +AGHI Z 10100111 r1:4 1011 i2:16 + + +# format:RR Add Logical (32 bit) +ALR Z 00011110 r1:4 r2:4 + +# format:RRE Add Logical (64 bit) +ALGR Z 10111001 00001010 00000000 r1:4 r2:4 + +# format:RRE Add Logical (32 bit to 64 bit) +ALGFR Z 10111001 00011010 00000000 r1:4 r2:4 + + +# format:RRF-c Population Count +POPCNT STFLE45 10111001 11100001 m3:4 0000 r1:4 r2:4 + + +###### Binary floating point instructions ###### + +# format:RRE ADD (short BFP) +AEBR BFP 10110011 00001010 00000000 r1:4 r2:4 + +# format:RRE ADD (long BFP) +ADBR BFP 10110011 00011010 00000000 r1:4 r2:4 + +# format:RRE ADD (extended BFP) +AXBR BFP 10110011 01001010 00000000 r1:4 r2:4 + + +# format:RRE COMPARE (short BFP) +CEBR BFP 10110011 00001001 00000000 r1:4 r2:4 + +# format:RRE COMPARE (long BFP) +CDBR BFP 10110011 00011001 00000000 r1:4 r2:4 + +# format:RRE COMPARE (extended BFP) +CXBR BFP 10110011 01001001 00000000 r1:4 r2:4 + + +# format:RRF-e LOAD FP INTEGER (short BFP) +FIEBRA BFP 10110011 01010111 m3:4 m4:4 r1:4 r2:4 + +# format:RRF-e LOAD FP INTEGER (long BFP) +FIDBRA BFP 10110011 01011111 m3:4 m4:4 r1:4 r2:4 + +# format:RRF-e LOAD FP INTEGER (extended BFP) +FIXBRA BFP 10110011 01000111 m3:4 m4:4 r1:4 r2:4 +
Signature · 1 line
2.41.0
PATCH v3 6/7 build-all-archs: Add s390x to the script that builds all architectures
In reply to Thomas HuthTo avoid regressions, let's check s390x also via this file.
--- build-all-archs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
build-all-archs +2 -1
@@ -91,7 +91,8 @@ program_exists() { for triplet in i386-linux-gnu i686-linux-gnu x86_64-linux-gnu \ aarch64-linux-gnu arm-linux-gnueabihf \ m68k-linux-gnu \ - powerpc64le-linux-gnu powerpc64-linux-gnu ; do + powerpc64le-linux-gnu powerpc64-linux-gnu \ + s390x-linux-gnu ; do if ! program_exists "${triplet}-gcc"; then echo "Skipping ${triplet}: no compiler found"
Signature · 1 line
2.41.0
PATCH v3 5/7 s390x: Update the configure script for s390x support
In reply to Thomas HuthAuto-detect s390x hosts and add s390x information to the help text.
--- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
configure +3 -1
@@ -58,6 +58,8 @@ guess_arch() { ARCH="m68k" elif check_define __powerpc64__ ; then ARCH="ppc64" + elif check_define __s390x__ ; then + ARCH="s390x" else echo "This cpu is not supported by risu. Try -h. " >&2 exit 1
@@ -139,7 +141,7 @@ Some influential environment variables: prefixed with the given string. ARCH force target architecture instead of trying to detect it. - Valid values=[arm|aarch64|ppc64|ppc64le|m68k] + Valid values=[arm|aarch64|m68k|ppc64|ppc64le|s390x] CC C compiler command CFLAGS C compiler flags
Signature · 1 line
2.41.0
RFC PATCH v3 7/7 Add a travis.yml file for testing RISU in the Travis-CI
In reply to Thomas HuthTravis-CI offers native build machines for aarch64, ppc64le and s390x, so this is very useful for testing RISU on these architectures. While compiling works fine for all architectures, running the binary currently only works for s390x (the aarch64 runner reports a mismatch when comparing the registers, and the ppc64le runner simply hangs), so we can only run the resulting binary on s390x right now.
---
Not sure if this is useful for anybody but me since Travis is not that popular anymore these days ... so please feel free to ignore this patch.
.travis.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .travis.yml
.travis.yml new file +37 -0
@@ -0,0 +1,37 @@ +dist: focal +language: c +compiler: + - gcc +addons: + apt: + packages: + - perl + - perl-modules + - liblist-compare-perl + +before_script: + - ./configure +script: + - set -e + - make -j2 + - ./risugen --numinsns 1000 ${ARCH}.risu ${ARCH}.bin + +matrix: + include: + + - env: + - ARCH="aarch64" + arch: arm64 + + - env: + - ARCH="ppc64" + arch: ppc64le + + - env: + - ARCH="s390x" + arch: s390x + after_script: + - ./risu --master ${ARCH}.bin > stdout.txt 2> stderr.txt & + - sleep 1 + - ./risu --host localhost ${ARCH}.bin + - cat stdout.txt stderr.txt
Signature · 1 line
2.41.0
v3 cover Add support for s390x to RISU
Hi Peter!
Here are some patches that add basic support for s390x to RISU. It's still quite limited, e.g. no support for load/store memory operations yet, but the basics with simple 16-bit or 32-bit instructions work *now* already fine.
(I'm also already experimenting in extending RISU to support instructions with opcodes lengths > 32-bit, but the patches are not quite ready yet)
v3:
- Use si_addr to get the address of the faulting instruction (since the PSW address in the ucontext already points to the next instruction)
- Use the kernel header asm/ucontext.h instead the one from the glibc since the latter does not provide information about vector registers (VRs are not used yet, but will be added later)
- Disable exceptions in the floating point control register so we can also test floating point instructions
- Added some more instructions to s390x.risu
- Added RFC patch to compile test aarch64, ppc64le and s390x on Travis-CI
v2:
- Removed the code to avoid r14 (return address) and r15 (stack pointer) since it is not necessary anymore since commit ad82a069e8d6a
- Initialize the floating point registers in test_s390x.S, too
- Added Acked-bys and Reviewed-bys from v1
Thomas Huth (7):
Pass siginfo_t->si_addr to the reginfo_init() function
s390x: Add basic s390x support to the C code
s390x: Add simple s390x.risu file
s390x: Add basic risugen perl module for s390x
s390x: Update the configure script for s390x support
build-all-archs: Add s390x to the script that builds all architectures Add a travis.yml file for testing RISU in the Travis-CI
.travis.yml | 37 ++++++++ build-all-archs | 3 +- configure | 4 +- risu.c | 12 +-- risu.h | 2 +- risu_reginfo_aarch64.c | 2 +- risu_reginfo_arm.c | 2 +- risu_reginfo_i386.c | 2 +- risu_reginfo_loongarch64.c | 2 +- risu_reginfo_m68k.c | 2 +- risu_reginfo_ppc64.c | 2 +- risu_reginfo_s390x.c | 140 ++++++++++++++++++++++++++++ risu_reginfo_s390x.h | 25 +++++ risu_s390x.c | 51 ++++++++++ risugen_s390x.pm | 186 +++++++++++++++++++++++++++++++++++++ s390x.risu | 81 ++++++++++++++++ test_s390x.S | 53 +++++++++++ 17 files changed, 591 insertions(+), 15 deletions(-) create mode 100644 .travis.yml create mode 100644 risu_reginfo_s390x.c create mode 100644 risu_reginfo_s390x.h create mode 100644 risu_s390x.c create mode 100644 risugen_s390x.pm create mode 100644 s390x.risu create mode 100644 test_s390x.S
Signature · 1 line
2.41.0
PATCH v3 2/7 s390x: Add basic s390x support to the C code
With these changes, it is now possible to compile the "risu" binary for s390x hosts.
--- risu_reginfo_s390x.c | 140 +++++++++++++++++++++++++++++++++++++++++++ risu_reginfo_s390x.h | 25 ++++++++ risu_s390x.c | 51 ++++++++++++++++ test_s390x.S | 53 ++++++++++++++++ 4 files changed, 269 insertions(+) create mode 100644 risu_reginfo_s390x.c create mode 100644 risu_reginfo_s390x.h create mode 100644 risu_s390x.c create mode 100644 test_s390x.S
risu_reginfo_s390x.c new file +140 -0
@@ -0,0 +1,140 @@ +/****************************************************************************** +* Copyright 2023 Red Hat Inc. +* 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: +* Thomas Huth - initial implementation +*****************************************************************************/ + +#include <stdio.h> +#include <signal.h> +#include <asm/ucontext.h> +#include <string.h> +#include <math.h> +#include <stdlib.h> +#include <sys/user.h> + +#include "risu.h" +#include "risu_reginfo_s390x.h" + + +const struct option *const arch_long_opts; +const char *const arch_extra_help; + +void process_arch_opt (int opt,const char *arg) +{ +abort (); +} + +void arch_init (void ) +{ +} + +int reginfo_size (struct reginfo *ri) +{ +return sizeof (*ri); +} + +/* reginfo_init: initialize with a ucontext */ +void reginfo_init (struct reginfo *ri,ucontext_t *uc,void *siaddr) +{ +struct ucontext_extended *uce = (struct ucontext_extended *)uc; + +memset (ri,0 ,sizeof (*ri)); + +/* +* We can get the size of the instruction by looking at the +* first two bits of the instruction +*/ +switch (*(uint8_t *)siaddr >>6 ) { +case 0 : + ri->faulting_insn = *(uint16_t *)siaddr; + ri->faulting_insn_len =2 ; +break ; +case 3 : + ri->faulting_insn = ((*(uint32_t *)siaddr) <<16 ) + | *(uint16_t *)(siaddr +4 ); + ri->faulting_insn_len =6 ; +break ; +default : + ri->faulting_insn = *(uint32_t *)siaddr; + ri->faulting_insn_len =4 ; + } + + ri->psw_mask = uce->uc_mcontext.regs.psw.mask; + ri->pc_offset = (uintptr_t )siaddr - image_start_address; + +memcpy (ri->gprs, uce->uc_mcontext.regs.gprs,sizeof (ri->gprs)); + + ri->fpc = uc->uc_mcontext.fpregs.fpc; +memcpy (ri->fprs, &uc->uc_mcontext.fpregs.fprs,sizeof (ri->fprs)); +} + +/* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ +int reginfo_is_eq (struct reginfo *m,struct reginfo *a) +{ +return m->pc_offset == a->pc_offset && + m->fpc == a->fpc && +memcmp (m->gprs, a->gprs,sizeof (m->gprs)) ==0 && +memcmp (&m->fprs, &a->fprs,sizeof (m->fprs)) ==0 ; +} + +/* reginfo_dump: print state to a stream, returns nonzero on success */ +int reginfo_dump (struct reginfo *ri,FILE * f) +{ +int i; + +fprintf (f," faulting insn 0x%" PRIx64"\n" , ri->faulting_insn); +fprintf (f," PSW mask 0x%" PRIx64"\n" , ri->psw_mask); +fprintf (f," PC offset 0x%" PRIx64"\n\n" , ri->pc_offset); + +for (i =0 ; i <16 /2 ; i++) { +fprintf (f,"\tr%d: %16lx\tr%02d: %16lx\n" , i, ri->gprs[i], + i +8 , ri->gprs[i +8 ]); + } +fprintf (f,"\n" ); + +for (i =0 ; i <16 /2 ; i++) { +fprintf (f,"\tf%d: %16lx\tf%02d: %16lx\n" , + i, *(uint64_t *)&ri->fprs[i], + i +8 , *(uint64_t *)&ri->fprs[i +8 ]); + } +fprintf (f,"\tFPC: %8x\n\n" , ri->fpc); + +return !ferror (f); +} + +int reginfo_dump_mismatch (struct reginfo *m,struct reginfo *a,FILE *f) +{ +int i; + +if (m->pc_offset != a->pc_offset) { +fprintf (f,"Mismatch: PC offset master: [%016lx] - PC offset apprentice: [%016lx]\n" , + m->pc_offset, a->pc_offset); + } + +for (i =0 ; i <16 ; i++) { +if (m->gprs[i] != a->gprs[i]) { +fprintf (f,"Mismatch: r%d master: [%016lx] - r%d apprentice: [%016lx]\n" , + i, m->gprs[i], i, a->gprs[i]); + } + } + +for (i =0 ; i <16 ; i++) { +if (*(uint64_t *)&m->fprs[i] != *(uint64_t *)&a->fprs[i]) { +fprintf (f,"Mismatch: f%d master: [%016lx] - f%d apprentice: [%016lx]\n" , + i, *(uint64_t *)&m->fprs[i], + i, *(uint64_t *)&a->fprs[i]); + } + } + +if (m->fpc != a->fpc) { +fprintf (f,"Mismatch: FPC master: [%08x] - FPC apprentice: [%08x]\n" , + m->fpc, a->fpc); + } + +return !ferror (f); +}
risu_reginfo_s390x.h new file +25 -0
@@ -0,0 +1,25 @@ +/****************************************************************************** +* Copyright 2023 Red Hat Inc. +* 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: +* Thomas Huth - initial implementation +*****************************************************************************/ + +#ifndef RISU_REGINFO_S390X_H +#define RISU_REGINFO_S390X_H + +struct reginfo { +uint64_t psw_mask; +uint64_t pc_offset; +uint64_t faulting_insn; +int faulting_insn_len; +uint32_t fpc; +uint64_t gprs[16 ]; +uint64_t fprs[16 ]; +}; + +#endif /* RISU_REGINFO_S390X_H */
risu_s390x.c new file +51 -0
51 lines not on this page · raw message
test_s390x.S new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.41.0
Quoted 11 lines · Thomas Huth
Hi Peter!
Here are some patches that add basic support for s390x to RISU. It's still quite limited, e.g. no support for load/store memory operations yet, but the basics with simple 16-bit or 32-bit instructions work *now* already fine.
(I'm also already experimenting in extending RISU to support instructions with opcodes lengths > 32-bit, but the patches are not quite ready yet)
Hi; I've applied these patches to risu master, except for the last Travis one -- I'm not sure that makes sense for the upstream repo given it doesn't use Travis.
thanks
-- PMM