diff options
author | hidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-07 15:44:48 +0000 |
---|---|---|
committer | hidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-07 15:44:48 +0000 |
commit | b2c73f4e4c6fda28f45c1dbd5651d53dab9064f1 (patch) | |
tree | 0f2787510b9d6a396f4ad62835b693be57a9d17b /components | |
parent | 6a7b2a046dfa6a1ce71fdb757e5acbbdc0a464d6 (diff) | |
download | chromium_src-b2c73f4e4c6fda28f45c1dbd5651d53dab9064f1.zip chromium_src-b2c73f4e4c6fda28f45c1dbd5651d53dab9064f1.tar.gz chromium_src-b2c73f4e4c6fda28f45c1dbd5651d53dab9064f1.tar.bz2 |
Support non-SFI mode in NaCl manifest file.
Currently, the flag to enable non-SFI mode is checked just before launching the plugin in the browser process. However, even if the flag is set, we may need to run the plugin in SFI mode.
For example, trivially, if the plugin provides only SFI-mode binary.
To handle such a case, this CL adds entries to NaCl manifest file so that a plugin developer can declare if their plugin provides SFI-mode/non-SFI mode binaries.
In summary, NaCl works in non-SFI mode if;
1) --enable-nacl-nonsfi-mode is set to true, and
2) the plugin provides the binary for non-SFI mode.
So, some checks are moved from the browser to the renderer.
We need similar, but slightly different, a flag for non-SFI mode. Here is the naming rule:
1) enable_nonsfi_mode -> If non-SFI mode is enabled on the browser.
(In more precise, if it is running on supported platform, and --enable-nacl-nonsfi-mode is set)
2) uses_nonsfi_mode -> If the specified plugin should run on non-SFI mode.
This happens when the plugin provides the binary for non-SFI mode, and --enable-nacl-nonsfi-mode
is set.
Note that, in later CLs, we split non-SFI mode nacl_helper from the current nacl_helper with linking it to the newlib.
Then, the uses_nonsfi_mode will become a flag to decide which helper the host should talk to.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3734
TEST=Ran trybot.
Review URL: https://codereview.chromium.org/177113009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/nacl/browser/nacl_host_message_filter.cc | 3 | ||||
-rw-r--r-- | components/nacl/browser/nacl_process_host.cc | 18 | ||||
-rw-r--r-- | components/nacl/browser/nacl_process_host.h | 3 | ||||
-rw-r--r-- | components/nacl/common/nacl_host_messages.h | 1 | ||||
-rw-r--r-- | components/nacl/common/nacl_messages.h | 2 | ||||
-rw-r--r-- | components/nacl/common/nacl_types.cc | 4 | ||||
-rw-r--r-- | components/nacl/common/nacl_types.h | 7 | ||||
-rw-r--r-- | components/nacl/loader/nacl_listener.cc | 4 | ||||
-rw-r--r-- | components/nacl/renderer/ppb_nacl_private_impl.cc | 12 |
9 files changed, 45 insertions, 9 deletions
diff --git a/components/nacl/browser/nacl_host_message_filter.cc b/components/nacl/browser/nacl_host_message_filter.cc index 2e5d473..92193dc 100644 --- a/components/nacl/browser/nacl_host_message_filter.cc +++ b/components/nacl/browser/nacl_host_message_filter.cc @@ -77,6 +77,7 @@ void NaClHostMessageFilter::OnLaunchNaCl( launch_params.render_view_id, launch_params.permission_bits, launch_params.uses_irt, + launch_params.uses_nonsfi_mode, launch_params.enable_dyncode_syscalls, launch_params.enable_exception_handling, launch_params.enable_crash_throttling, @@ -138,7 +139,7 @@ void NaClHostMessageFilter::AsyncReturnTemporaryFile( IPC::GetFileHandleForProcess(fd, PeerHandle(), false))); } -void NaClHostMessageFilter::OnNaClGetNumProcessors(int *num_processors) { +void NaClHostMessageFilter::OnNaClGetNumProcessors(int* num_processors) { *num_processors = base::SysInfo::NumberOfProcessors(); } diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc index d2b1ff1..3e93789 100644 --- a/components/nacl/browser/nacl_process_host.cc +++ b/components/nacl/browser/nacl_process_host.cc @@ -237,6 +237,7 @@ NaClProcessHost::NaClProcessHost(const GURL& manifest_url, int render_view_id, uint32 permission_bits, bool uses_irt, + bool uses_nonsfi_mode, bool enable_dyncode_syscalls, bool enable_exception_handling, bool enable_crash_throttling, @@ -254,6 +255,7 @@ NaClProcessHost::NaClProcessHost(const GURL& manifest_url, internal_(new NaClInternal()), weak_factory_(this), uses_irt_(uses_irt), + uses_nonsfi_mode_(uses_nonsfi_mode), enable_debug_stub_(false), enable_dyncode_syscalls_(enable_dyncode_syscalls), enable_exception_handling_(enable_exception_handling), @@ -762,8 +764,7 @@ bool NaClProcessHost::StartNaClExecution() { params.enable_ipc_proxy = enable_ppapi_proxy(); params.uses_irt = uses_irt_; params.enable_dyncode_syscalls = enable_dyncode_syscalls_; - params.enable_nonsfi_mode = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableNaClNonSfiMode); + params.uses_nonsfi_mode = uses_nonsfi_mode_; const ChildProcessData& data = process_->GetData(); if (!ShareHandleToSelLdr(data.handle, @@ -813,6 +814,19 @@ bool NaClProcessHost::StartNaClExecution() { } #endif + if (params.uses_nonsfi_mode) { +#if defined(OS_LINUX) + const bool kNonSFIModeSupported = true; +#else + const bool kNonSFIModeSupported = false; +#endif + if (!kNonSFIModeSupported || + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableNaClNonSfiMode)) { + return false; + } + } + process_->Send(new NaClProcessMsg_Start(params)); internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; diff --git a/components/nacl/browser/nacl_process_host.h b/components/nacl/browser/nacl_process_host.h index f099313..9df7ade 100644 --- a/components/nacl/browser/nacl_process_host.h +++ b/components/nacl/browser/nacl_process_host.h @@ -50,6 +50,7 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate { // render_view_id: RenderView routing id, to control access to private APIs. // permission_bits: controls which interfaces the NaCl plugin can use. // uses_irt: whether the launched process should use the IRT. + // uses_nonsfi_mode: whether the program should be loaded under non-SFI mode. // enable_dyncode_syscalls: whether the launched process should allow dyncode // and mmap with PROT_EXEC. // enable_exception_handling: whether the launched process should allow @@ -64,6 +65,7 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate { int render_view_id, uint32 permission_bits, bool uses_irt, + bool uses_nonsfi_mode, bool enable_dyncode_syscalls, bool enable_exception_handling, bool enable_crash_throttling, @@ -200,6 +202,7 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate { scoped_ptr<content::BrowserChildProcessHost> process_; bool uses_irt_; + bool uses_nonsfi_mode_; bool enable_debug_stub_; bool enable_dyncode_syscalls_; diff --git a/components/nacl/common/nacl_host_messages.h b/components/nacl/common/nacl_host_messages.h index 6918dc4..3a1e447 100644 --- a/components/nacl/common/nacl_host_messages.h +++ b/components/nacl/common/nacl_host_messages.h @@ -24,6 +24,7 @@ IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchParams) IPC_STRUCT_TRAITS_MEMBER(render_view_id) IPC_STRUCT_TRAITS_MEMBER(permission_bits) IPC_STRUCT_TRAITS_MEMBER(uses_irt) + IPC_STRUCT_TRAITS_MEMBER(uses_nonsfi_mode) IPC_STRUCT_TRAITS_MEMBER(enable_dyncode_syscalls) IPC_STRUCT_TRAITS_MEMBER(enable_exception_handling) IPC_STRUCT_TRAITS_MEMBER(enable_crash_throttling) diff --git a/components/nacl/common/nacl_messages.h b/components/nacl/common/nacl_messages.h index bfb8f4b..9f892be 100644 --- a/components/nacl/common/nacl_messages.h +++ b/components/nacl/common/nacl_messages.h @@ -24,7 +24,7 @@ IPC_STRUCT_TRAITS_BEGIN(nacl::NaClStartParams) IPC_STRUCT_TRAITS_MEMBER(enable_ipc_proxy) IPC_STRUCT_TRAITS_MEMBER(uses_irt) IPC_STRUCT_TRAITS_MEMBER(enable_dyncode_syscalls) - IPC_STRUCT_TRAITS_MEMBER(enable_nonsfi_mode) + IPC_STRUCT_TRAITS_MEMBER(uses_nonsfi_mode) IPC_STRUCT_TRAITS_END() //----------------------------------------------------------------------------- diff --git a/components/nacl/common/nacl_types.cc b/components/nacl/common/nacl_types.cc index acd49c0..50ea1b8 100644 --- a/components/nacl/common/nacl_types.cc +++ b/components/nacl/common/nacl_types.cc @@ -14,7 +14,7 @@ NaClStartParams::NaClStartParams() enable_ipc_proxy(false), uses_irt(false), enable_dyncode_syscalls(false), - enable_nonsfi_mode(false) { + uses_nonsfi_mode(false) { } NaClStartParams::~NaClStartParams() { @@ -33,6 +33,7 @@ NaClLaunchParams::NaClLaunchParams(const std::string& manifest_url, int render_view_id, uint32 permission_bits, bool uses_irt, + bool uses_nonsfi_mode, bool enable_dyncode_syscalls, bool enable_exception_handling, bool enable_crash_throttling) @@ -40,6 +41,7 @@ NaClLaunchParams::NaClLaunchParams(const std::string& manifest_url, render_view_id(render_view_id), permission_bits(permission_bits), uses_irt(uses_irt), + uses_nonsfi_mode(uses_nonsfi_mode), enable_dyncode_syscalls(enable_dyncode_syscalls), enable_exception_handling(enable_exception_handling), enable_crash_throttling(enable_crash_throttling) { diff --git a/components/nacl/common/nacl_types.h b/components/nacl/common/nacl_types.h index 29235ec..4adee9d 100644 --- a/components/nacl/common/nacl_types.h +++ b/components/nacl/common/nacl_types.h @@ -60,7 +60,7 @@ struct NaClStartParams { bool enable_ipc_proxy; bool uses_irt; bool enable_dyncode_syscalls; - bool enable_nonsfi_mode; + bool uses_nonsfi_mode; }; // Parameters sent to the browser process to have it launch a NaCl process. @@ -69,7 +69,9 @@ struct NaClStartParams { // nacl_host_messages.h. struct NaClLaunchParams { NaClLaunchParams(); - NaClLaunchParams(const std::string& u, int r, uint32 p, bool uses_irt, + NaClLaunchParams(const std::string& u, int r, uint32 p, + bool uses_irt, + bool uses_nonsfi_mode, bool enable_dyncode_syscalls, bool enable_exception_handling, bool enable_crash_throttling); @@ -80,6 +82,7 @@ struct NaClLaunchParams { int render_view_id; uint32 permission_bits; bool uses_irt; + bool uses_nonsfi_mode; bool enable_dyncode_syscalls; bool enable_exception_handling; bool enable_crash_throttling; diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc index f2d4be3..d2222ac 100644 --- a/components/nacl/loader/nacl_listener.cc +++ b/components/nacl/loader/nacl_listener.cc @@ -287,7 +287,7 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); #if defined(OS_LINUX) - if (params.enable_nonsfi_mode) { + if (params.uses_nonsfi_mode) { // In non-SFI mode, we neither intercept nor rewrite the message using // NaClIPCAdapter, and the channels are connected between the plugin and // the hosts directly. So, the IPC::Channel instances will be created in @@ -416,7 +416,7 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { #endif #if defined(OS_LINUX) - if (params.enable_nonsfi_mode) { + if (params.uses_nonsfi_mode) { nacl::nonsfi::MainStart(args->imc_bootstrap_handle); NOTREACHED(); return; diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc index 7f7876c..a5103aa 100644 --- a/components/nacl/renderer/ppb_nacl_private_impl.cc +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc @@ -106,6 +106,7 @@ void LaunchSelLdr(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, + PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, @@ -155,6 +156,7 @@ void LaunchSelLdr(PP_Instance instance, routing_id, perm_bits, PP_ToBool(uses_irt), + PP_ToBool(uses_nonsfi_mode), PP_ToBool(enable_dyncode_syscalls), PP_ToBool(enable_exception_handling), PP_ToBool(enable_crash_throttling)), @@ -300,6 +302,15 @@ int32_t GetNumberOfProcessors() { return num_processors; } +PP_Bool IsNonSFIModeEnabled() { +#if defined(OS_LINUX) + return PP_FromBool(CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableNaClNonSfiMode)); +#else + return PP_FALSE; +#endif +} + int32_t GetNexeFd(PP_Instance instance, const char* pexe_url, uint32_t abi_version, @@ -552,6 +563,7 @@ const PPB_NaCl_Private nacl_interface = { &GetReadonlyPnaclFD, &CreateTemporaryFile, &GetNumberOfProcessors, + &IsNonSFIModeEnabled, &GetNexeFd, &ReportTranslationFinished, &OpenNaClExecutable, |