mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-09 04:32:51 +00:00
31 lines
458 B
C++
31 lines
458 B
C++
/*
|
|
* 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;
|
|
};
|
|
|
|
}
|