OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h" | 5 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 inline bool IsArchitectureArm() { | 67 inline bool IsArchitectureArm() { |
68 #if defined(__arm__) | 68 #if defined(__arm__) |
69 return true; | 69 return true; |
70 #else | 70 #else |
71 return false; | 71 return false; |
72 #endif | 72 #endif |
73 } | 73 } |
74 | 74 |
75 bool IsAcceleratedVideoDecodeEnabled() { | 75 bool IsAcceleratedVideoEnabled() { |
76 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 76 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
77 return !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode); | 77 bool accelerated_encode_enabled = false; |
| 78 #if defined(OS_CHROMEOS) |
| 79 accelerated_encode_enabled = |
| 80 command_line.HasSwitch(switches::kEnableVaapiAcceleratedVideoEncode); |
| 81 #endif |
| 82 return !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode) || |
| 83 accelerated_encode_enabled; |
78 } | 84 } |
79 | 85 |
80 intptr_t GpuSIGSYS_Handler(const struct arch_seccomp_data& args, | 86 intptr_t GpuSIGSYS_Handler(const struct arch_seccomp_data& args, |
81 void* aux_broker_process) { | 87 void* aux_broker_process) { |
82 RAW_CHECK(aux_broker_process); | 88 RAW_CHECK(aux_broker_process); |
83 BrokerProcess* broker_process = | 89 BrokerProcess* broker_process = |
84 static_cast<BrokerProcess*>(aux_broker_process); | 90 static_cast<BrokerProcess*>(aux_broker_process); |
85 switch (args.nr) { | 91 switch (args.nr) { |
86 case __NR_access: | 92 case __NR_access: |
87 return broker_process->Access(reinterpret_cast<const char*>(args.args[0]), | 93 return broker_process->Access(reinterpret_cast<const char*>(args.args[0]), |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 DCHECK(!chromeos_arm_gpu); | 213 DCHECK(!chromeos_arm_gpu); |
208 | 214 |
209 DCHECK(!broker_process()); | 215 DCHECK(!broker_process()); |
210 // Create a new broker process. | 216 // Create a new broker process. |
211 InitGpuBrokerProcess( | 217 InitGpuBrokerProcess( |
212 GpuBrokerProcessPolicy::Create, | 218 GpuBrokerProcessPolicy::Create, |
213 std::vector<std::string>(), // No extra files in whitelist. | 219 std::vector<std::string>(), // No extra files in whitelist. |
214 std::vector<std::string>()); | 220 std::vector<std::string>()); |
215 | 221 |
216 if (IsArchitectureX86_64() || IsArchitectureI386()) { | 222 if (IsArchitectureX86_64() || IsArchitectureI386()) { |
217 // Accelerated video decode dlopen()'s some shared objects | 223 // Accelerated video dlopen()'s some shared objects |
218 // inside the sandbox, so preload them now. | 224 // inside the sandbox, so preload them now. |
219 if (IsAcceleratedVideoDecodeEnabled()) { | 225 if (IsAcceleratedVideoEnabled()) { |
220 const char* I965DrvVideoPath = NULL; | 226 const char* I965DrvVideoPath = NULL; |
221 | 227 |
222 if (IsArchitectureX86_64()) { | 228 if (IsArchitectureX86_64()) { |
223 I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so"; | 229 I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so"; |
224 } else if (IsArchitectureI386()) { | 230 } else if (IsArchitectureI386()) { |
225 I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so"; | 231 I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so"; |
226 } | 232 } |
227 | 233 |
228 dlopen(I965DrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); | 234 dlopen(I965DrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
229 dlopen("libva.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); | 235 dlopen("libva.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), | 268 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), |
263 read_whitelist, | 269 read_whitelist, |
264 write_whitelist); | 270 write_whitelist); |
265 // The initialization callback will perform generic initialization and then | 271 // The initialization callback will perform generic initialization and then |
266 // call broker_sandboxer_callback. | 272 // call broker_sandboxer_callback. |
267 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, | 273 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, |
268 broker_sandboxer_allocator))); | 274 broker_sandboxer_allocator))); |
269 } | 275 } |
270 | 276 |
271 } // namespace content | 277 } // namespace content |
OLD | NEW |