Commit Graph

192 Commits

Author SHA1 Message Date
Norman Feske bcdc706f42 Unify 'ipc.h' and 'ipc_generic.h' across platforms
The distinction between 'ipc.h' and 'ipc_generic.h' is no more. The only
use case for platform-specific extensions of the IPC support was the
marshalling of capabilities. However, this case is accommodated by a
function interface ('_marshal_capability', '_unmarshal_capability'). By
moving the implementation of these functions from the headers into the
respective ipc libraries, we can abandon the platform-specific 'ipc.h'
headers.
2013-02-14 13:23:37 +01:00
Norman Feske b1f63e3356 Turn 'platform_env.h' into a private header
This patch removes 'platform_env.h' from the public API headers because
this header was not part of the API anyway.
2013-02-14 13:23:36 +01:00
Alexander Boettcher ee8eea9330 nova: fix lock guard usage in cap selector
Issue #549
2013-02-11 12:11:48 +01:00
Alexander Boettcher 64dbe08359 nova: kill thread with no pager where recall fails
Issue #549
2013-02-11 12:01:27 +01:00
Alexander Boettcher edd30b56a2 nova: fix pager cleanup handling
The cleanup call must be performed already during the _dissolve function
shortly after the object at the cap_session is freed up. Otherwise there
is the chance that an in-flight IPC will find the to be dissolved function
again.

Bomb test triggered the case, that a already dissolved rpc_object was found
by a in-flight IPC. If the rpc_object was already freed up by alloc->destroy
the thread using this stale rpc_object pointer cause page-faults in core.

Fixes partly #549
2013-02-11 12:01:26 +01:00
Alexander Boettcher 28f7cf5dc2 nova: fix cleanup handling in server object
As first step the rpc object must be freed up so that the kernel object
(portal) vanishes. Then the object must be removed from the internal object
pool list so that the object can't be obtained anymore. And then the cleanup
call can be performed (_leave_server_object) since now all names to the
rpc_object are gone.

Doing it in different order (as before the commit) there is a very very little
chance (but the bomb test triggers it occasionally) that the rpc_object can be
obtained again by an incoming IPC - even it is already scheduled for removal.

Fixes partly #549
2013-02-11 12:01:26 +01:00
Alexander Boettcher 08d87adb4b nova: use kernel branch adjusted to Genode
Since we have now more than a handful patches to the vanilla kernel, we
better switch to a separate git repository in order to review and to maintain
the patches more effectively.

Remove the patches, they are already in the kernel branch.

Fixes #394
2013-02-11 12:01:26 +01:00
Alexander Boettcher f762e8e4fd nova: increase number of available cap indexes
Noux test requires some more indexes. We don't free all up because of a missing
reference counting implementation of indexes in base-nova.

Issue #394
2013-02-11 12:01:25 +01:00
Alexander Boettcher 9453d319cb base: add remove_client to rm_session
Fixes #13
2013-02-11 12:01:25 +01:00
Alexander Boettcher 486b27a1b8 nova: ease debugging if no cap indexes are left
If we ran out of capabilities indexes, the bit allocator throws an exception.
If this happens the code seems to hang and nothing happens.

Instead one could catch the exception and print some diagnostic message.
This would be nice, but don't work. Printing some diagnostic message itself
tries to do potentially IPC and will allocate new capability indexes at
least for the receive window.

So, catch the exception and let the thread die, so at least the instruction
pointer is left as trace to identify the reason of the trouble.

Fixes #625
2013-01-24 11:09:15 +01:00
Alexander Boettcher e817163f1a nova: use lock guard instead of explicit calls
If an exception is thrown the lock is released automatically, so that
other callers may get a capability index if in between some are freed. Fixes
some deadlocks if Genode is short on capability indexes.

Related to #625
2013-01-24 11:05:41 +01:00
Alexander Boettcher 6cc0d69aa7 nova: recall thread if exception can't be resolved
Recall faulting thread and block pager thread. The pager get resumed as soon
as the fault gets resolved by the rm_session (or never ever).

Fixes #621
2013-01-21 11:40:38 +01:00
Norman Feske 8fe0c6c91c base-nova: Coding style 2013-01-11 23:11:07 +01:00
Norman Feske bef78dd9f8 Core: Fix registration of CPU exception handler 2013-01-11 22:16:25 +01:00
Norman Feske 0ca774592f Fix default base-nova/etc/specs.conf 2013-01-11 20:54:46 +01:00
Norman Feske 73ab30c22c Update copyright headers to 2013 2013-01-10 21:44:47 +01:00
Alexander Boettcher e8c063a8b4 base: release signal context from signal list
Remove signal context object from signal source component list (_signal_queue)
before destruction, otherwise we get a dangling pointer.

