2012-05-30 20:13:09 +02:00
|
|
|
/*
|
|
|
|
* \brief RM- and pager implementations specific for base-hw and core
|
|
|
|
* \author Martin Stein
|
hw: restrict processor broadcast to TLB flushing
Removes the generic processor broadcast function call. By now, that call
was used for cross processor TLB maintance operations only. When core/kernel
gets its memory mapped on demand, and unmapped again, the previous cross
processor flush routine doesn't work anymore, because of a hen-egg problem.
The previous cross processor broadcast is realized using a thread constructed
by core running on top of each processor core. When constructing threads in
core, a dataspace for its thread context is constructed. Each constructed
RAM dataspace gets attached, zeroed out, and detached again. The detach
routine requires a TLB flush operation executed on each processor core.
Instead of executing a thread on each processor core, now a thread waiting
for a global TLB flush is removed from the scheduler queue, and gets attached
to a TLB flush queue of each processor. The processor local queue gets checked
whenever the kernel is entered. The last processor, which executed the TLB
flush, re-attaches the blocked thread to its scheduler queue again.
To ease uo the above described mechanism, a platform thread is now directly
associated with a platform pd object, instead of just associate it with the
kernel pd's id.
Ref #723
2014-04-28 20:36:00 +02:00
|
|
|
* \author Stefan Kalkowski
|
2012-05-30 20:13:09 +02:00
|
|
|
* \date 2012-02-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2012-2017 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* core includes */
|
2015-06-19 14:58:18 +02:00
|
|
|
#include <pager.h>
|
2013-09-18 13:12:32 +02:00
|
|
|
#include <platform_pd.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
#include <platform_thread.h>
|
2014-04-28 21:31:57 +02:00
|
|
|
#include <translation_table.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2016-06-15 15:04:54 +02:00
|
|
|
/* base-internal includes */
|
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
/**********************
|
|
|
|
** Pager_entrypoint **
|
|
|
|
**********************/
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2015-07-29 10:58:17 +02:00
|
|
|
void Pager_entrypoint::entry()
|
2013-11-14 13:29:47 +01:00
|
|
|
{
|
2017-03-01 15:28:13 +01:00
|
|
|
Untyped_capability cap;
|
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
while (1)
|
|
|
|
{
|
2017-03-01 15:28:13 +01:00
|
|
|
if (cap.valid()) Kernel::ack_signal(Capability_space::capid(cap));
|
|
|
|
|
2014-12-03 14:25:12 +01:00
|
|
|
/* receive fault */
|
2019-10-16 15:07:11 +02:00
|
|
|
if (Kernel::await_signal(Capability_space::capid(_kobj.cap()))) continue;
|
2015-08-10 13:34:16 +02:00
|
|
|
|
2017-03-01 15:28:13 +01:00
|
|
|
Pager_object *po = *(Pager_object**)Thread::myself()->utcb()->data();
|
|
|
|
cap = po->cap();
|
|
|
|
|
|
|
|
if (!po) continue;
|
|
|
|
|
|
|
|
/* fetch fault data */
|
|
|
|
Platform_thread * const pt = (Platform_thread *)po->badge();
|
|
|
|
if (!pt) {
|
|
|
|
Genode::warning("failed to get platform thread of faulter");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
_fault = pt->fault_info();
|
2017-03-01 15:28:13 +01:00
|
|
|
|
|
|
|
/* try to resolve fault directly via local region managers */
|
|
|
|
if (po->pager(*this)) continue;
|
|
|
|
|
|
|
|
/* apply mapping that was determined by the local region managers */
|
|
|
|
{
|
|
|
|
Locked_ptr<Address_space> locked_ptr(pt->address_space());
|
|
|
|
if (!locked_ptr.valid()) continue;
|
|
|
|
|
|
|
|
Hw::Address_space * as = static_cast<Hw::Address_space*>(&*locked_ptr);
|
|
|
|
as->insert_translation(_mapping.virt(), _mapping.phys(),
|
|
|
|
_mapping.size(), _mapping.flags());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* let pager object go back to no-fault state */
|
|
|
|
po->wake_up();
|
2013-11-14 13:29:47 +01:00
|
|
|
}
|
|
|
|
}
|