mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 15:44:04 +02:00
Ring3: Added EFI_MEMORY_USER attribute.
This commit is contained in:
parent
a322c0acac
commit
33f15b44de
@ -94,7 +94,8 @@ SetUefiImageMemoryAttributes (
|
||||
**/
|
||||
VOID
|
||||
SetUefiImageProtectionAttributes (
|
||||
IN UEFI_IMAGE_RECORD *ImageRecord
|
||||
IN UEFI_IMAGE_RECORD *ImageRecord,
|
||||
IN BOOLEAN IsUser
|
||||
)
|
||||
{
|
||||
UEFI_IMAGE_RECORD_SEGMENT *ImageRecordSegment;
|
||||
@ -107,7 +108,7 @@ SetUefiImageProtectionAttributes (
|
||||
SetUefiImageMemoryAttributes (
|
||||
SectionAddress,
|
||||
ImageRecordSegment->Size,
|
||||
ImageRecordSegment->Attributes
|
||||
IsUser ? ImageRecordSegment->Attributes | (UINT32)EFI_MEMORY_USER : ImageRecordSegment->Attributes
|
||||
);
|
||||
|
||||
SectionAddress += ImageRecordSegment->Size;
|
||||
@ -231,7 +232,11 @@ ProtectUefiImage (
|
||||
//
|
||||
// CPU ARCH present. Update memory attribute directly.
|
||||
//
|
||||
SetUefiImageProtectionAttributes (ImageRecord);
|
||||
if (AsciiStrStr (PdbPointer, "Ntfs") != NULL) {
|
||||
SetUefiImageProtectionAttributes (ImageRecord, TRUE);
|
||||
} else {
|
||||
SetUefiImageProtectionAttributes (ImageRecord, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
Finish:
|
||||
@ -663,7 +668,7 @@ MemoryProtectionCpuArchProtocolNotify (
|
||||
//
|
||||
// CPU ARCH present. Update memory attribute directly.
|
||||
//
|
||||
SetUefiImageProtectionAttributes (ImageRecord);
|
||||
SetUefiImageProtectionAttributes (ImageRecord, FALSE);
|
||||
}
|
||||
|
||||
Done:
|
||||
|
@ -114,6 +114,11 @@ typedef enum {
|
||||
// capable of being dynamically removed from the platform at runtime.
|
||||
//
|
||||
#define EFI_MEMORY_HOT_PLUGGABLE 0x0000000000100000
|
||||
//
|
||||
// If this flag is set, the memory region contains user code or data.
|
||||
// If this flag is clear, the memory region contains supervisor code or data.
|
||||
//
|
||||
#define EFI_MEMORY_USER 0x0000000000200000ULL
|
||||
|
||||
//
|
||||
// Runtime memory attribute
|
||||
@ -140,7 +145,7 @@ typedef enum {
|
||||
//
|
||||
#define EFI_CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP)
|
||||
#define EFI_MEMORY_ACCESS_MASK (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEMORY_RO)
|
||||
#define EFI_MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_ACCESS_MASK | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO)
|
||||
#define EFI_MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_ACCESS_MASK | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO | EFI_MEMORY_USER)
|
||||
|
||||
///
|
||||
/// Memory descriptor version number.
|
||||
|
@ -467,6 +467,27 @@ ConvertPageEntryAttribute (
|
||||
}
|
||||
}
|
||||
|
||||
if ((Attributes & EFI_MEMORY_USER) != 0) {
|
||||
switch (PageAction) {
|
||||
case PageActionAssign:
|
||||
case PageActionSet:
|
||||
NewPageEntry |= IA32_PG_U;
|
||||
break;
|
||||
case PageActionClear:
|
||||
NewPageEntry &= ~(UINT64)IA32_PG_U;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (PageAction) {
|
||||
case PageActionAssign:
|
||||
NewPageEntry &= ~(UINT64)IA32_PG_U;
|
||||
break;
|
||||
case PageActionSet:
|
||||
case PageActionClear:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GetPagingDetails (&PagingContext->ContextData, NULL, &PageAttributes);
|
||||
|
||||
if ((*PageAttributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED) != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user