Always set WP in CR0.
Always set RW+P bit for page table by default. So that we can use write-protection for code later. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com> Reviewed-by: "Kinney, Michael D" <michael.d.kinney@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18960 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -785,7 +785,7 @@ Gen4GPageTable (
|
||||
// Set Page Directory Pointers
|
||||
//
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
Pte[Index] = (UINTN)PageTable + EFI_PAGE_SIZE * (Index + 1) + IA32_PG_P;
|
||||
Pte[Index] = (UINTN)PageTable + EFI_PAGE_SIZE * (Index + 1) + PAGE_ATTRIBUTE_BITS;
|
||||
}
|
||||
Pte += EFI_PAGE_SIZE / sizeof (*Pte);
|
||||
|
||||
@@ -793,7 +793,7 @@ Gen4GPageTable (
|
||||
// Fill in Page Directory Entries
|
||||
//
|
||||
for (Index = 0; Index < EFI_PAGE_SIZE * 4 / sizeof (*Pte); Index++) {
|
||||
Pte[Index] = (Index << 21) + IA32_PG_PS + IA32_PG_RW + IA32_PG_P;
|
||||
Pte[Index] = (Index << 21) | IA32_PG_PS | PAGE_ATTRIBUTE_BITS;
|
||||
}
|
||||
|
||||
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
|
||||
@@ -802,7 +802,7 @@ Gen4GPageTable (
|
||||
Pdpte = (UINT64*)PageTable;
|
||||
for (PageIndex = Low2MBoundary; PageIndex <= High2MBoundary; PageIndex += SIZE_2MB) {
|
||||
Pte = (UINT64*)(UINTN)(Pdpte[BitFieldRead32 ((UINT32)PageIndex, 30, 31)] & ~(EFI_PAGE_SIZE - 1));
|
||||
Pte[BitFieldRead32 ((UINT32)PageIndex, 21, 29)] = (UINT64)Pages + IA32_PG_RW + IA32_PG_P;
|
||||
Pte[BitFieldRead32 ((UINT32)PageIndex, 21, 29)] = (UINT64)Pages | PAGE_ATTRIBUTE_BITS;
|
||||
//
|
||||
// Fill in Page Table Entries
|
||||
//
|
||||
@@ -819,7 +819,7 @@ Gen4GPageTable (
|
||||
GuardPage = 0;
|
||||
}
|
||||
} else {
|
||||
Pte[Index] = PageAddress + IA32_PG_RW + IA32_PG_P;
|
||||
Pte[Index] = PageAddress | PAGE_ATTRIBUTE_BITS;
|
||||
}
|
||||
PageAddress+= EFI_PAGE_SIZE;
|
||||
}
|
||||
@@ -886,7 +886,7 @@ SetCacheability (
|
||||
NewPageTable[Index] |= (UINT64)(Index << EFI_PAGE_SHIFT);
|
||||
}
|
||||
|
||||
PageTable[PTIndex] = ((UINTN)NewPageTableAddress & gPhyMask) | IA32_PG_P;
|
||||
PageTable[PTIndex] = ((UINTN)NewPageTableAddress & gPhyMask) | PAGE_ATTRIBUTE_BITS;
|
||||
}
|
||||
|
||||
ASSERT (PageTable[PTIndex] & IA32_PG_P);
|
||||
|
Reference in New Issue
Block a user