ladybird/Kernel/Arch/x86/SmapDisabler.h
Hendiadyoin1 7ca3d413f7 Kernel: Pull apart CPU.h
This does not add any functional changes
2021-06-24 00:38:23 +02:00

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;
};
}