* [PATCH Dovetail 6.17 v3 1/4] clocksource/hyper-v: irq_pipeline: Enable pipelined clock events
2025-10-21 12:23 [PATCH Dovetail 6.17 v3 0/4] dovetail: Add support for hyper-v as hypervisor Florian Bezdeka
@ 2025-10-21 12:23 ` Florian Bezdeka
2025-10-21 12:47 ` Philippe Gerum
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 2/4] x86: irq_pipeline: Implement inband handler for hyper-v specific vectors Florian Bezdeka
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Florian Bezdeka @ 2025-10-21 12:23 UTC (permalink / raw)
To: xenomai; +Cc: Jan Kiszka, Philippe Gerum, Florian Bezdeka
Make the clock event around the STIMER0 pipeline safe. The
implementation is following the same pattern that we already have in
place for the x86 LAPIC interrupt / clock event.
To get the proxy tick working we need to link the hyperv clock event
device with the STIMER0 vector. This part is also following the pattern
of the x86 lapic interrupt. Both have a fixed arch specific vector
assigned.
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
drivers/clocksource/hyperv_timer.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index 2edc13ca184e0..0850b0c385a8e 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -26,6 +26,7 @@
#include <clocksource/hyperv_timer.h>
#include <hyperv/hvhdk.h>
#include <asm/mshyperv.h>
+#include <asm/trace/irq_vectors.h>
static struct clock_event_device __percpu *hv_clock_event;
/* Note: offset can hold negative values after hibernation. */
@@ -53,6 +54,30 @@ static int stimer0_irq = -1;
static int stimer0_message_sint;
static __maybe_unused DEFINE_PER_CPU(long, stimer0_evt);
+#ifdef CONFIG_IRQ_PIPELINE
+
+#define HV_STIMER_IRQ apicm_vector_irq(HYPERV_STIMER0_VECTOR)
+
+static irqreturn_t hv_stimer_oob_handler(int irq, void *dev_id)
+{
+ struct clock_event_device *evt = this_cpu_ptr(hv_clock_event);
+
+ trace_local_timer_entry(HYPERV_STIMER0_VECTOR);
+ clockevents_handle_event(evt);
+ trace_local_timer_exit(HYPERV_STIMER0_VECTOR);
+
+ return IRQ_HANDLED;
+}
+
+static struct irqaction hv_stimer_oob_action = {
+ .handler = hv_stimer_oob_handler,
+ .name = "Out-of-band STIMER0 timer interrupt",
+ .flags = IRQF_TIMER | IRQF_PERCPU,
+};
+#else
+#define HV_STIMER_IRQ -1
+#endif
+
/*
* Common code for stimer0 interrupts coming via Direct Mode or
* as a VMbus message.
@@ -137,8 +162,9 @@ static int hv_stimer_init(unsigned int cpu)
ce = per_cpu_ptr(hv_clock_event, cpu);
ce->name = "Hyper-V clockevent";
- ce->features = CLOCK_EVT_FEAT_ONESHOT;
+ ce->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PIPELINE;
ce->cpumask = cpumask_of(cpu);
+ ce->irq = HV_STIMER_IRQ;
/*
* Lower the rating of the Hyper-V timer in a TDX VM without paravisor,
@@ -305,6 +331,12 @@ int hv_stimer_alloc(bool have_percpu_irqs)
hv_remove_stimer0_irq();
goto free_clock_event;
}
+
+#ifdef CONFIG_IRQ_PIPELINE
+ ret = setup_percpu_irq(HV_STIMER_IRQ, &hv_stimer_oob_action);
+ if (ret)
+ goto free_clock_event;
+#endif
return ret;
free_clock_event:
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH Dovetail 6.17 v3 2/4] x86: irq_pipeline: Implement inband handler for hyper-v specific vectors
2025-10-21 12:23 [PATCH Dovetail 6.17 v3 0/4] dovetail: Add support for hyper-v as hypervisor Florian Bezdeka
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 1/4] clocksource/hyper-v: irq_pipeline: Enable pipelined clock events Florian Bezdeka
@ 2025-10-21 12:23 ` Florian Bezdeka
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 3/4] hyper-v: x86: dovetail: Close race window in PV spinlocks Florian Bezdeka
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 4/4] x86: irq_pipeline: Allow CONFIG_HYPERV in combination with CONFIG_DOVETAIL Florian Bezdeka
3 siblings, 0 replies; 6+ messages in thread
From: Florian Bezdeka @ 2025-10-21 12:23 UTC (permalink / raw)
To: xenomai; +Cc: Jan Kiszka, Philippe Gerum, Florian Bezdeka
Both vectors were already routed to the inband stage but were not
implemented / handled there. We ended up ignoring those IRQs. That
resulted in a boot hang on hyper-v.
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
arch/x86/kernel/irq_pipeline.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/x86/kernel/irq_pipeline.c b/arch/x86/kernel/irq_pipeline.c
index 1d6dfc6e95122..d6162310929c6 100644
--- a/arch/x86/kernel/irq_pipeline.c
+++ b/arch/x86/kernel/irq_pipeline.c
@@ -160,6 +160,15 @@ static void do_sysvec_inband(struct irq_desc *desc, struct pt_regs *regs)
case POSTED_INTR_NESTED_VECTOR:
run_sysvec_on_irqstack_cond(__sysvec_kvm_posted_intr_nested_ipi, regs);
break;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+ case HYPERV_REENLIGHTENMENT_VECTOR:
+ run_sysvec_on_irqstack_cond(__sysvec_hyperv_reenlightenment,
+ regs);
+ break;
+ case HYPERV_STIMER0_VECTOR:
+ run_sysvec_on_irqstack_cond(__sysvec_hyperv_stimer0, regs);
+ break;
#endif
case HYPERVISOR_CALLBACK_VECTOR:
run_sysvec_on_irqstack_cond(pipeline_hv_callback, regs);
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH Dovetail 6.17 v3 3/4] hyper-v: x86: dovetail: Close race window in PV spinlocks
2025-10-21 12:23 [PATCH Dovetail 6.17 v3 0/4] dovetail: Add support for hyper-v as hypervisor Florian Bezdeka
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 1/4] clocksource/hyper-v: irq_pipeline: Enable pipelined clock events Florian Bezdeka
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 2/4] x86: irq_pipeline: Implement inband handler for hyper-v specific vectors Florian Bezdeka
@ 2025-10-21 12:23 ` Florian Bezdeka
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 4/4] x86: irq_pipeline: Allow CONFIG_HYPERV in combination with CONFIG_DOVETAIL Florian Bezdeka
3 siblings, 0 replies; 6+ messages in thread
From: Florian Bezdeka @ 2025-10-21 12:23 UTC (permalink / raw)
To: xenomai; +Cc: Jan Kiszka, Philippe Gerum, Florian Bezdeka
Stalling the in-band stage is not enough, we have to disable hard IRQs
to avoid additional instructions between the comparison of the value
and the rdmsrl() - as explained in the comment above.
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
arch/x86/hyperv/hv_spinlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/hyperv/hv_spinlock.c b/arch/x86/hyperv/hv_spinlock.c
index 81b006601370c..282a0c69c9110 100644
--- a/arch/x86/hyperv/hv_spinlock.c
+++ b/arch/x86/hyperv/hv_spinlock.c
@@ -44,7 +44,7 @@ static void hv_qlock_wait(u8 *byte, u8 val)
* into 'idle' state by the hypervisor and kept in that state for
* an unspecified amount of time.
*/
- local_irq_save(flags);
+ flags = hard_local_irq_save();
/*
* Only issue the rdmsrq() when the lock state has not changed.
*/
@@ -55,7 +55,7 @@ static void hv_qlock_wait(u8 *byte, u8 val)
(void)msr_val;
}
- local_irq_restore(flags);
+ hard_local_irq_restore(flags);
}
/*
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH Dovetail 6.17 v3 4/4] x86: irq_pipeline: Allow CONFIG_HYPERV in combination with CONFIG_DOVETAIL
2025-10-21 12:23 [PATCH Dovetail 6.17 v3 0/4] dovetail: Add support for hyper-v as hypervisor Florian Bezdeka
` (2 preceding siblings ...)
2025-10-21 12:23 ` [PATCH Dovetail 6.17 v3 3/4] hyper-v: x86: dovetail: Close race window in PV spinlocks Florian Bezdeka
@ 2025-10-21 12:23 ` Florian Bezdeka
3 siblings, 0 replies; 6+ messages in thread
From: Florian Bezdeka @ 2025-10-21 12:23 UTC (permalink / raw)
To: xenomai; +Cc: Jan Kiszka, Philippe Gerum, Florian Bezdeka
No known issues anymore, so we can allow that combination now.
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
drivers/hv/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index cf9cf77ac2187..6c7e76fd1b01e 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -5,7 +5,7 @@ menu "Microsoft Hyper-V guest support"
config HYPERV
tristate "Microsoft Hyper-V client drivers"
depends on ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
- || (ARM64 && !CPU_BIG_ENDIAN)) && !IRQ_PIPELINE
+ || (ARM64 && !CPU_BIG_ENDIAN))
select PARAVIRT
select X86_HV_CALLBACK_VECTOR if X86
select OF_EARLY_FLATTREE if OF
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread