summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2022-02-02 10:51:18 +0000
committerAda Christine <adachristine18@gmail.com>2022-02-02 10:51:18 +0000
commit65430cd09f3b6162187d66d66f860e8883f8ff9b (patch)
tree37e6df044dca7a77a13db722a2c0cce93c5bc67e
parent4130fbcdcfd2baa6d1f9b065ce34afa2a339f670 (diff)
cast with uintptr_t, ist index should be checked
-rw-r--r--kc/core/cpu/cpu.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/kc/core/cpu/cpu.c b/kc/core/cpu/cpu.c
index 49a88be..27ee827 100644
--- a/kc/core/cpu/cpu.c
+++ b/kc/core/cpu/cpu.c
@@ -270,16 +270,21 @@ void isr_install(int vec, void (*isr)(void), int trap, int ist)
type = TRAP64_GATE;
}
- set_idt(vec, CODE_SUPER_SEG_INDEX << 3, (uint64_t)isr, type);
- if (ist)
+ set_idt(vec, CODE_SUPER_SEG_INDEX << 3, (uintptr_t)isr, type);
+ // an IST greater than 7 is invalid
+ if (ist && ist < 7)
{
set_ist(vec, ist);
}
+ else
+ {
+ panic(GENERAL_PANIC);
+ }
}
void ist_install(int ist, void *stack)
{
- tss.ist[ist] = (uint64_t)stack;
+ tss.ist[ist] = (uintptr_t)stack;
}
void int_enable(void)