From 19fe5da9be329ff0296cd19b91bc11c59c42fd7d Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 20 Nov 2017 15:33:25 +0100 Subject: [PATCH] core: use separate signal ep Fixes #2584 --- repos/base/src/core/include/core_env.h | 1 + repos/base/src/core/include/signal_broker.h | 13 +-- .../src/core/include/signal_delivery_proxy.h | 80 +++++++++++++++++++ repos/base/src/core/main.cc | 5 +- .../src/core/signal_transmitter_noinit.cc | 5 ++ .../base/src/core/signal_transmitter_proxy.cc | 66 +++------------ 6 files changed, 103 insertions(+), 67 deletions(-) create mode 100644 repos/base/src/core/include/signal_delivery_proxy.h diff --git a/repos/base/src/core/include/core_env.h b/repos/base/src/core/include/core_env.h index 370a6d04d3..e9a6b09709 100644 --- a/repos/base/src/core/include/core_env.h +++ b/repos/base/src/core/include/core_env.h @@ -83,6 +83,7 @@ class Genode::Core_env : public Env_deprecated Ram_allocator &ram_allocator() { return _synced_ram_allocator; } Region_map &local_rm() { return _region_map; } + Rpc_entrypoint &signal_ep(); /****************************** ** Env_deprecated interface ** diff --git a/repos/base/src/core/include/signal_broker.h b/repos/base/src/core/include/signal_broker.h index aa9642ef5b..8678828c71 100644 --- a/repos/base/src/core/include/signal_broker.h +++ b/repos/base/src/core/include/signal_broker.h @@ -17,6 +17,7 @@ #include #include #include +#include namespace Genode { class Signal_broker; } @@ -30,6 +31,7 @@ class Genode::Signal_broker Signal_source_component _source; Signal_source_capability _source_cap; Signal_context_slab _contexts_slab { _md_alloc }; + Signal_delivery_proxy_component _delivery_proxy { _source_ep }; public: @@ -93,16 +95,9 @@ class Genode::Signal_broker destroy(&_contexts_slab, context); } - void submit(Signal_context_capability cap, unsigned cnt) + void submit(Signal_context_capability const cap, unsigned const cnt) { - _source_ep.apply(cap, [&] (Signal_context_component *context) { - if (!context) { - warning("invalid signal-context capability"); - return; - } - - context->source()->submit(context, cnt); - }); + _delivery_proxy.submit(cap, cnt); } }; diff --git a/repos/base/src/core/include/signal_delivery_proxy.h b/repos/base/src/core/include/signal_delivery_proxy.h new file mode 100644 index 0000000000..20f226f9d4 --- /dev/null +++ b/repos/base/src/core/include/signal_delivery_proxy.h @@ -0,0 +1,80 @@ +/* + * \brief Mechanism to deliver signals via core + * \author Norman Feske + * \date 2017-05-10 + */ + +/* + * Copyright (C) 2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _CORE__INCLUDE__SIGNAL_DELIVERY_PROXY_H_ +#define _CORE__INCLUDE__SIGNAL_DELIVERY_PROXY_H_ + +namespace Genode { + + struct Signal_delivery_proxy + { + GENODE_RPC(Rpc_deliver, void, _deliver_from_ep, Signal_context_capability, unsigned); + GENODE_RPC_INTERFACE(Rpc_deliver); + }; + + struct Signal_delivery_proxy_component + : + Rpc_object + { + Rpc_entrypoint &_ep; + + Capability _proxy_cap; + + /** + * Constructor + * + * \param ep entrypoint to be used as a proxy for delivering signals + * as IPC-reply messages. + */ + Signal_delivery_proxy_component(Rpc_entrypoint &ep) : _ep(ep) + { + _proxy_cap = _ep.manage(this); + } + + ~Signal_delivery_proxy_component() + { + if (_proxy_cap.valid()) + _ep.dissolve(this); + } + + /** + * Signal_delivery_proxy RPC interface + * + * This method is executed in the context of the 'ep'. Hence, it + * can produce legitimate IPC reply messages to 'Signal_source' + * clients. + */ + void _deliver_from_ep(Signal_context_capability cap, unsigned cnt) + { + _ep.apply(cap, [&] (Signal_context_component *context) { + if (context) + context->source()->submit(context, cnt); + else + warning("invalid signal-context capability"); + }); + } + + /** + * Deliver signal via the proxy mechanism + * + * Since this method perform an RPC call to the 'ep' specified at the + * constructor, is must never be called from this ep. + * + * Called from threads other than 'ep'. + */ + void submit(Signal_context_capability cap, unsigned cnt) { + _proxy_cap.call(cap, cnt); } + }; +} + +#endif /* _CORE__INCLUDE__SIGNLA_DELIVERY_PROXY_H_ */ diff --git a/repos/base/src/core/main.cc b/repos/base/src/core/main.cc index af4b398ddc..390f9a3f3c 100644 --- a/repos/base/src/core/main.cc +++ b/repos/base/src/core/main.cc @@ -69,7 +69,7 @@ Core_env * Genode::core_env() if (!signal_transmitter_initialized) signal_transmitter_initialized = - (init_core_signal_transmitter(*_env.entrypoint()), true); + (init_core_signal_transmitter(_env.signal_ep()), true); return &_env; } @@ -256,7 +256,8 @@ int main() static Rm_root rm_root (&ep, &sliced_heap, pager_ep); static Cpu_root cpu_root (&ep, &ep, &pager_ep, &sliced_heap, Trace::sources()); - static Pd_root pd_root (ep, ep, pager_ep, *platform()->ram_alloc(), + static Pd_root pd_root (ep, core_env()->signal_ep(), pager_ep, + *platform()->ram_alloc(), local_rm, sliced_heap, *platform_specific()->core_mem_alloc()); static Log_root log_root (&ep, &sliced_heap); diff --git a/repos/base/src/core/signal_transmitter_noinit.cc b/repos/base/src/core/signal_transmitter_noinit.cc index aeafdae159..44b01e4734 100644 --- a/repos/base/src/core/signal_transmitter_noinit.cc +++ b/repos/base/src/core/signal_transmitter_noinit.cc @@ -15,6 +15,11 @@ */ /* core-local includes */ +#include #include +using namespace Genode; + void Genode::init_core_signal_transmitter(Rpc_entrypoint &) { } + +Rpc_entrypoint &Core_env::signal_ep() { return _entrypoint; } diff --git a/repos/base/src/core/signal_transmitter_proxy.cc b/repos/base/src/core/signal_transmitter_proxy.cc index d726553160..0063254713 100644 --- a/repos/base/src/core/signal_transmitter_proxy.cc +++ b/repos/base/src/core/signal_transmitter_proxy.cc @@ -17,6 +17,7 @@ #include /* core-local includes */ +#include #include #include @@ -26,66 +27,11 @@ using namespace Genode; -namespace { - - struct Signal_delivery_proxy - { - GENODE_RPC(Rpc_deliver, void, _deliver_from_ep, Signal_context_capability, unsigned); - GENODE_RPC_INTERFACE(Rpc_deliver); - }; - - struct Signal_delivery_proxy_component - : - Rpc_object - { - Rpc_entrypoint &_ep; - - Capability _proxy_cap = _ep.manage(this); - - /** - * Constructor - * - * \param ep entrypoint to be used as a proxy for delivering signals - * as IPC-reply messages. - */ - Signal_delivery_proxy_component(Rpc_entrypoint &ep) : _ep(ep) { } - - /** - * Signal_delivery_proxy RPC interface - * - * This method is executed in the context of the 'ep'. Hence, it - * can produce legitimate IPC reply messages to 'Signal_source' - * clients. - */ - void _deliver_from_ep(Signal_context_capability cap, unsigned cnt) - { - _ep.apply(cap, [&] (Signal_context_component *context) { - if (context) - context->source()->submit(context, cnt); - else - warning("invalid signal-context capability"); - }); - } - - /** - * Deliver signal via the proxy mechanism - * - * Since this method perform an RPC call to the 'ep' specified at the - * constructor, is must never be called from this ep. - * - * Called from threads other than 'ep'. - */ - void submit(Signal_context_capability cap, unsigned cnt) { - _proxy_cap.call(cap, cnt); } - }; -} - - static Constructible delivery_proxy; /* - * Entrypoint that servces the 'Signal_source' RPC objects + * Entrypoint that serves the 'Signal_source' RPC objects */ static Rpc_entrypoint *_ep; @@ -107,3 +53,11 @@ void Signal_transmitter::submit(unsigned cnt) } delivery_proxy->submit(_context, cnt); } + + +Rpc_entrypoint &Core_env::signal_ep() +{ + static Rpc_entrypoint ep(nullptr, ENTRYPOINT_STACK_SIZE, + "signal_entrypoint"); + return ep; +}