]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/ResetVector: Depend on PCD values of the page tables.
authorMarvin Häuser <Marvin.Haeuser@outlook.com>
Fri, 4 Nov 2016 13:32:39 +0000 (13:32 +0000)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 4 Nov 2016 22:47:07 +0000 (23:47 +0100)
Currently, the value of the page tables' address is hard-coded in the
ResetVector. This patch replaces these values with a PCD dependency.

A check for the size has been added to alert the developer to rewrite
the ASM according to the new size, if it has been changed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/ResetVector/Ia32/PageTables64.asm
OvmfPkg/ResetVector/ResetVector.inf
OvmfPkg/ResetVector/ResetVector.nasmb

index b5a4cf8d71871142bfb9e82a2551f25af62de4d0..6201cad1f5dc3f1ea0b888b62e612cedd679b74f 100644 (file)
@@ -44,10 +44,11 @@ BITS    32
 SetCr3ForPageTables64:\r
 \r
     ;\r
-    ; For OVMF, build some initial page tables at 0x800000-0x806000.\r
+    ; For OVMF, build some initial page tables at\r
+    ; PcdOvmfSecPageTablesBase - (PcdOvmfSecPageTablesBase + 0x6000).\r
     ;\r
-    ; This range should match with PcdOvmfSecPageTablesBase and\r
-    ; PcdOvmfSecPageTablesSize which are declared in the FDF files.\r
+    ; This range should match with PcdOvmfSecPageTablesSize which is\r
+    ; declared in the FDF files.\r
     ;\r
     ; At the end of PEI, the pages tables will be rebuilt into a\r
     ; more permanent location by DxeIpl.\r
@@ -56,21 +57,21 @@ SetCr3ForPageTables64:
     mov     ecx, 6 * 0x1000 / 4\r
     xor     eax, eax\r
 clearPageTablesMemoryLoop:\r
-    mov     dword[ecx * 4 + 0x800000 - 4], eax\r
+    mov     dword[ecx * 4 + PT_ADDR (0) - 4], eax\r
     loop    clearPageTablesMemoryLoop\r
 \r
     ;\r
     ; Top level Page Directory Pointers (1 * 512GB entry)\r
     ;\r
-    mov     dword[0x800000], 0x801000 + PAGE_PDP_ATTR\r
+    mov     dword[PT_ADDR (0)], PT_ADDR (0x1000) + PAGE_PDP_ATTR\r
 \r
     ;\r
     ; Next level Page Directory Pointers (4 * 1GB entries => 4GB)\r
     ;\r
-    mov     dword[0x801000], 0x802000 + PAGE_PDP_ATTR\r
-    mov     dword[0x801008], 0x803000 + PAGE_PDP_ATTR\r
-    mov     dword[0x801010], 0x804000 + PAGE_PDP_ATTR\r
-    mov     dword[0x801018], 0x805000 + PAGE_PDP_ATTR\r
+    mov     dword[PT_ADDR (0x1000)], PT_ADDR (0x2000) + PAGE_PDP_ATTR\r
+    mov     dword[PT_ADDR (0x1008)], PT_ADDR (0x3000) + PAGE_PDP_ATTR\r
+    mov     dword[PT_ADDR (0x1010)], PT_ADDR (0x4000) + PAGE_PDP_ATTR\r
+    mov     dword[PT_ADDR (0x1018)], PT_ADDR (0x5000) + PAGE_PDP_ATTR\r
 \r
     ;\r
     ; Page Table Entries (2048 * 2MB entries => 4GB)\r
@@ -81,13 +82,13 @@ pageTableEntriesLoop:
     dec     eax\r
     shl     eax, 21\r
     add     eax, PAGE_2M_PDE_ATTR\r
-    mov     [ecx * 8 + 0x802000 - 8], eax\r
+    mov     [ecx * 8 + PT_ADDR (0x2000 - 8)], eax\r
     loop    pageTableEntriesLoop\r
 \r
     ;\r
     ; Set CR3 now that the paging structures are available\r
     ;\r
-    mov     eax, 0x800000\r
+    mov     eax, PT_ADDR (0)\r
     mov     cr3, eax\r
 \r
     OneTimeCallRet SetCr3ForPageTables64\r
index 46610d243ecf2010293f1408785a21eff8ee660f..d1e5d4d9bdea5d225072cbf287aaed9da9f69884 100644 (file)
   ResetVector.nasmb\r
 \r
 [Packages]\r
+  OvmfPkg/OvmfPkg.dec\r
   MdePkg/MdePkg.dec\r
   UefiCpuPkg/UefiCpuPkg.dec\r
 \r
 [BuildOptions]\r
    *_*_IA32_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/\r
    *_*_X64_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/\r
+\r
+[Pcd]\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize\r
index 31ac06ae4a8c46c370a073af75825c229e7f9161..29cbad36771184c067eda4dff87296b30e79210a 100644 (file)
 %include "Ia32/SearchForSecEntry.asm"\r
 \r
 %ifdef ARCH_X64\r
+  #include <AutoGen.h>\r
+\r
+  %if (FixedPcdGet32 (PcdOvmfSecPageTablesSize) != 0x6000)\r
+    %error "This implementation inherently depends on PcdOvmfSecPageTablesSize"\r
+  %endif\r
+\r
+  %define PT_ADDR(Offset) (FixedPcdGet32 (PcdOvmfSecPageTablesBase) + (Offset))\r
 %include "Ia32/Flat32ToFlat64.asm"\r
 %include "Ia32/PageTables64.asm"\r
 %endif\r