summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/amd64/machdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64/amd64/machdep.c')
-rw-r--r--sys/arch/amd64/amd64/machdep.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 8258f8e..408ac95 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -178,6 +178,19 @@ enable_simd(void)
}
}
+static void
+cpu_check_feat(struct cpu_info *ci)
+{
+ uint32_t unused, ebx;
+
+ /* Extended features */
+ CPUID(0x07, unused, ebx, unused, unused);
+ if (ISSET(ebx, BIT(7)))
+ ci->feat |= CPU_FEAT_SMEP;
+ if (ISSET(ebx, BIT(20)))
+ ci->feat |= CPU_FEAT_SMAP;
+}
+
void
cpu_shootdown_tlb(vaddr_t va)
{
@@ -304,6 +317,7 @@ void
cpu_startup(struct cpu_info *ci)
{
ci->self = ci;
+ ci->feat = 0;
gdt_load();
idt_load();
@@ -313,6 +327,8 @@ cpu_startup(struct cpu_info *ci)
init_tss(ci);
try_mitigate_spectre();
+ cpu_check_feat(ci);
+
enable_simd();
lapic_init();