Changeset 108794 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/Ia32/Stack.nasm
- Timestamp:
- Mar 31, 2025 11:31:09 AM (2 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168237
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-164365 /vendor/edk2/current 103735-103757,103769-103776,129194-168232
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFsp2Pkg/Library/BaseFspSwitchStackLib/Ia32/Stack.nasm
r99404 r108794 13 13 14 14 extern ASM_PFX(SwapStack) 15 extern ASM_PFX(FeaturePcdGet (PcdFspSaveRestorePageTableEnable)) 16 17 ; Page table related bits in CR0/CR4/EFER 18 %define CR0_PG_MASK 0x80010000 ; CR0.PG and CR0.WP 19 %define CR4_PG_MASK 0x10B0 ; CR4.PSE, CR4.PAE, CR4.PGE and CR4.LA57 20 %define EFER_PG_MASK 0x800 ; EFER.NXE 15 21 16 22 ;------------------------------------------------------------------------------ … … 51 57 cli 52 58 pushad 59 60 ; 61 ; Allocate 4x4 bytes on the stack. 62 ; 63 sub esp, 16 64 cmp byte [dword ASM_PFX(FeaturePcdGet (PcdFspSaveRestorePageTableEnable))], 0 65 jz SkipPagetableSave 66 67 add esp, 16 68 ; Save EFER MSR lower 32 bits 69 push ecx 70 push eax 71 mov ecx, 0xC0000080 72 rdmsr 73 mov edx, eax 74 pop eax 75 pop ecx 76 push edx 77 78 ; Save CR registers 79 mov eax, cr4 80 push eax 81 mov eax, cr3 82 push eax 83 mov eax, cr0 84 push eax 85 SkipPagetableSave: 86 53 87 sub esp, 8 54 88 sidt [esp] … … 62 96 lidt [esp] 63 97 add esp, 8 98 99 cmp byte [dword ASM_PFX(FeaturePcdGet (PcdFspSaveRestorePageTableEnable))], 0 100 jz SkipPagetableRestore 101 ; [esp] stores new cr0 102 ; [esp+4] stores new cr3 103 ; [esp+8] stores new cr4 104 ; [esp+12] stores new Efer 105 ; 106 ; When new EFER.NXE == 1, the restore flow is: EFER --> CRx 107 ; Otherwise: CRx --> EFER 108 ; When new CR0.PG == 1, the restore flow for CRx is: CR3 --> CR4 --> CR0 109 ; Otherwise, the restore flow is: CR0 --> CR3 --> CR4 110 ; 111 ; If NXE bit is changed to 1, change NXE before CR register 112 ; This is because Nx bit in page table entry in new CR3 will be invalid 113 ; if updating CR3 before EFER MSR. 114 ; 115 mov eax, [esp+12] 116 bt eax, 11 117 jnc SkipEferLabel1 118 119 ; Restore EFER MSR 120 mov ecx, 0xC0000080 121 rdmsr 122 and eax, ~EFER_PG_MASK 123 mov ebx, [esp+12] 124 and ebx, EFER_PG_MASK 125 or eax, ebx 126 wrmsr 127 128 SkipEferLabel1: 129 130 ; 131 ; if new cr0 is to disable page table, change CR0 before CR3/CR4 132 ; 133 mov eax, [esp] 134 bt eax, 31 135 jc SkipCr0Label1 136 137 ; Restore CR0 138 mov edx, cr0 139 and edx, ~CR0_PG_MASK 140 mov eax, [esp] 141 and eax, CR0_PG_MASK 142 or edx, eax 143 mov cr0, edx 144 145 SkipCr0Label1: 146 147 ; Restore CR3/CR4 148 mov eax, [esp+4] 149 mov cr3, eax 150 151 mov edx, cr4 152 and edx, ~CR4_PG_MASK 153 mov eax, [esp+8] 154 and eax, CR4_PG_MASK 155 or edx, eax 156 mov cr4, edx 157 158 ; 159 ; if new cr0 is to enable page table, change CR0 after CR3/CR4 160 ; 161 mov eax, [esp] 162 bt eax, 31 163 jnc SkipCr0Label2 164 165 ; Restore CR0 166 mov edx, cr0 167 and edx, ~CR0_PG_MASK 168 mov eax, [esp] 169 and eax, CR0_PG_MASK 170 or edx, eax 171 mov cr0, edx 172 173 SkipCr0Label2: 174 ; 175 ; If NXE bit is changed to 0, change NXE after than CR regiser 176 ; 177 mov eax, [esp+12] 178 bt eax, 11 179 jc SkipEferLabel2 180 181 ; Restore EFER MSR 182 mov ecx, 0xC0000080 183 rdmsr 184 and eax, ~EFER_PG_MASK 185 mov ebx, [esp+12] 186 and ebx, EFER_PG_MASK 187 or eax, ebx 188 wrmsr 189 190 SkipEferLabel2: 191 SkipPagetableRestore: 192 193 ; pop page table related registers. 194 add esp, 16 195 64 196 popad 65 197 popfd
Note:
See TracChangeset
for help on using the changeset viewer.