diff options
author | John Bates <jbates@chromium.org> | 2020-12-03 11:37:33 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-10 04:40:43 +0000 |
commit | 0d9d0e3c85ff0f96a6c56c07a3b0ba83e4e293ce (patch) | |
tree | ba39fdd5cf6590a5afc81b5f0c6e7b9dea907113 | |
parent | 2f6d79efdf9210822fcc7866b4846d455ab49442 (diff) | |
download | crosvm-0d9d0e3c85ff0f96a6c56c07a3b0ba83e4e293ce.tar.gz |
Allow perfetto tracing from crosvm gpu process
New syscalls and /run/perfetto bind mount are required.
BUG=b:174162684
TEST=Run crosvm with perfetto instrumentation and confirm that
events can be traced through traced. Tested on both hatch
and ARM kukui device.
Cq-Depend: chromium:2570487
Change-Id: I809400ec393c2971ba9a1134ddbef7f48d818786
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2571659
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: John Bates <jbates@chromium.org>
Commit-Queue: John Bates <jbates@chromium.org>
-rw-r--r-- | seccomp/aarch64/gpu_device.policy | 4 | ||||
-rw-r--r-- | seccomp/arm/gpu_device.policy | 4 | ||||
-rw-r--r-- | seccomp/x86_64/gpu_device.policy | 8 | ||||
-rw-r--r-- | src/linux.rs | 7 |
4 files changed, 22 insertions, 1 deletions
diff --git a/seccomp/aarch64/gpu_device.policy b/seccomp/aarch64/gpu_device.policy index 14a939097..4d91b6e8b 100644 --- a/seccomp/aarch64/gpu_device.policy +++ b/seccomp/aarch64/gpu_device.policy @@ -42,6 +42,10 @@ sigaltstack: 1 write: 1 writev: 1 +# Required for perfetto tracing +getsockopt: 1 +shutdown: 1 + ## Rules specific to gpu connect: 1 getrandom: 1 diff --git a/seccomp/arm/gpu_device.policy b/seccomp/arm/gpu_device.policy index 793265a9e..0f5936d59 100644 --- a/seccomp/arm/gpu_device.policy +++ b/seccomp/arm/gpu_device.policy @@ -44,6 +44,10 @@ sigaltstack: 1 write: 1 writev: 1 +# Required for perfetto tracing +getsockopt: 1 +shutdown: 1 + ## Rules specific to gpu connect: 1 getrandom: 1 diff --git a/seccomp/x86_64/gpu_device.policy b/seccomp/x86_64/gpu_device.policy index f55671475..9d25f45d3 100644 --- a/seccomp/x86_64/gpu_device.policy +++ b/seccomp/x86_64/gpu_device.policy @@ -47,7 +47,8 @@ writev: 1 # Rules specific to gpu connect: 1 -fcntl: arg1 == F_DUPFD_CLOEXEC +fcntl: arg1 == F_DUPFD_CLOEXEC || arg1 == F_SETFD || arg1 == F_GETFL || \ + arg1 == F_SETFL fstat: 1 # Used to set of size new memfd. ftruncate: 1 @@ -71,6 +72,11 @@ stat: 1 statx: 1 sysinfo: 1 +# Required for perfetto tracing +# fcntl: arg1 == F_SETFD || arg1 == F_GETFL || arg1 == F_SETFL (merged above) +getsockopt: 1 +shutdown: 1 + # Rules for Mesa's shader binary cache. flock: 1 mkdir: 1 diff --git a/src/linux.rs b/src/linux.rs index 2e31efe69..57f9a8b04 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -848,6 +848,13 @@ fn create_gpu_device( (libc::MS_NOSUID | libc::MS_NODEV | libc::MS_NOEXEC | libc::MS_RDONLY) as usize, )?; + // To enable perfetto tracing, we need to give access to the perfetto service IPC + // endpoints. + let perfetto_path = Path::new("/run/perfetto"); + if perfetto_path.exists() { + jail.mount_bind(perfetto_path, perfetto_path, true)?; + } + Some(jail) } None => None, |