Skip to contentSkip to conversation

Initial support for SVE

PATCH Applied Alex Bennée 4 participants 24 messages Nov 7, 2017 – Nov 21, 2017

lore
Share & tools
lore
#0 lore raw

cover Initial support for SVE

Hi,

These patches apply on-top of the last clean-up series:

Subject: [RISU PATCH 0/7] Add @Group support and some aarch64.risu cleanups
Date: Tue, 31 Oct 2017 14:54:37 +0000
Message-Id: <[email protected]>

This series adds support for SVE to RISU. Most of the initial patches are plumbing changes to better support arch specific option flags (cleaning up a TODO in the process). I also needed to ensure configure actually honoured CPPFLAGS so it could be passed yet to be released headers.

The actual guts of the SVE support is in 3 patches. One to risugen so it can generate random values for the vector registers. If this isn't done you get inconsistent runs because of left over junk in the registers. The remaining two patches add support for copying the SVE vectors from the signal context and dumping any differences found.

To test this I ran on the Foundation model with:

  ${RTSM_MODEL} --no-secure-memory --gicv3 --data=${BL1_FIRMWARE}@0x0 --data=${FIP_FIRMWARE}@0x8000000 \
                --semihost --network nat --network-nat-ports=8022=22 --block-device ${DISK_IMAGE}

With my hacked up copy of secure firmware to ensure SVE is enabled. You also need a kernel with SVE support:

Subject: [PATCH v5 00/30] ARM Scalable Vector Extension (SVE)
Date: Tue, 31 Oct 2017 15:50:52 +0000
Message-Id: <[email protected]>

My testing so far has been to ensure that each run on the foundation model is deterministic (same m5sum on each trace) and that differences are printed out when the user-space vector length is tweaked (/proc/sys/abi/sve_default_vector_length).

Alex Bennée (10):
build-all-arches: drop -t (for tty) from docker invocation risu.c: split out setting up options
risu.c: add missing --trace longopt
risu: move optional args to each architecture
configure: allow repeated invocation of configure in build dir
configure: support CPPFLAGS
risugen: add --sve support
aarch64.risu: initial SVE instruction
risu_reginfo_aarch64: add reginfo_copy_sve
risu_reginfo_aarch64: add SVE support to reginfo_dump_mismatch

 README                 |   6 +++
 aarch64.risu           |  24 ++++++++++
 build-all-archs        |   2 +-
 configure              |   5 +-
 risu.c                 |  57 +++++++++++++++++-----
 risu.h                 |   6 ++-
 risu_reginfo_aarch64.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++
 risu_reginfo_aarch64.h |   8 ++++
 risu_reginfo_arm.c     |  11 +++++
 risu_reginfo_m68k.c    |   3 ++
 risu_reginfo_ppc64.c   |   3 ++
 risugen                |   3 ++
 risugen_arm.pm         |  57 +++++++++++++++++++---
 13 files changed, 286 insertions(+), 25 deletions(-)
Signature · 1 line
2.14.2
#1 lore raw

PATCH 1/10 build-all-arches: drop -t (for tty) from docker invocation

This prevents gcc from going nuts with colorizing the compiler output which looks particularly ugly when invoked via compilation-mode.

---
 build-all-archs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
build-all-archs +1 -1
index 63918e5..fa2ac90 100755
@@ -61,7 +61,7 @@ done
 # If docker is enabled we just brute force the various images until we
 # can set the one that has a workable cross compiler.
 
-DOCKER_RUN="docker run --rm -t -u $(id -u) -v $(pwd):$(pwd) -w $(pwd)"
+DOCKER_RUN="docker run --rm -u $(id -u) -v $(pwd):$(pwd) -w $(pwd)"
 
 program_exists() {
     if [ ! -z "$docker_tags" ]; then
Signature · 1 line
2.14.2
#2 lore raw

PATCH 2/10 risu.c: split out setting up options

In reply to Alex Bennée

This is a prerequisite to properly handling architecture specific options.

---
 risu.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)
risu.c +19 -10
index 47471c6..a5d155d 100644
@@ -282,6 +282,21 @@ void usage(void)
             "(default 9191)\n");
 }
 
+struct option * setup_options(char **short_opts)
+{
+    static struct option default_longopts[] = {
+        {"help", no_argument, 0, '?'},
+        {"master", no_argument, &ismaster, 1},
+        {"host", required_argument, 0, 'h'},
+        {"port", required_argument, 0, 'p'},
+        {"test-fp-exc", no_argument, &test_fp_exc, 1},
+        {0, 0, 0, 0}
+    };
+
+    *short_opts = "h:p:t:";
+    return default_longopts;
+}
+
 int main(int argc, char **argv)
 {
     /* some handy defaults to make testing easier */
@@ -289,20 +304,14 @@ int main(int argc, char **argv)
     char *hostname = "localhost";
     char *imgfile;
     char *trace_fn = NULL;
+    struct option *longopts;
+    char *shortopts;
 
-    /* TODO clean this up later */
+    longopts = setup_options(&shortopts);
 
     for (;;) {
-        static struct option longopts[] = {
-            {"help", no_argument, 0, '?'},
-            {"master", no_argument, &ismaster, 1},
-            {"host", required_argument, 0, 'h'},
-            {"port", required_argument, 0, 'p'},
-            {"test-fp-exc", no_argument, &test_fp_exc, 1},
-            {0, 0, 0, 0}
-        };
         int optidx = 0;
-        int c = getopt_long(argc, argv, "h:p:t:", longopts, &optidx);
+        int c = getopt_long(argc, argv, shortopts, longopts, &optidx);
         if (c == -1) {
             break;
         }
Signature · 1 line
2.14.2
#3 lore raw

PATCH 3/10 risu.c: add missing --trace longopt

In reply to Alex Bennée

This got missed when trace support was added.

---
 risu.c | 1 +
 1 file changed, 1 insertion(+)
risu.c +1 -0
index a5d155d..616fc33 100644
@@ -289,6 +289,7 @@ struct option * setup_options(char **short_opts)
         {"master", no_argument, &ismaster, 1},
         {"host", required_argument, 0, 'h'},
         {"port", required_argument, 0, 'p'},
+        {"trace", required_argument, 0, 't'},
         {"test-fp-exc", no_argument, &test_fp_exc, 1},
         {0, 0, 0, 0}
     };
Signature · 1 line
2.14.2
#4 lore raw

PATCH 4/10 risu: move optional args to each architecture

In reply to Alex Bennée

The key variables here are: *arch_long_opts and *arch_extra_help. If they are not NULL then we concatenate the extra options to appropriate structure to enable the support. Adding architecture short options is not supported.

This also includes moving the ARM specific test_fp_exc/test-fp-exc into ARM specific code.

---
 risu.c                 | 31 ++++++++++++++++++++++++++-----
 risu.h                 |  6 ++++--
 risu_reginfo_aarch64.c |  3 +++
 risu_reginfo_arm.c     | 11 +++++++++++
 risu_reginfo_m68k.c    |  3 +++
 risu_reginfo_ppc64.c   |  3 +++
 6 files changed, 50 insertions(+), 7 deletions(-)
risu.c +26 -5
index 616fc33..f063093 100644
@@ -43,9 +43,6 @@ gzFile gz_trace_file;
 
 sigjmp_buf jmpbuf;
 
-/* Should we test for FP exception status bits? */
-int test_fp_exc;
-
 /* Master functions */
 
 int read_sock(void *ptr, size_t bytes)
@@ -280,6 +277,9 @@ void usage(void)
     fprintf(stderr,
             "  -p, --port=PORT   Specify the port to connect to/listen on "
             "(default 9191)\n");
+    if (arch_extra_help) {
+        fprintf(stderr, "%s", arch_extra_help);
+    }
 }
 
 struct option * setup_options(char **short_opts)
@@ -290,12 +290,33 @@ struct option * setup_options(char **short_opts)
         {"host", required_argument, 0, 'h'},
         {"port", required_argument, 0, 'p'},
         {"trace", required_argument, 0, 't'},
-        {"test-fp-exc", no_argument, &test_fp_exc, 1},
         {0, 0, 0, 0}
     };
+    struct option *lopts = &default_longopts[0];
 
     *short_opts = "h:p:t:";
-    return default_longopts;
+
+    if (arch_long_opts) {
+        struct option *dptr, *sptr;
+        size_t osize = sizeof(default_longopts);
+        lopts = malloc(osize);
+        /* Copy default opts */
+        memcpy(lopts, default_longopts, osize);
+        dptr = lopts;
+        while (dptr->name) {
+            dptr++;
+        }
+        /* Copy extra opts */
+        sptr = arch_long_opts;
+        while (sptr->name) {
+            osize += sizeof(struct option);
+            lopts = realloc(lopts, osize);
+            *dptr++ = *sptr++;
+        }
+        memset(dptr, 0, sizeof(struct option));
+    }
+
+    return lopts;
 }
 
 int main(int argc, char **argv)
risu.h +4 -2
index 1c8ecee..89811f4 100644
@@ -17,6 +17,10 @@
 #include <ucontext.h>
 #include <stdio.h>
 
+/* Extra option processing for architectures */
+extern void *arch_long_opts;
+extern char *arch_extra_help;
+
 /* GCC computed include to pull in the correct risu_reginfo_*.h for
  * the architecture.
  */
@@ -36,8 +40,6 @@ void send_response_byte(int sock, int resp);
 extern uintptr_t image_start_address;
 extern void *memblock;
 
-extern int test_fp_exc;
-
 /* Ops code under test can request from risu: */
 #define OP_COMPARE 0
 #define OP_TESTEND 1
risu_reginfo_aarch64.c +3 -0
index e3fadde..38ad338 100644
@@ -17,6 +17,9 @@
 #include "risu.h"
 #include "risu_reginfo_aarch64.h"
 
+void *arch_long_opts;
+char *arch_extra_help;
+
 /* reginfo_init: initialize with a ucontext */
 void reginfo_init(struct reginfo *ri, ucontext_t *uc)
 {
risu_reginfo_arm.c +11 -0
index 6b9ee7b..5acad02 100644
@@ -13,12 +13,23 @@
 #include <stdio.h>
 #include <ucontext.h>
 #include <string.h>
+#include <getopt.h>
 
 #include "risu.h"
 #include "risu_reginfo_arm.h"
 
 extern int insnsize(ucontext_t *uc);
 
+/* Should we test for FP exception status bits? */
+static int test_fp_exc;
+static struct option extra_opts[] = {
+    {"test-fp-exc", no_argument, &test_fp_exc, 1},
+    {0, 0, 0, 0}
+};
+
+void *arch_long_opts = &extra_opts[0];
+char *arch_extra_help = "  --test-fp-exc     Check FP exception bits when comparing\n";
+
 static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc)
 {
     /* Read VFP registers. These live in uc->uc_regspace, which is
risu_reginfo_m68k.c +3 -0
index 4ff0aa8..d429502 100644
@@ -14,6 +14,9 @@
 #include "risu.h"
 #include "risu_reginfo_m68k.h"
 
+void *arch_long_opts;
+char *arch_extra_help;
+
 /* reginfo_init: initialize with a ucontext */
 void reginfo_init(struct reginfo *ri, ucontext_t *uc)
 {
risu_reginfo_ppc64.c +3 -0
index eb9c12b..aa5d8c6 100644
@@ -22,6 +22,9 @@
 #define XER 37
 #define CCR 38
 
+void *arch_long_opts;
+char *arch_extra_help;
+
 /* reginfo_init: initialize with a ucontext */
 void reginfo_init(struct reginfo *ri, ucontext_t *uc)
 {
Signature · 1 line
2.14.2
#5 lore raw

Re: [Qemu-devel] [RISU PATCH 04/10] risu: move optional args to each architecture

Quoted 5 lines · Alex Bennée
risu.c +5 -0
+    if (arch_long_opts) {
+        struct option *dptr, *sptr;
+        size_t osize = sizeof(default_longopts);
+        lopts = malloc(osize);
+        /* Copy default opts */

risu.c struct option * setup_options(char **short_opts) · line 313

Quoted 10 lines
risu.c +10 -0
+        memcpy(lopts, default_longopts, osize);
+        dptr = lopts;
+        while (dptr->name) {
+            dptr++;
+        }
+        /* Copy extra opts */
+        sptr = arch_long_opts;
+        while (sptr->name) {
+            osize += sizeof(struct option);
+            lopts = realloc(lopts, osize);

Count default and arch opts first?

r~

#6 lore raw

PATCH 5/10 configure: allow repeated invocation of configure in build dir

In reply to Alex Bennée

Otherwise a second configure run will totally miss out the setting of BUILD_INC. I made the link -sf as it seemed the easier way around.

---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure +2 -2
index 1dc527b..c622a5e 100755
@@ -176,10 +176,10 @@ fi
 
 # Are we in a separate build tree? If so, link the Makefile
 # so that 'make' works.
-if test ! -e Makefile; then
+if test ! -e Makefile || test -s Makefile; then
     echo "linking Makefile..."
     BUILD_INC="-I $(pwd)"
-    ln -s "${SRCDIR}/Makefile" .
+    ln -sf "${SRCDIR}/Makefile" .
 fi
 
 generate_config
Signature · 1 line
2.14.2
#7 lore raw

PATCH 6/10 configure: support CPPFLAGS

In reply to Alex Bennée

Useful for accessing API's that are still brewing, e.g:

  CROSS_PREFIX=aarch64-linux-gnu- \
    CPPFLAGS=-I/home/alex/lsrc/qemu/risu.git/sve-headers/include \
    ../configure
---
 README    | 6 ++++++
 configure | 1 +
 2 files changed, 7 insertions(+)
README +6 -0
index 9946e6e..fbe408d 100644
@@ -26,6 +26,12 @@ Most useful is
    need this if you're not building on the target system
    (Example: CROSS_PREFIX=arm-linux-gnueabihf- )
 
+Another useful flag is
+ CPPFLAGS= which specified pre-processor flags, usually -I statements
+   for specifying extra include paths. Use this is you need something
+   from new kernel headers not installed on your system.
+   (Example: CPPFLAGS=-I/path/to/sve-kernel-headers/include)
+
 Passing --static will build a statically linked binary which is useful
 if you don't want to mess around with a chroot to run the binary.
 
configure +1 -0
index c622a5e..65e1819 100755
@@ -111,6 +111,7 @@ generate_makefilein() {
     echo "# Makefile.in - generated by the 'configure' script" > $m
     echo "ARCH:=${ARCH}" >> $m
     echo "CC:=${CC}" >> $m
+    echo "CPPFLAGS:=${CPPFLAGS}" >> $m
     echo "LDFLAGS:=${LDFLAGS}" >> $m
     echo "AS:=${AS}" >> $m
     echo "OBJCOPY:=${OBJCOPY}" >> $m
Signature · 1 line
2.14.2
#8 lore raw

Re: [RISU PATCH 06/10] configure: support CPPFLAGS

Quoted 17 lines · Alex Bennée

Useful for accessing API's that are still brewing, e.g:

  CROSS_PREFIX=aarch64-linux-gnu- \
    CPPFLAGS=-I/home/alex/lsrc/qemu/risu.git/sve-headers/include \
    ../configure
---
 README    | 6 ++++++
 configure | 1 +
 2 files changed, 7 insertions(+)
README +0 -0
index 9946e6e..fbe408d 100644

README Most useful is · line 31

Quoted 6 lines
README +3 -0
@@ -26,6 +26,12 @@ Most useful is
    need this if you're not building on the target system
    (Example: CROSS_PREFIX=arm-linux-gnueabihf- )
 
+Another useful flag is
+ CPPFLAGS= which specified pre-processor flags, usually -I statements
+   for specifying extra include paths. Use this is you need something

s/is/if/

README Most useful is · line 34

Quoted 3 lines
README +3 -0
+   from new kernel headers not installed on your system.
+   (Example: CPPFLAGS=-I/path/to/sve-kernel-headers/include)
+

You should probably point out that the path should refer to headers installed by running 'make headers_install' in the Linux source. This means we really test the uapi headers properly, and I don't get spurious bug reports about bad headers ;)

[...]

Cheers
---Dave

#9 lore raw

Re: [RISU PATCH 06/10] configure: support CPPFLAGS

Quoted 27 lines · Dave Martin
Quoted 17 lines · Alex Bennée

Useful for accessing API's that are still brewing, e.g:

  CROSS_PREFIX=aarch64-linux-gnu- \
    CPPFLAGS=-I/home/alex/lsrc/qemu/risu.git/sve-headers/include \
    ../configure
---
 README    | 6 ++++++
 configure | 1 +
 2 files changed, 7 insertions(+)
README +0 -0
index 9946e6e..fbe408d 100644

README Most useful is · line 31

Quoted 6 lines
README +3 -0
@@ -26,6 +26,12 @@ Most useful is
    need this if you're not building on the target system
    (Example: CROSS_PREFIX=arm-linux-gnueabihf- )
 
+Another useful flag is
+ CPPFLAGS= which specified pre-processor flags, usually -I statements
+   for specifying extra include paths. Use this is you need something

s/is/if/

Quoted 8 lines

README Most useful is · line 34

Quoted 3 lines
README +3 -0
+   from new kernel headers not installed on your system.
+   (Example: CPPFLAGS=-I/path/to/sve-kernel-headers/include)
+

You should probably point out that the path should refer to headers installed by running 'make headers_install' in the Linux source. This means we really test the uapi headers properly, and I don't get spurious bug reports about bad headers ;)

Will do. Thanks.

Quoted 5 lines

[...]

Cheers
---Dave

--
Alex Bennée

#10 lore raw

PATCH 7/10 risugen: add --sve support

In reply to Alex Bennée

This is similar to the approach used by the FP/simd data in so far as we generate a block of random data and then load into it. As there are no post-index SVE operations we need to emit an additional incp instruction to generate our offset into the array.

---
 risugen        |  3 +++
 risugen_arm.pm | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 53 insertions(+), 7 deletions(-)
risugen +3 -0
index aba4bb7..0ac8e86 100755
@@ -317,6 +317,7 @@ sub main()
     my $condprob = 0;
     my $fpscr = 0;
     my $fp_enabled = 1;
+    my $sve_enabled = 1;
     my $big_endian = 0;
     my ($infile, $outfile);
 
@@ -334,6 +335,7 @@ sub main()
                 },
                 "be" => sub { $big_endian = 1; },
                 "no-fp" => sub { $fp_enabled = 0; },
+                "sve" => sub { $sve_enabled = 1; },
         ) or return 1;
     # allow "--pattern re,re" and "--pattern re --pattern re"
     @pattern_re = split(/,/,join(',',@pattern_re));
@@ -361,6 +363,7 @@ sub main()
         'fpscr' => $fpscr,
         'numinsns' => $numinsns,
         'fp_enabled' => $fp_enabled,
+        'sve_enabled' => $sve_enabled,
         'outfile' => $outfile,
         'details' => \%insn_details,
         'keys' => \@insn_keys,
risugen_arm.pm +50 -7

97 lines not on this page · raw message

Signature · 1 line
2.14.2
#11 lore raw

Re: [Qemu-devel] [RISU PATCH 07/10] risugen: add --sve support

risugen_arm.pm sub write_random_aarch64_regdata($) · line 526

Quoted 7 lines · Alex Bennée
risugen_arm.pm +3 -0
@@ -483,6 +521,10 @@ sub write_random_aarch64_regdata($)
         write_random_aarch64_fpdata();
     }
 
+    if ($sve_enabled) {
+        write_random_aarch64_svedata();
+    }

Should write either sve or fpdata, but not both, since the registers overlap.

r~

#12 lore raw

Re: [RISU PATCH 07/10] risugen: add --sve support

In reply to Alex Bennée
Quoted 44 lines · Alex Bennée

This is similar to the approach used by the FP/simd data in so far as we generate a block of random data and then load into it. As there are no post-index SVE operations we need to emit an additional incp instruction to generate our offset into the array.

---
 risugen        |  3 +++
 risugen_arm.pm | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 53 insertions(+), 7 deletions(-)
risugen +3 -0
index aba4bb7..0ac8e86 100755
@@ -317,6 +317,7 @@ sub main()
     my $condprob = 0;
     my $fpscr = 0;
     my $fp_enabled = 1;
+    my $sve_enabled = 1;
     my $big_endian = 0;
     my ($infile, $outfile);
 
@@ -334,6 +335,7 @@ sub main()
                 },
                 "be" => sub { $big_endian = 1; },
                 "no-fp" => sub { $fp_enabled = 0; },
+                "sve" => sub { $sve_enabled = 1; },
         ) or return 1;
     # allow "--pattern re,re" and "--pattern re --pattern re"
     @pattern_re = split(/,/,join(',',@pattern_re));
@@ -361,6 +363,7 @@ sub main()
         'fpscr' => $fpscr,
         'numinsns' => $numinsns,
         'fp_enabled' => $fp_enabled,
+        'sve_enabled' => $sve_enabled,
         'outfile' => $outfile,
         'details' => \%insn_details,
         'keys' => \@insn_keys,
risugen_arm.pm +0 -0
index 2f10d58..8d1e1fd 100644

risugen_arm.pm sub write_random_aarch64_fpdata() · line 479

Quoted 10 lines
risugen_arm.pm +4 -2
@@ -472,9 +472,47 @@ sub write_random_aarch64_fpdata()
     }
 }
 
