summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Mintram <me@jamesrm.com>2021-10-14 22:53:48 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-15 21:48:45 +0100
commit0fbeac6011731d16069aed80fe6602992282cfe6 (patch)
tree6195c803da3af1f1f152ecc12ffff0a740e47a7b
parentf4fb6379145e5dfa6e008e936f7f2763199e6b5a (diff)
downloadserenity-0fbeac6011731d16069aed80fe6602992282cfe6.zip
Kernel: Split SmapDisabler so header is platform independent
A new header file has been created in the Arch/ folder while the implementation has been moved into a CPP living in the X86 folder.
-rw-r--r--Kernel/Arch/SmapDisabler.h22
-rw-r--r--Kernel/Arch/aarch64/SmapDisabler.cpp20
-rw-r--r--Kernel/Arch/x86/SmapDisabler.cpp25
-rw-r--r--Kernel/Arch/x86/SmapDisabler.h31
-rw-r--r--Kernel/CMakeLists.txt3
-rw-r--r--Kernel/KSyms.cpp2
-rw-r--r--Kernel/Memory/AnonymousVMObject.cpp2
-rw-r--r--Kernel/PerformanceEventBuffer.cpp2
-rw-r--r--Kernel/StdLib.cpp2
-rw-r--r--Kernel/Syscalls/mmap.cpp2
-rw-r--r--Kernel/Syscalls/sigaction.cpp2
-rw-r--r--Kernel/Thread.cpp2
12 files changed, 76 insertions, 39 deletions
diff --git a/Kernel/Arch/SmapDisabler.h b/Kernel/Arch/SmapDisabler.h
new file mode 100644
index 0000000000..319f24b7f8
--- /dev/null
+++ b/Kernel/Arch/SmapDisabler.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Types.h>
+
+namespace Kernel {
+
+class SmapDisabler {
+public:
+ SmapDisabler();
+ ~SmapDisabler();
+
+private:
+ const FlatPtr m_flags;
+};
+
+}
diff --git a/Kernel/Arch/aarch64/SmapDisabler.cpp b/Kernel/Arch/aarch64/SmapDisabler.cpp
new file mode 100644
index 0000000000..80c8e93503
--- /dev/null
+++ b/Kernel/Arch/aarch64/SmapDisabler.cpp
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <Kernel/Arch/SmapDisabler.h>
+
+namespace Kernel {
+
+SmapDisabler::SmapDisabler()
+ : m_flags(0)
+{
+}
+
+SmapDisabler::~SmapDisabler()
+{
+}
+
+}
diff --git a/Kernel/Arch/x86/SmapDisabler.cpp b/Kernel/Arch/x86/SmapDisabler.cpp
new file mode 100644
index 0000000000..1adf3154ed
--- /dev/null
+++ b/Kernel/Arch/x86/SmapDisabler.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <Kernel/Arch/SmapDisabler.h>
+
+#include <Kernel/Arch/x86/ASM_wrapper.h>
+
+namespace Kernel {
+
+SmapDisabler::SmapDisabler()
+ : m_flags(cpu_flags())
+{
+ stac();
+}
+
+SmapDisabler::~SmapDisabler()
+{
+ if (!(m_flags & 0x40000))
+ clac();
+}
+
+}
diff --git a/Kernel/Arch/x86/SmapDisabler.h b/Kernel/Arch/x86/SmapDisabler.h
deleted file mode 100644
index 8dcbac6475..0000000000
--- a/Kernel/Arch/x86/SmapDisabler.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <Kernel/Arch/x86/ASM_wrapper.h>
-
-namespace Kernel {
-
-class SmapDisabler {
-public:
- ALWAYS_INLINE SmapDisabler()
- : m_flags(cpu_flags())
- {
- stac();
- }
-
- ALWAYS_INLINE ~SmapDisabler()
- {
- if (!(m_flags & 0x40000))
- clac();
- }
-
-private:
- const FlatPtr m_flags;
-};
-
-}
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt
index fc31dffc6b..26f16c433a 100644
--- a/Kernel/CMakeLists.txt
+++ b/Kernel/CMakeLists.txt
@@ -20,7 +20,6 @@ set(KERNEL_HEAP_SOURCES
set(KERNEL_SOURCES
AddressSanitizer.cpp
- Arch/x86/SmapDisabler.h
Bus/PCI/Access.cpp
Bus/PCI/API.cpp
Bus/PCI/Device.cpp
@@ -291,6 +290,7 @@ if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
set(KERNEL_SOURCES
${KERNEL_SOURCES}
Arch/x86/ScopedCritical.cpp
+ Arch/x86/SmapDisabler.cpp
)
set(KERNEL_SOURCES
@@ -369,6 +369,7 @@ else()
${AK_SOURCES}
Arch/aarch64/dummy.cpp
+ Arch/aarch64/SmapDisabler.cpp
Arch/aarch64/ScopedCritical.cpp
UBSanitizer.cpp
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index cbd098071d..d199e78b03 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -5,7 +5,7 @@
*/
#include <AK/TemporaryChange.h>
-#include <Kernel/Arch/x86/SmapDisabler.h>
+#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/KSyms.h>
#include <Kernel/Process.h>
diff --git a/Kernel/Memory/AnonymousVMObject.cpp b/Kernel/Memory/AnonymousVMObject.cpp
index 1857daeb04..582f3192ee 100644
--- a/Kernel/Memory/AnonymousVMObject.cpp
+++ b/Kernel/Memory/AnonymousVMObject.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <Kernel/Arch/x86/SmapDisabler.h>
+#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Debug.h>
#include <Kernel/Memory/AnonymousVMObject.h>
#include <Kernel/Memory/MemoryManager.h>
diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp
index 89c6fd34b7..576a27b809 100644
--- a/Kernel/PerformanceEventBuffer.cpp
+++ b/Kernel/PerformanceEventBuffer.cpp
@@ -7,8 +7,8 @@
#include <AK/JsonArraySerializer.h>
#include <AK/JsonObjectSerializer.h>
#include <AK/ScopeGuard.h>
+#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Arch/x86/RegisterState.h>
-#include <Kernel/Arch/x86/SmapDisabler.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/KBufferBuilder.h>
#include <Kernel/PerformanceEventBuffer.h>
diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp
index edfe4bfc5a..aebd148070 100644
--- a/Kernel/StdLib.cpp
+++ b/Kernel/StdLib.cpp
@@ -8,7 +8,7 @@
#include <AK/MemMem.h>
#include <AK/String.h>
#include <AK/Types.h>
-#include <Kernel/Arch/x86/SmapDisabler.h>
+#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/StdLib.h>
diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp
index f1699cc2b2..5d6b757699 100644
--- a/Kernel/Syscalls/mmap.cpp
+++ b/Kernel/Syscalls/mmap.cpp
@@ -5,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Arch/x86/MSR.h>
-#include <Kernel/Arch/x86/SmapDisabler.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/Memory/AnonymousVMObject.h>
#include <Kernel/Memory/MemoryManager.h>
diff --git a/Kernel/Syscalls/sigaction.cpp b/Kernel/Syscalls/sigaction.cpp
index 8c0537b592..4a7fe5dbf4 100644
--- a/Kernel/Syscalls/sigaction.cpp
+++ b/Kernel/Syscalls/sigaction.cpp
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
-#include <Kernel/Arch/x86/SmapDisabler.h>
#include <Kernel/Process.h>
namespace Kernel {
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 0a4adbe1b0..059914338a 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -8,8 +8,8 @@
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <AK/Time.h>
+#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
-#include <Kernel/Arch/x86/SmapDisabler.h>
#include <Kernel/Arch/x86/TrapFrame.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/KCOVDevice.h>