From 7727888087461c71e06202ead8ad856ba42ca434 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sun, 4 Feb 2024 23:43:38 +0100 Subject: [PATCH] Implement ArFlushTlb() routine --- xtoskrnl/ar/amd64/cpufunc.c | 15 +++++++++++++++ xtoskrnl/ar/i686/cpufunc.c | 15 +++++++++++++++ xtoskrnl/includes/amd64/ari.h | 4 ++++ xtoskrnl/includes/i686/ari.h | 4 ++++ 4 files changed, 38 insertions(+) diff --git a/xtoskrnl/ar/amd64/cpufunc.c b/xtoskrnl/ar/amd64/cpufunc.c index d1b21d54..874c8530 100644 --- a/xtoskrnl/ar/amd64/cpufunc.c +++ b/xtoskrnl/ar/amd64/cpufunc.c @@ -67,6 +67,21 @@ ArCpuId(IN OUT PCPUID_REGISTERS Registers) return TRUE; } +/** + * Partially flushes the Translation Lookaside Buffer (TLB) + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArFlushTlb() +{ + /* Flush the TLB by resetting the CR3 */ + ArWriteControlRegister(3, ArReadControlRegister(3)); +} + /** * Gets the address of the current stack register. * diff --git a/xtoskrnl/ar/i686/cpufunc.c b/xtoskrnl/ar/i686/cpufunc.c index a3ae24f6..27a828de 100644 --- a/xtoskrnl/ar/i686/cpufunc.c +++ b/xtoskrnl/ar/i686/cpufunc.c @@ -67,6 +67,21 @@ ArCpuId(IN OUT PCPUID_REGISTERS Registers) return TRUE; } +/** + * Partially flushes the Translation Lookaside Buffer (TLB) + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArFlushTlb() +{ + /* Flush the TLB by resetting the CR3 */ + ArWriteControlRegister(3, ArReadControlRegister(3)); +} + /** * Gets the address of the current stack register. * diff --git a/xtoskrnl/includes/amd64/ari.h b/xtoskrnl/includes/amd64/ari.h index 9d1849e7..97dd0455 100644 --- a/xtoskrnl/includes/amd64/ari.h +++ b/xtoskrnl/includes/amd64/ari.h @@ -21,6 +21,10 @@ XTCDECL BOOLEAN ArCpuId(IN OUT PCPUID_REGISTERS Registers); +XTCDECL +VOID +ArFlushTlb(); + XTASSEMBLY XTCDECL ULONG_PTR diff --git a/xtoskrnl/includes/i686/ari.h b/xtoskrnl/includes/i686/ari.h index 69b8a495..6fd3e5b3 100644 --- a/xtoskrnl/includes/i686/ari.h +++ b/xtoskrnl/includes/i686/ari.h @@ -21,6 +21,10 @@ XTCDECL BOOLEAN ArCpuId(IN OUT PCPUID_REGISTERS Registers); +XTCDECL +VOID +ArFlushTlb(); + XTASSEMBLY XTCDECL ULONG_PTR