summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-05 01:03:23 +0000
committerIan Moffett <ian@osmora.org>2025-07-05 01:03:23 +0000
commit627c047d1ce71c9882cefac41a0d0b3c9d379c5b (patch)
tree951a98b4421e943e5d2c7f34131cab1796650254 /sys/arch
parent6856d7533b4cec8d35639578b02578f28f3699bc (diff)
kernel/amd64: Add 'feat' field in cpu_info
Keep track of per-cpu features by using a 'feat' field which contains the results of various CPUIDs. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch')
-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();