Commit 12cfe027 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Spawn GPU process from the unsandboxed zygote.

Now that we have an unsandboxed zygote from https://crrev.com/742875 we
can spawn all process types from it. This ensures we use the same binary
as the browser process even when the on disk version changes.

Bug: 22703
Test: All existing tests still pass.
Change-Id: I56ab870ca591d10723b19ccba2d5de4420d99249
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067393Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743371}
parent 52d9d606
...@@ -451,6 +451,7 @@ struct MainFunction { ...@@ -451,6 +451,7 @@ struct MainFunction {
// Returns the exit code of the subprocess. // Returns the exit code of the subprocess.
int RunZygote(ContentMainDelegate* delegate) { int RunZygote(ContentMainDelegate* delegate) {
static const MainFunction kMainFunctions[] = { static const MainFunction kMainFunctions[] = {
{switches::kGpuProcess, GpuMain},
{switches::kRendererProcess, RendererMain}, {switches::kRendererProcess, RendererMain},
{switches::kUtilityProcess, UtilityMain}, {switches::kUtilityProcess, UtilityMain},
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
......
...@@ -312,14 +312,14 @@ class GpuSandboxedProcessLauncherDelegate ...@@ -312,14 +312,14 @@ class GpuSandboxedProcessLauncherDelegate
public: public:
explicit GpuSandboxedProcessLauncherDelegate( explicit GpuSandboxedProcessLauncherDelegate(
const base::CommandLine& cmd_line) const base::CommandLine& cmd_line)
:
#if defined(OS_WIN) #if defined(OS_WIN)
: cmd_line_(cmd_line), enable_appcontainer_(true),
enable_appcontainer_(true)
#endif #endif
{ cmd_line_(cmd_line) {
} }
~GpuSandboxedProcessLauncherDelegate() override {} ~GpuSandboxedProcessLauncherDelegate() override = default;
#if defined(OS_WIN) #if defined(OS_WIN)
bool DisableDefaultPolicy() override { return true; } bool DisableDefaultPolicy() override { return true; }
...@@ -412,13 +412,22 @@ class GpuSandboxedProcessLauncherDelegate ...@@ -412,13 +412,22 @@ class GpuSandboxedProcessLauncherDelegate
void DisableAppContainer() { enable_appcontainer_ = false; } void DisableAppContainer() { enable_appcontainer_ = false; }
#endif // OS_WIN #endif // OS_WIN
#if BUILDFLAG(USE_ZYGOTE_HANDLE)
service_manager::ZygoteHandle GetZygote() override {
if (service_manager::IsUnsandboxedSandboxType(GetSandboxType()))
return nullptr;
// The GPU process needs a specialized sandbox, so fork from the unsandboxed
// zygote and then apply the actual sandboxes in the forked process.
return service_manager::GetUnsandboxedZygote();
}
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
service_manager::SandboxType GetSandboxType() override { service_manager::SandboxType GetSandboxType() override {
#if defined(OS_WIN)
if (cmd_line_.HasSwitch(service_manager::switches::kDisableGpuSandbox)) { if (cmd_line_.HasSwitch(service_manager::switches::kDisableGpuSandbox)) {
DVLOG(1) << "GPU sandbox is disabled"; DVLOG(1) << "GPU sandbox is disabled";
return service_manager::SandboxType::kNoSandbox; return service_manager::SandboxType::kNoSandbox;
} }
#endif
return service_manager::SandboxType::kGpu; return service_manager::SandboxType::kGpu;
} }
...@@ -436,9 +445,10 @@ class GpuSandboxedProcessLauncherDelegate ...@@ -436,9 +445,10 @@ class GpuSandboxedProcessLauncherDelegate
return base::win::IsRunningUnderDesktopName(STRING16_LITERAL("winlogon")); return base::win::IsRunningUnderDesktopName(STRING16_LITERAL("winlogon"));
} }
base::CommandLine cmd_line_;
bool enable_appcontainer_; bool enable_appcontainer_;
#endif // OS_WIN #endif
base::CommandLine cmd_line_;
}; };
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "gpu/ipc/service/gpu_watchdog_thread.h" #include "gpu/ipc/service/gpu_watchdog_thread.h"
#include "media/gpu/buildflags.h" #include "media/gpu/buildflags.h"
#include "services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h" #include "services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h"
#include "services/tracing/public/cpp/trace_startup.h"
#include "third_party/angle/src/gpu_info_util/SystemInfo.h" #include "third_party/angle/src/gpu_info_util/SystemInfo.h"
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/switches.h" #include "ui/gfx/switches.h"
...@@ -397,6 +398,15 @@ int GpuMain(const MainFunctionParams& parameters) { ...@@ -397,6 +398,15 @@ int GpuMain(const MainFunctionParams& parameters) {
gpu_process.set_main_thread(child_thread); gpu_process.set_main_thread(child_thread);
#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
// Startup tracing is usually enabled earlier, but if we forked from a zygote,
// we can only enable it after mojo IPC support is brought up initialized by
// GpuChildThread, because the mojo broker has to create the tracing SMB on
// our behalf due to the zygote sandbox.
if (parameters.zygote_child)
tracing::EnableStartupTracingIfNeeded();
#endif // OS_POSIX && !OS_ANDROID && !!OS_MACOSX
// Setup tracing sampler profiler as early as possible. // Setup tracing sampler profiler as early as possible.
std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler = std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler =
tracing::TracingSamplerProfiler::CreateOnMainThread(); tracing::TracingSamplerProfiler::CreateOnMainThread();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment