From 44860e89bee4b4e3b70b01891c23c4b68caa9558 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 16 Dec 2024 15:49:24 +0100 Subject: [PATCH] core: remove Core_env This patch adjusts the last remaining callers of 'core_env' and removes the 'Core_env' interface. - Core's RAM/cap accounts are now represented by 'Core_account' implementing the 'Pd_account' interface. - The former parts of 'Core_env' are now initialized in sequence in 'bootstrap_component'. - 'Core_child' has been moved to a header to reduce the code in 'main.cc' to a bare minimum. This as a preparation for the plan of making 'main.cc' specific for each kernel. Fixes #5408 --- repos/base-linux/src/core/platform.cc | 6 +- repos/base-nova/src/core/pager.cc | 1 - .../src/core/vm_session_component.cc | 1 - repos/base/src/core/include/core_account.h | 60 ++++ repos/base/src/core/include/core_child.h | 113 ++++++++ repos/base/src/core/include/core_env.h | 98 ------- repos/base/src/core/include/pd_root.h | 5 +- .../src/core/include/pd_session_component.h | 18 +- .../src/core/include/ram_dataspace_factory.h | 1 - .../src/core/include/rm_session_component.h | 1 + .../src/core/include/signal_transmitter.h | 3 + repos/base/src/core/main.cc | 270 ++++-------------- repos/base/src/core/pd_session_component.cc | 3 +- .../src/core/signal_transmitter_noinit.cc | 3 +- .../base/src/core/signal_transmitter_proxy.cc | 7 +- .../base/src/include/base/internal/globals.h | 2 + 16 files changed, 270 insertions(+), 322 deletions(-) create mode 100644 repos/base/src/core/include/core_account.h create mode 100644 repos/base/src/core/include/core_child.h delete mode 100644 repos/base/src/core/include/core_env.h diff --git a/repos/base-linux/src/core/platform.cc b/repos/base-linux/src/core/platform.cc index 8f47817235f..84b2055a7d3 100644 --- a/repos/base-linux/src/core/platform.cc +++ b/repos/base-linux/src/core/platform.cc @@ -20,9 +20,9 @@ #include /* local includes */ -#include "platform.h" -#include "core_env.h" -#include "resource_path.h" +#include +#include +#include /* Linux includes */ #include diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc index 5024229a9d6..2536fc0e3a0 100644 --- a/repos/base-nova/src/core/pager.cc +++ b/repos/base-nova/src/core/pager.cc @@ -25,7 +25,6 @@ #include #include #include -#include /* NOVA includes */ #include diff --git a/repos/base-nova/src/core/vm_session_component.cc b/repos/base-nova/src/core/vm_session_component.cc index b137080ecde..1ae8882ebfa 100644 --- a/repos/base-nova/src/core/vm_session_component.cc +++ b/repos/base-nova/src/core/vm_session_component.cc @@ -19,7 +19,6 @@ #include /* core includes */ -#include #include #include #include diff --git a/repos/base/src/core/include/core_account.h b/repos/base/src/core/include/core_account.h new file mode 100644 index 00000000000..e4a71674198 --- /dev/null +++ b/repos/base/src/core/include/core_account.h @@ -0,0 +1,60 @@ +/* + * \brief RAM and cap account of the core component + * \author Norman Feske + * \date 2024-12-17 + */ + +/* + * Copyright (C) 2016-2024 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__CORE_ACCOUNT_H_ +#define _CORE__INCLUDE__CORE_ACCOUNT_H_ + +namespace Core { struct Core_account; } + + +struct Core::Core_account : Rpc_object +{ + Rpc_entrypoint &_ep; + + Ram_quota_guard ram_quota_guard; + Cap_quota_guard cap_quota_guard; + + Core::Account ram_account { ram_quota_guard, "core" }; + Core::Account cap_account { cap_quota_guard, "core" }; + + Core_account(Rpc_entrypoint &ep, Ram_quota ram, Cap_quota caps) + : _ep(ep), ram_quota_guard(ram), cap_quota_guard(caps) { ep.manage(this); } + + Transfer_result _with_pd(Capability cap, auto const &fn) + { + if (this->cap() == cap) + return Transfer_result::OK; + + return _ep.apply(cap, [&] (Pd_session_component *pd_ptr) { + Transfer_result result = Transfer_result::INVALID; + if (pd_ptr) + fn(*pd_ptr, result); + return result; }); + } + + Transfer_result transfer_quota(Capability to, Cap_quota amount) override + { + return _with_pd(to, [&] (Pd_session_component &pd, Transfer_result &result) { + pd.with_cap_account([&] (Account &to) { + result = cap_account.transfer_quota(to, amount); }); }); + } + + Transfer_result transfer_quota(Capability to, Ram_quota amount) override + { + return _with_pd(to, [&] (Pd_session_component &pd, Transfer_result &result) { + pd.with_ram_account([&] (Account &to) { + result = ram_account.transfer_quota(to, amount); }); }); + } +}; + +#endif /* _CORE__INCLUDE__CORE_ACCOUNT_H_ */ diff --git a/repos/base/src/core/include/core_child.h b/repos/base/src/core/include/core_child.h new file mode 100644 index 00000000000..c42feb0dd06 --- /dev/null +++ b/repos/base/src/core/include/core_child.h @@ -0,0 +1,113 @@ +/* + * \brief Child policy for the init component + * \author Norman Feske + * \date 2024-12-17 + */ + +/* + * Copyright (C) 2016-2024 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__CORE_CHILD_H_ +#define _CORE__INCLUDE__CORE_CHILD_H_ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + +namespace Core { class Core_child; } + + +class Core::Core_child : public Child_policy +{ + private: + + Registry &_services; + Rpc_entrypoint &_ep; + Region_map &_core_rm; + Ram_allocator &_core_ram; + Core_account &_core_account; + + Capability _core_cpu_cap; + Cpu_session &_core_cpu; + + Cap_quota const _cap_quota; + Ram_quota const _ram_quota; + + Id_space _server_ids { }; + + Child _child { _core_rm, _ep, *this }; + + public: + + Core_child(Registry &services, Rpc_entrypoint &ep, + Region_map &core_rm, Ram_allocator &core_ram, + Core_account &core_account, + Cpu_session &core_cpu, Capability core_cpu_cap, + Cap_quota cap_quota, Ram_quota ram_quota) + : + _services(services), _ep(ep), _core_rm(core_rm), _core_ram(core_ram), + _core_account(core_account), + _core_cpu_cap(core_cpu_cap), _core_cpu(core_cpu), + _cap_quota(Child::effective_quota(cap_quota)), + _ram_quota(Child::effective_quota(ram_quota)) + { } + + + /**************************** + ** Child-policy interface ** + ****************************/ + + Name name() const override { return "init"; } + + Route resolve_session_request(Service::Name const &name, + Session_label const &label, + Session::Diag const diag) override + { + Service *service = nullptr; + _services.for_each([&] (Service &s) { + if (!service && s.name() == name) + service = &s; }); + + if (!service) + throw Service_denied(); + + return Route { .service = *service, + .label = label, + .diag = diag }; + } + + void init(Pd_session &, Capability cap) override + { + _ep.apply(cap, [&] (Pd_session_component *pd_ptr) { + if (pd_ptr) + pd_ptr->ref_accounts(_core_account.ram_account, + _core_account.cap_account); }); + + _core_account.transfer_quota(cap, _cap_quota); + _core_account.transfer_quota(cap, _ram_quota); + } + + void init(Cpu_session &session, Capability cap) override + { + session.ref_account(_core_cpu_cap); + _core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100)); + } + + Ram_allocator &session_md_ram() override { return _core_ram; } + + Pd_account &ref_account() override { return _core_account; } + Capability ref_account_cap() const override { return _core_account.cap(); } + + size_t session_alloc_batch_size() const override { return 128; } + + Id_space &server_id_space() override { return _server_ids; } +}; + +#endif /* _CORE__INCLUDE__CORE_CHILD_H_ */ diff --git a/repos/base/src/core/include/core_env.h b/repos/base/src/core/include/core_env.h deleted file mode 100644 index fef3b37bf82..00000000000 --- a/repos/base/src/core/include/core_env.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * \brief Core-specific environment - * \author Norman Feske - * \author Christian Helmuth - * \date 2006-07-28 - */ - -/* - * Copyright (C) 2006-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__CORE_ENV_H_ -#define _CORE__INCLUDE__CORE_ENV_H_ - -/* Genode includes */ -#include - -/* base-internal includes */ -#include - -/* core includes */ -#include -#include -#include -#include -#include - -namespace Core { - - class Core_env; - extern Core_env &core_env(); -} - - -class Core::Core_env : public Noncopyable -{ - private: - - enum { ENTRYPOINT_STACK_SIZE = 20 * 1024 }; - - /* - * Initialize the stack area before creating the first thread, - * which happens to be the '_entrypoint'. - */ - bool _init_stack_area() { init_stack_area(); return true; } - bool _stack_area_initialized = _init_stack_area(); - - Rpc_entrypoint _entrypoint; - Core_region_map _region_map; - Pd_session_component _pd_session; - Synced_ram_allocator _synced_ram_allocator { _pd_session }; - - public: - - Core_env() - : - _entrypoint(nullptr, ENTRYPOINT_STACK_SIZE, "entrypoint", - Affinity::Location()), - _region_map(_entrypoint), - _pd_session(_entrypoint, - _entrypoint, - Session::Resources { - Ram_quota { platform().ram_alloc().avail() }, - Cap_quota { platform().max_caps() } }, - Session::Label("core"), - Session::Diag{false}, - platform().ram_alloc(), - Ram_dataspace_factory::any_phys_range(), - Ram_dataspace_factory::Virt_range { platform().vm_start(), - platform().vm_size() }, - Pd_session_component::Managing_system::PERMITTED, - _region_map, - *((Pager_entrypoint *)nullptr), - "" /* args to native PD */, - platform_specific().core_mem_alloc(), - *((Core::System_control *)nullptr)) - { - _pd_session.init_cap_and_ram_accounts(); - } - - Rpc_entrypoint &entrypoint() { return _entrypoint; } - Ram_allocator &ram_allocator() { return _synced_ram_allocator; } - Region_map &local_rm() { return _region_map; } - - Rpc_entrypoint &signal_ep(); - - Parent *parent() { return nullptr; } - Region_map *rm_session() { return &_region_map; } - Pd_session *pd_session() { return &_pd_session; } - Cpu_session *cpu_session() { ASSERT_NEVER_CALLED; } - Cpu_session_capability cpu_session_cap() { ASSERT_NEVER_CALLED; } - Pd_session_capability pd_session_cap() { return _pd_session.cap(); } -}; - -#endif /* _CORE__INCLUDE__CORE_ENV_H_ */ diff --git a/repos/base/src/core/include/pd_root.h b/repos/base/src/core/include/pd_root.h index 547c4035ff7..be37f8563a0 100644 --- a/repos/base/src/core/include/pd_root.h +++ b/repos/base/src/core/include/pd_root.h @@ -14,10 +14,11 @@ #ifndef _CORE__INCLUDE__PD_ROOT_H_ #define _CORE__INCLUDE__PD_ROOT_H_ -/* Genode */ +/* Genode includes */ #include +#include -/* Core */ +/* core includes */ #include namespace Core { class Pd_root; } diff --git a/repos/base/src/core/include/pd_session_component.h b/repos/base/src/core/include/pd_session_component.h index 9c596503e0f..7c3db3d36f8 100644 --- a/repos/base/src/core/include/pd_session_component.h +++ b/repos/base/src/core/include/pd_session_component.h @@ -149,7 +149,7 @@ class Core::Pd_session_component : public Session_object _constrained_md_ram_alloc(*this, _ram_quota_guard(), _cap_quota_guard()), _constrained_core_ram_alloc(_ram_quota_guard(), _cap_quota_guard(), core_mem), _sliced_heap(_constrained_md_ram_alloc, local_rm), - _ram_ds_factory(ep, phys_alloc, phys_range, local_rm, + _ram_ds_factory(ep, phys_alloc, phys_range, _constrained_core_ram_alloc), _signal_broker(_sliced_heap, signal_ep, signal_ep), _rpc_cap_factory(_sliced_heap), @@ -168,6 +168,22 @@ class Core::Pd_session_component : public Session_object ~Pd_session_component(); + void ref_accounts(Account &ram_ref, Account &cap_ref) + { + _ram_account.construct(_ram_quota_guard(), _label, ram_ref); + _cap_account.construct(_cap_quota_guard(), _label, cap_ref); + } + + void with_ram_account(auto const &fn) + { + if (_ram_account.constructed()) fn(*_ram_account); + } + + void with_cap_account(auto const &fn) + { + if (_cap_account.constructed()) fn(*_cap_account); + } + /** * Initialize cap and RAM accounts without providing a reference account * diff --git a/repos/base/src/core/include/ram_dataspace_factory.h b/repos/base/src/core/include/ram_dataspace_factory.h index c00a2858fbf..497f2c9178e 100644 --- a/repos/base/src/core/include/ram_dataspace_factory.h +++ b/repos/base/src/core/include/ram_dataspace_factory.h @@ -87,7 +87,6 @@ class Core::Ram_dataspace_factory : public Ram_allocator, Ram_dataspace_factory(Rpc_entrypoint &ep, Range_allocator &phys_alloc, Phys_range phys_range, - Region_map &, Allocator &allocator) : _ep(ep), _phys_alloc(phys_alloc), _phys_range(phys_range), diff --git a/repos/base/src/core/include/rm_session_component.h b/repos/base/src/core/include/rm_session_component.h index 2621ab0c450..c8377927ed7 100644 --- a/repos/base/src/core/include/rm_session_component.h +++ b/repos/base/src/core/include/rm_session_component.h @@ -18,6 +18,7 @@ #include #include #include +#include /* core includes */ #include diff --git a/repos/base/src/core/include/signal_transmitter.h b/repos/base/src/core/include/signal_transmitter.h index a3e47111804..00890fe6218 100644 --- a/repos/base/src/core/include/signal_transmitter.h +++ b/repos/base/src/core/include/signal_transmitter.h @@ -39,6 +39,9 @@ namespace Core { * argument. */ void init_core_signal_transmitter(Rpc_entrypoint &ep); + + + Rpc_entrypoint &core_signal_ep(Rpc_entrypoint &core_ep); } #endif /* _CORE__INCLUDE__SIGNAL_TRANSMITTER_H_ */ diff --git a/repos/base/src/core/main.cc b/repos/base/src/core/main.cc index f3e06974cfb..f15e30c428a 100644 --- a/repos/base/src/core/main.cc +++ b/repos/base/src/core/main.cc @@ -13,20 +13,13 @@ /* Genode includes */ #include -#include -#include -#include -#include -#include -#include -#include /* base-internal includes */ #include /* core includes */ #include -#include +#include #include #include #include @@ -39,43 +32,9 @@ #include #include #include +#include #include -using namespace Core; - - -/*************************************** - ** Core environment/platform support ** - ***************************************/ - -Core_env &Core::core_env() -{ - /* - * Make sure to initialize the platform before constructing the core - * environment. - */ - platform(); - - /* - * By placing the environment as static object here, we ensure that its - * constructor gets called when this function is used the first time. - */ - static Core_env _env; - - /* - * Register signal-source entrypoint at core-local signal-transmitter back - * end - */ - static bool signal_transmitter_initialized; - - if (!signal_transmitter_initialized) - signal_transmitter_initialized = - (init_core_signal_transmitter(_env.signal_ep()), true); - - return _env; -} - - Core::Platform &Core::platform_specific() { static Platform _platform; @@ -83,155 +42,67 @@ Core::Platform &Core::platform_specific() } -Platform_generic &Core::platform() { return platform_specific(); } +Core::Platform_generic &Core::platform() { return platform_specific(); } -struct Genode::Platform { }; - - -Genode::Platform &Genode::init_platform() +Core::Trace::Source_registry &Core::Trace::sources() { - core_env(); - static Genode::Platform platform { }; - return platform; + static Source_registry inst; + return inst; } -/** - * Dummy implementation for core that has no parent to ask for resources - */ -void Genode::init_parent_resource_requests(Genode::Env &) {}; - - -/**************** - ** Core child ** - ****************/ - -class Core_child : public Child_policy -{ - private: - - Registry &_services; - - Capability _core_pd_cap; - Pd_session &_core_pd; - - Capability _core_cpu_cap; - Cpu_session &_core_cpu; - - Cap_quota const _cap_quota; - Ram_quota const _ram_quota; +namespace Genode { extern char const *version_string; } - Id_space _server_ids { }; - Child _child; - - public: - - /** - * Constructor - */ - Core_child(Registry &services, Region_map &local_rm, - Pd_session &core_pd, Capability core_pd_cap, - Cpu_session &core_cpu, Capability core_cpu_cap, - Cap_quota cap_quota, Ram_quota ram_quota, - Rpc_entrypoint &ep) - : - _services(services), - _core_pd_cap (core_pd_cap), _core_pd (core_pd), - _core_cpu_cap(core_cpu_cap), _core_cpu(core_cpu), - _cap_quota(Child::effective_quota(cap_quota)), - _ram_quota(Child::effective_quota(ram_quota)), - _child(local_rm, ep, *this) - { } - - - /**************************** - ** Child-policy interface ** - ****************************/ - - Name name() const override { return "init"; } - - Route resolve_session_request(Service::Name const &name, - Session_label const &label, - Session::Diag const diag) override - { - Service *service = nullptr; - _services.for_each([&] (Service &s) { - if (!service && s.name() == name) - service = &s; }); - - if (!service) - throw Service_denied(); - - return Route { .service = *service, - .label = label, - .diag = diag }; - } - - void init(Pd_session &session, Capability cap) override - { - session.ref_account(_core_pd_cap); - _core_pd.transfer_quota(cap, _cap_quota); - _core_pd.transfer_quota(cap, _ram_quota); - } - - void init(Cpu_session &session, Capability cap) override - { - session.ref_account(_core_cpu_cap); - _core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100)); - } - - Ram_allocator &session_md_ram() override { return _core_pd; } - - Pd_account &ref_account() override { return _core_pd; } - Capability ref_account_cap() const override { return _core_pd_cap; } +struct Genode::Platform { }; - size_t session_alloc_batch_size() const override { return 128; } - Id_space &server_id_space() override { return _server_ids; } -}; +/* + * Executed on the initial stack + */ +Genode::Platform &Genode::init_platform() +{ + init_stack_area(); + static Platform platform { }; + return platform; +} -/**************** - ** Signal API ** - ****************/ /* - * In contrast to non-core components, core disables the signal thread by - * overriding 'Genode::init_signal_thread' with a dummy. Within core, the - * signal thread is not needed as core is never supposed to receive any - * signals. + * Executed on a stack located within the stack area */ +void Genode::bootstrap_component(Genode::Platform &) +{ + using namespace Core; -void Genode::init_signal_thread(Env &) { } + Range_allocator &ram_ranges = Core::platform().ram_alloc(); + Rom_fs &rom_modules = Core::platform().rom_fs(); + Range_allocator &io_mem_ranges = Core::platform().io_mem_alloc(); + Range_allocator &io_port_ranges = Core::platform().io_port_alloc(); + Range_allocator &irq_ranges = Core::platform().irq_alloc(); + Allocator &core_alloc = platform_specific().core_mem_alloc(); + Ram_quota const avail_ram { ram_ranges.avail() }; + Cap_quota const avail_caps { Core::platform().max_caps() }; -/******************* - ** Trace support ** - *******************/ + static constexpr size_t STACK_SIZE = 20 * 1024; -Core::Trace::Source_registry &Core::Trace::sources() -{ - static Source_registry inst; - return inst; -} + static Rpc_entrypoint ep { nullptr, STACK_SIZE, "entrypoint", Affinity::Location() }; + static Core::Core_account core_account { ep, avail_ram, avail_caps }; -/*************** - ** Core main ** - ***************/ + static Ram_dataspace_factory core_ram { + ep, ram_ranges, Ram_dataspace_factory::any_phys_range(), core_alloc }; -namespace Genode { - extern bool inhibit_tracing; - extern char const *version_string; -} + static Core_region_map core_rm { ep }; + static Rpc_entrypoint &signal_ep = core_signal_ep(ep); -void Genode::bootstrap_component(Genode::Platform &) -{ - init_exception_handling(*core_env().pd_session(), core_env().local_rm()); - init_page_fault_handling(core_env().entrypoint()); + init_exception_handling(core_ram, core_rm); + init_core_signal_transmitter(signal_ep); + init_page_fault_handling(ep); /* disable tracing within core because it is not fully implemented */ inhibit_tracing = true; @@ -240,24 +111,18 @@ void Genode::bootstrap_component(Genode::Platform &) static Core::Trace::Policy_registry trace_policies; - static Rpc_entrypoint &ep = core_env().entrypoint(); - static Ram_allocator &core_ram_alloc = core_env().ram_allocator(); - static Region_map &local_rm = core_env().local_rm(); - Pd_session &core_pd = *core_env().pd_session(); - Capability core_pd_cap = core_env().pd_session_cap(); - static Registry services; /* * Allocate session meta data on distinct dataspaces to enable independent * destruction (to enable quota trading) of session component objects. */ - static Sliced_heap sliced_heap(core_ram_alloc, local_rm); + static Sliced_heap sliced_heap { core_ram, core_rm }; /* * Factory for creating RPC capabilities within core */ - static Rpc_cap_factory rpc_cap_factory(sliced_heap); + static Rpc_cap_factory rpc_cap_factory { sliced_heap }; static Pager_entrypoint pager_ep(rpc_cap_factory); @@ -266,20 +131,17 @@ void Genode::bootstrap_component(Genode::Platform &) static Core::System_control &system_control = init_system_control(sliced_heap, ep); - static Rom_root rom_root (ep, ep, platform().rom_fs(), sliced_heap); - static Rm_root rm_root (ep, sliced_heap, core_ram_alloc, local_rm, pager_ep); - static Cpu_root cpu_root (core_ram_alloc, local_rm, ep, ep, pager_ep, + static Rom_root rom_root (ep, ep, rom_modules, sliced_heap); + static Rm_root rm_root (ep, sliced_heap, core_ram, core_rm, pager_ep); + static Cpu_root cpu_root (core_ram, core_rm, ep, ep, pager_ep, sliced_heap, Core::Trace::sources()); - static Pd_root pd_root (ep, core_env().signal_ep(), pager_ep, - platform().ram_alloc(), - local_rm, sliced_heap, + static Pd_root pd_root (ep, signal_ep, pager_ep, ram_ranges, core_rm, sliced_heap, platform_specific().core_mem_alloc(), system_control); static Log_root log_root (ep, sliced_heap); - static Io_mem_root io_mem_root (ep, ep, platform().io_mem_alloc(), - platform().ram_alloc(), sliced_heap); - static Irq_root irq_root (platform().irq_alloc(), sliced_heap); - static Trace_root trace_root (core_ram_alloc, local_rm, ep, sliced_heap, + static Io_mem_root io_mem_root (ep, ep, io_mem_ranges, ram_ranges, sliced_heap); + static Irq_root irq_root (irq_ranges, sliced_heap); + static Trace_root trace_root (core_ram, core_rm, ep, sliced_heap, Core::Trace::sources(), trace_policies); static Core_service rom_service (services, rom_root); @@ -293,26 +155,20 @@ void Genode::bootstrap_component(Genode::Platform &) /* make platform-specific services known to service pool */ platform_add_local_services(ep, sliced_heap, services, Core::Trace::sources(), - core_ram_alloc, local_rm, platform().io_port_alloc()); - - size_t const avail_ram_quota = core_pd.avail_ram().value; - size_t const avail_cap_quota = core_pd.avail_caps().value; + core_ram, core_rm, io_port_ranges); - size_t const preserved_ram_quota = 224*1024; - size_t const preserved_cap_quota = 1000; - - if (avail_ram_quota < preserved_ram_quota) { - error("core preservation exceeds platform RAM limit"); + if (!core_account.ram_account.try_withdraw({ 224*1024 })) { + error("core preservation exceeds available RAM"); return; } - if (avail_cap_quota < preserved_cap_quota) { - error("core preservation exceeds platform cap quota limit"); + if (!core_account.cap_account.try_withdraw({ 1000 })) { + error("core preservation exceeds available caps"); return; } - Ram_quota const init_ram_quota { avail_ram_quota - preserved_ram_quota }; - Cap_quota const init_cap_quota { avail_cap_quota - preserved_cap_quota }; + Ram_quota const init_ram_quota = core_account.ram_account.avail(); + Cap_quota const init_cap_quota = core_account.cap_account.avail(); /* CPU session representing core */ static Cpu_session_component @@ -320,19 +176,17 @@ void Genode::bootstrap_component(Genode::Platform &) Session::Resources{{Cpu_session::RAM_QUOTA}, {Cpu_session::CAP_QUOTA}}, "core", Session::Diag{false}, - core_ram_alloc, local_rm, ep, pager_ep, Core::Trace::sources(), "", + core_ram, core_rm, ep, pager_ep, Core::Trace::sources(), "", Affinity::unrestricted(), Cpu_session::QUOTA_LIMIT); - Cpu_session_capability core_cpu_cap = core_cpu.cap(); - - log("", init_ram_quota.value / (1024*1024), " MiB RAM and ", init_cap_quota, " caps " - "assigned to init"); + log(init_ram_quota.value / (1024*1024), " MiB RAM and ", + init_cap_quota, " caps assigned to init"); - static Reconstructible - init(services, local_rm, core_pd, core_pd_cap, core_cpu, core_cpu_cap, - init_cap_quota, init_ram_quota, ep); + static Reconstructible + init(services, ep, core_rm, core_ram, core_account, + core_cpu, core_cpu.cap(), init_cap_quota, init_ram_quota); - platform().wait_for_exit(); + Core::platform().wait_for_exit(); init.destruct(); } diff --git a/repos/base/src/core/pd_session_component.cc b/repos/base/src/core/pd_session_component.cc index 847fbe387e8..04f9b0c1b71 100644 --- a/repos/base/src/core/pd_session_component.cc +++ b/repos/base/src/core/pd_session_component.cc @@ -116,8 +116,7 @@ Pd_session::Ref_account_result Pd_session_component::ref_account(Capability_ram_account.constructed()) return; - _cap_account.construct(_cap_quota_guard(), _label, *pd->_cap_account); - _ram_account.construct(_ram_quota_guard(), _label, *pd->_ram_account); + ref_accounts(*pd->_ram_account, *pd->_cap_account); result = Ref_account_result::OK; }); diff --git a/repos/base/src/core/signal_transmitter_noinit.cc b/repos/base/src/core/signal_transmitter_noinit.cc index 44b16eb9213..25c1848909d 100644 --- a/repos/base/src/core/signal_transmitter_noinit.cc +++ b/repos/base/src/core/signal_transmitter_noinit.cc @@ -15,7 +15,6 @@ */ /* core includes */ -#include #include using namespace Core; @@ -24,4 +23,4 @@ using namespace Core; void Core::init_core_signal_transmitter(Rpc_entrypoint &) { } -Rpc_entrypoint &Core_env::signal_ep() { return _entrypoint; } +Rpc_entrypoint &Core::core_signal_ep(Rpc_entrypoint &core_ep) { return core_ep; } diff --git a/repos/base/src/core/signal_transmitter_proxy.cc b/repos/base/src/core/signal_transmitter_proxy.cc index 9e9a0f3f790..67fcbf9d7df 100644 --- a/repos/base/src/core/signal_transmitter_proxy.cc +++ b/repos/base/src/core/signal_transmitter_proxy.cc @@ -17,9 +17,9 @@ #include /* core includes */ -#include #include #include +#include /* base-internal includes */ #include @@ -46,9 +46,10 @@ void Signal_transmitter::submit(unsigned cnt) } -Rpc_entrypoint &Core_env::signal_ep() +Rpc_entrypoint &Core::core_signal_ep(Rpc_entrypoint &) { - static Rpc_entrypoint ep(nullptr, ENTRYPOINT_STACK_SIZE, + size_t const STACK_SIZE = 20 * 1024; + static Rpc_entrypoint ep(nullptr, STACK_SIZE, "signal_entrypoint", Affinity::Location()); return ep; } diff --git a/repos/base/src/include/base/internal/globals.h b/repos/base/src/include/base/internal/globals.h index 961eb81ed78..40ecde5d8d0 100644 --- a/repos/base/src/include/base/internal/globals.h +++ b/repos/base/src/include/base/internal/globals.h @@ -58,6 +58,8 @@ namespace Genode { void prepare_init_main_thread(); void bootstrap_component(Platform &); void binary_ready_hook_for_platform(); + + extern bool inhibit_tracing; } void genode_exit(int);