mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
Kernel: Detect syscall/sysenter support
This commit is contained in:
parent
5b6920a18a
commit
ce5ae83963
2 changed files with 25 additions and 2 deletions
|
@ -788,10 +788,20 @@ void Processor::cpu_detect()
|
|||
set_feature(CPUFeature::TSC);
|
||||
if (processor_info.ecx() & (1 << 30))
|
||||
set_feature(CPUFeature::RDRAND);
|
||||
|
||||
if (processor_info.edx() & (1 << 11)) {
|
||||
u32 stepping = processor_info.eax() & 0xf;
|
||||
u32 model = (processor_info.eax() >> 4) & 0xf;
|
||||
u32 family = (processor_info.eax() >> 8) & 0xf;
|
||||
if (!(family == 6 && model < 3 && stepping < 3))
|
||||
set_feature(CPUFeature::SEP);
|
||||
}
|
||||
CPUID extended_processor_info(0x80000001);
|
||||
if (extended_processor_info.edx() & (1 << 20))
|
||||
set_feature(CPUFeature::NX);
|
||||
if (extended_processor_info.edx() & (1 << 11)) {
|
||||
// Only available in 64 bit mode
|
||||
set_feature(CPUFeature::SYSCALL);
|
||||
}
|
||||
|
||||
CPUID extended_features(0x7);
|
||||
if (extended_features.ebx() & (1 << 20))
|
||||
|
@ -895,6 +905,10 @@ String Processor::features_string() const
|
|||
return "tsc";
|
||||
case CPUFeature::UMIP:
|
||||
return "umip";
|
||||
case CPUFeature::SEP:
|
||||
return "sep";
|
||||
case CPUFeature::SYSCALL:
|
||||
return "syscall";
|
||||
// no default statement here intentionally so that we get
|
||||
// a warning if a new feature is forgotten to be added here
|
||||
}
|
||||
|
|
|
@ -599,7 +599,9 @@ enum class CPUFeature : u32 {
|
|||
SMEP = (1 << 6),
|
||||
SSE = (1 << 7),
|
||||
TSC = (1 << 8),
|
||||
UMIP = (1 << 9)
|
||||
UMIP = (1 << 9),
|
||||
SEP = (1 << 10),
|
||||
SYSCALL = (1 << 11)
|
||||
};
|
||||
|
||||
class Thread;
|
||||
|
@ -613,6 +615,13 @@ struct TrapFrame;
|
|||
#define GDT_SELECTOR_PROC 0x30
|
||||
#define GDT_SELECTOR_TSS 0x38
|
||||
|
||||
// SYSENTER makes certain assumptions on how the GDT is structured:
|
||||
static_assert(GDT_SELECTOR_CODE0 + 8 == GDT_SELECTOR_DATA0); // SS0 = CS0 + 8
|
||||
|
||||
// SYSEXIT makes certain assumptions on how the GDT is structured:
|
||||
static_assert(GDT_SELECTOR_CODE0 + 16 == GDT_SELECTOR_CODE3); // CS3 = CS0 + 16
|
||||
static_assert(GDT_SELECTOR_CODE0 + 24 == GDT_SELECTOR_DATA3); // SS3 = CS0 + 32
|
||||
|
||||
class ProcessorInfo;
|
||||
struct MemoryManagerData;
|
||||
struct ProcessorMessageEntry;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue