arch: make sure not to set NX-bit when it is reserved

This commit is contained in:
Pawel Dziepak
2013-04-22 17:36:36 +02:00
parent 3f0a22c88b
commit be573dcd88
4 changed files with 12 additions and 4 deletions
@@ -373,8 +373,10 @@ X86PagingMethod64Bit::PutPageTableEntryInTable(uint64* entry,
page |= X86_64_PTE_USER;
if ((attributes & B_WRITE_AREA) != 0)
page |= X86_64_PTE_WRITABLE;
if ((attributes & B_EXECUTE_AREA) == 0)
if ((attributes & B_EXECUTE_AREA) == 0
&& x86_check_feature(IA32_FEATURE_AMD_EXT_NX, FEATURE_EXT_AMD)) {
page |= X86_64_PTE_NOT_EXECUTABLE;
}
} else if ((attributes & B_KERNEL_WRITE_AREA) != 0)
page |= X86_64_PTE_WRITABLE;
@@ -673,8 +673,10 @@ X86VMTranslationMap64Bit::Protect(addr_t start, addr_t end, uint32 attributes,
newProtectionFlags = X86_64_PTE_USER;
if ((attributes & B_WRITE_AREA) != 0)
newProtectionFlags |= X86_64_PTE_WRITABLE;
if ((attributes & B_EXECUTE_AREA) == 0)
if ((attributes & B_EXECUTE_AREA) == 0
&& x86_check_feature(IA32_FEATURE_AMD_EXT_NX, FEATURE_EXT_AMD)) {
newProtectionFlags |= X86_64_PTE_NOT_EXECUTABLE;
}
} else if ((attributes & B_KERNEL_WRITE_AREA) != 0)
newProtectionFlags = X86_64_PTE_WRITABLE;
@@ -784,8 +784,10 @@ X86PagingMethodPAE::PutPageTableEntryInTable(pae_page_table_entry* entry,
page |= X86_PAE_PTE_USER;
if ((attributes & B_WRITE_AREA) != 0)
page |= X86_PAE_PTE_WRITABLE;
if ((attributes & B_EXECUTE_AREA) == 0)
if ((attributes & B_EXECUTE_AREA) == 0
&& x86_check_feature(IA32_FEATURE_AMD_EXT_NX, FEATURE_EXT_AMD)) {
page |= X86_PAE_PTE_NOT_EXECUTABLE;
}
} else if ((attributes & B_KERNEL_WRITE_AREA) != 0)
page |= X86_PAE_PTE_WRITABLE;
@@ -772,8 +772,10 @@ X86VMTranslationMapPAE::Protect(addr_t start, addr_t end, uint32 attributes,
newProtectionFlags = X86_PAE_PTE_USER;
if ((attributes & B_WRITE_AREA) != 0)
newProtectionFlags |= X86_PAE_PTE_WRITABLE;
if ((attributes & B_EXECUTE_AREA) == 0)
if ((attributes & B_EXECUTE_AREA) == 0
&& x86_check_feature(IA32_FEATURE_AMD_EXT_NX, FEATURE_EXT_AMD)) {
newProtectionFlags |= X86_PAE_PTE_NOT_EXECUTABLE;
}
} else if ((attributes & B_KERNEL_WRITE_AREA) != 0)
newProtectionFlags = X86_PAE_PTE_WRITABLE;