Drop the superfluous kvm_hv_set_sint() and instead wire up ->set() directly
to its final destination.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/hyperv.c | 10 +++++++---
arch/x86/kvm/hyperv.h | 3 ++-
arch/x86/kvm/irq_comm.c | 12 ------------
3 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 24f0318c50d7..7f565636edde 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -497,15 +497,19 @@ static int synic_set_irq(struct kvm_vcpu_hv_synic *synic, u32 sint)
return ret;
}
-int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vpidx, u32 sint)
+int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm,
+ int irq_source_id, int level, bool line_status)
{
struct kvm_vcpu_hv_synic *synic;
- synic = synic_get(kvm, vpidx);
+ if (!level)
+ return -1;
+
+ synic = synic_get(kvm, e->hv_sint.vcpu);
if (!synic)
return -EINVAL;
- return synic_set_irq(synic, sint);
+ return synic_set_irq(synic, e->hv_sint.sint);
}
void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector)
diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h
index 913bfc96959c..4ad5a0749739 100644
--- a/arch/x86/kvm/hyperv.h
+++ b/arch/x86/kvm/hyperv.h
@@ -103,7 +103,8 @@ static inline bool kvm_hv_hypercall_enabled(struct kvm_vcpu *vcpu)
int kvm_hv_hypercall(struct kvm_vcpu *vcpu);
void kvm_hv_irq_routing_update(struct kvm *kvm);
-int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vcpu_id, u32 sint);
+int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm,
+ int irq_source_id, int level, bool line_status);
void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector);
int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages);
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 8dcb6a555902..b85e4be2ddff 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -127,18 +127,6 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
return kvm_irq_delivery_to_apic(kvm, NULL, &irq, NULL);
}
-#ifdef CONFIG_KVM_HYPERV
-static int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e,
- struct kvm *kvm, int irq_source_id, int level,
- bool line_status)
-{
- if (!level)
- return -1;
-
- return kvm_hv_synic_set_irq(kvm, e->hv_sint.vcpu, e->hv_sint.sint);
-}
-#endif
-
int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
struct kvm *kvm, int irq_source_id, int level,
bool line_status)
--
2.49.0.1101.gccaa498523-goog
On Mon, 2025-05-19 at 16:27 -0700, Sean Christopherson wrote:
> Drop the superfluous kvm_hv_set_sint() and instead wire up ->set() directly
> to its final destination.
kvm_hv_set_sint() is still there after this patch. Did you mean "superfluous
kvm_hv_synic_set_irq()"? :-)
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/hyperv.c | 10 +++++++---
> arch/x86/kvm/hyperv.h | 3 ++-
> arch/x86/kvm/irq_comm.c | 12 ------------
> 3 files changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 24f0318c50d7..7f565636edde 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -497,15 +497,19 @@ static int synic_set_irq(struct kvm_vcpu_hv_synic *synic, u32 sint)
> return ret;
> }
>
> -int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vpidx, u32 sint)
> +int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm,
> + int irq_source_id, int level, bool line_status)
> {
> struct kvm_vcpu_hv_synic *synic;
>
> - synic = synic_get(kvm, vpidx);
> + if (!level)
> + return -1;
> +
> + synic = synic_get(kvm, e->hv_sint.vcpu);
> if (!synic)
> return -EINVAL;
>
> - return synic_set_irq(synic, sint);
> + return synic_set_irq(synic, e->hv_sint.sint);
> }
>
> void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector)
> diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h
> index 913bfc96959c..4ad5a0749739 100644
> --- a/arch/x86/kvm/hyperv.h
> +++ b/arch/x86/kvm/hyperv.h
> @@ -103,7 +103,8 @@ static inline bool kvm_hv_hypercall_enabled(struct kvm_vcpu *vcpu)
> int kvm_hv_hypercall(struct kvm_vcpu *vcpu);
>
> void kvm_hv_irq_routing_update(struct kvm *kvm);
> -int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vcpu_id, u32 sint);
> +int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm,
> + int irq_source_id, int level, bool line_status);
> void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector);
> int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages);
>
> diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
> index 8dcb6a555902..b85e4be2ddff 100644
> --- a/arch/x86/kvm/irq_comm.c
> +++ b/arch/x86/kvm/irq_comm.c
> @@ -127,18 +127,6 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
> return kvm_irq_delivery_to_apic(kvm, NULL, &irq, NULL);
> }
>
> -#ifdef CONFIG_KVM_HYPERV
> -static int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e,
> - struct kvm *kvm, int irq_source_id, int level,
> - bool line_status)
> -{
> - if (!level)
> - return -1;
> -
> - return kvm_hv_synic_set_irq(kvm, e->hv_sint.vcpu, e->hv_sint.sint);
> -}
> -#endif
> -
> int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
> struct kvm *kvm, int irq_source_id, int level,
> bool line_status)
On Thu, May 29, 2025, Kai Huang wrote: > On Mon, 2025-05-19 at 16:27 -0700, Sean Christopherson wrote: > > Drop the superfluous kvm_hv_set_sint() and instead wire up ->set() directly > > to its final destination. > > kvm_hv_set_sint() is still there after this patch. Did you mean "superfluous > kvm_hv_synic_set_irq()"? :-) Ugh, yeah, bad changelog. Maybe this? Rename kvm_hv_synic_set_irq() to kvm_hv_set_sint() and drop the previous incarnation of kvm_hv_set_sint() provided by irq_comm.c, which is just a wrapper to the hyperv.c code. That said, given that the tracepoint is trace_kvm_hv_synic_set_irq(), and that the IOAPIC and PIC versions are kvm_ioapic_set_irq() and kvm_pic_set_irq() respectively, I'm leaning towards a straight drop of kvm_hv_set_sint(), i.e. keep kvm_hv_synic_set_irq().
On Thu, 2025-05-29 at 07:39 -0700, Sean Christopherson wrote: > On Thu, May 29, 2025, Kai Huang wrote: > > On Mon, 2025-05-19 at 16:27 -0700, Sean Christopherson wrote: > > > Drop the superfluous kvm_hv_set_sint() and instead wire up ->set() directly > > > to its final destination. > > > > kvm_hv_set_sint() is still there after this patch. Did you mean "superfluous > > kvm_hv_synic_set_irq()"? :-) > > Ugh, yeah, bad changelog. Maybe this? > > Rename kvm_hv_synic_set_irq() to kvm_hv_set_sint() and drop the previous > incarnation of kvm_hv_set_sint() provided by irq_comm.c, which is just a > wrapper to the hyperv.c code. > > That said, given that the tracepoint is trace_kvm_hv_synic_set_irq(), and that > the IOAPIC and PIC versions are kvm_ioapic_set_irq() and kvm_pic_set_irq() > respectively, I'm leaning towards a straight drop of kvm_hv_set_sint(), i.e. keep > kvm_hv_synic_set_irq(). Yeah LGTM. Thanks.
Sean Christopherson <seanjc@google.com> writes:
> Drop the superfluous kvm_hv_set_sint() and instead wire up ->set() directly
> to its final destination.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Nitpick: synic_set_irq() still has trace_kvm_hv_synic_set_irq() but
kvm_hv_synic_set_irq() is now gone, I think it may make sense to rename
it to e.g. 'trace_kvm_hv_set_sint' or 'trace_synic_set_irq' to avoid any
confusion.
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> arch/x86/kvm/hyperv.c | 10 +++++++---
> arch/x86/kvm/hyperv.h | 3 ++-
> arch/x86/kvm/irq_comm.c | 12 ------------
> 3 files changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 24f0318c50d7..7f565636edde 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -497,15 +497,19 @@ static int synic_set_irq(struct kvm_vcpu_hv_synic *synic, u32 sint)
> return ret;
> }
>
> -int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vpidx, u32 sint)
> +int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm,
> + int irq_source_id, int level, bool line_status)
> {
> struct kvm_vcpu_hv_synic *synic;
>
> - synic = synic_get(kvm, vpidx);
> + if (!level)
> + return -1;
> +
> + synic = synic_get(kvm, e->hv_sint.vcpu);
> if (!synic)
> return -EINVAL;
>
> - return synic_set_irq(synic, sint);
> + return synic_set_irq(synic, e->hv_sint.sint);
> }
>
> void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector)
> diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h
> index 913bfc96959c..4ad5a0749739 100644
> --- a/arch/x86/kvm/hyperv.h
> +++ b/arch/x86/kvm/hyperv.h
> @@ -103,7 +103,8 @@ static inline bool kvm_hv_hypercall_enabled(struct kvm_vcpu *vcpu)
> int kvm_hv_hypercall(struct kvm_vcpu *vcpu);
>
> void kvm_hv_irq_routing_update(struct kvm *kvm);
> -int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vcpu_id, u32 sint);
> +int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm,
> + int irq_source_id, int level, bool line_status);
> void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector);
> int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages);
>
> diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
> index 8dcb6a555902..b85e4be2ddff 100644
> --- a/arch/x86/kvm/irq_comm.c
> +++ b/arch/x86/kvm/irq_comm.c
> @@ -127,18 +127,6 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
> return kvm_irq_delivery_to_apic(kvm, NULL, &irq, NULL);
> }
>
> -#ifdef CONFIG_KVM_HYPERV
> -static int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e,
> - struct kvm *kvm, int irq_source_id, int level,
> - bool line_status)
> -{
> - if (!level)
> - return -1;
> -
> - return kvm_hv_synic_set_irq(kvm, e->hv_sint.vcpu, e->hv_sint.sint);
> -}
> -#endif
> -
> int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
> struct kvm *kvm, int irq_source_id, int level,
> bool line_status)
--
Vitaly
© 2016 - 2025 Red Hat, Inc.