On native hardware for base-nova, the signal source thread triggered page
faults in the Signal_source_component::wait_for_signal() method when the signal
context got freed up in Signal_session_component::free_context but was still
enqueued in Signal_source_component::_signal_queue.

Fixes #600
2013-01-10 21:17:42 +01:00
Alexander Boettcher c2d3543e62 base: replace obj_by_* by lookup_and_lock
Add functionality to lookup an object and lock it. Additional the case is
handled that a object may be already in-destruction and the lookup will deny
returning the object.

The object_pool generalize the lookup and lock functionality of the rpc_server
and serve as base for following up patches to fix dangling pointer issues.
2013-01-10 11:13:13 +01:00
Norman Feske 9f82764316 core: Introduce default CPU exception handler
The CPU session interfaces comes with the ability to install an
exception handler per thread. This patch enhances the feature with the
provision of a default signal handler that is used if no thread-specific
handler is installed. The default signal handler can be set by
specifying an invalid thread capability and a valid signal context
capability.

Furthermore, this patch relaxes the requirement of the order of the
calls of 'exception_handler' and 'set_pager'. Originally, the exception
handler could be installed not before setting a pager. Now, we remember
the installed exception handler in the 'Cpu_thread' and propagate to to
the platform thread at a later time.
2013-01-04 15:26:16 +01:00
Alexander Boettcher 1211516c08 nova: decode type of page fault in core
Ease reading debugging messages if a core thread fails.
2012-12-21 14:54:20 +01:00
Alexander Boettcher cef9af1978 nova: set page fault handler for core threads
Ease debugging if a core thread fail.
2012-12-21 14:54:20 +01:00
Alexander Boettcher 2426030c5b nova: extend cap_session to free up portals 2012-12-21 14:54:20 +01:00
Alexander Boettcher 8c4e1b7eb0 base: extend cap_session with memory allocator
Required to allocate memory to remember per session created capabilities.
During session destruction all capabilities have to be freed up.
2012-12-21 14:54:20 +01:00
Christian Prochaska 42cef716e1 CPU session meta data RAM quota upgrade support
Fixes #541.
2012-11-30 16:27:29 +01:00
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
Norman Feske 0dbb5e1696 Propagate 'Range_allocator::alloc_aligned' errors
This patch reflects eventual allocation errors in a more specific way to
the caller of 'alloc_aligned', in particular out-of-metadata and
out-of-memory are considered as different conditions.

Related to issue #526.
2012-11-28 22:51:09 +01:00
Christian Prochaska 6c25ced5f2 base-nova: fix core virtual memory region leak
Revert the core-local mapping created in 'Ram_session_component::_clear_ds()'
and free the virtual memory region allocated for this mapping when a
RAM dataspace gets freed.

Fixes #416.
2012-11-27 20:21:36 +01:00
Alexander Boettcher 51f99106bd NOVA: don't exclude 2. page of virt. address space
Fixes #519
2012-11-27 15:33:03 +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
Alexander Boettcher c63a6d94f6 NOVA: add chain_loader 'bender'
'Bender' can detect serial ports accessible via PCI and writes the I/O ports
to the Bios Data area (BDA).

Usage together with the PXE bootloader ease life running Genode/NOVA on native
hardware, where a standard serial device isn't available anymore anywhere.
2012-11-23 12:20:28 +01:00
Alexander Boettcher 94c6b7bd10 NOVA: map boot modules rx only 2012-11-23 12:20:28 +01:00
Alexander Boettcher d5ef49acf9 NOVA: fix bootstrap if modules are loaded above 3G
We don't can use map_local_one_to_one for boot modules because it happens
that boot modules can be at addresses above physical 3G boundary for x86_32.

Defer the mapping of modules until the point where the core allocators
are set up properly and then remap the physical pages to virtual addresses
below 3G.
2012-11-23 12:20:27 +01:00
Alexander Boettcher b8ab3673cd NOVA: support to restrict memory rwx bits in core 2012-11-23 12:20:27 +01:00
Alexander Boettcher 4d12464cee Read BIOS data area (BDA) to get serial I/O ports
If the I/O ports are non default (3f8), we had to specify manually the correct
I/O ports. With this commit the BDA is read and the I/O port of the first
serial interface (COM) is taken. If no serial interface is available no device
configuration will be undertaken.
2012-11-23 12:20:27 +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
Norman Feske bcabbe2c92 Add 'Thread_base::join()'
Using the new 'join()' function, the caller can explicitly block for the
completion of the thread's 'entry()' function. The test case for this
feature can be found at 'os/src/test/thread_join'. For hybrid
Linux/Genode programs, the 'Thread_base::join()' does not map directly
to 'pthread_join'. The latter function gets already called by the
destructor of 'Thread_base'. According to the documentation, subsequent
calls of 'pthread_join' for one thread may result in undefined behaviour.
So we use a 'Genode::Lock' on this platform, which is in line with the
other platforms.

