mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:42:57 +00:00
[NTOSKRNL] Handle some more KeFeatureFlags in amd64/cpu.c and set RtlpUse16ByteSLists
[NTDLL] Set RtlpUse16ByteSLists [RTL] Make use of RtlpUse16ByteSLists in x64 Interlocked SList functions svn path=/trunk/; revision=67523
This commit is contained in:
parent
e31acf630c
commit
0100d8de0c
4 changed files with 51 additions and 24 deletions
|
@ -87,6 +87,7 @@ ULONG RtlpShutdownProcessFlags; // TODO: Use it
|
||||||
|
|
||||||
NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders, PVOID ImageBase);
|
NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders, PVOID ImageBase);
|
||||||
void actctx_init(void);
|
void actctx_init(void);
|
||||||
|
extern BOOLEAN RtlpUse16ByteSLists;
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define DEFAULT_SECURITY_COOKIE 0x00002B992DDFA232ll
|
#define DEFAULT_SECURITY_COOKIE 0x00002B992DDFA232ll
|
||||||
|
@ -2183,6 +2184,11 @@ LdrpInit(PCONTEXT Context,
|
||||||
NtCurrentTeb()->RealClientId.UniqueProcess,
|
NtCurrentTeb()->RealClientId.UniqueProcess,
|
||||||
NtCurrentTeb()->RealClientId.UniqueThread);
|
NtCurrentTeb()->RealClientId.UniqueThread);
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
/* Set the SList header usage */
|
||||||
|
RtlpUse16ByteSLists = SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE128];
|
||||||
|
#endif /* _WIN64 */
|
||||||
|
|
||||||
/* Check if we have a deallocation stack */
|
/* Check if we have a deallocation stack */
|
||||||
if (!Teb->DeallocationStack)
|
if (!Teb->DeallocationStack)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <asm.inc>
|
#include <asm.inc>
|
||||||
#include <ksamd64.inc>
|
#include <ksamd64.inc>
|
||||||
|
|
||||||
|
EXTERN RtlpUse16ByteSLists:BYTE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
|
typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
|
||||||
{
|
{
|
||||||
|
@ -99,11 +101,11 @@ ExpInterlockedPopEntrySList:
|
||||||
/* Load ListHead->Alignment into rax */
|
/* Load ListHead->Alignment into rax */
|
||||||
mov rax, [rcx]
|
mov rax, [rcx]
|
||||||
|
|
||||||
/* Check what kind of header this is */
|
/* Check for 16 byte SList support */
|
||||||
test rdx, SLIST8B_HEADERTYPE_MASK
|
cmp byte ptr [RtlpUse16ByteSLists], 0
|
||||||
jnz RtlInterlockedPopEntrySList16
|
jne RtlInterlockedPopEntrySList16
|
||||||
|
|
||||||
/* We have an 8 byte header */
|
/* Use the 8 byte header */
|
||||||
|
|
||||||
ExpInterlockedPopEntrySListResume:
|
ExpInterlockedPopEntrySListResume:
|
||||||
|
|
||||||
|
@ -229,6 +231,13 @@ ExpInterlockedPushEntrySList:
|
||||||
/* Not aligned, raise an assertion */
|
/* Not aligned, raise an assertion */
|
||||||
int HEX(2C)
|
int HEX(2C)
|
||||||
ExpInterlockedPushEntrySListChecked:
|
ExpInterlockedPushEntrySListChecked:
|
||||||
|
|
||||||
|
/* Make sure RtlpUse16ByteSLists is initialized */
|
||||||
|
cmp byte ptr [RtlpUse16ByteSLists], HEX(FF)
|
||||||
|
jne ExpInterlockedPushEntrySListChecked2
|
||||||
|
/* Not initialized, raise an assertion */
|
||||||
|
int HEX(2C)
|
||||||
|
ExpInterlockedPushEntrySListChecked2:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Load ListHead->Alignment into rax */
|
/* Load ListHead->Alignment into rax */
|
||||||
|
@ -237,11 +246,11 @@ ExpInterlockedPushEntrySListChecked:
|
||||||
/* Load ListHead->Region into r9 */
|
/* Load ListHead->Region into r9 */
|
||||||
mov r9, [rcx + 8]
|
mov r9, [rcx + 8]
|
||||||
|
|
||||||
/* Check what kind of header this is */
|
/* Check for 16 byte SList support */
|
||||||
test r9, SLIST8B_HEADERTYPE_MASK
|
cmp byte ptr [RtlpUse16ByteSLists], 0
|
||||||
jnz RtlInterlockedPushEntrySList16
|
jne RtlInterlockedPushEntrySList16
|
||||||
|
|
||||||
/* We have an 8 byte header */
|
/* Use the 8 byte header */
|
||||||
|
|
||||||
RtlInterlockedPushEntrySListLoop:
|
RtlInterlockedPushEntrySListLoop:
|
||||||
|
|
||||||
|
@ -358,11 +367,11 @@ ExpInterlockedFlushSList:
|
||||||
/* Load ListHead->Alignment into rax */
|
/* Load ListHead->Alignment into rax */
|
||||||
mov rax, [rcx]
|
mov rax, [rcx]
|
||||||
|
|
||||||
/* Check what kind of header this is */
|
/* Check for 16 byte SList support */
|
||||||
test rdx, SLIST8B_HEADERTYPE_MASK
|
cmp byte ptr [RtlpUse16ByteSLists], 0
|
||||||
jnz RtlInterlockedFlushSList16
|
jne RtlInterlockedFlushSList16
|
||||||
|
|
||||||
/* We have an 8 byte header */
|
/* Use the 8 byte header */
|
||||||
|
|
||||||
RtlInterlockedFlushSListLoop:
|
RtlInterlockedFlushSListLoop:
|
||||||
|
|
||||||
|
|
|
@ -203,14 +203,13 @@ KiGetFeatureBits(VOID)
|
||||||
if (CpuFeatures & 0x02000000) FeatureBits |= KF_XMMI;
|
if (CpuFeatures & 0x02000000) FeatureBits |= KF_XMMI;
|
||||||
if (CpuFeatures & 0x04000000) FeatureBits |= KF_XMMI64;
|
if (CpuFeatures & 0x04000000) FeatureBits |= KF_XMMI64;
|
||||||
|
|
||||||
#if 0
|
if (Reg[2] & 0x00000001) FeatureBits |= KF_SSE3;
|
||||||
if (Reg[2] & 0x00000001) FeatureBits |= KF_SSE3NEW;
|
//if (Reg[2] & 0x00000008) FeatureBits |= KF_MONITOR;
|
||||||
if (Reg[2] & 0x00000008) FeatureBits |= KF_MONITOR;
|
//if (Reg[2] & 0x00000200) FeatureBits |= KF_SSE3SUP;
|
||||||
if (Reg[2] & 0x00000200) FeatureBits |= KF_SSE3SUP;
|
|
||||||
if (Reg[2] & 0x00002000) FeatureBits |= KF_CMPXCHG16B;
|
if (Reg[2] & 0x00002000) FeatureBits |= KF_CMPXCHG16B;
|
||||||
if (Reg[2] & 0x00080000) FeatureBits |= KF_SSE41;
|
//if (Reg[2] & 0x00080000) FeatureBits |= KF_SSE41;
|
||||||
if (Reg[2] & 0x00800000) FeatureBits |= KF_POPCNT;
|
//if (Reg[2] & 0x00800000) FeatureBits |= KF_POPCNT;
|
||||||
#endif
|
if (Reg[2] & 0x04000000) FeatureBits |= KF_XSTATE;
|
||||||
|
|
||||||
/* Check if the CPU has hyper-threading */
|
/* Check if the CPU has hyper-threading */
|
||||||
if (CpuFeatures & 0x10000000)
|
if (CpuFeatures & 0x10000000)
|
||||||
|
|
|
@ -15,10 +15,12 @@
|
||||||
|
|
||||||
#define REQUIRED_FEATURE_BITS (KF_RDTSC|KF_CR4|KF_CMPXCHG8B|KF_XMMI|KF_XMMI64| \
|
#define REQUIRED_FEATURE_BITS (KF_RDTSC|KF_CR4|KF_CMPXCHG8B|KF_XMMI|KF_XMMI64| \
|
||||||
KF_LARGE_PAGE|KF_FAST_SYSCALL|KF_GLOBAL_PAGE| \
|
KF_LARGE_PAGE|KF_FAST_SYSCALL|KF_GLOBAL_PAGE| \
|
||||||
KF_CMOV|KF_PAT|KF_MMX|KF_FXSR|KF_NX_BIT)
|
KF_CMOV|KF_PAT|KF_MMX|KF_FXSR|KF_NX_BIT|KF_MTRR)
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
extern BOOLEAN RtlpUse16ByteSLists;
|
||||||
|
|
||||||
/* Function pointer for early debug prints */
|
/* Function pointer for early debug prints */
|
||||||
ULONG (*FrLdrDbgPrint)(const char *Format, ...);
|
ULONG (*FrLdrDbgPrint)(const char *Format, ...);
|
||||||
|
|
||||||
|
@ -82,6 +84,8 @@ KiInitMachineDependent(VOID)
|
||||||
// KeBugCheckEx(NO_PAGES_AVAILABLE, 2, PAGE_SIZE * 2, 0, 0);
|
// KeBugCheckEx(NO_PAGES_AVAILABLE, 2, PAGE_SIZE * 2, 0, 0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/* Initialize 8/16 bit SList support */
|
||||||
|
RtlpUse16ByteSLists = (KeFeatureBits & KF_CMPXCHG16B) ? TRUE: FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -279,19 +283,29 @@ KiInitializeKernelMachineDependent(
|
||||||
KeI386CpuStep = Prcb->CpuStep;
|
KeI386CpuStep = Prcb->CpuStep;
|
||||||
KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
|
KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
|
||||||
KeProcessorLevel = (USHORT)Prcb->CpuType;
|
KeProcessorLevel = (USHORT)Prcb->CpuType;
|
||||||
if (Prcb->CpuID) KeProcessorRevision = Prcb->CpuStep;
|
if (Prcb->CpuID)
|
||||||
|
KeProcessorRevision = Prcb->CpuStep;
|
||||||
|
|
||||||
/* Set basic CPU Features that user mode can read */
|
/* Set basic CPU Features that user mode can read */
|
||||||
|
SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
||||||
|
SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
||||||
|
SharedUserData->ProcessorFeatures[PF_PPC_MOVEMEM_64BIT_OK] = TRUE;
|
||||||
|
SharedUserData->ProcessorFeatures[PF_PAE_ENABLED] = TRUE; // ???
|
||||||
|
SharedUserData->ProcessorFeatures[PF_NX_ENABLED] = TRUE;
|
||||||
|
SharedUserData->ProcessorFeatures[PF_FASTFAIL_AVAILABLE] = TRUE;
|
||||||
|
SharedUserData->ProcessorFeatures[PF_XSAVE_ENABLED] = TRUE;
|
||||||
SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] =
|
SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] =
|
||||||
(Prcb->FeatureBits & KF_MMX) ? TRUE: FALSE;
|
(Prcb->FeatureBits & KF_MMX) ? TRUE: FALSE;
|
||||||
SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
|
|
||||||
SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] =
|
SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] =
|
||||||
((Prcb->FeatureBits & KF_FXSR) && (Prcb->FeatureBits & KF_XMMI)) ? TRUE: FALSE;
|
((Prcb->FeatureBits & KF_FXSR) && (Prcb->FeatureBits & KF_XMMI)) ? TRUE: FALSE;
|
||||||
SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] =
|
SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] =
|
||||||
((Prcb->FeatureBits & KF_FXSR) && (Prcb->FeatureBits & KF_XMMI64)) ? TRUE: FALSE;
|
((Prcb->FeatureBits & KF_FXSR) && (Prcb->FeatureBits & KF_XMMI64)) ? TRUE: FALSE;
|
||||||
SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] =
|
SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] =
|
||||||
(Prcb->FeatureBits & KF_3DNOW) ? TRUE: FALSE;
|
(Prcb->FeatureBits & KF_3DNOW) ? TRUE: FALSE;
|
||||||
SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
|
SharedUserData->ProcessorFeatures[PF_SSE3_INSTRUCTIONS_AVAILABLE] =
|
||||||
|
(Prcb->FeatureBits & KF_SSE3) ? TRUE: FALSE;
|
||||||
|
SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE128] =
|
||||||
|
(Prcb->FeatureBits & KF_CMPXCHG16B) ? TRUE: FALSE;
|
||||||
|
|
||||||
/* Set the default NX policy (opt-in) */
|
/* Set the default NX policy (opt-in) */
|
||||||
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
||||||
|
@ -322,7 +336,6 @@ KiInitializeKernelMachineDependent(
|
||||||
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
|
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
|
||||||
Prcb->FeatureBits |= KF_NX_DISABLED;
|
Prcb->FeatureBits |= KF_NX_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static LDR_DATA_TABLE_ENTRY LdrCoreEntries[3];
|
static LDR_DATA_TABLE_ENTRY LdrCoreEntries[3];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue