base-linux: inhibit tracing in region-map attach/detach

Tracing must be inhibited in attach/detach as RPC trace points may
trigger attachment of trace dataspaces, which would result in nested
mutex acquisition.

This prevents errors in test-trace_logger like follows.

  [init -> depot_autopilot] 0.140 [init -> dynamic_rom] Error: deadlock ahead, mutex=0x500e6f00, return ip=0x50053ed7

Fixes #4607
This commit is contained in:
Christian Helmuth 2022-09-12 16:55:18 +02:00 committed by Norman Feske
parent 80a2f7224e
commit c8b4b83b71

View File

@ -172,6 +172,24 @@ void Region_map_mmap::_add_to_rmap(Region const &region)
}
/*
* Tracing must be inhibited in attach/detach as RPC trace points may trigger
* attachment of trace dataspaces, which would result in nested mutex
* acquisition.
*/
namespace Genode { extern bool inhibit_tracing; }
struct Inhibit_tracing_guard
{
bool old_value = inhibit_tracing;
Inhibit_tracing_guard() { inhibit_tracing = true; }
~Inhibit_tracing_guard() { inhibit_tracing = old_value; }
};
Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds,
size_t size, off_t offset,
bool use_local_addr,
@ -180,6 +198,8 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds,
{
Mutex::Guard mutex_guard(mutex());
Inhibit_tracing_guard it_guard { };
/* only support attach_at for sub RM sessions */
if (_sub_rm && !use_local_addr) {
error("Region_map_mmap::attach: attaching w/o local addr not supported");
@ -325,6 +345,8 @@ void Region_map_mmap::detach(Region_map::Local_addr local_addr)
{
Mutex::Guard mutex_guard(mutex());
Inhibit_tracing_guard it_guard { };
/*
* Cases
*