Related to #194, #501
2012-11-19 12:43:34 +01:00
Christian Helmuth d23ee02e9a Destruct IPC-server object on entrypoint destruction
The IPC-server object exists solely on the stack of the entrypoint
thread and, therefore, would never be destructed as the thread is just
killed. Now, the object is explicitly destructed in the entrypoint
destructor. An alternative solution could instruct the entrypoint thread
the terminate, which would automatically cleanup its stack.

The object pool is assumed to be empty on destruction of the entrypoint.
If not, we warn and at least dissolve all RPC objects.
2012-11-16 13:55:00 +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 c1d59e81c2 NOVA: use latest kernel from github
Related to issue #431. Requires toolchain rebuild to bump version to 2.22 !!!

Fixes #429
2012-11-05 17:28:51 +01:00
Christian Helmuth 2f357a7224 Firewall-friendly download methods for contrib src
After this commit "make prepare" uses HTTP, HTTPS, or FTP where possible
fvor downloading third-party source codes. This prevents problems with
strict firewall rules where only selected ports are usable.

Unfortunately, git.l4android.org does not support Git via HTTP and,
therefore, the sources need a working Git port (9418).

Fixes #443.
2012-10-30 12:12:42 +01:00
Stefan Kalkowski dc3d784e6d Introduce platform-specific services for core
By now all services in core where created, and registered in the generic
main routine. Although there exists already a x86-specific service (I/O ports)
there was no possibility to announce core-services for certain platforms only.
This commit introduces a hook function in the 'Platform' class, that enables
registration of platform-specific services. Moreover, the io-port service
is offered on x86 platforms only now.
2012-10-29 10:08:29 +01:00
Christian Prochaska 1c064d9e70 core: implement missing context area functions
This patch implements the following functions:

base:
- Context_area_rm_session::detach()
- Context_area_ram_session::free()

base-nova:
- unmap_local()

base-fiasco, base-pistachio:
- unmap_local() stub

This patch partially resolves issue #394.
2012-10-24 11:34:39 +02:00
Christian Prochaska 330980378c base-nova: 'Rm_client::unmap()' fix
Areas of an attached dataspace which have never been accessed cannot get
unmapped. With this patch this case is not treated as error anymore.

Fixes #398.
2012-10-24 11:34:39 +02:00
Alexander Boettcher 83039267fa Cleanup: remove 'first' and 'next' of cpu_session
Fixes #10
2012-10-24 11:34:38 +02:00
Norman Feske 8b0ad007ca Fix warning 2012-10-12 13:10:48 +02:00
Sebastian Sumpf 4a3d852b65 Core: Shared IRQ support for Nova/FOC/OKL4
Implement shared IRQs using 'Irq_proxy' class.

Nova: Added global worker 'Irq_thread' support in core and adapted Irq_session.

FOC: Adapted IRQ session code, x86 has shared IRQ support, ARM uses the old
model. Read and set 'mode' argument (from MADT) in 'Irq_session'.

OKL4: Use generic 'Irq_proxy'

Fixes issue #390
2012-10-11 17:10:16 +02:00
Norman Feske 4a1b545770 Move 'Child' API implementation to library 2012-10-09 13:45:33 +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 f1202139f9 NOVA: fix compiler warning 2012-10-08 15:08:06 +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 7bd0ed7c44 NOVA: fix overflow in address check 2012-09-24 09:17:59 +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 ed2e610178 NOVA: maximize contiguous virtual space for 32/64
Use virtual regions for memory used during core initialization behind context
area. Enables us to start Vancouver VMs up to 1280 MiB, which requires
large virtual regions of contiguous aligned memory.

Exclude used virtual regions of echo and of pager thread in core.
2012-09-24 09:17:57 +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 8526dc4f19 Set ERR_INVALID_OBEJCT if call failed to server
Tell the client that the last operation failed, instead of continuing doing
useless things.
2012-08-10 10:57:54 +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 a7235d2411 NOVA: Use Genode interfaces to bootstrap Vancouver
Since no kernel objects can be created anymore outside Genode::core,
the Vancouver port must be adjusted to use solely the Genode interfaces.

The Vcpu_dispatcher creates all portals via the cpu_session interface and
uses the feature to setup a specific receive window during a IPC (the
cap_session::alloc IPC) to place to be received/to be mapped capability
(virtualization exception portal) at the designed indexes.

The actual vCPU thread extends from a normal Genode::Thread and extends it
by specific vCPU requirements, which are a larger exception base window and
the need by Vancouver to place the SM and EC cap at indexes next to each other.

