Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: content/common/sandbox_init_linux.cc

Issue 10824019: Tweak the GPU process sandbox to allow accelerated video decode. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix incorrect path for shared object. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_init_linux.cc
diff --git a/content/common/sandbox_init_linux.cc b/content/common/sandbox_init_linux.cc
index a67a784232aa70bcd6c856baf2546384bbab83da..2b5f9ef6baee3d7284f6613358776e48c2b60bc5 100644
--- a/content/common/sandbox_init_linux.cc
+++ b/content/common/sandbox_init_linux.cc
@@ -12,6 +12,7 @@
#endif
#include <asm/unistd.h>
+#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/audit.h>
@@ -146,6 +147,11 @@ bool IsFileSystemSyscall(int sysno) {
}
}
+bool EnabledAcceleratedVideoDecode() {
jln (very slow on Chromium) 2012/07/25 23:47:56 Rename to AcceleratedVideoDecodeIsEnabled() to bet
Jorge Lucangeli Obes 2012/07/26 00:43:28 Done.
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ return command_line.HasSwitch(switches::kEnableAcceleratedVideoDecode);
+}
+
static const char kDriRcPath[] = "/etc/drirc";
// TODO(jorgelo): limited to /etc/drirc for now, extend this to cover
@@ -270,10 +276,16 @@ playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) {
case __NR_fchmod:
return EPERM; // ATI binary driver.
case __NR_open:
- // Hook open() in the GPU process to allow opening /etc/drirc,
- // needed by Mesa.
- // The hook needs dup(), lseek(), and close() to be allowed.
- return playground2::Sandbox::ErrorCode(GpuOpenSIGSYS_Handler, NULL);
+ // Accelerated video decode is *not* enabled by default.
+ if (EnabledAcceleratedVideoDecode())
jln (very slow on Chromium) 2012/07/25 23:47:56 Style: please add braces around these multi lines
Jorge Lucangeli Obes 2012/07/26 00:43:28 Done.
+ // Accelerated video decode needs to open /dev/dri/card0, and
+ // dup()'ing an already open fd does not work.
jln (very slow on Chromium) 2012/07/25 23:47:56 Can you add a comment along the lines of: "This es
Jorge Lucangeli Obes 2012/07/26 00:43:28 Done.
+ return playground2::Sandbox::SB_ALLOWED;
+ else
+ // Hook open() in the GPU process to allow opening /etc/drirc,
+ // needed by Mesa.
+ // The hook needs dup(), lseek(), and close() to be allowed.
+ return playground2::Sandbox::ErrorCode(GpuOpenSIGSYS_Handler, NULL);
default:
if (IsGettimeSyscall(sysno) ||
IsKillSyscall(sysno)) { // GPU watchdog.
@@ -387,11 +399,19 @@ playground2::Sandbox::ErrorCode AllowAllPolicy(int sysno) {
}
}
+static const char kI965DrvVideoPath_64[] =
+ "/usr/lib64/va/drivers/i965_drv_video.so";
jln (very slow on Chromium) 2012/07/25 23:47:56 This should be scoped in the if with the dlopen be
Jorge Lucangeli Obes 2012/07/26 00:43:28 Unfortunately no. libva uses the full path when it
+
// Warms up/preloads resources needed by the policies.
void WarmupPolicy(playground2::Sandbox::EvaluateSyscall policy) {
#if defined(__x86_64__)
- if (policy == GpuProcessPolicy_x86_64)
+ if (policy == GpuProcessPolicy_x86_64) {
OpenWithCache(kDriRcPath, O_RDONLY);
+ // Accelerated video decode dlopen()'s this shared object
+ // inside the sandbox, so preload it now.
+ if (EnabledAcceleratedVideoDecode())
+ dlopen(kI965DrvVideoPath_64, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
+ }
#endif
}
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698