Remove 'Env::reinit' and 'Env::reinit_main_thread'

Fixes #4404
This commit is contained in:
Norman Feske 2022-02-03 13:58:52 +01:00
parent 62b4871c5c
commit 50c2b0066f
25 changed files with 15 additions and 285 deletions

View File

@ -25,8 +25,7 @@ using namespace Genode;
** Startup library support **
*****************************/
void prepare_init_main_thread() { }
void prepare_reinit_main_thread() { }
void prepare_init_main_thread() { }
/************

View File

@ -38,14 +38,6 @@ void prepare_init_main_thread()
}
void prepare_reinit_main_thread()
{
construct_at<Capability_map>(&cap_map());
cap_idx_alloc().reinit();
prepare_init_main_thread();
}
/************
** Thread **
************/

View File

@ -58,9 +58,6 @@ void prepare_init_main_thread()
}
void prepare_reinit_main_thread() { prepare_init_main_thread(); }
/************
** Thread **
************/

View File

@ -56,9 +56,6 @@ void Thread::_init_platform_thread(size_t weight, Type type)
addr_t const utcb_new = (addr_t)&_stack->utcb() - stack_area;
Region_map * const rm = env_stack_area_region_map;
if (type == REINITIALIZED_MAIN)
rm->detach(utcb_new);
/* remap initial main-thread UTCB according to stack-area spec */
try { rm->attach_at(Hw::_main_thread_utcb_ds, utcb_new, utcb_size); }
catch(...) {

View File

@ -31,7 +31,6 @@ SRC_CC := main.cc \
core_log.cc \
core_log_out.cc \
default_log.cc \
env_reinit.cc \
heartbeat.cc \
thread.cc \
thread_myself.cc
@ -61,7 +60,6 @@ vpath heartbeat.cc $(GEN_CORE_DIR)
vpath thread.cc $(BASE_DIR)/src/lib/base
vpath thread_myself.cc $(BASE_DIR)/src/lib/base
vpath trace.cc $(BASE_DIR)/src/lib/base
vpath env_reinit.cc $(REP_DIR)/src/lib/base
vpath dataspace_component.cc $(REP_DIR)/src/core/spec/$(BOARD)
vpath io_mem_session_component.cc $(REP_DIR)/src/core/spec/$(BOARD)
vpath irq_session_component.cc $(REP_DIR)/src/core/spec/$(BOARD)

View File

@ -91,9 +91,6 @@ class Genode::Platform_env_base : public Env_deprecated
Cpu_session_capability cpu_session_cap() override { return _cpu_session_cap; }
Pd_session *pd_session() override { return &_local_pd_session; }
Pd_session_capability pd_session_cap() override { return _pd_session_cap; }
void reinit(Native_capability::Raw) override;
void reinit_main_thread(Capability<Region_map> &) override;
};

View File

@ -1,24 +0,0 @@
/*
* \brief Environment reinitialization
* \author Norman Feske
* \date 2016-04-29
*
* Support functions for implementing fork on Noux, which is not supported on
* Linux.
*/
/*
* Copyright (C) 2016-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.
*/
/* base-internal includes */
#include <base/internal/platform_env.h>
void Genode::Platform_env_base::reinit(Native_capability::Raw) { }
void Genode::Platform_env_base::reinit_main_thread(Capability<Region_map> &) { }

View File

@ -100,14 +100,6 @@ void prepare_init_main_thread()
}
}
void prepare_reinit_main_thread()
{
using namespace Genode;
construct_at<Capability_map>(&cap_map());
construct_at<Initial_cap_range>(&initial_cap_range());
prepare_init_main_thread();
}
/************
** Thread **

View File

@ -81,7 +81,7 @@ void Thread::_init_platform_thread(size_t weight, Type type)
native_thread().ec_sel = Native_thread::INVALID_INDEX;
/* for main threads the member initialization differs */
if (type == MAIN || type == REINITIALIZED_MAIN) {
if (type == MAIN) {
_thread_cap = main_thread_cap();
native_thread().exc_pt_sel = 0;

View File

@ -65,9 +65,6 @@ void prepare_init_main_thread()
}
void prepare_reinit_main_thread() { prepare_init_main_thread(); }
/************
** Thread **
************/

View File

@ -32,8 +32,6 @@ void prepare_init_main_thread()
main_thread_tid = Pistachio::L4_Myself();
}
void prepare_reinit_main_thread() { prepare_init_main_thread(); }
/************
** Thread **

View File

@ -64,18 +64,6 @@ static unsigned &rcv_sel()
** Startup library support **
*****************************/
void prepare_reinit_main_thread()
{
/**
* Reset selector to invalid, so that a new fresh will be allocated.
* The IPC buffer of the thread must be configured to point to the
* receive selector which is done by Capability_space::alloc_rcv_sel(),
* which finally calls seL4_SetCapReceivePath();
*/
rcv_sel() = 0;
}
/**
* Convert Genode::Msgbuf_base content into seL4 message
*

View File

@ -141,33 +141,6 @@ struct Genode::Env : Interface
*/
virtual void exec_static_constructors() = 0;
/**
* Reload parent capability and reinitialize environment resources
*
* This method is solely used for implementing fork in Noux. After forking
* a process, the new child process is executed within a copy of the
* address space of the forking process. Thereby, the new process inherits
* the original 'env' object of the forking process, which is meaningless
* in the context of the new process. By calling this function, the new
* process is able to reinitialize its 'env' with meaningful capabilities
* obtained via its updated parent capability.
*
* \noapi
*/
virtual void reinit(Native_capability::Raw) = 0;
/**
* Reinitialize main-thread object
*
* \param stack_area_rm new region map of the stack area
*
* This function is solely used for implementing fork as provided by the
* Noux environment.
*
* \noapi
*/
virtual void reinit_main_thread(Capability<Region_map> &stack_area_rm) = 0;
/**
* Attempt the creation of a session
*

View File

@ -138,7 +138,7 @@ class Genode::Thread
* Some threads need special treatment at construction. This enum
* is solely used to distinguish them at construction.
*/
enum Type { NORMAL, MAIN, REINITIALIZED_MAIN };
enum Type { NORMAL, MAIN };
private:

View File

@ -87,34 +87,6 @@ struct Genode::Env_deprecated : Interface
*/
virtual Pd_session *pd_session() = 0;
virtual Pd_session_capability pd_session_cap() = 0;
/**
* Reload parent capability and reinitialize environment resources
*
* This function is solely used for implementing fork semantics.
* After forking a process, the new child process is executed
* within a copy of the address space of the forking process.
* Thereby, the new process inherits the original 'env' object of
* the forking process, which is meaningless in the context of the
* new process. By calling this function, the new process is able
* to reinitialize its 'env' with meaningful capabilities obtained
* via its updated parent capability.
*
* \noapi
*/
virtual void reinit(Native_capability::Raw) = 0;
/**
* Reinitialize main-thread object
*
* \param stack_area_rm new RM session of the stack area
*
* This function is solely used for implementing fork semantics
* as provided by the Noux environment.
*
* \noapi
*/
virtual void reinit_main_thread(Capability<Region_map> &stack_area_rm) = 0;
};
#endif /* _INCLUDE__DEPRECATED__ENV_H_ */

View File

@ -1,5 +1,5 @@
SRC_CC += default_log.cc
SRC_CC += env_deprecated.cc stack_area.cc env_reinit.cc main_thread_cap.cc
SRC_CC += env_deprecated.cc stack_area.cc main_thread_cap.cc
SRC_CC += rpc_cap_alloc.cc heartbeat.cc
SRC_CC += vm.cc

View File

@ -99,9 +99,6 @@ class Genode::Core_env : public Env_deprecated, Noncopyable
Cpu_session *cpu_session() override { ASSERT_NEVER_CALLED; }
Cpu_session_capability cpu_session_cap() override { ASSERT_NEVER_CALLED; }
Pd_session_capability pd_session_cap() override { return _pd_session.cap(); }
void reinit(Capability<Parent>::Raw) override { }
void reinit_main_thread(Capability<Region_map> &) override { }
};
#endif /* _CORE__INCLUDE__CORE_ENV_H_ */

View File

@ -96,12 +96,6 @@ class Genode::Platform_env : public Platform_env_base
env_stack_area_region_map = &_stack_area;
}
/*
* Support functions for implementing fork on Noux.
*/
void reinit(Native_capability::Raw) override;
void reinit_main_thread(Capability<Region_map> &) override;
/******************************
** Env_deprecated interface **

View File

@ -94,16 +94,6 @@ namespace {
return Genode::env_session_id_space();
}
void reinit(Native_capability::Raw raw) override
{
Genode::env_deprecated()->reinit(raw);
}
void reinit_main_thread(Capability<Region_map> &stack_area_rm) override
{
Genode::env_deprecated()->reinit_main_thread(stack_area_rm);
}
void _block_for_session()
{
/*

View File

@ -1,90 +0,0 @@
/*
* \brief Environment reinitialization
* \author Norman Feske
* \author Martin Stein
* \date 2012-02-16
*/
/*
* Copyright (C) 2012-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.
*/
/* Genode includes */
#include <util/construct_at.h>
#include <rm_session/connection.h>
/* base-internal includes */
#include <base/internal/platform_env.h>
#include <base/internal/crt0.h>
void prepare_reinit_main_thread();
void reinit_main_thread();
namespace Genode { extern bool inhibit_tracing; }
void Genode::Platform_env::reinit(Native_capability::Raw raw)
{
/*
* This function is unused during the normal operation of Genode. It is
* relevant only for implementing fork semantics such as provided by the
* Noux execution environment.
*
* The function is called by the freshly created process right after the
* fork happened.
*
* The existing 'Platform_env' object contains capabilities that are
* meaningful for the forking process but not the new process. Before the
* the environment can be used, it must be reinitialized with the resources
* provided by the actual parent.
*/
/* avoid RPCs by the tracing framework as long as we have no valid env */
inhibit_tracing = true;
/* do platform specific preparation */
prepare_reinit_main_thread();
/*
* Patch new parent capability into the original location as specified by
* the linker script.
*/
*(Native_capability::Raw *)(&_parent_cap) = raw;
/*
* Re-initialize 'Platform_env' members
*/
Expanding_parent_client * const p = &_parent_client;
construct_at<Expanding_parent_client>(p, parent_cap());
construct_at<Resources>(&_resources, _parent_client);
/*
* Keep information about dynamically allocated memory but use the new
* resources as backing store. Note that the capabilites of the already
* allocated backing-store dataspaces are rendered meaningless. But this is
* no problem because they are used by the 'Heap' destructor only, which is
* never called for heap instance of 'Platform_env'.
*/
_heap.reassign_resources(&_resources.pd, &_resources.rm);
}
void
Genode::Platform_env::
reinit_main_thread(Capability<Region_map> &stack_area_rm)
{
/* reinitialize stack area RM session */
Region_map * const rms = env_stack_area_region_map;
Region_map_client * const rmc = dynamic_cast<Region_map_client *>(rms);
construct_at<Region_map_client>(rmc, stack_area_rm);
/* reinitialize main-thread object */
::reinit_main_thread();
/* re-enable tracing */
inhibit_tracing = false;
}

View File

@ -204,8 +204,7 @@ Thread::Thread(size_t weight, const char *name, size_t stack_size,
_cpu_session(cpu_session),
_affinity(affinity),
_trace_control(nullptr),
_stack(type == REINITIALIZED_MAIN ?
_stack : _alloc_stack(stack_size, name, type == MAIN))
_stack(_alloc_stack(stack_size, name, type == MAIN))
{
_init_platform_thread(weight, type);
}

View File

@ -56,32 +56,24 @@ extern unsigned char __initial_stack_base[];
/**
* The first thread in a program
*/
class Main_thread : public Thread
struct Main_thread : Thread
{
public:
Main_thread()
:
Thread(Weight::DEFAULT_WEIGHT, "main", MAIN_THREAD_STACK_SIZE, Type::MAIN)
{ }
/**
* Constructor
*
* \param reinit wether this is called for reinitialization
*/
Main_thread(bool reinit)
:
Thread(Weight::DEFAULT_WEIGHT, "main", MAIN_THREAD_STACK_SIZE,
reinit ? Type::REINITIALIZED_MAIN : Type::MAIN)
{ }
/**********************
** Thread interface **
**********************/
/**********************
** Thread interface **
**********************/
void entry() override { }
void entry() override { }
};
Main_thread * main_thread()
{
static Main_thread s(false);
static Main_thread s { };
return &s;
}
@ -134,9 +126,3 @@ extern "C" void init_main_thread()
for (;;);
}
}
/**
* Reinitialize main-thread object according to a reinitialized environment
*/
void reinit_main_thread() { construct_at<Main_thread>(main_thread(), true); }

View File

@ -74,14 +74,6 @@ struct Qt_launchpad_namespace::Local_env : Genode::Env
void close(Parent::Client::Id id) override { return genode_env.close(id); }
void exec_static_constructors() override { }
void reinit(Native_capability::Raw raw) override {
genode_env.reinit(raw);
}
void reinit_main_thread(Capability<Region_map> &stack_area_rm) override {
genode_env.reinit_main_thread(stack_area_rm);
}
};

View File

@ -129,12 +129,6 @@ class Libc::Env_implementation : public Libc::Env, public Config_accessor
/* already done by the libc */
void exec_static_constructors() override { }
void reinit(Native_capability::Raw raw) override {
_env.reinit(raw); }
void reinit_main_thread(Capability<Region_map> &stack_area_rm) override {
_env.reinit_main_thread(stack_area_rm); }
};
#endif /* _LIBC__INTERNAL__ENV_H_ */

View File

@ -98,14 +98,6 @@ class Gdb_monitor::App_child : public Child_policy,
void close(Parent::Client::Id id) override { return genode_env.close(id); }
void exec_static_constructors() override { }
void reinit(Native_capability::Raw raw) override {
genode_env.reinit(raw);
}
void reinit_main_thread(Capability<Region_map> &stack_area_rm) override {
genode_env.reinit_main_thread(stack_area_rm);
}
};
Local_env _env;