From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933368AbdHYV6a (ORCPT ); Fri, 25 Aug 2017 17:58:30 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:43056 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935023AbdHYV6Y (ORCPT ); Fri, 25 Aug 2017 17:58:24 -0400 Message-Id: <20170825214943.620086406@linutronix.de> User-Agent: quilt/0.63-1 Date: Fri, 25 Aug 2017 23:47:31 +0200 From: Thomas Gleixner To: LKML Cc: Ingo Molnar , Peter Anvin , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Steven Rostedt , Juergen Gross , "K. Y. Srinivasan" , Stephen Hemminger , Boris Ostrovsky Subject: [patch V2 43/44] x86/idt: Simplify alloc_intr_gate References: <20170825214648.264521964@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=x86-idt--Simplify-alloc_intr_gate.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Juergen Gross Cc: "K. Y. Srinivasan" Cc: Stephen Hemminger Cc: Boris Ostrovsky Cc: Juergen Gross --- arch/x86/kernel/cpu/mshyperv.c | 9 ++------- arch/x86/kernel/idt.c | 6 +++--- drivers/xen/events/events_base.c | 6 ++---- 3 files changed, 7 insertions(+), 14 deletions(-) --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -59,13 +59,8 @@ void hyperv_vector_handler(struct pt_reg void hv_setup_vmbus_irq(void (*handler)(void)) { vmbus_handler = handler; - /* - * Setup the IDT for hypervisor callback. Prevent reallocation - * at module reload. - */ - if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors)) - alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, - hyperv_callback_vector); + /* Setup the IDT for hypervisor callback */ + alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector); } void hv_remove_vmbus_irq(void) --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -352,7 +352,7 @@ void set_intr_gate(unsigned int n, const void alloc_intr_gate(unsigned int n, const void *addr) { - BUG_ON(test_bit(n, used_vectors) || n < FIRST_SYSTEM_VECTOR); - set_bit(n, used_vectors); - set_intr_gate(n, addr); + BUG_ON(n < FIRST_SYSTEM_VECTOR); + if (!test_and_set_bit(n, used_vectors)) + set_intr_gate(n, addr); } --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -1653,10 +1653,8 @@ void xen_callback_vector(void) return; } pr_info("Xen HVM callback vector for event delivery is enabled\n"); - /* in the restore case the vector has already been allocated */ - if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors)) - alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, - xen_hvm_callback_vector); + alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, + xen_hvm_callback_vector); } } #else