From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753393AbdH2L1Q (ORCPT ); Tue, 29 Aug 2017 07:27:16 -0400 Received: from terminus.zytor.com ([65.50.211.136]:46141 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752924AbdH2L1O (ORCPT ); Tue, 29 Aug 2017 07:27:14 -0400 Date: Tue, 29 Aug 2017 04:21:15 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: jgross@suse.com, sthemmin@microsoft.com, luto@kernel.org, rostedt@goodmis.org, boris.ostrovsky@oracle.com, jpoimboe@redhat.com, peterz@infradead.org, torvalds@linux-foundation.org, kys@microsoft.com, brgerst@gmail.com, bp@alien8.de, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, dvlasenk@redhat.com, mingo@kernel.org Reply-To: tglx@linutronix.de, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com, brgerst@gmail.com, bp@alien8.de, peterz@infradead.org, torvalds@linux-foundation.org, kys@microsoft.com, rostedt@goodmis.org, sthemmin@microsoft.com, jgross@suse.com, luto@kernel.org, boris.ostrovsky@oracle.com, jpoimboe@redhat.com In-Reply-To: <20170828064959.580830286@linutronix.de> References: <20170828064959.580830286@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/apic] x86/idt: Simplify alloc_intr_gate() Git-Commit-ID: 4447ac1195a845b18f2f427686f116ab77c5b268 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4447ac1195a845b18f2f427686f116ab77c5b268 Gitweb: http://git.kernel.org/tip/4447ac1195a845b18f2f427686f116ab77c5b268 Author: Thomas Gleixner AuthorDate: Mon, 28 Aug 2017 08:47:58 +0200 Committer: Ingo Molnar CommitDate: Tue, 29 Aug 2017 12:07:28 +0200 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 Reviewed-by: Juergen Gross Reviewed-by: K. Y. Srinivasan Cc: Andy Lutomirski Cc: Boris Ostrovsky Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephen Hemminger Cc: Steven Rostedt Link: http://lkml.kernel.org/r/20170828064959.580830286@linutronix.de Signed-off-by: Ingo Molnar --- 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(-) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 70e717f..9fc3265 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -59,13 +59,8 @@ void hyperv_vector_handler(struct pt_regs *regs) 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) diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index 8e9318d..b609eac 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -354,7 +354,7 @@ void set_intr_gate(unsigned int n, const void *addr) 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); } diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 2d43118..1ab4bd1 100644 --- 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