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>
This commit is contained in:
John Bates 2020-12-03 11:37:33 -08:00 committed by Commit Bot
parent 2f6d79efdf
commit 0d9d0e3c85
4 changed files with 22 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,