Skip to content

Commit 4447ac1

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/idt: Simplify alloc_intr_gate()
The only users of alloc_intr_gate() are hypervisors, which both check the used_vectors bitmap whether they have allocated the gate already. Move that check into alloc_intr_gate() and simplify the users. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Reviewed-by: K. Y. Srinivasan <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephen Hemminger <[email protected]> Cc: Steven Rostedt <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent db18da7 commit 4447ac1

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ void hyperv_vector_handler(struct pt_regs *regs)
5959
void hv_setup_vmbus_irq(void (*handler)(void))
6060
{
6161
vmbus_handler = handler;
62-
/*
63-
* Setup the IDT for hypervisor callback. Prevent reallocation
64-
* at module reload.
65-
*/
66-
if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
67-
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
68-
hyperv_callback_vector);
62+
/* Setup the IDT for hypervisor callback */
63+
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector);
6964
}
7065

7166
void hv_remove_vmbus_irq(void)

arch/x86/kernel/idt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void set_intr_gate(unsigned int n, const void *addr)
354354

355355
void alloc_intr_gate(unsigned int n, const void *addr)
356356
{
357-
BUG_ON(test_bit(n, used_vectors) || n < FIRST_SYSTEM_VECTOR);
358-
set_bit(n, used_vectors);
359-
set_intr_gate(n, addr);
357+
BUG_ON(n < FIRST_SYSTEM_VECTOR);
358+
if (!test_and_set_bit(n, used_vectors))
359+
set_intr_gate(n, addr);
360360
}

drivers/xen/events/events_base.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,10 +1653,8 @@ void xen_callback_vector(void)
16531653
return;
16541654
}
16551655
pr_info("Xen HVM callback vector for event delivery is enabled\n");
1656-
/* in the restore case the vector has already been allocated */
1657-
if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
1658-
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
1659-
xen_hvm_callback_vector);
1656+
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
1657+
xen_hvm_callback_vector);
16601658
}
16611659
}
16621660
#else

0 commit comments

Comments
 (0)