cpu-kvm: Added informative error message
authorRyan Gambord <gambordr@oregonstate.edu>
Thu, 21 Mar 2019 14:01:29 +0000 (07:01 -0700)
committerRyan Gambord <gambordr@oregonstate.edu>
Thu, 21 Mar 2019 14:24:48 +0000 (14:24 +0000)
PerfKvmCounter::attach fails if the user doesn't have privileges to make
the perf_event_open syscall. This is the default privilege setting since
kernel 4.6. I've seen some users in the mailing list resort to running
as root; changing the perf_event_paranoid setting is an alternative.

Change-Id: I2bc6f76abb6e97bf34b408a611f64b1910f50a43
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17508
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/cpu/kvm/perfevent.cc

index 5023b301e6bef9134750cc93d5d697a59abc41e9..0b5960d5136f5dfae41ad23bf281aa5549150cd1 100644 (file)
@@ -169,7 +169,18 @@ PerfKvmCounter::attach(PerfKvmCounterConfig &config,
                  group_fd,
                  0); // Flags
     if (fd == -1)
-        panic("PerfKvmCounter::open failed (%i)\n", errno);
+    {
+        if (errno == EACCES)
+        {
+            panic("PerfKvmCounter::attach recieved error EACCESS\n"
+            "  This error may be caused by a too restrictive setting\n"
+            "  in the file '/proc/sys/kernel/perf_event_paranoid'\n"
+            "  The default value was changed to 2 in kernel 4.6\n"
+            "  A value greater than 1 prevents gem5 from making\n"
+            "  the syscall to perf_event_open");
+        }
+        panic("PerfKvmCounter::attach failed (%i)\n", errno);
+    }
 
     mmapPerf(1);
 }