mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 15:44:04 +02:00
SysCall: Split SMEP and SMAP initialization.
This commit is contained in:
parent
213d1fdf18
commit
33b3f9221c
@ -29,10 +29,19 @@ InitializeMsr (
|
|||||||
// Forbid supervisor-mode accesses to any user-mode pages.
|
// Forbid supervisor-mode accesses to any user-mode pages.
|
||||||
//
|
//
|
||||||
AsmCpuidEx (0x07, 0x0, NULL, &Ebx, NULL, NULL);
|
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.UintN = AsmReadCr4 ();
|
||||||
Cr4.Bits.SMAP = 1;
|
Cr4.Bits.SMAP = 1;
|
||||||
Cr4.Bits.SMEP = 1;
|
|
||||||
AsmWriteCr4 (Cr4.UintN);
|
AsmWriteCr4 (Cr4.UintN);
|
||||||
|
|
||||||
Eflags.UintN = AsmReadEflags ();
|
Eflags.UintN = AsmReadEflags ();
|
||||||
|
@ -30,10 +30,19 @@ InitializeMsr (
|
|||||||
// Forbid supervisor-mode accesses to any user-mode pages.
|
// Forbid supervisor-mode accesses to any user-mode pages.
|
||||||
//
|
//
|
||||||
AsmCpuidEx (0x07, 0x0, NULL, &Ebx, NULL, NULL);
|
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.UintN = AsmReadCr4 ();
|
||||||
Cr4.Bits.SMAP = 1;
|
Cr4.Bits.SMAP = 1;
|
||||||
Cr4.Bits.SMEP = 1;
|
|
||||||
AsmWriteCr4 (Cr4.UintN);
|
AsmWriteCr4 (Cr4.UintN);
|
||||||
|
|
||||||
Eflags.UintN = AsmReadEflags ();
|
Eflags.UintN = AsmReadEflags ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user