https://git.reactos.org/?p=reactos.git;a=commitdiff;h=51258295bd41ab76de7a4…
commit 51258295bd41ab76de7a422f53ae81556dc1009f
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Thu Jun 24 11:41:24 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Aug 4 17:48:39 2021 +0200
[NTOS:KE] Rewrite KeZeroPages in assembly
We spend a lot of time in this function, let's optimize it.
---
ntoskrnl/ke/i386/cpu.c | 9 ---------
ntoskrnl/ke/i386/zeropage.S | 32 ++++++++++++++++++++++++++++++++
ntoskrnl/ntos.cmake | 1 +
3 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/ntoskrnl/ke/i386/cpu.c b/ntoskrnl/ke/i386/cpu.c
index bdc92f908fd..ac1d9ee4dfd 100644
--- a/ntoskrnl/ke/i386/cpu.c
+++ b/ntoskrnl/ke/i386/cpu.c
@@ -1133,15 +1133,6 @@ KeInvalidateAllCaches(VOID)
return TRUE;
}
-VOID
-FASTCALL
-KeZeroPages(IN PVOID Address,
- IN ULONG Size)
-{
- /* Not using XMMI in this routine */
- RtlZeroMemory(Address, Size);
-}
-
VOID
NTAPI
KiSaveProcessorState(IN PKTRAP_FRAME TrapFrame,
diff --git a/ntoskrnl/ke/i386/zeropage.S b/ntoskrnl/ke/i386/zeropage.S
new file mode 100644
index 00000000000..c999b22eec1
--- /dev/null
+++ b/ntoskrnl/ke/i386/zeropage.S
@@ -0,0 +1,32 @@
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE: Fast zeroing of pages
+ * COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou(a)reactos.org>
+ */
+
+#include <asm.inc>
+
+/* FUNCTIONS ****************************************************************/
+.code
+
+/*
+ * VOID
+ * FASTCALL
+ * KeZeroPages(void* ptr, ULONG Size)
+ */
+PUBLIC @KeZeroPages@8
+FUNC @KeZeroPages@8
+ FPO 0, 0, 0, 0, 0, FRAME_FPO
+
+ push edi
+ mov edi, ecx
+ mov ecx, edx
+ shr ecx, 2
+ xor eax, eax
+ rep stosd
+ pop edi
+ ret
+ENDFUNC
+
+END
diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake
index 4b56e74896e..7803e4c812e 100644
--- a/ntoskrnl/ntos.cmake
+++ b/ntoskrnl/ntos.cmake
@@ -298,6 +298,7 @@ if(ARCH STREQUAL "i386")
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/i386/ctxswitch.S
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/i386/trap.s
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/i386/usercall_asm.S
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/i386/zeropage.S
${REACTOS_SOURCE_DIR}/ntoskrnl/rtl/i386/stack.S)
list(APPEND SOURCE
${REACTOS_SOURCE_DIR}/ntoskrnl/config/i386/cmhardwr.c