diff --git a/repos/base-linux/src/lib/base/region_map_mmap.cc b/repos/base-linux/src/lib/base/region_map_mmap.cc index 01946e4204..46b34ae66b 100644 --- a/repos/base-linux/src/lib/base/region_map_mmap.cc +++ b/repos/base-linux/src/lib/base/region_map_mmap.cc @@ -172,6 +172,24 @@ void Region_map_mmap::_add_to_rmap(Region const ®ion) } +/* + * 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 *