kernel: fix taking smep/smap path on unsupported systems

This commit is contained in:
Matheus
2026-05-14 12:03:11 -03:00
parent 85d588da08
commit f9912b8970
4 changed files with 21 additions and 3 deletions
+8 -2
View File
@@ -324,8 +324,14 @@ static volatile struct limine_executable_address_request kaddrreq = {
#define ERROR_FETCH 16
static void pfisr(isr_t *self, context_t *ctx) {
if ((ctx->rflags & ARCH_CONTEXT_RFLAGS_AC) == 0 && IS_USER_ADDRESS((void *)ctx->cr2) && !IS_USER_ADDRESS((void *)ctx->rip)) {
_panic("SMAP/SMEP violation", ctx);
if (!ARCH_CONTEXT_ISUSER(ctx) && IS_USER_ADDRESS((void *)ctx->cr2)) {
if ((ctx->error & ERROR_FETCH) && arch_cpu_smep_enabled()) {
_panic("SMEP violation", ctx);
}
if ((ctx->error & ERROR_FETCH) == 0 && (ctx->rflags & ARCH_CONTEXT_RFLAGS_AC) == 0 && arch_cpu_smap_enabled()) {
_panic("SMAP violation", ctx);
}
}
thread_t *thread = current_thread();