From: Kevin Pedretti Date: Tue, 21 Oct 2008 22:03:46 +0000 (-0500) Subject: Protect IDT table with a spinlock X-Git-Tag: 1.0^2~30^2~3 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=f96c8f76db88b8a91066736959869cdb7df02253 Protect IDT table with a spinlock --- diff --git a/kitten/arch/x86_64/kernel/interrupts.c b/kitten/arch/x86_64/kernel/interrupts.c index a62c106..7441829 100644 --- a/kitten/arch/x86_64/kernel/interrupts.c +++ b/kitten/arch/x86_64/kernel/interrupts.c @@ -10,9 +10,8 @@ #include #include -typedef void (*idtvec_handler_t)(struct pt_regs *regs, unsigned int vector); - idtvec_handler_t idtvec_table[NUM_IDT_ENTRIES]; +static DEFINE_SPINLOCK(idtvec_table_lock); extern void asm_idtvec_table(void); @@ -220,11 +219,12 @@ do_apic_spurious(struct pt_regs *regs, unsigned int vector) while (1) {} } -void __init +void set_idtvec_handler(unsigned int vector, idtvec_handler_t handler) { char namebuf[KSYM_NAME_LEN+1]; unsigned long symsize, offset; + unsigned long irqstate; ASSERT(vector < NUM_IDT_ENTRIES); @@ -235,7 +235,9 @@ set_idtvec_handler(unsigned int vector, idtvec_handler_t handler) ); } + spin_lock_irqsave(&idtvec_table_lock, irqstate); idtvec_table[vector] = handler; + spin_unlock_irqrestore(&idtvec_table_lock, irqstate); } void diff --git a/kitten/include/arch-x86_64/ptrace.h b/kitten/include/arch-x86_64/ptrace.h index e57c4f4..19f91d9 100644 --- a/kitten/include/arch-x86_64/ptrace.h +++ b/kitten/include/arch-x86_64/ptrace.h @@ -116,6 +116,10 @@ enum { EF_ID = 0x00200000, /* id */ }; +/* TODO: remove this */ +typedef void (*idtvec_handler_t)(struct pt_regs *regs, unsigned int vector); +void set_idtvec_handler(unsigned int vector, idtvec_handler_t handler); + #endif #endif