1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

Kernel: Detect support for no-execute (NX) CPU features

Previously we assumed all hosts would have support for IA32_EFER.NXE.
This is mostly true for newer hardware, but older hardware will crash
and burn if you try to use this feature.

Now we check for support via CPUID.80000001[20].
This commit is contained in:
Conrad Pankoff 2019-12-26 15:28:30 +11:00 committed by Andreas Kling
parent 5be6a43860
commit 17aef7dc99
3 changed files with 32 additions and 12 deletions

View file

@ -216,7 +216,8 @@ void Region::remap_page(size_t index)
pte.set_writable(false);
else
pte.set_writable(is_writable());
pte.set_execute_disabled(!is_executable());
if (MM.has_nx_support())
pte.set_execute_disabled(!is_executable());
pte.set_user_allowed(is_user_accessible());
m_page_directory->flush(page_vaddr);
#ifdef MM_DEBUG
@ -265,7 +266,8 @@ void Region::map(PageDirectory& page_directory)
pte.set_writable(false);
else
pte.set_writable(is_writable());
pte.set_execute_disabled(!is_executable());
if (MM.has_nx_support())
pte.set_execute_disabled(!is_executable());
} else {
pte.set_physical_page_base(0);
pte.set_present(false);