mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
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.
This commit is contained in:
parent
f4fb637914
commit
0fbeac6011
Notes:
sideshowbarker
2024-07-18 02:20:01 +09:00
Author: https://github.com/jamesmintram Commit: https://github.com/SerenityOS/serenity/commit/0fbeac60117 Pull-request: https://github.com/SerenityOS/serenity/pull/10475 Reviewed-by: https://github.com/linusg ✅
22
Kernel/Arch/SmapDisabler.h
Normal file
22
Kernel/Arch/SmapDisabler.h
Normal file
@ -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;
|
||||
};
|
||||
|
||||
}
|
20
Kernel/Arch/aarch64/SmapDisabler.cpp
Normal file
20
Kernel/Arch/aarch64/SmapDisabler.cpp
Normal file
@ -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()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
25
Kernel/Arch/x86/SmapDisabler.cpp
Normal file
25
Kernel/Arch/x86/SmapDisabler.cpp
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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 {
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user