Commit Graph

60 Commits

Author SHA1 Message Date
Alexander Boettcher fa2cbdc7cb Fix: don't deference stale pager pointer in core
Reset pager pointer in platform_thread if pager object is removed.

Fixes #532
2012-11-29 13:44:07 +01:00
Alexander Boettcher 727f29f2e9 Remove obsolete cap selector lock
We can use the Genode::Lock abstraction instead of a separate native SM cap.
2012-11-27 10:56:05 +01:00
Norman Feske f2e47ef9f4 Whitespace 2012-11-26 09:45:13 +01:00
Martin Stein 05f5999e71 cpu_session: Access thread state by value 2012-11-23 12:20:22 +01:00
Norman Feske 959df5d46b Generalize handling of PD-session arguments
On Linux, we want to attach additional attributes to processes, i.e.,
the chroot location, the designated UID, and GID. Instead of polluting
the generic code with such Linux-specific platform details, I introduced
the new 'Native_pd_args' type, which can be customized for each
platform. The platform-dependent policy of init is factored out in the
new 'pd_args' library.

The new 'base-linux/run/lx_pd_args.run' script can be used to validate
the propagation of those attributes into core.

Note that this patch does not add the interpretation of the new UID and
PID attributes by core. This will be subject of a follow-up patch.

Related to #510.
2012-11-21 20:04:07 +01:00
Martin Stein 91c27f3f72 base: Tell a mapping wether it maps IO memory. 2012-11-14 16:36:51 +01:00
Alexander Boettcher 7a619b9ede base-nova: solely revoke unused capabilities
Extend tracking of delegated and of translated items. The additional
information is used to solely free up unused/unwanted mapped capabilities and
to avoid unnecessary revokes on capability indexes where nothing have been
received.

Fixes #430
2012-11-07 13:32:40 +01:00
Alexander Boettcher 83039267fa Cleanup: remove 'first' and 'next' of cpu_session
Fixes #10
2012-10-24 11:34:38 +02:00
Alexander Boettcher ec66788f11 NOVA: cleanup - remove _first_sel special handling
Replace dislocation of extern variables with simplistic convention
2012-10-08 15:08:12 +02:00
Alexander Boettcher 6862ab481a NOVA: drop special utcb handling of main thread
Unify handling of UTCBs. The utcb of the main thread is with commit
ea38aad30e at a fixed location - per convention.
So we can remove all the ugly code to transfer the utcb address during process
creation.

To do so also the UTCB of the main thread of Core must be inside Genode's
thread context area to handle it the same way. Unfortunately the UTCB of the
main thread of Core can't be chosen, it is defined by the kernel.

Possible solutions:
- make virtual address of first thread UTCB configurable in hypervisor
- map the utcb of the first thread inside Core to the desired location

This commit implements the second option.

Kernel patch: make utcb map-able
With the patch the Utcb of the main thread of Core is map-able.

Fixes #374

Noux actually uses the sp variable during thread creation and expects to be
set accordingly. This wasn't the case for the main thread, it was ever set
to the address of the main thread UTCB.
2012-10-04 14:35:38 +02:00
Alexander Boettcher 110a69413d NOVA: move context area
Move the context area close to the end of the virtual user available address,
so that Vancouver can obtain as much as possible of the lower virtual address
range for VMs.
2012-09-24 09:17:58 +02:00
Alexander Boettcher ea38aad30e Move context area definition to native_type 2012-09-24 09:17:54 +02:00
Norman Feske 83bdfea9b0 Extend Cpu_session with thread-affinity API
This patch introduces the functions 'affinity' and 'num_cpus' to the CPU
session interface. The interface extension will allow the assignment of
individual threads to CPUs. At this point, it is just a stub with no
actual platform support.
2012-09-05 10:25:04 +02:00
Alexander Boettcher aae3ce348e NOVA: add single-step support used by gdb
Fixes #336
2012-08-30 10:42:38 +02:00
Alexander Boettcher 3b0e4372fe NOVA: setup all exception handlers of a thread 2012-08-30 10:42:38 +02:00
Alexander Boettcher fcd62729d4 NOVA: tunnel thread start parameters via state()
The cpu_session interface fails to be virtualized by gdb_monitor because
platform-nova uses an extended nova_cpu_session interface.

