diff --git a/Kernel/Arch/aarch64/Processor.h b/Kernel/Arch/aarch64/Processor.h index 88ba48db944..4ea7d658625 100644 --- a/Kernel/Arch/aarch64/Processor.h +++ b/Kernel/Arch/aarch64/Processor.h @@ -48,6 +48,16 @@ public: return 0; } + ALWAYS_INLINE bool has_nx() const + { + return true; + } + + ALWAYS_INLINE bool has_pat() const + { + return false; + } + ALWAYS_INLINE static FlatPtr current_in_irq() { return 0; diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h index 60740dc9dd2..d7df2b257bd 100644 --- a/Kernel/Arch/x86/Processor.h +++ b/Kernel/Arch/x86/Processor.h @@ -397,6 +397,16 @@ public: static void deferred_call_queue(Function callback); + ALWAYS_INLINE bool has_nx() const + { + return has_feature(CPUFeature::NX); + } + + ALWAYS_INLINE bool has_pat() const + { + return has_feature(CPUFeature::PAT); + } + ALWAYS_INLINE bool has_feature(CPUFeature::Type const& feature) const { return m_features.has_flag(feature); diff --git a/Kernel/Memory/Region.cpp b/Kernel/Memory/Region.cpp index 84790f3e313..3fe340d8627 100644 --- a/Kernel/Memory/Region.cpp +++ b/Kernel/Memory/Region.cpp @@ -6,7 +6,8 @@ #include #include -#include +#include +#include #include #include #include @@ -212,9 +213,9 @@ bool Region::map_individual_page_impl(size_t page_index) pte->set_writable(false); else pte->set_writable(is_writable()); - if (Processor::current().has_feature(CPUFeature::NX)) + if (Processor::current().has_nx()) pte->set_execute_disabled(!is_executable()); - if (Processor::current().has_feature(CPUFeature::PAT)) + if (Processor::current().has_pat()) pte->set_pat(is_write_combine()); pte->set_user_allowed(user_allowed); } @@ -317,7 +318,7 @@ void Region::remap() ErrorOr Region::set_write_combine(bool enable) { - if (enable && !Processor::current().has_feature(CPUFeature::PAT)) { + if (enable && !Processor::current().has_pat()) { dbgln("PAT is not supported, implement MTRR fallback if available"); return Error::from_errno(ENOTSUP); }