Author: tkreuzer
Date: Sat May 2 22:20:59 2015
New Revision: 67523
URL:
http://svn.reactos.org/svn/reactos?rev=67523&view=rev
Log:
[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
Modified:
trunk/reactos/dll/ntdll/ldr/ldrinit.c
trunk/reactos/lib/rtl/amd64/slist.S
trunk/reactos/ntoskrnl/ke/amd64/cpu.c
trunk/reactos/ntoskrnl/ke/amd64/kiinit.c
Modified: trunk/reactos/dll/ntdll/ldr/ldrinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrinit.c?re…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/ldrinit.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/ldrinit.c [iso-8859-1] Sat May 2 22:20:59 2015
@@ -87,6 +87,7 @@
NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders, PVOID ImageBase);
void actctx_init(void);
+extern BOOLEAN RtlpUse16ByteSLists;
#ifdef _WIN64
#define DEFAULT_SECURITY_COOKIE 0x00002B992DDFA232ll
@@ -2183,6 +2184,11 @@
NtCurrentTeb()->RealClientId.UniqueProcess,
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 */
if (!Teb->DeallocationStack)
{
Modified: trunk/reactos/lib/rtl/amd64/slist.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/amd64/slist.S?rev=…
==============================================================================
--- trunk/reactos/lib/rtl/amd64/slist.S [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/amd64/slist.S [iso-8859-1] Sat May 2 22:20:59 2015
@@ -8,6 +8,8 @@
#include <asm.inc>
#include <ksamd64.inc>
+
+EXTERN RtlpUse16ByteSLists:BYTE
/*
typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
@@ -99,11 +101,11 @@
/* Load ListHead->Alignment into rax */
mov rax, [rcx]
- /* Check what kind of header this is */
- test rdx, SLIST8B_HEADERTYPE_MASK
- jnz RtlInterlockedPopEntrySList16
-
- /* We have an 8 byte header */
+ /* Check for 16 byte SList support */
+ cmp byte ptr [RtlpUse16ByteSLists], 0
+ jne RtlInterlockedPopEntrySList16
+
+ /* Use the 8 byte header */
ExpInterlockedPopEntrySListResume:
@@ -229,6 +231,13 @@
/* Not aligned, raise an assertion */
int HEX(2C)
ExpInterlockedPushEntrySListChecked:
+
+ /* Make sure RtlpUse16ByteSLists is initialized */
+ cmp byte ptr [RtlpUse16ByteSLists], HEX(FF)
+ jne ExpInterlockedPushEntrySListChecked2
+ /* Not initialized, raise an assertion */
+ int HEX(2C)
+ExpInterlockedPushEntrySListChecked2:
#endif
/* Load ListHead->Alignment into rax */
@@ -237,11 +246,11 @@
/* Load ListHead->Region into r9 */
mov r9, [rcx + 8]
- /* Check what kind of header this is */
- test r9, SLIST8B_HEADERTYPE_MASK
- jnz RtlInterlockedPushEntrySList16
-
- /* We have an 8 byte header */
+ /* Check for 16 byte SList support */
+ cmp byte ptr [RtlpUse16ByteSLists], 0
+ jne RtlInterlockedPushEntrySList16
+
+ /* Use the 8 byte header */
RtlInterlockedPushEntrySListLoop:
@@ -358,11 +367,11 @@
/* Load ListHead->Alignment into rax */
mov rax, [rcx]
- /* Check what kind of header this is */
- test rdx, SLIST8B_HEADERTYPE_MASK
- jnz RtlInterlockedFlushSList16
-
- /* We have an 8 byte header */
+ /* Check for 16 byte SList support */
+ cmp byte ptr [RtlpUse16ByteSLists], 0
+ jne RtlInterlockedFlushSList16
+
+ /* Use the 8 byte header */
RtlInterlockedFlushSListLoop:
Modified: trunk/reactos/ntoskrnl/ke/amd64/cpu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/amd64/cpu.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] Sat May 2 22:20:59 2015
@@ -203,14 +203,13 @@
if (CpuFeatures & 0x02000000) FeatureBits |= KF_XMMI;
if (CpuFeatures & 0x04000000) FeatureBits |= KF_XMMI64;
-#if 0
- if (Reg[2] & 0x00000001) FeatureBits |= KF_SSE3NEW;
- if (Reg[2] & 0x00000008) FeatureBits |= KF_MONITOR;
- if (Reg[2] & 0x00000200) FeatureBits |= KF_SSE3SUP;
+ if (Reg[2] & 0x00000001) FeatureBits |= KF_SSE3;
+ //if (Reg[2] & 0x00000008) FeatureBits |= KF_MONITOR;
+ //if (Reg[2] & 0x00000200) FeatureBits |= KF_SSE3SUP;
if (Reg[2] & 0x00002000) FeatureBits |= KF_CMPXCHG16B;
- if (Reg[2] & 0x00080000) FeatureBits |= KF_SSE41;
- if (Reg[2] & 0x00800000) FeatureBits |= KF_POPCNT;
-#endif
+ //if (Reg[2] & 0x00080000) FeatureBits |= KF_SSE41;
+ //if (Reg[2] & 0x00800000) FeatureBits |= KF_POPCNT;
+ if (Reg[2] & 0x04000000) FeatureBits |= KF_XSTATE;
/* Check if the CPU has hyper-threading */
if (CpuFeatures & 0x10000000)
Modified: trunk/reactos/ntoskrnl/ke/amd64/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/amd64/kiinit.c…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] Sat May 2 22:20:59 2015
@@ -15,9 +15,11 @@
#define REQUIRED_FEATURE_BITS (KF_RDTSC|KF_CR4|KF_CMPXCHG8B|KF_XMMI|KF_XMMI64| \
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 *******************************************************************/
+
+extern BOOLEAN RtlpUse16ByteSLists;
/* Function pointer for early debug prints */
ULONG (*FrLdrDbgPrint)(const char *Format, ...);
@@ -82,6 +84,8 @@
// KeBugCheckEx(NO_PAGES_AVAILABLE, 2, PAGE_SIZE * 2, 0, 0);
// }
+ /* Initialize 8/16 bit SList support */
+ RtlpUse16ByteSLists = (KeFeatureBits & KF_CMPXCHG16B) ? TRUE: FALSE;
}
VOID
@@ -279,19 +283,29 @@
KeI386CpuStep = Prcb->CpuStep;
KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
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 */
+ 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] =
(Prcb->FeatureBits & KF_MMX) ? TRUE: FALSE;
- SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] =
((Prcb->FeatureBits & KF_FXSR) && (Prcb->FeatureBits &
KF_XMMI)) ? TRUE: FALSE;
SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] =
((Prcb->FeatureBits & KF_FXSR) && (Prcb->FeatureBits &
KF_XMMI64)) ? TRUE: FALSE;
SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] =
(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) */
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
@@ -322,7 +336,6 @@
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
Prcb->FeatureBits |= KF_NX_DISABLED;
}
-
}
static LDR_DATA_TABLE_ENTRY LdrCoreEntries[3];