-sub write_random_aarch64_regdata($)
+sub write_random_aarch64_svedata()
 {
-    my ($fp_enabled) = @_;
+    # Load SVE registers
+    my $align = 16;
+    my $vl = 16;                             # number of vqs

Would this be better phrased

	my $vq = 16;				# quadwords per vector
Quoted 20 lines
risugen_arm.pm +20 -0
+    my $datalen = (32 * $vl * 16) + $align;
+
+    write_pc_adr(0, (3 * 4) + ($align - 1)); # insn 1
+    write_align_reg(0, $align);              # insn 2
+    write_jump_fwd($datalen);                # insn 3
+
+    # align safety
+    for (my $i = 0; $i < ($align / 4); $i++) {
+        # align with nops
+        insn32(0xd503201f);
+    };
+
+    for (my $rt = 0; $rt <= 31; $rt++) {
+        for (my $q = 0; $q < $vl; $q++) {
+            write_random_fpreg_var(4); # quad
+        }
+    }
+
+    # Reset all the predicate registers to all true
+    for (my $p = 0; $p < 16; $p++) {

risugen_arm.pm sub write_random_aarch64_fpdata() · line 509

Quoted 10 lines
risugen_arm.pm +10 -0
+        insn32(0x2518e3e0 | $p);
+    }
+
+    # there is no post index load so we do this by hand
+    write_mov_ri(1, 0);
+    for (my $rt = 0; $rt <= 31; $rt++) {
+        # ld1d    z0.d, p0/z, [x0, x1, lsl #3]
+        insn32(0xa5e14000 | $rt);
+        # incp    x1, p0.d
+        insn32(0x25ec8801);

You could avoid this with the unpredicated form LDR (vector). (LD1x scalar+immediate doesn't provide enough immediate range).

	# ldr	z$rt, [x0, #$rt, mul vl]
	insn32(0x85804000 + $rt + (($rt & 7) << 10) + (($rt & 0x18) << 13));

which is what the kernel does.

No harm in exercising different instructions though! The kernel uses embarrassingly few.

Does it matter that the stride will depend on the actual current VL? If x0 just points to a block of random data, I guess it doesn't matter:
some trailing data remains unused, but that doesn't make the used data any less random.

[...]

Cheers
---Dave

#13 lore raw

Re: [RISU PATCH 07/10] risugen: add --sve support

Quoted 94 lines · Dave Martin
Quoted 44 lines · Alex Bennée

This is similar to the approach used by the FP/simd data in so far as we generate a block of random data and then load into it. As there are no post-index SVE operations we need to emit an additional incp instruction to generate our offset into the array.

---
 risugen        |  3 +++
 risugen_arm.pm | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 53 insertions(+), 7 deletions(-)
risugen +3 -0
index aba4bb7..0ac8e86 100755
@@ -317,6 +317,7 @@ sub main()
     my $condprob = 0;
     my $fpscr = 0;
     my $fp_enabled = 1;
+    my $sve_enabled = 1;
     my $big_endian = 0;
     my ($infile, $outfile);
 
@@ -334,6 +335,7 @@ sub main()
                 },
                 "be" => sub { $big_endian = 1; },
                 "no-fp" => sub { $fp_enabled = 0; },
+                "sve" => sub { $sve_enabled = 1; },
         ) or return 1;
     # allow "--pattern re,re" and "--pattern re --pattern re"
     @pattern_re = split(/,/,join(',',@pattern_re));
@@ -361,6 +363,7 @@ sub main()
         'fpscr' => $fpscr,
         'numinsns' => $numinsns,
         'fp_enabled' => $fp_enabled,
+        'sve_enabled' => $sve_enabled,
         'outfile' => $outfile,
         'details' => \%insn_details,
         'keys' => \@insn_keys,
risugen_arm.pm +0 -0
index 2f10d58..8d1e1fd 100644

risugen_arm.pm sub write_random_aarch64_fpdata() · line 479

Quoted 10 lines
risugen_arm.pm +4 -2
@@ -472,9 +472,47 @@ sub write_random_aarch64_fpdata()
     }
 }
 
