public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] The NX bit in page table is not expected for new allocated EfiBootServicesCode
@ 2024-07-04  9:26 David Hsieh via groups.io
  0 siblings, 0 replies; only message in thread
From: David Hsieh via groups.io @ 2024-07-04  9:26 UTC (permalink / raw)
  To: devel@edk2.groups.io

[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]

Problem:
The NX bit in page table is not expected for new allocated EfiBootServicesCode
if bit7(EfiConventionalMemory) is zero and bit0(EfiReservedMemoryType) is one of PcdDxeNxMemoryProtectionPolicy.

Flow:
When bit0 of PcdDxeNxMemoryProtectionPolicy is set to 1, the EfiReservedMemoryType attribute is EFI_MEMORY_XP,
the NX bit is set for EfiReservedMemoryType memory in InitializeDxeNxMemoryProtectionPolicy().


In CoreInternalAllocatePages, if request a specific address but can't be found in current memory map,
it does a special “memory promotion”.
PromoteMemoryResource() is called to find memory resource and add UNTESTED memory region to be system memory.
The type of UNTESTED memory is EfiGcdMemoryTypeReserved.

In CoreAddRange(), the new memory resource is added to allocable system memory resource,
the new type is EfiConventionalMemory but the memory attribute is not really changed, NX bit is still set.

Before return to caller, ApplyMemoryProtectionPolicy() is used to convert memory attribute,
however, both bit7(EfiConventionalMemory) and bit3(EfiBootServicesCode) are zero, memory attribute is not changed.
NX bit is still set.

AllocatePages returns a EfiBootServicesCode memory but its NX bit is set.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119807): https://edk2.groups.io/g/devel/message/119807
Mute This Topic: https://groups.io/mt/107058325/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 5314 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-07-05 18:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04  9:26 [edk2-devel] The NX bit in page table is not expected for new allocated EfiBootServicesCode David Hsieh via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox