public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "David Hsieh via groups.io" <davidhsieh=ami.com@groups.io>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: [edk2-devel] The NX bit in page table is not expected for new allocated EfiBootServicesCode
Date: Thu, 4 Jul 2024 09:26:48 +0000	[thread overview]
Message-ID: <PH7PR10MB660380A3E441E0E9376897D3D1DE2@PH7PR10MB6603.namprd10.prod.outlook.com> (raw)

[-- 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 --]

                 reply	other threads:[~2024-07-05 18:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH7PR10MB660380A3E441E0E9376897D3D1DE2@PH7PR10MB6603.namprd10.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox