53 m_pt{std::make_unique<page_table_x64>(&m_cr3)}
63 std::lock_guard<std::mutex> guard(m_mutex);
136 std::lock_guard<std::mutex> guard(m_mutex);
137 return m_pt->virt_to_pte(virt);
143 std::lock_guard<std::mutex> guard(m_mutex);
144 return m_pt->pt_to_mdl();
153 return m_pt->add_page_1g(virt);
156 return m_pt->add_page_2m(virt);
159 return m_pt->add_page_4k(virt);
162 throw std::logic_error(
"invalid pt size");
169 std::lock_guard<std::mutex> guard(m_mutex);
171 auto &&entry = add_page(virt, size);
173 auto ___ = gsl::on_failure([&]
174 { this->unmap_page(virt); });
181 entry.set_present(
true);
189 entry.set_present(
true);
197 entry.set_present(
true);
235 throw std::logic_error(
"unsupported memory permissions");
239 g_mm->add_md(virt, phys, attr);
246 { m_pt->remove_page(virt); });
251 {
g_mm->remove_md(virt); });
258 static std::unique_ptr<root_page_table_x64> rpt;
262 rpt = std::make_unique<root_page_table_x64>(
true);
266 for (
const auto &md :
g_mm->descriptors())
275 rpt->map_4k(md.virt, md.phys, attr);
278 catch (std::exception &e)
282 bferror <<
"failed to construct root page tables: " << e.what() << bfendl;
constexpr const auto pt_wp
virtual void map_2m(integer_pointer virt, integer_pointer phys, attr_type attr)
constexpr const auto re_wc
virtual void map_1g(integer_pointer virt, integer_pointer phys, attr_type attr)
constexpr const auto re_wp
void unmap_identity_map_1g(integer_pointer saddr, integer_pointer eaddr)
constexpr const auto re_uc_m
void root_page_table_terminate()
constexpr const auto rw_uc_m
void setup_identity_map_1g(integer_pointer saddr, integer_pointer eaddr)
root_page_table_x64 * root_pt() noexcept
constexpr const auto invalid
auto mem_attr_to_pat_index(T attr)
constexpr const auto pt_wb
constexpr const auto size_bytes
page_table_x64::memory_descriptor_list memory_descriptor_list
constexpr const auto size
constexpr const auto re_wt
void uint64_t uint64_t uint64_t *rdx noexcept
virtual void map_4k(integer_pointer virt, integer_pointer phys, attr_type attr)
virtual void unmap(integer_pointer virt) noexcept
constexpr const auto rw_wb
memory_descriptor_list pt_to_mdl() const
void unmap_identity_map_2m(integer_pointer saddr, integer_pointer eaddr)
constexpr const auto rw_uc
constexpr const auto pt_wt
constexpr const auto re_uc
constexpr const auto pt_wc
constexpr const auto pt_uc
constexpr page_table_x64::integer_pointer virt
uintptr_t integer_pointer
constexpr const auto rw_wc
void setup_identity_map_4k(integer_pointer saddr, integer_pointer eaddr)
constexpr const auto pt_uc_m
page_table_entry_x64 virt_to_pte(integer_pointer virt) const
uintptr_t integer_pointer
E guard_exceptions(E error_code, T func)
void setup_identity_map_2m(integer_pointer saddr, integer_pointer eaddr)
constexpr const auto rw_wt
constexpr const auto rw_wp
root_page_table_x64(bool is_vmm=false)
constexpr const auto re_wb
void unmap_identity_map_4k(integer_pointer saddr, integer_pointer eaddr)