Fixes #316
2012-08-09 11:09:42 +02:00
Alexander Boettcher 135a5a6bfb Adjust cap_integrity test to NOVA changes 2012-08-09 11:09:42 +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 650a1d47f0 NOVA: Throughly cleanup caps in case of errors 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 2f84fd0434 NOVA: allocate stack size depending on word size 2012-08-09 11:09:41 +02:00
Alexander Boettcher f1fa55e804 NOVA: Suppress warnings in rpc_entrypoint 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 9c57fd7229 NOVA: delegate EC cap solely with recall right
Vancouver recalls the vCPU in the vCPU dispatcher code. Enable the right bit
in the mapped native cap so that Vancouver actually is able to perform this
operation.
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 a6d2042d5b NOVA: kernel patch - remove utcb if ec creation fails 2012-08-09 10:24:01 +02:00
Alexander Boettcher 49ab1bbc44 NOVA: kernel patch - deliver only local portal id 2012-08-09 10:24:01 +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 54ed373468 NOVA: translate item patch, issue #268
Unfortunately, another kernel patch is required for Genode/NOVA to get rid
of global unique ids for objects (issue #268).

Kernel patch:

If a translate of a object capability item inside the same PD
(receiver/sender in same PD) is not successful then he very same item is
returned instead of the null item.

Genode:

Some code in Genode try to map/translate the "root" (the first instance of a)
object capability within the same PD. The translate fails since it is the
first cap and was not delegated beforehand. Instead the cap gets mapped to a
new capability index due to xlt_rcv kernel item patch.

The new local object capability index is used to lookup manged objects
in lists, which however fails because the object is only known by the original
object capability index.

Unfortunately, this happens not only once. Below one example trace and
description is attached.

There are several possible solutions possible:
* Find all places in Genode and replace normal function calls between objects
  with IPC calls, such that all capabilities can be translated during IPC.
** Time consuming to find all spots
** Rather platform specific issue requires re-adjustments in generic Genode
   code
** Not trivial to ever remember this fact during development of new components
   [other platforms have not such a issue, however have global object ids]
** Neither good in terms of performance.

* Use some special system call to the kernel to be able to translate a given
  capability index as long until you find the requested original index.
  (Obviously ...  no comment).

* Kernel patch as this one.

* <your proposal>

Example trace + code description showing the behavior above:

int main(): --- create local services ---
int main(): --- start init ---
[0] DEL OBJ PD:0xc000aa80->0xc000aa80 SB:0x000000aa RB:0x000000ac O:0x00 A:0x1f
int main(): transferred 42 MB to init
[0] DEL OBJ PD:0xc000aa80->0xc000aa80 SB:0x00000120 RB:0x0000013c O:0x00 A:0x1f
[0] DEL OBJ PD:0xc000aa80->0xc000aa80 SB:0x0000016c RB:0x00000168 O:0x00 A:0x1f
Setup ELF failed
[0] XLT OBJ PD:0xc000aa80->0xc000aa80 SB:0x00000168 RB:0x0000016c O:0x00
unknown exception?
int main(): --- init created, waiting for exit condition ---

thread   - file - line - text
-------------------------------------------------------------------------------
thread A - [ 0] -  228 - new Core_child(... rom_session.dataspace() ...)
thread A - [ 1] -   27 - IPC call    - ask for dataspace cap
thread B - [ 2] -   49 - function    - return dataspace cap index 0x120
thread A - [ 1] -   27 - IPC returned - map 0x120 -> 0x13c, translate failed
thread A - ...
thread A - [ 3] -  231 - call _setup_elf()
thread A - [ 3] -   60 - call env->rm_session()->attach()
thread A - [ 4] -   35 - do dataspace object lookup (0x13c)
thread A - [ 4] -   36 - lookup failed (object known as 0x120), throw Exception
thread A - [ 3] -   61 - catch Exception -> return error code "0"
thread A - [ 3] -  233 - "Setup ELF failed" - because error code "0"

File legend:

[0] base/src/core/main.cc
[1] base/include/rom_session/client.h
[2] base-nova/src/core/include/core_rm_session.h
[3] base/src/base/process/process.cc
[4] base-nova/src/core/core_rm_session.cc
2012-08-09 10:24:00 +02:00
Alexander Boettcher 40b40b33c6 NOVA: apply #4 patch to use only local ids, #268 2012-08-09 10:24:00 +02:00
Alexander Boettcher b748d1f17f NOVA: use only local ids in pager code, issue #268 2012-08-09 10:24:00 +02:00
Alexander Boettcher 529a25e190 NOVA: enable map-translate transfer item use, #268 2012-08-09 10:24:00 +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
Martin Stein 9369057f90 Extend RAM/CPU session for base-hw context-areas. 2012-08-02 16:41:21 +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