Skip to contentSkip to conversation

x86: dovetail: Harden __send_ipi_mask for KVM guests

PATCH Superseded Jan Kiszka 3 participants 3 messages Feb 24, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 x86: dovetail: Harden __send_ipi_mask for KVM guests

From: Jan Kiszka <[email protected]>

This function is called in case paravirtual IPIs of a KVM host are used. Just like for hard submission handlers, we need to harden the path to avoid splashes like these:

IRQ pipeline: some code running in oob context 'Xenomai'
called an in-band only routine

 CPU: 0 PID: 410 Comm: (udev-worker) Not tainted 5.10.229-cip54+ #265
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
 IRQ stage: Xenomai
 Call Trace:
  dump_stack+0x84/0x9c
  inband_irq_save+0xa/0x30
  __send_ipi_mask+0x81/0x260
  ? preempt_count_sub+0x96/0xe0
  ? _raw_spin_unlock_irq+0x33/0x50
  ? xnsched_pick_next+0xe0/0xe0
  ? ___xnsched_run+0x491/0x5b0
  ? ktime_get_mono_fast_ns+0x50/0xb0
  ___xnsched_run+0x491/0x5b0
  run_oob_call+0x97/0x170
  xnthread_start+0x23f/0x330
  ? rt_stack_deliver+0x340/0x340 [rtnet]
  rtdm_task_init.part.14+0x7e/0xc0
---
 arch/x86/kernel/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/kvm.c +2 -2
index 5df1061fc6ee1..b183caf41aa44 100644
@@ -525,7 +525,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
 	if (cpumask_empty(mask))
 		return;
 
-	local_irq_save(flags);
+	flags = hard_local_irq_save();
 
 	switch (vector) {
 	default:
@@ -563,7 +563,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
 			  ret);
 	}
 
-	local_irq_restore(flags);
+	hard_local_irq_restore(flags);
 }
 
 static void kvm_send_ipi_mask(const struct cpumask *mask, int vector)
Signature · 1 line
2.43.0
#1 lore raw
Quoted 45 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This function is called in case paravirtual IPIs of a KVM host are used. Just like for hard submission handlers, we need to harden the path to avoid splashes like these:

IRQ pipeline: some code running in oob context 'Xenomai'
called an in-band only routine

 CPU: 0 PID: 410 Comm: (udev-worker) Not tainted 5.10.229-cip54+ #265
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
 IRQ stage: Xenomai
 Call Trace:
  dump_stack+0x84/0x9c
  inband_irq_save+0xa/0x30
  __send_ipi_mask+0x81/0x260
  ? preempt_count_sub+0x96/0xe0
  ? _raw_spin_unlock_irq+0x33/0x50
  ? xnsched_pick_next+0xe0/0xe0
  ? ___xnsched_run+0x491/0x5b0
  ? ktime_get_mono_fast_ns+0x50/0xb0
  ___xnsched_run+0x491/0x5b0
  run_oob_call+0x97/0x170
  xnthread_start+0x23f/0x330
  ? rt_stack_deliver+0x340/0x340 [rtnet]
  rtdm_task_init.part.14+0x7e/0xc0
---
 arch/x86/kernel/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/kvm.c +1 -1
index 5df1061fc6ee1..b183caf41aa44 100644
@@ -525,7 +525,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
 	if (cpumask_empty(mask))
 		return;
 
-	local_irq_save(flags);
+	flags = hard_local_irq_save();
 
 	switch (vector) {
 	default:

arch/x86/kernel/kvm.c static void __send_ipi_mask(const struct cpumask *mask, int vector) · line 569

Quoted 8 lines
arch/x86/kernel/kvm.c +1 -1
@@ -563,7 +563,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
 			  ret);
 	}
 
-	local_irq_restore(flags);
+	hard_local_irq_restore(flags);
 }
 
 static void kvm_send_ipi_mask(const struct cpumask *mask, int vector)

Ack.

Signature · 1 line
Philippe.
#2 lore raw
Quoted 50 lines · Philippe Gerum
Quoted 48 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This function is called in case paravirtual IPIs of a KVM host are used. Just like for hard submission handlers, we need to harden the path to avoid splashes like these:

IRQ pipeline: some code running in oob context 'Xenomai'
called an in-band only routine

 CPU: 0 PID: 410 Comm: (udev-worker) Not tainted 5.10.229-cip54+ #265
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
 IRQ stage: Xenomai
 Call Trace:
  dump_stack+0x84/0x9c
  inband_irq_save+0xa/0x30
  __send_ipi_mask+0x81/0x260
  ? preempt_count_sub+0x96/0xe0
  ? _raw_spin_unlock_irq+0x33/0x50
  ? xnsched_pick_next+0xe0/0xe0
  ? ___xnsched_run+0x491/0x5b0
  ? ktime_get_mono_fast_ns+0x50/0xb0
  ___xnsched_run+0x491/0x5b0
  run_oob_call+0x97/0x170
  xnthread_start+0x23f/0x330
  ? rt_stack_deliver+0x340/0x340 [rtnet]
  rtdm_task_init.part.14+0x7e/0xc0
---
 arch/x86/kernel/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/kvm.c +1 -1
index 5df1061fc6ee1..b183caf41aa44 100644
@@ -525,7 +525,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
 	if (cpumask_empty(mask))
 		return;
 
-	local_irq_save(flags);
+	flags = hard_local_irq_save();
 
 	switch (vector) {
 	default:
@@ -563,7 +563,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
 			  ret);
 	}
 
Quoted 7 lines

arch/x86/kernel/kvm.c static void __send_ipi_mask(const struct cpumask *mask, int vector) · line 569

Quoted 5 lines
arch/x86/kernel/kvm.c +1 -1
-	local_irq_restore(flags);
+	hard_local_irq_restore(flags);
 }
 
 static void kvm_send_ipi_mask(const struct cpumask *mask, int vector)

Ack.

Ack. The hyperv PV code is also affected (__send_ipi_mask_ex).

Quoted 3 lines
Signature · 2 lines
-- 
Philippe.