-sub write_random_aarch64_regdata($)
+sub write_random_aarch64_svedata()
 {
-    my ($fp_enabled) = @_;
+    # Load SVE registers
+    my $align = 16;
+    my $vl = 16;                             # number of vqs

Would this be better phrased

	my $vq = 16;				# quadwords per vector
Quoted 20 lines
risugen_arm.pm +20 -0
+    my $datalen = (32 * $vl * 16) + $align;
+
+    write_pc_adr(0, (3 * 4) + ($align - 1)); # insn 1
+    write_align_reg(0, $align);              # insn 2
+    write_jump_fwd($datalen);                # insn 3
+
+    # align safety
+    for (my $i = 0; $i < ($align / 4); $i++) {
+        # align with nops
+        insn32(0xd503201f);
+    };
+
+    for (my $rt = 0; $rt <= 31; $rt++) {
+        for (my $q = 0; $q < $vl; $q++) {
+            write_random_fpreg_var(4); # quad
+        }
+    }
+
+    # Reset all the predicate registers to all true
+    for (my $p = 0; $p < 16; $p++) {

risugen_arm.pm sub write_random_aarch64_fpdata() · line 509

Quoted 10 lines
risugen_arm.pm +10 -0
+        insn32(0x2518e3e0 | $p);
+    }
+
+    # there is no post index load so we do this by hand
+    write_mov_ri(1, 0);
+    for (my $rt = 0; $rt <= 31; $rt++) {
+        # ld1d    z0.d, p0/z, [x0, x1, lsl #3]
+        insn32(0xa5e14000 | $rt);
+        # incp    x1, p0.d
+        insn32(0x25ec8801);

You could avoid this with the unpredicated form LDR (vector). (LD1x scalar+immediate doesn't provide enough immediate range).

Quoted 4 lines
	# ldr	z$rt, [x0, #$rt, mul vl]
	insn32(0x85804000 + $rt + (($rt & 7) << 10) + (($rt & 0x18) << 13));

which is what the kernel does.

Ahh thanks.

Quoted 2 lines

No harm in exercising different instructions though! The kernel uses embarrassingly few.

Well that's what the actual random instructions are for. I haven't yet considered if we need to group things together to properly exercise the predicate code. So far RISU doesn't exercise conditional branches as it's hard to do that without generating code that would lock up. It's very much the "easy 80%" of instructions we target.

Quoted 4 lines

Does it matter that the stride will depend on the actual current VL? If x0 just points to a block of random data, I guess it doesn't matter:
some trailing data remains unused, but that doesn't make the used data any less random.

Not really. We do try and re-generate every N instructions so all the floats don't just denormalise.

Quoted 5 lines

[...]

Cheers
---Dave

--
Alex Bennée

#14 lore raw

PATCH 8/10 aarch64.risu: initial SVE instruction

In reply to Alex Bennée
---
 aarch64.risu | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
aarch64.risu +24 -0
index 838bded..bfa4ff8 100644
@@ -2937,3 +2937,27 @@ FCVTZUsi_RES A64_V sf:1 0011110 1 type:1 1 11 001 000000 rn:5 rd:5
 # End of:
 # Data processing - SIMD and floating point
 # Data processing - Scalar Floating-Point and Advanced SIMD
+
+# SVE Instructions
+# Top-level Encodings
+#
+# 31            24 | 23 22 | 21      17 | 16 | 15    10 | 9                 0
+#  y y y y y y y m |  -  - |  m m m m m |  - |          | - - - - - - - - - -
+#
+@SVE
+
+# SVE Integer Arithmetic - Binary Predicated Group
+# 31            24 | 23  22 | 21 | 20  19 | 18 16 | 15  13 | 12           0
+#  0 0 0 0 0 1 0 0 |  size  |  0 |   op   |  ---  |  0 0 0 | ------------- |
+
+SVE_INTA_PRED_UNALL A64_V 00000100 ig:2 010 001 000 ignore2:13
+
+# - SVE integer add/subtract vectors (predicated)
+# 31            24 | 23 22 | 21  19 | 18 16 | 15  13 | 12  10 | 9  5 | 4  0 |
+#  0 0 0 0 0 1 0 0 |  size |  0 0 0 |  opc  |  0 0 0 |   Pg   |  Zm  |  Zn  |
+# opc 010/1xx are UNALLOCATED
+
+SVE_INT_ADDSUB_PRED A64_V 00000100 sz:2 000 opc:3 000 pg:3 zm:5 zn:5
+
+@
+# End of SVE instructions
Signature · 1 line
2.14.2
#15 lore raw

PATCH 9/10 risu_reginfo_aarch64: add reginfo_copy_sve

In reply to Alex Bennée

Add the ability to save SVE registers from the signal context. This is controlled with an optional flag --test-sve. The whole thing is conditionally compiled when SVE support is in the sigcontext headers.

Technically SVE registers could be beyond an EXTRA_MAGIC section. I've not seen this on the model so currently we abort() if we encounter the EXTRA_MAGIC section.

---
 risu_reginfo_aarch64.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
 risu_reginfo_aarch64.h |  8 ++++++
 2 files changed, 82 insertions(+)
risu_reginfo_aarch64.c +74 -0
index 38ad338..7c97790 100644
@@ -13,12 +13,78 @@
 #include <stdio.h>
 #include <ucontext.h>
 #include <string.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdbool.h>
 
 #include "risu.h"
 #include "risu_reginfo_aarch64.h"
 
+#ifndef SVE_MAGIC
 void *arch_long_opts;
 char *arch_extra_help;
+#else
+/* Should we test SVE register state */
+static int test_sve;
+static struct option extra_opts[] = {
+    {"test-sve", no_argument, &test_sve, 1},
+    {0, 0, 0, 0}
+};
+
+void *arch_long_opts = &extra_opts[0];
+char *arch_extra_help = "  --test-sve        Compare SVE registers\n";
+
+/* Extra SVE copy function, only called with --test-sve */
+static void reginfo_copy_sve(struct reginfo *ri, struct _aarch64_ctx *ctx)
+{
+    struct sve_context *sve;
+    int r, vq;
+    bool found = false;
+
+    while (!found) {
+       switch (ctx->magic)
+       {
+          case SVE_MAGIC:
+             found = true;
+             break;
+          case EXTRA_MAGIC:
+             fprintf(stderr, "%s: found EXTRA_MAGIC\n", __func__);
+             abort();
+          case 0:
+             /* We might not have an SVE context */
+             fprintf(stderr, "%s: reached end of ctx, no joy (%d)\n", __func__, ctx->size);
+             return;
+          default:
+             ctx = (struct _aarch64_ctx *)((void *)ctx + ctx->size);
+             break;
+       }
+
+    }
+
+    sve = (struct sve_context *) ctx;
+    ri->vl = sve->vl;
+    vq = sve_vq_from_vl(sve->vl); /* number of quads for whole vl */
+
+    /* Copy ZREG's one at a time */
+    for (r = 0; r < SVE_NUM_ZREGS; r++) {
+        memcpy(&ri->zregs[r],
+               (char *)sve + SVE_SIG_ZREG_OFFSET(vq, r),
+               SVE_SIG_ZREG_SIZE(vq));
+    }
+
+    /* Copy PREG's one at a time */
+    for (r = 0; r < SVE_NUM_PREGS; r++) {
+        memcpy(&ri->pregs[r],
+               (char *)sve + SVE_SIG_PREG_OFFSET(vq, r),
+               SVE_SIG_PREG_SIZE(vq));
+    }
+
+    /* Finally the FFR */
+    memcpy(&ri->ffr,(char *)sve + SVE_SIG_FFR_OFFSET(vq),
+               SVE_SIG_FFR_SIZE(vq));
+
+}
+#endif
 
 /* reginfo_init: initialize with a ucontext */
 void reginfo_init(struct reginfo *ri, ucontext_t *uc)
@@ -26,6 +92,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
     int i;
     struct _aarch64_ctx *ctx;
     struct fpsimd_context *fp;
+
     /* necessary to be able to compare with memcmp later */
     memset(ri, 0, sizeof(*ri));
 
@@ -59,6 +126,13 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
     for (i = 0; i < 32; i++) {
         ri->vregs[i] = fp->vregs[i];
     }
+
+#ifdef SVE_MAGIC
+    if (test_sve) {
+        ctx = (struct _aarch64_ctx *) &uc->uc_mcontext.__reserved[0];
+        reginfo_copy_sve(ri, ctx);
+    }
+#endif
 };
 
 /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */
risu_reginfo_aarch64.h +8 -0
index a05fb4e..317383f 100644
@@ -25,6 +25,14 @@ struct reginfo {
     uint32_t fpsr;
     uint32_t fpcr;
     __uint128_t vregs[32];
+
+#ifdef SVE_MAGIC
+    /* SVE */
+    uint16_t    vl; /* current VL */
+    __uint128_t zregs[SVE_NUM_ZREGS][SVE_VQ_MAX];
+    uint16_t    pregs[SVE_NUM_PREGS][SVE_VQ_MAX];
+    uint16_t    ffr[SVE_VQ_MAX];
+#endif
 };
 
 #endif /* RISU_REGINFO_AARCH64_H */
Signature · 1 line
2.14.2
#16 lore raw

Re: [RISU PATCH 09/10] risu_reginfo_aarch64: add reginfo_copy_sve

Quoted 106 lines · Alex Bennée

Add the ability to save SVE registers from the signal context. This is controlled with an optional flag --test-sve. The whole thing is conditionally compiled when SVE support is in the sigcontext headers.

Technically SVE registers could be beyond an EXTRA_MAGIC section. I've not seen this on the model so currently we abort() if we encounter the EXTRA_MAGIC section.

---
 risu_reginfo_aarch64.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
 risu_reginfo_aarch64.h |  8 ++++++
 2 files changed, 82 insertions(+)
risu_reginfo_aarch64.c +67 -0
index 38ad338..7c97790 100644
@@ -13,12 +13,78 @@
 #include <stdio.h>
 #include <ucontext.h>
 #include <string.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdbool.h>
 
 #include "risu.h"
 #include "risu_reginfo_aarch64.h"
 
+#ifndef SVE_MAGIC
 void *arch_long_opts;
 char *arch_extra_help;
+#else
+/* Should we test SVE register state */
+static int test_sve;
+static struct option extra_opts[] = {
+    {"test-sve", no_argument, &test_sve, 1},
+    {0, 0, 0, 0}
+};
+
+void *arch_long_opts = &extra_opts[0];
+char *arch_extra_help = "  --test-sve        Compare SVE registers\n";
+
+/* Extra SVE copy function, only called with --test-sve */
+static void reginfo_copy_sve(struct reginfo *ri, struct _aarch64_ctx *ctx)
+{
+    struct sve_context *sve;
+    int r, vq;
+    bool found = false;
+
+    while (!found) {
+       switch (ctx->magic)
+       {
+          case SVE_MAGIC:
+             found = true;
+             break;
+          case EXTRA_MAGIC:
+             fprintf(stderr, "%s: found EXTRA_MAGIC\n", __func__);
+             abort();
+          case 0:
+             /* We might not have an SVE context */
+             fprintf(stderr, "%s: reached end of ctx, no joy (%d)\n", __func__, ctx->size);
+             return;
+          default:
+             ctx = (struct _aarch64_ctx *)((void *)ctx + ctx->size);
+             break;
+       }
+
+    }
+
+    sve = (struct sve_context *) ctx;
+    ri->vl = sve->vl;
+    vq = sve_vq_from_vl(sve->vl); /* number of quads for whole vl */
+
+    /* Copy ZREG's one at a time */
+    for (r = 0; r < SVE_NUM_ZREGS; r++) {
+        memcpy(&ri->zregs[r],
+               (char *)sve + SVE_SIG_ZREG_OFFSET(vq, r),
+               SVE_SIG_ZREG_SIZE(vq));
+    }
+
+    /* Copy PREG's one at a time */
+    for (r = 0; r < SVE_NUM_PREGS; r++) {
+        memcpy(&ri->pregs[r],
+               (char *)sve + SVE_SIG_PREG_OFFSET(vq, r),
+               SVE_SIG_PREG_SIZE(vq));
+    }
+
+    /* Finally the FFR */
+    memcpy(&ri->ffr,(char *)sve + SVE_SIG_FFR_OFFSET(vq),
+               SVE_SIG_FFR_SIZE(vq));
+
+}
+#endif
 
 /* reginfo_init: initialize with a ucontext */
 void reginfo_init(struct reginfo *ri, ucontext_t *uc)
@@ -26,6 +92,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
     int i;
     struct _aarch64_ctx *ctx;
     struct fpsimd_context *fp;
+
     /* necessary to be able to compare with memcmp later */
     memset(ri, 0, sizeof(*ri));
 

risu_reginfo_aarch64.c void reginfo_init(struct reginfo *ri, ucontext_t *uc) · line 129

Quoted 4 lines
risu_reginfo_aarch64.c +1 -0
@@ -59,6 +126,13 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
     for (i = 0; i < 32; i++) {
         ri->vregs[i] = fp->vregs[i];
     }
+

Where do you get uc from?

If it comes straight out of a signal frame that's OK, but if it's copied around as a ucontext_t or manipulated by getcontext() etc this is going to go wrong when extra_context is present.

This code may get used by people as a reference, so at least adding a comment to the effect that this only works on the signal frame would be a good idea.

When you add support for extra_context, you should probably add a sanity-check to ensure that the datap pointer really does point to the right place -- see <asm/sigcontext.h>.

Even though the kernel _should_ never violate this, it can be violated by ucontext_t manipulation in userspace, so any function that doesn't know where its ucontext_t came from should do this check.

[...]

Cheers
---Dave

#17 lore raw

PATCH 10/10 risu_reginfo_aarch64: add SVE support to reginfo_dump_mismatch

In reply to Alex Bennée
---
 risu_reginfo_aarch64.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
risu_reginfo_aarch64.c +49 -0
index 7c97790..8aba192 100644
@@ -141,6 +141,18 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2)
     return memcmp(r1, r2, sizeof(*r1)) == 0;
 }
 
