diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-05 01:09:24 +0000 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-05 01:09:24 +0000 |
commit | ddc58847e2bcff65a7950f0a866da041e73d3e76 (patch) | |
tree | eee0abdaec7dad39032b07e22702cd46ce28cdd6 /sys/arch/amd64/amd64 | |
parent | 755615ef0b094ca644ada0f677c49e665120ff37 (diff) |
kernel/amd64: conf: Add CPU_SMEP option
Allow the user to configure if SMEP would be enabled for their build of
the Hyra AMD64 port
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 5acacb4..9b65d6e 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -61,6 +61,12 @@ #define SPECTRE_IBRS 0 #endif +#if defined(__CPU_SMEP) +#define CPU_SMEP __CPU_SMEP +#else +#define CPU_SMEP 0 +#endif + int ibrs_enable(void); int simd_init(void); void syscall_isr(void); @@ -319,6 +325,11 @@ cpu_enable_smep(void) struct cpu_info *ci; uint64_t cr4; + /* Don't bother if not enabled */ + if (!CPU_SMEP) { + return; + } + ci = this_cpu(); if (!ISSET(ci->feat, CPU_FEAT_SMEP)) { pr_trace_bsp("SMEP not supported\n"); @@ -336,6 +347,10 @@ cpu_disable_smep(void) struct cpu_info *ci; uint64_t cr4; + if (!CPU_SMEP) { + return; + } + ci = this_cpu(); if (!ISSET(ci->feat, CPU_FEAT_SMEP)) { return; |