mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
SysCall: Split SMEP and SMAP initialization.
This commit is contained in:
parent
94be39d0c5
commit
5515e17ae8
MdeModulePkg/Core/Dxe/SysCall
@ -29,10 +29,19 @@ InitializeMsr (
|
||||
// Forbid supervisor-mode accesses to any user-mode pages.
|
||||
//
|
||||
AsmCpuidEx (0x07, 0x0, NULL, &Ebx, NULL, NULL);
|
||||
if (((Ebx & BIT20) != 0) && ((Ebx & BIT7) != 0)) {
|
||||
if ((Ebx & BIT7) != 0) {
|
||||
Cr4.UintN = AsmReadCr4 ();
|
||||
Cr4.Bits.SMEP = 1;
|
||||
AsmWriteCr4 (Cr4.UintN);
|
||||
|
||||
Eflags.UintN = AsmReadEflags ();
|
||||
Eflags.Bits.AC = 0;
|
||||
AsmWriteEflags (Eflags.UintN);
|
||||
}
|
||||
|
||||
if ((Ebx & BIT20) != 0) {
|
||||
Cr4.UintN = AsmReadCr4 ();
|
||||
Cr4.Bits.SMAP = 1;
|
||||
Cr4.Bits.SMEP = 1;
|
||||
AsmWriteCr4 (Cr4.UintN);
|
||||
|
||||
Eflags.UintN = AsmReadEflags ();
|
||||
|
@ -30,10 +30,19 @@ InitializeMsr (
|
||||
// Forbid supervisor-mode accesses to any user-mode pages.
|
||||
//
|
||||
AsmCpuidEx (0x07, 0x0, NULL, &Ebx, NULL, NULL);
|
||||
if (((Ebx & BIT20) != 0) && ((Ebx & BIT7) != 0)) {
|
||||
if ((Ebx & BIT7) != 0) {
|
||||
Cr4.UintN = AsmReadCr4 ();
|
||||
Cr4.Bits.SMEP = 1;
|
||||
AsmWriteCr4 (Cr4.UintN);
|
||||
|
||||
Eflags.UintN = AsmReadEflags ();
|
||||
Eflags.Bits.AC = 0;
|
||||
AsmWriteEflags (Eflags.UintN);
|
||||
}
|
||||
|
||||
if ((Ebx & BIT20) != 0) {
|
||||
Cr4.UintN = AsmReadCr4 ();
|
||||
Cr4.Bits.SMAP = 1;
|
||||
Cr4.Bits.SMEP = 1;
|
||||
AsmWriteCr4 (Cr4.UintN);
|
||||
|
||||
Eflags.UintN = AsmReadEflags ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user