+#ifdef SVE_MAGIC
+static int sve_zreg_is_eq(struct reginfo *r1, struct reginfo *r2, int z)
+{
+    return memcmp(r1->zregs[z], r2->zregs[z], sizeof(*r1->zregs[z])) == 0;
+}
+
+static int sve_preg_is_eq(struct reginfo *r1, struct reginfo *r2, int p)
+{
+    return memcmp(r1->pregs[p], r2->pregs[p], sizeof(*r1->pregs[p])) == 0;
+}
+#endif
+
 /* reginfo_dump: print state to a stream, returns nonzero on success */
 int reginfo_dump(struct reginfo *ri, FILE * f)
 {
@@ -216,5 +228,42 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
         }
     }
 
+#ifdef SVE_MAGIC
+    if (test_sve) {
+        if (m->vl != a->vl) {
+            fprintf(f, "  SVE VL  : %d vs %d\n", m->vl, a->vl);
+        }
+        for (i = 0; i < SVE_NUM_PREGS; i++) {
+           if (!sve_preg_is_eq(m, a, i)) {
+              int q;
+              fprintf(f, "  P%2d   : ", i);
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 fprintf(f, "%04x", m->pregs[i][q]);
+              }
+              fprintf(f, " vs ");
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 fprintf(f, "%04x", a->pregs[i][q]);
+              }
+              fprintf(f, "\n");
+            }
+        }
+        for (i = 0; i < SVE_NUM_ZREGS; i++) {
+           if (!sve_zreg_is_eq(m, a, i)) {
+              int q;
+              char *pad="";
+              fprintf(f, "  Z%2d   : ", i);
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 if (m->zregs[i][q] != a->zregs[i][q]) {
+                    fprintf(f, "%sq%02d: %016" PRIx64 "%016" PRIx64 " vs %016" PRIx64 "%016" PRIx64"\n", pad, q,
+                            (uint64_t) (m->zregs[i][q] >> 64), (uint64_t) m->zregs[i][q],
+                            (uint64_t) (a->zregs[i][q] >> 64), (uint64_t) a->zregs[i][q]);
+                    pad = "          ";
+                 }
+              }
+           }
+        }
+    }
+#endif
+
     return !ferror(f);
 }
Signature · 1 line
2.14.2
#18 lore raw

Re: [RISU PATCH 10/10] risu_reginfo_aarch64: add SVE support to reginfo_dump_mismatch

Quoted 56 lines · Alex Bennée
---
 risu_reginfo_aarch64.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
risu_reginfo_aarch64.c +36 -0
index 7c97790..8aba192 100644
@@ -141,6 +141,18 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2)
     return memcmp(r1, r2, sizeof(*r1)) == 0;
 }
 
+#ifdef SVE_MAGIC
+static int sve_zreg_is_eq(struct reginfo *r1, struct reginfo *r2, int z)
+{
+    return memcmp(r1->zregs[z], r2->zregs[z], sizeof(*r1->zregs[z])) == 0;
+}
+
+static int sve_preg_is_eq(struct reginfo *r1, struct reginfo *r2, int p)
+{
+    return memcmp(r1->pregs[p], r2->pregs[p], sizeof(*r1->pregs[p])) == 0;
+}
+#endif
+
 /* reginfo_dump: print state to a stream, returns nonzero on success */
 int reginfo_dump(struct reginfo *ri, FILE * f)
 {
@@ -216,5 +228,42 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
         }
     }
 
+#ifdef SVE_MAGIC
+    if (test_sve) {
+        if (m->vl != a->vl) {
+            fprintf(f, "  SVE VL  : %d vs %d\n", m->vl, a->vl);
+        }
+        for (i = 0; i < SVE_NUM_PREGS; i++) {
+           if (!sve_preg_is_eq(m, a, i)) {
+              int q;
+              fprintf(f, "  P%2d   : ", i);
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 fprintf(f, "%04x", m->pregs[i][q]);
+              }
+              fprintf(f, " vs ");
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 fprintf(f, "%04x", a->pregs[i][q]);
+              }
+              fprintf(f, "\n");
+            }
+        }
+        for (i = 0; i < SVE_NUM_ZREGS; i++) {
+           if (!sve_zreg_is_eq(m, a, i)) {
+              int q;
+              char *pad="";
+              fprintf(f, "  Z%2d   : ", i);

risu_reginfo_aarch64.c int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) · line 264

Quoted 10 lines
risu_reginfo_aarch64.c +10 -0
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 if (m->zregs[i][q] != a->zregs[i][q]) {
+                    fprintf(f, "%sq%02d: %016" PRIx64 "%016" PRIx64 " vs %016" PRIx64 "%016" PRIx64"\n", pad, q,
+                            (uint64_t) (m->zregs[i][q] >> 64), (uint64_t) m->zregs[i][q],
+                            (uint64_t) (a->zregs[i][q] >> 64), (uint64_t) a->zregs[i][q]);
+                    pad = "          ";
+                 }
+              }
+           }
+        }

No FFR?

Perhaps I should have explicitly encoded FFR as "P16" -- that sort of works and saves some open-coding of the extra special case, but it feels less correct.

You could do

static int sve_preg_is_eq(uint16_t const (*p1)[SVE_VQ_MAX],

				uint16_t const (*p2)[SVE_VQ_MAX])
{
	return memcmp(p1, p2, sizeof *p1) == 0;
}

/* ... */

sve_preg_is_eq(&r1->pregs[p], &r2->pregs[p])

/* ... */

sve_preg_is_eq(&r1->ffr, &r2->ffr)

(or some variation on this theme). ffr is a specialised predicate register, so I think you can assume that it really does have the same type as pregs[p]. Coding the above way will give a typcheck error if not.

Cheers
---Dave

#19 lore raw

Re: [RISU PATCH 10/10] risu_reginfo_aarch64: add SVE support to reginfo_dump_mismatch

Quoted 70 lines · Dave Martin
Quoted 56 lines · Alex Bennée
---
 risu_reginfo_aarch64.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
risu_reginfo_aarch64.c +36 -0
index 7c97790..8aba192 100644
@@ -141,6 +141,18 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2)
     return memcmp(r1, r2, sizeof(*r1)) == 0;
 }
 
+#ifdef SVE_MAGIC
+static int sve_zreg_is_eq(struct reginfo *r1, struct reginfo *r2, int z)
+{
+    return memcmp(r1->zregs[z], r2->zregs[z], sizeof(*r1->zregs[z])) == 0;
+}
+
+static int sve_preg_is_eq(struct reginfo *r1, struct reginfo *r2, int p)
+{
+    return memcmp(r1->pregs[p], r2->pregs[p], sizeof(*r1->pregs[p])) == 0;
+}
+#endif
+
 /* reginfo_dump: print state to a stream, returns nonzero on success */
 int reginfo_dump(struct reginfo *ri, FILE * f)
 {
@@ -216,5 +228,42 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
         }
     }
 
+#ifdef SVE_MAGIC
+    if (test_sve) {
+        if (m->vl != a->vl) {
+            fprintf(f, "  SVE VL  : %d vs %d\n", m->vl, a->vl);
+        }
+        for (i = 0; i < SVE_NUM_PREGS; i++) {
+           if (!sve_preg_is_eq(m, a, i)) {
+              int q;
+              fprintf(f, "  P%2d   : ", i);
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 fprintf(f, "%04x", m->pregs[i][q]);
+              }
+              fprintf(f, " vs ");
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 fprintf(f, "%04x", a->pregs[i][q]);
+              }
+              fprintf(f, "\n");
+            }
+        }
+        for (i = 0; i < SVE_NUM_ZREGS; i++) {
+           if (!sve_zreg_is_eq(m, a, i)) {
+              int q;
+              char *pad="";
+              fprintf(f, "  Z%2d   : ", i);

risu_reginfo_aarch64.c int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) · line 264

Quoted 10 lines
risu_reginfo_aarch64.c +10 -0
+              for (q = 0; q < sve_vq_from_vl(m->vl); q++) {
+                 if (m->zregs[i][q] != a->zregs[i][q]) {
+                    fprintf(f, "%sq%02d: %016" PRIx64 "%016" PRIx64 " vs %016" PRIx64 "%016" PRIx64"\n", pad, q,
+                            (uint64_t) (m->zregs[i][q] >> 64), (uint64_t) m->zregs[i][q],
+                            (uint64_t) (a->zregs[i][q] >> 64), (uint64_t) a->zregs[i][q]);
+                    pad = "          ";
+                 }
+              }
+           }
+        }

