mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
Ring3: Added support for User page table to AllocatePages(), FreePages().
This commit is contained in:
parent
1bde91a85d
commit
fcd47185eb
@ -245,7 +245,8 @@ DxeMain (
|
|||||||
EFI_VECTOR_HANDOFF_INFO *VectorInfoList;
|
EFI_VECTOR_HANDOFF_INFO *VectorInfoList;
|
||||||
EFI_VECTOR_HANDOFF_INFO *VectorInfo;
|
EFI_VECTOR_HANDOFF_INFO *VectorInfo;
|
||||||
|
|
||||||
gRing3Data = NULL;
|
gRing3Data = NULL;
|
||||||
|
gUserPageTable = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setup Stack Guard
|
// Setup Stack Guard
|
||||||
|
@ -909,6 +909,7 @@ ApplyMemoryProtectionPolicy (
|
|||||||
{
|
{
|
||||||
UINT64 OldAttributes;
|
UINT64 OldAttributes;
|
||||||
UINT64 NewAttributes;
|
UINT64 NewAttributes;
|
||||||
|
UINT64 CurrentAttributes;
|
||||||
|
|
||||||
//
|
//
|
||||||
// The policy configured in PcdDxeNxMemoryProtectionPolicy
|
// The policy configured in PcdDxeNxMemoryProtectionPolicy
|
||||||
@ -964,11 +965,27 @@ ApplyMemoryProtectionPolicy (
|
|||||||
NewAttributes = GetPermissionAttributeForMemoryType (NewType);
|
NewAttributes = GetPermissionAttributeForMemoryType (NewType);
|
||||||
|
|
||||||
if (OldType != EfiMaxMemoryType) {
|
if (OldType != EfiMaxMemoryType) {
|
||||||
|
//
|
||||||
|
// AllocatePages
|
||||||
|
//
|
||||||
OldAttributes = GetPermissionAttributeForMemoryType (OldType);
|
OldAttributes = GetPermissionAttributeForMemoryType (OldType);
|
||||||
if (OldAttributes == NewAttributes) {
|
if (OldAttributes == NewAttributes) {
|
||||||
// policy is the same between OldType and NewType
|
// policy is the same between OldType and NewType
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((gUserPageTable != 0) && (NewType == EfiRing3MemoryType)) {
|
||||||
|
gCpu->SetUserMemoryAttributes (gCpu, gUserPageTable, Memory, Length, NewAttributes);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// FreePages
|
||||||
|
//
|
||||||
|
gCpu->GetMemoryAttributes (gCpu, Memory, &CurrentAttributes);
|
||||||
|
|
||||||
|
if ((gUserPageTable != 0) && ((CurrentAttributes & EFI_MEMORY_USER) != 0)) {
|
||||||
|
gCpu->SetUserMemoryAttributes (gCpu, gUserPageTable, Memory, Length, EFI_MEMORY_RP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return gCpu->SetMemoryAttributes (gCpu, Memory, Length, NewAttributes);
|
return gCpu->SetMemoryAttributes (gCpu, Memory, Length, NewAttributes);
|
||||||
|
@ -421,6 +421,7 @@ CpuGetMemoryAttributes (
|
|||||||
|
|
||||||
PageEntry = GetPageTableEntry (&PagingContext, Address, &PageAttribute);
|
PageEntry = GetPageTableEntry (&PagingContext, Address, &PageAttribute);
|
||||||
if (PageEntry == NULL) {
|
if (PageEntry == NULL) {
|
||||||
|
*Attributes = 0;
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user