The problem was that threads have been created directly at core without
knowledge of gdb_monitor. This lead to the situation that gdb_monitor didn't
know of all threads to be debugged.

Tunnel the additional parameters required on base-nova through the state()
call of the cpu_session interface before the thread actual is started.
2012-08-30 10:42:26 +02:00
Alexander Boettcher 197a48a26c NOVA: implement pause using recall kernel feature 2012-08-30 10:40:00 +02:00
Alexander Boettcher 841a1fd579 NOVA: extend cpu_session with synchronous pause
The kernel provides a "recall" feature issued on threads to force a thread into
an exception. In the exception the current state of the thread can be obtained
and its execution can be halted/paused.

However, the recall exception is only delivered when the next time the thread
would leave the kernel. That means the delivery is asynchronous and Genode has
to wait until the exception triggered.

Waiting for the exception can either be done in the cpu_session service or
outside the service in the protection domain of the caller.

It turned out that waiting inside the cpu_service is prone to deadlock the
system. The cpu_session interface is one of many session interfaces handled by
the same thread inside Core.

Deadlock situation:
* The caller (thread_c) to pause some thread_p manages to establish the call
  to the cpu_session thread_s of Core but get be interrupted before issuing
  the actual pause (recall) command.
* Now the - to be recalled thread_p - is scheduled and tries to invoke another
  service of Core, like making log output.
* Since the Core thread_s is handling the session request of thread_c, the
  kernel uses the timeslice of thread_p to help to finish the request handled
  by thread_s.
* Thread_s issues the actual pause/recall on thread_p and blocks inside Core
  to wait for the recall exception to be issued.
* thread_p will leave not the kernel before finishing it actual IPC with
  thread_s which is blocked waiting for thread_p.

That is the reason why the waiting/blocking for the recall exception taking
place must be done on NOVA in the context of the caller (thread_1).

Introduce a pause_sync call to the cpu_session which returns a semaphore
capability to the caller. The caller blocks on the semaphore and is woken up
when the pager of thread_p receives the recall exception with the state of
thread_p.
2012-08-30 10:40:00 +02:00
Alexander Boettcher 0d03a91b80 NOVA: Use thread_state with all registers 2012-08-30 10:40:00 +02:00
Alexander Boettcher 869abe4ec6 NOVA: make noux_tool_chain happy
Multiple calls to get the dataspace capability on NOVA lead to the situation
that the caller gets each time a new mapping of the same capability at
different indexes.

The client/caller assumes to get every time the very same index, e.g. in
Noux the index is used to look up structures.

Cache the dataspace capability returned via a rm_session for base-nova.
2012-08-17 11:43:04 +02:00
Alexander Boettcher 6899dd3d0a NOVA: fix compiler warning 2012-08-16 10:03:07 +02:00
Alexander Boettcher dddd602b48 NOVA: fix invalid cap detection 2012-08-10 10:58:14 +02:00
Alexander Boettcher c06c2887f2 NOVA: don't use externals in sleep forever
Not required.
2012-08-09 14:14:28 +02:00
Alexander Boettcher 2726740d6b NOVA: enable specifying a receive index for IPC
Extend Native_capability type to hold a specific selector index where the to
be received cap during a IPC should be mapped to. This feature is required to
place created caps by the cap_session at specific indexes. This feature is
used by Vancouver to setup the virtualization exception portals (created by
the cap_session) at the intended indexes.
2012-08-09 11:09:42 +02:00
Alexander Boettcher f68482f87a NOVA: add support to cpu_session to create vCPUs
Extend base-nova specific cpu_session to create also vCPUs.
2012-08-09 11:09:42 +02:00
Alexander Boettcher 4342d0d234 NOVA: let thread die if SM cap is invalid
Patch prevents following bugs:

* In sleep_forever the thread return from semaphore down if cap is revoked
  during destruction of a thread. This causes an endless loop consuming time
  not available for other threads.
* In lock_helper and cap_sel_alloc the thread return from the lock() method
  even if the semaphore down call failed because of an revoked semaphore.

  This lead to the situation that a thread subject to de-construction returns
  from the lock method, but not holding the lock, entering the critical section
  and modifying state inside the critical section. Another thread in parallel
  already in the critical section or entering the critical section also
  modifies the state. This lead to curious bugs ...
* thread_nova, thread_start, irq_session
  Detect early bugs if the SM is gone unexpectedly where it should never
  happen.
2012-08-09 11:09:42 +02:00
Alexander Boettcher e3a7d2220d NOVA: Use everywhere same value for a invalid cap 2012-08-09 11:09:42 +02:00
Alexander Boettcher e44648e1ab NOVA: remove pd selector from non Core code
Pd selector isn't used beside core anymore - remove all occurrences inside base
code.
2012-08-09 11:09:41 +02:00
Alexander Boettcher b6ea5714d7 NOVA: create sm solely in core
Any kernel objects are now created solely by core - namely pt, ec, sm and sc.
2012-08-09 11:09:41 +02:00
Alexander Boettcher 5620eca7b9 NOVA: force to map cap in pd_session::assing_pd 2012-08-09 11:09:41 +02:00
Alexander Boettcher 4155585267 NOVA: Adjust native_capability type
It now can hold a right bit used during IPC to demote rights of the to be
transfered capability.

The local_name field in the native_capability type is not needed anymore
in NOVA. Simplify the class, remove it from constructors and adapt all
invocations in base-nova.

Unfortunately local_name in struct Raw is still used in generic base code
(process.cc, reload_parent_cap.cc), however has no effect in base-nova.
2012-08-09 11:09:41 +02:00
Alexander Boettcher 7550f243ad NOVA: use cap_session to allocate portals 2012-08-09 11:09:41 +02:00
Alexander Boettcher 0a89d8dbb4 NOVA: extend cpu_session for base-nova 2012-08-09 11:09:40 +02:00
Alexander Boettcher cb859a4785 NOVA: extend cap session for base-nova 2012-08-09 11:09:40 +02:00
Alexander Boettcher ddd4b9633d NOVA: add rights mask and enums for kernel errors 2012-08-09 11:09:40 +02:00
Alexander Boettcher 755ed3dc90 NOVA: Use solely unsigned types for selectors 2012-08-09 11:09:40 +02:00
Alexander Boettcher 998ebfc01b NOVA: Fix cleanup of received capabilities, #268
MsgBuf has to keep the number of received capabilities in order
to free/know correctly unused and unwanted capabilities. Explicitly
call rcv_msg->post_ipc to store this information in a MsgBuf.

Don't reset rcv_msg in ipc.cc, since this is used during
un-marshalling of caps in ipc.h afterwards. The MsgBuf is reseted when its
de-constructor is called.
2012-08-09 10:24:01 +02:00
Alexander Boettcher e829288069 NOVA: remove global unique ids for user objects
With this patch solely the local ids are used, no global unique ids
are transfered anymore during IPC.

demo.run, signal.run, noux_tool_chain.run works up to the same
point as before the patches for issue #268.

Fixes #268
2012-08-09 10:24:01 +02:00
Alexander Boettcher 2b161b7aff NOVA: use translate feature of kernel, issue #268
Kernel patch:
Introduce a transfer item type to express that a cap should be translated
and if this fails to map it instead.

It would be possible without this combined transfer item type however
with additional overhead. In this case Genode/NOVA would
have to map and translate all caps used as parameter in IPC. It would look
like this:
* If the map and translation succeed, the cap at the new cap index
  would have to be revoked. Then the translated cap index can be used.
* If the map succeeds and the translation fails then the mapped cap index
  can be used.
* It would become complicated when multiple caps are mapped and translated
  and only some of the translation succeed. In such cases Genode would have
  to figure out the right relation of translated/mapped and not
  translated/mapped caps. It would require to make some assumption about the
  order how translated/mapped caps are reported at the UTCB by the kernel.
All the points above lead to the decision to create a separate transfer item
type for that.

Genode:
Most the times the translation succeeds, mapping of caps happens either
seldom. This takes now a bit the pressure of not enough aligned receive
cap windows as described in issue #247.

The patch mainly adds adjustments to handle the
translated and mapped caps correctly especially during freeing of the
receive window (don't free translated cap indexes).

Fixes #268
2012-08-09 10:24:00 +02:00
Alexander Boettcher 44ef8912d6 Add a bit array and bit allocator, issue #247
Add a allocator using bit maps to maintain used/unused caps.
It supports the allocation of 2^n aligned caps solely and
freeing of caps.

Fixes #247
2012-08-09 10:23:55 +02:00
Alexander Boettcher 4960370602 NOVA: fix some enum *_MASK to fit for 32 as 64 bit
The BASE_MASK and QUANTUM_MASK fitted only for 32 bit, for 64 bit
they are bigger. Adjust them to fit for both architectures.
2012-07-23 14:05:58 +02:00
Alexander Boettcher 1d6a00f01a Cleanup: cap allocation
Allocate exc_pt_sel inside Thread_base object
instead of pager object, since it is a thread
specific characteristic.

Same for freeing of the thread capabilities:
- ec, sc, rs, exc_pt_sel is thread specific
and has nothing to do in server nor pager object.
2012-07-04 14:56:46 +02:00
Alexander Boettcher 1a94c3b623 Fix: thread identifier comparator
The invalid thread is specified as 0,0,-1 (ec cap, sc cap, sem cap).
The main thread is specified as 0,0,0.

The comparator identified "tid_main == tid_invalid" as equal,
which is obviously wrong.

The patch compares at least ec and sem cap.
2012-07-04 14:56:46 +02:00
Alexander Boettcher cd886bff6a Move semaphore op codes to generic syscall 2012-07-04 14:56:45 +02:00
Alexander Boettcher a4cac757e2 NOVA: Use right syscall function for ec_ctrl 2012-06-22 11:38:14 +02:00
Alexander Boettcher 0bf642ff9a Establish mappings during reply, #248
Caller thread sends echo thread mapping information. Echo thread
establish during reply the mappings.

Fixes #248
2012-06-20 19:44:08 +02:00
Alexander Boettcher 9ebbf9c9f2 Check that typed item fits on UTCB, issue #248
Check that there is enough room for a typed item on the
UTCB. Otherwise deny to add the item and return false.
Enable explicitly a return unused warning to get the right
attention.
2012-06-20 19:44:08 +02:00
Alexander Boettcher 0c2adf7ddd Msg_words are 16 bit, adjust bit mask. 2012-06-20 19:44:08 +02:00
Alexander Boettcher 67864d35f1 Structures must be dense packed, issue #248
Take care that utcb, hip, crd structure are dense packed by compiler.
2012-06-20 19:44:07 +02:00
Alexander Boettcher 4534d656a8 NOVA: Improve stability of process destruction
The UTCB of the thread cleaning up thread objects has been unmapped.
However the UTCB of the destroyed thread must be unmapped.

Objects must explicitly be made unreachable before cleaning up. The
server and pager objects must be unreachable before they can be freed.
Both object types are threads. Revoking the thread(EC) cap on NOVA
doesn't mean that the thread stops executing. All portals pointing to a
thread are still reachable by clients even if the last EC cap is gone in
user land. So it must be taken care that no portals are pointing anymore
to a thread when the associated objects are getting destroyed. This
commit handles this.

Additionally, even if the last portal is gone - there can be still an
ongoing request handled by such server/pager object/threads. For each
such object an additional portal is created. This object is called
'cleanup portal' and is only local to the object. After all portals are
revoked the cleanup portal is called. When the call returns we know that
nobody is anymore handled by the object since all remotely available
portals are gone.

Fixes #20
2012-06-20 19:44:07 +02:00