All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Stefan Bader <stefan.bader@canonical.com>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 1/2] x86/vpt: execute callbacks for masked interrupts
Date: Fri, 30 Mar 2018 13:35:59 +0100	[thread overview]
Message-ID: <20180330123600.22716-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20180330123600.22716-1-roger.pau@citrix.com>

Execute periodic_time callbacks even if the interrupt is not actually
injected because the IRQ is masked.

Current callbacks from emulated timer devices only update emulated
registers, which from my reading of the specs should happen regardless
of whether the interrupt has been injected or not.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
---
Changes since v1:
 - s/purged/to_purge/.
 - Force caller of execute_callbacks to hold the lock.
---
 xen/arch/x86/hvm/vpt.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c
index 9d27b483b2..e6c2aa01ac 100644
--- a/xen/arch/x86/hvm/vpt.c
+++ b/xen/arch/x86/hvm/vpt.c
@@ -247,9 +247,29 @@ static void pt_timer_fn(void *data)
     pt_unlock(pt);
 }
 
+static void execute_callbacks(struct vcpu *v, struct list_head *tm)
+{
+    while ( !list_empty(tm) )
+    {
+        struct periodic_time *pt = list_first_entry(tm, struct periodic_time,
+                                                    list);
+        time_cb *cb = pt->cb;
+        void *cb_priv = pt->priv;
+
+        list_del(&pt->list);
+        pt->on_list = 0;
+        spin_unlock(&v->arch.hvm_vcpu.tm_lock);
+
+        cb(v, cb_priv);
+
+        spin_lock(&v->arch.hvm_vcpu.tm_lock);
+    }
+}
+
 int pt_update_irq(struct vcpu *v)
 {
     struct list_head *head = &v->arch.hvm_vcpu.tm_list;
+    LIST_HEAD(to_purge);
     struct periodic_time *pt, *temp, *earliest_pt;
     uint64_t max_lag;
     int irq, is_lapic, pt_vector;
@@ -267,7 +287,10 @@ int pt_update_irq(struct vcpu *v)
             {
                 /* suspend timer emulation */
                 list_del(&pt->list);
-                pt->on_list = 0;
+                if ( pt->cb )
+                    list_add(&pt->list, &to_purge);
+                else
+                    pt->on_list = 0;
             }
             else
             {
@@ -282,6 +305,12 @@ int pt_update_irq(struct vcpu *v)
 
     if ( earliest_pt == NULL )
     {
+        /*
+         * NB: although the to_purge list is local, calls to
+         * destroy_periodic_time can still remove items from the list, hence
+         * the need to hold the lock while accessing it.
+         */
+        execute_callbacks(v, &to_purge);
         spin_unlock(&v->arch.hvm_vcpu.tm_lock);
         return -1;
     }
@@ -290,6 +319,8 @@ int pt_update_irq(struct vcpu *v)
     irq = earliest_pt->irq;
     is_lapic = (earliest_pt->source == PTSRC_lapic);
 
+    execute_callbacks(v, &to_purge);
+
     spin_unlock(&v->arch.hvm_vcpu.tm_lock);
 
     /*
-- 
2.16.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-03-30 12:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30 12:35 [PATCH v2 0/2] hpet: add support for level triggered interrupts Roger Pau Monne
2018-03-30 12:35 ` Roger Pau Monne [this message]
2018-04-09 15:34   ` [PATCH v2 1/2] x86/vpt: execute callbacks for masked interrupts Jan Beulich
2018-04-10  8:53     ` Roger Pau Monné
2018-04-10  9:33       ` Jan Beulich
2018-03-30 12:36 ` [PATCH v2 2/2] vhpet: add support for level triggered interrupts Roger Pau Monne
2018-04-09 15:51   ` Jan Beulich

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=20180330123600.22716-2-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=stefan.bader@canonical.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.