No FFR?

Quoted 3 lines

Perhaps I should have explicitly encoded FFR as "P16" -- that sort of works and saves some open-coding of the extra special case, but it feels less correct.

Oops, yeah missed that out. I'll add it to the next version.

Good catch!

Quoted 13 lines

You could do

static int sve_preg_is_eq(uint16_t const (*p1)[SVE_VQ_MAX],

				uint16_t const (*p2)[SVE_VQ_MAX])
{
	return memcmp(p1, p2, sizeof *p1) == 0;
}

/* ... */

sve_preg_is_eq(&r1->pregs[p], &r2->pregs[p])

Quoted 8 lines

/* ... */

sve_preg_is_eq(&r1->ffr, &r2->ffr)

(or some variation on this theme). ffr is a specialised predicate register, so I think you can assume that it really does have the same type as pregs[p]. Coding the above way will give a typcheck error if not.

Ahh ok thanks.

Quoted 3 lines

Cheers
---Dave

--
Alex Bennée

#20 lore raw
In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

Hi,

These patches apply on-top of the last clean-up series:

Subject: [RISU PATCH 0/7] Add @Group support and some aarch64.risu cleanups
Date: Tue, 31 Oct 2017 14:54:37 +0000
Message-Id: <[email protected]>

Quoted 5 lines

This series adds support for SVE to RISU. Most of the initial patches are plumbing changes to better support arch specific option flags (cleaning up a TODO in the process). I also needed to ensure configure actually honoured CPPFLAGS so it could be passed yet to be released headers.

Should there be a getauxval(AT_HWCAP) & HWCAP_SVE check in this series somewhere?

I don't know enough about how RISU is structured to know whether/where this is needed.

[...]

Cheers
---Dave

#21 lore raw
Quoted 15 lines · Dave Martin
Quoted 8 lines · Alex Bennée

Hi,

These patches apply on-top of the last clean-up series:

Subject: [RISU PATCH 0/7] Add @Group support and some aarch64.risu cleanups
Date: Tue, 31 Oct 2017 14:54:37 +0000
Message-Id: <[email protected]>

Quoted 5 lines

This series adds support for SVE to RISU. Most of the initial patches are plumbing changes to better support arch specific option flags (cleaning up a TODO in the process). I also needed to ensure configure actually honoured CPPFLAGS so it could be passed yet to be released headers.

Quoted 5 lines

Should there be a getauxval(AT_HWCAP) & HWCAP_SVE check in this series somewhere?

I don't know enough about how RISU is structured to know whether/where this is needed.

That would be a saner runtime check to do but it's a balance as RISU is a fairly specialist tool which kind of assumes people know what they are doing.

The current check is on SVE_MAGIC in the header files which does mean a binary compiled on an SVE headered system is now carrying about a much larger register dump even when run without the --test-sve flag.

Whether it makes sense to be more flexible is a call I'll leave up to Peter.

Quoted 5 lines

[...]

Cheers
---Dave

--
Alex Bennée

#22 lore raw
Quoted 28 lines · Alex Bennée
Quoted 15 lines · Dave Martin
Quoted 8 lines · Alex Bennée

Hi,

These patches apply on-top of the last clean-up series:

Subject: [RISU PATCH 0/7] Add @Group support and some aarch64.risu cleanups
Date: Tue, 31 Oct 2017 14:54:37 +0000
Message-Id: <[email protected]>

Quoted 5 lines

This series adds support for SVE to RISU. Most of the initial patches are plumbing changes to better support arch specific option flags (cleaning up a TODO in the process). I also needed to ensure configure actually honoured CPPFLAGS so it could be passed yet to be released headers.

Quoted 5 lines

Should there be a getauxval(AT_HWCAP) & HWCAP_SVE check in this series somewhere?

I don't know enough about how RISU is structured to know whether/where this is needed.

That would be a saner runtime check to do but it's a balance as RISU is a fairly specialist tool which kind of assumes people know what they are doing.

Quoted 6 lines

The current check is on SVE_MAGIC in the header files which does mean a binary compiled on an SVE headered system is now carrying about a much larger register dump even when run without the --test-sve flag.

Whether it makes sense to be more flexible is a call I'll leave up to Peter.

Fair enough. If there is anywhere useful to put it, it would serve as a useful example -- but as you point out, this is not a typical piece of userspace software...

Cheers
---Dave

#23 lore raw
In reply to Alex Bennée
Quoted 38 lines · Alex Bennée

Hi,

These patches apply on-top of the last clean-up series:

Subject: [RISU PATCH 0/7] Add @Group support and some aarch64.risu cleanups
Date: Tue, 31 Oct 2017 14:54:37 +0000
Message-Id: <[email protected]>

This series adds support for SVE to RISU. Most of the initial patches are plumbing changes to better support arch specific option flags (cleaning up a TODO in the process). I also needed to ensure configure actually honoured CPPFLAGS so it could be passed yet to be released headers.

The actual guts of the SVE support is in 3 patches. One to risugen so it can generate random values for the vector registers. If this isn't done you get inconsistent runs because of left over junk in the registers. The remaining two patches add support for copying the SVE vectors from the signal context and dumping any differences found.

To test this I ran on the Foundation model with:

  ${RTSM_MODEL} --no-secure-memory --gicv3 --data=${BL1_FIRMWARE}@0x0 --data=${FIP_FIRMWARE}@0x8000000 \
                --semihost --network nat --network-nat-ports=8022=22 --block-device ${DISK_IMAGE}

With my hacked up copy of secure firmware to ensure SVE is enabled. You also need a kernel with SVE support:

Subject: [PATCH v5 00/30] ARM Scalable Vector Extension (SVE)
Date: Tue, 31 Oct 2017 15:50:52 +0000
Message-Id: <[email protected]>

My testing so far has been to ensure that each run on the foundation model is deterministic (same m5sum on each trace) and that differences are printed out when the user-space vector length is tweaked (/proc/sys/abi/sve_default_vector_length).

Quoted 11 lines

Alex Bennée (10):
build-all-arches: drop -t (for tty) from docker invocation risu.c: split out setting up options
risu.c: add missing --trace longopt
risu: move optional args to each architecture
configure: allow repeated invocation of configure in build dir
configure: support CPPFLAGS
risugen: add --sve support
aarch64.risu: initial SVE instruction
risu_reginfo_aarch64: add reginfo_copy_sve
risu_reginfo_aarch64: add SVE support to reginfo_dump_mismatch

I've applied patches 1, 2, 3, 5, 6 to risu master.

thanks
-- PMM