From 2147c42ec6aec5451549f2ff53f8839dc7fe7b72 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 5 Sep 2016 11:24:51 +0200 Subject: [PATCH] base: unify page-fault notification for kernels * Enable page-fault messages for regions not directly managed by core * Unify output given when a page-fault occurs related to those regions Fix #2082 --- repos/base-fiasco/src/core/include/util.h | 12 ------- repos/base-fiasco/src/core/platform.cc | 8 +++-- repos/base-foc/src/core/include/util.h | 9 ----- repos/base-foc/src/core/pager.cc | 6 ++-- repos/base-foc/src/core/platform.cc | 8 +++-- repos/base-hw/src/core/include/pager.h | 6 +++- repos/base-hw/src/core/include/util.h | 35 ------------------- repos/base-hw/src/core/pager.cc | 19 +++++++--- .../src/core/include/region_map_component.h | 4 ++- repos/base-linux/src/lib/base/thread_linux.cc | 2 +- repos/base-nova/src/core/include/pager.h | 7 +++- repos/base-nova/src/core/include/util.h | 13 ------- repos/base-nova/src/core/pager.cc | 12 ++++++- repos/base-nova/src/core/platform.cc | 5 ++- repos/base-okl4/src/core/include/util.h | 9 ----- repos/base-pistachio/src/core/include/util.h | 12 ------- repos/base-pistachio/src/core/platform.cc | 8 +++-- repos/base-sel4/src/core/include/pager.h | 19 ++++++++-- repos/base-sel4/src/core/include/util.h | 11 ------ repos/base-sel4/src/core/pager.cc | 17 ++++++--- .../src/core/include/cpu_session_component.h | 2 +- .../src/core/include/cpu_thread_component.h | 3 +- repos/base/src/core/include/pager.h | 23 ++++++++++-- .../src/core/include/pd_session_component.h | 3 ++ .../src/core/include/region_map_component.h | 9 +++-- repos/base/src/core/pager_ep.cc | 4 +++ repos/base/src/core/region_map_component.cc | 17 +++++++-- 27 files changed, 142 insertions(+), 141 deletions(-) diff --git a/repos/base-fiasco/src/core/include/util.h b/repos/base-fiasco/src/core/include/util.h index 92df7e7961..03067fed47 100644 --- a/repos/base-fiasco/src/core/include/util.h +++ b/repos/base-fiasco/src/core/include/util.h @@ -98,18 +98,6 @@ namespace Genode { constexpr size_t get_super_page_size() { return L4_SUPERPAGESIZE; } constexpr size_t get_super_page_size_log2() { return L4_LOG2_SUPERPAGESIZE; } - inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, - Region_map::State::Fault_type pf_type, - unsigned long badge) - { - Fiasco::l4_threadid_t tid; - tid.raw = badge; - printf("%s (%s pf_addr=%p pf_ip=%p from %x.%02x)\n", msg, - pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", - (void *)pf_addr, (void *)pf_ip, - (int)tid.id.task, (int)tid.id.lthread); - } - inline addr_t map_src_addr(addr_t core_local_addr, addr_t phys_addr) { return core_local_addr; } diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc index 77161896a5..6a8e6601bf 100644 --- a/repos/base-fiasco/src/core/platform.cc +++ b/repos/base-fiasco/src/core/platform.cc @@ -133,7 +133,9 @@ static void _core_pager_loop() Platform::Sigma0::Sigma0() : - Pager_object(Cpu_session_capability(), Thread_capability(), 0, Affinity::Location()) + Pager_object(Cpu_session_capability(), Thread_capability(), + 0, Affinity::Location(), Session_label(), + Cpu_session::Name("sigma0")) { cap(Capability_space::import(Fiasco::sigma0_threadid, Rpc_obj_key())); } @@ -149,7 +151,9 @@ Platform::Sigma0 *Platform::sigma0() Platform::Core_pager::Core_pager(Platform_pd *core_pd) : Platform_thread(0, "core.pager"), - Pager_object(Cpu_session_capability(), Thread_capability(), 0, Affinity::Location()) + Pager_object(Cpu_session_capability(), Thread_capability(), + 0, Affinity::Location(), Session_label(), + Cpu_session::Name(name())) { Platform_thread::pager(sigma0()); diff --git a/repos/base-foc/src/core/include/util.h b/repos/base-foc/src/core/include/util.h index a94d51d772..fa373c2b75 100644 --- a/repos/base-foc/src/core/include/util.h +++ b/repos/base-foc/src/core/include/util.h @@ -97,15 +97,6 @@ namespace Genode { constexpr size_t get_super_page_size() { return L4_SUPERPAGESIZE; } constexpr size_t get_super_page_size_log2() { return L4_LOG2_SUPERPAGESIZE; } - inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, - Region_map::State::Fault_type pf_type, - unsigned long badge) - { - printf("%s (%s pf_addr=%p pf_ip=%p from %lx)\n", msg, - pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", - (void *)pf_addr, (void *)pf_ip, badge); - } - inline addr_t map_src_addr(addr_t core_local_addr, addr_t phys_addr) { return core_local_addr; } diff --git a/repos/base-foc/src/core/pager.cc b/repos/base-foc/src/core/pager.cc index b998bc5a4e..77bca31383 100644 --- a/repos/base-foc/src/core/pager.cc +++ b/repos/base-foc/src/core/pager.cc @@ -69,9 +69,9 @@ void Pager_entrypoint::entry() /* handle request */ if (obj->pager(_pager)) { /* could not resolv - leave thread in pagefault */ - warning("could not resolve " - "pf=", Hex(_pager.fault_addr()), " ", - "ip=", Hex(_pager.fault_ip())); + warning("page-fault, ", *obj, + " ip=", Hex(_pager.fault_ip()), + " pf-addr=", Hex(_pager.fault_addr())); } else { _pager.set_reply_dst(Native_thread(obj->badge())); reply_pending = true; diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc index f9f470579a..7a2576e4af 100644 --- a/repos/base-foc/src/core/platform.cc +++ b/repos/base-foc/src/core/platform.cc @@ -126,7 +126,9 @@ static void _core_pager_loop() Platform::Sigma0::Sigma0(Cap_index* i) : - Pager_object(Cpu_session_capability(), Thread_capability(), 0, Affinity::Location()) + Pager_object(Cpu_session_capability(), Thread_capability(), + 0, Affinity::Location(), Session_label(), + Cpu_session::Name("sigma0")) { /* * We use the Pager_object here in a slightly different manner, @@ -139,7 +141,9 @@ Platform::Sigma0::Sigma0(Cap_index* i) Platform::Core_pager::Core_pager(Platform_pd *core_pd, Sigma0 *sigma0) : Platform_thread("core.pager"), - Pager_object(Cpu_session_capability(), Thread_capability(), 0, Affinity::Location()) + Pager_object(Cpu_session_capability(), Thread_capability(), + 0, Affinity::Location(), Session_label(), + Cpu_session::Name(name())) { Platform_thread::pager(sigma0); diff --git a/repos/base-hw/src/core/include/pager.h b/repos/base-hw/src/core/include/pager.h index 117ddef9e8..5b9b4c651c 100644 --- a/repos/base-hw/src/core/include/pager.h +++ b/repos/base-hw/src/core/include/pager.h @@ -15,6 +15,7 @@ #define _CORE__INCLUDE__PAGER_H_ /* Genode includes */ +#include #include #include #include @@ -142,7 +143,8 @@ class Genode::Pager_object : public Object_pool::Entry, */ Pager_object(Cpu_session_capability cpu_session_cap, Thread_capability thread_cap, unsigned const badge, - Affinity::Location); + Affinity::Location, Session_label const&, + Cpu_session::Name const&); /** * User identification of pager object @@ -171,6 +173,8 @@ class Genode::Pager_object : public Object_pool::Entry, */ void unresolved_page_fault_occurred(); + void print(Output &out) const; + /****************** ** Pure virtual ** diff --git a/repos/base-hw/src/core/include/util.h b/repos/base-hw/src/core/include/util.h index 3a39eec795..98289deb5d 100644 --- a/repos/base-hw/src/core/include/util.h +++ b/repos/base-hw/src/core/include/util.h @@ -104,41 +104,6 @@ namespace Genode if (size_log2<20) return 12; return 20; } - - /** - * Print debug output on page faults - * - * \param fault_msg introductory message - * \param fault_addr target address of the fault access - * \param fault_ip instruction pointer of the faulter - * \param fault_type access type of fault - * \param faulter_badge user identification of faulter - */ - inline void print_page_fault(char const * const fault_msg, - addr_t const fault_addr, - addr_t const fault_ip, - Region_map::State::Fault_type const fault_type, - unsigned const faulter_badge); -} - - -void Genode::print_page_fault(char const * const fault_msg, - addr_t const fault_addr, - addr_t const fault_ip, - Region_map::State::Fault_type const fault_type, - unsigned const faulter_badge) -{ - const char read[] = "read from"; - const char write[] = "write to"; - printf("\033[31m%s\033[0m (faulter %x", fault_msg, faulter_badge); - printf(" with IP %p attempts to", (void *)fault_ip); - printf(" %s", fault_type == Region_map::State::READ_FAULT ? read : write); - printf(" address %p)\n", (void *)fault_addr); - if (ACTIVITY_TABLE_ON_FAULTS) { - printf("---------- activity table ----------\n"); - Kernel::print_char(0); - printf("\n"); - } } #endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/repos/base-hw/src/core/pager.cc b/repos/base-hw/src/core/pager.cc index 30b9eed703..8bafbde4ee 100644 --- a/repos/base-hw/src/core/pager.cc +++ b/repos/base-hw/src/core/pager.cc @@ -86,15 +86,24 @@ void Pager_object::unresolved_page_fault_occurred() { Platform_thread * const pt = (Platform_thread *)badge(); if (pt && pt->pd()) - error(pt->pd()->label(), " -> ", pt->label(), ": unresolved pagefault at " - "ip=", pt->kernel_object()->ip, " " - "sp=", pt->kernel_object()->sp, " " - "fault address=", pt->kernel_object()->fault_addr()); + warning("page fault, pager_object: pd='", pt->pd()->label(), + "' thread='", pt->label(), + "' ip=", Hex(pt->kernel_object()->ip), + " pf-addr=", Hex(pt->kernel_object()->fault_addr())); +} + +void Pager_object::print(Output &out) const +{ + Platform_thread * const pt = (Platform_thread *)badge(); + if (pt && pt->pd()) + Genode::print(out, "pager_object: pd='", pt->pd()->label(), + "' thread='", pt->label(), "'"); } Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, Thread_capability thread_cap, unsigned const badge, - Affinity::Location) + Affinity::Location, Session_label const &, + Cpu_session::Name const &) : Object_pool::Entry(Kernel_object::_cap), _badge(badge), _cpu_session_cap(cpu_session_cap), _thread_cap(thread_cap) diff --git a/repos/base-linux/src/core/include/region_map_component.h b/repos/base-linux/src/core/include/region_map_component.h index 28f59b46a4..745642c604 100644 --- a/repos/base-linux/src/core/include/region_map_component.h +++ b/repos/base-linux/src/core/include/region_map_component.h @@ -20,6 +20,7 @@ #include #include #include +#include #include /* core includes */ @@ -73,7 +74,8 @@ struct Genode::Rm_client : Pager_object, Rm_member Rm_client(Cpu_session_capability, Thread_capability, Region_map_component *rm, unsigned long badge, Weak_ptr &address_space, - Affinity::Location location) + Affinity::Location location, Cpu_session::Name const&, + Session_label const&) { } }; diff --git a/repos/base-linux/src/lib/base/thread_linux.cc b/repos/base-linux/src/lib/base/thread_linux.cc index 876905005b..70436be7d4 100644 --- a/repos/base-linux/src/lib/base/thread_linux.cc +++ b/repos/base-linux/src/lib/base/thread_linux.cc @@ -58,7 +58,7 @@ void Thread::_thread_start() lx_sigaltstack(stack_base, stack_size); if (stack_size < 0x1000) raw("small stack of ", stack_size, " bytes for \"", thread->name(), - "\" may may break Linux signal handling"); + "\" may break Linux signal handling"); /* * Set signal handler such that canceled system calls get not diff --git a/repos/base-nova/src/core/include/pager.h b/repos/base-nova/src/core/include/pager.h index 9e67e5f84f..708ce8e9d4 100644 --- a/repos/base-nova/src/core/include/pager.h +++ b/repos/base-nova/src/core/include/pager.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -152,7 +153,9 @@ namespace Genode { Pager_object(Cpu_session_capability cpu_session_cap, Thread_capability thread_cap, - unsigned long badge, Affinity::Location location); + unsigned long badge, Affinity::Location location, + Genode::Session_label const &, + Cpu_session::Name const &); virtual ~Pager_object(); @@ -362,6 +365,8 @@ namespace Genode { const char * pd = "core", const char * thread = "unknown", Policy = Policy::UPGRADE_CORE_TO_DST); + + void print(Output &out) const; }; /** diff --git a/repos/base-nova/src/core/include/util.h b/repos/base-nova/src/core/include/util.h index 61a720ea13..f7b903f693 100644 --- a/repos/base-nova/src/core/include/util.h +++ b/repos/base-nova/src/core/include/util.h @@ -41,19 +41,6 @@ namespace Genode { } - inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, - Region_map::State::Fault_type pf_type, - unsigned long faulter_badge) - { - Platform_thread * faulter = reinterpret_cast(faulter_badge); - printf("%s (%s pf_addr=%p pf_ip=%p from %02lx '%s':'%s')\n", msg, - pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", - (void *)pf_addr, (void *)pf_ip, - faulter_badge, faulter ? faulter->pd_name() : "unknown", - faulter ? faulter->name() : "unknown"); - } - - inline void backtrace() { using namespace Genode; diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc index 685fa73086..46a89c1651 100644 --- a/repos/base-nova/src/core/pager.cc +++ b/repos/base-nova/src/core/pager.cc @@ -470,6 +470,15 @@ void Pager_object::cleanup_call() } +void Pager_object::print(Output &out) const +{ + Platform_thread * faulter = reinterpret_cast(_badge); + Genode::print(out, "pager_object: pd='", + faulter ? faulter->pd_name() : "unknown", "' thread='", + faulter ? faulter->name() : "unknown", "'"); +} + + static uint8_t create_portal(addr_t pt, addr_t pd, addr_t ec, Mtd mtd, addr_t eip, Pager_object * oom_handler) { @@ -564,7 +573,8 @@ Exception_handlers::Exception_handlers(Pager_object *obj) Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, Thread_capability thread_cap, unsigned long badge, - Affinity::Location location) + Affinity::Location location, Session_label const &, + Cpu_session::Name const &) : _badge(badge), _selectors(cap_map()->insert(2)), diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc index 287b9d9b09..1060a6d0fb 100644 --- a/repos/base-nova/src/core/platform.cc +++ b/repos/base-nova/src/core/platform.cc @@ -120,9 +120,8 @@ static void page_fault_handler() addr_t pf_sp = utcb->sp; addr_t pf_type = utcb->qual[0]; - print_page_fault("\nPAGE-FAULT IN CORE", pf_addr, pf_ip, - (pf_type & Ipc_pager::ERR_W) ? Region_map::State::WRITE_FAULT - : Region_map::State::READ_FAULT, 0); + error("\nPAGE-FAULT IN CORE addr=", Hex(pf_addr), " ip=", Hex(pf_ip), + " (", (pf_type & Ipc_pager::ERR_W) ? "write" : "read", ")"); log("\nstack pointer ", Hex(pf_sp), ", qualifiers ", Hex(pf_type), " ", pf_type & Ipc_pager::ERR_I ? "I" : "i", diff --git a/repos/base-okl4/src/core/include/util.h b/repos/base-okl4/src/core/include/util.h index be6c30d9ba..9093aba5a4 100644 --- a/repos/base-okl4/src/core/include/util.h +++ b/repos/base-okl4/src/core/include/util.h @@ -113,15 +113,6 @@ namespace Genode { return trunc_page(page + get_page_size() - 1); } - inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, - Region_map::State::Fault_type pf_type, - unsigned long faulter_badge) - { - log(pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", " (", - msg, " pf_addr=", Hex(pf_addr), " pf_ip=", Hex(pf_ip), " " - "from ", Hex(faulter_badge), ")"); - } - inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; } inline size_t constrain_map_size_log2(size_t size_log2) { return size_log2; } diff --git a/repos/base-pistachio/src/core/include/util.h b/repos/base-pistachio/src/core/include/util.h index f8588d24f3..96f259f7bb 100644 --- a/repos/base-pistachio/src/core/include/util.h +++ b/repos/base-pistachio/src/core/include/util.h @@ -107,18 +107,6 @@ namespace Genode { return trunc_page(addr + get_page_size() - 1); } - inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, - Region_map::State::Fault_type pf_type, - unsigned long badge) - { - Pistachio::L4_ThreadId_t tid; - tid.raw = badge; - log(msg, " (", - pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", " " - "pf_addr=", Hex(pf_addr), " pf_ip=", Hex(pf_ip), " " - "from ", Formatted_tid(tid), ")"); - } - inline addr_t map_src_addr(addr_t core_local_addr, addr_t phys_addr) { return core_local_addr; } diff --git a/repos/base-pistachio/src/core/platform.cc b/repos/base-pistachio/src/core/platform.cc index 9e4b258c43..2afd14b0d6 100644 --- a/repos/base-pistachio/src/core/platform.cc +++ b/repos/base-pistachio/src/core/platform.cc @@ -204,7 +204,9 @@ static void _core_pager_loop() Platform::Sigma0::Sigma0() : - Pager_object(Cpu_session_capability(), Thread_capability(), 0, Affinity::Location()) + Pager_object(Cpu_session_capability(), Thread_capability(), + 0, Affinity::Location(), + Session_label(), Cpu_session::Name("sigma0")) { cap(Capability_space::import(Pistachio::get_sigma0(), Rpc_obj_key())); } @@ -220,7 +222,9 @@ Platform::Sigma0 *Platform::sigma0() Platform::Core_pager::Core_pager(Platform_pd *core_pd) : Platform_thread(0, "core.pager"), - Pager_object(Cpu_session_capability(), Thread_capability(), 0, Affinity::Location()) + Pager_object(Cpu_session_capability(), Thread_capability(), + 0, Affinity::Location(), + Session_label(), Cpu_session::Name(name())) { Platform_thread::pager(sigma0()); diff --git a/repos/base-sel4/src/core/include/pager.h b/repos/base-sel4/src/core/include/pager.h index 7c6785de0d..b809607be1 100644 --- a/repos/base-sel4/src/core/include/pager.h +++ b/repos/base-sel4/src/core/include/pager.h @@ -19,6 +19,7 @@ /* Genode includes */ #include #include +#include #include #include #include @@ -66,6 +67,9 @@ class Genode::Pager_object : public Object_pool::Entry */ Signal_context_capability _exception_sigh; + Session_label _pd_label; + Cpu_session::Name _name; + public: /** @@ -78,8 +82,10 @@ class Genode::Pager_object : public Object_pool::Entry * * \param location affinity of paged thread to physical CPU */ - Pager_object(Cpu_session_capability cpu_sesion, Thread_capability thread, - unsigned long badge, Affinity::Location location); + Pager_object(Cpu_session_capability cpu_session, Thread_capability thread, + unsigned long badge, Affinity::Location location, + Session_label const &pd_label, + Cpu_session::Name const &name); ~Pager_object(); @@ -138,6 +144,15 @@ class Genode::Pager_object : public Object_pool::Entry * fault occurred. */ void unresolved_page_fault_occurred(); + + /* + * Print pager object belonging + */ + void print(Output &out) const + { + Genode::print(out, "pager_object: pd='", _pd_label, + "' thread='", _name, "'"); + } }; diff --git a/repos/base-sel4/src/core/include/util.h b/repos/base-sel4/src/core/include/util.h index 53432ad69f..b9259b8849 100644 --- a/repos/base-sel4/src/core/include/util.h +++ b/repos/base-sel4/src/core/include/util.h @@ -33,17 +33,6 @@ namespace Genode { inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; } inline size_t constrain_map_size_log2(size_t size_log2) { return get_page_size_log2(); } - - - inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, - Region_map::State::Fault_type pf_type, - unsigned long faulter_badge) - { - printf("%s (%s pf_addr=%p pf_ip=%p from %02lx)\n", msg, - pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", - (void *)pf_addr, (void *)pf_ip, - faulter_badge); - } } #endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/repos/base-sel4/src/core/pager.cc b/repos/base-sel4/src/core/pager.cc index d9aea8e90b..8bcb35a7b2 100644 --- a/repos/base-sel4/src/core/pager.cc +++ b/repos/base-sel4/src/core/pager.cc @@ -101,12 +101,15 @@ Ipc_pager::Ipc_pager() : _last(0), _reply_sel(0) { } ** Pager object ** ******************/ -Pager_object::Pager_object(Cpu_session_capability cpu_sesion, +Pager_object::Pager_object(Cpu_session_capability cpu_session, Thread_capability thread, - unsigned long badge, Affinity::Location location) + unsigned long badge, Affinity::Location location, + Session_label const &pd_label, + Cpu_session::Name const &name) : - _badge(badge), _cpu_session_cap(cpu_sesion), _thread_cap(thread), - _reply_cap(platform_specific()->core_sel_alloc().alloc()) + _badge(badge), _cpu_session_cap(cpu_session), _thread_cap(thread), + _reply_cap(platform_specific()->core_sel_alloc().alloc()), + _pd_label(pd_label), _name(name) { } @@ -192,8 +195,12 @@ void Pager_entrypoint::entry() /* send reply if page-fault handling succeeded */ reply_pending = !obj->pager(_pager); - if (!reply_pending) + if (!reply_pending) { + warning("page-fault, ", *obj, + " ip=", Hex(_pager.fault_ip()), + " pf-addr=", Hex(_pager.fault_addr())); _pager.reply_save_caller(obj->reply_cap_sel()); + } }); } } diff --git a/repos/base/src/core/include/cpu_session_component.h b/repos/base/src/core/include/cpu_session_component.h index 6e91e60508..2c06225c46 100644 --- a/repos/base/src/core/include/cpu_session_component.h +++ b/repos/base/src/core/include/cpu_session_component.h @@ -18,9 +18,9 @@ #include #include #include +#include #include #include -#include /* core includes */ #include diff --git a/repos/base/src/core/include/cpu_thread_component.h b/repos/base/src/core/include/cpu_thread_component.h index 2b67a57e67..c4e2376019 100644 --- a/repos/base/src/core/include/cpu_thread_component.h +++ b/repos/base/src/core/include/cpu_thread_component.h @@ -149,7 +149,8 @@ class Genode::Cpu_thread_component : public Rpc_object, _rm_client(cpu_session_cap, _ep.manage(this), &_address_space_region_map, _platform_thread.pager_object_badge(), - _address_space, _platform_thread.affinity()) + _address_space, _platform_thread.affinity(), + pd.label(), name) { _address_space_region_map.add_client(_rm_client); diff --git a/repos/base/src/core/include/pager.h b/repos/base/src/core/include/pager.h index 4488036cb6..09b3a5b336 100644 --- a/repos/base/src/core/include/pager.h +++ b/repos/base/src/core/include/pager.h @@ -17,6 +17,7 @@ #define _CORE__INCLUDE__PAGER_H_ /* Genode includes */ +#include #include #include #include @@ -64,6 +65,9 @@ class Genode::Pager_object : public Object_pool::Entry */ Signal_context_capability _exception_sigh; + Session_label _pd_label; + Cpu_session::Name _name; + public: /** @@ -76,10 +80,14 @@ class Genode::Pager_object : public Object_pool::Entry * * \param location affinity of paged thread to physical CPU */ - Pager_object(Cpu_session_capability cpu_sesion, Thread_capability thread, - unsigned long badge, Affinity::Location location) + Pager_object(Cpu_session_capability cpu_sesion, + Thread_capability thread, + unsigned long badge, Affinity::Location location, + Session_label const &pd_label, + Cpu_session::Name const &name) : - _badge(badge), _cpu_session_cap(cpu_sesion), _thread_cap(thread) + _badge(badge), _cpu_session_cap(cpu_sesion), _thread_cap(thread), + _pd_label(pd_label), _name(name) { } virtual ~Pager_object() { } @@ -137,6 +145,15 @@ class Genode::Pager_object : public Object_pool::Entry * fault occurred. */ void unresolved_page_fault_occurred(); + + /* + * Print pager object belonging + */ + void print(Output &out) const + { + Genode::print(out, "pager_object: pd='", _pd_label, + "' thread='", _name, "'"); + } }; diff --git a/repos/base/src/core/include/pd_session_component.h b/repos/base/src/core/include/pd_session_component.h index ba3158dffa..b0fadd887c 100644 --- a/repos/base/src/core/include/pd_session_component.h +++ b/repos/base/src/core/include/pd_session_component.h @@ -18,6 +18,7 @@ /* Genode includes */ #include +#include #include #include #include @@ -134,6 +135,8 @@ class Genode::Pd_session_component : public Rpc_object return _address_space; } + Session_label label() { return Session_label(_label.string); } + /************************** ** PD session interface ** diff --git a/repos/base/src/core/include/region_map_component.h b/repos/base/src/core/include/region_map_component.h index 180aa98d29..f0c7f8f0f5 100644 --- a/repos/base/src/core/include/region_map_component.h +++ b/repos/base/src/core/include/region_map_component.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -190,10 +191,12 @@ class Genode::Rm_client : public Pager_object, public Rm_faulter, Thread_capability thread, Region_map_component *rm, unsigned long badge, Weak_ptr &address_space, - Affinity::Location location) + Affinity::Location location, + Session_label const &pd_label, + Cpu_session::Name const &name) : - Pager_object(cpu_session, thread, badge, location), Rm_faulter(this), - _region_map(rm), _address_space(address_space) + Pager_object(cpu_session, thread, badge, location, pd_label, name), + Rm_faulter(this), _region_map(rm), _address_space(address_space) { } int pager(Ipc_pager &pager); diff --git a/repos/base/src/core/pager_ep.cc b/repos/base/src/core/pager_ep.cc index 3d5ab14bb1..8d93ab392f 100644 --- a/repos/base/src/core/pager_ep.cc +++ b/repos/base/src/core/pager_ep.cc @@ -40,6 +40,10 @@ void Pager_entrypoint::entry() else /* send reply if page-fault handling succeeded */ reply_pending = !obj->pager(_pager); + if (!reply_pending) + warning("page-fault, ", *obj, + " ip=", Hex(_pager.fault_ip()), + " pf-addr=", Hex(_pager.fault_addr())); } else { /* diff --git a/repos/base/src/core/region_map_component.cc b/repos/base/src/core/region_map_component.cc index a0cfc08388..2a8dba824e 100644 --- a/repos/base/src/core/region_map_component.cc +++ b/repos/base/src/core/region_map_component.cc @@ -149,6 +149,17 @@ struct Genode::Region_map_component::Fault_area using namespace Genode; +static void print_page_fault(char const *msg, + addr_t pf_addr, + addr_t pf_ip, + Region_map::State::Fault_type pf_type, + Pager_object const &obj) +{ + log(msg, " (", + pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", + " pf_addr=", Hex(pf_addr), " pf_ip=", Hex(pf_ip), " from ", obj, ")"); +} + /*********************** ** Region-map client ** @@ -168,7 +179,7 @@ int Rm_client::pager(Ipc_pager &pager) addr_t pf_ip = pager.fault_ip(); if (verbose_page_faults) - print_page_fault("page fault", pf_addr, pf_ip, pf_type, badge()); + print_page_fault("page fault", pf_addr, pf_ip, pf_type, *this); auto lambda = [&] (Region_map_component *region_map, Rm_region *region, @@ -187,7 +198,7 @@ int Rm_client::pager(Ipc_pager &pager) /* print a warning if it's no managed-dataspace */ if (region_map == member_rm()) print_page_fault("no RM attachment", pf_addr, pf_ip, - pf_type, badge()); + pf_type, *this); /* register fault at responsible region map */ if (region_map) @@ -223,7 +234,7 @@ int Rm_client::pager(Ipc_pager &pager) /* attempted there is no attachment return an error condition */ print_page_fault("attempted write at read-only memory", - pf_addr, pf_ip, pf_type, badge()); + pf_addr, pf_ip, pf_type, *this); /* register fault at responsible region map */ region_map->fault(this, src_fault_area.fault_addr(), pf_type);