Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1721082 > unrolled thread

[patch V3 43/44] x86/idt: Simplify alloc_intr_gate

Started byThomas Gleixner <tglx@linutronix.de>
First post2017-08-28 09:00 +0200
Last post2017-08-29 13:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [patch V3 43/44] x86/idt: Simplify alloc_intr_gate Thomas Gleixner <tglx@linutronix.de> - 2017-08-28 09:00 +0200
    RE: [patch V3 43/44] x86/idt: Simplify alloc_intr_gate KY Srinivasan <kys@microsoft.com> - 2017-08-28 16:40 +0200
    [tip:x86/apic] x86/idt: Simplify alloc_intr_gate() tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-08-29 13:30 +0200

#1721082 — [patch V3 43/44] x86/idt: Simplify alloc_intr_gate

FromThomas Gleixner <tglx@linutronix.de>
Date2017-08-28 09:00 +0200
Subject[patch V3 43/44] x86/idt: Simplify alloc_intr_gate
Message-ID<ujmbF-2dY-47@gated-at.bofh.it>
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 <tglx@linutronix.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
---
 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
@@ -354,7 +354,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

[toc] | [next] | [standalone]


#1721683

FromKY Srinivasan <kys@microsoft.com>
Date2017-08-28 16:40 +0200
Message-ID<ujtmO-6J9-23@gated-at.bofh.it>
In reply to#1721082

> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Sunday, August 27, 2017 11:48 PM
> To: LKML <linux-kernel@vger.kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>; Peter Anvin <hpa@zytor.com>; Peter
> Zijlstra <peterz@infradead.org>; Andy Lutomirski <luto@kernel.org>;
> Borislav Petkov <bp@alien8.de>; Steven Rostedt <rostedt@goodmis.org>;
> Juergen Gross <jgross@suse.com>; KY Srinivasan <kys@microsoft.com>;
> Stephen Hemminger <sthemmin@microsoft.com>; Boris Ostrovsky
> <boris.ostrovsky@oracle.com>
> Subject: [patch V3 43/44] 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 <tglx@linutronix.de>
> Reviewed-by: Juergen Gross <jgross@suse.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>

Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>

> Cc: Stephen Hemminger <sthemmin@microsoft.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> ---
>  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
> @@ -354,7 +354,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
> 

[toc] | [prev] | [next] | [standalone]


#1722356 — [tip:x86/apic] x86/idt: Simplify alloc_intr_gate()

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2017-08-29 13:30 +0200
Subject[tip:x86/apic] x86/idt: Simplify alloc_intr_gate()
Message-ID<ujMSt-1Zf-5@gated-at.bofh.it>
In reply to#1721082
Commit-ID:  4447ac1195a845b18f2f427686f116ab77c5b268
Gitweb:     http://git.kernel.org/tip/4447ac1195a845b18f2f427686f116ab77c5b268
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Mon, 28 Aug 2017 08:47:58 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
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 <tglx@linutronix.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20170828064959.580830286@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web