|
Lines 22-27
Link Here
|
| 22 |
#include "base/macros.h" |
22 |
#include "base/macros.h" |
| 23 |
#include "base/memory/scoped_ptr.h" |
23 |
#include "base/memory/scoped_ptr.h" |
| 24 |
#include "build/build_config.h" |
24 |
#include "build/build_config.h" |
|
|
25 |
// Auto-generated for dlopen libva libraries |
| 26 |
#include "content/common/gpu/media/va_stubs.h" |
| 25 |
#include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" |
27 |
#include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" |
| 26 |
#include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" |
28 |
#include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" |
| 27 |
#include "content/common/set_process_title.h" |
29 |
#include "content/common/set_process_title.h" |
|
Lines 32-37
Link Here
|
| 32 |
#include "sandbox/linux/syscall_broker/broker_file_permission.h" |
34 |
#include "sandbox/linux/syscall_broker/broker_file_permission.h" |
| 33 |
#include "sandbox/linux/syscall_broker/broker_process.h" |
35 |
#include "sandbox/linux/syscall_broker/broker_process.h" |
| 34 |
#include "sandbox/linux/system_headers/linux_syscalls.h" |
36 |
#include "sandbox/linux/system_headers/linux_syscalls.h" |
|
|
37 |
#include "third_party/libva/va/va.h" |
| 38 |
#include "third_party/libva/va/va_x11.h" |
| 35 |
|
39 |
|
| 36 |
using sandbox::arch_seccomp_data; |
40 |
using sandbox::arch_seccomp_data; |
| 37 |
using sandbox::bpf_dsl::Allow; |
41 |
using sandbox::bpf_dsl::Allow; |
|
Lines 41-46
using sandbox::syscall_broker::BrokerFil
Link Here
|
| 41 |
using sandbox::syscall_broker::BrokerProcess; |
45 |
using sandbox::syscall_broker::BrokerProcess; |
| 42 |
using sandbox::SyscallSets; |
46 |
using sandbox::SyscallSets; |
| 43 |
|
47 |
|
|
|
48 |
using content_common_gpu_media::kModuleVa; |
| 49 |
using content_common_gpu_media::kModuleVa_x11; |
| 50 |
using content_common_gpu_media::InitializeStubs; |
| 51 |
using content_common_gpu_media::StubPathMap; |
| 52 |
|
| 44 |
namespace content { |
53 |
namespace content { |
| 45 |
|
54 |
|
| 46 |
namespace { |
55 |
namespace { |
|
Lines 95-101
inline bool UseLibV4L2() {
Link Here
|
| 95 |
|
104 |
|
| 96 |
bool IsAcceleratedVaapiVideoEncodeEnabled() { |
105 |
bool IsAcceleratedVaapiVideoEncodeEnabled() { |
| 97 |
bool accelerated_encode_enabled = false; |
106 |
bool accelerated_encode_enabled = false; |
| 98 |
#if defined(OS_CHROMEOS) |
107 |
#if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 99 |
const base::CommandLine& command_line = |
108 |
const base::CommandLine& command_line = |
| 100 |
*base::CommandLine::ForCurrentProcess(); |
109 |
*base::CommandLine::ForCurrentProcess(); |
| 101 |
accelerated_encode_enabled = |
110 |
accelerated_encode_enabled = |
|
Lines 300-326
bool GpuProcessPolicy::PreSandboxHook()
Link Here
|
| 300 |
// inside the sandbox, so preload them now. |
309 |
// inside the sandbox, so preload them now. |
| 301 |
if (IsAcceleratedVaapiVideoEncodeEnabled() || |
310 |
if (IsAcceleratedVaapiVideoEncodeEnabled() || |
| 302 |
IsAcceleratedVideoDecodeEnabled()) { |
311 |
IsAcceleratedVideoDecodeEnabled()) { |
| 303 |
const char* I965DrvVideoPath = NULL; |
312 |
VLOG(1) << "Attempting to enable hardware video acceleration."; |
| 304 |
const char* I965HybridDrvVideoPath = NULL; |
313 |
StubPathMap paths; |
|
|
314 |
paths[kModuleVa].push_back("libva.so.1"); |
| 315 |
paths[kModuleVa_x11].push_back("libva-x11.so.1"); |
| 316 |
if (!InitializeStubs(paths)) { |
| 317 |
VLOG(1) << "Failed to initialize stubs"; |
| 318 |
return false; |
| 319 |
} |
| 305 |
|
320 |
|
| 306 |
if (IsArchitectureX86_64()) { |
321 |
// libva drivers won't get loaded even above two libraries get dlopened. |
| 307 |
I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so"; |
322 |
// Thus, libva calls will fail after post sandbox stage. |
| 308 |
I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so"; |
323 |
// |
| 309 |
} else if (IsArchitectureI386()) { |
324 |
// To get the va driver loaded before sandboxing, upstream simply dlopen |
| 310 |
I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so"; |
325 |
// the hard-coded va driver path because ChromeOS is the only platform |
|
|
326 |
// that Google want to support libva. |
| 327 |
// |
| 328 |
// While generic linux distros ship va driver as anywhere they want. |
| 329 |
// Fortunately, the va driver will be loadded when vaInitialize() get |
| 330 |
// called. |
| 331 |
// So the following code is to call vaInitialize() before sandboxing. |
| 332 |
Display* x_display = XOpenDisplay(NULL); |
| 333 |
VADisplay va_display = vaGetDisplay(x_display); |
| 334 |
if (!vaDisplayIsValid(va_display)) { |
| 335 |
VLOG(1) << "Failed to call vaGetDisplay()"; |
| 336 |
return false; |
| 311 |
} |
337 |
} |
| 312 |
|
338 |
|
| 313 |
dlopen(I965DrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
339 |
int major_version, minor_version; |
| 314 |
if (I965HybridDrvVideoPath) |
340 |
if (vaInitialize(va_display, &major_version, &minor_version) |
| 315 |
dlopen(I965HybridDrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
341 |
!= VA_STATUS_SUCCESS) { |
| 316 |
dlopen("libva.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
342 |
VLOG(1) << "Failed to call vaInitialize()"; |
| 317 |
#if defined(USE_OZONE) |
343 |
return false; |
| 318 |
dlopen("libva-drm.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
344 |
} |
| 319 |
#elif defined(USE_X11) |
345 |
} // end of IsAcceleratedVaapiVideoEncodeEnabled() || IsAcceleratedVideoDecodeEnabled() |
| 320 |
dlopen("libva-x11.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
346 |
} // end of IsArchitectureX86_64() || IsArchitectureI386() |
| 321 |
#endif |
|
|
| 322 |
} |
| 323 |
} |
| 324 |
|
347 |
|
| 325 |
return true; |
348 |
return true; |
| 326 |
} |
349 |
} |