xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: xen: fix hvm_domain_use_pirq's behavior
Date: Wed, 31 Aug 2011 11:24:04 +0100	[thread overview]
Message-ID: <1314786246-15149-1-git-send-email-stefano.stabellini@eu.citrix.com> (raw)

hvm_domain_use_pirq should return true when the guest is using a certain
pirq, no matter if the corresponding event channel is currently enabled
or disabled.  As an additional complication, qemu is going to request
pirqs for passthrough devices even for Xen unaware HVM guests, so we
need to wait for an event channel to be connected before considering the
pirq of a passthrough device as "in use".

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

diff -r 1515138fbd7b xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c	Wed Aug 24 09:33:10 2011 +0100
+++ b/xen/arch/x86/irq.c	Tue Aug 30 11:56:21 2011 +0000
@@ -2024,6 +2024,5 @@ int unmap_domain_pirq_emuirq(struct doma
 bool_t hvm_domain_use_pirq(const struct domain *d, const struct pirq *pirq)
 {
     return is_hvm_domain(d) && pirq &&
-           pirq->arch.hvm.emuirq != IRQ_UNBOUND &&
-           pirq->evtchn != 0;
+           pirq->arch.hvm.emuirq != IRQ_UNBOUND; 
 }
diff -r 1515138fbd7b xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c	Wed Aug 24 09:33:10 2011 +0100
+++ b/xen/arch/x86/physdev.c	Tue Aug 30 11:56:21 2011 +0000
@@ -196,9 +196,6 @@ int physdev_map_pirq(domid_t domid, int 
     if ( ret == 0 )
         *pirq_p = pirq;
 
-    if ( !ret && is_hvm_domain(d) )
-        map_domain_emuirq_pirq(d, pirq, IRQ_PT);
-
  done:
     spin_unlock(&d->event_lock);
     spin_unlock(&pcidevs_lock);
@@ -271,7 +268,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
              v->domain->arch.pv_domain.pirq_eoi_map )
             evtchn_unmask(pirq->evtchn);
         if ( !is_hvm_domain(v->domain) ||
-             pirq->arch.hvm.emuirq == IRQ_PT )
+             domain_pirq_to_irq(v->domain, eoi.irq) > 0 )
             pirq_guest_eoi(pirq);
         spin_unlock(&v->domain->event_lock);
         ret = 0;
@@ -331,7 +328,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
             break;
         irq_status_query.flags = 0;
         if ( is_hvm_domain(v->domain) &&
-             domain_pirq_to_emuirq(v->domain, irq) != IRQ_PT )
+             domain_pirq_to_irq(v->domain, irq) <= 0 )
         {
             ret = copy_to_guest(arg, &irq_status_query, 1) ? -EFAULT : 0;
             break;
diff -r 1515138fbd7b xen/common/event_channel.c
--- a/xen/common/event_channel.c	Wed Aug 24 09:33:10 2011 +0100
+++ b/xen/common/event_channel.c	Tue Aug 30 11:56:21 2011 +0000
@@ -366,6 +366,9 @@ static long evtchn_bind_pirq(evtchn_bind
 
     bind->port = port;
 
+    if ( is_hvm_domain(d) && domain_pirq_to_irq(d, pirq) > 0 )
+        map_domain_emuirq_pirq(d, pirq, IRQ_PT);
+
  out:
     spin_unlock(&d->event_lock);
 
@@ -419,6 +422,8 @@ static long __evtchn_close(struct domain
         pirq->evtchn = 0;
         pirq_cleanup_check(pirq, d1);
         unlink_pirq_port(chn1, d1->vcpu[chn1->notify_vcpu_id]);
+        if ( is_hvm_domain(d1) && domain_pirq_to_irq(d1, pirq->pirq) > 0 )
+            unmap_domain_pirq_emuirq(d1, pirq->pirq);
         break;
     }

             reply	other threads:[~2011-08-31 10:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-31 10:24 stefano.stabellini [this message]
2011-08-31 10:24 ` xen: __hvm_pci_intx_assert should check for gsis remapped onto pirqs stefano.stabellini
2011-08-31 10:27   ` Stefano Stabellini
2011-08-31 10:24 ` xen: get_free_pirq: make sure that the returned pirq is allocated stefano.stabellini
2011-08-31 10:26 ` xen: fix hvm_domain_use_pirq's behavior Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314786246-15149-1-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).