@RtlPrefetchMemoryNonTemporal@8:\r
ret /* Overwritten by ntoskrnl/ke/i386/kernel.c if SSE is supported (see Ki386SetProcessorFeatures() ) */\r
\r
- mov eax, [_Ke386CacheGranularity] // Get cache line size\r
+ mov eax, [_Ke386CacheAlignment] // Get cache line size\r
\r
// This is fastcall, so ecx = address, edx = size\r
- fetch_next_line:\r
+fetch_next_line:\r
prefetchnta byte ptr [ecx] // prefechnta(address)\r
- sub edx, eax // count = count - cache_line_size\r
add ecx, eax // address = address + cache_line_size\r
- cmp edx, 0 // if(count) > 0\r
+ sub edx, eax // count = count - cache_line_size\r
ja fetch_next_line // goto fetch_next_line\r
ret\r
ULONG Ke386CacheAlignment;
CHAR Ke386CpuidModel[49] = {0,};
ULONG Ke386L1CacheSize;
-ULONG Ke386CacheGranularity = 0x40; /* FIXME: Default to 64 bytes for RtlPrefetchMemoryNonTemporal(), need real size */
BOOLEAN Ke386NoExecute = FALSE;
BOOLEAN Ke386Pae = FALSE;
BOOLEAN Ke386GlobalPagesEnabled = FALSE;
/* Target EIP. */
Ke386Wrmsr(0x176, (ULONG_PTR)KiFastCallEntry, 0);
}
+
+ /* Does the CPU Support 'prefetchnta' (SSE) */
+ if(KPCR->PrcbData.FeatureBits & X86_FEATURE_SSE)
+ {
+ ULONG Protect;
+
+ Protect = MmGetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal);
+ MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect | PAGE_IS_WRITABLE);
+ /* Replace the ret by a nop */
+ *(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90;
+ MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect);
+ }
}
VOID
SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] =
(Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE2);
- /* Does the CPU Support 'prefetchnta' (SSE) */
- if(Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE)
- {
- /* Replace the ret by a nop */
- /* FIXME - *(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90; */
- }
-
/* Does the CPU Support Fast System Call? */
if (Pcr->PrcbData.FeatureBits & X86_FEATURE_SYSCALL) {