From dc51de546ba9d81b1423f1130e1cf3955a2a30e3 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 5 May 2025 18:12:20 +0200 Subject: [PATCH] tukija: Fixed mapping of TIP and added some more querying functions. --- .../include/tukija/syscall-generic.h | 44 +++++++++++++++++-- repos/base-tukija/src/core/platform.cc | 2 +- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/repos/base-tukija/include/tukija/syscall-generic.h b/repos/base-tukija/include/tukija/syscall-generic.h index 0b2aead28e..9c99b931a0 100644 --- a/repos/base-tukija/include/tukija/syscall-generic.h +++ b/repos/base-tukija/include/tukija/syscall-generic.h @@ -43,6 +43,7 @@ #include #include +#include namespace Tukija { @@ -283,8 +284,23 @@ namespace Tukija { Genode::Affinity::Location loc_in_habitat = loc.transpose(location.xpos(), location.ypos()); unsigned idx = (loc_in_habitat.xpos() * habitat_affinity.height() + loc_in_habitat.ypos()) % habitat_affinity.total(); return idx_to_phys_cpu_id[idx]; - } + } + unsigned location_to_index(Genode::Affinity::Location const &loc) + { + Genode::Affinity::Location loc_in_habitat = + loc.transpose(location.xpos(), location.ypos()); + return (loc_in_habitat.xpos() * habitat_affinity.height() + + loc_in_habitat.ypos()) % + habitat_affinity.total(); + } + + unsigned get_cpu_index() + { + Genode::Affinity::Location loc = Genode::Thread::myself()->affinity(); + return location_to_index(loc); + } + /** * @brief Return the worker information structure for the workers at the given location * @@ -313,7 +329,7 @@ namespace Tukija { static Cip * cip() { - return reinterpret_cast(0x7FFFBFFDC000); + return reinterpret_cast(0x7fffbffd7000); } }; @@ -406,6 +422,12 @@ namespace Tukija { Domain nodes[]; /* Set of detected NUMA domains */ /* Parsing functions */ + + uint8_t num_domains() const + { + return (reinterpret_cast(&nodes) + length - reinterpret_cast(nodes)) / sizeof(Domain); + } + /** * @brief Applies the function fn to all detected NUMA domain structures * @@ -470,8 +492,10 @@ namespace Tukija { break; } - if (dom->id != id) - return; + if (dom->id != id) { + Genode::error("Domain ", id, " does not exist."); + throw Domain_not_found(); + } fn(*dom); } @@ -498,6 +522,18 @@ namespace Tukija { return *mem; } + uint8_t domain_of_loc(Genode::Affinity::Location const &loc) const + { + unsigned cpu = Cip::cip()->location_to_kernel_cpu(loc); + return static_cast(cpu_to_domain[cpu]); + } + + uint8_t domain_of_idx(unsigned idx) const + { + unsigned cpu = Cip::cip()->idx_to_phys_cpu_id[idx]; + return static_cast(cpu_to_domain[cpu]); + } + inline static Tip const *tip() { return reinterpret_cast(0x7fffbffdb000); } diff --git a/repos/base-tukija/src/core/platform.cc b/repos/base-tukija/src/core/platform.cc index 9cbf682a72..b9c868af81 100644 --- a/repos/base-tukija/src/core/platform.cc +++ b/repos/base-tukija/src/core/platform.cc @@ -429,7 +429,7 @@ Core::Platform::Platform() get_page_size() * 4); /* exclude TIP */ - region_alloc().remove_range((addr_t)_tip, get_page_size() * 32); + region_alloc().remove_range((addr_t)_tip, get_page_size() * 128); /* exclude CIP */ region_alloc().remove_range((addr_t)Tukija::Cip::cip(), get_page_size() * 4);