@@ -23,6 +23,7 @@
extern const struct option * const arch_long_opts;
extern const char * const arch_extra_help;
void process_arch_opt(int opt, const char *arg);
+void arch_init(void);
#define FIRST_ARCH_OPT 0x100
/* GCC computed include to pull in the correct risu_reginfo_*.h for
@@ -617,6 +617,9 @@ int main(int argc, char **argv)
load_image(imgfile);
+ /* E.g. select requested SVE vector length. */
+ arch_init();
+
if (ismaster) {
return master();
} else {
@@ -19,6 +19,7 @@
#include <stdbool.h>
#include <inttypes.h>
#include <assert.h>
+#include <errno.h>
#include <sys/prctl.h>
#include "risu.h"
@@ -37,8 +38,6 @@ const char * const arch_extra_help
void process_arch_opt(int opt, const char *arg)
{
- long want, got;
-
assert(opt == FIRST_ARCH_OPT);
test_sve = strtol(arg, 0, 10);
@@ -46,16 +45,26 @@ void process_arch_opt(int opt, const char *arg)
fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX);
exit(EXIT_FAILURE);
}
- want = sve_vl_from_vq(test_sve);
- got = prctl(PR_SVE_SET_VL, want);
- if (want != got) {
- if (got < 0) {
- perror("prctl PR_SVE_SET_VL");
- } else {
- fprintf(stderr, "Unsupported value for VQ (%d != %d)\n",
- test_sve, (int)sve_vq_from_vl(got));
+}
+
+void arch_init(void)
+{
+ long want, got;
+
+ if (test_sve) {
+ want = sve_vl_from_vq(test_sve);
+ got = prctl(PR_SVE_SET_VL, want);
+ if (want != got) {
+ if (got >= 0) {
+ fprintf(stderr, "Unsupported VQ for SVE (%d != %d)\n",
+ test_sve, (int)sve_vq_from_vl(got));
+ } else if (errno == EINVAL) {
+ fprintf(stderr, "System does not support SVE\n");
+ } else {
+ perror("prctl PR_SVE_SET_VL");
+ }
+ exit(EXIT_FAILURE);
}
- exit(EXIT_FAILURE);
}
}
@@ -36,6 +36,10 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
+void arch_init(void)
+{
+}
+
int reginfo_size(struct reginfo *ri)
{
return sizeof(*ri);
@@ -74,6 +74,10 @@ void process_arch_opt(int opt, const char *arg)
}
}
+void arch_init(void)
+{
+}
+
int reginfo_size(struct reginfo *ri)
{
return sizeof(*ri);
@@ -23,6 +23,10 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
+void arch_init(void)
+{
+}
+
int reginfo_size(struct reginfo *ri)
{
return sizeof(*ri);
@@ -32,6 +32,10 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
+void arch_init(void)
+{
+}
+
int reginfo_size(struct reginfo *ri)
{
return sizeof(*ri);
Adjust some of the aarch64 code to look at the reginfo struct instead of looking at test_sve, so that we do not need to pass the --test-sve option in order to dump sve trace files. Diagnose EINVAL as either cpu or kernel does not support SVE. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- risu.h | 1 + risu.c | 3 +++ risu_reginfo_aarch64.c | 31 ++++++++++++++++++++----------- risu_reginfo_arm.c | 4 ++++ risu_reginfo_i386.c | 4 ++++ risu_reginfo_m68k.c | 4 ++++ risu_reginfo_ppc64.c | 4 ++++ 7 files changed, 40 insertions(+), 11 deletions(-)