diff mbox series

[v2,30/35] x86/hvm: add helpers for raising guest IRQs

Message ID 20241205-vuart-ns8250-v1-30-e9aa923127eb@ford.com (mailing list archive)
State New
Headers show
Series Introduce NS8250 UART emulator | expand

Commit Message

Denis Mukhin via B4 Relay Dec. 6, 2024, 4:42 a.m. UTC
From: Denis Mukhin <dmukhin@ford.com>

Added convenience wrappers for asserting/de-asserting interrupts in the
hardware emulation code.

That will be used for PCI-based NS8250 emulator.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
 xen/arch/x86/hvm/irq.c             | 24 ++++++++++++++++++++++++
 xen/arch/x86/include/asm/hvm/irq.h |  3 +++
 2 files changed, 27 insertions(+)

Comments

Roger Pau Monné Dec. 12, 2024, 4:18 p.m. UTC | #1
On Thu, Dec 05, 2024 at 08:42:00PM -0800, Denis Mukhin via B4 Relay wrote:
> From: Denis Mukhin <dmukhin@ford.com>
> 
> Added convenience wrappers for asserting/de-asserting interrupts in the
> hardware emulation code.
> 
> That will be used for PCI-based NS8250 emulator.

Strictly speaking the ns8250 uart should only generate ISA interrupts
as I understand it, as it only uses IRQs 3 and 4?  IOW from that code
you should only need to use hvm_isa_irq_assert().

> 
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
>  xen/arch/x86/hvm/irq.c             | 24 ++++++++++++++++++++++++
>  xen/arch/x86/include/asm/hvm/irq.h |  3 +++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
> index 1eab44defca4c82ec35769617c66c380cc07d1b6..9e3a50d21dcf281c1015116094e47795c51ed5d0 100644
> --- a/xen/arch/x86/hvm/irq.c
> +++ b/xen/arch/x86/hvm/irq.c
> @@ -242,6 +242,30 @@ void hvm_isa_irq_deassert(
>      spin_unlock(&d->arch.hvm.irq_lock);
>  }
>  
> +void hvm_irq_raise(struct domain *d, unsigned int irq)
> +{
> +    if ( irq < NR_ISAIRQS )
> +    {
> +        hvm_isa_irq_assert(d, irq, NULL);
> +    }
> +    else
> +    {
> +        hvm_gsi_assert(d, irq);
> +    }
> +}
> +
> +void hvm_irq_lower(struct domain *d, unsigned int irq)

It would be better to use the assert/deassert nomenclature, like it's
used for the functions that are called.

> +{
> +    if ( irq < NR_ISAIRQS )
> +    {
> +        hvm_isa_irq_deassert(d, irq);
> +    }
> +    else
> +    {
> +        hvm_gsi_deassert(d, irq);
> +    }
> +}

The parameter to thins function is kind of fuzzy, as I understand it,
if the parameter is < NR_ISAIRQS it's an ISA IRQ, while if it's >=
NR_ISAIRQS it's a GSI?

It would also be helpul to mention that hvm_isa_irq_deassert() will
already do the ISA IRQ -> GSI conversion in case there are any source
overrides.

Thanks, Roger.
diff mbox series

Patch

diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
index 1eab44defca4c82ec35769617c66c380cc07d1b6..9e3a50d21dcf281c1015116094e47795c51ed5d0 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -242,6 +242,30 @@  void hvm_isa_irq_deassert(
     spin_unlock(&d->arch.hvm.irq_lock);
 }
 
+void hvm_irq_raise(struct domain *d, unsigned int irq)
+{
+    if ( irq < NR_ISAIRQS )
+    {
+        hvm_isa_irq_assert(d, irq, NULL);
+    }
+    else
+    {
+        hvm_gsi_assert(d, irq);
+    }
+}
+
+void hvm_irq_lower(struct domain *d, unsigned int irq)
+{
+    if ( irq < NR_ISAIRQS )
+    {
+        hvm_isa_irq_deassert(d, irq);
+    }
+    else
+    {
+        hvm_gsi_deassert(d, irq);
+    }
+}
+
 static void hvm_set_callback_irq_level(struct vcpu *v)
 {
     struct domain *d = v->domain;
diff --git a/xen/arch/x86/include/asm/hvm/irq.h b/xen/arch/x86/include/asm/hvm/irq.h
index 87e89993a44f48f366fa84e851688f383cb562d4..27bb9f64171c1b8aac2cf119699e60c91e727177 100644
--- a/xen/arch/x86/include/asm/hvm/irq.h
+++ b/xen/arch/x86/include/asm/hvm/irq.h
@@ -210,6 +210,9 @@  void hvm_maybe_deassert_evtchn_irq(void);
 void hvm_assert_evtchn_irq(struct vcpu *v);
 void hvm_set_callback_via(struct domain *d, uint64_t via);
 
+void hvm_irq_raise(struct domain *d, unsigned int irq);
+void hvm_irq_lower(struct domain *d, unsigned int irq);
+
 struct pirq;
 bool hvm_domain_use_pirq(const struct domain *d, const struct pirq *pirq);