EnableExecuteDisable in MP_CPU_EXCHANGE_INFO is used to tell AP reset vector if
enable execute disable feature on APs. This feature should be enabled before CR3
is written.
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Michael Kinney <michael.d.kinney@intel.com>
NumApsExecutingLocation equ LockLocation + 24h\r
CodeSegmentLocation equ LockLocation + 28h\r
DataSegmentLocation equ LockLocation + 2Ch\r
NumApsExecutingLocation equ LockLocation + 24h\r
CodeSegmentLocation equ LockLocation + 28h\r
DataSegmentLocation equ LockLocation + 2Ch\r
+EnableExecuteDisableLocation equ LockLocation + 30h\r
+Cr3Location equ LockLocation + 3Ch\r
mov ss, dx\r
\r
mov esi, ebx\r
mov ss, dx\r
\r
mov esi, ebx\r
+\r
+ mov edi, esi\r
+ add edi, EnableExecuteDisableLocation\r
+ cmp byte [edi], 0\r
+ jz SkipEnableExecuteDisable\r
+\r
+ ;\r
+ ; Enable IA32 PAE execute disable\r
+ ;\r
+\r
+ mov ecx, 0xc0000080\r
+ rdmsr\r
+ bts eax, 11\r
+ wrmsr\r
+\r
+ mov edi, esi\r
+ add edi, Cr3Location\r
+ mov eax, dword [edi]\r
+ mov cr3, eax\r
+\r
+ mov eax, cr4\r
+ bts eax, 5\r
+ mov cr4, eax\r
+\r
+ mov eax, cr0\r
+ bts eax, 31\r
+ mov cr0, eax\r
+\r
+SkipEnableExecuteDisable:\r
+\r
mov edi, esi\r
add edi, LockLocation\r
mov eax, NotVacantFlag\r
mov edi, esi\r
add edi, LockLocation\r
mov eax, NotVacantFlag\r
UINTN NumApsExecuting;\r
UINTN CodeSegment;\r
UINTN DataSegment;\r
UINTN NumApsExecuting;\r
UINTN CodeSegment;\r
UINTN DataSegment;\r
+ UINTN EnableExecuteDisable;\r
UINTN Cr3;\r
} MP_CPU_EXCHANGE_INFO;\r
\r
UINTN Cr3;\r
} MP_CPU_EXCHANGE_INFO;\r
\r
NumApsExecutingLocation equ LockLocation + 44h\r
CodeSegmentLocation equ LockLocation + 4Ch\r
DataSegmentLocation equ LockLocation + 54h\r
NumApsExecutingLocation equ LockLocation + 44h\r
CodeSegmentLocation equ LockLocation + 4Ch\r
DataSegmentLocation equ LockLocation + 54h\r
-Cr3Location equ LockLocation + 5Ch\r
+EnableExecuteDisableLocation equ LockLocation + 5Ch\r
+Cr3Location equ LockLocation + 64h\r
+\r
\r
;-------------------------------------------------------------------------------\r
\r
;-------------------------------------------------------------------------------\r
mov si, IdtrLocation\r
o32 lidt [cs:si]\r
\r
mov si, IdtrLocation\r
o32 lidt [cs:si]\r
\r
+ mov si, EnableExecuteDisableLocation\r
+ cmp byte [si], 0\r
+ jz SkipEnableExecuteDisableBit\r
+\r
+ ;\r
+ ; Enable execute disable bit\r
+ ;\r
+ mov ecx, 0c0000080h ; EFER MSR number\r
+ rdmsr ; Read EFER\r
+ bts eax, 11 ; Enable Execute Disable Bit\r
+ wrmsr ; Write EFER\r
+\r
+SkipEnableExecuteDisableBit:\r
\r
mov di, DataSegmentLocation\r
mov edi, [di] ; Save long mode DS in edi\r
\r
mov di, DataSegmentLocation\r
mov edi, [di] ; Save long mode DS in edi\r