mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
Kernel: Replace inline assembly for turning on IA32_EFER.NXE with MSR
This fixes a triple fault that occurs when compiling serenity with the i686 clang toolchain. (The underlying issue is that the old inline assembly did not specify that it clobbered the eax/ecx/edx registers and as such the compiler assumed they were not changed and used their values across it) Co-authored-by: Brian Gianforcaro <bgianf@serenityos.org>
This commit is contained in:
parent
a9e9bd8d84
commit
bc7b0a8986
2 changed files with 3 additions and 5 deletions
|
@ -32,6 +32,7 @@ enum class ProcessorSpecificDataID {
|
||||||
# define MSR_FS_BASE 0xc0000100
|
# define MSR_FS_BASE 0xc0000100
|
||||||
# define MSR_GS_BASE 0xc0000101
|
# define MSR_GS_BASE 0xc0000101
|
||||||
#endif
|
#endif
|
||||||
|
#define MSR_IA32_EFER 0xc0000080
|
||||||
|
|
||||||
// FIXME: Find a better place for these
|
// FIXME: Find a better place for these
|
||||||
extern "C" void thread_context_first_enter(void);
|
extern "C" void thread_context_first_enter(void);
|
||||||
|
|
|
@ -177,11 +177,8 @@ UNMAP_AFTER_INIT void Processor::cpu_setup()
|
||||||
|
|
||||||
if (has_feature(CPUFeature::NX)) {
|
if (has_feature(CPUFeature::NX)) {
|
||||||
// Turn on IA32_EFER.NXE
|
// Turn on IA32_EFER.NXE
|
||||||
asm volatile(
|
MSR ia32_efer(MSR_IA32_EFER);
|
||||||
"movl $0xc0000080, %ecx\n"
|
ia32_efer.set(ia32_efer.get() | 0x800);
|
||||||
"rdmsr\n"
|
|
||||||
"orl $0x800, %eax\n"
|
|
||||||
"wrmsr\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_feature(CPUFeature::SMEP)) {
|
if (has_feature(CPUFeature::SMEP)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue